[Windows] Fix driver version detection of AMD RDNA+ GPU on Windows 10
[xbmc.git] / xbmc / settings / windows / GUIControlSettings.h
blob36f863671bdb6114c34862b4cf93429379f227fb
1 /*
2 * Copyright (C) 2005-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/ISliderCallback.h"
12 #include "utils/ILocalizer.h"
14 #include <functional>
15 #include <memory>
16 #include <stdlib.h>
17 #include <string>
19 class CGUIControl;
20 class CGUIImage;
21 class CGUISpinControlEx;
22 class CGUIEditControl;
23 class CGUIButtonControl;
24 class CGUIRadioButtonControl;
25 class CGUISettingsSliderControl;
26 class CGUILabelControl;
27 class CGUIColorButtonControl;
29 class CSetting;
30 class CSettingControlSlider;
31 class CSettingString;
32 class CSettingPath;
34 class CFileItemList;
35 class CVariant;
37 class CGUIControlBaseSetting : protected ILocalizer
39 public:
40 CGUIControlBaseSetting(int id, std::shared_ptr<CSetting> pSetting, ILocalizer* localizer);
41 ~CGUIControlBaseSetting() override = default;
43 int GetID() const { return m_id; }
44 std::shared_ptr<CSetting> GetSetting() { return m_pSetting; }
46 /*!
47 \brief Specifies that this setting should update after a delay
48 Useful for settings that have options to navigate through
49 and may take a while, or require additional input to update
50 once the final setting is chosen. Settings default to updating
51 instantly.
52 \sa IsDelayed()
54 void SetDelayed() { m_delayed = true; }
56 /*!
57 \brief Returns whether this setting should have delayed update
58 \return true if the setting's update should be delayed
59 \sa SetDelayed()
61 bool IsDelayed() const { return m_delayed; }
63 /*!
64 \brief Returns whether this setting is enabled or disabled
65 This state is independent of the real enabled state of a
66 setting control but represents the enabled state of the
67 setting itself based on specific conditions.
68 \return true if the setting is enabled otherwise false
69 \sa SetEnabled()
71 bool IsEnabled() const;
73 /*!
74 \brief Returns whether the setting's value is valid or not
76 bool IsValid() const { return m_valid; }
78 void SetValid(bool valid) { m_valid = valid; }
80 virtual CGUIControl* GetControl() { return NULL; }
81 virtual bool OnClick() { return false; }
82 void UpdateFromControl();
83 void UpdateFromSetting(bool updateDisplayOnly = false);
84 virtual void Clear() = 0; ///< Clears the attached control
85 protected:
86 // implementation of ILocalizer
87 std::string Localize(std::uint32_t code) const override;
89 virtual void Update(bool fromControl, bool updateDisplayOnly);
91 int m_id;
92 std::shared_ptr<CSetting> m_pSetting;
93 ILocalizer* m_localizer;
94 bool m_delayed = false;
95 bool m_valid = true;
98 class CGUIControlRadioButtonSetting : public CGUIControlBaseSetting
100 public:
101 CGUIControlRadioButtonSetting(CGUIRadioButtonControl* pRadioButton,
102 int id,
103 std::shared_ptr<CSetting> pSetting,
104 ILocalizer* localizer);
105 ~CGUIControlRadioButtonSetting() override;
107 void Select(bool bSelect);
109 CGUIControl* GetControl() override { return reinterpret_cast<CGUIControl*>(m_pRadioButton); }
110 bool OnClick() override;
111 void Clear() override { m_pRadioButton = NULL; }
113 protected:
114 // specialization of CGUIControlBaseSetting
115 void Update(bool fromControl, bool updateDisplayOnly) override;
117 private:
118 CGUIRadioButtonControl* m_pRadioButton;
121 class CGUIControlColorButtonSetting : public CGUIControlBaseSetting
123 public:
124 CGUIControlColorButtonSetting(CGUIColorButtonControl* pColorControl,
125 int id,
126 const std::shared_ptr<CSetting>& pSetting,
127 ILocalizer* localizer);
128 ~CGUIControlColorButtonSetting() override;
130 void Select(bool bSelect);
132 CGUIControl* GetControl() override { return reinterpret_cast<CGUIControl*>(m_pColorButton); }
133 bool OnClick() override;
134 void Clear() override { m_pColorButton = nullptr; }
136 protected:
137 // specialization of CGUIControlBaseSetting
138 void Update(bool fromControl, bool updateDisplayOnly) override;
140 private:
141 CGUIColorButtonControl* m_pColorButton;
144 class CGUIControlSpinExSetting : public CGUIControlBaseSetting
146 public:
147 CGUIControlSpinExSetting(CGUISpinControlEx* pSpin,
148 int id,
149 std::shared_ptr<CSetting> pSetting,
150 ILocalizer* localizer);
151 ~CGUIControlSpinExSetting() override;
153 CGUIControl* GetControl() override { return reinterpret_cast<CGUIControl*>(m_pSpin); }
154 bool OnClick() override;
155 void Clear() override { m_pSpin = NULL; }
157 protected:
158 // specialization of CGUIControlBaseSetting
159 void Update(bool fromControl, bool updateDisplayOnly) override;
161 private:
162 void FillControl(bool updateDisplayOnly);
163 void FillIntegerSettingControl(bool updateValues);
164 void FillFloatSettingControl();
165 void FillStringSettingControl(bool updateValues);
166 CGUISpinControlEx* m_pSpin;
169 class CGUIControlListSetting : public CGUIControlBaseSetting
171 public:
172 CGUIControlListSetting(CGUIButtonControl* pButton,
173 int id,
174 std::shared_ptr<CSetting> pSetting,
175 ILocalizer* localizer);
176 ~CGUIControlListSetting() override;
178 CGUIControl* GetControl() override { return reinterpret_cast<CGUIControl*>(m_pButton); }
179 bool OnClick() override;
180 void Clear() override { m_pButton = NULL; }
182 protected:
183 // specialization of CGUIControlBaseSetting
184 void Update(bool fromControl, bool updateDisplayOnly) override;
186 private:
187 bool GetItems(const std::shared_ptr<const CSetting>& setting,
188 CFileItemList& items,
189 bool updateItems) const;
190 bool GetIntegerItems(const std::shared_ptr<const CSetting>& setting,
191 CFileItemList& items,
192 bool updateItems) const;
193 bool GetStringItems(const std::shared_ptr<const CSetting>& setting,
194 CFileItemList& items,
195 bool updateItems) const;
197 CGUIButtonControl* m_pButton;
200 class CGUIControlListColorSetting : public CGUIControlBaseSetting
202 public:
203 CGUIControlListColorSetting(CGUIButtonControl* pButton,
204 int id,
205 std::shared_ptr<CSetting> pSetting,
206 ILocalizer* localizer);
207 ~CGUIControlListColorSetting() override;
209 CGUIControl* GetControl() override { return reinterpret_cast<CGUIControl*>(m_pButton); }
210 bool OnClick() override;
211 void Clear() override { m_pButton = nullptr; }
213 protected:
214 // specialization of CGUIControlBaseSetting
215 void Update(bool fromControl, bool updateDisplayOnly) override;
217 private:
218 CGUIButtonControl* m_pButton;
221 class CGUIControlButtonSetting : public CGUIControlBaseSetting, protected ISliderCallback
223 public:
224 CGUIControlButtonSetting(CGUIButtonControl* pButton,
225 int id,
226 std::shared_ptr<CSetting> pSetting,
227 ILocalizer* localizer);
228 ~CGUIControlButtonSetting() override;
230 CGUIControl* GetControl() override { return reinterpret_cast<CGUIControl*>(m_pButton); }
231 bool OnClick() override;
232 void Clear() override { m_pButton = NULL; }
234 static bool GetPath(const std::shared_ptr<CSettingPath>& pathSetting, ILocalizer* localizer);
236 protected:
237 // specialization of CGUIControlBaseSetting
238 void Update(bool fromControl, bool updateDisplayOnly) override;
240 // implementations of ISliderCallback
241 void OnSliderChange(void* data, CGUISliderControl* slider) override;
243 private:
244 CGUIButtonControl* m_pButton;
247 class CGUIControlEditSetting : public CGUIControlBaseSetting
249 public:
250 CGUIControlEditSetting(CGUIEditControl* pButton,
251 int id,
252 const std::shared_ptr<CSetting>& pSetting,
253 ILocalizer* localizer);
254 ~CGUIControlEditSetting() override;
256 CGUIControl* GetControl() override { return reinterpret_cast<CGUIControl*>(m_pEdit); }
257 bool OnClick() override;
258 void Clear() override { m_pEdit = NULL; }
260 protected:
261 // specialization of CGUIControlBaseSetting
262 void Update(bool fromControl, bool updateDisplayOnly) override;
264 private:
265 static bool InputValidation(const std::string& input, void* data);
267 CGUIEditControl* m_pEdit;
270 class CGUIControlSliderSetting : public CGUIControlBaseSetting
272 public:
273 CGUIControlSliderSetting(CGUISettingsSliderControl* pSlider,
274 int id,
275 std::shared_ptr<CSetting> pSetting,
276 ILocalizer* localizer);
277 ~CGUIControlSliderSetting() override;
279 CGUIControl* GetControl() override { return reinterpret_cast<CGUIControl*>(m_pSlider); }
280 bool OnClick() override;
281 void Clear() override { m_pSlider = NULL; }
283 static std::string GetText(const std::shared_ptr<CSetting>& setting,
284 const CVariant& value,
285 const CVariant& minimum,
286 const CVariant& step,
287 const CVariant& maximum,
288 ILocalizer* localizer);
290 protected:
291 // specialization of CGUIControlBaseSetting
292 void Update(bool fromControl, bool updateDisplayOnly) override;
294 private:
295 static bool FormatText(const std::string& formatString,
296 const CVariant& value,
297 const std::string& settingId,
298 std::string& formattedText);
300 CGUISettingsSliderControl* m_pSlider;
303 class CGUIControlRangeSetting : public CGUIControlBaseSetting
305 public:
306 CGUIControlRangeSetting(CGUISettingsSliderControl* pSlider,
307 int id,
308 std::shared_ptr<CSetting> pSetting,
309 ILocalizer* localizer);
310 ~CGUIControlRangeSetting() override;
312 CGUIControl* GetControl() override { return reinterpret_cast<CGUIControl*>(m_pSlider); }
313 bool OnClick() override;
314 void Clear() override { m_pSlider = NULL; }
316 protected:
317 // specialization of CGUIControlBaseSetting
318 void Update(bool fromControl, bool updateDisplayOnly) override;
320 private:
321 CGUISettingsSliderControl* m_pSlider;
324 class CGUIControlSeparatorSetting : public CGUIControlBaseSetting
326 public:
327 CGUIControlSeparatorSetting(CGUIImage* pImage, int id, ILocalizer* localizer);
328 ~CGUIControlSeparatorSetting() override;
330 CGUIControl* GetControl() override { return reinterpret_cast<CGUIControl*>(m_pImage); }
331 bool OnClick() override { return false; }
332 void Clear() override { m_pImage = NULL; }
334 private:
335 CGUIImage* m_pImage;
338 class CGUIControlGroupTitleSetting : public CGUIControlBaseSetting
340 public:
341 CGUIControlGroupTitleSetting(CGUILabelControl* pLabel, int id, ILocalizer* localizer);
342 ~CGUIControlGroupTitleSetting() override;
344 CGUIControl* GetControl() override { return reinterpret_cast<CGUIControl*>(m_pLabel); }
345 bool OnClick() override { return false; }
346 void Clear() override { m_pLabel = NULL; }
348 private:
349 CGUILabelControl* m_pLabel;
352 class CGUIControlLabelSetting : public CGUIControlBaseSetting
354 public:
355 CGUIControlLabelSetting(CGUIButtonControl* pButton,
356 int id,
357 std::shared_ptr<CSetting> pSetting,
358 ILocalizer* localizer);
359 ~CGUIControlLabelSetting() override = default;
361 CGUIControl* GetControl() override { return reinterpret_cast<CGUIControl*>(m_pButton); }
362 void Clear() override { m_pButton = NULL; }
364 private:
365 CGUIButtonControl* m_pButton;