Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches

Class: kodi::gui::controls::CSpin

Window control used for cycling up/down controls
The settings spin control is used in the settings screens for when a list of options can be chosen from using up/down arrows. More...

Typedefs

typedef enum kodi::gui::controls::AddonGUISpinControlType kodi::gui::controls::AddonGUISpinControlType
 The values here defines the used value format for steps on spin control.
 

Enumerations

enum  kodi::gui::controls::AddonGUISpinControlType { kodi::gui::controls::ADDON_SPIN_CONTROL_TYPE_INT = 1 , kodi::gui::controls::ADDON_SPIN_CONTROL_TYPE_FLOAT = 2 , kodi::gui::controls::ADDON_SPIN_CONTROL_TYPE_TEXT = 3 , kodi::gui::controls::ADDON_SPIN_CONTROL_TYPE_PAGE = 4 }
 The values here defines the used value format for steps on spin control. More...
 

Functions

 kodi::gui::controls::CSpin::CSpin (CWindow *window, int controlId)
 Construct a new control.
 
 kodi::gui::controls::CSpin::~CSpin () override=default
 Destructor.
 
void kodi::gui::controls::CSpin::SetVisible (bool visible)
 Set the control on window to visible.
 
void kodi::gui::controls::CSpin::SetEnabled (bool enabled)
 Set's the control's enabled/disabled state.
 
void kodi::gui::controls::CSpin::SetText (const std::string &text)
 To set the text string on spin control.
 
void kodi::gui::controls::CSpin::Reset ()
 To reset spin control to defaults.
 
void kodi::gui::controls::CSpin::SetType (AddonGUISpinControlType type)
 To set the with SpinControlType defined types of spin.
 
void kodi::gui::controls::CSpin::AddLabel (const std::string &label, const std::string &value)
 To add a label entry in spin defined with a value as string.
 
void kodi::gui::controls::CSpin::AddLabel (const std::string &label, int value)
 To add a label entry in spin defined with a value as integer.
 
void kodi::gui::controls::CSpin::SetStringValue (const std::string &value)
 To change the spin to position with them string as value.
 
std::string kodi::gui::controls::CSpin::GetStringValue () const
 To get the current spin control position with text string value.
 
void kodi::gui::controls::CSpin::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 defined position where it reach the end.
 
void kodi::gui::controls::CSpin::SetIntValue (int value)
 Set the slider position with the given integer value. The Range must be defined with a call from SetIntRange before.
 
int kodi::gui::controls::CSpin::GetIntValue () const
 To get the current position as integer value.
 
void kodi::gui::controls::CSpin::SetFloatRange (float start, float end)
 To set the the range as float of spin, e.g. -25.0 is the spin start and e.g. +25.0 is the from here defined position where it reach the end.
 
void kodi::gui::controls::CSpin::SetFloatValue (float value)
 Set the spin position with the given float value. The Range can be defined with a call from SetIntRange before, as default it is 0.0 to 1.0.
 
float kodi::gui::controls::CSpin::GetFloatValue () const
 To get the current position as float value.
 
void kodi::gui::controls::CSpin::SetFloatInterval (float interval)
 To set the interval steps of spin, as default is it 0.1 If it becomes changed with this function will a step of the user with the value fixed here be executed.
 

Detailed Description

Class: kodi::gui::controls::CSpin

Window control used for cycling up/down controls
The settings spin control is used in the settings screens for when a list of options can be chosen from using up/down arrows.

You can choose the position, size, and look of the spin control. It is basically a cross between the button control and a spin control. It has a label and focus and non focus textures, as well as a spin control on the right.

It has the header #include <kodi/gui/controls/Spin.h> be included to enjoy it.

Here you find the needed skin part for a spin control.

Note
The call of the control is only possible from the corresponding window as its class and identification number is required.

Example:

#define MY_SPIN_CONTROL 1
class CMyWindow : public kodi::gui::CWindow
{
public:
CMyWindow()
void ShowWindow();
bool OnInit() override;
bool OnClick(int controlId) override;
private:
kodi::gui::controls::CSpin m_mySpinControl;
};
CMyWindow::CMyWindow()
: kodi::gui::CWindow("my_skin.xml", "skin.estuary", true, false),
m_mySpinControl(this, MY_SPIN_CONTROL)
{
}
void CMyWindow::ShowWindow()
{
}
bool CMyWindow::OnInit()
{
m_mySpinControl.SetIntRange(1, 80);
return true;
}
bool CMyWindow::OnClick(int controlId)
{
if (controlId == MY_SPIN_CONTROL)
{
int value = m_mySpinControl.GetIntValue();
...
}
return true;
}
return false;
}
enum const char const char * value
Definition addon_base.h:203
friend class CWindow
Definition addons/kodi-dev-kit/include/kodi/gui/ListItem.h:40
Definition addons/kodi-dev-kit/include/kodi/gui/Window.h:110
@ ADDON_SPIN_CONTROL_TYPE_INT
One spin step interpreted as integer.
Definition kodi-dev-kit/include/kodi/gui/controls/Spin.h:106
virtual bool OnClick(int controlId)
OnClick method.
Definition addons/kodi-dev-kit/include/kodi/gui/Window.h:685
virtual bool OnInit()
OnInit method.
Definition addons/kodi-dev-kit/include/kodi/gui/Window.h:661
void DoModal()
Display this window until close() is called.
Definition addons/kodi-dev-kit/include/kodi/gui/Window.h:190
typedef void(ATTR_APIENTRYP PFN_KODI_ADDON_SCREENSAVER_STOP_V1)(const KODI_ADDON_SCREENSAVER_HDL hdl)
Definition addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h:21

Typedef Documentation

◆ AddonGUISpinControlType

The values here defines the used value format for steps on spin control.

Enumeration Type Documentation

◆ AddonGUISpinControlType

The values here defines the used value format for steps on spin control.

Enumerator
ADDON_SPIN_CONTROL_TYPE_INT 

One spin step interpreted as integer.

ADDON_SPIN_CONTROL_TYPE_FLOAT 

One spin step interpreted as floating point value.

ADDON_SPIN_CONTROL_TYPE_TEXT 

One spin step interpreted as text string.

ADDON_SPIN_CONTROL_TYPE_PAGE 

One spin step interpreted as a page change value.

Function Documentation

◆ AddLabel() [1/2]

void kodi::gui::controls::CSpin::AddLabel ( const std::string & label,
const std::string & value )
inline

To add a label entry in spin defined with a value as string.

Format must be set to ADDON_SPIN_CONTROL_TYPE_TEXT to use this function.

Parameters
[in]labelLabel string to view on skin
[in]valueString value to use for selection of them

◆ AddLabel() [2/2]

void kodi::gui::controls::CSpin::AddLabel ( const std::string & label,
int value )
inline

To add a label entry in spin defined with a value as integer.

Format must be set to ADDON_SPIN_CONTROL_TYPE_INT to use this function.

Parameters
[in]labelLabel string to view on skin
[in]valueInteger value to use for selection of them.

◆ CSpin()

kodi::gui::controls::CSpin::CSpin ( CWindow * window,
int controlId )
inline

Construct a new control.

Parameters
[in]windowRelated window control class
[in]controlIdUsed skin xml control id

◆ GetFloatValue()

float kodi::gui::controls::CSpin::GetFloatValue ( ) const
inline

To get the current position as float value.

Returns
The position as float

◆ GetIntValue()

int kodi::gui::controls::CSpin::GetIntValue ( ) const
inline

To get the current position as integer value.

Returns
The position as integer
Note
Percent, floating point or integer are alone possible. Combining these different values can be not together and can, therefore, only one each can be used and must be defined with SetType before.

◆ GetStringValue()

std::string kodi::gui::controls::CSpin::GetStringValue ( ) const
inline

To get the current spin control position with text string value.

Format must be set to ADDON_SPIN_CONTROL_TYPE_TEXT to use this function.

Returns
Currently selected string value

◆ Reset()

void kodi::gui::controls::CSpin::Reset ( )
inline

To reset spin control to defaults.

◆ SetEnabled()

void kodi::gui::controls::CSpin::SetEnabled ( bool enabled)
inline

Set's the control's enabled/disabled state.

Parameters
[in]enabledIf true enabled, otherwise disabled

◆ SetFloatInterval()

void kodi::gui::controls::CSpin::SetFloatInterval ( float interval)
inline

To set the interval steps of spin, as default is it 0.1 If it becomes changed with this function will a step of the user with the value fixed here be executed.

Parameters
[in]intervalIntervall step to set.
Note
Percent, floating point or integer are alone possible. Combining these different values can be not together and can, therefore, only one each can be used and must be defined with SetType before.

◆ SetFloatRange()

void kodi::gui::controls::CSpin::SetFloatRange ( float start,
float end )
inline

To set the the range as float of spin, e.g. -25.0 is the spin start and e.g. +25.0 is the from here defined position where it reach the end.

As default is the range 0.0 to 1.0.

The float interval is as default 0.1 and can be changed with SetFloatInterval.

Parameters
[in]startInteger start value
[in]endInteger end value
Note
Percent, floating point or integer are alone possible. Combining these different values can be not together and can, therefore, only one each can be used and must be defined with SetType before.

◆ SetFloatValue()

void kodi::gui::controls::CSpin::SetFloatValue ( float value)
inline

Set the spin position with the given float value. The Range can be defined with a call from SetIntRange before, as default it is 0.0 to 1.0.

Parameters
[in]valuePosition in range to set with float
Note
Percent, floating point or integer are alone possible. Combining these different values can be not together and can, therefore, only one each can be used and must be defined with SetType before.

◆ SetIntRange()

void kodi::gui::controls::CSpin::SetIntRange ( int start,
int end )
inline

To set the the range as integer of slider, e.g. -10 is the slider start and e.g. +10 is the from here defined position where it reach the end.

Ad default is the range from 0 to 100.

Parameters
[in]startInteger start value
[in]endInteger end value
Note
Percent, floating point or integer are alone possible. Combining these different values can be not together and can, therefore, only one each can be used and must be defined with SetType before.

◆ SetIntValue()

void kodi::gui::controls::CSpin::SetIntValue ( int value)
inline

Set the slider position with the given integer value. The Range must be defined with a call from SetIntRange before.

Parameters
[in]valuePosition in range to set with integer
Note
Percent, floating point or integer are alone possible. Combining these different values can be not together and can, therefore, only one each can be used and must be defined with SetType before.

◆ SetStringValue()

void kodi::gui::controls::CSpin::SetStringValue ( const std::string & value)
inline

To change the spin to position with them string as value.

Format must be set to ADDON_SPIN_CONTROL_TYPE_TEXT to use this function.

Parameters
[in]valueString value to change to

◆ SetText()

void kodi::gui::controls::CSpin::SetText ( const std::string & text)
inline

To set the text string on spin control.

Parameters
[in]textText to show as name for spin

◆ SetType()

void kodi::gui::controls::CSpin::SetType ( AddonGUISpinControlType type)
inline

To set the with SpinControlType defined types of spin.

Parameters
[in]typeThe type to use
Note
See description of AddonGUISpinControlType for available types.

◆ SetVisible()

void kodi::gui::controls::CSpin::SetVisible ( bool visible)
inline

Set the control on window to visible.

Parameters
[in]visibleIf true visible, otherwise hidden

◆ ~CSpin()

kodi::gui::controls::CSpin::~CSpin ( )
overridedefault

Destructor.