2 \file GUISliderControl.h
6 #ifndef GUILIB_GUISLIDERCONTROL_H
7 #define GUILIB_GUISLIDERCONTROL_H
12 * Copyright (C) 2005-2013 Team XBMC
15 * This Program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2, or (at your option)
20 * This Program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with XBMC; see the file COPYING. If not, see
27 * <http://www.gnu.org/licenses/>.
31 #include "GUIControl.h"
32 #include "GUITexture.h"
34 #define SPIN_CONTROL_TYPE_INT 1
35 #define SPIN_CONTROL_TYPE_FLOAT 2
36 #define SPIN_CONTROL_TYPE_TEXT 3
41 const char *formatString;
50 class CGUISliderControl :
55 RangeSelectorLower = 0,
56 RangeSelectorUpper = 1
59 CGUISliderControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& backGroundTexture, const CTextureInfo& mibTexture, const CTextureInfo& nibTextureFocus, int iType);
60 virtual ~CGUISliderControl(void);
61 virtual CGUISliderControl *Clone() const { return new CGUISliderControl(*this); };
63 virtual void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
64 virtual void Render();
65 virtual bool OnAction(const CAction &action);
66 virtual void AllocResources();
67 virtual void FreeResources(bool immediately = false);
68 virtual void DynamicResourceAlloc(bool bOnOff);
69 virtual void SetInvalid();
70 virtual void SetRange(int iStart, int iEnd);
71 virtual void SetFloatRange(float fStart, float fEnd);
72 virtual bool OnMessage(CGUIMessage& message);
73 bool ProcessSelector(CGUITexture &nib, unsigned int currentTime, float fScaleY, RangeSelector selector);
74 void SetRangeSelection(bool rangeSelection);
75 bool GetRangeSelection() const { return m_rangeSelection; }
76 void SetRangeSelector(RangeSelector selector);
77 void SwitchRangeSelector();
78 void SetInfo(int iInfo);
79 void SetPercentage(float iPercent, RangeSelector selector = RangeSelectorLower, bool updateCurrent = false);
80 float GetPercentage(RangeSelector selector = RangeSelectorLower) const;
81 void SetIntValue(int iValue, RangeSelector selector = RangeSelectorLower, bool updateCurrent = false);
82 int GetIntValue(RangeSelector selector = RangeSelectorLower) const;
83 void SetFloatValue(float fValue, RangeSelector selector = RangeSelectorLower, bool updateCurrent = false);
84 float GetFloatValue(RangeSelector selector = RangeSelectorLower) const;
85 void SetIntInterval(int iInterval);
86 void SetFloatInterval(float fInterval);
87 void SetType(int iType) { m_iType = iType; };
88 virtual CStdString GetDescription() const;
89 void SetTextValue(const CStdString &textValue) { m_textValue = textValue; };
90 void SetAction(const CStdString &action);
92 virtual bool HitTest(const CPoint &point) const;
93 virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
94 virtual bool UpdateColors();
95 virtual void Move(int iNumSteps);
96 virtual void SetFromPosition(const CPoint &point, bool guessSelector = false);
97 /*! \brief Get the current position of the slider as a proportion
98 \return slider position in the range [0,1]
100 float GetProportion(RangeSelector selector = RangeSelectorLower) const;
102 /*! \brief Send a click message (and/or action) to the app in response to a slider move
106 CGUITexture m_guiBackground;
107 CGUITexture m_guiSelectorLower;
108 CGUITexture m_guiSelectorUpper;
109 CGUITexture m_guiSelectorLowerFocus;
110 CGUITexture m_guiSelectorUpperFocus;
113 bool m_rangeSelection;
114 RangeSelector m_currentSelector;
116 float m_percentValues[2];
123 float m_floatValues[2];
129 CStdString m_textValue; ///< Allows overriding of the text value to be displayed (parent must update when the slider updates)
130 const SliderAction *m_action; ///< Allows the skin to configure the action of a click on the slider \sa SendClick
131 bool m_dragging; ///< Whether we're in a (mouse/touch) drag operation or not - some actions are sent only on release.