GUI: Better perspective saving, bugfixes

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4114 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2009-08-31 05:56:30 +00:00
parent 718c88ff6a
commit 30c87e4822
6 changed files with 210 additions and 156 deletions

View File

@ -452,10 +452,6 @@ void CCodeWindow::Load()
ini.Get(_Section.c_str(), "Sound", &iSoundWindow, 0);
ini.Get(_Section.c_str(), "Video", &iVideoWindow, 0);
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
Console->Log(LogTypes::LCUSTOM, StringFromFormat(
"Load: %i\n", iRegisterWindow).c_str());
// Boot to pause or not
ini.Get("ShowOnStart", "AutomaticStart", &bAutomaticStart, false);
ini.Get("ShowOnStart", "BootToPause", &bBootToPause, true);
@ -618,11 +614,6 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam
wxMenuItem* pRegister = pDebugDialogs->Append(IDM_REGISTERWINDOW, _T("&Registers"), wxEmptyString, wxITEM_CHECK);
pRegister->Check(bRegisterWindow);
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
Console->Log(LogTypes::LCUSTOM, StringFromFormat(
"bRegisterWindow: %i\n", bRegisterWindow).c_str());
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);

View File

@ -62,8 +62,7 @@ class CCodeWindow
// Parent interaction
CFrame *Parent;
wxMenuBar * GetMenuBar();
wxAuiToolBar * GetToolBar();
int Limit(int,int,int);
wxAuiToolBar * GetToolBar();
int GetNootebookAffiliation(wxString);
wxBitmap m_Bitmaps[ToolbarDebugBitmapMax];

View File

@ -325,12 +325,7 @@ void CCodeWindow::OnChangeFont(wxCommandEvent& event)
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Toogle windows
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
int CCodeWindow::Limit(int i, int Low, int High)
{
if (i < Low) return Low;
if (i > High) return High;
return i;
}
void CCodeWindow::OpenPages()
{
Parent->DoToggleWindow(IDM_CODEWINDOW, true);
@ -369,7 +364,7 @@ void CCodeWindow::OnToggleBreakPointWindow(bool Show, int i)
{
if (Show)
{
if (!m_RegisterWindow) m_BreakpointWindow = new CBreakPointWindow(this, Parent);
if (!m_BreakpointWindow) m_BreakpointWindow = new CBreakPointWindow(this, Parent);
Parent->DoAddPage(m_BreakpointWindow, i, "Breakpoints");
}
else // hide

View File

@ -421,6 +421,9 @@ CFrame::CFrame(bool showLogWindow,
RecreateToolbar();
if (!SConfig::GetInstance().m_InterfaceToolbar) DoToggleToolbar(false);
// Create list of available plugins for the configuration window
CPluginManager::GetInstance().ScanForPlugins();
// Setup perspectives
if (UseDebugger)
{
@ -463,59 +466,24 @@ CFrame::CFrame(bool showLogWindow,
if (TryParseInt(_SHeight.at(0).c_str(), &_Tmp)) Tmp.Height.push_back(_Tmp);
}
Perspectives.push_back(Tmp);
//Console->Log(LogTypes::LCUSTOM, StringFromFormat("Read: %s %s\n", _Width.c_str(), _Height.c_str()).c_str());
}
if (Perspectives.size() > 0)
{
// Create new panes with notebooks
for (int j = 0; j < Perspectives.at(0).Width.size() - 1; j++)
{
m_Mgr->AddPane(new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, DefaultNBStyle));
}
NamePanes();
std::vector<std::string> FormatNames;
SplitString(StringFromFormat("%s", Perspectives.at(0).Perspective.mb_str()), "|", FormatNames);
//Console->Log(LogTypes::LCUSTOM, StringFromFormat("Perspective: %s\n", Perspectives.at(0).Perspective.mb_str()).c_str());
for (int i = 0; i < FormatNames.size(); i++)
{
Console->Log(LogTypes::LCUSTOM, StringFromFormat("Perspective: %s\n", FormatNames.at(i).c_str()).c_str());
}
if (ActivePerspective >= Perspectives.size()) ActivePerspective = 0;
DoLoadPerspective(Perspectives.at(ActivePerspective).Perspective);
}
// Create one pane by default
else
{
m_Mgr->AddPane(new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, DefaultNBStyle));
}
//Console->Log(LogTypes::LCUSTOM, StringFromFormat("Panes: %i\n", m_Mgr->GetAllPanes().GetCount()).c_str());
DoLoadPerspective();
}
else
{
m_Mgr->GetPane(wxT("Pane 1")).Hide().PaneBorder(false).CaptionVisible(false).Layer(0).Right();
//if (m_bLogWindow || SConfig::GetInstance().m_InterfaceConsole) m_Mgr->GetPane(wxT("Pane 1")).Show();
}
// Show window
Show();
// Create list of available plugins for the configuration window
CPluginManager::GetInstance().ScanForPlugins();
// Load GUI settings
if (UseDebugger) g_pCodeWindow->Load();
// Open notebook pages
if (UseDebugger) AddRemoveBlankPage();
if (UseDebugger) g_pCodeWindow->OpenPages();
if (m_bLogWindow) DoToggleWindow(IDM_LOGWINDOW, true);
if (SConfig::GetInstance().m_InterfaceConsole) DoToggleWindow(IDM_CONSOLEWINDOW, true);
if (!UseDebugger) SetSimplePaneSize();
if (!UseDebugger)
{
SetSimplePaneSize();
if (m_bLogWindow) DoToggleWindow(IDM_LOGWINDOW, true);
if (SConfig::GetInstance().m_InterfaceConsole) DoToggleWindow(IDM_CONSOLEWINDOW, true);
}
//if we are ever going back to optional iso caching:
//m_GameListCtrl->Update(SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableIsoCache);
@ -622,23 +590,26 @@ void CFrame::DoFullscreen(bool _F)
m_Mgr->LoadPerspective(AuiCurrent, true);
}
}
int CFrame::Limit(int i, int Low, int High)
{
if (i < Low) return Low;
if (i > High) return High;
return i;
}
void CFrame::SetSimplePaneSize()
{
wxArrayInt i, j;
i.Add(0); j.Add(50);
i.Add(1); j.Add(50);
SetPaneSize(i, j);
}
void CFrame::SetPaneSize(wxArrayInt Pane, wxArrayInt Size)
{
int iClientSize = this->GetSize().GetX();
wxArrayInt Pane, Size;
Pane.Add(0); Size.Add(50);
Pane.Add(1); Size.Add(50);
int iClientSize = this->GetSize().GetX();
// Fix the pane sizes
for (int i = 0; i < Pane.size(); i++)
{
// Check limits
if (Size[i] > 95) Size[i] = 95; if (Size[i] < 5) Size[i] = 5;
Size[i] = Limit(Size[i], 5, 95);
// Produce pixel width from percentage width
Size[i] = iClientSize * (float)(Size[i]/100.0);
Size[i] = PercentageToPixels(Size[i], iClientSize);
// Update size
m_Mgr->GetPane(wxString::Format(wxT("Pane %i"), Pane[i])).BestSize(Size[i], -1).MinSize(Size[i], -1).MaxSize(Size[i], -1);
}
@ -649,109 +620,127 @@ void CFrame::SetPaneSize(wxArrayInt Pane, wxArrayInt Size)
m_Mgr->GetPane(wxString::Format(wxT("Pane %i"), Pane[i])).MinSize(-1, -1).MaxSize(-1, -1);
}
}
void CFrame::DoLoadPerspective(wxString Perspective)
{
m_Mgr->LoadPerspective(Perspective, true);
/*
m_Mgr->LoadPerspective(AuiPerspective[Perspective], true);
int _iRightWidth, iClientSize = this->GetSize().GetX();
wxArrayInt i, j;
// Set the size
if (Perspective == 0)
{
_iRightWidth = 100 - iLeftWidth[0];
i.Add(0); j.Add(iLeftWidth[0]);
i.Add(2); j.Add(_iRightWidth);
//m_Mgr->GetPane(wxT("Pane 1")).BestSize(_iLeftWidth, -1).MinSize(_iLeftWidth, -1).MaxSize(_iLeftWidth, -1);
//m_Mgr->GetPane(wxT("Pane 2")).BestSize(_iRightWidth, -1).MinSize(_iRightWidth, -1).MaxSize(_iRightWidth, -1);
}
else
{
_iRightWidth = 100 - iLeftWidth[1] - iMidWidth[1];
i.Add(0); j.Add(iLeftWidth[1]);
i.Add(2); j.Add(iMidWidth[1]);
i.Add(3); j.Add(_iRightWidth);
//m_Mgr->GetPane(wxT("Pane 0")).BestSize(_iLeftWidth, -1).MinSize(_iLeftWidth, -1).MaxSize(_iLeftWidth, -1);
//m_Mgr->GetPane(wxT("Pane1")).BestSize(_iLeftWidth, -1).MinSize(_iLeftWidth, -1).MaxSize(_iLeftWidth, -1);
//m_Mgr->GetPane(wxT("Pane2")).BestSize(_iMidWidth, -1).MinSize(_iMidWidth, -1).MaxSize(_iMidWidth, -1);
//m_Mgr->GetPane(wxT("Pane3")).BestSize(_iRightWidth, -1).MinSize(_iRightWidth, -1).MaxSize(_iRightWidth, -1);
}
SetPaneSize(i, j);
*/
}
int CFrame::PixelsToPercentage(int Pixels, int Total)
void CFrame::SetPaneSize()
{
int Percentage = (int)(((float)Pixels / (float)Total) * 100.0);
return Percentage;
}
if (Perspectives.size() <= ActivePerspective) return;
int iClientX = this->GetSize().GetX(), iClientY = this->GetSize().GetY();
void CFrame::NamePanes()
{
for (int i = 0, j = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
{
if (!m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiToolBar)))
{
m_Mgr->GetAllPanes().Item(i).Name(wxString::Format(wxT("Pane %i"), j));
m_Mgr->GetAllPanes().Item(i).Caption(wxString::Format(wxT("Pane %i"), j));
if (!m_Mgr->GetAllPanes().Item(i).IsOk()) return;
if (Perspectives.at(ActivePerspective).Width.size() <= j || Perspectives.at(ActivePerspective).Height.size() <= j) continue;
int W = Perspectives.at(ActivePerspective).Width.at(j), H = Perspectives.at(ActivePerspective).Height.at(j);
// Check limits
W = Limit(W, 5, 95); H = Limit(H, 5, 95);
// Produce pixel width from percentage width
W = PercentageToPixels(W, iClientX); H = PercentageToPixels(H, iClientY);
m_Mgr->GetAllPanes().Item(i).BestSize(W,H).MinSize(W,H).MaxSize(W,H);
j++;
}
}
}
void CFrame::AddPane()
{
m_Mgr->AddPane(new wxAuiNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, DefaultNBStyle));
NamePanes();
m_Mgr->Update();
}
void CFrame::OnPaneClose(wxAuiManagerEvent& event)
{
event.Veto();
wxAuiNotebook * nb = (wxAuiNotebook*)event.pane->window;
if (!nb) return;
if (! (nb->GetPageCount() == 0 || (nb->GetPageCount() == 1 && nb->GetPageText(0).IsSameAs(wxT("<>")))))
for (int i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
{
wxMessageBox(wxT("You can't close panes that have pages in them."),
wxT("Notice"),
wxOK,
this);
if (!m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiToolBar)))
{
m_Mgr->GetAllPanes().Item(i).MinSize(-1,-1).MaxSize(-1,-1);
}
}
}
// Debugging, show loose windows
void CFrame::ListChildren()
{
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
for (int i = 0; i < this->GetChildren().size(); i++)
{
wxWindow * Win = this->GetChildren().Item(i)->GetData();
Console->Log(LogTypes::LCUSTOM, StringFromFormat(
"%i: %s (%s) :: % s\n", i,
Win->GetName().mb_str(), Win->GetLabel().mb_str(), Win->GetParent()->GetName().mb_str()).c_str());
Win = this->GetChildren().Item(i)->GetData();
for (int j = 0; j < Win->GetChildren().size(); j++)
{
Console->Log(LogTypes::LCUSTOM, StringFromFormat(
" %i.%i: %s (%s) :: % s\n", i, j,
Win->GetName().mb_str(), Win->GetLabel().mb_str(), Win->GetParent()->GetName().mb_str()).c_str());
}
}
}
void CFrame::ReloadPanes()
{
if (ActivePerspective >= Perspectives.size()) ActivePerspective = 0;
if (Perspectives.size() > 0)
{
// Close all pages
ClosePages();
// Drop all panes with notebooks
for (int i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
{
if (m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiNotebook)))
{
// Todo, delete the window instead of just hiding it
m_Mgr->GetAllPanes().Item(i).window->Hide();
m_Mgr->DetachPane(m_Mgr->GetAllPanes().Item(i).window);
}
}
// Create new panes with notebooks
for (int i = 0; i < Perspectives.at(ActivePerspective).Width.size() - 1; i++)
m_Mgr->AddPane(CreateEmptyNotebook());
// Names
NamePanes();
// Perspectives
m_Mgr->LoadPerspective(Perspectives.at(ActivePerspective).Perspective, true);
}
// Create one pane by default
else
{
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
Console->Log(LogTypes::LCUSTOM, StringFromFormat("GetNotebookCount before: %i\n", GetNotebookCount()).c_str());
// Detach and delete the empty notebook
m_Mgr->DetachPane(event.pane->window);
//event.pane->window->Close();
event.pane->window->Destroy();
Console->Log(LogTypes::LCUSTOM, StringFromFormat("GetNotebookCount after: %i\n", GetNotebookCount()).c_str());
m_Mgr->AddPane(CreateEmptyNotebook());
}
m_Mgr->Update();
// Load GUI settings
g_pCodeWindow->Load();
// Open notebook pages
AddRemoveBlankPage();
g_pCodeWindow->OpenPages();
if (m_bLogWindow) DoToggleWindow(IDM_LOGWINDOW, true);
if (SConfig::GetInstance().m_InterfaceConsole) DoToggleWindow(IDM_CONSOLEWINDOW, true);
}
void CFrame::DoLoadPerspective()
{
ReloadPanes();
// Restore the exact window sizes, which LoadPerspective doesn't always do
SetPaneSize();
/*
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
Console->Log(LogTypes::LCUSTOM, StringFromFormat(
"Loaded: %s, NBs: %i, Non-NBs: %i, \n",
Perspectives.at(ActivePerspective).Name.c_str(), GetNotebookCount(), m_Mgr->GetAllPanes().GetCount() - GetNotebookCount()).c_str());
*/
}
void CFrame::Save()
{
if (Perspectives.size() == 0) return;
if (ActivePerspective >= Perspectives.size()) ActivePerspective = 0;
// Turn off edit before saving
TogglePaneStyle(false);
/**/
// Get client size
int iClientX = this->GetSize().GetX(), iClientY = this->GetSize().GetY();;
int iClientX = this->GetSize().GetX(), iClientY = this->GetSize().GetY();
IniFile ini;
ini.Load(DEBUGGER_CONFIG_FILE);
std::string _Section = StringFromFormat("P - %s", Perspectives.at(ActivePerspective).Name.c_str());
ini.Set(_Section.c_str(), "Perspective", m_Mgr->SavePerspective().mb_str());
std::string SWidth = "", SHeight = "";
for (int i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
{
@ -776,16 +765,80 @@ void CFrame::Save()
}
STmp = STmp.substr(0, STmp.length()-1);
ini.Set("Perspectives", "Perspectives", STmp.c_str());
ini.Set("Perspectives", "Active", ActivePerspective);
ini.Save(DEBUGGER_CONFIG_FILE);
/*
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
Console->Log(LogTypes::LCUSTOM, StringFromFormat("Saved: %s\n", STmp.c_str()).c_str());
Console->Log(LogTypes::LCUSTOM, StringFromFormat("Saved: %s\n", Perspectives.at(ActivePerspective).Name.c_str()).c_str());
*/
TogglePaneStyle(m_ToolBarAui->GetToolToggled(IDM_EDIT_PERSPECTIVES));
}
int CFrame::PercentageToPixels(int Percentage, int Total)
{
int Pixels = (int)((float)Total * ((float)Percentage / 100.0));
return Pixels;
}
int CFrame::PixelsToPercentage(int Pixels, int Total)
{
int Percentage = (int)(((float)Pixels / (float)Total) * 100.0);
return Percentage;
}
void CFrame::NamePanes()
{
for (int i = 0, j = 0; i < m_Mgr->GetAllPanes().GetCount(); i++)
{
if (!m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiToolBar)))
{
m_Mgr->GetAllPanes().Item(i).Name(wxString::Format(wxT("Pane %i"), j));
m_Mgr->GetAllPanes().Item(i).Caption(wxString::Format(wxT("Pane %i"), j));
j++;
}
}
}
void CFrame::AddPane()
{
m_Mgr->AddPane(CreateEmptyNotebook());
NamePanes();
AddRemoveBlankPage();
m_Mgr->Update();
}
void CFrame::OnPaneClose(wxAuiManagerEvent& event)
{
event.Veto();
wxAuiNotebook * nb = (wxAuiNotebook*)event.pane->window;
if (!nb) return;
if (false)
//if (! (nb->GetPageCount() == 0 || (nb->GetPageCount() == 1 && nb->GetPageText(0).IsSameAs(wxT("<>")))))
{
wxMessageBox(wxT("You can't close panes that have pages in them."),
wxT("Notice"),
wxOK,
this);
}
else
{
/*
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
Console->Log(LogTypes::LCUSTOM, StringFromFormat("GetNotebookCount before: %i\n", GetNotebookCount()).c_str());
*/
// Detach and delete the empty notebook
m_Mgr->DetachPane(event.pane->window);
//event.pane->window->Close();
event.pane->window->Destroy();
//Console->Log(LogTypes::LCUSTOM, StringFromFormat("GetNotebookCount after: %i\n", GetNotebookCount()).c_str());
}
m_Mgr->Update();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -890,6 +943,9 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
void CFrame::OnKeyDown(wxKeyEvent& event)
{
// Don't block other events
event.Skip();
// Escape key turn off fullscreen then Stop emulation in windowed mode
if (event.GetKeyCode() == WXK_ESCAPE)
{
@ -933,9 +989,6 @@ void CFrame::OnKeyDown(wxKeyEvent& event)
// Send the keyboard status to the Input plugin
if(Core::GetState() != Core::CORE_UNINITIALIZED)
CPluginManager::GetInstance().GetPad(0)->PAD_Input(event.GetKeyCode(), 1); // 1 = Down
// Don't block other events
event.Skip();
}
void CFrame::OnKeyUp(wxKeyEvent& event)

View File

@ -114,6 +114,8 @@ class CFrame : public wxFrame
void OnAllowNotebookDnD(wxAuiNotebookEvent& event);
void OnNotebookPageChanged(wxAuiNotebookEvent& event);
int GetNootebookAffiliation(wxString Name);
void ListChildren();
void ClosePages();
void DoToggleWindow(int,bool);
int GetNotebookCount();
void DoAddPage(wxWindow *, int, std::string);
@ -121,7 +123,7 @@ class CFrame : public wxFrame
void DoRemovePageString(wxString, bool Hide = true);
void HidePane();
void SetSimplePaneSize();
void SetPaneSize(wxArrayInt,wxArrayInt);
void SetPaneSize();
void TogglePaneStyle(bool);
void ToggleNotebookStyle(long);
void ResizeConsole();
@ -136,12 +138,15 @@ class CFrame : public wxFrame
wxString AuiFullscreen, AuiCurrent;
wxArrayString AuiPerspective;
int ActivePerspective;
int PercentageToPixels(int,int);
int PixelsToPercentage(int,int);
void NamePanes();
void AddPane();
int Limit(int,int,int);
void Save();
void OnPaneClose(wxAuiManagerEvent& evt);
void DoLoadPerspective(wxString);
void ReloadPanes();
void DoLoadPerspective();
void OnCreatePerspective(wxCommandEvent& event);
void OnDropDownToolbarItem(wxAuiToolBarEvent& event);
void OnSelectPerspective(wxCommandEvent& event);

View File

@ -739,12 +739,9 @@ void CFrame::OnToolBar(wxCommandEvent& event)
void CFrame::OnSelectPerspective(wxCommandEvent& event)
{
int _Selection = event.GetId() - IDM_PERSPECTIVES_0;
if (Perspectives.size() <= _Selection) return;
if (Perspectives.size() <= _Selection) _Selection = 0;
ActivePerspective = _Selection;
DoLoadPerspective(Perspectives.at(ActivePerspective).Perspective);
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
Console->Log(LogTypes::LCUSTOM, StringFromFormat("OnSelectPerspective: %i %s\n", _Selection, Perspectives.at(ActivePerspective).Name.c_str()).c_str());
DoLoadPerspective();
}
void CFrame::OnDropDownToolbarItem(wxAuiToolBarEvent& event)
{
@ -1094,6 +1091,18 @@ int CFrame::GetNootebookAffiliation(wxString Name)
}
return -1;
}
void CFrame::ClosePages()
{
DoToggleWindow(IDM_LOGWINDOW, false);
//DoToggleWindow(IDM_CONSOLEWINDOW, false);
DoToggleWindow(IDM_CODEWINDOW, false);
DoToggleWindow(IDM_REGISTERWINDOW, false);
DoToggleWindow(IDM_BREAKPOINTWINDOW, false);
DoToggleWindow(IDM_MEMORYWINDOW, false);
DoToggleWindow(IDM_JITWINDOW, false);
DoToggleWindow(IDM_SOUNDWINDOW, false);
DoToggleWindow(IDM_VIDEOWINDOW, false);
}
void CFrame::DoToggleWindow(int Id, bool Show)
{
switch (Id)
@ -1210,8 +1219,10 @@ void CFrame::DoAddPage(wxWindow * Win, int i, std::string Name)
if (Win && GetNotebook(i)->GetPageIndex(Win) != wxNOT_FOUND) return;
GetNotebook(i)->AddPage(Win, wxString::FromAscii(Name.c_str()), true, aNormalFile );
/*
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
Console->Log(LogTypes::LCUSTOM, StringFromFormat("Add: %s\n", Name.c_str()).c_str());
*/
}
void CFrame::DoRemovePage(wxWindow * Win, bool Hide)
{