diff options
| author | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
| commit | be933ef2241d79558f91796cc5b3a161f72ebf9c (patch) | |
| tree | fe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h | |
| parent | 5f8335c1e49ce108ef3481863833c98efa00411b (diff) | |
| download | kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2 kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip | |
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h')
| -rw-r--r-- | xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h | 326 |
1 files changed, 326 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h new file mode 100644 index 0000000..077def8 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Slider.h | |||
| @@ -0,0 +1,326 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2005-2018 Team Kodi | ||
| 3 | * This file is part of Kodi - https://kodi.tv | ||
| 4 | * | ||
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later | ||
| 6 | * See LICENSES/README.md for more information. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #pragma once | ||
| 10 | |||
| 11 | #include "../../c-api/gui/controls/slider.h" | ||
| 12 | #include "../Window.h" | ||
| 13 | |||
| 14 | #ifdef __cplusplus | ||
| 15 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace controls | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_windows_controls_CSlider Control Slider | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CSlider } | ||
| 27 | /// **Window control for moveable slider**\n | ||
| 28 | /// The slider control is used for things where a sliding bar best represents | ||
| 29 | /// the operation at hand (such as a volume control or seek control). | ||
| 30 | /// | ||
| 31 | /// You can choose the position, size, and look of the slider control. | ||
| 32 | /// | ||
| 33 | /// It has the header @ref Slider.h "#include <kodi/gui/controls/Slider.h>" | ||
| 34 | /// be included to enjoy it. | ||
| 35 | /// | ||
| 36 | /// Here you find the needed skin part for a @ref Slider_Control "slider control". | ||
| 37 | /// | ||
| 38 | /// @note The call of the control is only possible from the corresponding | ||
| 39 | /// window as its class and identification number is required. | ||
| 40 | /// | ||
| 41 | class ATTRIBUTE_HIDDEN CSlider : public CAddonGUIControlBase | ||
| 42 | { | ||
| 43 | public: | ||
| 44 | //============================================================================ | ||
| 45 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 46 | /// @brief Construct a new control. | ||
| 47 | /// | ||
| 48 | /// @param[in] window Related window control class | ||
| 49 | /// @param[in] controlId Used skin xml control id | ||
| 50 | /// | ||
| 51 | CSlider(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 52 | { | ||
| 53 | m_controlHandle = m_interface->kodi_gui->window->get_control_slider( | ||
| 54 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 55 | if (!m_controlHandle) | ||
| 56 | kodi::Log(ADDON_LOG_FATAL, | ||
| 57 | "kodi::gui::controls::CSlider can't create control class from Kodi !!!"); | ||
| 58 | } | ||
| 59 | //---------------------------------------------------------------------------- | ||
| 60 | |||
| 61 | //============================================================================ | ||
| 62 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 63 | /// @brief Destructor. | ||
| 64 | /// | ||
| 65 | ~CSlider() override = default; | ||
| 66 | //---------------------------------------------------------------------------- | ||
| 67 | |||
| 68 | //============================================================================ | ||
| 69 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 70 | /// @brief Set the control on window to visible. | ||
| 71 | /// | ||
| 72 | /// @param[in] visible If true visible, otherwise hidden | ||
| 73 | /// | ||
| 74 | void SetVisible(bool visible) | ||
| 75 | { | ||
| 76 | m_interface->kodi_gui->control_slider->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 77 | visible); | ||
| 78 | } | ||
| 79 | //---------------------------------------------------------------------------- | ||
| 80 | |||
| 81 | //============================================================================ | ||
| 82 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 83 | /// @brief Set's the control's enabled/disabled state. | ||
| 84 | /// | ||
| 85 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 86 | /// | ||
| 87 | void SetEnabled(bool enabled) | ||
| 88 | { | ||
| 89 | m_interface->kodi_gui->control_slider->set_enabled(m_interface->kodiBase, m_controlHandle, | ||
| 90 | enabled); | ||
| 91 | } | ||
| 92 | //---------------------------------------------------------------------------- | ||
| 93 | |||
| 94 | //============================================================================ | ||
| 95 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 96 | /// @brief To reset slider on defaults. | ||
| 97 | /// | ||
| 98 | void Reset() | ||
| 99 | { | ||
| 100 | m_interface->kodi_gui->control_slider->reset(m_interface->kodiBase, m_controlHandle); | ||
| 101 | } | ||
| 102 | //---------------------------------------------------------------------------- | ||
| 103 | |||
| 104 | //============================================================================ | ||
| 105 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 106 | /// @brief With GetDescription becomes a string value of position returned. | ||
| 107 | /// | ||
| 108 | /// @return Text string about current slider position | ||
| 109 | /// | ||
| 110 | /// The following are the text definition returned from this: | ||
| 111 | /// | Value | Without range selection | With range selection | | ||
| 112 | /// |:---------:|:------------------------|:-------------------------------| | ||
| 113 | /// | float | <c>%2.2f</c> | <c>[%2.2f, %2.2f]</c> | | ||
| 114 | /// | integer | <c>%i</c> | <c>[%i, %i]</c> | | ||
| 115 | /// | percent | <c>%i%%</c> | <c>[%i%%, %i%%]</c> | | ||
| 116 | /// | ||
| 117 | std::string GetDescription() const | ||
| 118 | { | ||
| 119 | std::string text; | ||
| 120 | char* ret = m_interface->kodi_gui->control_slider->get_description(m_interface->kodiBase, | ||
| 121 | m_controlHandle); | ||
| 122 | if (ret != nullptr) | ||
| 123 | { | ||
| 124 | if (std::strlen(ret)) | ||
| 125 | text = ret; | ||
| 126 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 127 | } | ||
| 128 | return text; | ||
| 129 | } | ||
| 130 | //---------------------------------------------------------------------------- | ||
| 131 | |||
| 132 | //============================================================================ | ||
| 133 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 134 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider | ||
| 135 | /// start and e.g. +10 is the from here defined position where it reach the | ||
| 136 | /// end. | ||
| 137 | /// | ||
| 138 | /// Ad default is the range from 0 to 100. | ||
| 139 | /// | ||
| 140 | /// The integer interval is as default 1 and can be changed with | ||
| 141 | /// @ref SetIntInterval. | ||
| 142 | /// | ||
| 143 | /// @param[in] start Integer start value | ||
| 144 | /// @param[in] end Integer end value | ||
| 145 | /// | ||
| 146 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 147 | /// these different values can be not together and can, therefore, only one | ||
| 148 | /// each can be used. | ||
| 149 | /// | ||
| 150 | void SetIntRange(int start, int end) | ||
| 151 | { | ||
| 152 | m_interface->kodi_gui->control_slider->set_int_range(m_interface->kodiBase, m_controlHandle, | ||
| 153 | start, end); | ||
| 154 | } | ||
| 155 | //---------------------------------------------------------------------------- | ||
| 156 | |||
| 157 | //============================================================================ | ||
| 158 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 159 | /// @brief Set the slider position with the given integer value. The Range | ||
| 160 | /// must be defined with a call from @ref SetIntRange before. | ||
| 161 | /// | ||
| 162 | /// @param[in] value Position in range to set with integer | ||
| 163 | /// | ||
| 164 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 165 | /// these different values can be not together and can, therefore, only one | ||
| 166 | /// each can be used. | ||
| 167 | /// | ||
| 168 | void SetIntValue(int value) | ||
| 169 | { | ||
| 170 | m_interface->kodi_gui->control_slider->set_int_value(m_interface->kodiBase, m_controlHandle, | ||
| 171 | value); | ||
| 172 | } | ||
| 173 | //---------------------------------------------------------------------------- | ||
| 174 | |||
| 175 | //============================================================================ | ||
| 176 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 177 | /// @brief To get the current position as integer value. | ||
| 178 | /// | ||
| 179 | /// @return The position as integer | ||
| 180 | /// | ||
| 181 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 182 | /// these different values can be not together and can, therefore, only | ||
| 183 | /// one each can be used. | ||
| 184 | /// | ||
| 185 | int GetIntValue() const | ||
| 186 | { | ||
| 187 | return m_interface->kodi_gui->control_slider->get_int_value(m_interface->kodiBase, | ||
| 188 | m_controlHandle); | ||
| 189 | } | ||
| 190 | //---------------------------------------------------------------------------- | ||
| 191 | |||
| 192 | //============================================================================ | ||
| 193 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 194 | /// @brief To set the interval steps of slider, as default is it 1. If it | ||
| 195 | /// becomes changed with this function will a step of the user with the | ||
| 196 | /// value fixed here be executed. | ||
| 197 | /// | ||
| 198 | /// @param[in] interval Intervall step to set. | ||
| 199 | /// | ||
| 200 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 201 | /// these different values can be not together and can, therefore, only one | ||
| 202 | /// each can be used. | ||
| 203 | /// | ||
| 204 | void SetIntInterval(int interval) | ||
| 205 | { | ||
| 206 | m_interface->kodi_gui->control_slider->set_int_interval(m_interface->kodiBase, m_controlHandle, | ||
| 207 | interval); | ||
| 208 | } | ||
| 209 | //---------------------------------------------------------------------------- | ||
| 210 | |||
| 211 | //============================================================================ | ||
| 212 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 213 | /// @brief Sets the percent of the slider. | ||
| 214 | /// | ||
| 215 | /// @param[in] percent float - Percent value of slide | ||
| 216 | /// | ||
| 217 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 218 | /// these different values can be not together and can, therefore, only one | ||
| 219 | /// each can be used. | ||
| 220 | /// | ||
| 221 | void SetPercentage(float percent) | ||
| 222 | { | ||
| 223 | m_interface->kodi_gui->control_slider->set_percentage(m_interface->kodiBase, m_controlHandle, | ||
| 224 | percent); | ||
| 225 | } | ||
| 226 | //---------------------------------------------------------------------------- | ||
| 227 | |||
| 228 | //============================================================================ | ||
| 229 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 230 | /// @brief Returns a float of the percent of the slider. | ||
| 231 | /// | ||
| 232 | /// @return float - Percent of slider | ||
| 233 | /// | ||
| 234 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 235 | /// these different values can be not together and can, therefore, only one | ||
| 236 | /// each can be used. | ||
| 237 | /// | ||
| 238 | float GetPercentage() const | ||
| 239 | { | ||
| 240 | return m_interface->kodi_gui->control_slider->get_percentage(m_interface->kodiBase, | ||
| 241 | m_controlHandle); | ||
| 242 | } | ||
| 243 | //---------------------------------------------------------------------------- | ||
| 244 | |||
| 245 | //============================================================================ | ||
| 246 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 247 | /// @brief To set the the range as float of slider, e.g. -25.0 is the slider | ||
| 248 | /// start and e.g. +25.0 is the from here defined position where it reach | ||
| 249 | /// the end. | ||
| 250 | /// | ||
| 251 | /// As default is the range 0.0 to 1.0. | ||
| 252 | /// | ||
| 253 | /// The float interval is as default 0.1 and can be changed with | ||
| 254 | /// @ref SetFloatInterval. | ||
| 255 | /// | ||
| 256 | /// @param[in] start Integer start value | ||
| 257 | /// @param[in] end Integer end value | ||
| 258 | /// | ||
| 259 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 260 | /// these different values can be not together and can, therefore, only | ||
| 261 | /// one each can be used. | ||
| 262 | /// | ||
| 263 | void SetFloatRange(float start, float end) | ||
| 264 | { | ||
| 265 | m_interface->kodi_gui->control_slider->set_float_range(m_interface->kodiBase, m_controlHandle, | ||
| 266 | start, end); | ||
| 267 | } | ||
| 268 | //---------------------------------------------------------------------------- | ||
| 269 | |||
| 270 | //============================================================================ | ||
| 271 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 272 | /// @brief Set the slider position with the given float value. The Range | ||
| 273 | /// can be defined with a call from @ref SetIntRange before, as default it | ||
| 274 | /// is 0.0 to 1.0. | ||
| 275 | /// | ||
| 276 | /// @param[in] value Position in range to set with float | ||
| 277 | /// | ||
| 278 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 279 | /// these different values can be not together and can, therefore, only one | ||
| 280 | /// each can be used. | ||
| 281 | /// | ||
| 282 | void SetFloatValue(float value) | ||
| 283 | { | ||
| 284 | m_interface->kodi_gui->control_slider->set_float_value(m_interface->kodiBase, m_controlHandle, | ||
| 285 | value); | ||
| 286 | } | ||
| 287 | //---------------------------------------------------------------------------- | ||
| 288 | |||
| 289 | //============================================================================ | ||
| 290 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 291 | /// @brief To get the current position as float value. | ||
| 292 | /// | ||
| 293 | /// @return The position as float | ||
| 294 | /// | ||
| 295 | float GetFloatValue() const | ||
| 296 | { | ||
| 297 | return m_interface->kodi_gui->control_slider->get_float_value(m_interface->kodiBase, | ||
| 298 | m_controlHandle); | ||
| 299 | } | ||
| 300 | //---------------------------------------------------------------------------- | ||
| 301 | |||
| 302 | //============================================================================ | ||
| 303 | /// @ingroup cpp_kodi_gui_windows_controls_CSlider | ||
| 304 | /// @brief To set the interval steps of slider, as default is it 0.1 If it | ||
| 305 | /// becomes changed with this function will a step of the user with the | ||
| 306 | /// value fixed here be executed. | ||
| 307 | /// | ||
| 308 | /// @param[in] interval Intervall step to set. | ||
| 309 | /// | ||
| 310 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 311 | /// these different values can be not together and can, therefore, only | ||
| 312 | /// one each can be used. | ||
| 313 | /// | ||
| 314 | void SetFloatInterval(float interval) | ||
| 315 | { | ||
| 316 | m_interface->kodi_gui->control_slider->set_float_interval(m_interface->kodiBase, | ||
| 317 | m_controlHandle, interval); | ||
| 318 | } | ||
| 319 | //---------------------------------------------------------------------------- | ||
| 320 | }; | ||
| 321 | |||
| 322 | } /* namespace controls */ | ||
| 323 | } /* namespace gui */ | ||
| 324 | } /* namespace kodi */ | ||
| 325 | |||
| 326 | #endif /* __cplusplus */ | ||
