-
Notifications
You must be signed in to change notification settings - Fork 86
glgui button
glgui-button creates a button with a texture image. It supports the generation of a toggle button by specifying a list of images.
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 |
img | Image texture placed centered on the button. This can also be a list of images which will be used with a toggle button. |
callback | Function to be called if button is pressed |
Example 1: Create a button that when clicked changes image color from red to white everytime it is clicked. This widget is diplayed with image texture pushme.img, which is generated from pushme.png in the application's texture folder. This widget is specified with x=0, y=10, width= 60, height= 30, and belongs to gui g.
(define (button-callback g w t x y)
(glgui-widget-set! g w 'color (if (= (glgui-widget-get g w 'color) White) Red White)))
(glgui-button g 0 10 60 30 pushme.img button-callback)
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 |
---|---|---|
value | 0 | If this is a toggle button (a list of images was given) then this is the index of the currently selected section of the button. |
toggle-selected-color | Grey | This is the background color of the selected section of a toggle button. |
toggle-normal-color | DimGrey | This is the background color of the non-selected section(s) of a toggle button. |
button-selected-color | Grey | This is the background color of the (non-toggle) button when the mouse (finger) is down on it. |
button-normal-color | DimGrey | This is the normal background color of the (non-toggle) button (when the mouse is not down on it). |
solid-color | False | By default, the button background is a texture with a gradient which is partially transparent. If solid-color is set to false, this texture is not used and instead just the above color attributes are used, 100% opaque. |
rounded | False | If set to true, the button is a rounded rectangle shape. Otherwise, the button is a rectangle. |
Example 2: An update to example 1 that also changes the background color when the button is clicked, alternating between a white image on a red background and a red image on a white background.
(define (button-callback g w t x y)
(glgui-widget-set! g w 'color (if (= (glgui-widget-get g w 'color) White) Red White))
(glgui-widget-set! g w 'button-normal-color (if (= (glgui-widget-get g w 'button-normal-color) White) Red White)))
(set! b (glgui-button g 0 10 60 30 pushme.img button-callback))
(glgui-widget-set! g b 'button-normal-color Red)
-
- accelerometer
- alist
- audio
- audioaux
- base64
- btle-scan
- camera
- cdb
- cgi
- config
- csv
- curl
- digest
- dmtx
- download
- eventloop
- fcgi
- fft
- generalized-arrays
- gps
- graph
- gyro
- hidapi
- hpdf
- html
- httpsclient
- hybridapp
- json
- lmdb
- ln_core
- ln_glcore
- ln_glgui
- ln_store
- localization
- localization_gui
- localnotification
- magnetometer
- mdns
- mqtt
- mqtt-store
- multitouch
- oauth
- orientation
- p256ecdsa
- png
- portaudio
- pregexp
- pressure
- prime
- pushnotification
- redcap
- rsa
- rtaudio
- rupi
- rotation
- sanestring
- scheduler
- serial
- sets
- settings
- simplexnoise
- sqlite
- ssax
- syntax-case
- timestamp
- ttf
- uiform
- url
- uuid
- vibrate
- videoplayer
- watchdog
- website
- xml
- zip