From 5ae6c21c2e2537859ff4473b131c4d2f9f2a6e0b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 3 Nov 2016 18:02:53 -0400 Subject: CodeWindow: Eliminate explicit menu item updating from CodeWindow Gets rid of more menu-related code from CodeWindow and puts it back in CFrame where it belongs. This turns the previous menu update function within CodeWindow into one that simply updates the debugger font for its managed controls. It also improves how the font is actually updated. Previously, fonts would change, however this wouldn't actually reflect onto the respective controls until a refresh or update event occurred. Since codeview, callstack, symbols, callers, and calls windows are all managed by a wxAuiManager instance, calling Update() on it after the font has been set will reflect font changes immediately. --- Source/Core/DolphinWX/FrameTools.cpp | 81 +++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 5 deletions(-) (limited to 'Source/Core/DolphinWX/FrameTools.cpp') diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index b48dad0e5f..674d27ab89 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -176,6 +176,18 @@ void CFrame::BindMenuBarEvents() Bind(wxEVT_MENU, &CFrame::GameListChanged, this, IDM_PURGE_GAME_LIST_CACHE); Bind(wxEVT_MENU, &CFrame::OnChangeColumnsVisible, this, IDM_SHOW_SYSTEM, IDM_SHOW_STATE); + // Help menu + Bind(wxEVT_MENU, &CFrame::OnHelp, this, IDM_HELP_WEBSITE); + Bind(wxEVT_MENU, &CFrame::OnHelp, this, IDM_HELP_ONLINE_DOCS); + Bind(wxEVT_MENU, &CFrame::OnHelp, this, IDM_HELP_GITHUB); + Bind(wxEVT_MENU, &CFrame::OnHelp, this, wxID_ABOUT); + + if (UseDebugger) + BindDebuggerMenuBarEvents(); +} + +void CFrame::BindDebuggerMenuBarEvents() +{ // Debug menu Bind(wxEVT_MENU, &CFrame::OnPerspectiveMenu, this, IDM_SAVE_PERSPECTIVE); Bind(wxEVT_MENU, &CFrame::OnPerspectiveMenu, this, IDM_EDIT_PERSPECTIVES); @@ -189,11 +201,50 @@ void CFrame::BindMenuBarEvents() Bind(wxEVT_MENU, &CFrame::OnPerspectiveMenu, this, IDM_TAB_SPLIT); Bind(wxEVT_MENU, &CFrame::OnPerspectiveMenu, this, IDM_NO_DOCKING); - // Help menu - Bind(wxEVT_MENU, &CFrame::OnHelp, this, IDM_HELP_WEBSITE); - Bind(wxEVT_MENU, &CFrame::OnHelp, this, IDM_HELP_ONLINE_DOCS); - Bind(wxEVT_MENU, &CFrame::OnHelp, this, IDM_HELP_GITHUB); - Bind(wxEVT_MENU, &CFrame::OnHelp, this, wxID_ABOUT); + BindDebuggerMenuBarUpdateEvents(); +} + +void CFrame::BindDebuggerMenuBarUpdateEvents() +{ + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCPUCanStep, this, IDM_STEP); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCPUCanStep, this, IDM_STEPOUT); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCPUCanStep, this, IDM_STEPOVER); + + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_INTERPRETER); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_OFF); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_LS_OFF); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_LSLXZ_OFF); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_LSLWZ_OFF); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_LSLBZX_OFF); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_LSF_OFF); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_LSP_OFF); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_FP_OFF); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_I_OFF); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_P_OFF); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_SR_OFF); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_CLEAR_CODE_CACHE); + + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_SEARCH_INSTRUCTION); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_CLEAR_SYMBOLS); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_SCAN_FUNCTIONS); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_LOAD_MAP_FILE); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_SAVEMAPFILE); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_LOAD_MAP_FILE_AS); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_SAVE_MAP_FILE_AS); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_LOAD_BAD_MAP_FILE); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, + IDM_SAVE_MAP_FILE_WITH_CODES); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, + IDM_CREATE_SIGNATURE_FILE); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, + IDM_APPEND_SIGNATURE_FILE); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, + IDM_COMBINE_SIGNATURE_FILES); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_RENAME_SYMBOLS); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_USE_SIGNATURE_FILE); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreInitialized, this, IDM_PATCH_HLE_FUNCTIONS); + + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCoreUninitialized, this, IDM_JIT_NO_BLOCK_CACHE); } wxToolBar* CFrame::OnCreateToolBar(long style, wxWindowID id, const wxString& name) @@ -1015,6 +1066,26 @@ void CFrame::OnReloadThemeBitmaps(wxCommandEvent& WXUNUSED(event)) UpdateGameList(); } +void CFrame::OnEnableMenuItemIfCoreInitialized(wxUpdateUIEvent& event) +{ + event.Enable(Core::GetState() != Core::CORE_UNINITIALIZED); +} + +void CFrame::OnEnableMenuItemIfCoreUninitialized(wxUpdateUIEvent& event) +{ + event.Enable(Core::GetState() == Core::CORE_UNINITIALIZED); +} + +void CFrame::OnEnableMenuItemIfCorePaused(wxUpdateUIEvent& event) +{ + event.Enable(Core::GetState() == Core::CORE_PAUSE); +} + +void CFrame::OnEnableMenuItemIfCPUCanStep(wxUpdateUIEvent& event) +{ + event.Enable(Core::GetState() != Core::CORE_UNINITIALIZED && CPU::IsStepping()); +} + void CFrame::ClearStatusBar() { if (this->GetStatusBar()->IsEnabled()) -- cgit v1.2.3 From 5d4c714662f4bf9e4ef025b85ffd96331e265724 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 3 Nov 2016 23:43:35 -0400 Subject: CodeWindow: Hide GetMenuBar() This eliminates public usage of the GetMenuBar() function in CodeWindow. The benefit of this is it also gets rid of the need to perform direct access across the config dialog and the main frame. It also gets rid of the use of the main_frame global. GetMenuBar() will be removed entirely from CodeWindow in a follow-up that also removes any related remnants of code made obsolete with its removal. --- Source/Core/DolphinWX/FrameTools.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Source/Core/DolphinWX/FrameTools.cpp') diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 674d27ab89..cb4297585f 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -210,7 +210,8 @@ void CFrame::BindDebuggerMenuBarUpdateEvents() Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCPUCanStep, this, IDM_STEPOUT); Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCPUCanStep, this, IDM_STEPOVER); - Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_INTERPRETER); + Bind(wxEVT_UPDATE_UI, &CFrame::OnUpdateInterpreterMenuItem, this, IDM_INTERPRETER); + Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_OFF); Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_LS_OFF); Bind(wxEVT_UPDATE_UI, &CFrame::OnEnableMenuItemIfCorePaused, this, IDM_JIT_LSLXZ_OFF); @@ -1086,6 +1087,16 @@ void CFrame::OnEnableMenuItemIfCPUCanStep(wxUpdateUIEvent& event) event.Enable(Core::GetState() != Core::CORE_UNINITIALIZED && CPU::IsStepping()); } +void CFrame::OnUpdateInterpreterMenuItem(wxUpdateUIEvent& event) +{ + OnEnableMenuItemIfCorePaused(event); + + if (GetMenuBar()->FindItem(IDM_INTERPRETER)->IsChecked()) + return; + + event.Check(SConfig::GetInstance().iCPUCore == PowerPC::CORE_INTERPRETER); +} + void CFrame::ClearStatusBar() { if (this->GetStatusBar()->IsEnabled()) -- cgit v1.2.3