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.
This commit is contained in:
parent
e18ceca7af
commit
5ae6c21c2e
|
@ -213,7 +213,6 @@ void CCodeWindow::OnCodeStep(wxCommandEvent& event)
|
|||
break;
|
||||
}
|
||||
|
||||
UpdateButtonStates();
|
||||
// Update all toolbars in the aui manager
|
||||
Parent->UpdateGUI();
|
||||
}
|
||||
|
@ -502,9 +501,6 @@ void CCodeWindow::OnCPUMode(wxCommandEvent& event)
|
|||
|
||||
// Clear the JIT cache to enable these changes
|
||||
JitInterface::ClearCache();
|
||||
|
||||
// Update
|
||||
UpdateButtonStates();
|
||||
}
|
||||
|
||||
void CCodeWindow::OnJitMenu(wxCommandEvent& event)
|
||||
|
@ -574,63 +570,20 @@ void CCodeWindow::Repopulate(bool refresh_codeview)
|
|||
|
||||
if (refresh_codeview)
|
||||
codeview->Refresh();
|
||||
|
||||
UpdateCallstack();
|
||||
UpdateButtonStates();
|
||||
|
||||
// Do not automatically show the current PC position when a breakpoint is hit or
|
||||
// when we pause since this can be called at other times too.
|
||||
// codeview->Center(PC);
|
||||
}
|
||||
|
||||
void CCodeWindow::UpdateButtonStates()
|
||||
void CCodeWindow::UpdateFonts()
|
||||
{
|
||||
bool Initialized = (Core::GetState() != Core::CORE_UNINITIALIZED);
|
||||
bool Pause = (Core::GetState() == Core::CORE_PAUSE);
|
||||
bool Stepping = CPU::IsStepping();
|
||||
bool can_step = Initialized && Stepping;
|
||||
|
||||
GetMenuBar()->Enable(IDM_INTERPRETER, Pause); // CPU Mode
|
||||
|
||||
GetMenuBar()->Enable(IDM_STEP, can_step);
|
||||
GetMenuBar()->Enable(IDM_STEPOVER, can_step);
|
||||
GetMenuBar()->Enable(IDM_STEPOUT, can_step);
|
||||
|
||||
GetMenuBar()->Enable(IDM_JIT_NO_BLOCK_CACHE, !Initialized);
|
||||
|
||||
GetMenuBar()->Enable(IDM_JIT_OFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JIT_LS_OFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JIT_LSLXZ_OFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JIT_LSLWZ_OFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JIT_LSLBZX_OFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JIT_LSF_OFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JIT_LSP_OFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JIT_FP_OFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JIT_I_OFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JIT_P_OFF, Pause);
|
||||
GetMenuBar()->Enable(IDM_JIT_SR_OFF, Pause);
|
||||
|
||||
GetMenuBar()->Enable(IDM_CLEAR_CODE_CACHE, Pause); // JIT Menu
|
||||
GetMenuBar()->Enable(IDM_SEARCH_INSTRUCTION, Initialized);
|
||||
|
||||
GetMenuBar()->Enable(IDM_CLEAR_SYMBOLS, Initialized); // Symbols menu
|
||||
GetMenuBar()->Enable(IDM_SCAN_FUNCTIONS, Initialized);
|
||||
GetMenuBar()->Enable(IDM_LOAD_MAP_FILE, Initialized);
|
||||
GetMenuBar()->Enable(IDM_SAVEMAPFILE, Initialized);
|
||||
GetMenuBar()->Enable(IDM_LOAD_MAP_FILE_AS, Initialized);
|
||||
GetMenuBar()->Enable(IDM_SAVE_MAP_FILE_AS, Initialized);
|
||||
GetMenuBar()->Enable(IDM_LOAD_BAD_MAP_FILE, Initialized);
|
||||
GetMenuBar()->Enable(IDM_SAVE_MAP_FILE_WITH_CODES, Initialized);
|
||||
GetMenuBar()->Enable(IDM_CREATE_SIGNATURE_FILE, Initialized);
|
||||
GetMenuBar()->Enable(IDM_APPEND_SIGNATURE_FILE, Initialized);
|
||||
GetMenuBar()->Enable(IDM_COMBINE_SIGNATURE_FILES, Initialized);
|
||||
GetMenuBar()->Enable(IDM_RENAME_SYMBOLS, Initialized);
|
||||
GetMenuBar()->Enable(IDM_USE_SIGNATURE_FILE, Initialized);
|
||||
GetMenuBar()->Enable(IDM_PATCH_HLE_FUNCTIONS, Initialized);
|
||||
|
||||
// Update Fonts
|
||||
callstack->SetFont(DebuggerFont);
|
||||
symbols->SetFont(DebuggerFont);
|
||||
callers->SetFont(DebuggerFont);
|
||||
calls->SetFont(DebuggerFont);
|
||||
m_aui_manager.GetArtProvider()->SetFont(wxAUI_DOCKART_CAPTION_FONT, DebuggerFont);
|
||||
m_aui_manager.Update();
|
||||
}
|
||||
|
|
|
@ -95,7 +95,6 @@ public:
|
|||
|
||||
void Repopulate(bool refresh_codeview = true);
|
||||
void NotifyMapLoaded();
|
||||
void UpdateButtonStates();
|
||||
void OpenPages();
|
||||
|
||||
// Menu bar
|
||||
|
@ -151,6 +150,7 @@ private:
|
|||
void StepOut();
|
||||
void ToggleBreakpoint();
|
||||
|
||||
void UpdateFonts();
|
||||
void UpdateLists();
|
||||
void UpdateCallstack();
|
||||
|
||||
|
|
|
@ -447,6 +447,7 @@ void CCodeWindow::OnChangeFont(wxCommandEvent& event)
|
|||
if (dialog.ShowModal() == wxID_OK)
|
||||
DebuggerFont = dialog.GetFontData().GetChosenFont();
|
||||
|
||||
UpdateFonts();
|
||||
// TODO: Send event to all panels that tells them to reload the font when it changes.
|
||||
}
|
||||
|
||||
|
|
|
@ -429,16 +429,11 @@ CFrame::CFrame(wxFrame* parent, wxWindowID id, const wxString& title, wxRect geo
|
|||
X11Utils::XWindowFromHandle(GetHandle()));
|
||||
#endif
|
||||
|
||||
// -------------------------
|
||||
// Connect event handlers
|
||||
|
||||
m_Mgr->Bind(wxEVT_AUI_RENDER, &CFrame::OnManagerResize, this);
|
||||
// ----------
|
||||
|
||||
// Update controls
|
||||
UpdateGUI();
|
||||
if (g_pCodeWindow)
|
||||
g_pCodeWindow->UpdateButtonStates();
|
||||
|
||||
// check if game is running
|
||||
InitControllers();
|
||||
|
|
|
@ -179,6 +179,8 @@ private:
|
|||
|
||||
void BindEvents();
|
||||
void BindMenuBarEvents();
|
||||
void BindDebuggerMenuBarEvents();
|
||||
void BindDebuggerMenuBarUpdateEvents();
|
||||
|
||||
wxToolBar* OnCreateToolBar(long style, wxWindowID id, const wxString& name) override;
|
||||
wxMenuBar* CreateMenuBar() const;
|
||||
|
@ -235,6 +237,11 @@ private:
|
|||
|
||||
void OnReloadThemeBitmaps(wxCommandEvent& event);
|
||||
|
||||
void OnEnableMenuItemIfCoreInitialized(wxUpdateUIEvent& event);
|
||||
void OnEnableMenuItemIfCoreUninitialized(wxUpdateUIEvent& event);
|
||||
void OnEnableMenuItemIfCorePaused(wxUpdateUIEvent& event);
|
||||
void OnEnableMenuItemIfCPUCanStep(wxUpdateUIEvent& event);
|
||||
|
||||
void OnOpen(wxCommandEvent& event); // File menu
|
||||
void DoOpen(bool Boot);
|
||||
void OnRefresh(wxCommandEvent& event);
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue