Skip to content

glgui horizontalvaluepicker

Dustin edited this page Sep 23, 2016 · 2 revisions

glgui-horizontalvaluepicker creates a horizontally oriented value (number, string, or icon) picker. The picker displays the currently selected item with arrow (triangle) buttons to the left and right of 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 left or right 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. The displayed value is centered within this width. The left and right arrow buttons have trigger area of the left and right most 60 pixels, highlight (when pressed) the left and right most 45 pixels, and actual arrow icons are 20 pixels wide within the 45.
h Height of the element in pixels
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 left and right 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, 130px in width and 70px 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-horizontalvaluepicker gui 10 10 130 70 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, 130px in width and 70 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"))
(glgui-horizontalvaluepicker gui 200 10 130 70 #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.
rightleft False If true, the right arrow decreases the current value by the step size (or one index in the list) and the left 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.
arrowhperc 0.33 The height of the arrow icon as a percentage of the widget height. Note that this does not change the height of the clickable area, just the drawn arrow.
arrowwspace 15 The space between left and right edges of the widget (buttons) and the arrow that's drawn. If this is decreased, the icon is larger.

Example

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

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