Torque3D Documentation / _generateds / guiSliderCtrl.h

guiSliderCtrl.h

Engine/source/gui/controls/guiSliderCtrl.h

More...

Classes:

class

A slider control that selects out of a floating-point value range.

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _GUISLIDERCTRL_H_
 25#define _GUISLIDERCTRL_H_
 26
 27#ifndef _GUICONTROL_H_
 28#include "gui/core/guiControl.h"
 29#endif
 30
 31
 32/// A slider control that selects out of a floating-point value range.
 33class GuiSliderCtrl : public GuiControl
 34{
 35   public:
 36   
 37      typedef GuiControl Parent;
 38
 39   protected:
 40
 41      Point2F mRange;
 42      U32  mTicks;
 43      bool mRenderTicks;
 44      bool mSnap;
 45      F32  mValue;
 46      RectI   mThumb;
 47      Point2I mThumbSize;
 48      S32 mShiftPoint;
 49      S32 mShiftExtent;
 50      F32 mIncAmount;
 51      bool mDisplayValue;
 52      bool mDepressed;
 53      bool mMouseOver;
 54      bool mMouseDragged;
 55      bool mHasTexture;
 56      bool mUseFillBar;
 57      ColorI mFillBarColor;
 58
 59      enum
 60      {
 61         SliderLineLeft = 0,
 62         SliderLineCenter,
 63         SliderLineRight,
 64         SliderButtonNormal,
 65         SliderButtonHighlight,
 66         NumBitmaps
 67      };
 68         RectI *mBitmapBounds;
 69
 70      F32 _getThumbValue( const GuiEvent& event );
 71      void _updateThumb( F32 value, bool snap = true, bool onWake = false, bool doCallback = true );
 72      
 73      /// @name Callbacks
 74      /// @{
 75      
 76      DECLARE_CALLBACK( void, onMouseDragged, () );
 77      
 78      /// @}
 79      
 80      static bool _setValue( void* object, const char* index, const char* data ) { static_cast< GuiSliderCtrl* >( object )->setValue( dAtof( data ) ); return false; }
 81
 82   public:
 83         
 84      GuiSliderCtrl();
 85      
 86      bool isThumbBeingDragged() const { return mDepressed; }
 87         
 88      const Point2F& getRange() const { return mRange; }
 89
 90      // GuiControl.
 91      bool onWake();
 92
 93      void onMouseDown(const GuiEvent &event);
 94      void onMouseDragged(const GuiEvent &event);
 95      void onMouseUp(const GuiEvent &);
 96      void onMouseLeave(const GuiEvent &);
 97      void onMouseEnter(const GuiEvent &);
 98      bool onMouseWheelUp(const GuiEvent &event);
 99      bool onMouseWheelDown(const GuiEvent &event);
100      
101      void setActive( bool value );
102
103      F32 getValue() const { return mValue; }
104      void setScriptValue(const char *val) { setValue(dAtof(val)); }
105      void setValue(F32 val, bool doCallback=false);
106
107      void onRender(Point2I offset, const RectI &updateRect);
108      
109      virtual bool resize( const Point2I& newSize, const Point2I& newExtent );
110      virtual void parentResized( const RectI& oldParentRect, const RectI& newParentRect );
111
112      static void initPersistFields();
113
114      DECLARE_CONOBJECT(GuiSliderCtrl);
115      DECLARE_CATEGORY( "Gui Values" );
116      DECLARE_DESCRIPTION( "A control that implements a horizontal or vertical slider to\n"
117                           "select/represent values in a certain range." )
118};
119
120#endif
121