File: PostProcessingConfigDiag.h

package info (click to toggle)
dolphin-emu 5.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 29,052 kB
  • sloc: cpp: 213,146; java: 6,252; asm: 2,277; xml: 1,998; ansic: 1,514; python: 462; sh: 279; pascal: 247; makefile: 124; perl: 97
file content (106 lines) | stat: -rw-r--r-- 3,110 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright 2014 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <map>
#include <string>
#include <vector>

#include <wx/dialog.h>
#include <wx/slider.h>
#include <wx/textctrl.h>

#include "VideoCommon/PostProcessing.h"

class wxButton;
class wxCheckBox;
class wxFlexGridSizer;

class PostProcessingConfigDiag : public wxDialog
{
public:
	PostProcessingConfigDiag(wxWindow* parent, const std::string& shader);
	~PostProcessingConfigDiag();

private:

	// This is literally the stupidest thing ever
	// wxWidgets takes ownership of any pointer given to a event handler
	// Instead of passing them a pointer to a std::string, we wrap around it here.
	class UserEventData : public wxObject
	{
	public:
		UserEventData(const std::string& data) : m_data(data) {}
		const std::string& GetData() { return m_data; }
	private:
		const std::string m_data;
	};

	class ConfigGrouping
	{
	public:
		enum WidgetType
		{
			TYPE_TOGGLE,
			TYPE_SLIDER,
		};

		ConfigGrouping(WidgetType type, const std::string& gui_name,
		               const std::string& option_name, const std::string& parent,
				   const PostProcessingShaderConfiguration::ConfigurationOption* config_option)
			: m_type(type), m_gui_name(gui_name),
			  m_option(option_name), m_parent(parent),
			  m_config_option(config_option) {}

		void AddChild(ConfigGrouping* child) { m_children.push_back(child); }
		bool HasChildren() { return m_children.size() != 0; }
		std::vector<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
		// Also is a unique identifier for the option's configuration
		const std::string& GetOption() { return m_option; }
		// Gets the option name of the parent of this option
		const std::string& GetParent() { return m_parent; }

		void GenerateUI(PostProcessingConfigDiag* dialog, wxWindow* parent, wxFlexGridSizer* sizer);

		void EnableDependentChildren(bool enable);

		int GetSliderValue(const int index) { return m_option_sliders[index]->GetValue(); }
		void SetSliderText(const int index, const std::string& text) { m_option_text_ctrls[index]->SetValue(text); }

	private:
		const WidgetType m_type;
		const std::string m_gui_name;
		const std::string m_option;
		const std::string m_parent;
		const PostProcessingShaderConfiguration::ConfigurationOption* m_config_option;

		// For TYPE_TOGGLE
		wxCheckBox* m_option_checkbox;

		// For TYPE_SLIDER
		// Can have up to 4
		std::vector<wxSlider*> m_option_sliders;
		std::vector<wxTextCtrl*> m_option_text_ctrls;

		std::vector<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;
};