From 7b5b911c34482bea7ef3f0d6869dfb429a0ee004 Mon Sep 17 00:00:00 2001 From: John Peterson Date: Thu, 27 Aug 2009 15:53:19 +0000 Subject: [PATCH] GUI: Save notebook association for pages git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4079 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DebuggerWX/Src/CodeWindow.cpp | 84 +++++++++---------- Source/Core/DebuggerWX/Src/CodeWindow.h | 38 +++++---- Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp | 82 +++++++++++-------- Source/Core/DebuggerWX/Src/JitWindow.h | 2 +- Source/Core/DolphinWX/Src/Frame.cpp | 43 +++++----- Source/Core/DolphinWX/Src/Frame.h | 8 +- Source/Core/DolphinWX/Src/FrameTools.cpp | 86 +++++++++++++------- Source/Core/DolphinWX/Src/Globals.h | 1 + 8 files changed, 194 insertions(+), 150 deletions(-) diff --git a/Source/Core/DebuggerWX/Src/CodeWindow.cpp b/Source/Core/DebuggerWX/Src/CodeWindow.cpp index a741de8640..11c1128b39 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindow.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindow.cpp @@ -265,36 +265,36 @@ void CCodeWindow::Load() DebuggerFont.SetNativeFontInfoUserDesc(wxString::FromAscii(fontDesc.c_str())); // Decide what windows to use - ini.Get("ShowOnStart", "RegisterWindow", &bRegisterWindow, true); - ini.Get("ShowOnStart", "BreakpointWindow", &bBreakpointWindow, true); - 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", "Code", &bCodeWindow, true); + ini.Get("ShowOnStart", "Registers", &bRegisterWindow, false); + ini.Get("ShowOnStart", "Breakpoints", &bBreakpointWindow, false); + ini.Get("ShowOnStart", "Memory", &bMemoryWindow, false); + ini.Get("ShowOnStart", "JIT", &bJitWindow, false); + ini.Get("ShowOnStart", "Sound", &bSoundWindow, false); + ini.Get("ShowOnStart", "Video", &bVideoWindow, false); + + ini.Get("Notebook", "Log", &iLogWindow, 1); + ini.Get("Notebook", "Code", &iCodeWindow, 1); + ini.Get("Notebook", "Registers", &iRegisterWindow, 1); + ini.Get("Notebook", "Breakpoints", &iBreakpointWindow, 0); + ini.Get("Notebook", "Memory", &iMemoryWindow, 1); + ini.Get("Notebook", "JIT", &iJitWindow, 1); + ini.Get("Notebook", "Sound", &iSoundWindow, 0); + ini.Get("Notebook", "Video", &iVideoWindow, 0); + + // Remove bad values + iCodeWindow = Limit(iCodeWindow, 0, Parent->m_NB.size()-1); + iRegisterWindow = Limit(iRegisterWindow, 0, Parent->m_NB.size()-1); + iBreakpointWindow = Limit(iBreakpointWindow, 0, Parent->m_NB.size()-1); + iMemoryWindow = Limit(iMemoryWindow, 0, Parent->m_NB.size()-1); + iJitWindow = Limit(iJitWindow, 0, Parent->m_NB.size()-1); + iSoundWindow = Limit(iSoundWindow, 0, Parent->m_NB.size()-1); + iVideoWindow = Limit(iVideoWindow, 0, Parent->m_NB.size()-1); // 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; - ini.Get("CodeWindow", "x", &x, GetPosition().x); - ini.Get("CodeWindow", "y", &y, GetPosition().y); - ini.Get("CodeWindow", "w", &w, GetSize().GetWidth()); - ini.Get("CodeWindow", "h", &h, GetSize().GetHeight()); - this->SetSize(x, y, w, h); - ini.Get("MainWindow", "x", &x, 100); - ini.Get("MainWindow", "y", &y, 100); - ini.Get("MainWindow", "w", &w, 800); - ini.Get("MainWindow", "h", &h, 600); - GetParent()->SetSize(x, y, w, h); -} -*/ - - void CCodeWindow::Save() { IniFile ini; @@ -306,13 +306,23 @@ void CCodeWindow::Save() ini.Set("ShowOnStart", "AutomaticStart", GetMenuBar()->IsChecked(IDM_AUTOMATICSTART)); ini.Set("ShowOnStart", "BootToPause", GetMenuBar()->IsChecked(IDM_BOOTTOPAUSE)); - // Save windows settings - ini.Set("ShowOnStart", "RegisterWindow", GetMenuBar()->IsChecked(IDM_REGISTERWINDOW)); - ini.Set("ShowOnStart", "BreakpointWindow", GetMenuBar()->IsChecked(IDM_BREAKPOINTWINDOW)); - ini.Set("ShowOnStart", "MemoryWindow", GetMenuBar()->IsChecked(IDM_MEMORYWINDOW)); - 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 windows settings + ini.Set("ShowOnStart", "Code", GetMenuBar()->IsChecked(IDM_CODEWINDOW)); + ini.Set("ShowOnStart", "Registers", GetMenuBar()->IsChecked(IDM_REGISTERWINDOW)); + ini.Set("ShowOnStart", "Breakpoints", GetMenuBar()->IsChecked(IDM_BREAKPOINTWINDOW)); + ini.Set("ShowOnStart", "Memory", GetMenuBar()->IsChecked(IDM_MEMORYWINDOW)); + ini.Set("ShowOnStart", "JIT", GetMenuBar()->IsChecked(IDM_JITWINDOW)); + ini.Set("ShowOnStart", "Sound", GetMenuBar()->IsChecked(IDM_SOUNDWINDOW)); + ini.Set("ShowOnStart", "Video", GetMenuBar()->IsChecked(IDM_VIDEOWINDOW)); + + ini.Set("Notebook", "Log", iLogWindow); + ini.Set("Notebook", "Code", iCodeWindow); + ini.Set("Notebook", "Registers", iRegisterWindow); + ini.Set("Notebook", "Breakpoints", iBreakpointWindow); + ini.Set("Notebook", "Memory", iMemoryWindow); + ini.Set("Notebook", "JIT", iJitWindow); + ini.Set("Notebook", "Sound", iSoundWindow); + ini.Set("Notebook", "Video", iVideoWindow); // Save window settings /* @@ -432,30 +442,22 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam // dualcore->Check(_LocalCoreStartupParameter.bUseDualCore); pMenuBar->Append(pCoreMenu, _T("&CPU Mode")); - - - // Views + // Views wxMenu* pDebugDialogs = new wxMenu; wxMenuItem* pRegister = pDebugDialogs->Append(IDM_REGISTERWINDOW, _T("&Registers"), wxEmptyString, wxITEM_CHECK); pRegister->Check(bRegisterWindow); - wxMenuItem* pBreakPoints = pDebugDialogs->Append(IDM_BREAKPOINTWINDOW, _T("&BreakPoints"), wxEmptyString, wxITEM_CHECK); pBreakPoints->Check(bBreakpointWindow); - wxMenuItem* pMemory = pDebugDialogs->Append(IDM_MEMORYWINDOW, _T("&Memory"), wxEmptyString, wxITEM_CHECK); pMemory->Check(bMemoryWindow); - wxMenuItem* pJit = pDebugDialogs->Append(IDM_JITWINDOW, _T("&Jit"), wxEmptyString, wxITEM_CHECK); pJit->Check(bJitWindow); - wxMenuItem* pSound = pDebugDialogs->Append(IDM_SOUNDWINDOW, _T("&Sound"), wxEmptyString, wxITEM_CHECK); pSound->Check(bSoundWindow); - wxMenuItem* pVideo = pDebugDialogs->Append(IDM_VIDEOWINDOW, _T("&Video"), wxEmptyString, wxITEM_CHECK); pVideo->Check(bVideoWindow); - pDebugDialogs->AppendSeparator(); wxMenuItem* pFontPicker = pDebugDialogs->Append(IDM_FONTPICKER, _T("&Font..."), wxEmptyString, wxITEM_NORMAL); diff --git a/Source/Core/DebuggerWX/Src/CodeWindow.h b/Source/Core/DebuggerWX/Src/CodeWindow.h index a97ec6d6ce..cbb9497810 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindow.h +++ b/Source/Core/DebuggerWX/Src/CodeWindow.h @@ -63,10 +63,10 @@ class CCodeWindow CFrame *Parent; wxMenuBar * GetMenuBar(); wxAuiToolBar * GetToolBar(); - #ifdef _WIN32 wxWindow * GetWxWindow(wxString); - #endif - wxWindow * GetNootebookPage(wxString); + wxWindow * GetNootebookPage(wxString); + int Limit(int,int,int); + int GetNootebookAffiliation(wxString); wxBitmap m_Bitmaps[ToolbarDebugBitmapMax]; bool UseInterpreter(); @@ -87,12 +87,12 @@ class CCodeWindow void UpdateManager(); void OnToggleWindow(wxCommandEvent& event); - void OnToggleRegisterWindow(bool,wxAuiNotebook*); - void OnToggleBreakPointWindow(bool,wxAuiNotebook*); - void OnToggleMemoryWindow(bool,wxAuiNotebook*); - void OnToggleJitWindow(bool,wxAuiNotebook*); - void OnToggleSoundWindow(bool,wxAuiNotebook*); - void OnToggleVideoWindow(bool,wxAuiNotebook*); + void OnToggleRegisterWindow(bool,int); + void OnToggleBreakPointWindow(bool,int); + void OnToggleMemoryWindow(bool,int); + void OnToggleJitWindow(bool,int); + void OnToggleSoundWindow(bool,int); + void OnToggleVideoWindow(bool,int); void OnChangeFont(wxCommandEvent& event); // Sub dialogs @@ -102,6 +102,17 @@ class CCodeWindow CMemoryWindow* m_MemoryWindow; CJitWindow* m_JitWindow; + // Settings + bool bAutomaticStart; bool bBootToPause; + bool bLogWindow; bool iLogWindow; + bool bCodeWindow; int iCodeWindow; + bool bRegisterWindow; int iRegisterWindow; + bool bBreakpointWindow; int iBreakpointWindow; + bool bMemoryWindow; int iMemoryWindow; + bool bJitWindow; int iJitWindow; + bool bSoundWindow; int iSoundWindow; + bool bVideoWindow; int iVideoWindow; + private: enum @@ -114,15 +125,6 @@ class CCodeWindow ID_SYMBOLLIST }; - // Settings - bool bAutomaticStart; bool bBootToPause; - bool bRegisterWindow; - bool bBreakpointWindow; - bool bMemoryWindow; - bool bJitWindow; - bool bSoundWindow; - bool bVideoWindow; - void OnSymbolListChange(wxCommandEvent& event); void OnSymbolListContextMenu(wxContextMenuEvent& event); void OnCallstackListChange(wxCommandEvent& event); diff --git a/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp b/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp index db7dff1635..f4d51a7bf6 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindowSJP.cpp @@ -33,7 +33,6 @@ #include // ugly that this lib included code from the main -#include "../../DolphinWX/Src/Globals.h" #include "../../DolphinWX/Src/WxUtils.h" #include "Host.h" @@ -327,21 +326,21 @@ void CCodeWindow::OnChangeFont(wxCommandEvent& event) // ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ wxWindow * CCodeWindow::GetNootebookPage(wxString Name) { - if (!Parent->m_NB0 || !Parent->m_NB1) return NULL; + if (!Parent->m_NB[0] || !Parent->m_NB[1]) return NULL; - for(u32 i = 0; i <= Parent->m_NB0->GetPageCount(); i++) + for(u32 i = 0; i <= Parent->m_NB[0]->GetPageCount(); i++) { - if (Parent->m_NB0->GetPageText(i).IsSameAs(Name)) return Parent->m_NB0->GetPage(i); + if (Parent->m_NB[0]->GetPageText(i).IsSameAs(Name)) return Parent->m_NB[0]->GetPage(i); } - for(u32 i = 0; i <= Parent->m_NB1->GetPageCount(); i++) + for(u32 i = 0; i <= Parent->m_NB[1]->GetPageCount(); i++) { - if (Parent->m_NB1->GetPageText(i).IsSameAs(Name)) return Parent->m_NB1->GetPage(i); + if (Parent->m_NB[1]->GetPageText(i).IsSameAs(Name)) return Parent->m_NB[1]->GetPage(i); } return NULL; } -#ifdef _WIN32 wxWindow * CCodeWindow::GetWxWindow(wxString Name) { + #ifdef _WIN32 HWND hWnd = ::FindWindow(NULL, Name.c_str()); if (hWnd) { @@ -350,7 +349,9 @@ wxWindow * CCodeWindow::GetWxWindow(wxString Name) Win->AdoptAttributesFromHWND(); return Win; } - else if (Parent->FindWindowByName(Name)) + else + #endif + if (Parent->FindWindowByName(Name)) { return Parent->FindWindowByName(Name); } @@ -365,79 +366,93 @@ wxWindow * CCodeWindow::GetWxWindow(wxString Name) else return NULL; } -#endif +int CCodeWindow::Limit(int i, int Low, int High) +{ + if (i < Low) return Low; + if (i > High) return High; + return i; +} void CCodeWindow::OpenPages() { - if (bRegisterWindow) Parent->DoToggleWindow(IDM_REGISTERWINDOW, true); - if (bBreakpointWindow) Parent->DoToggleWindow(IDM_BREAKPOINTWINDOW, true); - if (bMemoryWindow) Parent->DoToggleWindow(IDM_MEMORYWINDOW, true); - if (bJitWindow) Parent->DoToggleWindow(IDM_JITWINDOW, true); - if (bSoundWindow) Parent->DoToggleWindow(IDM_SOUNDWINDOW, true); - if (bVideoWindow) Parent->DoToggleWindow(IDM_VIDEOWINDOW, true); + ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener(); + Console->Log(LogTypes::LNOTICE, StringFromFormat( + "OpenPages:%i %i\n", iRegisterWindow, iBreakpointWindow).c_str()); + + if (bRegisterWindow) Parent->DoToggleWindow(IDM_REGISTERWINDOW, bRegisterWindow); + if (bBreakpointWindow) Parent->DoToggleWindow(IDM_BREAKPOINTWINDOW, bBreakpointWindow); + if (bMemoryWindow) Parent->DoToggleWindow(IDM_MEMORYWINDOW, bMemoryWindow); + if (bJitWindow) Parent->DoToggleWindow(IDM_JITWINDOW, bJitWindow); + if (bSoundWindow) Parent->DoToggleWindow(IDM_SOUNDWINDOW, bSoundWindow); + if (bVideoWindow) Parent->DoToggleWindow(IDM_VIDEOWINDOW, bVideoWindow); } void CCodeWindow::OnToggleWindow(wxCommandEvent& event) { Parent->DoToggleWindow(event.GetId(), GetMenuBar()->IsChecked(event.GetId())); } -void CCodeWindow::OnToggleRegisterWindow(bool Show, wxAuiNotebook * _NB) +void CCodeWindow::OnToggleRegisterWindow(bool Show, int i) { if (Show) { - if (m_RegisterWindow && _NB->GetPageIndex(m_RegisterWindow) != wxNOT_FOUND) return; + if (i < 0 || i > Parent->m_NB.size()-1) return; + if (m_RegisterWindow && Parent->m_NB[i]->GetPageIndex(m_RegisterWindow) != wxNOT_FOUND) return; if (!m_RegisterWindow) m_RegisterWindow = new CRegisterWindow(Parent); - _NB->AddPage(m_RegisterWindow, wxT("Registers"), true, Parent->aNormalFile ); + Parent->m_NB[i]->AddPage(m_RegisterWindow, wxT("Registers"), true, Parent->aNormalFile ); } else // hide Parent->DoRemovePage (m_RegisterWindow); } -void CCodeWindow::OnToggleBreakPointWindow(bool Show, wxAuiNotebook * _NB) +void CCodeWindow::OnToggleBreakPointWindow(bool Show, int i) { if (Show) { - if (m_BreakpointWindow && _NB->GetPageIndex(m_BreakpointWindow) != wxNOT_FOUND) return; + if (i < 0 || i > Parent->m_NB.size()-1) return; + if (m_BreakpointWindow && Parent->m_NB[i]->GetPageIndex(m_BreakpointWindow) != wxNOT_FOUND) return; if (!m_BreakpointWindow) m_BreakpointWindow = new CBreakPointWindow(this, Parent); - _NB->AddPage(m_BreakpointWindow, wxT("Breakpoints"), true, Parent->aNormalFile ); + Parent->m_NB[i]->AddPage(m_BreakpointWindow, wxT("Breakpoints"), true, Parent->aNormalFile ); } else // hide Parent->DoRemovePage(m_BreakpointWindow); } -void CCodeWindow::OnToggleJitWindow(bool Show, wxAuiNotebook * _NB) +void CCodeWindow::OnToggleJitWindow(bool Show, int i) { if (Show) { - if (m_JitWindow && _NB->GetPageIndex(m_JitWindow) != wxNOT_FOUND) return; + if (i < 0 || i > Parent->m_NB.size()-1) return; + if (m_JitWindow && Parent->m_NB[i]->GetPageIndex(m_JitWindow) != wxNOT_FOUND) return; if (!m_JitWindow) m_JitWindow = new CJitWindow(Parent); - _NB->AddPage(m_JitWindow, wxT("JIT"), true, Parent->aNormalFile ); + Parent->m_NB[i]->AddPage(m_JitWindow, wxT("JIT"), true, Parent->aNormalFile ); } else // hide Parent->DoRemovePage(m_JitWindow); } -void CCodeWindow::OnToggleMemoryWindow(bool Show, wxAuiNotebook * _NB) +void CCodeWindow::OnToggleMemoryWindow(bool Show, int i) { if (Show) { - if (m_MemoryWindow && _NB->GetPageIndex(m_MemoryWindow) != wxNOT_FOUND) return; + if (i < 0 || i > Parent->m_NB.size()-1) return; + if (m_MemoryWindow && Parent->m_NB[i]->GetPageIndex(m_MemoryWindow) != wxNOT_FOUND) return; if (!m_MemoryWindow) m_MemoryWindow = new CMemoryWindow(Parent); - _NB->AddPage(m_MemoryWindow, wxT("Memory"), true, Parent->aNormalFile ); + Parent->m_NB[i]->AddPage(m_MemoryWindow, wxT("Memory"), true, Parent->aNormalFile ); } else // hide Parent->DoRemovePage(m_MemoryWindow); } //Toggle Sound Debugging Window -void CCodeWindow::OnToggleSoundWindow(bool Show, wxAuiNotebook * _NB) +void CCodeWindow::OnToggleSoundWindow(bool Show, int i) { //ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener(); if (Show) { + if (i < 0 || i > Parent->m_NB.size()-1) return; #ifdef _WIN32 wxWindow *Win = GetWxWindow(wxT("Sound")); - if (Win && _NB->GetPageIndex(Win) != wxNOT_FOUND) return; + if (Win && Parent->m_NB[i]->GetPageIndex(Win) != wxNOT_FOUND) return; { #endif @@ -455,7 +470,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, Parent->aNormalFile ); + Parent->m_NB[i]->AddPage(Win, wxT("Sound"), true, Parent->aNormalFile ); } #endif } @@ -475,15 +490,16 @@ void CCodeWindow::OnToggleSoundWindow(bool Show, wxAuiNotebook * _NB) } // Toggle Video Debugging Window -void CCodeWindow::OnToggleVideoWindow(bool Show, wxAuiNotebook * _NB) +void CCodeWindow::OnToggleVideoWindow(bool Show, int i) { //GetMenuBar()->Check(event.GetId(), false); // Turn off if (Show) { + if (i < 0 || i > Parent->m_NB.size()-1) return; #ifdef _WIN32 wxWindow *Win = GetWxWindow(wxT("Video")); - if (Win && _NB->GetPageIndex(Win) != wxNOT_FOUND) return; + if (Win && Parent->m_NB[i]->GetPageIndex(Win) != wxNOT_FOUND) return; { #endif @@ -497,7 +513,7 @@ void CCodeWindow::OnToggleVideoWindow(bool Show, wxAuiNotebook * _NB) } Win = GetWxWindow(wxT("Video")); - if (Win) _NB->AddPage(Win, wxT("Video"), true, Parent->aNormalFile ); + if (Win) Parent->m_NB[i]->AddPage(Win, wxT("Video"), true, Parent->aNormalFile ); #endif } else // hide diff --git a/Source/Core/DebuggerWX/Src/JitWindow.h b/Source/Core/DebuggerWX/Src/JitWindow.h index 76e0066c31..50a2152fb7 100644 --- a/Source/Core/DebuggerWX/Src/JitWindow.h +++ b/Source/Core/DebuggerWX/Src/JitWindow.h @@ -24,10 +24,10 @@ #include #include #include + #include "Debugger.h" #include "MemoryView.h" #include "Thread.h" - #include "CoreParameter.h" diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index fc28b4d9e8..ca4d07f768 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -302,6 +302,7 @@ EVT_TEXT(wxID_ANY, CFrame::PostEvent) EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, CFrame::OnNotebookPageClose) EVT_AUINOTEBOOK_ALLOW_DND(wxID_ANY, CFrame::OnAllowNotebookDnD) +EVT_AUINOTEBOOK_PAGE_CHANGED(wxID_ANY, CFrame::OnNotebookPageChanged) END_EVENT_TABLE() ///////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -320,7 +321,6 @@ CFrame::CFrame(bool showLogWindow, long style) : wxFrame(parent, id, title, pos, size, style) , UseDebugger(_UseDebugger), m_LogWindow(NULL) - , m_NB0(NULL), m_NB1(NULL), m_NB2(NULL) , m_pStatusBar(NULL), bRenderToMain(true), HaveLeds(false) , HaveSpeakers(false), m_Panel(NULL), m_ToolBar(NULL), m_ToolBarDebug(NULL) , m_bLogWindow(showLogWindow || SConfig::GetInstance().m_InterfaceLogWindow) @@ -330,8 +330,15 @@ CFrame::CFrame(bool showLogWindow, #endif { + // Give it a console + ConsoleListener *Console = LogManager::GetInstance()->getConsoleListener(); + if (SConfig::GetInstance().m_InterfaceConsole) Console->Open(); + + // Default + m_NB.resize(3); for (int i = 0; i < m_NB.size(); i++) m_NB[i] = NULL; + // Start debugging mazimized - //if (UseDebugger) this->Maximize(true); + if (UseDebugger) this->Maximize(true); // Debugger class if (UseDebugger) g_pCodeWindow = new CCodeWindow(SConfig::GetInstance().m_LocalCoreStartupParameter, this, this); @@ -370,14 +377,14 @@ CFrame::CFrame(bool showLogWindow, if (UseDebugger) { - m_NB0 = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Style); - m_NB1 = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Style); - m_NB2 = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Style); - m_NB1->AddPage(g_pCodeWindow, wxT("Code"), false, aNormalFile); + m_NB[0] = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Style); + m_NB[1] = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Style); + m_NB[2] = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Style); + m_NB[g_pCodeWindow->iCodeWindow]->AddPage(g_pCodeWindow, wxT("Code"), false, aNormalFile); } else { - m_NB0 = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Style); + m_NB[0] = new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Style); } // ------------------------------------------------------------------------- @@ -419,14 +426,14 @@ CFrame::CFrame(bool showLogWindow, if (UseDebugger) { m_Mgr->AddPane(m_Panel, wxAuiPaneInfo().Name(wxT("Pane0")).Caption(wxT("Pane0")).Hide()); - m_Mgr->AddPane(m_NB0, wxAuiPaneInfo().Name(wxT("Pane1")).Caption(wxT("Pane1")).Hide()); - m_Mgr->AddPane(m_NB1, wxAuiPaneInfo().Name(wxT("Pane2")).Caption(wxT("Pane2")).Hide()); - m_Mgr->AddPane(m_NB2, wxAuiPaneInfo().Name(wxT("Pane3")).Caption(wxT("Pane3")).Hide()); + m_Mgr->AddPane(m_NB[0], wxAuiPaneInfo().Name(wxT("Pane1")).Caption(wxT("Pane1")).Hide()); + m_Mgr->AddPane(m_NB[1], wxAuiPaneInfo().Name(wxT("Pane2")).Caption(wxT("Pane2")).Hide()); + m_Mgr->AddPane(m_NB[2], wxAuiPaneInfo().Name(wxT("Pane3")).Caption(wxT("Pane3")).Hide()); } else { m_Mgr->AddPane(m_Panel, wxAuiPaneInfo().Name(wxT("Pane0")).Caption(wxT("Pane0")).Hide()); - m_Mgr->AddPane(m_NB0, wxAuiPaneInfo().Name(wxT("Pane1")).Caption(wxT("Pane1")).Hide()); + m_Mgr->AddPane(m_NB[0], wxAuiPaneInfo().Name(wxT("Pane1")).Caption(wxT("Pane1")).Hide()); } // Setup perspectives @@ -487,14 +494,9 @@ CFrame::CFrame(bool showLogWindow, // Open notebook pages if (UseDebugger) g_pCodeWindow->OpenPages(); - if (m_bLogWindow) ToggleLogWindow(true, UseDebugger ? m_NB1 : m_NB0); + if (m_bLogWindow) ToggleLogWindow(true, UseDebugger ? 1 : 0); if (!UseDebugger) SetSimplePaneSize(); - // Give it a console - ConsoleListener *console = LogManager::GetInstance()->getConsoleListener(); - if (SConfig::GetInstance().m_InterfaceConsole) - console->Open(); - //if we are ever going back to optional iso caching: //m_GameListCtrl->Update(SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableIsoCache); m_GameListCtrl->Update(); @@ -568,13 +570,6 @@ void CFrame::OnClose(wxCloseEvent& event) UpdateGUI(); } } -void CFrame::OnAllowNotebookDnD(wxAuiNotebookEvent& event) -{ - event.Skip(); - wxAuiNotebook* Ctrl = (wxAuiNotebook*)event.GetEventObject(); - // If we drag away the last one the tab bar goes away and we can't add any panes to it - if (Ctrl->GetPageCount() > 1) event.Allow(); -} void CFrame::DoFullscreen(bool _F) { diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index ab38bb0507..64b95506a3 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -74,8 +74,8 @@ class CFrame : public wxFrame void DoStop(); bool bRenderToMain; void UpdateGUI(); - void ToggleLogWindow(bool, wxAuiNotebook * _NB = NULL); - void ToggleConsole(bool, wxAuiNotebook * _NB = NULL); + void ToggleLogWindow(bool, int i = -1); + void ToggleConsole(bool, int i = -1); void PostEvent(wxCommandEvent& event); void PostMenuEvent(wxMenuEvent& event); void PostUpdateUIEvent(wxUpdateUIEvent& event); @@ -100,13 +100,15 @@ class CFrame : public wxFrame // AUI wxAuiManager *m_Mgr; wxAuiToolBar *m_ToolBar, *m_ToolBarDebug, *m_ToolBarAui; - wxAuiNotebook *m_NB0, *m_NB1, *m_NB2; + std::vector m_NB; int iLeftWidth[2], iMidWidth[2]; // Perspectives wxString AuiFullscreen, AuiCurrent; wxArrayString AuiPerspective; void OnNotebookPageClose(wxAuiNotebookEvent& event); void OnAllowNotebookDnD(wxAuiNotebookEvent& event); + void OnNotebookPageChanged(wxAuiNotebookEvent& event); + int GetNootebookAffiliation(wxString Name); void DoToggleWindow(int,bool); void DoRemovePage(wxWindow *, bool Hide = true); void DoLoadPerspective(int); diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 15688a3b1b..018be9cd63 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -860,6 +860,44 @@ void CFrame::OnFrameSkip(wxCommandEvent& event) ///////////////////////////////////////////////////////////////////////////////////////////////////////// // Notebooks // ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ +int CFrame::GetNootebookAffiliation(wxString Name) +{ + for (int i = 0; i < m_NB.size(); i++) + { + if (!m_NB[i]) continue; + for(u32 j = 0; j <= m_NB[i]->GetPageCount(); j++) + { + if (m_NB[i]->GetPageText(j).IsSameAs(Name)) return i; + } + } + return -1; +} +void CFrame::DoToggleWindow(int Id, bool Show) +{ + switch (Id) + { + case IDM_LOGWINDOW: ToggleLogWindow(Show, UseDebugger ? g_pCodeWindow->iLogWindow : 0); break; + case IDM_REGISTERWINDOW: g_pCodeWindow->OnToggleRegisterWindow(Show, g_pCodeWindow->iRegisterWindow); break; + case IDM_BREAKPOINTWINDOW: g_pCodeWindow->OnToggleBreakPointWindow(Show, g_pCodeWindow->iBreakpointWindow); break; + case IDM_MEMORYWINDOW: g_pCodeWindow->OnToggleMemoryWindow(Show, g_pCodeWindow->iMemoryWindow); break; + case IDM_JITWINDOW: g_pCodeWindow->OnToggleJitWindow(Show, g_pCodeWindow->iJitWindow); break; + case IDM_SOUNDWINDOW: g_pCodeWindow->OnToggleSoundWindow(Show, g_pCodeWindow->iSoundWindow); break; + case IDM_VIDEOWINDOW: g_pCodeWindow->OnToggleVideoWindow(Show, g_pCodeWindow->iVideoWindow); break; + } +} +void CFrame::OnNotebookPageChanged(wxAuiNotebookEvent& event) +{ + event.Skip(); + // Update the notebook affiliation + if(GetNootebookAffiliation(wxT("Log")) >= 0) g_pCodeWindow->iLogWindow = GetNootebookAffiliation(wxT("Log")); + if(GetNootebookAffiliation(wxT("Code")) >= 0) g_pCodeWindow->iCodeWindow = GetNootebookAffiliation(wxT("Code")); + if(GetNootebookAffiliation(wxT("Registers")) >= 0) g_pCodeWindow->iRegisterWindow = GetNootebookAffiliation(wxT("Registers")); + if(GetNootebookAffiliation(wxT("Breakpoints")) >= 0) g_pCodeWindow->iBreakpointWindow = GetNootebookAffiliation(wxT("Breakpoints")); + if(GetNootebookAffiliation(wxT("JIT")) >= 0) g_pCodeWindow->iJitWindow = GetNootebookAffiliation(wxT("JIT")); + if(GetNootebookAffiliation(wxT("Memory")) >= 0) g_pCodeWindow->iMemoryWindow = GetNootebookAffiliation(wxT("Memory")); + if(GetNootebookAffiliation(wxT("Sound")) >= 0) g_pCodeWindow->iSoundWindow = GetNootebookAffiliation(wxT("Sound")); + if(GetNootebookAffiliation(wxT("Video")) >= 0) g_pCodeWindow->iVideoWindow = GetNootebookAffiliation(wxT("Video")); +} void CFrame::OnNotebookPageClose(wxAuiNotebookEvent& event) { // Override event @@ -875,10 +913,16 @@ void CFrame::OnNotebookPageClose(wxAuiNotebookEvent& event) if (Ctrl->GetPageText(event.GetSelection()).IsSameAs(wxT("Sound"))) { GetMenuBar()->FindItem(IDM_SOUNDWINDOW)->Check(false); DoToggleWindow(IDM_SOUNDWINDOW, false); } if (Ctrl->GetPageText(event.GetSelection()).IsSameAs(wxT("Video"))) { GetMenuBar()->FindItem(IDM_VIDEOWINDOW)->Check(false); DoToggleWindow(IDM_VIDEOWINDOW, false); } } - +void CFrame::OnAllowNotebookDnD(wxAuiNotebookEvent& event) +{ + event.Skip(); + wxAuiNotebook* Ctrl = (wxAuiNotebook*)event.GetEventObject(); + // If we drag away the last one the tab bar goes away and we can't add any panes to it + if (Ctrl->GetPageCount() > 1) event.Allow(); +} void CFrame::HidePane() { - if (m_NB0->GetPageCount() == 0) + if (m_NB[0]->GetPageCount() == 0) m_Mgr->GetPane(wxT("Pane1")).Hide(); else m_Mgr->GetPane(wxT("Pane1")).Show(); @@ -897,17 +941,12 @@ void CFrame::DoRemovePage(wxWindow * Win, bool Hide) if (Win) { - if (m_NB0) + for (int i = 0; i < m_NB.size(); i++) { - if (m_NB0->GetPageIndex(Win) != wxNOT_FOUND) m_NB0->RemovePage(m_NB0->GetPageIndex(Win)); - } - if (m_NB1) - { - if (m_NB1->GetPageIndex(Win) != wxNOT_FOUND) m_NB1->RemovePage(m_NB1->GetPageIndex(Win)); - } - if (m_NB2) - { - if (m_NB2->GetPageIndex(Win) != wxNOT_FOUND) m_NB2->RemovePage(m_NB2->GetPageIndex(Win)); + if (m_NB[i]) + { + if (m_NB[i]->GetPageIndex(Win) != wxNOT_FOUND) m_NB[i]->RemovePage(m_NB[i]->GetPageIndex(Win)); + } } if (Hide) Win->Hide(); } @@ -947,34 +986,21 @@ void CFrame::OnToggleStatusbar(wxCommandEvent& event) this->SendSizeEvent(); } -void CFrame::DoToggleWindow(int Id, bool Show) -{ - switch (Id) - { - case IDM_LOGWINDOW: ToggleLogWindow(Show, UseDebugger ? m_NB1 : m_NB0); break; - case IDM_REGISTERWINDOW: g_pCodeWindow->OnToggleRegisterWindow(Show, m_NB1); break; - case IDM_BREAKPOINTWINDOW: g_pCodeWindow->OnToggleBreakPointWindow(Show, m_NB0); break; - case IDM_MEMORYWINDOW: g_pCodeWindow->OnToggleMemoryWindow(Show, m_NB1); break; - case IDM_JITWINDOW: g_pCodeWindow->OnToggleJitWindow(Show, m_NB1); break; - case IDM_SOUNDWINDOW: g_pCodeWindow->OnToggleSoundWindow(Show, m_NB0); break; - case IDM_VIDEOWINDOW: g_pCodeWindow->OnToggleVideoWindow(Show, m_NB0); break; - } -} // Enable and disable the log window void CFrame::OnToggleLogWindow(wxCommandEvent& event) { DoToggleWindow(event.GetId(), event.IsChecked()); } -void CFrame::ToggleLogWindow(bool Show, wxAuiNotebook * _NB) +void CFrame::ToggleLogWindow(bool Show, int i) { SConfig::GetInstance().m_InterfaceLogWindow = Show; if (Show) { - if (!_NB) return; + if (!m_NB[i]) return; - if (m_LogWindow && _NB->GetPageIndex(m_LogWindow) != wxNOT_FOUND) return; + if (m_LogWindow && m_NB[i]->GetPageIndex(m_LogWindow) != wxNOT_FOUND) return; if (!m_LogWindow) m_LogWindow = new CLogWindow(this); - _NB->AddPage(m_LogWindow, wxT("Log"), true, aNormalFile); + m_NB[i]->AddPage(m_LogWindow, wxT("Log"), true, aNormalFile); } else { @@ -992,7 +1018,7 @@ void CFrame::OnToggleConsole(wxCommandEvent& event) { ToggleConsole(event.IsChecked()); } -void CFrame::ToggleConsole(bool Show, wxAuiNotebook * _NB) +void CFrame::ToggleConsole(bool Show, int i) { ConsoleListener *Console = LogManager::GetInstance()->getConsoleListener(); SConfig::GetInstance().m_InterfaceConsole = Show; diff --git a/Source/Core/DolphinWX/Src/Globals.h b/Source/Core/DolphinWX/Src/Globals.h index 398d43da4c..8e1b431e78 100644 --- a/Source/Core/DolphinWX/Src/Globals.h +++ b/Source/Core/DolphinWX/Src/Globals.h @@ -134,6 +134,7 @@ enum IDM_FONTPICKER, IDM_LOGWINDOW, IDM_CONSOLE, + IDM_CODEWINDOW, IDM_REGISTERWINDOW, IDM_BREAKPOINTWINDOW, IDM_MEMORYWINDOW,