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