From bc938c4b0130ff3b9b4d3a00fa1192bef156b6f4 Mon Sep 17 00:00:00 2001 From: John Peterson Date: Thu, 27 Aug 2009 01:30:08 +0000 Subject: [PATCH] GUI: Save page views git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4071 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DebuggerWX/Src/CodeWindow.cpp | 135 ++++++------------- Source/Core/DebuggerWX/Src/CodeWindow.h | 11 +- Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp | 24 +++- Source/Core/DolphinWX/Src/Frame.cpp | 9 +- 4 files changed, 71 insertions(+), 108 deletions(-) diff --git a/Source/Core/DebuggerWX/Src/CodeWindow.cpp b/Source/Core/DebuggerWX/Src/CodeWindow.cpp index 6fe4a6d67d..41eff0953f 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindow.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindow.cpp @@ -171,21 +171,17 @@ CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter , m_BreakpointWindow(NULL) , m_MemoryWindow(NULL) , m_JitWindow(NULL) - , m_ToolBar2(NULL) + , m_ToolBar2(NULL), m_NB0(NULL), m_NB1(NULL) { // Load ini settings - IniFile file; - file.Load(DEBUGGER_CONFIG_FILE); - this->Load_(file); + this->Load(); - page_bmp = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16)); + aNormalFile = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16)); InitBitmaps(); CreateGUIControls(_LocalCoreStartupParameter); - // Create the toolbar //RecreateToolbar(); - // Update bitmap buttons //UpdateButtonStates(); @@ -195,34 +191,17 @@ CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter (wxObject*)0, this); // Load settings for selectable windows, but only if they have been created - this->Load(file); - if (m_BreakpointWindow) m_BreakpointWindow->Load(file); - if (m_RegisterWindow) m_RegisterWindow->Load(file); - if (m_MemoryWindow) m_MemoryWindow->Load(file); - if (m_JitWindow) m_JitWindow->Load(file); + //this->Load(); } CCodeWindow::~CCodeWindow() { - // Will be fixed. Pointers currently non-NULL while object is deleted on close - /* - IniFile file; - file.Load(DEBUGGER_CONFIG_FILE); - - this->Save(file); - if (m_BreakpointWindow) m_BreakpointWindow->Save(file); - if (m_RegisterWindow) m_RegisterWindow->Save(file); - if (m_MemoryWindow) m_MemoryWindow->Save(file); - if (m_JitWindow) m_JitWindow->Save(file); - - file.Save(DEBUGGER_CONFIG_FILE); - */ } ///////////////////////////////////////////////////////////////////////////////////////////////////// -//Redirect old wxFrame calls +// Redirect old wxFrame calls // ------------ wxFrame *CCodeWindow::GetParentFrame() { @@ -274,39 +253,23 @@ void CCodeWindow::OnHostMessage(wxCommandEvent& event) case IDM_NOTIFYMAPLOADED: NotifyMapLoaded(); break; - - /* case IDM_UPDATELOGDISPLAY: - - if (m_LogWindow) - { - m_LogWindow->NotifyUpdate(); - } - - break; - */ + /* + case IDM_UPDATELOGDISPLAY: + if (m_LogWindow) m_LogWindow->NotifyUpdate(); + break; + */ case IDM_UPDATEDISASMDIALOG: Update(); - - if (m_RegisterWindow) - { - m_RegisterWindow->NotifyUpdate(); - } + if (m_RegisterWindow) m_RegisterWindow->NotifyUpdate(); break; case IDM_UPDATEBREAKPOINTS: Update(); - - if (m_BreakpointWindow) - { - m_BreakpointWindow->NotifyUpdate(); - } + if (m_BreakpointWindow) m_BreakpointWindow->NotifyUpdate(); break; case IDM_UPDATESTATUSBAR: //if (main_frame->m_pStatusBar != NULL) { - // What is this PanicAlert() for? - //PanicAlert(""); - //this->GetParent()->m_p //this->GetParent()-> //parent->m_pStatusBar->SetStatusText(wxT("Hi"), 0); @@ -315,7 +278,6 @@ void CCodeWindow::OnHostMessage(wxCommandEvent& event) //main_frame->m_pStatusBar->SetStatusText(event.GetString(), event.GetInt()); } break; - } } @@ -323,8 +285,11 @@ void CCodeWindow::OnHostMessage(wxCommandEvent& event) // Load these settings before CreateGUIControls() -void CCodeWindow::Load_( IniFile &ini ) +void CCodeWindow::Load() { + IniFile ini; + ini.Load(DEBUGGER_CONFIG_FILE); + // The font to override DebuggerFont with std::string fontDesc; ini.Get("ShowOnStart", "DebuggerFont", &fontDesc); @@ -337,15 +302,14 @@ void CCodeWindow::Load_( IniFile &ini ) ini.Get("ShowOnStart", "MemoryWindow", &bMemoryWindow, true); ini.Get("ShowOnStart", "JitWindow", &bJitWindow, true); ini.Get("ShowOnStart", "SoundWindow", &bSoundWindow, false); - ini.Get("ShowOnStart", "VideoWindow", &bVideoWindow, false); - + ini.Get("ShowOnStart", "VideoWindow", &bVideoWindow, false); // Boot to pause or not ini.Get("ShowOnStart", "AutomaticStart", &bAutomaticStart, false); ini.Get("ShowOnStart", "BootToPause", &bBootToPause, true); } - +/* void CCodeWindow::Load( IniFile &ini ) { int x,y,w,h; @@ -360,21 +324,13 @@ void CCodeWindow::Load( IniFile &ini ) ini.Get("MainWindow", "h", &h, 600); GetParent()->SetSize(x, y, w, h); } +*/ -void CCodeWindow::Save(IniFile &ini) +void CCodeWindow::Save() { - // Crashes on exit, will be fixed - return; - - ini.Set("CodeWindow", "x", GetPosition().x); - ini.Set("CodeWindow", "y", GetPosition().y); - ini.Set("CodeWindow", "w", GetSize().GetWidth()); - ini.Set("CodeWindow", "h", GetSize().GetHeight()); - ini.Set("MainWindow", "x", GetParent()->GetPosition().x); - ini.Set("MainWindow", "y", GetParent()->GetPosition().y); - ini.Set("MainWindow", "w", GetParent()->GetSize().GetWidth()); - ini.Set("MainWindow", "h", GetParent()->GetSize().GetHeight()); + IniFile ini; + ini.Load(DEBUGGER_CONFIG_FILE); ini.Set("ShowOnStart", "DebuggerFont", std::string(DebuggerFont.GetNativeFontInfoUserDesc().mb_str())); @@ -389,6 +345,25 @@ void CCodeWindow::Save(IniFile &ini) ini.Set("ShowOnStart", "JitWindow", GetMenuBar()->IsChecked(IDM_JITWINDOW)); ini.Set("ShowOnStart", "SoundWindow", GetMenuBar()->IsChecked(IDM_SOUNDWINDOW)); ini.Set("ShowOnStart", "VideoWindow", GetMenuBar()->IsChecked(IDM_VIDEOWINDOW)); + + // Save window settings + /* + ini.Set("CodeWindow", "x", GetPosition().x); + ini.Set("CodeWindow", "y", GetPosition().y); + ini.Set("CodeWindow", "w", GetSize().GetWidth()); + ini.Set("CodeWindow", "h", GetSize().GetHeight()); + ini.Set("MainWindow", "x", GetParent()->GetPosition().x); + ini.Set("MainWindow", "y", GetParent()->GetPosition().y); + ini.Set("MainWindow", "w", GetParent()->GetSize().GetWidth()); + ini.Set("MainWindow", "h", GetParent()->GetSize().GetHeight()); + + if (m_BreakpointWindow) m_BreakpointWindow->Save(file); + if (m_RegisterWindow) m_RegisterWindow->Save(file); + if (m_MemoryWindow) m_MemoryWindow->Save(file); + if (m_JitWindow) m_JitWindow->Save(file); + */ + + ini.Save(DEBUGGER_CONFIG_FILE); } void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStartupParameter) @@ -418,34 +393,6 @@ void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStart sizerBig->Fit(this); sync_event.Init(); - - if (bRegisterWindow) OnToggleRegisterWindow(true, m_NB0); - if (bBreakpointWindow) OnToggleBreakPointWindow(true, m_NB1); - if (bMemoryWindow) OnToggleMemoryWindow(true, m_NB0); - if (bJitWindow) OnToggleJitWindow(true, m_NB0); - if (bSoundWindow) OnToggleSoundWindow(true, m_NB1); - /* - { - // Possible todo: add some kind of if here to? can it fail? - CPluginManager::GetInstance().OpenDebug( - GetHandle(), - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDSPPlugin.c_str(), - PLUGIN_TYPE_DSP, true - ); - } // don't have any else, just ignore it - */ - - if (bVideoWindow) OnToggleVideoWindow(true, m_NB1); - /* - { - // possible todo: add some kind of if here to? can it fail? - CPluginManager::GetInstance().OpenDebug( - GetHandle(), - _LocalCoreStartupParameter.m_strVideoPlugin.c_str(), - PLUGIN_TYPE_VIDEO, true - ); - } // don't have any else, just ignore it - */ } diff --git a/Source/Core/DebuggerWX/Src/CodeWindow.h b/Source/Core/DebuggerWX/Src/CodeWindow.h index c22ab913a5..bc0f69858a 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindow.h +++ b/Source/Core/DebuggerWX/Src/CodeWindow.h @@ -51,6 +51,8 @@ class CCodeWindow */ ~CCodeWindow(); + void Load(); + void Save(); // Function redirection wxFrame *GetParentFrame(); @@ -60,17 +62,13 @@ class CCodeWindow bool IsActive(); void UpdateToolbar(wxAuiToolBar *); void UpdateNotebook(int, wxAuiNotebook *); - wxBitmap page_bmp; + wxBitmap aNormalFile; #ifdef _WIN32 wxWindow * GetWxWindow(wxString); #endif wxWindow * GetNootebookPage(wxString); void DoToggleWindow(int,bool); - void Load_(IniFile &file); - void Load(IniFile &file); - void Save(IniFile &file); - bool UseInterpreter(); bool BootToPause(); bool AutomaticStart(); @@ -86,7 +84,8 @@ class CCodeWindow void PopulateToolbar(wxAuiToolBar* toolBar); void CreateSymbolsMenu(); void UpdateButtonStates(); - void CCodeWindow::UpdateManager(); + void OpenPages(); + void UpdateManager(); // Sub dialogs wxMenuBar* pMenuBar; diff --git a/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp b/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp index e4d9729a11..2d2fb5d293 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp @@ -366,6 +366,16 @@ wxWindow * CCodeWindow::GetWxWindow(wxString Name) return NULL; } #endif +void CCodeWindow::OpenPages() +{ + if (bRegisterWindow) OnToggleRegisterWindow(true, m_NB0); + if (bBreakpointWindow) OnToggleBreakPointWindow(true, m_NB1); + if (bMemoryWindow) OnToggleMemoryWindow(true, m_NB0); + if (bJitWindow) OnToggleJitWindow(true, m_NB0); + // Todo, potentially add a safety check here since it will crash if ScanForPlugins() is not run yet + if (bSoundWindow) OnToggleSoundWindow(true, m_NB1); + if (bVideoWindow) OnToggleVideoWindow(true, m_NB1); +} void CCodeWindow::OnToggleWindow(wxCommandEvent& event) { DoToggleWindow(event.GetId(), GetMenuBar()->IsChecked(event.GetId())); @@ -384,11 +394,13 @@ void CCodeWindow::DoToggleWindow(int Id, bool Show) } void CCodeWindow::OnToggleRegisterWindow(bool Show, wxAuiNotebook * _NB) { + if(!_NB) return; + if (Show) { if (m_RegisterWindow && _NB->GetPageIndex(m_RegisterWindow) != wxNOT_FOUND) return; if (!m_RegisterWindow) m_RegisterWindow = new CRegisterWindow(GetParent()->GetParent()); - _NB->AddPage(m_RegisterWindow, wxT("Registers"), true, page_bmp ); + _NB->AddPage(m_RegisterWindow, wxT("Registers"), true, aNormalFile ); } else // hide { @@ -413,7 +425,7 @@ void CCodeWindow::OnToggleBreakPointWindow(bool Show, wxAuiNotebook * _NB) { if (m_BreakpointWindow && _NB->GetPageIndex(m_BreakpointWindow) != wxNOT_FOUND) return; if (!m_BreakpointWindow) m_BreakpointWindow = new CBreakPointWindow(this, GetParent()->GetParent()); - _NB->AddPage(m_BreakpointWindow, wxT("Breakpoints"), true, page_bmp ); + _NB->AddPage(m_BreakpointWindow, wxT("Breakpoints"), true, aNormalFile ); } else // hide { @@ -437,7 +449,7 @@ void CCodeWindow::OnToggleJitWindow(bool Show, wxAuiNotebook * _NB) { if (m_JitWindow && _NB->GetPageIndex(m_JitWindow) != wxNOT_FOUND) return; if (!m_JitWindow) m_JitWindow = new CJitWindow(GetParent()->GetParent()); - _NB->AddPage(m_JitWindow, wxT("JIT"), true, page_bmp ); + _NB->AddPage(m_JitWindow, wxT("JIT"), true, aNormalFile ); } else // hide { @@ -462,7 +474,7 @@ void CCodeWindow::OnToggleMemoryWindow(bool Show, wxAuiNotebook * _NB) { if (m_MemoryWindow && _NB->GetPageIndex(m_MemoryWindow) != wxNOT_FOUND) return; if (!m_MemoryWindow) m_MemoryWindow = new CMemoryWindow(GetParent()->GetParent()); - _NB->AddPage(m_MemoryWindow, wxT("Memory"), true, page_bmp ); + _NB->AddPage(m_MemoryWindow, wxT("Memory"), true, aNormalFile ); } else // hide { @@ -507,7 +519,7 @@ void CCodeWindow::OnToggleSoundWindow(bool Show, wxAuiNotebook * _NB) if (Win) { //Console->Log(LogTypes::LNOTICE, StringFromFormat("AddPage\n").c_str()); - _NB->AddPage(Win, wxT("Sound"), true, page_bmp ); + _NB->AddPage(Win, wxT("Sound"), true, aNormalFile ); } #endif } @@ -549,7 +561,7 @@ void CCodeWindow::OnToggleVideoWindow(bool Show, wxAuiNotebook * _NB) } Win = GetWxWindow(wxT("Video")); - if (Win) _NB->AddPage(Win, wxT("Video"), true, page_bmp ); + if (Win) _NB->AddPage(Win, wxT("Video"), true, aNormalFile ); #endif } else // hide diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 603ac02906..fa6e460a60 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -367,12 +367,12 @@ CFrame::CFrame(bool showLogWindow, if (UseDebugger) { - wxBitmap page_bmp = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16)); + wxBitmap aNormalFile = wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16,16)); static int Style = wxAUI_NB_TOP | wxAUI_NB_TAB_MOVE | wxAUI_NB_SCROLL_BUTTONS | wxAUI_NB_CLOSE_ON_ACTIVE_TAB | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER; m_NB1 = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxSize(430,200), Style); m_NB0 = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxSize(430,200), Style); - m_NB0->AddPage(g_pCodeWindow, wxT("Code"), false, page_bmp ); + m_NB0->AddPage(g_pCodeWindow, wxT("Code"), false, aNormalFile ); g_pCodeWindow->UpdateNotebook(0, m_NB0); g_pCodeWindow->UpdateNotebook(1, m_NB1); @@ -438,6 +438,9 @@ CFrame::CFrame(bool showLogWindow, // Create list of available plugins for the configuration window CPluginManager::GetInstance().ScanForPlugins(); + // Open notebook pages + if (UseDebugger) g_pCodeWindow->OpenPages(); + //if we are ever going back to optional iso caching: //m_GameListCtrl->Update(SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableIsoCache); m_GameListCtrl->Update(); @@ -502,6 +505,8 @@ void CFrame::OnClose(wxCloseEvent& event) { // Don't forget the skip or the window won't be destroyed event.Skip(); + // Save GUI settings + if (UseDebugger) g_pCodeWindow->Save(); if (Core::GetState() != Core::CORE_UNINITIALIZED) {