Merge pull request #26350 from jjd-uk/estuary_media_align
[xbmc.git] / xbmc / guilib / GUISpinControl.h
blob9d29950d731669fc84da7480d6abd1bb41678f35
1 /*
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.
7 */
9 #pragma once
11 /*!
12 \file GUISpinControl.h
13 \brief
16 #include "GUIControl.h"
17 #include "GUILabel.h"
18 #include "GUITexture.h"
20 #include <vector>
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
27 /*!
28 \ingroup controls
29 \brief
31 class CGUISpinControl : public CGUIControl
33 public:
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);
58 int GetValue() const;
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; }
78 void Clear();
79 std::string GetDescription() const override;
80 bool IsFocusedOnUp() const;
82 bool IsVisible() const override;
84 protected:
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;
97 void PageUp();
98 void PageDown();
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);
104 int m_iStart;
105 int m_iEnd;
106 float m_fStart;
107 float m_fEnd;
108 int m_iValue;
109 float m_fValue;
110 int m_iType;
111 int m_iSelect;
112 bool m_bReverse;
113 float m_fInterval;
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;
123 CGUILabel m_label;
124 bool m_bShowRange;
125 char m_szTyped[10];
126 int m_iTypedPos;
128 int m_currentItem;
129 int m_itemsPerPage;
130 int m_numItems;
131 bool m_showOnePage;