PageRenderTime 47ms CodeModel.GetById 34ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/xbmc/guilib/GUISliderControl.h

http://github.com/xbmc/xbmc
C Header | 121 lines | 85 code | 16 blank | 20 comment | 0 complexity | d030cc3eae8866bfdf71d543cdc169cd MD5 | raw file
  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/*!
 12\file GUISliderControl.h
 13\brief
 14*/
 15
 16#include "GUIControl.h"
 17#include "GUITexture.h"
 18
 19#define SLIDER_CONTROL_TYPE_INT         1
 20#define SLIDER_CONTROL_TYPE_FLOAT       2
 21#define SLIDER_CONTROL_TYPE_PERCENTAGE  3
 22
 23typedef struct
 24{
 25  const char *action;
 26  const char *formatString;
 27  int         infoCode;
 28  bool        fireOnDrag;
 29} SliderAction;
 30
 31/*!
 32 \ingroup controls
 33 \brief
 34 */
 35class CGUISliderControl :
 36      public CGUIControl
 37{
 38public:
 39  typedef enum {
 40    RangeSelectorLower = 0,
 41    RangeSelectorUpper = 1
 42  } RangeSelector;
 43
 44  CGUISliderControl(int parentID, int controlID, float posX, float posY, float width, float height, const CTextureInfo& backGroundTexture, const CTextureInfo& mibTexture, const CTextureInfo& nibTextureFocus, int iType, ORIENTATION orientation);
 45  ~CGUISliderControl(void) override;
 46  CGUISliderControl *Clone() const override { return new CGUISliderControl(*this); };
 47
 48  void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) override;
 49  void Render() override;
 50  bool OnAction(const CAction &action) override;
 51  virtual bool IsActive() const { return true; };
 52  void AllocResources() override;
 53  void FreeResources(bool immediately = false) override;
 54  void DynamicResourceAlloc(bool bOnOff) override;
 55  void SetInvalid() override;
 56  virtual void SetRange(int iStart, int iEnd);
 57  virtual void SetFloatRange(float fStart, float fEnd);
 58  bool OnMessage(CGUIMessage& message) override;
 59  bool ProcessSelector(CGUITexture &nib, unsigned int currentTime, float fScale, RangeSelector selector);
 60  void SetRangeSelection(bool rangeSelection);
 61  bool GetRangeSelection() const { return m_rangeSelection; }
 62  void SetRangeSelector(RangeSelector selector);
 63  void SwitchRangeSelector();
 64  void SetInfo(int iInfo);
 65  void SetPercentage(float iPercent, RangeSelector selector = RangeSelectorLower, bool updateCurrent = false);
 66  float GetPercentage(RangeSelector selector = RangeSelectorLower) const;
 67  void SetIntValue(int iValue, RangeSelector selector = RangeSelectorLower, bool updateCurrent = false);
 68  int GetIntValue(RangeSelector selector = RangeSelectorLower) const;
 69  void SetFloatValue(float fValue, RangeSelector selector = RangeSelectorLower, bool updateCurrent = false);
 70  float GetFloatValue(RangeSelector selector = RangeSelectorLower) const;
 71  void SetIntInterval(int iInterval);
 72  void SetFloatInterval(float fInterval);
 73  void SetType(int iType) { m_iType = iType; };
 74  int GetType() const { return m_iType; }
 75  std::string GetDescription() const override;
 76  void SetTextValue(const std::string &textValue) { m_textValue = textValue; };
 77  void SetAction(const std::string &action);
 78protected:
 79  bool HitTest(const CPoint &point) const override;
 80  EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event) override;
 81  bool UpdateColors() override;
 82  virtual void Move(int iNumSteps);
 83  virtual void SetFromPosition(const CPoint &point, bool guessSelector = false);
 84  /*! \brief Get the current position of the slider as a proportion
 85   \return slider position in the range [0,1]
 86   */
 87  float GetProportion(RangeSelector selector = RangeSelectorLower) const;
 88
 89  /*! \brief Send a click message (and/or action) to the app in response to a slider move
 90   */
 91  void SendClick();
 92
 93  CGUITexture m_guiBackground;
 94  CGUITexture m_guiSelectorLower;
 95  CGUITexture m_guiSelectorUpper;
 96  CGUITexture m_guiSelectorLowerFocus;
 97  CGUITexture m_guiSelectorUpperFocus;
 98  int m_iType;
 99
100  bool m_rangeSelection;
101  RangeSelector m_currentSelector;
102
103  float m_percentValues[2];
104
105  int m_intValues[2];
106  int m_iStart;
107  int m_iInterval;
108  int m_iEnd;
109
110  float m_floatValues[2];
111  float m_fStart;
112  float m_fInterval;
113  float m_fEnd;
114
115  int m_iInfoCode;
116  std::string m_textValue; ///< Allows overriding of the text value to be displayed (parent must update when the slider updates)
117  const SliderAction *m_action; ///< Allows the skin to configure the action of a click on the slider \sa SendClick
118  bool m_dragging; ///< Whether we're in a (mouse/touch) drag operation or not - some actions are sent only on release.
119  ORIENTATION m_orientation;
120};
121