Public Member Functions | Private Member Functions | Private Attributes

Slider Class Reference

Base class for all sliding controls. More...

#include <Slider.h>

Inheritance diagram for Slider:
Control Broadcaster Listener

List of all members.

Public Member Functions

 Slider (const std::string &name, int height, SliderType type=SLIDER_VERTICAL)
void setPosition (double position)
void changePosition (double change)
double getPosition () const
double getStepSize (Uint units=1) const
int getSlideLength () const
void setThumbSize (Uint height)

Private Member Functions

void initialize ()
void drawSkin ()
void drawPlain ()
void logic ()
void onClick (Event *event)
void onDrag (Event *event)
void onPressed (Event *event)
void onChanged (Event *event)
void onResized ()
void constrainThumb ()

Private Attributes

SliderType mSliderType
SkinPartmThumb
int mThumbWidth
int mThumbHeight
int mThumbRelativeX
int mThumbRelativeY
int mSlideArea
int mMouseX
int mMouseY
double mPosition
bool mThumbPressed

Detailed Description

Base class for all sliding controls.

Todo:
Currently only Veritcal type sliders are supported. Horizontal should be pretty straight forward.
Todo:
There's a bit of odd behavior when the mouse is dragged passed the slide area. This should be fairly straight forward to fix using the mMouseX and mMouseY values although it requires that this Control respond to onMouseMove() events.

Constructor & Destructor Documentation

Slider::Slider ( const std::string &  name,
int  height,
SliderType  type = SLIDER_VERTICAL 
)

Member Function Documentation

void Slider::changePosition ( double  change  ) 

Adds the change amount to the current position.

Parameters:
change Amount to change in percent to change the slider's position. Must be between 0.0 1.0.
void Slider::constrainThumb (  )  [private]
void Slider::drawPlain (  )  [private, virtual]

Draws a Control without a Skin.

Reimplemented from Control.

void Slider::drawSkin (  )  [private, virtual]

Draws a Control using a Skin.

Reimplemented from Control.

double Slider::getPosition (  )  const

Gets the current position of the slider as percentage of the length of the slider.

int Slider::getSlideLength (  )  const

Returns the number of pixels the slider can move along.

double Slider::getStepSize ( Uint  unit = 1  )  const

Gets the size of a step based on a unit size.

Parameters:
unit Size of a step as a measure of pixels. Default unit size is 1 pixel.
void Slider::initialize (  )  [private, virtual]

Todo:
I'm not thrilled with the way the slider determines its width. I'd like to go through this code to ensure that 1) it's correct and 2) it's cleaner than it is.

Reimplemented from Control.

void Slider::logic (  )  [private, virtual]

Reimplemented from Control.

void Slider::onChanged ( Event event  )  [private, virtual]

Called whenever a Control's data changes.

Reimplemented from Control.

void Slider::onClick ( Event event  )  [private, virtual]

Reset mouse pressed.

Reimplemented from Control.

void Slider::onDrag ( Event event  )  [private, virtual]

If the mouse is still pressed on the thumbnail and moves, update the thumbnail position.

Reimplemented from Control.

void Slider::onPressed ( Event event  )  [private, virtual]

Reimplemented from Control.

void Slider::onResized (  )  [private, virtual]

Called whenever a Control changes its size.

Reimplemented from Control.

void Slider::setPosition ( double  position  ) 

Update thumb position

void Slider::setThumbSize ( Uint  size  ) 

Sets the thumb size in pixels.

Parameters:
size Number of pixels to set the size of the Thumb.
Note:
If slider type is SLIDER_VERTICAL than size will modify height. Otherwise size will modify width.

Member Data Documentation

int Slider::mMouseX [private]

Mouse X coordinate. Used to prevent odd behavior in the thumb.

Reimplemented from Control.

int Slider::mMouseY [private]

Mouse X coordinate. Used to prevent odd behavior in the thumb.

Reimplemented from Control.

double Slider::mPosition [private]

Thumbnail position.

int Slider::mSlideArea [private]

Area in which the slider is allowed to move. Avoids unnecessary on-the-fly calculations.

Type of the Slider.

Slider's Thumb graphics.

int Slider::mThumbHeight [private]

Height of the Thumb.

bool Slider::mThumbPressed [private]

Flag to indicate if this control is pressed.

int Slider::mThumbRelativeX [private]

Current location of the Thumb.

int Slider::mThumbRelativeY [private]

Current location of the Thumb.

int Slider::mThumbWidth [private]

Width of the Thumb.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines