diff options
| author | manuel <manuel@mausz.at> | 2017-07-23 16:59:43 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2017-07-23 16:59:43 +0200 |
| commit | 4c3251ec645c8b71820dab7e51e612e5919d4e75 (patch) | |
| tree | 9533268a93e58fc2e16de1b8ee3fafe3784e5225 /xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h | |
| parent | f44ecaa4f27e7538ddcad66d40e543bffa2d2d86 (diff) | |
| download | kodi-pvr-build-4c3251ec645c8b71820dab7e51e612e5919d4e75.tar.gz kodi-pvr-build-4c3251ec645c8b71820dab7e51e612e5919d4e75.tar.bz2 kodi-pvr-build-4c3251ec645c8b71820dab7e51e612e5919d4e75.zip | |
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h')
| -rw-r--r-- | xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h | 376 |
1 files changed, 376 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h new file mode 100644 index 0000000..b39cd06 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Spin.h | |||
| @@ -0,0 +1,376 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2005-2017 Team KODI | ||
| 4 | * http://kodi.tv | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with KODI; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "../../AddonBase.h" | ||
| 23 | #include "../Window.h" | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | namespace controls | ||
| 30 | { | ||
| 31 | |||
| 32 | //============================================================================ | ||
| 33 | /// | ||
| 34 | /// \defgroup cpp_kodi_gui_controls_CSpin Control Spin | ||
| 35 | /// \ingroup cpp_kodi_gui | ||
| 36 | /// @brief \cpp_class{ kodi::gui::controls::CSpin } | ||
| 37 | /// **Window control used for cycling up/down controls** | ||
| 38 | /// | ||
| 39 | /// The settings spin control is used in the settings screens for when a list | ||
| 40 | /// of options can be chosen from using up/down arrows. You can choose the | ||
| 41 | /// position, size, and look of the spin control. It is basically a cross | ||
| 42 | /// between the button control and a spin control. It has a label and focus | ||
| 43 | /// and non focus textures, as well as a spin control on the right. | ||
| 44 | /// | ||
| 45 | /// It has the header \ref Spin.h "#include <kodi/gui/controls/Spin.h>" | ||
| 46 | /// be included to enjoy it. | ||
| 47 | /// | ||
| 48 | /// Here you find the needed skin part for a \ref Spin_Control "spin control" | ||
| 49 | /// | ||
| 50 | /// @note The call of the control is only possible from the corresponding | ||
| 51 | /// window as its class and identification number is required. | ||
| 52 | /// | ||
| 53 | |||
| 54 | |||
| 55 | //============================================================================ | ||
| 56 | /// | ||
| 57 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 58 | /// @anchor AddonGUISpinControlType | ||
| 59 | /// @brief The values here defines the used value format for steps on | ||
| 60 | /// spin control. | ||
| 61 | /// | ||
| 62 | typedef enum AddonGUISpinControlType | ||
| 63 | { | ||
| 64 | /// One spin step interpreted as integer | ||
| 65 | ADDON_SPIN_CONTROL_TYPE_INT = 1, | ||
| 66 | /// One spin step interpreted as floating point value | ||
| 67 | ADDON_SPIN_CONTROL_TYPE_FLOAT = 2, | ||
| 68 | /// One spin step interpreted as text string | ||
| 69 | ADDON_SPIN_CONTROL_TYPE_TEXT = 3, | ||
| 70 | /// One spin step interpreted as a page change value | ||
| 71 | ADDON_SPIN_CONTROL_TYPE_PAGE = 4 | ||
| 72 | } AddonGUISpinControlType; | ||
| 73 | //---------------------------------------------------------------------------- | ||
| 74 | |||
| 75 | class CSpin : public CAddonGUIControlBase | ||
| 76 | { | ||
| 77 | public: | ||
| 78 | //========================================================================== | ||
| 79 | /// | ||
| 80 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 81 | /// @brief Construct a new control | ||
| 82 | /// | ||
| 83 | /// @param[in] window related window control class | ||
| 84 | /// @param[in] controlId Used skin xml control id | ||
| 85 | /// | ||
| 86 | CSpin(CWindow* window, int controlId) | ||
| 87 | : CAddonGUIControlBase(window) | ||
| 88 | { | ||
| 89 | m_controlHandle = m_interface->kodi_gui->window->get_control_spin(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 90 | if (!m_controlHandle) | ||
| 91 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CSpin can't create control class from Kodi !!!"); | ||
| 92 | } | ||
| 93 | //-------------------------------------------------------------------------- | ||
| 94 | |||
| 95 | //========================================================================== | ||
| 96 | /// | ||
| 97 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 98 | /// @brief Destructor | ||
| 99 | /// | ||
| 100 | ~CSpin() override = default; | ||
| 101 | //-------------------------------------------------------------------------- | ||
| 102 | |||
| 103 | //========================================================================== | ||
| 104 | /// | ||
| 105 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 106 | /// @brief Set the control on window to visible | ||
| 107 | /// | ||
| 108 | /// @param[in] visible If true visible, otherwise hidden | ||
| 109 | /// | ||
| 110 | void SetVisible(bool visible) | ||
| 111 | { | ||
| 112 | m_interface->kodi_gui->control_spin->set_visible(m_interface->kodiBase, m_controlHandle, visible); | ||
| 113 | } | ||
| 114 | //-------------------------------------------------------------------------- | ||
| 115 | |||
| 116 | //========================================================================== | ||
| 117 | /// | ||
| 118 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 119 | /// @brief Set's the control's enabled/disabled state | ||
| 120 | /// | ||
| 121 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 122 | /// | ||
| 123 | void SetEnabled(bool enabled) | ||
| 124 | { | ||
| 125 | m_interface->kodi_gui->control_spin->set_enabled(m_interface->kodiBase, m_controlHandle, enabled); | ||
| 126 | } | ||
| 127 | //-------------------------------------------------------------------------- | ||
| 128 | |||
| 129 | //========================================================================== | ||
| 130 | /// | ||
| 131 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 132 | /// @brief To set the text string on spin control | ||
| 133 | /// | ||
| 134 | /// @param[in] text Text to show as name for spin | ||
| 135 | /// | ||
| 136 | void SetText(const std::string& text) | ||
| 137 | { | ||
| 138 | m_interface->kodi_gui->control_spin->set_text(m_interface->kodiBase, m_controlHandle, text.c_str()); | ||
| 139 | } | ||
| 140 | //-------------------------------------------------------------------------- | ||
| 141 | |||
| 142 | //========================================================================== | ||
| 143 | /// | ||
| 144 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 145 | /// @brief To reset spin control to defaults | ||
| 146 | /// | ||
| 147 | void Reset() | ||
| 148 | { | ||
| 149 | m_interface->kodi_gui->control_spin->reset(m_interface->kodiBase, m_controlHandle); | ||
| 150 | } | ||
| 151 | //-------------------------------------------------------------------------- | ||
| 152 | |||
| 153 | //========================================================================== | ||
| 154 | /// | ||
| 155 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 156 | /// @brief To set the with SpinControlType defined types of spin. | ||
| 157 | /// | ||
| 158 | /// @param[in] type The type to use | ||
| 159 | /// | ||
| 160 | /// @note See description of \ref AddonGUISpinControlType for available types. | ||
| 161 | /// | ||
| 162 | void SetType(AddonGUISpinControlType type) | ||
| 163 | { | ||
| 164 | m_interface->kodi_gui->control_spin->set_type(m_interface->kodiBase, m_controlHandle, (int)type); | ||
| 165 | } | ||
| 166 | //-------------------------------------------------------------------------- | ||
| 167 | |||
| 168 | //========================================================================== | ||
| 169 | /// | ||
| 170 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 171 | /// @brief To add a label entry in spin defined with a value as string. | ||
| 172 | /// | ||
| 173 | /// Format must be set to ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 174 | /// | ||
| 175 | /// @param[in] label Label string to view on skin | ||
| 176 | /// @param[in] value String value to use for selection | ||
| 177 | /// of them. | ||
| 178 | /// | ||
| 179 | void AddLabel(const std::string& label, const std::string& value) | ||
| 180 | { | ||
| 181 | m_interface->kodi_gui->control_spin->add_string_label(m_interface->kodiBase, m_controlHandle, label.c_str(), value.c_str()); | ||
| 182 | } | ||
| 183 | //-------------------------------------------------------------------------- | ||
| 184 | |||
| 185 | //========================================================================== | ||
| 186 | /// | ||
| 187 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 188 | /// @brief To add a label entry in spin defined with a value as integer. | ||
| 189 | /// | ||
| 190 | /// Format must be set to ADDON_SPIN_CONTROL_TYPE_INT to use this function. | ||
| 191 | /// | ||
| 192 | /// @param[in] label Label string to view on skin | ||
| 193 | /// @param[in] value Integer value to use for selection | ||
| 194 | /// of them. | ||
| 195 | /// | ||
| 196 | void AddLabel(const std::string& label, int value) | ||
| 197 | { | ||
| 198 | m_interface->kodi_gui->control_spin->add_int_label(m_interface->kodiBase, m_controlHandle, label.c_str(), value); | ||
| 199 | } | ||
| 200 | //-------------------------------------------------------------------------- | ||
| 201 | |||
| 202 | //========================================================================== | ||
| 203 | /// | ||
| 204 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 205 | /// @brief To change the spin to position with them string as value. | ||
| 206 | /// | ||
| 207 | /// Format must be set to ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 208 | /// | ||
| 209 | /// @param[in] value String value to change to | ||
| 210 | /// | ||
| 211 | void SetStringValue(const std::string& value) | ||
| 212 | { | ||
| 213 | m_interface->kodi_gui->control_spin->set_string_value(m_interface->kodiBase, m_controlHandle, value.c_str()); | ||
| 214 | } | ||
| 215 | //-------------------------------------------------------------------------- | ||
| 216 | |||
| 217 | //========================================================================== | ||
| 218 | /// | ||
| 219 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 220 | /// @brief To get the current spin control position with text string value. | ||
| 221 | /// | ||
| 222 | /// Format must be set to ADDON_SPIN_CONTROL_TYPE_TEXT to use this function. | ||
| 223 | /// | ||
| 224 | /// @return Currently selected string value | ||
| 225 | /// | ||
| 226 | std::string GetStringValue() const | ||
| 227 | { | ||
| 228 | std::string value; | ||
| 229 | char* ret = m_interface->kodi_gui->control_spin->get_string_value(m_interface->kodiBase, m_controlHandle); | ||
| 230 | if (ret != nullptr) | ||
| 231 | { | ||
| 232 | if (std::strlen(ret)) | ||
| 233 | value = ret; | ||
| 234 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 235 | } | ||
| 236 | return value; | ||
| 237 | } | ||
| 238 | //-------------------------------------------------------------------------- | ||
| 239 | |||
| 240 | //========================================================================== | ||
| 241 | /// | ||
| 242 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 243 | /// @brief To set the the range as integer of slider, e.g. -10 is the slider | ||
| 244 | /// start and e.g. +10 is the from here defined position where it reach the | ||
| 245 | /// end. | ||
| 246 | /// | ||
| 247 | /// Ad default is the range from 0 to 100. | ||
| 248 | /// | ||
| 249 | /// @param[in] start Integer start value | ||
| 250 | /// @param[in] end Integer end value | ||
| 251 | /// | ||
| 252 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 253 | /// these different values can be not together and can, therefore, only | ||
| 254 | /// one each can be used and must be defined with \ref SetType before. | ||
| 255 | /// | ||
| 256 | void SetIntRange(int start, int end) | ||
| 257 | { | ||
| 258 | m_interface->kodi_gui->control_spin->set_int_range(m_interface->kodiBase, m_controlHandle, start, end); | ||
| 259 | } | ||
| 260 | //-------------------------------------------------------------------------- | ||
| 261 | |||
| 262 | //========================================================================== | ||
| 263 | /// | ||
| 264 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 265 | /// @brief Set the slider position with the given integer value. The Range | ||
| 266 | /// must be defined with a call from \ref SetIntRange before. | ||
| 267 | /// | ||
| 268 | /// @param[in] value Position in range to set with integer | ||
| 269 | /// | ||
| 270 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 271 | /// these different values can be not together and can, therefore, only | ||
| 272 | /// one each can be used and must be defined with \ref SetType before. | ||
| 273 | /// | ||
| 274 | void SetIntValue(int value) | ||
| 275 | { | ||
| 276 | m_interface->kodi_gui->control_spin->set_int_value(m_interface->kodiBase, m_controlHandle, value); | ||
| 277 | } | ||
| 278 | //-------------------------------------------------------------------------- | ||
| 279 | |||
| 280 | //========================================================================== | ||
| 281 | /// | ||
| 282 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 283 | /// @brief To get the current position as integer value. | ||
| 284 | /// | ||
| 285 | /// @return The position as integer | ||
| 286 | /// | ||
| 287 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 288 | /// these different values can be not together and can, therefore, only | ||
| 289 | /// one each can be used and must be defined with \ref SetType before. | ||
| 290 | /// | ||
| 291 | int GetIntValue() const | ||
| 292 | { | ||
| 293 | return m_interface->kodi_gui->control_spin->get_int_value(m_interface->kodiBase, m_controlHandle); | ||
| 294 | } | ||
| 295 | //-------------------------------------------------------------------------- | ||
| 296 | |||
| 297 | //========================================================================== | ||
| 298 | /// | ||
| 299 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 300 | /// @brief To set the the range as float of spin, e.g. -25.0 is the spin | ||
| 301 | /// start and e.g. +25.0 is the from here defined position where it reach | ||
| 302 | /// the end. | ||
| 303 | /// | ||
| 304 | /// As default is the range 0.0 to 1.0. | ||
| 305 | /// | ||
| 306 | /// The float interval is as default 0.1 and can be changed with | ||
| 307 | /// @ref SetFloatInterval. | ||
| 308 | /// | ||
| 309 | /// @param[in] start Integer start value | ||
| 310 | /// @param[in] end Integer end value | ||
| 311 | /// | ||
| 312 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 313 | /// these different values can be not together and can, therefore, only | ||
| 314 | /// one each can be used and must be defined with \ref SetType before. | ||
| 315 | /// | ||
| 316 | void SetFloatRange(float start, float end) | ||
| 317 | { | ||
| 318 | m_interface->kodi_gui->control_spin->set_float_range(m_interface->kodiBase, m_controlHandle, start, end); | ||
| 319 | } | ||
| 320 | //-------------------------------------------------------------------------- | ||
| 321 | |||
| 322 | //========================================================================== | ||
| 323 | /// | ||
| 324 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 325 | /// @brief Set the spin position with the given float value. The Range | ||
| 326 | /// can be defined with a call from \ref SetIntRange before, as default it | ||
| 327 | /// is 0.0 to 1.0. | ||
| 328 | /// | ||
| 329 | /// @param[in] value Position in range to set with float | ||
| 330 | /// | ||
| 331 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 332 | /// these different values can be not together and can, therefore, only | ||
| 333 | /// one each can be used and must be defined with \ref SetType before. | ||
| 334 | /// | ||
| 335 | void SetFloatValue(float value) | ||
| 336 | { | ||
| 337 | m_interface->kodi_gui->control_spin->set_float_value(m_interface->kodiBase, m_controlHandle, value); | ||
| 338 | } | ||
| 339 | //-------------------------------------------------------------------------- | ||
| 340 | |||
| 341 | //========================================================================== | ||
| 342 | /// | ||
| 343 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 344 | /// @brief To get the current position as float value. | ||
| 345 | /// | ||
| 346 | /// @return The position as float | ||
| 347 | /// | ||
| 348 | float GetFloatValue() const | ||
| 349 | { | ||
| 350 | return m_interface->kodi_gui->control_spin->get_float_value(m_interface->kodiBase, m_controlHandle); | ||
| 351 | } | ||
| 352 | //-------------------------------------------------------------------------- | ||
| 353 | |||
| 354 | //========================================================================== | ||
| 355 | /// | ||
| 356 | /// \ingroup cpp_kodi_gui_controls_CSpin | ||
| 357 | /// @brief To set the interval steps of spin, as default is it 0.1 If it | ||
| 358 | /// becomes changed with this function will a step of the user with the | ||
| 359 | /// value fixed here be executed. | ||
| 360 | /// | ||
| 361 | /// @param[in] interval Intervall step to set. | ||
| 362 | /// | ||
| 363 | /// @note Percent, floating point or integer are alone possible. Combining | ||
| 364 | /// these different values can be not together and can, therefore, only | ||
| 365 | /// one each can be used and must be defined with \ref SetType before. | ||
| 366 | /// | ||
| 367 | void SetFloatInterval(float interval) | ||
| 368 | { | ||
| 369 | m_interface->kodi_gui->control_spin->set_float_interval(m_interface->kodiBase, m_controlHandle, interval); | ||
| 370 | } | ||
| 371 | //-------------------------------------------------------------------------- | ||
| 372 | }; | ||
| 373 | |||
| 374 | } /* namespace controls */ | ||
| 375 | } /* namespace gui */ | ||
| 376 | } /* namespace kodi */ | ||
