Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
3.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef SLIDER_H
  8. #define SLIDER_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui/vgui.h>
  13. #include <vgui_controls/Panel.h>
  14. namespace vgui
  15. {
  16. //-----------------------------------------------------------------------------
  17. // Labeled horizontal slider
  18. //-----------------------------------------------------------------------------
  19. class Slider : public Panel
  20. {
  21. DECLARE_CLASS_SIMPLE( Slider, Panel );
  22. public:
  23. Slider(Panel *parent, const char *panelName);
  24. // interface
  25. virtual void SetValue(int value, bool bTriggerChangeMessage = true);
  26. virtual int GetValue();
  27. virtual void SetRange(int min, int max); // set to max and min range of rows to display
  28. virtual void GetRange(int &min, int &max);
  29. virtual void GetNobPos(int &min, int &max); // get current Slider position
  30. virtual void SetButtonOffset(int buttonOffset);
  31. virtual void OnCursorMoved(int x, int y);
  32. virtual void OnMousePressed(MouseCode code);
  33. virtual void OnMouseDoublePressed(MouseCode code);
  34. virtual void OnMouseReleased(MouseCode code);
  35. virtual void SetTickCaptions(const wchar_t *left, const wchar_t *right);
  36. virtual void SetTickCaptions(const char *left, const char *right);
  37. virtual void SetNumTicks(int ticks);
  38. virtual void SetThumbWidth( int width );
  39. virtual int EstimateValueAtPos( int localMouseX, int localMouseY );
  40. virtual void SetInverted( bool bInverted );
  41. // If you click on the slider outside of the nob, the nob jumps
  42. // to the click position, and if this setting is enabled, the nob
  43. // is then draggable from the new position until the mouse is released
  44. virtual void SetDragOnRepositionNob( bool state );
  45. virtual bool IsDragOnRepositionNob() const;
  46. // Get if the slider nob is being dragged by user, usually the application
  47. // should refuse from forcefully setting slider value if it is being dragged
  48. // by user since the next frame the nob will pop back to mouse position
  49. virtual bool IsDragged( void ) const;
  50. // This allows the slider to behave like it's larger than what's actually being drawn
  51. virtual void SetSliderThumbSubRange( bool bEnable, int nMin = 0, int nMax = 100 );
  52. protected:
  53. virtual void OnSizeChanged(int wide, int tall);
  54. virtual void Paint();
  55. virtual void PaintBackground();
  56. virtual void PerformLayout();
  57. virtual void ApplySchemeSettings(IScheme *pScheme);
  58. virtual void GetSettings(KeyValues *outResourceData);
  59. virtual void ApplySettings(KeyValues *inResourceData);
  60. virtual const char *GetDescription();
  61. #ifdef _GAMECONSOLE
  62. virtual void OnKeyCodePressed(KeyCode code);
  63. #endif
  64. virtual void OnKeyCodeTyped(KeyCode code);
  65. virtual void DrawNob();
  66. virtual void DrawTicks();
  67. virtual void DrawTickLabels();
  68. virtual void GetTrackRect( int &x, int &y, int &w, int &h );
  69. protected:
  70. virtual void RecomputeNobPosFromValue();
  71. virtual void RecomputeValueFromNobPos();
  72. virtual void SendSliderMovedMessage();
  73. virtual void SendSliderDragStartMessage();
  74. virtual void SendSliderDragEndMessage();
  75. bool _dragging;
  76. int _nobPos[2];
  77. int _nobDragStartPos[2];
  78. int _dragStartPos[2];
  79. int _range[2];
  80. int _subrange[ 2 ];
  81. int _value; // the position of the Slider, in coordinates as specified by SetRange/SetRangeWindow
  82. int _buttonOffset;
  83. IBorder *_sliderBorder;
  84. IBorder *_insetBorder;
  85. float _nobSize;
  86. TextImage *_leftCaption;
  87. TextImage *_rightCaption;
  88. Color m_TickColor;
  89. Color m_TrackColor;
  90. Color m_DisabledTextColor1;
  91. Color m_DisabledTextColor2;
  92. #ifdef _GAMECONSOLE
  93. Color m_DepressedBgColor;
  94. #endif
  95. int m_nNumTicks;
  96. bool m_bIsDragOnRepositionNob : 1;
  97. bool m_bUseSubRange : 1;
  98. bool m_bInverted : 1;
  99. };
  100. }
  101. #endif // SLIDER_H