WX: HiDPI: VideoConfigDiag

Resolved "TODO" for Texture Cache safety, added explanation message.
Resolved "TODO" for default description, no longer uses default text for sizing

Fixed a memory leak in PostProcessingConfigDiag where it was never freeing any
of the objects it allocated in its constructor.

Minor design change to PostProcessingConfigDiag to give padding around elements
consistent with the rest of Dolphin's user interface (5px).
This commit is contained in:
EmptyChaos
2016-10-04 13:47:22 +11:00
parent 2dfd04d7a5
commit ef0d21299a
5 changed files with 340 additions and 228 deletions
@@ -2,15 +2,13 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <math.h>
#include <unordered_map>
#include <cmath>
#include <wx/button.h>
#include <wx/checkbox.h>
#include <wx/notebook.h>
#include <wx/panel.h>
#include <wx/sizer.h>
#include <wx/slider.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
@@ -37,45 +35,54 @@ PostProcessingConfigDiag::PostProcessingConfigDiag(wxWindow* parent, const std::
// Create our UI classes
const PostProcessingShaderConfiguration::ConfigMap& config_map = m_post_processor->GetOptions();
std::vector<std::unique_ptr<ConfigGrouping>> config_groups;
config_groups.reserve(config_map.size());
m_config_map.reserve(config_map.size());
for (const auto& it : config_map)
{
std::unique_ptr<ConfigGrouping> group;
if (it.second.m_type ==
PostProcessingShaderConfiguration::ConfigurationOption::OptionType::OPTION_BOOL)
{
ConfigGrouping* group =
new ConfigGrouping(ConfigGrouping::WidgetType::TYPE_TOGGLE, it.second.m_gui_name,
it.first, it.second.m_dependent_option, &it.second);
m_config_map[it.first] = group;
group = std::make_unique<ConfigGrouping>(ConfigGrouping::WidgetType::TYPE_TOGGLE,
it.second.m_gui_name, it.first,
it.second.m_dependent_option, &it.second);
}
else
{
ConfigGrouping* group =
new ConfigGrouping(ConfigGrouping::WidgetType::TYPE_SLIDER, it.second.m_gui_name,
it.first, it.second.m_dependent_option, &it.second);
m_config_map[it.first] = group;
group = std::make_unique<ConfigGrouping>(ConfigGrouping::WidgetType::TYPE_SLIDER,
it.second.m_gui_name, it.first,
it.second.m_dependent_option, &it.second);
}
m_config_map[it.first] = group.get();
config_groups.emplace_back(std::move(group));
}
// Arrange our vectors based on dependency
for (const auto& it : m_config_map)
for (auto& group : config_groups)
{
const std::string parent_name = it.second->GetParent();
if (parent_name.size())
const std::string& parent_name = group->GetParent();
if (parent_name.empty())
{
// Since it depends on a different object, push it to a parent's object
m_config_map[parent_name]->AddChild(m_config_map[it.first]);
// It doesn't have a parent, just push it to the vector
m_config_groups.emplace_back(std::move(group));
}
else
{
// It doesn't have a child, just push it to the vector
m_config_groups.push_back(m_config_map[it.first]);
// Since it depends on a different object, push it to a parent's object
m_config_map[parent_name]->AddChild(std::move(group));
}
}
config_groups.clear(); // Full of null unique_ptrs now
config_groups.shrink_to_fit();
const int space5 = FromDIP(5);
const int space10 = FromDIP(10);
// Generate our UI
wxNotebook* const notebook = new wxNotebook(this, wxID_ANY);
wxPanel* const page_general = new wxPanel(notebook);
wxFlexGridSizer* const szr_general = new wxFlexGridSizer(2, 5, 5);
wxFlexGridSizer* const szr_general = new wxFlexGridSizer(2, space5, space5);
// Now let's actually populate our window with our information
bool add_general_page = false;
@@ -85,7 +92,8 @@ PostProcessingConfigDiag::PostProcessingConfigDiag(wxWindow* parent, const std::
{
// Options with children get their own tab
wxPanel* const page_option = new wxPanel(notebook);
wxFlexGridSizer* const szr_option = new wxFlexGridSizer(2, 10, 5);
wxBoxSizer* const wrap_sizer = new wxBoxSizer(wxVERTICAL);
wxFlexGridSizer* const szr_option = new wxFlexGridSizer(2, space10, space5);
it->GenerateUI(this, page_option, szr_option);
// Add all the children
@@ -93,8 +101,11 @@ PostProcessingConfigDiag::PostProcessingConfigDiag(wxWindow* parent, const std::
{
child->GenerateUI(this, page_option, szr_option);
}
page_option->SetSizerAndFit(szr_option);
notebook->AddPage(page_option, _(it->GetGUIName()));
wrap_sizer->AddSpacer(space5);
wrap_sizer->Add(szr_option, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
wrap_sizer->AddSpacer(space5);
page_option->SetSizerAndFit(wrap_sizer);
notebook->AddPage(page_option, it->GetGUIName());
}
else
{
@@ -110,20 +121,30 @@ PostProcessingConfigDiag::PostProcessingConfigDiag(wxWindow* parent, const std::
if (add_general_page)
{
page_general->SetSizerAndFit(szr_general);
wxBoxSizer* const wrap_sizer = new wxBoxSizer(wxVERTICAL);
wrap_sizer->AddSpacer(space5);
wrap_sizer->Add(szr_general, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
wrap_sizer->AddSpacer(space5);
page_general->SetSizerAndFit(wrap_sizer);
notebook->InsertPage(0, page_general, _("General"));
}
// Close Button
wxButton* const btn_close = new wxButton(this, wxID_OK, _("Close"));
btn_close->Bind(wxEVT_BUTTON, &PostProcessingConfigDiag::Event_ClickClose, this);
Bind(wxEVT_CLOSE_WINDOW, &PostProcessingConfigDiag::Event_Close, this);
wxStdDialogButtonSizer* const btn_strip = CreateStdDialogButtonSizer(wxOK | wxNO_DEFAULT);
btn_strip->GetAffirmativeButton()->SetLabel(_("Close"));
SetEscapeId(wxID_OK); // Treat closing the window by 'X' or hitting escape as 'OK'
wxBoxSizer* const szr_main = new wxBoxSizer(wxVERTICAL);
szr_main->Add(notebook, 1, wxEXPAND | wxALL, 5);
szr_main->Add(btn_close, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 5);
szr_main->AddSpacer(space5);
szr_main->Add(notebook, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
szr_main->Add(btn_strip, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
szr_main->SetMinSize(FromDIP(wxSize(400, -1)));
SetLayoutAdaptationMode(wxDIALOG_ADAPTATION_MODE_ENABLED);
SetLayoutAdaptationLevel(wxDIALOG_ADAPTATION_STANDARD_SIZER);
SetSizerAndFit(szr_main);
Center();
SetFocus();
@@ -145,7 +166,7 @@ void PostProcessingConfigDiag::ConfigGrouping::GenerateUI(PostProcessingConfigDi
{
if (m_type == WidgetType::TYPE_TOGGLE)
{
m_option_checkbox = new wxCheckBox(parent, wxID_ANY, _(m_gui_name));
m_option_checkbox = new wxCheckBox(parent, wxID_ANY, m_gui_name);
m_option_checkbox->SetValue(m_config_option->m_bool_value);
m_option_checkbox->Bind(wxEVT_CHECKBOX, &PostProcessingConfigDiag::Event_CheckBox, dialog,
wxID_ANY, wxID_ANY, new UserEventData(m_option));
@@ -162,8 +183,8 @@ void PostProcessingConfigDiag::ConfigGrouping::GenerateUI(PostProcessingConfigDi
else
vector_size = m_config_option->m_float_values.size();
wxFlexGridSizer* const szr_values = new wxFlexGridSizer(vector_size + 1, 0, 0);
wxStaticText* const option_static_text = new wxStaticText(parent, wxID_ANY, _(m_gui_name));
wxFlexGridSizer* const szr_values = new wxFlexGridSizer(vector_size + 1);
wxStaticText* const option_static_text = new wxStaticText(parent, wxID_ANY, m_gui_name);
sizer->Add(option_static_text);
for (size_t i = 0; i < vector_size; ++i)
@@ -185,7 +206,7 @@ void PostProcessingConfigDiag::ConfigGrouping::GenerateUI(PostProcessingConfigDi
// This may not be 100% spot on accurate since developers can have odd stepping intervals
// set.
// Round up so if it is outside our range, then set it to the minimum or maximum
steps = ceil(range / (double)m_config_option->m_integer_step_values[i]);
steps = std::ceil(range / (double)m_config_option->m_integer_step_values[i]);
// Default value is just the currently set value here
current_value = m_config_option->m_integer_values[i];
@@ -196,7 +217,7 @@ void PostProcessingConfigDiag::ConfigGrouping::GenerateUI(PostProcessingConfigDi
// Same as above but with floats
float range =
m_config_option->m_float_max_values[i] - m_config_option->m_float_min_values[i];
steps = ceil(range / m_config_option->m_float_step_values[i]);
steps = std::ceil(range / m_config_option->m_float_step_values[i]);
// We need to convert our default float value from a float to the nearest step value range
current_value =
@@ -204,8 +225,9 @@ void PostProcessingConfigDiag::ConfigGrouping::GenerateUI(PostProcessingConfigDi
string_value = std::to_string(m_config_option->m_float_values[i]);
}
wxSlider* slider = new wxSlider(parent, wxID_ANY, current_value, 0, steps, wxDefaultPosition,
wxSize(200, -1), wxSL_HORIZONTAL | wxSL_BOTTOM);
DolphinSlider* slider =
new DolphinSlider(parent, wxID_ANY, current_value, 0, steps, wxDefaultPosition,
parent->FromDIP(wxSize(200, -1)), wxSL_HORIZONTAL | wxSL_BOTTOM);
wxTextCtrl* text_ctrl = new wxTextCtrl(parent, wxID_ANY, string_value);
// Disable the textctrl, it's only there to show the absolute value from the slider
@@ -222,18 +244,18 @@ void PostProcessingConfigDiag::ConfigGrouping::GenerateUI(PostProcessingConfigDi
if (vector_size == 1)
{
szr_values->Add(m_option_sliders[0], wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL));
szr_values->Add(m_option_text_ctrls[0]);
szr_values->Add(m_option_sliders[0], 0, wxALIGN_CENTER_VERTICAL);
szr_values->Add(m_option_text_ctrls[0], 0, wxALIGN_CENTER_VERTICAL);
sizer->Add(szr_values);
}
else
{
wxFlexGridSizer* const szr_inside = new wxFlexGridSizer(2, 0, 0);
wxFlexGridSizer* const szr_inside = new wxFlexGridSizer(2);
for (size_t i = 0; i < vector_size; ++i)
{
szr_inside->Add(m_option_sliders[i], wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL));
szr_inside->Add(m_option_text_ctrls[i]);
szr_inside->Add(m_option_sliders[i], 0, wxALIGN_CENTER_VERTICAL);
szr_inside->Add(m_option_text_ctrls[i], 0, wxALIGN_CENTER_VERTICAL);
}
szr_values->Add(szr_inside);
@@ -313,13 +335,3 @@ void PostProcessingConfigDiag::Event_Slider(wxCommandEvent& ev)
}
ev.Skip();
}
void PostProcessingConfigDiag::Event_ClickClose(wxCommandEvent&)
{
Close();
}
void PostProcessingConfigDiag::Event_Close(wxCloseEvent& ev)
{
EndModal(wxID_OK);
}
@@ -4,14 +4,16 @@
#pragma once
#include <map>
#include <memory>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include <wx/dialog.h>
#include <wx/slider.h>
#include <wx/textctrl.h>
#include "DolphinWX/DolphinSlider.h"
#include "VideoCommon/PostProcessing.h"
class wxButton;
@@ -54,9 +56,12 @@ private:
{
}
void AddChild(ConfigGrouping* child) { m_children.push_back(child); }
void AddChild(std::unique_ptr<ConfigGrouping>&& child)
{
m_children.emplace_back(std::move(child));
}
bool HasChildren() { return m_children.size() != 0; }
std::vector<ConfigGrouping*>& GetChildren() { return m_children; }
const std::vector<std::unique_ptr<ConfigGrouping>>& GetChildren() { return m_children; }
// Gets the string that is shown in the UI for the option
const std::string& GetGUIName() { return m_gui_name; }
// Gets the option name for use in the shader
@@ -86,21 +91,19 @@ private:
// For TYPE_SLIDER
// Can have up to 4
std::vector<wxSlider*> m_option_sliders;
std::vector<DolphinSlider*> m_option_sliders;
std::vector<wxTextCtrl*> m_option_text_ctrls;
std::vector<ConfigGrouping*> m_children;
std::vector<std::unique_ptr<ConfigGrouping>> m_children;
};
// WX UI things
void Event_Close(wxCloseEvent&);
void Event_ClickClose(wxCommandEvent&);
void Event_Slider(wxCommandEvent& ev);
void Event_CheckBox(wxCommandEvent& ev);
const std::string& m_shader;
PostProcessingShaderConfiguration* m_post_processor;
std::map<std::string, ConfigGrouping*> m_config_map;
std::vector<ConfigGrouping*> m_config_groups;
std::unordered_map<std::string, ConfigGrouping*> m_config_map;
std::vector<std::unique_ptr<ConfigGrouping>> m_config_groups;
};
@@ -36,11 +36,12 @@ SoftwareVideoConfigDialog::SoftwareVideoConfigDialog(wxWindow* parent, const std
wxString(wxString::Format(_("Dolphin %s Graphics Configuration"), title)))
{
VideoConfig& vconfig = g_Config;
vconfig.Load(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini");
wxNotebook* const notebook = new wxNotebook(this, wxID_ANY);
const int space5 = FromDIP(5);
// -- GENERAL --
{
wxPanel* const page_general = new wxPanel(notebook);
@@ -51,9 +52,11 @@ SoftwareVideoConfigDialog::SoftwareVideoConfigDialog(wxWindow* parent, const std
{
wxStaticBoxSizer* const group_rendering =
new wxStaticBoxSizer(wxVERTICAL, page_general, _("Rendering"));
szr_general->Add(group_rendering, 0, wxEXPAND | wxALL, 5);
wxGridSizer* const szr_rendering = new wxGridSizer(2, 5, 5);
group_rendering->Add(szr_rendering, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
szr_general->AddSpacer(space5);
szr_general->Add(group_rendering, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
wxGridSizer* const szr_rendering = new wxGridSizer(2, space5, space5);
group_rendering->Add(szr_rendering, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
group_rendering->AddSpacer(space5);
// backend
wxStaticText* const label_backend = new wxStaticText(page_general, wxID_ANY, _("Backend:"));
@@ -68,8 +71,8 @@ SoftwareVideoConfigDialog::SoftwareVideoConfigDialog(wxWindow* parent, const std
choice_backend->SetStringSelection(StrToWxStr(g_video_backend->GetName()));
choice_backend->Bind(wxEVT_CHOICE, &SoftwareVideoConfigDialog::Event_Backend, this);
szr_rendering->Add(label_backend, 1, wxALIGN_CENTER_VERTICAL, 5);
szr_rendering->Add(choice_backend, 1, 0, 0);
szr_rendering->Add(label_backend, 0, wxALIGN_CENTER_VERTICAL);
szr_rendering->Add(choice_backend, 0, wxALIGN_CENTER_VERTICAL);
if (Core::GetState() != Core::CORE_UNINITIALIZED)
{
@@ -86,9 +89,11 @@ SoftwareVideoConfigDialog::SoftwareVideoConfigDialog(wxWindow* parent, const std
{
wxStaticBoxSizer* const group_info =
new wxStaticBoxSizer(wxVERTICAL, page_general, _("Overlay Information"));
szr_general->Add(group_info, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
wxGridSizer* const szr_info = new wxGridSizer(2, 5, 5);
group_info->Add(szr_info, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
szr_general->AddSpacer(space5);
szr_general->Add(group_info, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
wxGridSizer* const szr_info = new wxGridSizer(2, space5, space5);
group_info->Add(szr_info, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
group_info->AddSpacer(space5);
szr_info->Add(
new SettingCheckBox(page_general, _("Various Statistics"), "", vconfig.bOverlayStats));
@@ -98,9 +103,11 @@ SoftwareVideoConfigDialog::SoftwareVideoConfigDialog(wxWindow* parent, const std
{
wxStaticBoxSizer* const group_utility =
new wxStaticBoxSizer(wxVERTICAL, page_general, _("Utility"));
szr_general->Add(group_utility, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
wxGridSizer* const szr_utility = new wxGridSizer(2, 5, 5);
group_utility->Add(szr_utility, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
szr_general->AddSpacer(space5);
szr_general->Add(group_utility, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
wxGridSizer* const szr_utility = new wxGridSizer(2, space5, space5);
group_utility->Add(szr_utility, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
group_utility->AddSpacer(space5);
szr_utility->Add(
new SettingCheckBox(page_general, _("Dump Textures"), "", vconfig.bDumpTextures));
@@ -110,10 +117,12 @@ SoftwareVideoConfigDialog::SoftwareVideoConfigDialog(wxWindow* parent, const std
// - debug only
wxStaticBoxSizer* const group_debug_only_utility =
new wxStaticBoxSizer(wxHORIZONTAL, page_general, _("Debug Only"));
group_utility->Add(group_debug_only_utility, 0, wxEXPAND | wxBOTTOM, 5);
wxGridSizer* const szr_debug_only_utility = new wxGridSizer(2, 5, 5);
group_debug_only_utility->Add(szr_debug_only_utility, 1,
wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
group_utility->Add(group_debug_only_utility, 0, wxEXPAND);
group_utility->AddSpacer(space5);
wxGridSizer* const szr_debug_only_utility = new wxGridSizer(2, space5, space5);
group_debug_only_utility->AddSpacer(space5);
group_debug_only_utility->Add(szr_debug_only_utility, 0, wxEXPAND | wxBOTTOM, space5);
group_debug_only_utility->AddSpacer(space5);
szr_debug_only_utility->Add(
new SettingCheckBox(page_general, _("Dump TEV Stages"), "", vconfig.bDumpTevStages));
@@ -125,23 +134,33 @@ SoftwareVideoConfigDialog::SoftwareVideoConfigDialog(wxWindow* parent, const std
{
wxStaticBoxSizer* const group_misc =
new wxStaticBoxSizer(wxVERTICAL, page_general, _("Drawn Object Range"));
szr_general->Add(group_misc, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
wxFlexGridSizer* const szr_misc = new wxFlexGridSizer(2, 5, 5);
group_misc->Add(szr_misc, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5);
szr_general->AddSpacer(space5);
szr_general->Add(group_misc, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
wxFlexGridSizer* const szr_misc = new wxFlexGridSizer(2, space5, space5);
group_misc->Add(szr_misc, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
group_misc->AddSpacer(space5);
szr_misc->Add(
new IntegerSetting<int>(page_general, _("Start"), vconfig.drawStart, 0, 100000));
szr_misc->Add(new IntegerSetting<int>(page_general, _("End"), vconfig.drawEnd, 0, 100000));
}
szr_general->AddSpacer(space5);
page_general->SetSizerAndFit(szr_general);
}
wxBoxSizer* const szr_main = new wxBoxSizer(wxVERTICAL);
szr_main->Add(notebook, 1, wxEXPAND | wxALL, 5);
szr_main->Add(new wxButton(this, wxID_OK, _("Close"), wxDefaultPosition), 0,
wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 5);
wxStdDialogButtonSizer* const btn_sizer = CreateStdDialogButtonSizer(wxOK | wxNO_DEFAULT);
btn_sizer->GetAffirmativeButton()->SetLabel(_("Close"));
wxBoxSizer* const szr_main = new wxBoxSizer(wxVERTICAL);
szr_main->AddSpacer(space5);
szr_main->Add(notebook, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
szr_main->Add(btn_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
SetLayoutAdaptationMode(wxDIALOG_ADAPTATION_MODE_ENABLED);
SetLayoutAdaptationLevel(wxDIALOG_ADAPTATION_STANDARD_SIZER);
SetSizerAndFit(szr_main);
Center();
SetFocus();
File diff suppressed because it is too large Load Diff
+4 -5
View File
@@ -21,6 +21,7 @@
#include "Common/SysConf.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "DolphinWX/DolphinSlider.h"
#include "DolphinWX/PostProcessingConfigDiag.h"
#include "DolphinWX/WxUtils.h"
#include "VideoCommon/PostProcessing.h"
@@ -100,8 +101,7 @@ protected:
wxMessageBox(_("Software rendering is an order of magnitude slower than using the "
"other backends.\nIt's only useful for debugging purposes.\nDo you "
"really want to enable software rendering? If unsure, select 'No'."),
_("Warning"), wxYES_NO | wxNO_DEFAULT | wxICON_EXCLAMATION,
wxWindow::FindFocus()));
_("Warning"), wxYES_NO | wxNO_DEFAULT | wxICON_EXCLAMATION, this));
}
if (do_switch)
@@ -198,8 +198,7 @@ protected:
ev.Skip();
}
void Event_ClickClose(wxCommandEvent&);
void Event_Close(wxCloseEvent&);
void Event_Close(wxCommandEvent&);
// Enables/disables UI elements depending on current config
void OnUpdateUI(wxUpdateUIEvent& ev)
@@ -274,7 +273,7 @@ protected:
wxStaticText* text_aamode;
wxChoice* choice_aamode;
wxSlider* conv_slider;
DolphinSlider* conv_slider;
wxStaticText* label_display_resolution;