[Windows] Fix driver version detection of AMD RDNA+ GPU on Windows 10
[xbmc.git] / xbmc / settings / dialogs / GUIDialogSettingsBase.h
blob63862e6643dd4c489ed22a1450a72e85ced35ee3
1 /*
2 * Copyright (C) 2014-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "guilib/GUIDialog.h"
12 #include "settings/SettingControl.h"
13 #include "settings/lib/ISettingCallback.h"
14 #include "threads/Timer.h"
15 #include "utils/ILocalizer.h"
17 #include <set>
18 #include <vector>
20 #define CONTROL_SETTINGS_LABEL 2
21 #define CONTROL_SETTINGS_DESCRIPTION 6
23 #define CONTROL_SETTINGS_OKAY_BUTTON 28
24 #define CONTROL_SETTINGS_CANCEL_BUTTON 29
25 #define CONTROL_SETTINGS_CUSTOM_BUTTON 30
27 #define CONTROL_SETTINGS_START_BUTTONS -200
28 #define CONTROL_SETTINGS_START_CONTROL -180
30 #define SETTINGS_RESET_SETTING_ID "settings.reset"
31 #define SETTINGS_EMPTY_CATEGORY_ID "categories.empty"
33 class CGUIControl;
34 class CGUIControlBaseSetting;
35 class CGUIImage;
36 class CGUISpinControlEx;
37 class CGUIEditControl;
38 class CGUIButtonControl;
39 class CGUIRadioButtonControl;
40 class CGUISettingsSliderControl;
41 class CGUILabelControl;
42 class CGUIColorButtonControl;
44 class CSetting;
45 class CSettingAction;
46 class CSettingCategory;
47 class CSettingGroup;
48 class CSettingSection;
50 class CVariant;
52 class ISetting;
54 typedef std::shared_ptr<CGUIControlBaseSetting> BaseSettingControlPtr;
56 class CGUIDialogSettingsBase : public CGUIDialog,
57 public CSettingControlCreator,
58 public ILocalizer,
59 protected ITimerCallback,
60 protected ISettingCallback
62 public:
63 CGUIDialogSettingsBase(int windowId, const std::string& xmlFile);
64 ~CGUIDialogSettingsBase() override;
66 // specializations of CGUIControl
67 bool OnMessage(CGUIMessage& message) override;
68 bool OnAction(const CAction& action) override;
69 bool OnBack(int actionID) override;
70 void DoProcess(unsigned int currentTime, CDirtyRegionList& dirtyregions) override;
72 virtual bool IsConfirmed() const { return m_confirmed; }
74 // implementation of ILocalizer
75 std::string Localize(std::uint32_t code) const override { return GetLocalizedString(code); }
77 protected:
78 // specializations of CGUIWindow
79 void OnInitWindow() override;
81 // implementations of ITimerCallback
82 void OnTimeout() override;
84 // implementations of ISettingCallback
85 void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) override;
86 void OnSettingPropertyChanged(const std::shared_ptr<const CSetting>& setting,
87 const char* propertyName) override;
89 // new virtual methods
90 virtual bool AllowResettingSettings() const { return true; }
91 virtual int GetSettingLevel() const { return 0; }
92 virtual std::shared_ptr<CSettingSection> GetSection() = 0;
93 virtual std::shared_ptr<CSetting> GetSetting(const std::string& settingId) = 0;
94 virtual std::chrono::milliseconds GetDelayMs() const { return std::chrono::milliseconds(1500); }
95 virtual std::string GetLocalizedString(uint32_t labelId) const;
97 virtual bool OnOkay()
99 m_confirmed = true;
100 return true;
102 virtual void OnCancel() {}
104 virtual void SetupView();
105 virtual std::set<std::string> CreateSettings();
106 virtual void UpdateSettings();
109 \brief Get the name for the setting entry
111 Used as virtual to allow related settings dialog to give a std::string name of the setting.
112 If not used on own dialog class it handle the string from int CSetting::GetLabel(),
113 This must also be used if on related dialog no special entry is wanted.
115 \param pSetting Base settings class which need the name
116 \return Name used on settings dialog
118 virtual std::string GetSettingsLabel(const std::shared_ptr<ISetting>& pSetting);
120 virtual CGUIControl* AddSetting(const std::shared_ptr<CSetting>& pSetting,
121 float width,
122 int& iControlID);
123 virtual CGUIControl* AddSettingControl(CGUIControl* pControl,
124 BaseSettingControlPtr pSettingControl,
125 float width,
126 int& iControlID);
128 virtual void SetupControls(bool createSettings = true);
129 virtual void FreeControls();
130 virtual void DeleteControls();
131 virtual void FreeSettingsControls();
133 virtual void SetHeading(const CVariant& label);
134 virtual void SetDescription(const CVariant& label);
136 virtual void OnResetSettings();
139 \brief A setting control has been interacted with by the user
141 This method is called when the user manually interacts (clicks,
142 edits) with a setting control. It contains handling for both
143 delayed and undelayed settings and either starts the delay timer
144 or triggers the setting change which, on success, results in a
145 callback to OnSettingChanged().
147 \param pSettingControl Setting control that has been interacted with
149 virtual void OnClick(const BaseSettingControlPtr& pSettingControl);
151 void UpdateSettingControl(const std::string& settingId, bool updateDisplayOnly = false);
152 void UpdateSettingControl(const BaseSettingControlPtr& pSettingControl,
153 bool updateDisplayOnly = false);
154 void SetControlLabel(int controlId, const CVariant& label);
156 BaseSettingControlPtr GetSettingControl(const std::string& setting);
157 BaseSettingControlPtr GetSettingControl(int controlId);
159 CGUIControl* AddSeparator(float width, int& iControlID);
160 CGUIControl* AddGroupLabel(const std::shared_ptr<CSettingGroup>& group,
161 float width,
162 int& iControlID);
164 std::vector<std::shared_ptr<CSettingCategory>> m_categories;
165 std::vector<BaseSettingControlPtr> m_settingControls;
167 int m_iSetting = 0;
168 int m_iCategory = 0;
169 std::shared_ptr<CSettingAction> m_resetSetting;
170 std::shared_ptr<CSettingCategory> m_dummyCategory;
172 CGUISpinControlEx* m_pOriginalSpin;
173 CGUISettingsSliderControl* m_pOriginalSlider;
174 CGUIRadioButtonControl* m_pOriginalRadioButton;
175 CGUIColorButtonControl* m_pOriginalColorButton = nullptr;
176 CGUIButtonControl* m_pOriginalCategoryButton;
177 CGUIButtonControl* m_pOriginalButton;
178 CGUIEditControl* m_pOriginalEdit;
179 CGUIImage* m_pOriginalImage;
180 CGUILabelControl* m_pOriginalGroupTitle;
181 bool m_newOriginalEdit = false;
183 BaseSettingControlPtr
184 m_delayedSetting; ///< Current delayed setting \sa CBaseSettingControl::SetDelayed()
185 CTimer m_delayedTimer; ///< Delayed setting timer
187 bool m_confirmed = false;
188 int m_focusedControl = 0, m_fadedControl = 0;