Kodi Development  20.0
for Binary and Script based Add-Ons
Slider.h
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 //==============================================================================
41 class ATTRIBUTE_HIDDEN CSlider : public CAddonGUIControlBase
42 {
43 public:
44  //============================================================================
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)
57  "kodi::gui::controls::CSlider can't create control class from Kodi !!!");
58  }
59  //----------------------------------------------------------------------------
60 
61  //============================================================================
65  ~CSlider() override = default;
66  //----------------------------------------------------------------------------
67 
68  //============================================================================
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  //============================================================================
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  //============================================================================
98  void Reset()
99  {
100  m_interface->kodi_gui->control_slider->reset(m_interface->kodiBase, m_controlHandle);
101  }
102  //----------------------------------------------------------------------------
103 
104  //============================================================================
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  //============================================================================
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  //============================================================================
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  //============================================================================
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  //============================================================================
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  //============================================================================
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  //============================================================================
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  //============================================================================
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  //============================================================================
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  //============================================================================
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  //============================================================================
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 */
Definition: ListItem.h:26
Definition: Window.h:110
Definition: Slider.h:42
@ ADDON_LOG_FATAL
4 : To notify fatal unrecoverable errors, which can may also indicate upcoming crashes.
Definition: addon_base.h:187
void SetIntInterval(int interval)
To set the interval steps of slider, as default is it 1. If it becomes changed with this function wil...
Definition: Slider.h:204
std::string GetDescription() const
With GetDescription becomes a string value of position returned.
Definition: Slider.h:117
void SetPercentage(float percent)
Sets the percent of the slider.
Definition: Slider.h:221
void SetFloatInterval(float interval)
To set the interval steps of slider, as default is it 0.1 If it becomes changed with this function wi...
Definition: Slider.h:314
void SetIntRange(int start, int end)
To set the the range as integer of slider, e.g. -10 is the slider start and e.g. +10 is the from here...
Definition: Slider.h:150
void SetIntValue(int value)
Set the slider position with the given integer value. The Range must be defined with a call from SetI...
Definition: Slider.h:168
void Reset()
To reset slider on defaults.
Definition: Slider.h:98
float GetFloatValue() const
To get the current position as float value.
Definition: Slider.h:295
void SetVisible(bool visible)
Set the control on window to visible.
Definition: Slider.h:74
~CSlider() override=default
Destructor.
float GetPercentage() const
Returns a float of the percent of the slider.
Definition: Slider.h:238
CSlider(CWindow *window, int controlId)
Construct a new control.
Definition: Slider.h:51
void SetEnabled(bool enabled)
Set's the control's enabled/disabled state.
Definition: Slider.h:87
void SetFloatValue(float value)
Set the slider position with the given float value. The Range can be defined with a call from SetIntR...
Definition: Slider.h:282
int GetIntValue() const
To get the current position as integer value.
Definition: Slider.h:185
void SetFloatRange(float start, float end)
To set the the range as float of slider, e.g. -25.0 is the slider start and e.g. +25....
Definition: Slider.h:263
void ATTRIBUTE_HIDDEN Log(const AddonLog loglevel, const char *format,...)
Add a message to Kodi's log.
Definition: AddonBase.h:749