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/Spin.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/Spin.h')
| -rw-r--r-- | xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Spin.h | 416 |
1 files changed, 416 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Spin.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Spin.h new file mode 100644 index 0000000..6c55243 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Spin.h | |||
| @@ -0,0 +1,416 @@ | |||
| 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/spin.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_CSpin Control Spin | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CSpin } | ||
| 27 | /// **Window control used for cycling up/down controls**\n | ||
| 28 | /// The settings spin control is used in the settings screens for when a list | ||
| 29 | /// of options can be chosen from using up/down arrows. | ||
| 30 | /// | ||
| 31 | /// You can choose the position, size, and look of the spin control. It is | ||
| 32 | /// basically a cross between the button control and a spin control. It has a | ||
| 33 | /// label and focus and non focus textures, as well as a spin control on the | ||
| 34 | /// right. | ||
| 35 | /// | ||
| 36 | /// It has the header @ref Spin.h "#include <kodi/gui/controls/Spin.h>" | ||
| 37 | /// be included to enjoy it. | ||
| 38 | /// | ||
| 39 | /// Here you find the needed skin part for a @ref Spin_Control "spin control". | ||
| 40 | /// | ||
| 41 | /// @note The call of the control is only possible from the corresponding | ||
| 42 | /// window as its class and identification number is required. | ||
| 43 | /// | ||
| 44 | /// -------------------------------------------------------------------------- | ||
| 45 | /// **Example:** | ||
| 46 | /// ~~~~~~~~~~~~cpp | ||
| 47 | /// #include <kodi/gui/Window.h> | ||
| 48 | /// | ||
| 49 | /// #define MY_SPIN_CONTROL 1 | ||
| 50 | /// | ||
| 51 | /// class CMyWindow : public kodi::gui::CWindow | ||
| 52 | /// { | ||
| 53 | /// public: | ||
| 54 | /// CMyWindow() | ||
| 55 | /// | ||
| 56 | /// void ShowWindow(); | ||
| 57 | /// | ||
| 58 | /// bool OnInit() override; | ||
| 59 | /// bool OnClick(int controlId) override; | ||
| 60 | /// | ||
| 61 | /// private: | ||
| 62 | /// kodi::gui::controls::CSpin m_mySpinControl; | ||
| 63 | /// }; | ||
| 64 | /// | ||
| 65 | /// CMyWindow::CMyWindow() | ||
| 66 | /// : kodi::gui::CWindow("my_skin.xml", "skin.estuary", true, false), | ||
| 67 | /// m_mySpinControl(this, MY_SPIN_CONTROL) | ||
| 68 | /// { | ||
| 69 | /// } | ||
| 70 | /// | ||
| 71 | /// void CMyWindow::ShowWindow() | ||
| 72 | /// { | ||
| 73 | /// kodi::gui::CWindow::DoModal(); | ||
| 74 | /// } | ||
| 75 | /// | ||
| 76 | /// bool CMyWindow::OnInit() | ||
| 77 | /// { | ||
| 78 | /// m_mySpinControl.SetType(kodi::gui::controls::ADDON_SPIN_CONTROL_TYPE_INT); | ||
| 79 | /// m_mySpinControl.SetIntRange(1, 80); | ||
| 80 | /// return true; | ||
| 81 | /// } | ||
| 82 | /// | ||
| 83 | /// bool CMyWindow::OnClick(int controlId) | ||
| 84 | /// { | ||
| 85 | /// if (controlId == MY_SPIN_CONTROL) | ||
| 86 | /// { | ||
| 87 | /// int value = m_mySpinControl.GetIntValue(); | ||
| 88 | /// ... | ||
| 89 | /// } | ||
| 90 | /// return true; | ||
| 91 | /// } | ||
| 92 | /// return false; | ||
| 93 | /// } | ||
| 94 | /// ~~~~~~~~~~~~ | ||
| 95 | /// | ||
| 96 | |||
| 97 | |||
| 98 | //============================================================================== | ||
| 99 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 100 | /// @anchor AddonGUISpinControlType | ||
| 101 | /// @brief The values here defines the used value format for steps on | ||
| 102 | /// spin control. | ||
| 103 | /// | ||
| 104 | typedef enum AddonGUISpinControlType | ||
| 105 | { | ||
| 106 | /// One spin step interpreted as integer | ||
| 107 | ADDON_SPIN_CONTROL_TYPE_INT = 1, | ||
| 108 | /// One spin step interpreted as floating point value | ||
| 109 | ADDON_SPIN_CONTROL_TYPE_FLOAT = 2, | ||
| 110 | /// One spin step interpreted as text string | ||
| 111 | ADDON_SPIN_CONTROL_TYPE_TEXT = 3, | ||
| 112 | /// One spin step interpreted as a page change value | ||
| 113 | ADDON_SPIN_CONTROL_TYPE_PAGE = 4 | ||
| 114 | } AddonGUISpinControlType; | ||
| 115 | //------------------------------------------------------------------------------ | ||
| 116 | |||
| 117 | class ATTRIBUTE_HIDDEN CSpin : public CAddonGUIControlBase | ||
| 118 | { | ||
| 119 | public: | ||
| 120 | //============================================================================ | ||
| 121 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 122 | /// @brief Construct a new control. | ||
| 123 | /// | ||
| 124 | /// @param[in] window Related window control class | ||
| 125 | /// @param[in] controlId Used skin xml control id | ||
| 126 | /// | ||
| 127 | CSpin(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 128 | { | ||
| 129 | m_controlHandle = m_interface->kodi_gui->window->get_control_spin( | ||
| 130 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 131 | if (!m_controlHandle) | ||
| 132 | kodi::Log(ADDON_LOG_FATAL, | ||
| 133 | "kodi::gui::controls::CSpin can't create control class from Kodi !!!"); | ||
| 134 | } | ||
| 135 | //---------------------------------------------------------------------------- | ||
| 136 | |||
| 137 | //============================================================================ | ||
| 138 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 139 | /// @brief Destructor. | ||
| 140 | /// | ||
| 141 | ~CSpin() override = default; | ||
| 142 | //---------------------------------------------------------------------------- | ||
| 143 | |||
| 144 | //============================================================================ | ||
| 145 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 146 | /// @brief Set the control on window to visible. | ||
| 147 | /// | ||
| 148 | /// @param[in] visible If true visible, otherwise hidden | ||
| 149 | /// | ||
| 150 | void SetVisible(bool visible) | ||
| 151 | { | ||
| 152 | m_interface->kodi_gui->control_spin->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 153 | visible); | ||
| 154 | } | ||
| 155 | //---------------------------------------------------------------------------- | ||
| 156 | |||
| 157 | //============================================================================ | ||
| 158 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 159 | /// @brief Set's the control's enabled/disabled state. | ||
| 160 | /// | ||
| 161 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 162 | /// | ||
| 163 | void SetEnabled(bool enabled) | ||
| 164 | { | ||
| 165 | m_interface->kodi_gui->control_spin->set_enabled(m_interface->kodiBase, m_controlHandle, | ||
| 166 | enabled); | ||
| 167 | } | ||
| 168 | //---------------------------------------------------------------------------- | ||
| 169 | |||
| 170 | //============================================================================ | ||
| 171 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 172 | /// @brief To set the text string on spin control. | ||
| 173 | /// | ||
| 174 | /// @param[in] text Text to show as name for spin | ||
| 175 | /// | ||
| 176 | void SetText(const std::string& text) | ||
| 177 | { | ||
| 178 | m_interface->kodi_gui->control_spin->set_text(m_interface->kodiBase, m_controlHandle, | ||
| 179 | text.c_str()); | ||
| 180 | } | ||
| 181 | //---------------------------------------------------------------------------- | ||
| 182 | |||
| 183 | //============================================================================ | ||
| 184 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 185 | /// @brief To reset spin control to defaults. | ||
| 186 | /// | ||
| 187 | void Reset() | ||
| 188 | { | ||
| 189 | m_interface->kodi_gui->control_spin->reset(m_interface->kodiBase, m_controlHandle); | ||
| 190 | } | ||
| 191 | //---------------------------------------------------------------------------- | ||
| 192 | |||
| 193 | //============================================================================ | ||
| 194 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 195 | /// @brief To set the with SpinControlType defined types of spin. | ||
| 196 | /// | ||
| 197 | /// @param[in] type The type to use | ||
| 198 | /// | ||
| 199 | /// @note See description of @ref AddonGUISpinControlType for available types. | ||
| 200 | /// | ||
| 201 | void SetType(AddonGUISpinControlType type) | ||
| 202 | { | ||
| 203 | m_interface->kodi_gui->control_spin->set_type(m_interface->kodiBase, m_controlHandle, | ||
| 204 | (int)type); | ||
| 205 | } | ||
| 206 | //---------------------------------------------------------------------------- | ||
| 207 | |||
| 208 | //============================================================================ | ||
| 209 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 210 | /// @brief To add a label entry in spin defined with a value as string. | ||
| 211 | /// | ||
| 212 | /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 213 | /// | ||
| 214 | /// @param[in] label Label string to view on skin | ||
| 215 | /// @param[in] value String value to use for selection of them | ||
| 216 | /// | ||
| 217 | void AddLabel(const std::string& label, const std::string& value) | ||
| 218 | { | ||
| 219 | m_interface->kodi_gui->control_spin->add_string_label(m_interface->kodiBase, m_controlHandle, | ||
| 220 | label.c_str(), value.c_str()); | ||
| 221 | } | ||
| 222 | //---------------------------------------------------------------------------- | ||
| 223 | |||
| 224 | //============================================================================ | ||
| 225 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 226 | /// @brief To add a label entry in spin defined with a value as integer. | ||
| 227 | /// | ||
| 228 | /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_INT to use this function. | ||
| 229 | /// | ||
| 230 | /// @param[in] label Label string to view on skin | ||
| 231 | /// @param[in] value Integer value to use for selection of them. | ||
| 232 | /// | ||
| 233 | void AddLabel(const std::string& label, int value) | ||
| 234 | { | ||
| 235 | m_interface->kodi_gui->control_spin->add_int_label(m_interface->kodiBase, m_controlHandle, | ||
| 236 | label.c_str(), value); | ||
| 237 | } | ||
| 238 | //---------------------------------------------------------------------------- | ||
| 239 | |||
| 240 | //============================================================================ | ||
| 241 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 242 | /// @brief To change the spin to position with them string as value. | ||
| 243 | /// | ||
| 244 | /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 245 | /// | ||
| 246 | /// @param[in] value String value to change to | ||
| 247 | /// | ||
| 248 | void SetStringValue(const std::string& value) | ||
| 249 | { | ||
| 250 | m_interface->kodi_gui->control_spin->set_string_value(m_interface->kodiBase, m_controlHandle, | ||
| 251 | value.c_str()); | ||
| 252 | } | ||
| 253 | //---------------------------------------------------------------------------- | ||
| 254 | |||
| 255 | //============================================================================ | ||
| 256 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 257 | /// @brief To get the current spin control position with text string value. | ||
| 258 | /// | ||
| 259 | /// Format must be set to @ref ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 260 | /// | ||
| 261 | /// @return Currently selected string value | ||
| 262 | /// | ||
| 263 | std::string GetStringValue() const | ||
| 264 | { | ||
| 265 | std::string value; | ||
| 266 | char* ret = m_interface->kodi_gui->control_spin->get_string_value(m_interface->kodiBase, | ||
| 267 | m_controlHandle); | ||
| 268 | if (ret != nullptr) | ||
| 269 | { | ||
| 270 | if (std::strlen(ret)) | ||
| 271 | value = ret; | ||
| 272 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 273 | } | ||
| 274 | return value; | ||
| 275 | } | ||
| 276 | //---------------------------------------------------------------------------- | ||
| 277 | |||
| 278 | //============================================================================ | ||
| 279 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 280 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider | ||
| 281 | /// start and e.g. +10 is the from here defined position where it reach the | ||
| 282 | /// end. | ||
| 283 | /// | ||
| 284 | /// Ad default is the range from 0 to 100. | ||
| 285 | /// | ||
| 286 | /// @param[in] start Integer start value | ||
| 287 | /// @param[in] end Integer end value | ||
| 288 | /// | ||
| 289 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 290 | /// these different values can be not together and can, therefore, only | ||
| 291 | /// one each can be used and must be defined with @ref SetType before. | ||
| 292 | /// | ||
| 293 | void SetIntRange(int start, int end) | ||
| 294 | { | ||
| 295 | m_interface->kodi_gui->control_spin->set_int_range(m_interface->kodiBase, m_controlHandle, | ||
| 296 | start, end); | ||
| 297 | } | ||
| 298 | //---------------------------------------------------------------------------- | ||
| 299 | |||
| 300 | //============================================================================ | ||
| 301 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 302 | /// @brief Set the slider position with the given integer value. The Range | ||
| 303 | /// must be defined with a call from @ref SetIntRange before. | ||
| 304 | /// | ||
| 305 | /// @param[in] value Position in range to set with integer | ||
| 306 | /// | ||
| 307 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 308 | /// these different values can be not together and can, therefore, only | ||
| 309 | /// one each can be used and must be defined with @ref SetType before. | ||
| 310 | /// | ||
| 311 | void SetIntValue(int value) | ||
| 312 | { | ||
| 313 | m_interface->kodi_gui->control_spin->set_int_value(m_interface->kodiBase, m_controlHandle, | ||
| 314 | value); | ||
| 315 | } | ||
| 316 | //---------------------------------------------------------------------------- | ||
| 317 | |||
| 318 | //============================================================================ | ||
| 319 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 320 | /// @brief To get the current position as integer value. | ||
| 321 | /// | ||
| 322 | /// @return The position as integer | ||
| 323 | /// | ||
| 324 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 325 | /// these different values can be not together and can, therefore, only | ||
| 326 | /// one each can be used and must be defined with @ref SetType before. | ||
| 327 | /// | ||
| 328 | int GetIntValue() const | ||
| 329 | { | ||
| 330 | return m_interface->kodi_gui->control_spin->get_int_value(m_interface->kodiBase, | ||
| 331 | m_controlHandle); | ||
| 332 | } | ||
| 333 | //---------------------------------------------------------------------------- | ||
| 334 | |||
| 335 | //============================================================================ | ||
| 336 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 337 | /// @brief To set the the range as float of spin, e.g. -25.0 is the spin | ||
| 338 | /// start and e.g. +25.0 is the from here defined position where it reach | ||
| 339 | /// the end. | ||
| 340 | /// | ||
| 341 | /// As default is the range 0.0 to 1.0. | ||
| 342 | /// | ||
| 343 | /// The float interval is as default 0.1 and can be changed with | ||
| 344 | /// @ref SetFloatInterval. | ||
| 345 | /// | ||
| 346 | /// @param[in] start Integer start value | ||
| 347 | /// @param[in] end Integer end value | ||
| 348 | /// | ||
| 349 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 350 | /// these different values can be not together and can, therefore, only | ||
| 351 | /// one each can be used and must be defined with @ref SetType before. | ||
| 352 | /// | ||
| 353 | void SetFloatRange(float start, float end) | ||
| 354 | { | ||
| 355 | m_interface->kodi_gui->control_spin->set_float_range(m_interface->kodiBase, m_controlHandle, | ||
| 356 | start, end); | ||
| 357 | } | ||
| 358 | //---------------------------------------------------------------------------- | ||
| 359 | |||
| 360 | //============================================================================ | ||
| 361 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 362 | /// @brief Set the spin position with the given float value. The Range | ||
| 363 | /// can be defined with a call from @ref SetIntRange before, as default it | ||
| 364 | /// is 0.0 to 1.0. | ||
| 365 | /// | ||
| 366 | /// @param[in] value Position in range to set with float | ||
| 367 | /// | ||
| 368 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 369 | /// these different values can be not together and can, therefore, only | ||
| 370 | /// one each can be used and must be defined with @ref SetType before. | ||
| 371 | /// | ||
| 372 | void SetFloatValue(float value) | ||
| 373 | { | ||
| 374 | m_interface->kodi_gui->control_spin->set_float_value(m_interface->kodiBase, m_controlHandle, | ||
| 375 | value); | ||
| 376 | } | ||
| 377 | //---------------------------------------------------------------------------- | ||
| 378 | |||
| 379 | //============================================================================ | ||
| 380 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 381 | /// @brief To get the current position as float value. | ||
| 382 | /// | ||
| 383 | /// @return The position as float | ||
| 384 | /// | ||
| 385 | float GetFloatValue() const | ||
| 386 | { | ||
| 387 | return m_interface->kodi_gui->control_spin->get_float_value(m_interface->kodiBase, | ||
| 388 | m_controlHandle); | ||
| 389 | } | ||
| 390 | //---------------------------------------------------------------------------- | ||
| 391 | |||
| 392 | //============================================================================ | ||
| 393 | /// @ingroup cpp_kodi_gui_windows_controls_CSpin | ||
| 394 | /// @brief To set the interval steps of spin, as default is it 0.1 If it | ||
| 395 | /// becomes changed with this function will a step of the user with the | ||
| 396 | /// value fixed here be executed. | ||
| 397 | /// | ||
| 398 | /// @param[in] interval Intervall step to set. | ||
| 399 | /// | ||
| 400 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 401 | /// these different values can be not together and can, therefore, only | ||
| 402 | /// one each can be used and must be defined with @ref SetType before. | ||
| 403 | /// | ||
| 404 | void SetFloatInterval(float interval) | ||
| 405 | { | ||
| 406 | m_interface->kodi_gui->control_spin->set_float_interval(m_interface->kodiBase, m_controlHandle, | ||
| 407 | interval); | ||
| 408 | } | ||
| 409 | //---------------------------------------------------------------------------- | ||
| 410 | }; | ||
| 411 | |||
| 412 | } /* namespace controls */ | ||
| 413 | } /* namespace gui */ | ||
| 414 | } /* namespace kodi */ | ||
| 415 | |||
| 416 | #endif /* __cplusplus */ | ||
