Skip to content

glgui verticalvaluepicker

shaybeau731 edited this page Jun 1, 2016 · 6 revisions

glgui-verticalvaluepicker creates a vertically oriented value (number, string, or icon) picker. The picker displays the currently selected item with arrow (triangle) buttons above or below it for changing the value. steps can be a list specifying strings to be drawn in the picker or textures to be displayed in the picker (for using icons). The value displayed when first created is the smallest (or first) value. The current number or index of string or textures can be get or set as the 'value parameter of the widget. The 'callback is called on EVENT_BUTTON1UP (or after dragging outside the widget) after EVENT_BUTTON1DOWN on one of the up or down buttons.

Parameter Description
g Graphical User Interface (GUI) for this widget
x Lower left corner along the x-axis in pixels
y Lower left corner along the y-axis in pixels
w Width of the element in pixels
h Height of the element in pixels. The displayed value is centered within this height. The top and bottom arrow buttons have trigger area of the top and bottom 60 pixels, highlight (when pressed) the top and bottom 45 pixels, and actual arrow icons are 20 pixels high within the 45.
vmin The minimum value in the value picker. If steps is a list of strings or textures, this parameter is not used.
vmax The maximum value in the value picker. If steps is a list of strings or textures, this parameter is not used.
colorarrows Color for the up and down triangle arrows
colorhighlight Color of the arrow button background when being pressed. When not being pressed these buttons have no background.
colorvalue Color of the value being displayed
colorbg Color of the background of the value picker. Set to #f for no background color.
font Font of the value being displayed. If steps is a list of textures, this parameter is not used.
steps Optional: Step size or values of steps, this is the step-size between adjacent values in the value picker, OR this is a list specifying strings or textures to be displayed as values.

Examples

Example 1: Create a number picker, with values from 1 to 6. Place on the gui at 10,10, 70px in width and 130 px high. The arrow buttons are grey with a blue highlight behind them when pressed. The number displayed is white and the background of the whole widget is black.

(glgui-verticalvaluepicker gui 10 10 70 130 1 6 Grey Blue White Black ascii_25.fnt)

Example 2: Create a minutes picker, with values from 00 to 55 in 5 minute steps. Place on the gui at 200,10, 70px in width and 130 px high. The arrow buttons are white with an orange highlight behind them when pressed. The number displayed is red and there is no background to the widget.

(set! minutes-list '("00" "05" "10" "15" "20" "25" "30" "35" "40" "45" "50" "55"))
(set! minute (glgui-verticalvaluepicker gui 200 10 70 130 #f #f 
  White Orange Red #f ascii_25.fnt minutes-list))

Attributes

Besides the parameters set in the above procedure, the widget has the following attributes that can be set using glgui-widget-set! and retrieved using glgui-widget-get:

Attribute Default Value Description
callback False If a procedure, this procedure is called when a selection change is finished being made in the value picker. If Button1 (or your finger on a mobile platform) is being held down for cycling through values, the callback is not called until you release.
cycle False If set to true, then both arrow buttons are always present and going passed the maximum value cycles to the minimum value and vice versa.
hidden False If true, the widget is not displayed.
scalearrows False If true, the size of the arrow buttons will be proportional to the height of the widget.
topdown False If true, the up arrow decreases the current value by the step size (or one index in the list) and the down arrow increases it instead of the other way around.
vallist List of values or False This is set indirectly in the creation of the widget, to either the list of values given in steps or False if no list used.
value vmin or 0 The current selected number value, or if vallist used the index of the currently selected string or icon.

Example

Example 3: Retrieves the current value from a verticalvaluepicker vvp and hides the widget if the value is over 9000.

(if (> (glgui-widget-get gui vvp 'value) 9000.)
  (glgui-widget-set! gui vvp 'hidden #t)
)
Clone this wiki locally