-
Notifications
You must be signed in to change notification settings - Fork 88
glgui button string
Walt K edited this page Jan 23, 2016
·
4 revisions
glgui-button-string creates a button with a string label. It supports the generation of a toggle button by specifying a list of strings.
| 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 |
| str | String or a list of strings to use as labels of a toggle button. To update the string(s) later, set parameter 'image. If a non-toggle button, set to a list of 1 item. For example, (list "string"). |
| fnt | Font to be render the string in |
| callback | Function to be called if button is pressed |
| icon | Optional: Image texture to use as an icon to the left of the string label. This can also be a list of icons which will be used with a toggle button. |
Example 1 from apps/DemoHelloWorld/main.scm,
(define (button-callback g w t x y)
(let ((oldcolor (glgui-widget-get g w 'color)))
(if ahooga (audiofile-play ahooga))
(glgui-widget-set! g w 'color (if (= oldcolor White) Red White))
)
)
(set! b (glgui-button-string gui bx by bw bh "Me too!!!" ascii_18.fnt 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 strings 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 | True | If true, the button is a rounded rectangle shape. Otherwise, the button is a rectangle. |
| multiline | False | If true, the string label will be wrapped to extra lines if necessary to fit or if newline characters are used. |
| align | GUI_ALIGNCENTER | The alignment of the text on the button. |
| direction | GUI_LEFTTORIGHT | This is only used if multiline is true and specifies which way to wrap to the next line of text. If set to GUI_RIGHTTOLEFT then text is wrapped with the right end of the string on the top line and the left end on the bottom line, useful for right-to-left languages. |
| icon-space | 5 | This is only used if icon is not false. This is the space in pixels between the text and the icon (vertically or horizontally depending on the below parameter). |
| icon-align | GUI_ALIGNLEFT | The side the icon is on compared to the text. Choose from GUI_ALIGNLEFT, GUI_ALIGNRIGHT, GUI_ALIGNTOP and GUI_ALIGNBOTTOM. |
Example 2: Aligns the "Me Too!!!" text from Example 1 to the left and makes the background a solid color. It changes the normal background color of the button to Dark Green which changes to Green when the mouse is down on it.
(glgui-widget-set! gui b 'align GUI_ALIGNLEFT)
(glgui-widget-set! gui b 'solid-color #t)
(glgui-widget-set! gui b 'button-normal-color DarkGreen)
(glgui-widget-set! gui b 'button-selected-color Green)
Example 3: Changes text of a toggle button to "a" and "b"
(glgui-widget-set! gui w 'image (map list (list ("a" "b"))))
-
- 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