GUI: Save notebook association for pages

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4079 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson
2009-08-27 15:53:19 +00:00
parent 5f3752d358
commit 7b5b911c34
8 changed files with 194 additions and 150 deletions

View File

@ -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)
{

View File

@ -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<wxAuiNotebook*> 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);

View File

@ -860,6 +860,44 @@ void CFrame::OnFrameSkip(wxCommandEvent& event)
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Notebooks
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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;

View File

@ -134,6 +134,7 @@ enum
IDM_FONTPICKER,
IDM_LOGWINDOW,
IDM_CONSOLE,
IDM_CODEWINDOW,
IDM_REGISTERWINDOW,
IDM_BREAKPOINTWINDOW,
IDM_MEMORYWINDOW,