From 7cf78a00eb1b10116ee0f1239266c488ba6d31d5 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 30 Apr 2017 02:44:27 -0400 Subject: [PATCH 1/7] MemoryWindow: Normalize variable naming --- .../Core/DolphinWX/Debugger/MemoryWindow.cpp | 145 +++++++++--------- Source/Core/DolphinWX/Debugger/MemoryWindow.h | 22 +-- 2 files changed, 87 insertions(+), 80 deletions(-) diff --git a/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp b/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp index 6f4553657c..f1f3b06772 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp @@ -40,13 +40,13 @@ enum { - IDM_MEM_ADDRBOX, - IDM_SYMBOLLIST, - IDM_SETVALBUTTON, + IDM_ADDRESS_SEARCH_CTRL, + IDM_SYMBOL_LIST, + IDM_SET_VALUE_BUTTON, IDM_DUMP_MEMORY, IDM_DUMP_MEM2, IDM_DUMP_FAKEVMEM, - IDM_VALBOX, + IDM_VALUE_TEXT_CTRL, IDM_DATA_TYPE_RBOX, IDM_FIND_NEXT, IDM_FIND_PREVIOUS, @@ -56,7 +56,7 @@ enum }; BEGIN_EVENT_TABLE(CMemoryWindow, wxPanel) -EVT_BUTTON(IDM_SETVALBUTTON, CMemoryWindow::SetMemoryValue) +EVT_BUTTON(IDM_SET_VALUE_BUTTON, CMemoryWindow::OnSetMemoryValue) EVT_BUTTON(IDM_DUMP_MEMORY, CMemoryWindow::OnDumpMemory) EVT_BUTTON(IDM_DUMP_MEM2, CMemoryWindow::OnDumpMem2) EVT_BUTTON(IDM_DUMP_FAKEVMEM, CMemoryWindow::OnDumpFakeVMEM) @@ -73,25 +73,26 @@ CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id, const wxPoint& pos { DebugInterface* di = &PowerPC::debug_interface; - memview = new CMemoryView(di, this); - memview->Bind(DOLPHIN_EVT_MEMORY_VIEW_DATA_TYPE_CHANGED, &CMemoryWindow::OnDataTypeChanged, this); + m_memory_view = new CMemoryView(di, this); + m_memory_view->Bind(DOLPHIN_EVT_MEMORY_VIEW_DATA_TYPE_CHANGED, &CMemoryWindow::OnDataTypeChanged, + this); - addrbox = new wxSearchCtrl(this, IDM_MEM_ADDRBOX); - addrbox->Bind(wxEVT_TEXT, &CMemoryWindow::OnAddrBoxChange, this); - addrbox->SetDescriptiveText(_("Search Address")); + m_address_search_ctrl = new wxSearchCtrl(this, IDM_ADDRESS_SEARCH_CTRL); + m_address_search_ctrl->Bind(wxEVT_TEXT, &CMemoryWindow::OnSearchAddressChanged, this); + m_address_search_ctrl->SetDescriptiveText(_("Search Address")); - valbox = - new wxTextCtrl(this, IDM_VALBOX, "", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); - valbox->Bind(wxEVT_TEXT_ENTER, &CMemoryWindow::SetMemoryValueFromValBox, this); - valbox->Bind(wxEVT_TEXT, &CMemoryWindow::OnValueChanged, this); + m_value_text_ctrl = new wxTextCtrl(this, IDM_VALUE_TEXT_CTRL, "", wxDefaultPosition, + wxDefaultSize, wxTE_PROCESS_ENTER); + m_value_text_ctrl->Bind(wxEVT_TEXT_ENTER, &CMemoryWindow::OnSetMemoryValueFromValBox, this); + m_value_text_ctrl->Bind(wxEVT_TEXT, &CMemoryWindow::OnValueChanged, this); const int space3 = FromDIP(3); const int space5 = FromDIP(5); wxBoxSizer* const search_sizer = new wxBoxSizer(wxVERTICAL); - search_sizer->Add(addrbox, 0, wxEXPAND); - search_sizer->Add(valbox, 0, wxEXPAND); - search_sizer->Add(new wxButton(this, IDM_SETVALBUTTON, _("Set Value"))); + search_sizer->Add(m_address_search_ctrl, 0, wxEXPAND); + search_sizer->Add(m_value_text_ctrl, 0, wxEXPAND); + search_sizer->Add(new wxButton(this, IDM_SET_VALUE_BUTTON, _("Set Value"))); wxBoxSizer* const dump_sizer = new wxBoxSizer(wxVERTICAL); dump_sizer->Add(new wxButton(this, IDM_DUMP_MEMORY, _("Dump MRAM")), 0, wxEXPAND); @@ -99,17 +100,17 @@ CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id, const wxPoint& pos if (!SConfig::GetInstance().bMMU) dump_sizer->Add(new wxButton(this, IDM_DUMP_FAKEVMEM, _("Dump FakeVMEM")), 0, wxEXPAND); - wxStaticBoxSizer* const sizerSearchType = new wxStaticBoxSizer(wxVERTICAL, this, _("Search")); - sizerSearchType->Add(m_btn_find_next = new wxButton(this, IDM_FIND_NEXT, _("Find Next"))); - sizerSearchType->Add(m_btn_find_previous = - new wxButton(this, IDM_FIND_PREVIOUS, _("Find Previous"))); - sizerSearchType->Add(m_rb_ascii = new wxRadioButton(this, IDM_ASCII, "Ascii", wxDefaultPosition, - wxDefaultSize, wxRB_GROUP)); - sizerSearchType->Add(m_rb_hex = new wxRadioButton(this, IDM_HEX, _("Hex"))); + wxStaticBoxSizer* const search_type_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Search")); + search_type_sizer->Add(m_btn_find_next = new wxButton(this, IDM_FIND_NEXT, _("Find Next"))); + search_type_sizer->Add(m_btn_find_previous = + new wxButton(this, IDM_FIND_PREVIOUS, _("Find Previous"))); + search_type_sizer->Add(m_rb_ascii = new wxRadioButton(this, IDM_ASCII, "Ascii", wxDefaultPosition, + wxDefaultSize, wxRB_GROUP)); + search_type_sizer->Add(m_rb_hex = new wxRadioButton(this, IDM_HEX, _("Hex"))); m_search_result_msg = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE | wxALIGN_CENTER_HORIZONTAL); - sizerSearchType->Add(m_search_result_msg, 0, wxEXPAND); + search_type_sizer->Add(m_search_result_msg, 0, wxEXPAND); wxArrayString data_type_options; data_type_options.Add("U8"); @@ -122,50 +123,51 @@ CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id, const wxPoint& pos wxStaticBoxSizer* const memcheck_options_sizer = new wxStaticBoxSizer(wxVERTICAL, this, "Memory breakpoint options"); - memcheck_options_sizer->Add(rdbReadWrite = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, - "Read and Write", wxDefaultPosition, - wxDefaultSize, wxRB_GROUP)); + memcheck_options_sizer->Add(m_read_write_radio_btn = new wxRadioButton( + this, IDM_MEMCHECK_OPTIONS_CHANGE, "Read and Write", + wxDefaultPosition, wxDefaultSize, wxRB_GROUP)); memcheck_options_sizer->Add( - rdbRead = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, "Read only")); + m_read_radio_btn = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, "Read only")); memcheck_options_sizer->Add( - rdbWrite = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, "Write only")); - memcheck_options_sizer->Add(chkLog = new wxCheckBox(this, IDM_MEMCHECK_OPTIONS_CHANGE, "Log")); + m_write_radio_btn = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, "Write only")); + memcheck_options_sizer->Add(m_log_checkbox = + new wxCheckBox(this, IDM_MEMCHECK_OPTIONS_CHANGE, "Log")); - wxBoxSizer* const sizerRight = new wxBoxSizer(wxVERTICAL); - sizerRight->Add(search_sizer); - sizerRight->AddSpacer(space5); - sizerRight->Add(dump_sizer, 0, wxEXPAND); - sizerRight->Add(sizerSearchType, 0, wxEXPAND); - sizerRight->Add(m_rbox_data_type, 0, wxEXPAND); - sizerRight->Add(memcheck_options_sizer, 0, wxEXPAND); + wxBoxSizer* const right_sizer = new wxBoxSizer(wxVERTICAL); + right_sizer->Add(search_sizer); + right_sizer->AddSpacer(space5); + right_sizer->Add(dump_sizer, 0, wxEXPAND); + right_sizer->Add(search_type_sizer, 0, wxEXPAND); + right_sizer->Add(m_rbox_data_type, 0, wxEXPAND); + right_sizer->Add(memcheck_options_sizer, 0, wxEXPAND); - wxBoxSizer* const sizerBig = new wxBoxSizer(wxHORIZONTAL); - sizerBig->Add(memview, 20, wxEXPAND); - sizerBig->AddSpacer(space3); - sizerBig->Add(sizerRight, 0, wxEXPAND | wxTOP | wxBOTTOM, space3); - sizerBig->AddSpacer(space3); + wxBoxSizer* const main_sizer = new wxBoxSizer(wxHORIZONTAL); + main_sizer->Add(m_memory_view, 20, wxEXPAND); + main_sizer->AddSpacer(space3); + main_sizer->Add(right_sizer, 0, wxEXPAND | wxTOP | wxBOTTOM, space3); + main_sizer->AddSpacer(space3); - SetSizer(sizerBig); + SetSizer(main_sizer); m_rb_hex->SetValue(true); // Set defaults - chkLog->SetValue(true); - m_rbox_data_type->SetSelection(static_cast(memview->GetDataType())); + m_log_checkbox->SetValue(true); + m_rbox_data_type->SetSelection(static_cast(m_memory_view->GetDataType())); - sizerRight->Fit(this); - sizerBig->Fit(this); + right_sizer->Fit(this); + main_sizer->Fit(this); } -void CMemoryWindow::JumpToAddress(u32 _Address) +void CMemoryWindow::JumpToAddress(u32 address) { - memview->Center(_Address); + m_memory_view->Center(address); } -void CMemoryWindow::SetMemoryValueFromValBox(wxCommandEvent& event) +void CMemoryWindow::OnSetMemoryValueFromValBox(wxCommandEvent& event) { - SetMemoryValue(event); - valbox->SetFocus(); + OnSetMemoryValue(event); + m_value_text_ctrl->SetFocus(); } -void CMemoryWindow::SetMemoryValue(wxCommandEvent& event) +void CMemoryWindow::OnSetMemoryValue(wxCommandEvent& event) { if (!Memory::IsInitialized()) { @@ -173,8 +175,8 @@ void CMemoryWindow::SetMemoryValue(wxCommandEvent& event) return; } - std::string str_addr = WxStrToStr(addrbox->GetValue()); - std::string str_val = WxStrToStr(valbox->GetValue()); + std::string str_addr = WxStrToStr(m_address_search_ctrl->GetValue()); + std::string str_val = WxStrToStr(m_value_text_ctrl->GetValue()); u32 addr; u32 val; @@ -191,17 +193,17 @@ void CMemoryWindow::SetMemoryValue(wxCommandEvent& event) } PowerPC::HostWrite_U32(val, addr); - memview->Refresh(); + m_memory_view->Refresh(); } -void CMemoryWindow::OnAddrBoxChange(wxCommandEvent& event) +void CMemoryWindow::OnSearchAddressChanged(wxCommandEvent& event) { - wxString txt = addrbox->GetValue(); + wxString txt = m_address_search_ctrl->GetValue(); if (txt.size()) { u32 addr; sscanf(WxStrToStr(txt).c_str(), "%08x", &addr); - memview->Center(addr & ~3); + m_memory_view->Center(addr & ~3); } event.Skip(); @@ -209,7 +211,7 @@ void CMemoryWindow::OnAddrBoxChange(wxCommandEvent& event) void CMemoryWindow::Repopulate() { - memview->Center(PC); + m_memory_view->Center(PC); } void CMemoryWindow::OnValueChanged(wxCommandEvent&) @@ -258,7 +260,7 @@ void CMemoryWindow::OnDataTypeChanged(wxCommandEvent& ev) MemoryDataType::FloatingPoint}}; if (ev.GetId() == IDM_DATA_TYPE_RBOX) { - memview->SetDataType(map.at(ev.GetSelection())); + m_memory_view->SetDataType(map.at(ev.GetSelection())); } else { @@ -288,7 +290,7 @@ void CMemoryWindow::Search(SearchType search_type) u8* ram_ptr = nullptr; std::size_t ram_size = 0; // NOTE: We're assuming the base address is zero. - switch (memview->GetMemoryType()) + switch (m_memory_view->GetMemoryType()) { case 0: default: @@ -316,7 +318,7 @@ void CMemoryWindow::Search(SearchType search_type) } std::vector search_bytes; - wxString search_val = valbox->GetValue(); + wxString search_val = m_value_text_ctrl->GetValue(); if (m_rb_hex->GetValue()) { @@ -363,7 +365,7 @@ void CMemoryWindow::Search(SearchType search_type) // Search starting from specified address if there is one. u32 addr = 0; // Base address { - wxString addr_val = addrbox->GetValue(); + wxString addr_val = m_address_search_ctrl->GetValue(); addr_val.Trim(true).Trim(false); if (!addr_val.empty()) { @@ -408,7 +410,7 @@ void CMemoryWindow::Search(SearchType search_type) m_search_result_msg->SetLabel(_("Match Found")); u32 offset = static_cast(ptr - ram_ptr); // NOTE: SetValue() generates a synthetic wxEVT_TEXT - addrbox->SetValue(wxString::Format("%08x", offset)); + m_address_search_ctrl->SetValue(wxString::Format("%08x", offset)); m_last_search_address = offset; m_continue_search = true; return; @@ -419,8 +421,13 @@ void CMemoryWindow::Search(SearchType search_type) void CMemoryWindow::OnMemCheckOptionChange(wxCommandEvent& event) { - if (rdbReadWrite->GetValue()) - memview->SetMemCheckOptions(true, true, chkLog->GetValue()); + if (m_read_write_radio_btn->GetValue()) + { + m_memory_view->SetMemCheckOptions(true, true, m_log_checkbox->GetValue()); + } else - memview->SetMemCheckOptions(rdbRead->GetValue(), rdbWrite->GetValue(), chkLog->GetValue()); + { + m_memory_view->SetMemCheckOptions(m_read_radio_btn->GetValue(), m_write_radio_btn->GetValue(), + m_log_checkbox->GetValue()); + } } diff --git a/Source/Core/DolphinWX/Debugger/MemoryWindow.h b/Source/Core/DolphinWX/Debugger/MemoryWindow.h index 6036bf6c95..c2811b598f 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryWindow.h +++ b/Source/Core/DolphinWX/Debugger/MemoryWindow.h @@ -29,7 +29,7 @@ public: void Repopulate(); - void JumpToAddress(u32 _Address); + void JumpToAddress(u32 address); private: enum class SearchType @@ -43,10 +43,10 @@ private: void OnDataTypeChanged(wxCommandEvent& event); void OnFindNext(wxCommandEvent& event); void OnFindPrevious(wxCommandEvent& event); - void OnAddrBoxChange(wxCommandEvent& event); + void OnSearchAddressChanged(wxCommandEvent& event); void OnValueChanged(wxCommandEvent&); - void SetMemoryValueFromValBox(wxCommandEvent& event); - void SetMemoryValue(wxCommandEvent& event); + void OnSetMemoryValueFromValBox(wxCommandEvent& event); + void OnSetMemoryValue(wxCommandEvent& event); void OnDumpMemory(wxCommandEvent& event); void OnDumpMem2(wxCommandEvent& event); void OnDumpFakeVMEM(wxCommandEvent& event); @@ -62,17 +62,17 @@ private: wxRadioBox* m_rbox_data_type; wxStaticText* m_search_result_msg; - wxCheckBox* chkLog; - wxRadioButton* rdbRead; - wxRadioButton* rdbWrite; - wxRadioButton* rdbReadWrite; + wxCheckBox* m_log_checkbox; + wxRadioButton* m_read_radio_btn; + wxRadioButton* m_write_radio_btn; + wxRadioButton* m_read_write_radio_btn; CCodeWindow* m_code_window; - CMemoryView* memview; + CMemoryView* m_memory_view; - wxSearchCtrl* addrbox; - wxTextCtrl* valbox; + wxSearchCtrl* m_address_search_ctrl; + wxTextCtrl* m_value_text_ctrl; u32 m_last_search_address = 0; bool m_continue_search = false; From 4c70f05fe0d2ba706c8c24da1d2149f79551ce9f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 30 Apr 2017 03:04:50 -0400 Subject: [PATCH 2/7] MemoryWindow: Get rid of unnecessary std::string constructions std::string's operator+ will handle this. Also move std::string to where they're actually needed. There's no need to construct an unnecessary string if the first failure case occurs. --- Source/Core/DolphinWX/Debugger/MemoryWindow.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp b/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp index f1f3b06772..3422f2c2ef 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp @@ -176,17 +176,16 @@ void CMemoryWindow::OnSetMemoryValue(wxCommandEvent& event) } std::string str_addr = WxStrToStr(m_address_search_ctrl->GetValue()); - std::string str_val = WxStrToStr(m_value_text_ctrl->GetValue()); u32 addr; - u32 val; - - if (!TryParse(std::string("0x") + str_addr, &addr)) + if (!TryParse("0x" + str_addr, &addr)) { WxUtils::ShowErrorDialog(wxString::Format(_("Invalid address: %s"), str_addr.c_str())); return; } - if (!TryParse(std::string("0x") + str_val, &val)) + std::string str_val = WxStrToStr(m_value_text_ctrl->GetValue()); + u32 val; + if (!TryParse("0x" + str_val, &val)) { WxUtils::ShowErrorDialog(wxString::Format(_("Invalid value: %s"), str_val.c_str())); return; From 7941a05a8078280be8af62b18bce29e5ac3548e0 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 30 Apr 2017 03:08:05 -0400 Subject: [PATCH 3/7] MemoryWindow: Add missing translation markers for UI strings --- Source/Core/DolphinWX/Debugger/MemoryWindow.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp b/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp index 3422f2c2ef..8285f2fa71 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp @@ -122,16 +122,16 @@ CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id, const wxPoint& pos wxDefaultSize, data_type_options, 1); wxStaticBoxSizer* const memcheck_options_sizer = - new wxStaticBoxSizer(wxVERTICAL, this, "Memory breakpoint options"); + new wxStaticBoxSizer(wxVERTICAL, this, _("Memory breakpoint options")); memcheck_options_sizer->Add(m_read_write_radio_btn = new wxRadioButton( - this, IDM_MEMCHECK_OPTIONS_CHANGE, "Read and Write", + this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Read and Write"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP)); memcheck_options_sizer->Add( - m_read_radio_btn = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, "Read only")); + m_read_radio_btn = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Read only"))); memcheck_options_sizer->Add( - m_write_radio_btn = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, "Write only")); + m_write_radio_btn = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Write only"))); memcheck_options_sizer->Add(m_log_checkbox = - new wxCheckBox(this, IDM_MEMCHECK_OPTIONS_CHANGE, "Log")); + new wxCheckBox(this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Log"))); wxBoxSizer* const right_sizer = new wxBoxSizer(wxVERTICAL); right_sizer->Add(search_sizer); From 402faf37585f7ac7a54ada50f8e6f94fce8d36e7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 30 Apr 2017 03:13:09 -0400 Subject: [PATCH 4/7] MemoryWindow: Make constructor explicit --- Source/Core/DolphinWX/Debugger/MemoryWindow.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinWX/Debugger/MemoryWindow.h b/Source/Core/DolphinWX/Debugger/MemoryWindow.h index c2811b598f..d1226aadbe 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryWindow.h +++ b/Source/Core/DolphinWX/Debugger/MemoryWindow.h @@ -23,9 +23,10 @@ class wxRadioButton; class CMemoryWindow : public wxPanel { public: - CMemoryWindow(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL | wxBORDER_NONE, - const wxString& name = _("Memory")); + explicit CMemoryWindow(wxWindow* parent, wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + long style = wxTAB_TRAVERSAL | wxBORDER_NONE, + const wxString& name = _("Memory")); void Repopulate(); From aad9fd6751622907f67de617afff542c8505e177 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 30 Apr 2017 03:55:55 -0400 Subject: [PATCH 5/7] MemoryWindow: Localize sizer creation code Keeps specific UI element initialization separate from one another. --- .../Core/DolphinWX/Debugger/MemoryWindow.cpp | 154 +++++++++++------- Source/Core/DolphinWX/Debugger/MemoryWindow.h | 7 + 2 files changed, 106 insertions(+), 55 deletions(-) diff --git a/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp b/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp index 8285f2fa71..075b0169e5 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp @@ -71,12 +71,53 @@ CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id, const wxPoint& pos const wxSize& size, long style, const wxString& name) : wxPanel(parent, id, pos, size, style, name) { - DebugInterface* di = &PowerPC::debug_interface; + CreateGUI(); +} - m_memory_view = new CMemoryView(di, this); +void CMemoryWindow::CreateGUI() +{ + m_memory_view = new CMemoryView(&PowerPC::debug_interface, this); m_memory_view->Bind(DOLPHIN_EVT_MEMORY_VIEW_DATA_TYPE_CHANGED, &CMemoryWindow::OnDataTypeChanged, this); + const int space3 = FromDIP(3); + + wxBoxSizer* const main_sizer = new wxBoxSizer(wxHORIZONTAL); + main_sizer->Add(m_memory_view, 20, wxEXPAND); + main_sizer->AddSpacer(space3); + main_sizer->Add(CreateRightHandSideSizer(), 0, wxEXPAND | wxTOP | wxBOTTOM, space3); + main_sizer->AddSpacer(space3); + + SetSizerAndFit(main_sizer); +} + +wxSizer* CMemoryWindow::CreateRightHandSideSizer() +{ + wxArrayString data_type_options; + data_type_options.Add("U8"); + data_type_options.Add("U16"); + data_type_options.Add("U32"); + data_type_options.Add("ASCII"); + data_type_options.Add("Float32"); + m_rbox_data_type = new wxRadioBox(this, IDM_DATA_TYPE_RBOX, _("Data Type"), wxDefaultPosition, + wxDefaultSize, data_type_options, 1); + m_rbox_data_type->SetSelection(static_cast(m_memory_view->GetDataType())); + + const int space5 = FromDIP(5); + + auto* const right_sizer = new wxBoxSizer(wxVERTICAL); + right_sizer->Add(CreateSearchSizer(), 0, wxEXPAND); + right_sizer->AddSpacer(space5); + right_sizer->Add(CreateDumpSizer(), 0, wxEXPAND); + right_sizer->Add(CreateSearchTypeSizer(), 0, wxEXPAND); + right_sizer->Add(m_rbox_data_type, 0, wxEXPAND); + right_sizer->Add(CreateMemcheckOptionSizer(), 0, wxEXPAND); + + return right_sizer; +} + +wxSizer* CMemoryWindow::CreateSearchSizer() +{ m_address_search_ctrl = new wxSearchCtrl(this, IDM_ADDRESS_SEARCH_CTRL); m_address_search_ctrl->Bind(wxEVT_TEXT, &CMemoryWindow::OnSearchAddressChanged, this); m_address_search_ctrl->SetDescriptiveText(_("Search Address")); @@ -86,74 +127,77 @@ CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id, const wxPoint& pos m_value_text_ctrl->Bind(wxEVT_TEXT_ENTER, &CMemoryWindow::OnSetMemoryValueFromValBox, this); m_value_text_ctrl->Bind(wxEVT_TEXT, &CMemoryWindow::OnValueChanged, this); - const int space3 = FromDIP(3); - const int space5 = FromDIP(5); + auto* const set_value_button = new wxButton(this, IDM_SET_VALUE_BUTTON, _("Set Value")); - wxBoxSizer* const search_sizer = new wxBoxSizer(wxVERTICAL); + auto* const search_sizer = new wxBoxSizer(wxVERTICAL); search_sizer->Add(m_address_search_ctrl, 0, wxEXPAND); search_sizer->Add(m_value_text_ctrl, 0, wxEXPAND); - search_sizer->Add(new wxButton(this, IDM_SET_VALUE_BUTTON, _("Set Value"))); + search_sizer->Add(set_value_button); + + return search_sizer; +} + +wxSizer* CMemoryWindow::CreateDumpSizer() +{ + auto* const dump_mram_button = new wxButton(this, IDM_DUMP_MEMORY, _("Dump MRAM")); + auto* const dump_exram_button = new wxButton(this, IDM_DUMP_MEM2, _("Dump EXRAM")); + + auto* const dump_sizer = new wxBoxSizer(wxVERTICAL); + dump_sizer->Add(dump_mram_button, 0, wxEXPAND); + dump_sizer->Add(dump_exram_button, 0, wxEXPAND); - wxBoxSizer* const dump_sizer = new wxBoxSizer(wxVERTICAL); - dump_sizer->Add(new wxButton(this, IDM_DUMP_MEMORY, _("Dump MRAM")), 0, wxEXPAND); - dump_sizer->Add(new wxButton(this, IDM_DUMP_MEM2, _("Dump EXRAM")), 0, wxEXPAND); if (!SConfig::GetInstance().bMMU) - dump_sizer->Add(new wxButton(this, IDM_DUMP_FAKEVMEM, _("Dump FakeVMEM")), 0, wxEXPAND); + { + auto* const dump_fake_vmem_button = new wxButton(this, IDM_DUMP_FAKEVMEM, _("Dump FakeVMEM")); + + dump_sizer->Add(dump_fake_vmem_button, 0, wxEXPAND); + } + + return dump_sizer; +} + +wxSizer* CMemoryWindow::CreateSearchTypeSizer() +{ + m_btn_find_next = new wxButton(this, IDM_FIND_NEXT, _("Find Next")); + m_btn_find_previous = new wxButton(this, IDM_FIND_PREVIOUS, _("Find Previous")); + + m_rb_ascii = + new wxRadioButton(this, IDM_ASCII, "Ascii", wxDefaultPosition, wxDefaultSize, wxRB_GROUP); + m_rb_hex = new wxRadioButton(this, IDM_HEX, _("Hex")); + m_rb_hex->SetValue(true); - wxStaticBoxSizer* const search_type_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Search")); - search_type_sizer->Add(m_btn_find_next = new wxButton(this, IDM_FIND_NEXT, _("Find Next"))); - search_type_sizer->Add(m_btn_find_previous = - new wxButton(this, IDM_FIND_PREVIOUS, _("Find Previous"))); - search_type_sizer->Add(m_rb_ascii = new wxRadioButton(this, IDM_ASCII, "Ascii", wxDefaultPosition, - wxDefaultSize, wxRB_GROUP)); - search_type_sizer->Add(m_rb_hex = new wxRadioButton(this, IDM_HEX, _("Hex"))); m_search_result_msg = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_NO_AUTORESIZE | wxALIGN_CENTER_HORIZONTAL); + + auto* const search_type_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Search")); + search_type_sizer->Add(m_btn_find_next); + search_type_sizer->Add(m_btn_find_previous); + search_type_sizer->Add(m_rb_ascii); + search_type_sizer->Add(m_rb_hex); search_type_sizer->Add(m_search_result_msg, 0, wxEXPAND); - wxArrayString data_type_options; - data_type_options.Add("U8"); - data_type_options.Add("U16"); - data_type_options.Add("U32"); - data_type_options.Add("ASCII"); - data_type_options.Add("Float32"); - m_rbox_data_type = new wxRadioBox(this, IDM_DATA_TYPE_RBOX, _("Data Type"), wxDefaultPosition, - wxDefaultSize, data_type_options, 1); + return search_type_sizer; +} - wxStaticBoxSizer* const memcheck_options_sizer = - new wxStaticBoxSizer(wxVERTICAL, this, _("Memory breakpoint options")); - memcheck_options_sizer->Add(m_read_write_radio_btn = new wxRadioButton( - this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Read and Write"), - wxDefaultPosition, wxDefaultSize, wxRB_GROUP)); - memcheck_options_sizer->Add( - m_read_radio_btn = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Read only"))); - memcheck_options_sizer->Add( - m_write_radio_btn = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Write only"))); - memcheck_options_sizer->Add(m_log_checkbox = - new wxCheckBox(this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Log"))); +wxSizer* CMemoryWindow::CreateMemcheckOptionSizer() +{ + m_read_write_radio_btn = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Read and Write"), + wxDefaultPosition, wxDefaultSize, wxRB_GROUP); + m_read_radio_btn = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Read only")); + m_write_radio_btn = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Write only")); - wxBoxSizer* const right_sizer = new wxBoxSizer(wxVERTICAL); - right_sizer->Add(search_sizer); - right_sizer->AddSpacer(space5); - right_sizer->Add(dump_sizer, 0, wxEXPAND); - right_sizer->Add(search_type_sizer, 0, wxEXPAND); - right_sizer->Add(m_rbox_data_type, 0, wxEXPAND); - right_sizer->Add(memcheck_options_sizer, 0, wxEXPAND); - - wxBoxSizer* const main_sizer = new wxBoxSizer(wxHORIZONTAL); - main_sizer->Add(m_memory_view, 20, wxEXPAND); - main_sizer->AddSpacer(space3); - main_sizer->Add(right_sizer, 0, wxEXPAND | wxTOP | wxBOTTOM, space3); - main_sizer->AddSpacer(space3); - - SetSizer(main_sizer); - m_rb_hex->SetValue(true); // Set defaults + m_log_checkbox = new wxCheckBox(this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Log")); m_log_checkbox->SetValue(true); - m_rbox_data_type->SetSelection(static_cast(m_memory_view->GetDataType())); - right_sizer->Fit(this); - main_sizer->Fit(this); + auto* const memcheck_options_sizer = + new wxStaticBoxSizer(wxVERTICAL, this, _("Memory breakpoint options")); + memcheck_options_sizer->Add(m_read_write_radio_btn); + memcheck_options_sizer->Add(m_read_radio_btn); + memcheck_options_sizer->Add(m_write_radio_btn); + memcheck_options_sizer->Add(m_log_checkbox); + + return memcheck_options_sizer; } void CMemoryWindow::JumpToAddress(u32 address) diff --git a/Source/Core/DolphinWX/Debugger/MemoryWindow.h b/Source/Core/DolphinWX/Debugger/MemoryWindow.h index d1226aadbe..f83a3c4f3b 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryWindow.h +++ b/Source/Core/DolphinWX/Debugger/MemoryWindow.h @@ -41,6 +41,13 @@ private: DECLARE_EVENT_TABLE() + void CreateGUI(); + wxSizer* CreateRightHandSideSizer(); + wxSizer* CreateSearchSizer(); + wxSizer* CreateDumpSizer(); + wxSizer* CreateSearchTypeSizer(); + wxSizer* CreateMemcheckOptionSizer(); + void OnDataTypeChanged(wxCommandEvent& event); void OnFindNext(wxCommandEvent& event); void OnFindPrevious(wxCommandEvent& event); From 9a778786dfc75da6b5bf03f19950917cdf978b3a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 30 Apr 2017 04:43:55 -0400 Subject: [PATCH 6/7] MemoryWindow: Convert event table over to bound events Event tables are the old method of performing event binding. --- .../Core/DolphinWX/Debugger/MemoryWindow.cpp | 27 ++++++++++--------- Source/Core/DolphinWX/Debugger/MemoryWindow.h | 2 -- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp b/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp index 075b0169e5..dffb04069b 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/MemoryWindow.cpp @@ -55,18 +55,6 @@ enum IDM_MEMCHECK_OPTIONS_CHANGE }; -BEGIN_EVENT_TABLE(CMemoryWindow, wxPanel) -EVT_BUTTON(IDM_SET_VALUE_BUTTON, CMemoryWindow::OnSetMemoryValue) -EVT_BUTTON(IDM_DUMP_MEMORY, CMemoryWindow::OnDumpMemory) -EVT_BUTTON(IDM_DUMP_MEM2, CMemoryWindow::OnDumpMem2) -EVT_BUTTON(IDM_DUMP_FAKEVMEM, CMemoryWindow::OnDumpFakeVMEM) -EVT_RADIOBOX(IDM_DATA_TYPE_RBOX, CMemoryWindow::OnDataTypeChanged) -EVT_BUTTON(IDM_FIND_NEXT, CMemoryWindow::OnFindNext) -EVT_BUTTON(IDM_FIND_PREVIOUS, CMemoryWindow::OnFindPrevious) -EVT_RADIOBUTTON(IDM_MEMCHECK_OPTIONS_CHANGE, CMemoryWindow::OnMemCheckOptionChange) -EVT_CHECKBOX(IDM_MEMCHECK_OPTIONS_CHANGE, CMemoryWindow::OnMemCheckOptionChange) -END_EVENT_TABLE() - CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxPanel(parent, id, pos, size, style, name) @@ -101,6 +89,7 @@ wxSizer* CMemoryWindow::CreateRightHandSideSizer() data_type_options.Add("Float32"); m_rbox_data_type = new wxRadioBox(this, IDM_DATA_TYPE_RBOX, _("Data Type"), wxDefaultPosition, wxDefaultSize, data_type_options, 1); + m_rbox_data_type->Bind(wxEVT_RADIOBOX, &CMemoryWindow::OnDataTypeChanged, this); m_rbox_data_type->SetSelection(static_cast(m_memory_view->GetDataType())); const int space5 = FromDIP(5); @@ -128,6 +117,7 @@ wxSizer* CMemoryWindow::CreateSearchSizer() m_value_text_ctrl->Bind(wxEVT_TEXT, &CMemoryWindow::OnValueChanged, this); auto* const set_value_button = new wxButton(this, IDM_SET_VALUE_BUTTON, _("Set Value")); + set_value_button->Bind(wxEVT_BUTTON, &CMemoryWindow::OnSetMemoryValue, this); auto* const search_sizer = new wxBoxSizer(wxVERTICAL); search_sizer->Add(m_address_search_ctrl, 0, wxEXPAND); @@ -140,7 +130,10 @@ wxSizer* CMemoryWindow::CreateSearchSizer() wxSizer* CMemoryWindow::CreateDumpSizer() { auto* const dump_mram_button = new wxButton(this, IDM_DUMP_MEMORY, _("Dump MRAM")); + dump_mram_button->Bind(wxEVT_BUTTON, &CMemoryWindow::OnDumpMemory, this); + auto* const dump_exram_button = new wxButton(this, IDM_DUMP_MEM2, _("Dump EXRAM")); + dump_exram_button->Bind(wxEVT_BUTTON, &CMemoryWindow::OnDumpMem2, this); auto* const dump_sizer = new wxBoxSizer(wxVERTICAL); dump_sizer->Add(dump_mram_button, 0, wxEXPAND); @@ -149,6 +142,7 @@ wxSizer* CMemoryWindow::CreateDumpSizer() if (!SConfig::GetInstance().bMMU) { auto* const dump_fake_vmem_button = new wxButton(this, IDM_DUMP_FAKEVMEM, _("Dump FakeVMEM")); + dump_fake_vmem_button->Bind(wxEVT_BUTTON, &CMemoryWindow::OnDumpFakeVMEM, this); dump_sizer->Add(dump_fake_vmem_button, 0, wxEXPAND); } @@ -159,7 +153,10 @@ wxSizer* CMemoryWindow::CreateDumpSizer() wxSizer* CMemoryWindow::CreateSearchTypeSizer() { m_btn_find_next = new wxButton(this, IDM_FIND_NEXT, _("Find Next")); + m_btn_find_next->Bind(wxEVT_BUTTON, &CMemoryWindow::OnFindNext, this); + m_btn_find_previous = new wxButton(this, IDM_FIND_PREVIOUS, _("Find Previous")); + m_btn_find_previous->Bind(wxEVT_BUTTON, &CMemoryWindow::OnFindPrevious, this); m_rb_ascii = new wxRadioButton(this, IDM_ASCII, "Ascii", wxDefaultPosition, wxDefaultSize, wxRB_GROUP); @@ -184,10 +181,16 @@ wxSizer* CMemoryWindow::CreateMemcheckOptionSizer() { m_read_write_radio_btn = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Read and Write"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); + m_read_write_radio_btn->Bind(wxEVT_RADIOBUTTON, &CMemoryWindow::OnMemCheckOptionChange, this); + m_read_radio_btn = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Read only")); + m_read_radio_btn->Bind(wxEVT_RADIOBUTTON, &CMemoryWindow::OnMemCheckOptionChange, this); + m_write_radio_btn = new wxRadioButton(this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Write only")); + m_write_radio_btn->Bind(wxEVT_RADIOBUTTON, &CMemoryWindow::OnMemCheckOptionChange, this); m_log_checkbox = new wxCheckBox(this, IDM_MEMCHECK_OPTIONS_CHANGE, _("Log")); + m_log_checkbox->Bind(wxEVT_CHECKBOX, &CMemoryWindow::OnMemCheckOptionChange, this); m_log_checkbox->SetValue(true); auto* const memcheck_options_sizer = diff --git a/Source/Core/DolphinWX/Debugger/MemoryWindow.h b/Source/Core/DolphinWX/Debugger/MemoryWindow.h index f83a3c4f3b..a090a3bbc3 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryWindow.h +++ b/Source/Core/DolphinWX/Debugger/MemoryWindow.h @@ -39,8 +39,6 @@ private: FindPrevious }; - DECLARE_EVENT_TABLE() - void CreateGUI(); wxSizer* CreateRightHandSideSizer(); wxSizer* CreateSearchSizer(); From 683462679bbff94e46d9b491e7a96601c4da214b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 30 Apr 2017 06:02:32 -0400 Subject: [PATCH 7/7] MemoryWindow: Remove unused member variable --- Source/Core/DolphinWX/Debugger/MemoryWindow.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/Core/DolphinWX/Debugger/MemoryWindow.h b/Source/Core/DolphinWX/Debugger/MemoryWindow.h index a090a3bbc3..7d23ed3a32 100644 --- a/Source/Core/DolphinWX/Debugger/MemoryWindow.h +++ b/Source/Core/DolphinWX/Debugger/MemoryWindow.h @@ -8,7 +8,6 @@ #include "Common/CommonTypes.h" class CMemoryView; -class CCodeWindow; class IniFile; class wxButton; class wxCheckBox; @@ -73,8 +72,6 @@ private: wxRadioButton* m_write_radio_btn; wxRadioButton* m_read_write_radio_btn; - CCodeWindow* m_code_window; - CMemoryView* m_memory_view; wxSearchCtrl* m_address_search_ctrl;