PostProcessingConfigDiag.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // Copyright 2014 Dolphin Emulator Project
  2. // Licensed under GPLv2+
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <map>
  6. #include <string>
  7. #include <vector>
  8. #include <wx/dialog.h>
  9. #include <wx/slider.h>
  10. #include <wx/textctrl.h>
  11. #include "VideoCommon/PostProcessing.h"
  12. class wxButton;
  13. class wxCheckBox;
  14. class wxFlexGridSizer;
  15. class PostProcessingConfigDiag : public wxDialog
  16. {
  17. public:
  18. PostProcessingConfigDiag(wxWindow* parent, const std::string& shader);
  19. ~PostProcessingConfigDiag();
  20. private:
  21. // This is literally the stupidest thing ever
  22. // wxWidgets takes ownership of any pointer given to a event handler
  23. // Instead of passing them a pointer to a std::string, we wrap around it here.
  24. class UserEventData : public wxObject
  25. {
  26. public:
  27. UserEventData(const std::string& data) : m_data(data) {}
  28. const std::string& GetData() { return m_data; }
  29. private:
  30. const std::string m_data;
  31. };
  32. class ConfigGrouping
  33. {
  34. public:
  35. enum WidgetType
  36. {
  37. TYPE_TOGGLE,
  38. TYPE_SLIDER,
  39. };
  40. ConfigGrouping(WidgetType type, const std::string& gui_name,
  41. const std::string& option_name, const std::string& parent,
  42. const PostProcessingShaderConfiguration::ConfigurationOption* config_option)
  43. : m_type(type), m_gui_name(gui_name),
  44. m_option(option_name), m_parent(parent),
  45. m_config_option(config_option) {}
  46. void AddChild(ConfigGrouping* child) { m_children.push_back(child); }
  47. bool HasChildren() { return m_children.size() != 0; }
  48. std::vector<ConfigGrouping*>& GetChildren() { return m_children; }
  49. // Gets the string that is shown in the UI for the option
  50. const std::string& GetGUIName() { return m_gui_name; }
  51. // Gets the option name for use in the shader
  52. // Also is a unique identifier for the option's configuration
  53. const std::string& GetOption() { return m_option; }
  54. // Gets the option name of the parent of this option
  55. const std::string& GetParent() { return m_parent; }
  56. void GenerateUI(PostProcessingConfigDiag* dialog, wxWindow* parent, wxFlexGridSizer* sizer);
  57. void EnableDependentChildren(bool enable);
  58. int GetSliderValue(const int index) { return m_option_sliders[index]->GetValue(); }
  59. void SetSliderText(const int index, const std::string& text) { m_option_text_ctrls[index]->SetValue(text); }
  60. private:
  61. const WidgetType m_type;
  62. const std::string m_gui_name;
  63. const std::string m_option;
  64. const std::string m_parent;
  65. const PostProcessingShaderConfiguration::ConfigurationOption* m_config_option;
  66. // For TYPE_TOGGLE
  67. wxCheckBox* m_option_checkbox;
  68. // For TYPE_SLIDER
  69. // Can have up to 4
  70. std::vector<wxSlider*> m_option_sliders;
  71. std::vector<wxTextCtrl*> m_option_text_ctrls;
  72. std::vector<ConfigGrouping*> m_children;
  73. };
  74. // WX UI things
  75. void Event_Close(wxCloseEvent&);
  76. void Event_ClickClose(wxCommandEvent&);
  77. void Event_Slider(wxCommandEvent &ev);
  78. void Event_CheckBox(wxCommandEvent &ev);
  79. const std::string& m_shader;
  80. PostProcessingShaderConfiguration* m_post_processor;
  81. std::map<std::string, ConfigGrouping*> m_config_map;
  82. std::vector<ConfigGrouping*> m_config_groups;
  83. };