DolphinWX: Move toolbar creation to a wxToolBar subclass
This commit is contained in:
parent
2536e37ec5
commit
5e8ccb15ff
|
@ -54,6 +54,7 @@ set(GUI_SRCS
|
||||||
LogWindow.cpp
|
LogWindow.cpp
|
||||||
Main.cpp
|
Main.cpp
|
||||||
MainMenuBar.cpp
|
MainMenuBar.cpp
|
||||||
|
MainToolBar.cpp
|
||||||
MemcardManager.cpp
|
MemcardManager.cpp
|
||||||
PatchAddEdit.cpp
|
PatchAddEdit.cpp
|
||||||
PostProcessingConfigDiag.cpp
|
PostProcessingConfigDiag.cpp
|
||||||
|
|
|
@ -37,6 +37,8 @@ CConfigMain::CConfigMain(wxWindow* parent, wxWindowID id, const wxString& title,
|
||||||
Bind(wxEVT_BUTTON, &CConfigMain::OnCloseButton, this, wxID_CLOSE);
|
Bind(wxEVT_BUTTON, &CConfigMain::OnCloseButton, this, wxID_CLOSE);
|
||||||
Bind(wxDOLPHIN_CFG_REFRESH_LIST, &CConfigMain::OnSetRefreshGameListOnClose, this);
|
Bind(wxDOLPHIN_CFG_REFRESH_LIST, &CConfigMain::OnSetRefreshGameListOnClose, this);
|
||||||
|
|
||||||
|
wxDialog::SetExtraStyle(GetExtraStyle() & ~wxWS_EX_BLOCK_EVENTS);
|
||||||
|
|
||||||
CreateGUIControls();
|
CreateGUIControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include "DolphinWX/Config/InterfaceConfigPane.h"
|
#include "DolphinWX/Config/InterfaceConfigPane.h"
|
||||||
#include "DolphinWX/Frame.h"
|
#include "DolphinWX/Frame.h"
|
||||||
#include "DolphinWX/InputConfigDiag.h"
|
#include "DolphinWX/InputConfigDiag.h"
|
||||||
#include "DolphinWX/Main.h"
|
|
||||||
#include "DolphinWX/WxUtils.h"
|
#include "DolphinWX/WxUtils.h"
|
||||||
|
|
||||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
|
@ -241,6 +240,7 @@ void InterfaceConfigPane::OnThemeSelected(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
SConfig::GetInstance().theme_name = WxStrToStr(m_theme_choice->GetStringSelection());
|
SConfig::GetInstance().theme_name = WxStrToStr(m_theme_choice->GetStringSelection());
|
||||||
|
|
||||||
main_frame->InitBitmaps();
|
wxCommandEvent theme_event{DOLPHIN_EVT_RELOAD_THEME_BITMAPS};
|
||||||
main_frame->UpdateGameList();
|
theme_event.SetEventObject(this);
|
||||||
|
ProcessEvent(theme_event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include <wx/textctrl.h>
|
#include <wx/textctrl.h>
|
||||||
#include <wx/textdlg.h>
|
#include <wx/textdlg.h>
|
||||||
#include <wx/thread.h>
|
#include <wx/thread.h>
|
||||||
#include <wx/toolbar.h>
|
|
||||||
#include <wx/aui/auibar.h>
|
#include <wx/aui/auibar.h>
|
||||||
#include <wx/aui/dockart.h>
|
#include <wx/aui/dockart.h>
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
@ -58,8 +57,6 @@ CCodeWindow::CCodeWindow(const SConfig& _LocalCoreStartupParameter, CFrame* pare
|
||||||
: wxPanel(parent, id, position, size, style, name), m_sibling_panels(), Parent(parent),
|
: wxPanel(parent, id, position, size, style, name), m_sibling_panels(), Parent(parent),
|
||||||
codeview(nullptr)
|
codeview(nullptr)
|
||||||
{
|
{
|
||||||
InitBitmaps();
|
|
||||||
|
|
||||||
DebugInterface* di = &PowerPC::debug_interface;
|
DebugInterface* di = &PowerPC::debug_interface;
|
||||||
|
|
||||||
codeview = new CCodeView(di, &g_symbolDB, this, wxID_ANY);
|
codeview = new CCodeView(di, &g_symbolDB, this, wxID_ANY);
|
||||||
|
@ -140,11 +137,6 @@ wxMenuBar* CCodeWindow::GetMenuBar()
|
||||||
return Parent->GetMenuBar();
|
return Parent->GetMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxToolBar* CCodeWindow::GetToolBar()
|
|
||||||
{
|
|
||||||
return Parent->m_ToolBar;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Events
|
// Events
|
||||||
|
|
||||||
|
@ -574,36 +566,6 @@ bool CCodeWindow::JITNoBlockLinking()
|
||||||
return GetMenuBar()->IsChecked(IDM_JIT_NO_BLOCK_LINKING);
|
return GetMenuBar()->IsChecked(IDM_JIT_NO_BLOCK_LINKING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toolbar
|
|
||||||
void CCodeWindow::InitBitmaps()
|
|
||||||
{
|
|
||||||
static constexpr std::array<const char* const, Toolbar_Debug_Bitmap_Max> s_image_names{
|
|
||||||
{"toolbar_debugger_step", "toolbar_debugger_step_over", "toolbar_debugger_step_out",
|
|
||||||
"toolbar_debugger_skip", "toolbar_debugger_goto_pc", "toolbar_debugger_set_pc"}};
|
|
||||||
const wxSize tool_size = Parent->GetToolbarBitmapSize();
|
|
||||||
for (std::size_t i = 0; i < s_image_names.size(); ++i)
|
|
||||||
m_Bitmaps[i] =
|
|
||||||
WxUtils::LoadScaledResourceBitmap(s_image_names[i], Parent, tool_size, wxDefaultSize,
|
|
||||||
WxUtils::LSI_SCALE_DOWN | WxUtils::LSI_ALIGN_CENTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCodeWindow::PopulateToolbar(wxToolBar* toolBar)
|
|
||||||
{
|
|
||||||
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_STEPOUT, _("Step Out"), m_Bitmaps[Toolbar_StepOut],
|
|
||||||
_("Step out of the current function"));
|
|
||||||
WxUtils::AddToolbarButton(toolBar, IDM_SKIP, _("Skip"), m_Bitmaps[Toolbar_Skip],
|
|
||||||
_("Skips the next instruction completely"));
|
|
||||||
toolBar->AddSeparator();
|
|
||||||
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"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update GUI
|
// Update GUI
|
||||||
void CCodeWindow::Repopulate()
|
void CCodeWindow::Repopulate()
|
||||||
{
|
{
|
||||||
|
@ -625,21 +587,7 @@ void CCodeWindow::UpdateButtonStates()
|
||||||
bool Pause = (Core::GetState() == Core::CORE_PAUSE);
|
bool Pause = (Core::GetState() == Core::CORE_PAUSE);
|
||||||
bool Stepping = CPU::IsStepping();
|
bool Stepping = CPU::IsStepping();
|
||||||
bool can_step = Initialized && Stepping;
|
bool can_step = Initialized && Stepping;
|
||||||
wxToolBar* ToolBar = GetToolBar();
|
|
||||||
|
|
||||||
// Toolbar
|
|
||||||
if (!ToolBar)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ToolBar->EnableTool(IDM_STEP, can_step);
|
|
||||||
ToolBar->EnableTool(IDM_STEPOVER, can_step);
|
|
||||||
ToolBar->EnableTool(IDM_STEPOUT, can_step);
|
|
||||||
ToolBar->EnableTool(IDM_SKIP, can_step);
|
|
||||||
ToolBar->EnableTool(IDM_SETPC, Pause);
|
|
||||||
ToolBar->Realize();
|
|
||||||
|
|
||||||
// Menu bar
|
|
||||||
// ------------------
|
|
||||||
GetMenuBar()->Enable(IDM_INTERPRETER, Pause); // CPU Mode
|
GetMenuBar()->Enable(IDM_INTERPRETER, Pause); // CPU Mode
|
||||||
|
|
||||||
GetMenuBar()->Enable(IDM_STEP, can_step);
|
GetMenuBar()->Enable(IDM_STEP, can_step);
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include <wx/aui/framemanager.h>
|
#include <wx/aui/framemanager.h>
|
||||||
#include <wx/bitmap.h>
|
|
||||||
#include <wx/panel.h>
|
#include <wx/panel.h>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
@ -86,7 +85,6 @@ public:
|
||||||
|
|
||||||
// Parent interaction
|
// Parent interaction
|
||||||
wxMenuBar* GetMenuBar();
|
wxMenuBar* GetMenuBar();
|
||||||
wxToolBar* GetToolBar();
|
|
||||||
|
|
||||||
bool UseInterpreter();
|
bool UseInterpreter();
|
||||||
bool BootToPause();
|
bool BootToPause();
|
||||||
|
@ -97,7 +95,6 @@ public:
|
||||||
|
|
||||||
void Repopulate();
|
void Repopulate();
|
||||||
void NotifyMapLoaded();
|
void NotifyMapLoaded();
|
||||||
void PopulateToolbar(wxToolBar* toolBar);
|
|
||||||
void UpdateButtonStates();
|
void UpdateButtonStates();
|
||||||
void OpenPages();
|
void OpenPages();
|
||||||
|
|
||||||
|
@ -157,11 +154,8 @@ private:
|
||||||
void UpdateLists();
|
void UpdateLists();
|
||||||
void UpdateCallstack();
|
void UpdateCallstack();
|
||||||
|
|
||||||
void InitBitmaps();
|
|
||||||
wxPanel* CreateSiblingPanel(int id);
|
wxPanel* CreateSiblingPanel(int id);
|
||||||
|
|
||||||
wxBitmap m_Bitmaps[Toolbar_Debug_Bitmap_Max];
|
|
||||||
|
|
||||||
// Sibling debugger panels
|
// Sibling debugger panels
|
||||||
// FIXME: This obviously belongs in some manager class above this one.
|
// FIXME: This obviously belongs in some manager class above this one.
|
||||||
std::array<wxPanel*, IDM_DEBUG_WINDOW_LIST_END - IDM_DEBUG_WINDOW_LIST_START> m_sibling_panels;
|
std::array<wxPanel*, IDM_DEBUG_WINDOW_LIST_END - IDM_DEBUG_WINDOW_LIST_START> m_sibling_panels;
|
||||||
|
|
|
@ -111,6 +111,7 @@
|
||||||
<ClCompile Include="MainNoGUI.cpp">
|
<ClCompile Include="MainNoGUI.cpp">
|
||||||
<ExcludedFromBuild>true</ExcludedFromBuild>
|
<ExcludedFromBuild>true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="MainToolBar.cpp" />
|
||||||
<ClCompile Include="MemcardManager.cpp" />
|
<ClCompile Include="MemcardManager.cpp" />
|
||||||
<ClCompile Include="NetPlay\PadMapDialog.cpp" />
|
<ClCompile Include="NetPlay\PadMapDialog.cpp" />
|
||||||
<ClCompile Include="PatchAddEdit.cpp" />
|
<ClCompile Include="PatchAddEdit.cpp" />
|
||||||
|
@ -175,6 +176,7 @@
|
||||||
<ClInclude Include="LogWindow.h" />
|
<ClInclude Include="LogWindow.h" />
|
||||||
<ClInclude Include="Main.h" />
|
<ClInclude Include="Main.h" />
|
||||||
<ClInclude Include="MainMenuBar.h" />
|
<ClInclude Include="MainMenuBar.h" />
|
||||||
|
<ClInclude Include="MainToolBar.h" />
|
||||||
<ClInclude Include="MemcardManager.h" />
|
<ClInclude Include="MemcardManager.h" />
|
||||||
<ClInclude Include="PatchAddEdit.h" />
|
<ClInclude Include="PatchAddEdit.h" />
|
||||||
<ClInclude Include="SoftwareVideoConfigDialog.h" />
|
<ClInclude Include="SoftwareVideoConfigDialog.h" />
|
||||||
|
|
|
@ -151,6 +151,9 @@
|
||||||
<ClCompile Include="MainMenuBar.cpp">
|
<ClCompile Include="MainMenuBar.cpp">
|
||||||
<Filter>GUI</Filter>
|
<Filter>GUI</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="MainToolBar.cpp">
|
||||||
|
<Filter>GUI</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="MemcardManager.cpp">
|
<ClCompile Include="MemcardManager.cpp">
|
||||||
<Filter>GUI</Filter>
|
<Filter>GUI</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -330,6 +333,9 @@
|
||||||
<ClInclude Include="MainMenuBar.h">
|
<ClInclude Include="MainMenuBar.h">
|
||||||
<Filter>GUI</Filter>
|
<Filter>GUI</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="MainToolBar.h">
|
||||||
|
<Filter>GUI</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="MemcardManager.h">
|
<ClInclude Include="MemcardManager.h">
|
||||||
<Filter>GUI</Filter>
|
<Filter>GUI</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <wx/statusbr.h>
|
#include <wx/statusbr.h>
|
||||||
#include <wx/textctrl.h>
|
#include <wx/textctrl.h>
|
||||||
#include <wx/thread.h>
|
#include <wx/thread.h>
|
||||||
|
#include <wx/toolbar.h>
|
||||||
|
|
||||||
#include "AudioCommon/AudioCommon.h"
|
#include "AudioCommon/AudioCommon.h"
|
||||||
|
|
||||||
|
@ -222,6 +223,7 @@ bool CRenderFrame::ShowFullScreen(bool show, long style)
|
||||||
|
|
||||||
wxDEFINE_EVENT(wxEVT_HOST_COMMAND, wxCommandEvent);
|
wxDEFINE_EVENT(wxEVT_HOST_COMMAND, wxCommandEvent);
|
||||||
wxDEFINE_EVENT(DOLPHIN_EVT_LOCAL_INI_CHANGED, wxCommandEvent);
|
wxDEFINE_EVENT(DOLPHIN_EVT_LOCAL_INI_CHANGED, wxCommandEvent);
|
||||||
|
wxDEFINE_EVENT(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, wxCommandEvent);
|
||||||
|
|
||||||
// Event tables
|
// Event tables
|
||||||
BEGIN_EVENT_TABLE(CFrame, CRenderFrame)
|
BEGIN_EVENT_TABLE(CFrame, CRenderFrame)
|
||||||
|
@ -293,10 +295,9 @@ static BOOL WINAPI s_ctrl_handler(DWORD fdwCtrlType)
|
||||||
CFrame::CFrame(wxFrame* parent, wxWindowID id, const wxString& title, wxRect geometry,
|
CFrame::CFrame(wxFrame* parent, wxWindowID id, const wxString& title, wxRect geometry,
|
||||||
bool use_debugger, bool batch_mode, bool show_log_window, long style)
|
bool use_debugger, bool batch_mode, bool show_log_window, long style)
|
||||||
: CRenderFrame(parent, id, title, wxDefaultPosition, wxSize(800, 600), style),
|
: CRenderFrame(parent, id, title, wxDefaultPosition, wxSize(800, 600), style),
|
||||||
UseDebugger(use_debugger), m_bBatchMode(batch_mode),
|
UseDebugger(use_debugger), m_bBatchMode(batch_mode)
|
||||||
m_toolbar_bitmap_size(FromDIP(wxSize(32, 32)))
|
|
||||||
{
|
{
|
||||||
BindMenuBarEvents();
|
BindEvents();
|
||||||
|
|
||||||
for (int i = 0; i <= IDM_CODE_WINDOW - IDM_LOG_WINDOW; i++)
|
for (int i = 0; i <= IDM_CODE_WINDOW - IDM_LOG_WINDOW; i++)
|
||||||
bFloatWindow[i] = false;
|
bFloatWindow[i] = false;
|
||||||
|
@ -312,8 +313,7 @@ CFrame::CFrame(wxFrame* parent, wxWindowID id, const wxString& title, wxRect geo
|
||||||
g_pCodeWindow->Load();
|
g_pCodeWindow->Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create toolbar bitmaps
|
wxFrame::CreateToolBar(wxTB_DEFAULT_STYLE | wxTB_TEXT | wxTB_FLAT);
|
||||||
InitBitmaps();
|
|
||||||
|
|
||||||
// Give it a status bar
|
// Give it a status bar
|
||||||
SetStatusBar(CreateStatusBar(2, wxST_SIZEGRIP, ID_STATUSBAR));
|
SetStatusBar(CreateStatusBar(2, wxST_SIZEGRIP, ID_STATUSBAR));
|
||||||
|
@ -361,8 +361,6 @@ CFrame::CFrame(wxFrame* parent, wxWindowID id, const wxString& title, wxRect geo
|
||||||
.Hide());
|
.Hide());
|
||||||
AuiFullscreen = m_Mgr->SavePerspective();
|
AuiFullscreen = m_Mgr->SavePerspective();
|
||||||
|
|
||||||
// Create toolbar
|
|
||||||
RecreateToolbar();
|
|
||||||
if (!SConfig::GetInstance().m_InterfaceToolbar)
|
if (!SConfig::GetInstance().m_InterfaceToolbar)
|
||||||
DoToggleToolbar(false);
|
DoToggleToolbar(false);
|
||||||
|
|
||||||
|
@ -483,6 +481,13 @@ CFrame::~CFrame()
|
||||||
m_menubar_shadow = nullptr;
|
m_menubar_shadow = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CFrame::BindEvents()
|
||||||
|
{
|
||||||
|
BindMenuBarEvents();
|
||||||
|
|
||||||
|
Bind(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, &CFrame::OnReloadThemeBitmaps, this);
|
||||||
|
}
|
||||||
|
|
||||||
bool CFrame::RendererIsFullscreen()
|
bool CFrame::RendererIsFullscreen()
|
||||||
{
|
{
|
||||||
bool fullscreen = false;
|
bool fullscreen = false;
|
||||||
|
|
|
@ -59,6 +59,8 @@ private:
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxDECLARE_EVENT(DOLPHIN_EVT_RELOAD_THEME_BITMAPS, wxCommandEvent);
|
||||||
|
|
||||||
class CFrame : public CRenderFrame
|
class CFrame : public CRenderFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -84,7 +86,6 @@ public:
|
||||||
wxCheatsWindow* g_CheatsWindow = nullptr;
|
wxCheatsWindow* g_CheatsWindow = nullptr;
|
||||||
TASInputDlg* g_TASInputDlg[8];
|
TASInputDlg* g_TASInputDlg[8];
|
||||||
|
|
||||||
void InitBitmaps();
|
|
||||||
void DoPause();
|
void DoPause();
|
||||||
void DoStop();
|
void DoStop();
|
||||||
void OnStopped();
|
void OnStopped();
|
||||||
|
@ -112,7 +113,6 @@ public:
|
||||||
|
|
||||||
const CGameListCtrl* GetGameListCtrl() const;
|
const CGameListCtrl* GetGameListCtrl() const;
|
||||||
wxMenuBar* GetMenuBar() const override;
|
wxMenuBar* GetMenuBar() const override;
|
||||||
const wxSize& GetToolbarBitmapSize() const; // Needed before the toolbar exists
|
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
Common::Event panic_event;
|
Common::Event panic_event;
|
||||||
|
@ -126,7 +126,6 @@ public:
|
||||||
|
|
||||||
wxMenu* m_SavedPerspectives = nullptr;
|
wxMenu* m_SavedPerspectives = nullptr;
|
||||||
|
|
||||||
wxToolBar* m_ToolBar = nullptr;
|
|
||||||
// AUI
|
// AUI
|
||||||
wxAuiManager* m_Mgr = nullptr;
|
wxAuiManager* m_Mgr = nullptr;
|
||||||
bool bFloatWindow[IDM_DEBUG_WINDOW_LIST_END - IDM_DEBUG_WINDOW_LIST_START] = {};
|
bool bFloatWindow[IDM_DEBUG_WINDOW_LIST_END - IDM_DEBUG_WINDOW_LIST_START] = {};
|
||||||
|
@ -164,21 +163,6 @@ private:
|
||||||
|
|
||||||
std::vector<std::string> drives;
|
std::vector<std::string> drives;
|
||||||
|
|
||||||
enum EToolbar
|
|
||||||
{
|
|
||||||
Toolbar_FileOpen,
|
|
||||||
Toolbar_Refresh,
|
|
||||||
Toolbar_Play,
|
|
||||||
Toolbar_Stop,
|
|
||||||
Toolbar_Pause,
|
|
||||||
Toolbar_Screenshot,
|
|
||||||
Toolbar_FullScreen,
|
|
||||||
Toolbar_ConfigMain,
|
|
||||||
Toolbar_ConfigGFX,
|
|
||||||
Toolbar_Controller,
|
|
||||||
EToolbar_Max
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ADD_PANE_TOP,
|
ADD_PANE_TOP,
|
||||||
|
@ -191,17 +175,14 @@ private:
|
||||||
wxTimer m_poll_hotkey_timer;
|
wxTimer m_poll_hotkey_timer;
|
||||||
wxTimer m_handle_signal_timer;
|
wxTimer m_handle_signal_timer;
|
||||||
|
|
||||||
wxSize m_toolbar_bitmap_size;
|
|
||||||
wxBitmap m_Bitmaps[EToolbar_Max];
|
|
||||||
|
|
||||||
wxMenuBar* m_menubar_shadow = nullptr;
|
wxMenuBar* m_menubar_shadow = nullptr;
|
||||||
|
|
||||||
void PopulateToolbar(wxToolBar* toolBar);
|
void BindEvents();
|
||||||
void RecreateToolbar();
|
|
||||||
|
|
||||||
wxMenuBar* CreateMenuBar() const;
|
|
||||||
void BindMenuBarEvents();
|
void BindMenuBarEvents();
|
||||||
|
|
||||||
|
wxToolBar* OnCreateToolBar(long style, wxWindowID id, const wxString& name) override;
|
||||||
|
wxMenuBar* CreateMenuBar() const;
|
||||||
|
|
||||||
// Utility
|
// Utility
|
||||||
wxWindow* GetNotebookPageFromId(wxWindowID Id);
|
wxWindow* GetNotebookPageFromId(wxWindowID Id);
|
||||||
wxAuiNotebook* GetNotebookFromId(u32 NBId);
|
wxAuiNotebook* GetNotebookFromId(u32 NBId);
|
||||||
|
@ -252,6 +233,8 @@ private:
|
||||||
void OnQuit(wxCommandEvent& event);
|
void OnQuit(wxCommandEvent& event);
|
||||||
void OnHelp(wxCommandEvent& event);
|
void OnHelp(wxCommandEvent& event);
|
||||||
|
|
||||||
|
void OnReloadThemeBitmaps(wxCommandEvent& event);
|
||||||
|
|
||||||
void OnOpen(wxCommandEvent& event); // File menu
|
void OnOpen(wxCommandEvent& event); // File menu
|
||||||
void DoOpen(bool Boot);
|
void DoOpen(bool Boot);
|
||||||
void OnRefresh(wxCommandEvent& event);
|
void OnRefresh(wxCommandEvent& event);
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
#include "DolphinWX/InputConfigDiag.h"
|
#include "DolphinWX/InputConfigDiag.h"
|
||||||
#include "DolphinWX/LogWindow.h"
|
#include "DolphinWX/LogWindow.h"
|
||||||
#include "DolphinWX/MainMenuBar.h"
|
#include "DolphinWX/MainMenuBar.h"
|
||||||
|
#include "DolphinWX/MainToolBar.h"
|
||||||
#include "DolphinWX/MemcardManager.h"
|
#include "DolphinWX/MemcardManager.h"
|
||||||
#include "DolphinWX/NetPlay/NetPlaySetupFrame.h"
|
#include "DolphinWX/NetPlay/NetPlaySetupFrame.h"
|
||||||
#include "DolphinWX/NetPlay/NetWindow.h"
|
#include "DolphinWX/NetPlay/NetWindow.h"
|
||||||
|
@ -97,11 +98,6 @@ wxMenuBar* CFrame::GetMenuBar() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxSize& CFrame::GetToolbarBitmapSize() const
|
|
||||||
{
|
|
||||||
return m_toolbar_bitmap_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create menu items
|
// Create menu items
|
||||||
// ---------------------
|
// ---------------------
|
||||||
wxMenuBar* CFrame::CreateMenuBar() const
|
wxMenuBar* CFrame::CreateMenuBar() const
|
||||||
|
@ -200,69 +196,12 @@ void CFrame::BindMenuBarEvents()
|
||||||
Bind(wxEVT_MENU, &CFrame::OnHelp, this, wxID_ABOUT);
|
Bind(wxEVT_MENU, &CFrame::OnHelp, this, wxID_ABOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create toolbar items
|
wxToolBar* CFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name)
|
||||||
// ---------------------
|
|
||||||
void CFrame::PopulateToolbar(wxToolBar* ToolBar)
|
|
||||||
{
|
{
|
||||||
WxUtils::AddToolbarButton(ToolBar, wxID_OPEN, _("Open"), m_Bitmaps[Toolbar_FileOpen],
|
const auto type =
|
||||||
_("Open file..."));
|
UseDebugger ? MainToolBar::ToolBarType::Debug : MainToolBar::ToolBarType::Regular;
|
||||||
WxUtils::AddToolbarButton(ToolBar, wxID_REFRESH, _("Refresh"), m_Bitmaps[Toolbar_Refresh],
|
|
||||||
_("Refresh game list"));
|
|
||||||
ToolBar->AddSeparator();
|
|
||||||
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();
|
|
||||||
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_CONTROLLERS, _("Controllers"),
|
|
||||||
m_Bitmaps[Toolbar_Controller], _("Controller settings"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete and recreate the toolbar
|
return new MainToolBar{type, this, id, wxDefaultPosition, wxDefaultSize, style};
|
||||||
void CFrame::RecreateToolbar()
|
|
||||||
{
|
|
||||||
static constexpr long TOOLBAR_STYLE = wxTB_DEFAULT_STYLE | wxTB_TEXT | wxTB_FLAT;
|
|
||||||
|
|
||||||
if (m_ToolBar != nullptr)
|
|
||||||
{
|
|
||||||
m_ToolBar->Destroy();
|
|
||||||
m_ToolBar = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_ToolBar = CreateToolBar(TOOLBAR_STYLE, wxID_ANY);
|
|
||||||
m_ToolBar->SetToolBitmapSize(m_toolbar_bitmap_size);
|
|
||||||
|
|
||||||
if (g_pCodeWindow)
|
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CFrame::InitBitmaps()
|
|
||||||
{
|
|
||||||
static constexpr std::array<const char* const, EToolbar_Max> s_image_names{
|
|
||||||
{"open", "refresh", "play", "stop", "pause", "screenshot", "fullscreen", "config", "graphics",
|
|
||||||
"classic"}};
|
|
||||||
for (std::size_t i = 0; i < s_image_names.size(); ++i)
|
|
||||||
m_Bitmaps[i] = WxUtils::LoadScaledThemeBitmap(s_image_names[i], this, m_toolbar_bitmap_size);
|
|
||||||
|
|
||||||
// Update in case the bitmap has been updated
|
|
||||||
if (m_ToolBar != nullptr)
|
|
||||||
RecreateToolbar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFrame::OpenGeneralConfiguration(int tab)
|
void CFrame::OpenGeneralConfiguration(int tab)
|
||||||
|
@ -629,8 +568,7 @@ void CFrame::StartGame(const std::string& filename)
|
||||||
return;
|
return;
|
||||||
m_bGameLoading = true;
|
m_bGameLoading = true;
|
||||||
|
|
||||||
if (m_ToolBar)
|
GetToolBar()->EnableTool(IDM_PLAY, false);
|
||||||
m_ToolBar->EnableTool(IDM_PLAY, false);
|
|
||||||
GetMenuBar()->FindItem(IDM_PLAY)->Enable(false);
|
GetMenuBar()->FindItem(IDM_PLAY)->Enable(false);
|
||||||
|
|
||||||
if (SConfig::GetInstance().bRenderToMain)
|
if (SConfig::GetInstance().bRenderToMain)
|
||||||
|
@ -1066,6 +1004,15 @@ void CFrame::OnHelp(wxCommandEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CFrame::OnReloadThemeBitmaps(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
wxCommandEvent reload_event{DOLPHIN_EVT_RELOAD_TOOLBAR_BITMAPS};
|
||||||
|
reload_event.SetEventObject(this);
|
||||||
|
wxPostEvent(GetToolBar(), reload_event);
|
||||||
|
|
||||||
|
UpdateGameList();
|
||||||
|
}
|
||||||
|
|
||||||
void CFrame::ClearStatusBar()
|
void CFrame::ClearStatusBar()
|
||||||
{
|
{
|
||||||
if (this->GetStatusBar()->IsEnabled())
|
if (this->GetStatusBar()->IsEnabled())
|
||||||
|
@ -1368,18 +1315,7 @@ void CFrame::UpdateGUI()
|
||||||
bool Paused = Core::GetState() == Core::CORE_PAUSE;
|
bool Paused = Core::GetState() == Core::CORE_PAUSE;
|
||||||
bool Stopping = Core::GetState() == Core::CORE_STOPPING;
|
bool Stopping = Core::GetState() == Core::CORE_STOPPING;
|
||||||
|
|
||||||
// Make sure that we have a toolbar
|
GetToolBar()->Refresh(false);
|
||||||
if (m_ToolBar)
|
|
||||||
{
|
|
||||||
// Enable/disable the Config and Stop buttons
|
|
||||||
m_ToolBar->EnableTool(wxID_OPEN, !Initialized);
|
|
||||||
// Don't allow refresh when we don't show the list
|
|
||||||
m_ToolBar->EnableTool(wxID_REFRESH, !Initialized);
|
|
||||||
m_ToolBar->EnableTool(IDM_STOP, Running || Paused);
|
|
||||||
m_ToolBar->EnableTool(IDM_TOGGLE_FULLSCREEN, Running || Paused);
|
|
||||||
m_ToolBar->EnableTool(IDM_SCREENSHOT, Running || Paused);
|
|
||||||
}
|
|
||||||
|
|
||||||
GetMenuBar()->Refresh(false);
|
GetMenuBar()->Refresh(false);
|
||||||
|
|
||||||
// File
|
// File
|
||||||
|
@ -1436,33 +1372,6 @@ void CFrame::UpdateGUI()
|
||||||
Core::PauseAndLock(false, was_unpaused);
|
Core::PauseAndLock(false, was_unpaused);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_ToolBar)
|
|
||||||
{
|
|
||||||
// Get the tool that controls pausing/playing
|
|
||||||
wxToolBarToolBase* PlayTool = m_ToolBar->FindById(IDM_PLAY);
|
|
||||||
|
|
||||||
if (PlayTool)
|
|
||||||
{
|
|
||||||
int position = m_ToolBar->GetToolPos(IDM_PLAY);
|
|
||||||
|
|
||||||
if (Running)
|
|
||||||
{
|
|
||||||
m_ToolBar->DeleteTool(IDM_PLAY);
|
|
||||||
m_ToolBar->InsertTool(position, IDM_PLAY, _("Pause"), m_Bitmaps[Toolbar_Pause],
|
|
||||||
WxUtils::CreateDisabledButtonBitmap(m_Bitmaps[Toolbar_Pause]),
|
|
||||||
wxITEM_NORMAL, _("Pause"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_ToolBar->DeleteTool(IDM_PLAY);
|
|
||||||
m_ToolBar->InsertTool(position, IDM_PLAY, _("Play"), m_Bitmaps[Toolbar_Play],
|
|
||||||
WxUtils::CreateDisabledButtonBitmap(m_Bitmaps[Toolbar_Play]),
|
|
||||||
wxITEM_NORMAL, _("Play"));
|
|
||||||
}
|
|
||||||
m_ToolBar->Realize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GetMenuBar()->FindItem(IDM_RECORD_READ_ONLY)->Enable(Running || Paused);
|
GetMenuBar()->FindItem(IDM_RECORD_READ_ONLY)->Enable(Running || Paused);
|
||||||
|
|
||||||
if (!Initialized && !m_bGameLoading)
|
if (!Initialized && !m_bGameLoading)
|
||||||
|
@ -1472,8 +1381,7 @@ void CFrame::UpdateGUI()
|
||||||
// Prepare to load Default ISO, enable play button
|
// Prepare to load Default ISO, enable play button
|
||||||
if (!SConfig::GetInstance().m_strDefaultISO.empty())
|
if (!SConfig::GetInstance().m_strDefaultISO.empty())
|
||||||
{
|
{
|
||||||
if (m_ToolBar)
|
GetToolBar()->EnableTool(IDM_PLAY, true);
|
||||||
m_ToolBar->EnableTool(IDM_PLAY, true);
|
|
||||||
GetMenuBar()->FindItem(IDM_PLAY)->Enable();
|
GetMenuBar()->FindItem(IDM_PLAY)->Enable();
|
||||||
GetMenuBar()->FindItem(IDM_RECORD)->Enable();
|
GetMenuBar()->FindItem(IDM_RECORD)->Enable();
|
||||||
GetMenuBar()->FindItem(IDM_PLAY_RECORD)->Enable();
|
GetMenuBar()->FindItem(IDM_PLAY_RECORD)->Enable();
|
||||||
|
@ -1482,8 +1390,7 @@ void CFrame::UpdateGUI()
|
||||||
else if (!SConfig::GetInstance().m_LastFilename.empty() &&
|
else if (!SConfig::GetInstance().m_LastFilename.empty() &&
|
||||||
File::Exists(SConfig::GetInstance().m_LastFilename))
|
File::Exists(SConfig::GetInstance().m_LastFilename))
|
||||||
{
|
{
|
||||||
if (m_ToolBar)
|
GetToolBar()->EnableTool(IDM_PLAY, true);
|
||||||
m_ToolBar->EnableTool(IDM_PLAY, true);
|
|
||||||
GetMenuBar()->FindItem(IDM_PLAY)->Enable();
|
GetMenuBar()->FindItem(IDM_PLAY)->Enable();
|
||||||
GetMenuBar()->FindItem(IDM_RECORD)->Enable();
|
GetMenuBar()->FindItem(IDM_RECORD)->Enable();
|
||||||
GetMenuBar()->FindItem(IDM_PLAY_RECORD)->Enable();
|
GetMenuBar()->FindItem(IDM_PLAY_RECORD)->Enable();
|
||||||
|
@ -1491,8 +1398,7 @@ void CFrame::UpdateGUI()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// No game has been selected yet, disable play button
|
// No game has been selected yet, disable play button
|
||||||
if (m_ToolBar)
|
GetToolBar()->EnableTool(IDM_PLAY, false);
|
||||||
m_ToolBar->EnableTool(IDM_PLAY, false);
|
|
||||||
GetMenuBar()->FindItem(IDM_PLAY)->Enable(false);
|
GetMenuBar()->FindItem(IDM_PLAY)->Enable(false);
|
||||||
GetMenuBar()->FindItem(IDM_RECORD)->Enable(false);
|
GetMenuBar()->FindItem(IDM_RECORD)->Enable(false);
|
||||||
GetMenuBar()->FindItem(IDM_PLAY_RECORD)->Enable(false);
|
GetMenuBar()->FindItem(IDM_PLAY_RECORD)->Enable(false);
|
||||||
|
@ -1508,8 +1414,7 @@ void CFrame::UpdateGUI()
|
||||||
// Game has been selected but not started, enable play button
|
// Game has been selected but not started, enable play button
|
||||||
if (m_GameListCtrl->GetSelectedISO() != nullptr && m_GameListCtrl->IsEnabled())
|
if (m_GameListCtrl->GetSelectedISO() != nullptr && m_GameListCtrl->IsEnabled())
|
||||||
{
|
{
|
||||||
if (m_ToolBar)
|
GetToolBar()->EnableTool(IDM_PLAY, true);
|
||||||
m_ToolBar->EnableTool(IDM_PLAY, true);
|
|
||||||
GetMenuBar()->FindItem(IDM_PLAY)->Enable();
|
GetMenuBar()->FindItem(IDM_PLAY)->Enable();
|
||||||
GetMenuBar()->FindItem(IDM_RECORD)->Enable();
|
GetMenuBar()->FindItem(IDM_RECORD)->Enable();
|
||||||
GetMenuBar()->FindItem(IDM_PLAY_RECORD)->Enable();
|
GetMenuBar()->FindItem(IDM_PLAY_RECORD)->Enable();
|
||||||
|
@ -1518,19 +1423,14 @@ void CFrame::UpdateGUI()
|
||||||
else if (Initialized)
|
else if (Initialized)
|
||||||
{
|
{
|
||||||
// Game has been loaded, enable the pause button
|
// Game has been loaded, enable the pause button
|
||||||
if (m_ToolBar)
|
GetToolBar()->EnableTool(IDM_PLAY, !Stopping);
|
||||||
m_ToolBar->EnableTool(IDM_PLAY, !Stopping);
|
|
||||||
GetMenuBar()->FindItem(IDM_PLAY)->Enable(!Stopping);
|
GetMenuBar()->FindItem(IDM_PLAY)->Enable(!Stopping);
|
||||||
|
|
||||||
// Reset game loading flag
|
// Reset game loading flag
|
||||||
m_bGameLoading = false;
|
m_bGameLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh toolbar
|
GetToolBar()->Refresh(false);
|
||||||
if (m_ToolBar)
|
|
||||||
{
|
|
||||||
m_ToolBar->Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Commit changes to manager
|
// Commit changes to manager
|
||||||
m_Mgr->Update();
|
m_Mgr->Update();
|
||||||
|
|
|
@ -9,17 +9,6 @@
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <wx/event.h>
|
#include <wx/event.h>
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
Toolbar_Step,
|
|
||||||
Toolbar_StepOver,
|
|
||||||
Toolbar_StepOut,
|
|
||||||
Toolbar_Skip,
|
|
||||||
Toolbar_GotoPC,
|
|
||||||
Toolbar_SetPC,
|
|
||||||
Toolbar_Debug_Bitmap_Max
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
// Emulation menu
|
// Emulation menu
|
||||||
|
|
|
@ -0,0 +1,255 @@
|
||||||
|
// Copyright 2016 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "DolphinWX/MainToolBar.h"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include "Core/Core.h"
|
||||||
|
#include "Core/HW/CPU.h"
|
||||||
|
#include "DolphinWX/Globals.h"
|
||||||
|
#include "DolphinWX/WxUtils.h"
|
||||||
|
|
||||||
|
wxDEFINE_EVENT(DOLPHIN_EVT_RELOAD_TOOLBAR_BITMAPS, wxCommandEvent);
|
||||||
|
|
||||||
|
MainToolBar::MainToolBar(ToolBarType type, wxWindow* parent, wxWindowID id, const wxPoint& pos,
|
||||||
|
const wxSize& size, long style, const wxString& name)
|
||||||
|
: wxToolBar{parent, id, pos, size, style, name}, m_type{type}
|
||||||
|
{
|
||||||
|
wxToolBar::SetToolBitmapSize(FromDIP(wxSize{32, 32}));
|
||||||
|
InitializeBitmaps();
|
||||||
|
AddToolBarButtons();
|
||||||
|
wxToolBar::Realize();
|
||||||
|
|
||||||
|
BindEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::BindEvents()
|
||||||
|
{
|
||||||
|
Bind(DOLPHIN_EVT_RELOAD_TOOLBAR_BITMAPS, &MainToolBar::OnReloadBitmaps, this);
|
||||||
|
|
||||||
|
BindMainButtonEvents();
|
||||||
|
|
||||||
|
if (m_type == ToolBarType::Debug)
|
||||||
|
BindDebuggerButtonEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::BindMainButtonEvents()
|
||||||
|
{
|
||||||
|
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCoreNotRunning, this, wxID_OPEN);
|
||||||
|
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCoreNotRunning, this, wxID_REFRESH);
|
||||||
|
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCoreRunningOrPaused, this, IDM_STOP);
|
||||||
|
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCoreRunningOrPaused, this, IDM_TOGGLE_FULLSCREEN);
|
||||||
|
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCoreRunningOrPaused, this, IDM_SCREENSHOT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::BindDebuggerButtonEvents()
|
||||||
|
{
|
||||||
|
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCPUCanStep, this, IDM_STEP);
|
||||||
|
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCPUCanStep, this, IDM_STEPOVER);
|
||||||
|
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCPUCanStep, this, IDM_STEPOUT);
|
||||||
|
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCPUCanStep, this, IDM_SKIP);
|
||||||
|
Bind(wxEVT_UPDATE_UI, &MainToolBar::OnUpdateIfCorePaused, this, IDM_SETPC);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::OnUpdateIfCoreNotRunning(wxUpdateUIEvent& event)
|
||||||
|
{
|
||||||
|
event.Enable(!Core::IsRunning());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::OnUpdateIfCorePaused(wxUpdateUIEvent& event)
|
||||||
|
{
|
||||||
|
event.Enable(Core::GetState() == Core::CORE_PAUSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::OnUpdateIfCoreRunningOrPaused(wxUpdateUIEvent& event)
|
||||||
|
{
|
||||||
|
const auto state = Core::GetState();
|
||||||
|
|
||||||
|
event.Enable(state == Core::CORE_RUN || state == Core::CORE_PAUSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::OnUpdateIfCPUCanStep(wxUpdateUIEvent& event)
|
||||||
|
{
|
||||||
|
event.Enable(Core::IsRunning() && CPU::IsStepping());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::OnReloadBitmaps(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
Freeze();
|
||||||
|
|
||||||
|
m_icon_bitmaps.clear();
|
||||||
|
InitializeBitmaps();
|
||||||
|
ApplyThemeBitmaps();
|
||||||
|
|
||||||
|
if (m_type == ToolBarType::Debug)
|
||||||
|
ApplyDebuggerBitmaps();
|
||||||
|
|
||||||
|
Thaw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::Refresh(bool erase_background, const wxRect* rect)
|
||||||
|
{
|
||||||
|
wxToolBar::Refresh(erase_background, rect);
|
||||||
|
|
||||||
|
RefreshPlayButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::InitializeBitmaps()
|
||||||
|
{
|
||||||
|
InitializeThemeBitmaps();
|
||||||
|
|
||||||
|
if (m_type == ToolBarType::Debug)
|
||||||
|
InitializeDebuggerBitmaps();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::InitializeThemeBitmaps()
|
||||||
|
{
|
||||||
|
m_icon_bitmaps.insert({{TOOLBAR_FILEOPEN, CreateBitmap("open")},
|
||||||
|
{TOOLBAR_REFRESH, CreateBitmap("refresh")},
|
||||||
|
{TOOLBAR_PLAY, CreateBitmap("play")},
|
||||||
|
{TOOLBAR_STOP, CreateBitmap("stop")},
|
||||||
|
{TOOLBAR_PAUSE, CreateBitmap("pause")},
|
||||||
|
{TOOLBAR_SCREENSHOT, CreateBitmap("screenshot")},
|
||||||
|
{TOOLBAR_FULLSCREEN, CreateBitmap("fullscreen")},
|
||||||
|
{TOOLBAR_CONFIGMAIN, CreateBitmap("config")},
|
||||||
|
{TOOLBAR_CONFIGGFX, CreateBitmap("graphics")},
|
||||||
|
{TOOLBAR_CONTROLLER, CreateBitmap("classic")}});
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::InitializeDebuggerBitmaps()
|
||||||
|
{
|
||||||
|
m_icon_bitmaps.insert(
|
||||||
|
{{TOOLBAR_DEBUG_STEP, CreateDebuggerBitmap("toolbar_debugger_step")},
|
||||||
|
{TOOLBAR_DEBUG_STEPOVER, CreateDebuggerBitmap("toolbar_debugger_step_over")},
|
||||||
|
{TOOLBAR_DEBUG_STEPOUT, CreateDebuggerBitmap("toolbar_debugger_step_out")},
|
||||||
|
{TOOLBAR_DEBUG_SKIP, CreateDebuggerBitmap("toolbar_debugger_skip")},
|
||||||
|
{TOOLBAR_DEBUG_GOTOPC, CreateDebuggerBitmap("toolbar_debugger_goto_pc")},
|
||||||
|
{TOOLBAR_DEBUG_SETPC, CreateDebuggerBitmap("toolbar_debugger_set_pc")}});
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmap MainToolBar::CreateBitmap(const std::string& name) const
|
||||||
|
{
|
||||||
|
return WxUtils::LoadScaledThemeBitmap(name, this, GetToolBitmapSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmap MainToolBar::CreateDebuggerBitmap(const std::string& name) const
|
||||||
|
{
|
||||||
|
constexpr auto scale_flags = WxUtils::LSI_SCALE_DOWN | WxUtils::LSI_ALIGN_CENTER;
|
||||||
|
|
||||||
|
return WxUtils::LoadScaledResourceBitmap(name, this, GetToolBitmapSize(), wxDefaultSize,
|
||||||
|
scale_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::ApplyThemeBitmaps()
|
||||||
|
{
|
||||||
|
constexpr std::array<std::pair<int, ToolBarBitmapID>, 8> bitmap_entries{
|
||||||
|
{{wxID_OPEN, TOOLBAR_FILEOPEN},
|
||||||
|
{wxID_REFRESH, TOOLBAR_REFRESH},
|
||||||
|
{IDM_STOP, TOOLBAR_STOP},
|
||||||
|
{IDM_TOGGLE_FULLSCREEN, TOOLBAR_FULLSCREEN},
|
||||||
|
{IDM_SCREENSHOT, TOOLBAR_SCREENSHOT},
|
||||||
|
{wxID_PREFERENCES, TOOLBAR_CONFIGMAIN},
|
||||||
|
{IDM_CONFIG_GFX_BACKEND, TOOLBAR_CONFIGGFX},
|
||||||
|
{IDM_CONFIG_CONTROLLERS, TOOLBAR_CONTROLLER}}};
|
||||||
|
|
||||||
|
for (const auto& entry : bitmap_entries)
|
||||||
|
ApplyBitmap(entry.first, entry.second);
|
||||||
|
|
||||||
|
// Separate, as the play button is dual-state and doesn't have a fixed bitmap.
|
||||||
|
RefreshPlayButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::ApplyDebuggerBitmaps()
|
||||||
|
{
|
||||||
|
constexpr std::array<std::pair<int, ToolBarBitmapID>, 6> bitmap_entries{
|
||||||
|
{{IDM_STEP, TOOLBAR_DEBUG_STEP},
|
||||||
|
{IDM_STEPOVER, TOOLBAR_DEBUG_STEPOVER},
|
||||||
|
{IDM_STEPOUT, TOOLBAR_DEBUG_STEPOUT},
|
||||||
|
{IDM_SKIP, TOOLBAR_DEBUG_SKIP},
|
||||||
|
{IDM_GOTOPC, TOOLBAR_DEBUG_GOTOPC},
|
||||||
|
{IDM_SETPC, TOOLBAR_DEBUG_SETPC}}};
|
||||||
|
|
||||||
|
for (const auto& entry : bitmap_entries)
|
||||||
|
ApplyBitmap(entry.first, entry.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::ApplyBitmap(int tool_id, ToolBarBitmapID bitmap_id)
|
||||||
|
{
|
||||||
|
const auto& bitmap = m_icon_bitmaps[bitmap_id];
|
||||||
|
|
||||||
|
SetToolDisabledBitmap(tool_id, WxUtils::CreateDisabledButtonBitmap(bitmap));
|
||||||
|
SetToolNormalBitmap(tool_id, bitmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::AddToolBarButtons()
|
||||||
|
{
|
||||||
|
if (m_type == ToolBarType::Debug)
|
||||||
|
{
|
||||||
|
AddDebuggerToolBarButtons();
|
||||||
|
AddSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
|
AddMainToolBarButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::AddMainToolBarButtons()
|
||||||
|
{
|
||||||
|
AddToolBarButton(wxID_OPEN, TOOLBAR_FILEOPEN, _("Open"), _("Open file..."));
|
||||||
|
AddToolBarButton(wxID_REFRESH, TOOLBAR_REFRESH, _("Refresh"), _("Refresh game list"));
|
||||||
|
AddSeparator();
|
||||||
|
AddToolBarButton(IDM_PLAY, TOOLBAR_PLAY, _("Play"), _("Play"));
|
||||||
|
AddToolBarButton(IDM_STOP, TOOLBAR_STOP, _("Stop"), _("Stop"));
|
||||||
|
AddToolBarButton(IDM_TOGGLE_FULLSCREEN, TOOLBAR_FULLSCREEN, _("FullScr"), _("Toggle fullscreen"));
|
||||||
|
AddToolBarButton(IDM_SCREENSHOT, TOOLBAR_SCREENSHOT, _("ScrShot"), _("Take screenshot"));
|
||||||
|
AddSeparator();
|
||||||
|
AddToolBarButton(wxID_PREFERENCES, TOOLBAR_CONFIGMAIN, _("Config"), _("Configure..."));
|
||||||
|
AddToolBarButton(IDM_CONFIG_GFX_BACKEND, TOOLBAR_CONFIGGFX, _("Graphics"),
|
||||||
|
_("Graphics settings"));
|
||||||
|
AddToolBarButton(IDM_CONFIG_CONTROLLERS, TOOLBAR_CONTROLLER, _("Controllers"),
|
||||||
|
_("Controller settings"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::AddDebuggerToolBarButtons()
|
||||||
|
{
|
||||||
|
AddToolBarButton(IDM_STEP, TOOLBAR_DEBUG_STEP, _("Step"), _("Step into the next instruction"));
|
||||||
|
AddToolBarButton(IDM_STEPOVER, TOOLBAR_DEBUG_STEPOVER, _("Step Over"),
|
||||||
|
_("Step over the next instruction"));
|
||||||
|
AddToolBarButton(IDM_STEPOUT, TOOLBAR_DEBUG_STEPOUT, _("Step Out"),
|
||||||
|
_("Step out of the current function"));
|
||||||
|
AddToolBarButton(IDM_SKIP, TOOLBAR_DEBUG_SKIP, _("Skip"),
|
||||||
|
_("Skips the next instruction completely"));
|
||||||
|
AddSeparator();
|
||||||
|
AddToolBarButton(IDM_GOTOPC, TOOLBAR_DEBUG_GOTOPC, _("Show PC"),
|
||||||
|
_("Go to the current instruction"));
|
||||||
|
AddToolBarButton(IDM_SETPC, TOOLBAR_DEBUG_SETPC, _("Set PC"), _("Set the current instruction"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::AddToolBarButton(int tool_id, ToolBarBitmapID bitmap_id, const wxString& label,
|
||||||
|
const wxString& short_help)
|
||||||
|
{
|
||||||
|
WxUtils::AddToolbarButton(this, tool_id, label, m_icon_bitmaps[bitmap_id], short_help);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainToolBar::RefreshPlayButton()
|
||||||
|
{
|
||||||
|
ToolBarBitmapID bitmap_id;
|
||||||
|
wxString label;
|
||||||
|
|
||||||
|
if (Core::GetState() == Core::CORE_RUN)
|
||||||
|
{
|
||||||
|
bitmap_id = TOOLBAR_PAUSE;
|
||||||
|
label = _("Pause");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bitmap_id = TOOLBAR_PLAY;
|
||||||
|
label = _("Play");
|
||||||
|
}
|
||||||
|
|
||||||
|
FindById(IDM_PLAY)->SetLabel(label);
|
||||||
|
SetToolShortHelp(IDM_PLAY, label);
|
||||||
|
ApplyBitmap(IDM_PLAY, bitmap_id);
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
// Copyright 2016 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <wx/bitmap.h>
|
||||||
|
#include <wx/toolbar.h>
|
||||||
|
|
||||||
|
wxDECLARE_EVENT(DOLPHIN_EVT_RELOAD_TOOLBAR_BITMAPS, wxCommandEvent);
|
||||||
|
|
||||||
|
class MainToolBar final : public wxToolBar
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum class ToolBarType
|
||||||
|
{
|
||||||
|
Regular,
|
||||||
|
Debug
|
||||||
|
};
|
||||||
|
|
||||||
|
MainToolBar(ToolBarType type, wxWindow* parent, wxWindowID id,
|
||||||
|
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||||
|
long style = wxTB_HORIZONTAL, const wxString& name = wxToolBarNameStr);
|
||||||
|
|
||||||
|
void Refresh(bool erase_background, const wxRect* rect = nullptr) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum ToolBarBitmapID : int
|
||||||
|
{
|
||||||
|
TOOLBAR_DEBUG_STEP,
|
||||||
|
TOOLBAR_DEBUG_STEPOVER,
|
||||||
|
TOOLBAR_DEBUG_STEPOUT,
|
||||||
|
TOOLBAR_DEBUG_SKIP,
|
||||||
|
TOOLBAR_DEBUG_GOTOPC,
|
||||||
|
TOOLBAR_DEBUG_SETPC,
|
||||||
|
|
||||||
|
TOOLBAR_FILEOPEN,
|
||||||
|
TOOLBAR_REFRESH,
|
||||||
|
TOOLBAR_PLAY,
|
||||||
|
TOOLBAR_STOP,
|
||||||
|
TOOLBAR_PAUSE,
|
||||||
|
TOOLBAR_SCREENSHOT,
|
||||||
|
TOOLBAR_FULLSCREEN,
|
||||||
|
TOOLBAR_CONFIGMAIN,
|
||||||
|
TOOLBAR_CONFIGGFX,
|
||||||
|
TOOLBAR_CONTROLLER,
|
||||||
|
};
|
||||||
|
|
||||||
|
void BindEvents();
|
||||||
|
void BindMainButtonEvents();
|
||||||
|
void BindDebuggerButtonEvents();
|
||||||
|
|
||||||
|
void OnUpdateIfCoreNotRunning(wxUpdateUIEvent&);
|
||||||
|
void OnUpdateIfCorePaused(wxUpdateUIEvent&);
|
||||||
|
void OnUpdateIfCoreRunningOrPaused(wxUpdateUIEvent&);
|
||||||
|
void OnUpdateIfCPUCanStep(wxUpdateUIEvent&);
|
||||||
|
|
||||||
|
void OnReloadBitmaps(wxCommandEvent&);
|
||||||
|
|
||||||
|
void InitializeBitmaps();
|
||||||
|
void InitializeThemeBitmaps();
|
||||||
|
void InitializeDebuggerBitmaps();
|
||||||
|
|
||||||
|
wxBitmap CreateBitmap(const std::string& name) const;
|
||||||
|
wxBitmap CreateDebuggerBitmap(const std::string& name) const;
|
||||||
|
|
||||||
|
void ApplyThemeBitmaps();
|
||||||
|
void ApplyDebuggerBitmaps();
|
||||||
|
void ApplyBitmap(int tool_id, ToolBarBitmapID bitmap_id);
|
||||||
|
|
||||||
|
void AddToolBarButtons();
|
||||||
|
void AddMainToolBarButtons();
|
||||||
|
void AddDebuggerToolBarButtons();
|
||||||
|
void AddToolBarButton(int tool_id, ToolBarBitmapID bitmap_id, const wxString& label,
|
||||||
|
const wxString& short_help = wxEmptyString);
|
||||||
|
|
||||||
|
void RefreshPlayButton();
|
||||||
|
|
||||||
|
ToolBarType m_type{};
|
||||||
|
std::unordered_map<ToolBarBitmapID, wxBitmap, std::hash<int>> m_icon_bitmaps;
|
||||||
|
};
|
Loading…
Reference in New Issue