This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

WidgetSlider Class

This class creates a slider: horizontal or vertical one.

WidgetSlider Class

This class inherits from Widget

Members


WidgetSlider (Gui gui, int minimum = 0, int maximum = 100, int initial = 0)

Constructor. Creates a slider with given properties (horizontal one by default).

Arguments

  • Gui gui - GUI, to which the slider will belong.
  • int minimum - Minimum value.
  • int maximum - Maximum value.
  • int initial - Initial value.

int getButtonHeight ()

Returns the height of the slider handle in pixels (for a vertical slider).

Return value

Height of the handle in pixels.

int getButtonWidth ()

Returns the width of the slider handle in pixels (for a horizontal slider).

Return value

Width of the handle in pixels.

int getMaxExpand ()

Returns the current maximum value, up to which the upper limit of the range of the slider values can be expanded.
Notice
The upper limit of the slider can be expanded only if the slider is attached to an editline with the GUI_ATTACH_MAX_EXPAND flag.
See also the setMaxExpand() function.

Return value

Maximum value, up to which the slider's upper limit can be raised.

int getMaxValue ()

Returns the current maximum value of the slider.
Notice
The value returned by this function may differ from the value set via setMaxValue(). See the setMaxExpand() function for more details.

Return value

Maximum value.

int getMinExpand ()

Returns the minimum value, up to which the lower limit of the range of the slider values can be expanded.
Notice
The lower limit of the slider can be expanded only if the slider is attached to an editline with the GUI_ATTACH_MIN_EXPAND flag.
See also the setMinExpand() function.

Return value

Minimum value, up to which the slider's lower limit can be dropped.

int getMinValue ()

Returns the minimum value of the slider.
Notice
The value returned by this function may differ from the value set via setMinValue(). See the setMinExpand() function for more details.

Return value

Minimum value.

int getOrientation ()

Returns the current orientation of the slider: horizontal or vertical one.

Return value

1 if the orientation is vertical; 0 if it is horizontal.

int getValue ()

Returns the current value of the slider, i.e. its position.

Return value

Current slider value.

void setButtonHeight (int height)

Sets height of the slider handle in pixels (for a vertical slider).

Arguments

  • int height - Height of the handle in pixels.

void setButtonWidth (int width)

Sets width of the slider handle in pixels (for a horizontal slider).

Arguments

  • int width - Width of the handle in pixels.

void setMaxExpand (int value)

Sets the maximum value, up to which the upper limit of the range of the slider values can be expanded.

Arguments

  • int value - Maximum value, up to which the slider's upper limit can be raised.

Examples

The following example demonstrates how to make the slider expandable and to set the maximum value, up to which the upper limit of the slider can be raised:

Source code (UnigineScript)
// get a system GUI
Gui gui = engine.getGui();

// create a new window and add it to the gui
WidgetWindow window = new WidgetWindow(gui,"Window");
gui.addChild(window,GUI_ALIGN_CENTER);

// add a new editline to the gui
WidgetEditLine editline = new WidgetEditLine(gui,"15");
window.addChild(editline,GUI_ALIGN_LEFT);

// add a new horizontal slider to the gui and attach it to the editline
WidgetSlider hslider = new WidgetSlider(gui,8,20,15);
window.addChild(hslider,GUI_ALIGN_LEFT);
editline.addAttach(hslider,0,1,GUI_ATTACH_MAX_EXPAND);
// set the maximum expand value for the slider
hslider.setMaxExpand(26);

In the result, the following window will be created:

The maximum slider value is 20 by default.

If you type, for example, 26 in the editline, the upper limit of the slider will be raised:

The maximum slider value is equal to 26 now.

void setMaxValue (int maximum)

Sets the maximum value for the slider.

Arguments

  • int maximum - Maximum value.

void setMinExpand (int value)

Sets the minimum value, up to which the lower limit of the range of the slider values can be expanded.

Arguments

  • int value - Minimum value, up to which the slider's lower limit can be dropped.

Examples

The following example demonstrates how to make the slider expandable and to set the minimum value, up to which the lower limit of the slider can be dropped:

Source code (UnigineScript)
// get a system GUI
Gui gui = engine.getGui();

// create a new window and add it to the gui
WidgetWindow window = new WidgetWindow(gui,"Window");
gui.addChild(window,GUI_ALIGN_CENTER);

// add a new editline to the gui
WidgetEditLine editline = new WidgetEditLine(gui,"15");
window.addChild(editline,GUI_ALIGN_LEFT);

// add a new horizontal slider to the gui and attach it to the editline
WidgetSlider hslider = new WidgetSlider(gui,8,20,15);
window.addChild(hslider,GUI_ALIGN_LEFT);
editline.addAttach(hslider,0,1,GUI_ATTACH_MIN_EXPAND);
// set the minimum expand value for the slider
hslider.setMinExpand(3);

In the result, the following window will be created:

The minimum slider value is 8 by default.

If you type, for example, 3 in the editline, the lower limit of the slider will be decreased:

The minimum slider value is equal to 3 now.

void setMinValue (int minimum)

Sets the minimum value for the slider.

Arguments

  • int minimum - Minimum value.

void setOrientation (int orientation)

Sets orientation of the slider: horizontal (by default) or vertical one.

Arguments

  • int orientation - 1 to set horizontal orientation; 0 to set vertical one.

void setValue (int value)

Sets a new current value for the slider, i.e. its position.

Arguments

  • int value - Slider value.
Last update: 2017-07-03
Build: ()