GuiSliderCtrl

consoledoc.h

A control that displays a value between its minimal and maximal bounds using a slider placed on a vertical or horizontal axis.

More...

Slider

Point2F

Min and max values corresponding to left and right slider position.

int

Spacing between tick marks in pixels. 0=off.

bool

Whether to snap the slider to tick marks.

float

The value corresponding to the current slider position.

bool

Whether to render the tick marks.

ColorI

Whether to render the tick marks.

bool

Whether to render the tick marks.

Callbacks

void

Called when the left mouse button is dragged across the slider.

Public Functions

float

Get the current value of the slider based on the position of the thumb.

bool

Returns true if the thumb is currently being dragged by the user. This method is mainly useful for scrubbing type sliders where the slider position is sync'd to a changing value. When the user is dragging the thumb, however, the sync'ing should pause and not get in the way of the user.

void
setValue(float pos, bool doCallback)

Set position of the thumb on the slider.

Detailed Description

A control that displays a value between its minimal and maximal bounds using a slider placed on a vertical or horizontal axis.

A slider displays a value and allows that value to be changed by dragging a thumb control along the axis of the slider. In this way, the value is changed between its allowed minimum and maximum.

To hook up script code to the value changes of a slider, use the command and altCommand properties. command is executed once the thumb is released by the user whereas altCommand is called any time the slider value changes. When changing the slider value from script, however, trigger of altCommand is suppressed by default.

The orientation of a slider is automatically determined from the ratio of its width to its height. If a slider is taller than it is wide, it will be rendered with a vertical orientation. If it is wider than it is tall, it will be rendered with a horizontal orientation.

The rendering of a slider depends on the bitmap in the slider's profile. This bitmap must be a bitmap array comprised of at least five bitmap rectangles. The rectangles are used such that:

  • Rectangle #1: Left edge of slider

  • Rectangle #2: Center piece of slider; this is stretched between the left and right edge

  • Rectangle #3: Right edge of slider

  • Rectangle #4: Thumb button in normal state

  • Rectangle #5: Thumb button in highlighted (mouse-over) state

// Create a sound source and a slider that changes the volume of the source.

%source = sfxPlayOnce( "art/sound/testing", AudioLoop2D );

new GuiSlider()
{
   // Update the sound source volume when the slider is being dragged and released.
   command = %source @ ".setVolume( $ThisControl.value );";

   // Limit the range to 0..1 since that is the allowable range for sound volumes.
   range = "0 1";
};

Slider

Point2F range 

Min and max values corresponding to left and right slider position.

int ticks 

Spacing between tick marks in pixels. 0=off.

bool snap 

Whether to snap the slider to tick marks.

float value 

The value corresponding to the current slider position.

bool useFillBar 

Whether to render the tick marks.

ColorI fillBarColor 

Whether to render the tick marks.

bool renderTicks 

Whether to render the tick marks.

Callbacks

onMouseDragged()

Called when the left mouse button is dragged across the slider.

Public Functions

getValue()

Get the current value of the slider based on the position of the thumb.

return:

Slider position (from range.x to range.y).

isThumbBeingDragged()

Returns true if the thumb is currently being dragged by the user. This method is mainly useful for scrubbing type sliders where the slider position is sync'd to a changing value. When the user is dragging the thumb, however, the sync'ing should pause and not get in the way of the user.

setValue(float pos, bool doCallback)

Set position of the thumb on the slider.

Parameters:

pos

New slider position (from range.x to range.y)

doCallback

If true, the altCommand callback will be invoked