GUI: Bugfixes, some bugs left

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4134 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2009-09-01 07:32:07 +00:00
parent d50b4c2ffc
commit 0f1a83c116
9 changed files with 199 additions and 105 deletions

View File

@ -271,7 +271,7 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text)
Color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
break;
}
if (strlen(Text) > 10)
if (Level != CUSTOM_LEVEL && strlen(Text) > 10)
{
// First 10 chars white
SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);

View File

@ -23,6 +23,7 @@
#define WARNING_LEVEL 3 // Something is suspicious.
#define INFO_LEVEL 4 // General information.
#define DEBUG_LEVEL 5 // Detailed debugging - might make things slow.
#define CUSTOM_LEVEL 6 // Custom level
namespace LogTypes
{
@ -81,6 +82,7 @@ enum LOG_LEVELS {
LWARNING = WARNING_LEVEL,
LINFO = INFO_LEVEL,
LDEBUG = DEBUG_LEVEL,
LCUSTOM = CUSTOM_LEVEL
};
} // namespace
@ -91,11 +93,11 @@ enum LOG_LEVELS {
- Debug_run() - run only in debug time
*/
#if defined LOGGING || defined _DEBUG || defined DEBUGFAST
#define MAX_LOGLEVEL DEBUG_LEVEL
#define MAX_LOGLEVEL DEBUG_LEVEL
#else
#ifndef MAX_LOGLEVEL
#define MAX_LOGLEVEL WARNING_LEVEL
#endif // loglevel
#ifndef MAX_LOGLEVEL
#define MAX_LOGLEVEL WARNING_LEVEL
#endif // loglevel
#endif // logging
#define ERROR_LOG(...) {}

View File

@ -21,9 +21,7 @@
#include "Log.h"
#include "Thread.h"
#include "StringUtil.h"
#ifdef _WIN32
#include <windows.h>
#endif
#include <vector>
#include <string.h>
#include <stdio.h>

View File

@ -174,7 +174,7 @@ CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter
}
CCodeWindow::~CCodeWindow()
{
Parent->g_pCodeWindow = NULL;
}
// Redirect old wxFrame calls
wxMenuBar *CCodeWindow::GetMenuBar()
@ -435,7 +435,7 @@ void CCodeWindow::Load()
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("ShowOnStart", "Video", &bVideoWindow, false);
// Get notebook affiliation
std::string _Section = StringFromFormat("P - %s",
(Parent->ActivePerspective < Parent->Perspectives.size())

View File

@ -421,7 +421,7 @@ void CCodeWindow::OnToggleMemoryWindow(bool Show, int i)
//Toggle Sound Debugging Window
void CCodeWindow::OnToggleSoundWindow(bool Show, int i)
{
//ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
if (Show)
{
@ -445,9 +445,20 @@ void CCodeWindow::OnToggleSoundWindow(bool Show, int i)
Win = Parent->GetWxWindow(wxT("Sound"));
if (Win)
{
//Console->Log(LogTypes::LNOTICE, StringFromFormat("AddPage\n").c_str());
{
//Parent->ListChildren();
Win->SetName(wxT("Sound"));
Win->Reparent(Parent);
//Console->Log(LogTypes::LNOTICE, StringFromFormat("Reparent\n").c_str());
//Parent->ListChildren();
Parent->GetNotebook(i)->AddPage(Win, wxT("Sound"), true, Parent->aNormalFile );
Console->Log(LogTypes::LNOTICE, StringFromFormat("AddPage\n").c_str());
//Parent->ListChildren();
//Console->Log(LogTypes::LNOTICE, StringFromFormat("OpenDebug: Win %i\n", FindWindowByName(wxT("Sound"))).c_str());
}
else
{
//Console->Log(LogTypes::LNOTICE, StringFromFormat("OpenDebug: Win not found\n").c_str());
}
#endif
}

View File

@ -341,7 +341,7 @@ CFrame::CFrame(bool showLogWindow,
if (SConfig::GetInstance().m_InterfaceConsole) Console->Open();
// Start debugging mazimized
if (UseDebugger) this->Maximize(true);
//if (UseDebugger) this->Maximize(true);
// Debugger class
if (UseDebugger)
{
@ -428,46 +428,7 @@ CFrame::CFrame(bool showLogWindow,
if (UseDebugger)
{
// Load perspective
std::vector<std::string> VPerspectives;
std::string _Perspectives;
IniFile ini;
ini.Load(DEBUGGER_CONFIG_FILE);
ini.Get("Perspectives", "Perspectives", &_Perspectives, "");
ini.Get("Perspectives", "Active", &ActivePerspective, 0);
SplitString(_Perspectives, ",", VPerspectives);
//
for (int i = 0; i < VPerspectives.size(); i++)
{
SPerspectives Tmp;
std::string _Section, _Perspective, _Width, _Height;
std::vector<std::string> _SWidth, _SHeight;
Tmp.Name = VPerspectives.at(i);
_Section = StringFromFormat("P - %s", Tmp.Name.c_str());
if (!ini.Exists(_Section.c_str(), "Width")) continue;
ini.Get(_Section.c_str(), "Perspective", &_Perspective, "");
ini.Get(_Section.c_str(), "Width", &_Width, "");
ini.Get(_Section.c_str(), "Height", &_Height, "");
Tmp.Perspective = wxString::FromAscii(_Perspective.c_str());
SplitString(_Width, ",", _SWidth);
SplitString(_Height, ",", _SHeight);
for (int i = 0; i < _SWidth.size(); i++)
{
int _Tmp;
if (TryParseInt(_SWidth.at(0).c_str(), &_Tmp)) Tmp.Width.push_back(_Tmp);
}
for (int i = 0; i < _SHeight.size(); i++)
{
int _Tmp;
if (TryParseInt(_SHeight.at(0).c_str(), &_Tmp)) Tmp.Height.push_back(_Tmp);
}
Perspectives.push_back(Tmp);
}
SaveLocal();
DoLoadPerspective();
}
else
@ -655,45 +616,89 @@ void CFrame::SetPaneSize()
// Debugging, show loose windows
void CFrame::ListChildren()
{
return;
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
wxAuiNotebook * NB = NULL;
for (int i = 0; i < this->GetChildren().size(); i++)
{
wxWindow * Win = this->GetChildren().Item(i)->GetData();
// Console->Log(LogTypes::LDEBUG, StringFromFormat(
// "%i: %s (%s) :: % s\n", i,
// Win->GetName().mb_str(), Win->GetLabel().mb_str(), Win->GetParent()->GetName().mb_str()).c_str());
Console->Log(LogTypes::LCUSTOM, StringFromFormat(
"%i: %s (%s) :: %s", i,
Win->GetName().mb_str(), Win->GetLabel().mb_str(), Win->GetParent()->GetName().mb_str()).c_str());
//if (Win->GetName().IsSameAs(wxT("control")))
if (Win->IsKindOf(CLASSINFO(wxAuiNotebook)))
{
NB = (wxAuiNotebook*)Win;
Console->Log(LogTypes::LCUSTOM, StringFromFormat("%s", NB->GetName().mb_str()).c_str());
}
else
{
NB = NULL;
}
Console->Log(LogTypes::LCUSTOM, StringFromFormat("\n").c_str());
Win = this->GetChildren().Item(i)->GetData();
for (int j = 0; j < Win->GetChildren().size(); j++)
{
// Console->Log(LogTypes::LDEBUG, StringFromFormat(
// " %i.%i: %s (%s) :: % s\n", i, j,
// Win->GetName().mb_str(), Win->GetLabel().mb_str(), Win->GetParent()->GetName().mb_str()).c_str());
Console->Log(LogTypes::LCUSTOM, StringFromFormat(
" %i.%i: %s (%s) :: %s", i, j,
Win->GetName().mb_str(), Win->GetLabel().mb_str(), Win->GetParent()->GetName().mb_str()).c_str());
if (NB) Console->Log(LogTypes::LCUSTOM, StringFromFormat("%s", NB->GetPage(j)->GetName().mb_str()).c_str());
Console->Log(LogTypes::LCUSTOM, StringFromFormat("\n").c_str());
Win = this->GetChildren().Item(j)->GetData();
for (int k = 0; k < Win->GetChildren().size(); k++)
{
Console->Log(LogTypes::LCUSTOM, StringFromFormat(
" %i.%i.%i: %s (%s) :: %s\n", i, j, k,
Win->GetName().mb_str(), Win->GetLabel().mb_str(), Win->GetParent()->GetName().mb_str()).c_str());
}
}
}
}
void CFrame::ReloadPanes()
{
// Keep settings
bool bConsole = SConfig::GetInstance().m_InterfaceConsole;
//ListChildren();
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
//Console->Log(LogTypes::LNOTICE, StringFromFormat("ReloadPanes begin: Sound %i\n", FindWindowByName(wxT("Sound"))).c_str());
if (ActivePerspective >= Perspectives.size()) ActivePerspective = 0;
// Check that there is a perspective
if (Perspectives.size() > 0)
{
// Check that the perspective was saved once before
if (Perspectives.at(ActivePerspective).Width.size() == 0) return;
// 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);
}
}
/*
Console->Log(LogTypes::LCUSTOM, StringFromFormat(
"Will detached panes, have %i panes (%i NBs)\n", m_Mgr->GetAllPanes().GetCount(), GetNotebookCount()).c_str());
*/
CloseAllNotebooks();
m_Mgr->Update();
/*
Console->Log(LogTypes::LCUSTOM, StringFromFormat(
"Detached panes, have %i panes (%i NBs)\n", m_Mgr->GetAllPanes().GetCount(), GetNotebookCount()).c_str());
*/
// Create new panes with notebooks
for (int i = 0; i < Perspectives.at(ActivePerspective).Width.size() - 1; i++)
m_Mgr->AddPane(CreateEmptyNotebook());
{
m_Mgr->AddPane(CreateEmptyNotebook(), wxAuiPaneInfo().Show());
}
/*
Console->Log(LogTypes::LCUSTOM, StringFromFormat(
"Created %i panes, have %i panes (%i NBs)\n",
Perspectives.at(ActivePerspective).Width.size() - 1, m_Mgr->GetAllPanes().GetCount(), GetNotebookCount()).c_str());
*/
// Names
NamePanes();
// Perspectives
@ -705,13 +710,18 @@ void CFrame::ReloadPanes()
m_Mgr->AddPane(CreateEmptyNotebook());
}
//Console->Log(LogTypes::LNOTICE, StringFromFormat("ReloadPanes end: Sound %i\n", FindWindowByName(wxT("Sound"))).c_str());
//ListChildren();
// If the code window was closed
if (!g_pCodeWindow) g_pCodeWindow = new CCodeWindow(SConfig::GetInstance().m_LocalCoreStartupParameter, this, this);
// 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);
//if (bConsole) DoToggleWindow(IDM_CONSOLEWINDOW, true);
}
void CFrame::DoLoadPerspective()
{
@ -722,17 +732,67 @@ void CFrame::DoLoadPerspective()
/*
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
Console->Log(LogTypes::LCUSTOM, StringFromFormat(
"Loaded: %s, NBs: %i, Non-NBs: %i, \n",
"Loaded: %s, NBs: %i, Non-NBs: %i, \n\n",
Perspectives.at(ActivePerspective).Name.c_str(), GetNotebookCount(), m_Mgr->GetAllPanes().GetCount() - GetNotebookCount()).c_str());
*/
}
// Update the local perspectives array
void CFrame::SaveLocal()
{
Perspectives.clear();
std::vector<std::string> VPerspectives;
std::string _Perspectives;
IniFile ini;
ini.Load(DEBUGGER_CONFIG_FILE);
ini.Get("Perspectives", "Perspectives", &_Perspectives, "");
ini.Get("Perspectives", "Active", &ActivePerspective, 5);
SplitString(_Perspectives, ",", VPerspectives);
//
for (int i = 0; i < VPerspectives.size(); i++)
{
SPerspectives Tmp;
std::string _Section, _Perspective, _Width, _Height;
std::vector<std::string> _SWidth, _SHeight;
Tmp.Name = VPerspectives.at(i);
_Section = StringFromFormat("P - %s", Tmp.Name.c_str());
if (!ini.Exists(_Section.c_str(), "Width")) continue;
ini.Get(_Section.c_str(), "Perspective", &_Perspective, "");
ini.Get(_Section.c_str(), "Width", &_Width, "");
ini.Get(_Section.c_str(), "Height", &_Height, "");
Tmp.Perspective = wxString::FromAscii(_Perspective.c_str());
SplitString(_Width, ",", _SWidth);
SplitString(_Height, ",", _SHeight);
for (int i = 0; i < _SWidth.size(); i++)
{
int _Tmp;
if (TryParseInt(_SWidth.at(0).c_str(), &_Tmp)) Tmp.Width.push_back(_Tmp);
}
for (int i = 0; i < _SHeight.size(); i++)
{
int _Tmp;
if (TryParseInt(_SHeight.at(0).c_str(), &_Tmp)) Tmp.Height.push_back(_Tmp);
}
Perspectives.push_back(Tmp);
}
}
void CFrame::Save()
{
if (Perspectives.size() == 0) return;
if (Perspectives.size() == 0)
{
wxMessageBox(wxT("Please create a perspective before saving"), wxT("Notice"), wxOK, this);
return;
}
if (ActivePerspective >= Perspectives.size()) ActivePerspective = 0;
// Turn off edit before saving
TogglePaneStyle(false);
// Name panes
NamePanes();
// Get client size
int iClientX = this->GetSize().GetX(), iClientY = this->GetSize().GetY();
@ -770,10 +830,15 @@ void CFrame::Save()
ini.Set("Perspectives", "Active", ActivePerspective);
ini.Save(DEBUGGER_CONFIG_FILE);
/*
// Update the local vector
SaveLocal();
/**/
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
Console->Log(LogTypes::LCUSTOM, StringFromFormat("Saved: %s\n", Perspectives.at(ActivePerspective).Name.c_str()).c_str());
*/
Console->Log(LogTypes::LCUSTOM, StringFromFormat(
"Saved: %s, NBs: %i, Non-NBs: %i, \n\n",
Perspectives.at(ActivePerspective).Name.c_str(), GetNotebookCount(), m_Mgr->GetAllPanes().GetCount() - GetNotebookCount()).c_str());
TogglePaneStyle(m_ToolBarAui->GetToolToggled(IDM_EDIT_PERSPECTIVES));
}
@ -815,14 +880,9 @@ void CFrame::OnPaneClose(wxAuiManagerEvent& event)
wxAuiNotebook * nb = (wxAuiNotebook*)event.pane->window;
if (!nb) return;
if (false)
//if (! (nb->GetPageCount() == 0 || (nb->GetPageCount() == 1 && nb->GetPageText(0).IsSameAs(wxT("<>")))))
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);
wxMessageBox(wxT("You can't close panes that have pages in them."), wxT("Notice"), wxOK, this);
}
else
{
@ -832,9 +892,8 @@ void CFrame::OnPaneClose(wxAuiManagerEvent& event)
*/
// Detach and delete the empty notebook
m_Mgr->DetachPane(event.pane->window);
//event.pane->window->Close();
event.pane->window->Destroy();
event.pane->DestroyOnClose(true);
m_Mgr->ClosePane(*event.pane);
//Console->Log(LogTypes::LCUSTOM, StringFromFormat("GetNotebookCount after: %i\n", GetNotebookCount()).c_str());
}

View File

@ -117,6 +117,7 @@ class CFrame : public wxFrame
void ListChildren();
void ClosePages();
void DoToggleWindow(int,bool);
void CloseAllNotebooks();
int GetNotebookCount();
void DoAddPage(wxWindow *, int, std::string);
void DoRemovePage(wxWindow *, bool Hide = true);
@ -144,6 +145,7 @@ class CFrame : public wxFrame
void AddPane();
int Limit(int,int,int);
void Save();
void SaveLocal();
void OnPaneClose(wxAuiManagerEvent& evt);
void ReloadPanes();
void DoLoadPerspective();

View File

@ -303,10 +303,12 @@ void CFrame::RecreateToolbar()
m_ToolBarDebug = new wxAuiToolBar(this, ID_TOOLBAR_DEBUG, wxDefaultPosition, wxDefaultSize,
wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_OVERFLOW | wxAUI_TB_TEXT);
g_pCodeWindow->PopulateToolbar(m_ToolBarDebug);
/*
m_Mgr->AddPane(m_ToolBarDebug, wxAuiPaneInfo().
Name(wxT("TBDebug")).Caption(wxT("TBDebug")).
ToolbarPane().Top().
LeftDockable(false).RightDockable(false).Floatable(false));
*/
m_ToolBarAui = new wxAuiToolBar(this, ID_TOOLBAR_AUI, wxDefaultPosition, wxDefaultSize,
wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_OVERFLOW | wxAUI_TB_TEXT);
@ -768,10 +770,6 @@ void CFrame::OnCreatePerspective(wxCommandEvent& event)
SPerspectives Tmp;
Tmp.Name = dlg.GetValue().mb_str();
Perspectives.push_back(Tmp);
//if (m_perspectives.GetCount() == 0) m_perspectives_menu->AppendSeparator();
// m_perspectives_menu->Append(ID_FirstPerspective + m_perspectives.GetCount(), dlg.GetValue());
//m_perspectives.Add(m_mgr.SavePerspective());
}
void CFrame::TogglePaneStyle(bool On)
@ -1180,6 +1178,30 @@ wxAuiNotebook * CFrame::GetNotebook(int NBId)
}
return NULL;
}
// Close all panes with notebooks
void CFrame::CloseAllNotebooks()
{
int i = 0;
while(GetNotebookCount() > 0)
{
if (m_Mgr->GetAllPanes().Item(i).window->IsKindOf(CLASSINFO(wxAuiNotebook)))
{
//m_Mgr->GetAllPanes().Item(i).DestroyOnClose(true);
//m_Mgr->ClosePane(m_Mgr->GetAllPanes().Item(i));
m_Mgr->GetAllPanes().Item(i).window->Hide();
m_Mgr->DetachPane(m_Mgr->GetAllPanes().Item(i).window);
i = 0;
//Console->Log(LogTypes::LCUSTOM, StringFromFormat(" %i Pane\n", i).c_str());
}
else
{
i++;
//Console->Log(LogTypes::LCUSTOM, StringFromFormat(" %i No pane\n", i).c_str());
}
}
}
int CFrame::GetNotebookCount()
{
int Ret = 0;

View File

@ -67,30 +67,20 @@ void CLogWindow::CreateGUIControls()
// Left side: buttons (-submit), options, and log type selection
wxStaticBoxSizer* sbLeftOptions = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Options"));
// Verbosity
wxArrayString wxLevels;
for (int i = 1; i <= MAX_LOGLEVEL; ++i)
wxLevels.Add(wxString::Format(wxT("%i"), i));
for (int i = 1; i <= MAX_LOGLEVEL; ++i) wxLevels.Add(wxString::Format(wxT("%i"), i));
m_verbosity = new wxRadioBox(this, IDM_VERBOSITY, wxT("Verbosity"), wxDefaultPosition, wxDefaultSize, wxLevels, 0, wxRA_SPECIFY_COLS, wxDefaultValidator);
sbLeftOptions->Add(m_verbosity);
// Options
m_writeFileCB = new wxCheckBox(this, IDM_WRITEFILE, wxT("Write to File"), wxDefaultPosition, wxDefaultSize, 0);
sbLeftOptions->Add(m_writeFileCB);
m_writeConsoleCB = new wxCheckBox(this, IDM_WRITECONSOLE, wxT("Write to Console"), wxDefaultPosition, wxDefaultSize, 0);
sbLeftOptions->Add(m_writeConsoleCB);
m_writeWindowCB = new wxCheckBox(this, IDM_WRITEWINDOW, wxT("Write to Window ->"), wxDefaultPosition, wxDefaultSize, 0);
sbLeftOptions->Add(m_writeWindowCB);
sLeft->Add(sbLeftOptions, 0, wxEXPAND);
wxBoxSizer* sLogCtrl = new wxBoxSizer(wxHORIZONTAL);
sLogCtrl->Add(new wxButton(this, IDM_TOGGLEALL, wxT("Toggle all"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT), 1);
sLogCtrl->Add(new wxButton(this, IDM_CLEARLOG, wxT("Clear"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT), 1);
sLeft->Add(sLogCtrl, 0, wxEXPAND);
m_checks = new wxCheckListBox(this, IDM_LOGCHECKS, wxDefaultPosition, wxDefaultSize);
sLeft->Add(m_checks, 1, wxEXPAND);
// Right side: Log viewer and submit row
m_log = new wxTextCtrl(this, IDM_LOG, wxEmptyString, wxDefaultPosition, wxDefaultSize,
@ -103,6 +93,16 @@ void CLogWindow::CreateGUIControls()
wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
//m_cmdline->SetFont(DebuggerFont);
// Sizers
sbLeftOptions->Add(m_writeFileCB);
sbLeftOptions->Add(m_writeConsoleCB);
sbLeftOptions->Add(m_writeWindowCB);
sLeft->Add(m_verbosity, 0, wxEXPAND);
sLeft->Add(sbLeftOptions, 0, wxEXPAND);
sLeft->Add(sLogCtrl, 0, wxEXPAND);
sLeft->Add(m_checks, 1, wxEXPAND);
sRightBottom->Add(m_cmdline, 1, wxEXPAND);
sRight->Add(m_log, 1, wxEXPAND | wxSHRINK);
sRight->Add(sRightBottom, 0, wxEXPAND);