From b73130af77e4a978e7837a0e40431af768d2f34c Mon Sep 17 00:00:00 2001 From: skidau Date: Fri, 24 Oct 2014 22:24:17 +1100 Subject: [PATCH] Added Load/Save function for the Watch window. Made the floating windows toolbars dockable. Scaled down the breakpoint toolbar icons to 16x16. --- Source/Core/Common/BreakPoints.cpp | 4 +- .../DolphinWX/Debugger/BreakpointWindow.cpp | 8 +- .../Core/DolphinWX/Debugger/WatchWindow.cpp | 89 +++++++++++++++++-- Source/Core/DolphinWX/Debugger/WatchWindow.h | 7 +- 4 files changed, 96 insertions(+), 12 deletions(-) diff --git a/Source/Core/Common/BreakPoints.cpp b/Source/Core/Common/BreakPoints.cpp index 8ef93758ab..e0498e34d0 100644 --- a/Source/Core/Common/BreakPoints.cpp +++ b/Source/Core/Common/BreakPoints.cpp @@ -234,7 +234,7 @@ Watches::TWatchesStr Watches::GetStrings() const for (const TWatch& bp : m_Watches) { std::stringstream ss; - ss << std::hex << bp.iAddress << " " << (bp.bOn ? "n" : ""); + ss << std::hex << bp.iAddress << " " << bp.name; bps.push_back(ss.str()); } @@ -249,7 +249,7 @@ void Watches::AddFromStrings(const TWatchesStr& bpstrs) std::stringstream ss; ss << std::hex << bpstr; ss >> bp.iAddress; - bp.bOn = bpstr.find("n") != bpstr.npos; + ss >> bp.name; Add(bp); } } diff --git a/Source/Core/DolphinWX/Debugger/BreakpointWindow.cpp b/Source/Core/DolphinWX/Debugger/BreakpointWindow.cpp index a25800f372..1649991d44 100644 --- a/Source/Core/DolphinWX/Debugger/BreakpointWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/BreakpointWindow.cpp @@ -45,9 +45,9 @@ public: { SetToolBitmapSize(wxSize(24, 24)); - m_Bitmaps[Toolbar_Delete] = wxBitmap(wxGetBitmapFromMemory(toolbar_delete_png).ConvertToImage().Rescale(24, 24)); - m_Bitmaps[Toolbar_Add_BP] = wxBitmap(wxGetBitmapFromMemory(toolbar_add_breakpoint_png).ConvertToImage().Rescale(24, 24)); - m_Bitmaps[Toolbar_Add_MC] = wxBitmap(wxGetBitmapFromMemory(toolbar_add_memcheck_png).ConvertToImage().Rescale(24, 24)); + m_Bitmaps[Toolbar_Delete] = wxBitmap(wxGetBitmapFromMemory(toolbar_delete_png).ConvertToImage().Rescale(16, 16)); + m_Bitmaps[Toolbar_Add_BP] = wxBitmap(wxGetBitmapFromMemory(toolbar_add_breakpoint_png).ConvertToImage().Rescale(16, 16)); + m_Bitmaps[Toolbar_Add_MC] = wxBitmap(wxGetBitmapFromMemory(toolbar_add_memcheck_png).ConvertToImage().Rescale(16, 16)); AddTool(ID_DELETE, _("Delete"), m_Bitmaps[Toolbar_Delete]); Bind(wxEVT_TOOL, &CBreakPointWindow::OnDelete, parent, ID_DELETE); @@ -112,7 +112,7 @@ CBreakPointWindow::CBreakPointWindow(CCodeWindow* _pCodeWindow, wxWindow* parent m_BreakPointListView = new CBreakPointView(this, wxID_ANY); m_mgr.AddPane(new CBreakPointBar(this, wxID_ANY), wxAuiPaneInfo().ToolbarPane().Top(). - LeftDockable(false).RightDockable(false).BottomDockable(false).Floatable(false)); + LeftDockable(true).RightDockable(true).BottomDockable(false).Floatable(false)); m_mgr.AddPane(m_BreakPointListView, wxAuiPaneInfo().CenterPane()); m_mgr.Update(); } diff --git a/Source/Core/DolphinWX/Debugger/WatchWindow.cpp b/Source/Core/DolphinWX/Debugger/WatchWindow.cpp index 7ac1630625..dc25d32d4b 100644 --- a/Source/Core/DolphinWX/Debugger/WatchWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/WatchWindow.cpp @@ -3,6 +3,8 @@ // Refer to the license.txt file included. #include + +#include #include #include #include @@ -10,10 +12,19 @@ #include #include #include +#include +#include "Common/FileUtil.h" +#include "Common/IniFile.h" +#include "Core/PowerPC/PowerPC.h" +#include "DolphinWX/WxUtils.h" #include "DolphinWX/Debugger/WatchView.h" #include "DolphinWX/Debugger/WatchWindow.h" +extern "C" { +#include "DolphinWX/resources/toolbar_debugger_delete.c" +} + class wxWindow; BEGIN_EVENT_TABLE(CWatchWindow, wxPanel) @@ -21,6 +32,40 @@ EVT_GRID_CELL_RIGHT_CLICK(CWatchView::OnMouseDownR) EVT_MENU(-1, CWatchView::OnPopupMenu) END_EVENT_TABLE() +class CWatchToolbar : public wxAuiToolBar +{ +public: +CWatchToolbar(CWatchWindow* parent, const wxWindowID id) + : wxAuiToolBar(parent, id, wxDefaultPosition, wxDefaultSize, + wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_TEXT) +{ + SetToolBitmapSize(wxSize(16, 16)); + + m_Bitmaps[Toolbar_File] = wxBitmap(wxGetBitmapFromMemory(toolbar_delete_png).ConvertToImage().Rescale(16, 16)); + + AddTool(ID_LOAD, _("Load"), m_Bitmaps[Toolbar_File]); + Bind(wxEVT_TOOL, &CWatchWindow::LoadAll, parent, ID_LOAD); + + AddTool(ID_SAVE, _("Save"), m_Bitmaps[Toolbar_File]); + Bind(wxEVT_TOOL, &CWatchWindow::Event_SaveAll, parent, ID_SAVE); +} + +private: + + enum + { + Toolbar_File, + Num_Bitmaps + }; + + enum + { + ID_LOAD, + ID_SAVE + }; + + wxBitmap m_Bitmaps[Num_Bitmaps]; +}; CWatchWindow::CWatchWindow(wxWindow* parent, wxWindowID id, const wxPoint& position, const wxSize& size, @@ -28,17 +73,18 @@ CWatchWindow::CWatchWindow(wxWindow* parent, wxWindowID id, : wxPanel(parent, id, position, size, style, name) , m_GPRGridView(nullptr) { - CreateGUIControls(); -} + m_mgr.SetManagedWindow(this); + m_mgr.SetFlags(wxAUI_MGR_DEFAULT | wxAUI_MGR_LIVE_RESIZE); -void CWatchWindow::CreateGUIControls() -{ wxBoxSizer *sGrid = new wxBoxSizer(wxVERTICAL); m_GPRGridView = new CWatchView(this, ID_GPR); sGrid->Add(m_GPRGridView, 1, wxGROW); SetSizer(sGrid); - NotifyUpdate(); + m_mgr.AddPane(new CWatchToolbar(this, wxID_ANY), wxAuiPaneInfo().ToolbarPane().Top(). + LeftDockable(true).RightDockable(true).BottomDockable(false).Floatable(false)); + m_mgr.AddPane(m_GPRGridView, wxAuiPaneInfo().CenterPane()); + m_mgr.Update(); } void CWatchWindow::NotifyUpdate() @@ -46,3 +92,36 @@ void CWatchWindow::NotifyUpdate() if (m_GPRGridView != nullptr) m_GPRGridView->Update(); } + +void CWatchWindow::Event_SaveAll(wxCommandEvent& WXUNUSED(event)) +{ + SaveAll(); +} + +void CWatchWindow::SaveAll() +{ + IniFile ini; + if (ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX))) + { + ini.SetLines("Watches", PowerPC::watches.GetStrings()); + ini.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX)); + } +} + +void CWatchWindow::LoadAll(wxCommandEvent& WXUNUSED(event)) +{ + IniFile ini; + Watches::TWatchesStr watches; + + if (!ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX))) + { + return; + } + + if (ini.GetLines("Watches", &watches, false)) + { + PowerPC::watches.AddFromStrings(watches); + } + + NotifyUpdate(); +} diff --git a/Source/Core/DolphinWX/Debugger/WatchWindow.h b/Source/Core/DolphinWX/Debugger/WatchWindow.h index 9a3b9c4d67..2f7dd75839 100644 --- a/Source/Core/DolphinWX/Debugger/WatchWindow.h +++ b/Source/Core/DolphinWX/Debugger/WatchWindow.h @@ -11,6 +11,7 @@ #include #include #include +#include class CWatchView; class wxWindow; @@ -27,11 +28,15 @@ public: const wxString& name = _("Watch")); void NotifyUpdate(); - + void Event_SaveAll(wxCommandEvent& WXUNUSED(event)); + void SaveAll(); + void LoadAll(wxCommandEvent& WXUNUSED(event)); private: DECLARE_EVENT_TABLE(); + wxAuiManager m_mgr; + enum { ID_GPR = 1002