Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #817 from archshift/disabledcolor
Fixed toolbar's disabled button color.
  • Loading branch information
lioncash committed Aug 23, 2014
2 parents 41577f0 + b7f3797 commit 6a74f5e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 43 deletions.
12 changes: 5 additions & 7 deletions Source/Core/DolphinWX/Debugger/CodeWindow.cpp
Expand Up @@ -618,16 +618,14 @@ void CCodeWindow::PopulateToolbar(wxToolBar* toolBar)
h = m_Bitmaps[0].GetHeight();

toolBar->SetToolBitmapSize(wxSize(w, h));
toolBar->AddTool(IDM_STEP, _("Step"), m_Bitmaps[Toolbar_Step]);
toolBar->AddTool(IDM_STEPOVER, _("Step Over"), m_Bitmaps[Toolbar_StepOver]);
toolBar->AddTool(IDM_SKIP, _("Skip"), m_Bitmaps[Toolbar_Skip]);
WxUtils::AddToolbarButton(toolBar, IDM_STEP, _("Step"), m_Bitmaps[Toolbar_Step], _("Step into the next instruction"));
WxUtils::AddToolbarButton(toolBar, IDM_STEPOVER, _("Step Over"), m_Bitmaps[Toolbar_StepOver], _("Step over the next instruction"));
WxUtils::AddToolbarButton(toolBar, IDM_SKIP, _("Skip"), m_Bitmaps[Toolbar_Skip], _("Skips the next instruction completely"));
toolBar->AddSeparator();
toolBar->AddTool(IDM_GOTOPC, _("Show PC"), m_Bitmaps[Toolbar_GotoPC]);
toolBar->AddTool(IDM_SETPC, _("Set PC"), m_Bitmaps[Toolbar_SetPC]);
WxUtils::AddToolbarButton(toolBar, IDM_GOTOPC, _("Show PC"), m_Bitmaps[Toolbar_GotoPC], _("Go to the current instruction"));
WxUtils::AddToolbarButton(toolBar, IDM_SETPC, _("Set PC"), m_Bitmaps[Toolbar_SetPC], _("Set the current instruction"));
toolBar->AddSeparator();
toolBar->AddControl(new wxTextCtrl(toolBar, IDM_ADDRBOX, ""));

toolBar->Realize();
}

// Update GUI
Expand Down
67 changes: 31 additions & 36 deletions Source/Core/DolphinWX/FrameTools.cpp
Expand Up @@ -463,8 +463,8 @@ wxString CFrame::GetMenuLabel(int Id)
break;

case HK_SAVE_FIRST_STATE: Label = _("Save Oldest State"); break;
case HK_UNDO_LOAD_STATE: Label = _("Undo Load State"); break;
case HK_UNDO_SAVE_STATE: Label = _("Undo Save State"); break;
case HK_UNDO_LOAD_STATE: Label = _("Undo Load State"); break;
case HK_UNDO_SAVE_STATE: Label = _("Undo Save State"); break;

default:
Label = wxString::Format(_("Undefined %i"), Id);
Expand All @@ -490,52 +490,47 @@ void CFrame::PopulateToolbar(wxToolBar* ToolBar)
ToolBar->SetToolBitmapSize(wxSize(w, h));


ToolBar->AddTool(wxID_OPEN, _("Open"), m_Bitmaps[Toolbar_FileOpen], _("Open file..."));
ToolBar->AddTool(wxID_REFRESH, _("Refresh"), m_Bitmaps[Toolbar_Refresh], _("Refresh game list"));
ToolBar->AddTool(IDM_BROWSE, _("Browse"), m_Bitmaps[Toolbar_Browse], _("Browse for an ISO directory..."));
WxUtils::AddToolbarButton(ToolBar, wxID_OPEN, _("Open"), m_Bitmaps[Toolbar_FileOpen], _("Open file..."));
WxUtils::AddToolbarButton(ToolBar, wxID_REFRESH, _("Refresh"), m_Bitmaps[Toolbar_Refresh], _("Refresh game list"));
WxUtils::AddToolbarButton(ToolBar, IDM_BROWSE, _("Browse"), m_Bitmaps[Toolbar_Browse], _("Browse for an ISO directory..."));
ToolBar->AddSeparator();
ToolBar->AddTool(IDM_PLAY, _("Play"), m_Bitmaps[Toolbar_Play], _("Play"));
ToolBar->AddTool(IDM_STOP, _("Stop"), m_Bitmaps[Toolbar_Stop], _("Stop"));
ToolBar->AddTool(IDM_TOGGLE_FULLSCREEN, _("FullScr"), m_Bitmaps[Toolbar_FullScreen], _("Toggle Fullscreen"));
ToolBar->AddTool(IDM_SCREENSHOT, _("ScrShot"), m_Bitmaps[Toolbar_Screenshot], _("Take Screenshot"));
WxUtils::AddToolbarButton(ToolBar, IDM_PLAY, _("Play"), m_Bitmaps[Toolbar_Play], _("Play"));
WxUtils::AddToolbarButton(ToolBar, IDM_STOP, _("Stop"), m_Bitmaps[Toolbar_Stop], _("Stop"));
WxUtils::AddToolbarButton(ToolBar, IDM_TOGGLE_FULLSCREEN, _("FullScr"), m_Bitmaps[Toolbar_FullScreen], _("Toggle Fullscreen"));
WxUtils::AddToolbarButton(ToolBar, IDM_SCREENSHOT, _("ScrShot"), m_Bitmaps[Toolbar_Screenshot], _("Take Screenshot"));
ToolBar->AddSeparator();
ToolBar->AddTool(wxID_PREFERENCES, _("Config"), m_Bitmaps[Toolbar_ConfigMain], _("Configure..."));
ToolBar->AddTool(IDM_CONFIG_GFX_BACKEND, _("Graphics"), m_Bitmaps[Toolbar_ConfigGFX], _("Graphics settings"));
ToolBar->AddTool(IDM_CONFIG_DSP_EMULATOR, _("DSP"), m_Bitmaps[Toolbar_ConfigDSP], _("DSP settings"));
ToolBar->AddTool(IDM_CONFIG_PAD_PLUGIN, _("GCPad"), m_Bitmaps[Toolbar_ConfigPAD], _("GameCube Pad settings"));
ToolBar->AddTool(IDM_CONFIG_WIIMOTE_PLUGIN, _("Wiimote"), m_Bitmaps[Toolbar_Wiimote], _("Wiimote settings"));

// after adding the buttons to the toolbar, must call Realize() to reflect
// the changes
ToolBar->Realize();
WxUtils::AddToolbarButton(ToolBar, wxID_PREFERENCES, _("Config"), m_Bitmaps[Toolbar_ConfigMain], _("Configure..."));
WxUtils::AddToolbarButton(ToolBar, IDM_CONFIG_GFX_BACKEND, _("Graphics"), m_Bitmaps[Toolbar_ConfigGFX], _("Graphics settings"));
WxUtils::AddToolbarButton(ToolBar, IDM_CONFIG_DSP_EMULATOR, _("DSP"), m_Bitmaps[Toolbar_ConfigDSP], _("DSP settings"));
WxUtils::AddToolbarButton(ToolBar, IDM_CONFIG_PAD_PLUGIN, _("GCPad"), m_Bitmaps[Toolbar_ConfigPAD], _("GameCube Pad settings"));
WxUtils::AddToolbarButton(ToolBar, IDM_CONFIG_WIIMOTE_PLUGIN, _("Wiimote"), m_Bitmaps[Toolbar_Wiimote], _("Wiimote settings"));
}


// Delete and recreate the toolbar
void CFrame::RecreateToolbar()
{
if (m_ToolBar)
static const long TOOLBAR_STYLE = wxTB_DEFAULT_STYLE | wxTB_TEXT;

if (m_ToolBar != nullptr)
{
m_Mgr->DetachPane(m_ToolBar);
m_ToolBar->Destroy();
m_ToolBar = nullptr;
}

long TOOLBAR_STYLE = wxTB_DEFAULT_STYLE | wxTB_TEXT;
m_ToolBar = CreateToolBar(TOOLBAR_STYLE, wxID_ANY);

if (!m_ToolBar)
if (g_pCodeWindow)
{
m_ToolBar = CreateToolBar(TOOLBAR_STYLE, wxID_ANY, "TBMain");

if (g_pCodeWindow)
{
g_pCodeWindow->PopulateToolbar(m_ToolBar);
m_ToolBar->AddSeparator();
}

PopulateToolbar(m_ToolBar);
g_pCodeWindow->PopulateToolbar(m_ToolBar);
m_ToolBar->AddSeparator();
}

PopulateToolbar(m_ToolBar);
// after adding the buttons to the toolbar, must call Realize() to reflect
// the changes
m_ToolBar->Realize();

UpdateGUI();
}

Expand Down Expand Up @@ -1603,11 +1598,11 @@ void CFrame::OnFrameSkip(wxCommandEvent& event)
void CFrame::UpdateGUI()
{
// Save status
bool Initialized = Core::IsRunning();
bool Running = Core::GetState() == Core::CORE_RUN;
bool Paused = Core::GetState() == Core::CORE_PAUSE;
bool Stopping = Core::GetState() == Core::CORE_STOPPING;
bool RunningWii = Initialized && SConfig::GetInstance().m_LocalCoreStartupParameter.bWii;
bool Initialized = Core::IsRunning();
bool Running = Core::GetState() == Core::CORE_RUN;
bool Paused = Core::GetState() == Core::CORE_PAUSE;
bool Stopping = Core::GetState() == Core::CORE_STOPPING;
bool RunningWii = Initialized && SConfig::GetInstance().m_LocalCoreStartupParameter.bWii;
bool RunningGamecube = Initialized && !SConfig::GetInstance().m_LocalCoreStartupParameter.bWii;

// Make sure that we have a toolbar
Expand Down
14 changes: 14 additions & 0 deletions Source/Core/DolphinWX/WxUtils.cpp
Expand Up @@ -10,6 +10,7 @@
#include <wx/msgdlg.h>
#include <wx/mstream.h>
#include <wx/string.h>
#include <wx/toolbar.h>
#include <wx/utils.h>

#include "DolphinWX/WxUtils.h"
Expand Down Expand Up @@ -75,6 +76,19 @@ wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length)
return(wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1));
}

wxBitmap CreateDisabledButtonBitmap(const wxBitmap& original)
{
wxImage image = original.ConvertToImage();
return wxBitmap(image.ConvertToDisabled(240));
}

void AddToolbarButton(wxToolBar* toolbar, int toolID, const wxString& label, const wxBitmap& bitmap, const wxString& shortHelp)
{
// Must explicitly set the disabled button bitmap because wxWidgets
// incorrectly desaturates it instead of lightening it.
toolbar->AddTool(toolID, label, bitmap, WxUtils::CreateDisabledButtonBitmap(bitmap), wxITEM_NORMAL, shortHelp);
}

} // namespace

std::string WxStrToStr(const wxString& str)
Expand Down
7 changes: 7 additions & 0 deletions Source/Core/DolphinWX/WxUtils.h
Expand Up @@ -8,6 +8,7 @@
#include <wx/string.h>

class wxBitmap;
class wxToolBar;

// A shortcut to access the bitmaps
#define wxGetBitmapFromMemory(name) WxUtils::_wxGetBitmapFromMemory(name, sizeof(name))
Expand All @@ -28,6 +29,12 @@ double GetCurrentBitmapLogicalScale();

wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length);

// From a wxBitmap, creates the corresponding disabled version for toolbar buttons
wxBitmap CreateDisabledButtonBitmap(const wxBitmap& original);

// Helper function to add a button to a toolbar
void AddToolbarButton(wxToolBar* toolbar, int toolID, const wxString& label, const wxBitmap& bitmap, const wxString& shortHelp);

} // namespace

std::string WxStrToStr(const wxString& str);
Expand Down

0 comments on commit 6a74f5e

Please sign in to comment.