From 12eb2caa65498c80c6e1e23f1efceaf05b37d488 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 6 Dec 2014 16:40:48 -0500 Subject: [PATCH 1/4] TASInputDlg: Remove unnecessary wxWidgets default values. --- Source/Core/DolphinWX/TASInputDlg.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/Core/DolphinWX/TASInputDlg.cpp b/Source/Core/DolphinWX/TASInputDlg.cpp index e17c9f5d54..cca0689b4a 100644 --- a/Source/Core/DolphinWX/TASInputDlg.cpp +++ b/Source/Core/DolphinWX/TASInputDlg.cpp @@ -289,7 +289,7 @@ TASInputDlg::Control TASInputDlg::CreateControl(long style, int width, int heigh TASInputDlg::Stick TASInputDlg::CreateStick(int id_stick, int xRange, int yRange, u32 defaultX, u32 defaultY, bool reverseX, bool reverseY) { Stick tempStick; - tempStick.bitmap = new wxStaticBitmap(this, id_stick, CreateStickBitmap(128,128), wxDefaultPosition, wxDefaultSize); + tempStick.bitmap = new wxStaticBitmap(this, id_stick, CreateStickBitmap(128, 128)); tempStick.bitmap->Bind(wxEVT_MOTION, &TASInputDlg::OnMouseDownL, this); tempStick.bitmap->Bind(wxEVT_LEFT_DOWN, &TASInputDlg::OnMouseDownL, this); tempStick.bitmap->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnMouseUpR, this); @@ -338,7 +338,7 @@ wxStaticBoxSizer* TASInputDlg::CreateAccelLayout(Control* x, Control* y, Control TASInputDlg::Button TASInputDlg::CreateButton(const std::string& name) { Button temp; - wxCheckBox* checkbox = new wxCheckBox(this, m_eleID++, name, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxCheckBoxNameStr); + wxCheckBox* checkbox = new wxCheckBox(this, m_eleID++, name); checkbox->Bind(wxEVT_RIGHT_DOWN, &TASInputDlg::SetTurbo, this); checkbox->Bind(wxEVT_LEFT_DOWN, &TASInputDlg::SetTurbo, this); temp.checkbox = checkbox; @@ -710,7 +710,7 @@ void TASInputDlg::OnCloseWindow(wxCloseEvent& event) if (event.CanVeto()) { event.Skip(false); - this->Show(false); + Show(false); ResetValues(); } } @@ -753,7 +753,7 @@ void TASInputDlg::OnMouseUpR(wxMouseEvent& event) stick->x_cont.slider->SetValue(stick->x_cont.default_value); stick->y_cont.slider->SetValue(stick->y_cont.default_value); - event.Skip(true); + event.Skip(); } void TASInputDlg::OnRightClickSlider(wxMouseEvent& event) @@ -806,7 +806,7 @@ void TASInputDlg::OnMouseDownL(wxMouseEvent& event) stick->x_cont.slider->SetValue(stick->x_cont.value); stick->y_cont.slider->SetValue(stick->y_cont.value); - event.Skip(true); + event.Skip(); } void TASInputDlg::SetTurbo(wxMouseEvent& event) @@ -824,7 +824,7 @@ void TASInputDlg::SetTurbo(wxMouseEvent& event) if (button) button->turbo_on = false; - event.Skip(true); + event.Skip(); return; } @@ -834,7 +834,7 @@ void TASInputDlg::SetTurbo(wxMouseEvent& event) button->turbo_on = !button->turbo_on; } - event.Skip(true); + event.Skip(); } void TASInputDlg::ButtonTurbo() From d09130e3d2554182e098a54b490e61c05f682f3c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 6 Dec 2014 16:54:42 -0500 Subject: [PATCH 2/4] TASInputDlg: Replace some for loops with range-based for loops. --- Source/Core/DolphinWX/TASInputDlg.cpp | 71 ++++++++++++++------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/Source/Core/DolphinWX/TASInputDlg.cpp b/Source/Core/DolphinWX/TASInputDlg.cpp index cca0689b4a..d1be562aff 100644 --- a/Source/Core/DolphinWX/TASInputDlg.cpp +++ b/Source/Core/DolphinWX/TASInputDlg.cpp @@ -162,10 +162,10 @@ void TASInputDlg::CreateWiiLayout(int num) m_ext_szr->Add(m_c_stick_szr); m_ext_szr->Add(nunchukaxisBox); - for (unsigned int i = 0; i < 10; ++i) + for (Control* const control : m_controls) { - if (m_controls[i] != nullptr) - m_controls[i]->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this); + if (control != nullptr) + control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this); } for (unsigned int i = 4; i < 14; ++i) @@ -224,10 +224,10 @@ void TASInputDlg::CreateGCLayout() shoulder_box->Add(m_r_cont.slider, 0, wxALIGN_CENTER_VERTICAL); shoulder_box->Add(m_r_cont.text, 0, wxALIGN_CENTER_VERTICAL); - for (unsigned int i = 0; i < 10; ++i) + for (Control* const control : m_controls) { - if (m_controls[i] != nullptr) - m_controls[i]->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this); + if (control != nullptr) + control->slider->Bind(wxEVT_RIGHT_UP, &TASInputDlg::OnRightClickSlider, this); } wxStaticBoxSizer* const m_buttons_box = new wxStaticBoxSizer(wxVERTICAL, this, _("Buttons")); @@ -348,19 +348,19 @@ TASInputDlg::Button TASInputDlg::CreateButton(const std::string& name) void TASInputDlg::ResetValues() { - for (unsigned int i = 0; i < 14; ++i) + for (Button* const button : m_buttons) { - if (m_buttons[i] != nullptr) - m_buttons[i]->checkbox->SetValue(false); + if (button != nullptr) + button->checkbox->SetValue(false); } - for (unsigned int i = 0; i < 10; ++i) + for (Control* const control : m_controls) { - if (m_controls[i] != nullptr) + if (control != nullptr) { - m_controls[i]->value = m_controls[i]->default_value; - m_controls[i]->slider->SetValue(m_controls[i]->default_value); - m_controls[i]->text->SetValue(std::to_string(m_controls[i]->default_value)); + control->value = control->default_value; + control->slider->SetValue(control->default_value); + control->text->SetValue(std::to_string(control->default_value)); } } } @@ -656,10 +656,10 @@ void TASInputDlg::UpdateFromSliders(wxCommandEvent& event) { wxTextCtrl* text = nullptr; - for (unsigned int i = 0; i < 10; ++i) + for (Control* const control : m_controls) { - if (m_controls[i] != nullptr && event.GetId() == m_controls[i]->slider_id) - text = m_controls[i]->text; + if (control != nullptr && event.GetId() == control->slider_id) + text = control->text; } int value = ((wxSlider*) event.GetEventObject())->GetValue(); @@ -674,15 +674,16 @@ void TASInputDlg::UpdateFromText(wxCommandEvent& event) if (!((wxTextCtrl*) event.GetEventObject())->GetValue().ToULong(&value)) return; - for (unsigned int i = 0; i < 10; ++i) + for (Control* const control : m_controls) { - if (m_controls[i] != nullptr && event.GetId() == m_controls[i]->text_id) + if (control != nullptr && event.GetId() == control->text_id) { - int v = value > m_controls[i]->range ? m_controls[i]->range : value; - m_controls[i]->slider->SetValue(v); - m_controls[i]->value = v; + int v = (value > control->range) ? control->range : value; + control->slider->SetValue(v); + control->value = v; } } + if (m_controls[2] != nullptr) { int x = m_c_stick.x_cont.value; @@ -720,9 +721,9 @@ bool TASInputDlg::TASHasFocus() if (!m_has_layout) return false; //allows numbers to be used as hotkeys - for (unsigned int i = 0; i < 10; ++i) + for (Control* const control : m_controls) { - if (m_controls[i] != nullptr && wxWindow::FindFocus() == m_controls[i]->text) + if (control != nullptr && wxWindow::FindFocus() == control->text) return false; } @@ -758,13 +759,13 @@ void TASInputDlg::OnMouseUpR(wxMouseEvent& event) void TASInputDlg::OnRightClickSlider(wxMouseEvent& event) { - for (unsigned int i = 0; i < 10; ++i) + for (Control* const control : m_controls) { - if (m_controls[i] != nullptr && event.GetId() == m_controls[i]->slider_id) + if (control != nullptr && event.GetId() == control->slider_id) { - m_controls[i]->value = m_controls[i]->default_value; - m_controls[i]->slider->SetValue(m_controls[i]->default_value); - m_controls[i]->text->SetValue(std::to_string(m_controls[i]->default_value)); + control->value = control->default_value; + control->slider->SetValue(control->default_value); + control->text->SetValue(std::to_string(control->default_value)); } } } @@ -813,10 +814,10 @@ void TASInputDlg::SetTurbo(wxMouseEvent& event) { Button* button = nullptr; - for (unsigned int i = 0; i < 14; ++i) + for (Button* const btn : m_buttons) { - if (m_buttons[i] != nullptr && event.GetId() == m_buttons[i]->id) - button = m_buttons[i]; + if (btn != nullptr && event.GetId() == btn->id) + button = btn; } if (event.LeftDown()) @@ -844,10 +845,10 @@ void TASInputDlg::ButtonTurbo() if (frame != Movie::g_currentFrame) { frame = Movie::g_currentFrame; - for (unsigned int i = 0; i < 14; ++i) + for (Button* const button : m_buttons) { - if (m_buttons[i] != nullptr && m_buttons[i]->turbo_on) - m_buttons[i]->checkbox->SetValue(!m_buttons[i]->checkbox->GetValue()); + if (button != nullptr && button->turbo_on) + button->checkbox->SetValue(!button->checkbox->GetValue()); } } } From 694247d3fe1de9730d6473fbf4dd54dafadf0cd2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 6 Dec 2014 17:09:05 -0500 Subject: [PATCH 3/4] TASInputDlg: Fix a typo in layout alignment flags --- Source/Core/DolphinWX/TASInputDlg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/DolphinWX/TASInputDlg.cpp b/Source/Core/DolphinWX/TASInputDlg.cpp index d1be562aff..c05587fcd2 100644 --- a/Source/Core/DolphinWX/TASInputDlg.cpp +++ b/Source/Core/DolphinWX/TASInputDlg.cpp @@ -308,7 +308,7 @@ wxStaticBoxSizer* TASInputDlg::CreateStickLayout(Stick* tempStick, const wxStrin temp_xslider_box->Add(tempStick->x_cont.slider, 0, wxALIGN_TOP); temp_xslider_box->Add(tempStick->x_cont.text, 0, wxALIGN_TOP); temp_stick_box->Add(temp_xslider_box); - temp_stick_box->Add(tempStick->bitmap,0, wxALL|wxCenter,3); + temp_stick_box->Add(tempStick->bitmap, 0, wxALL | wxALIGN_CENTER, 3); temp_box->Add(temp_stick_box); temp_yslider_box->Add(tempStick->y_cont.slider, 0, wxALIGN_CENTER_VERTICAL); temp_yslider_box->Add(tempStick->y_cont.text, 0, wxALIGN_CENTER_VERTICAL); From e5e8f49425bd7ebe99367b8e9639702df592247c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 6 Dec 2014 20:13:25 -0500 Subject: [PATCH 4/4] TASInputDlg: Eliminate the usage of some spacers. Bordering parameters can be specified on addition. --- Source/Core/DolphinWX/TASInputDlg.cpp | 28 +++++++++++---------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/Source/Core/DolphinWX/TASInputDlg.cpp b/Source/Core/DolphinWX/TASInputDlg.cpp index c05587fcd2..c5afd22648 100644 --- a/Source/Core/DolphinWX/TASInputDlg.cpp +++ b/Source/Core/DolphinWX/TASInputDlg.cpp @@ -159,7 +159,7 @@ void TASInputDlg::CreateWiiLayout(int num) m_c = CreateButton("C"); m_z = CreateButton("Z"); - m_ext_szr->Add(m_c_stick_szr); + m_ext_szr->Add(m_c_stick_szr, 0, wxLEFT | wxBOTTOM | wxRIGHT, 5); m_ext_szr->Add(nunchukaxisBox); for (Control* const control : m_controls) @@ -176,9 +176,9 @@ void TASInputDlg::CreateWiiLayout(int num) m_buttons_box->Add(m_buttons_grid); m_buttons_box->Add(m_buttons_dpad); - m_wiimote_szr->Add(m_main_stick_szr); - m_wiimote_szr->Add(axisBox); - m_wiimote_szr->Add(m_buttons_box); + m_wiimote_szr->Add(m_main_stick_szr, 0, wxALL, 5); + m_wiimote_szr->Add(axisBox, 0, wxTOP | wxRIGHT, 5); + m_wiimote_szr->Add(m_buttons_box, 0, wxTOP | wxRIGHT, 5); m_main_szr->Add(m_wiimote_szr); m_main_szr->Add(m_ext_szr); if (m_ext == 1) @@ -250,16 +250,10 @@ void TASInputDlg::CreateGCLayout() wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL); - top_box->AddSpacer(5); - top_box->Add(main_box); - top_box->AddSpacer(5); - top_box->Add(c_box); - top_box->AddSpacer(5); - bottom_box->AddSpacer(5); - bottom_box->Add(shoulder_box); - bottom_box->AddSpacer(5); - bottom_box->Add(m_buttons_box); - bottom_box->AddSpacer(5); + top_box->Add(main_box, 0, wxALL, 5); + top_box->Add(c_box, 0, wxTOP | wxRIGHT, 5); + bottom_box->Add(shoulder_box, 0, wxLEFT | wxRIGHT, 5); + bottom_box->Add(m_buttons_box, 0, wxBOTTOM, 5); main_szr->Add(top_box); main_szr->Add(bottom_box); SetSizerAndFit(main_szr); @@ -329,9 +323,9 @@ wxStaticBoxSizer* TASInputDlg::CreateAccelLayout(Control* x, Control* y, Control yBox->Add(y->text, 0, wxALIGN_CENTER_VERTICAL); zBox->Add(z->slider, 0, wxALIGN_CENTER_VERTICAL); zBox->Add(z->text, 0, wxALIGN_CENTER_VERTICAL); - temp_box->Add(xBox); - temp_box->Add(yBox); - temp_box->Add(zBox); + temp_box->Add(xBox, 0, wxLEFT | wxBOTTOM | wxRIGHT, 5); + temp_box->Add(yBox, 0, wxRIGHT, 5); + temp_box->Add(zBox, 0, wxRIGHT, 5); return temp_box; }