2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
12 \file GUISpinControl.h
16 #include "GUIControl.h"
18 #include "GUITexture.h"
22 #define SPIN_CONTROL_TYPE_INT 1
23 #define SPIN_CONTROL_TYPE_FLOAT 2
24 #define SPIN_CONTROL_TYPE_TEXT 3
25 #define SPIN_CONTROL_TYPE_PAGE 4
31 class CGUISpinControl
: public CGUIControl
34 CGUISpinControl(int parentID
, int controlID
, float posX
, float posY
, float width
, float height
, const CTextureInfo
& textureUp
, const CTextureInfo
& textureDown
, const CTextureInfo
& textureUpFocus
, const CTextureInfo
& textureDownFocus
, const CTextureInfo
& textureUpDisabled
, const CTextureInfo
& textureDownDisabled
, const CLabelInfo
& labelInfo
, int iType
);
35 ~CGUISpinControl() override
= default;
36 CGUISpinControl
* Clone() const override
{ return new CGUISpinControl(*this); }
38 void Process(unsigned int currentTime
, CDirtyRegionList
&dirtyregions
) override
;
39 void Render() override
;
40 bool OnAction(const CAction
&action
) override
;
41 void OnLeft() override
;
42 void OnRight() override
;
43 bool HitTest(const CPoint
&point
) const override
;
44 bool OnMouseOver(const CPoint
&point
) override
;
45 bool OnMessage(CGUIMessage
& message
) override
;
46 void AllocResources() override
;
47 void FreeResources(bool immediately
= false) override
;
48 void DynamicResourceAlloc(bool bOnOff
) override
;
49 void SetInvalid() override
;
50 void SetPosition(float posX
, float posY
) override
;
51 float GetWidth() const override
;
52 void SetRange(int iStart
, int iEnd
);
53 void SetFloatRange(float fStart
, float fEnd
);
54 void SetValue(int iValue
);
55 void SetValueFromLabel(const std::string
&label
);
56 void SetFloatValue(float fValue
);
57 void SetStringValue(const std::string
& strValue
);
59 float GetFloatValue() const;
60 std::string
GetStringValue() const;
61 void AddLabel(const std::string
& strLabel
, int iValue
);
62 void AddLabel(const std::string
& strLabel
, const std::string
& strValue
);
63 const std::string
GetLabel() const;
64 void SetReverse(bool bOnOff
);
65 int GetMaximum() const;
66 int GetMinimum() const;
67 void SetSpinAlign(uint32_t align
, float offsetX
)
69 m_label
.GetLabelInfo().align
= align
;
70 m_label
.GetLabelInfo().offsetX
= offsetX
;
72 void SetType(int iType
) { m_iType
= iType
; }
73 float GetSpinWidth() const { return m_imgspinUp
->GetWidth(); }
74 float GetSpinHeight() const { return m_imgspinUp
->GetHeight(); }
75 void SetFloatInterval(float fInterval
);
76 void SetShowRange(bool bOnoff
) ;
77 void SetShowOnePage(bool showOnePage
) { m_showOnePage
= showOnePage
; }
79 std::string
GetDescription() const override
;
80 bool IsFocusedOnUp() const;
82 bool IsVisible() const override
;
85 CGUISpinControl(const CGUISpinControl
& control
);
87 EVENT_RESULT
OnMouseEvent(const CPoint
& point
, const KODI::MOUSE::CMouseEvent
& event
) override
;
88 bool UpdateColors(const CGUIListItem
* item
) override
;
89 /*! \brief Render the spinner text
90 \param posX position of the left edge of the text
91 \param posY positing of the top edge of the text
92 \param width width of the text
93 \param height height of the text
95 virtual void RenderText(float posX
, float posY
, float width
, float height
);
96 CGUILabel::COLOR
GetTextColor() const;
99 bool CanMoveDown(bool bTestReverse
= true);
100 bool CanMoveUp(bool bTestReverse
= true);
101 void MoveUp(bool bTestReverse
= true);
102 void MoveDown(bool bTestReverse
= true);
103 void ChangePage(int amount
);
114 std::vector
<std::string
> m_vecLabels
;
115 std::vector
<int> m_vecValues
;
116 std::vector
<std::string
> m_vecStrValues
;
117 std::unique_ptr
<CGUITexture
> m_imgspinUp
;
118 std::unique_ptr
<CGUITexture
> m_imgspinDown
;
119 std::unique_ptr
<CGUITexture
> m_imgspinUpFocus
;
120 std::unique_ptr
<CGUITexture
> m_imgspinDownFocus
;
121 std::unique_ptr
<CGUITexture
> m_imgspinUpDisabled
;
122 std::unique_ptr
<CGUITexture
> m_imgspinDownDisabled
;