buttons.md 4.6 KB

Buttons

Toggle

This is a special field, should be followed by a container field, and it controls that container's visibility. If by any chance the next field isn't a container, then form->value is an index to the form passed to ui_event(). If form->label is 0, then form->ptr should point to a zero terminated UTF-8 string, displayed as label. Normally before that there's a right or down triangle, but with UI_NOBULLET there's no triangle rather the label is displayed with a different color (see [color theme], this is to provide menu toggles).

Parameter Description
form->type UI_TOGGLE
form->flags Might want UI_NOBULLET
form->label Index to the localized strings array (or 0)
form->ptr Only if label is 0, pointer to a string
form->value Only if next field isn't a container, ui_event() form's index

Checkbox

Draws a checkbox with label. The pointed value tells if it's checked. When clicked, int value is XOR'd at that address.

Parameter Description
form->type UI_CHECK
form->flags Might want UI_NOBULLET
form->ptr Pointer to the int value
form->value Bitmask for this button
form->label Index to the localized strings array

Radiobutton

Draws a radiobutton with label. The pointed value tells if it's checked. When clicked, int value is stored at that address.

Parameter Description
form->type UI_RADIO
form->flags Might want UI_NOBULLET
form->ptr Pointer to the int value
form->value Int value for this button
form->label Index to the localized strings array

Button

Draws a button. The pointed value tells if it's pressed. When clicked, int value is stored at that address. Might have an icon, a localized string, or both. When using skins, buttons might have a shadow which misaligns the button title vertically. If that happens, set the top margin in m (which could be negative as well).

Parameter Description
form->type UI_BUTTON
form->flags Might want UI_NOBORDER
form->ptr Pointer to the int value
form->value Int value for this button
form->label Index to the localized strings array
form->icon Pointer to an ui_image_t struct
form->m Top margin if skinned

Button Toggle

Draws a button which acts like a [toggle]. When clicked, toggles the pointed container field's visibility. If ptr is NULL, then form->value is an index to the form passed to ui_event().

Parameter Description
form->type UI_BTNTGL
form->flags Might want UI_NOBORDER
form->ptr Pointer to an ui_form_t container field
form->value Only if ptr is NULL, ui_event() form's index
form->label Index to the localized strings array
form->icon Pointer to an ui_image_t struct
form->m Top margin if skinned

Button Icon

Draws an icon if value is checked, otherwise nothing. When clicked, int value is XOR'd at that address. Acts as a [checkbox].

Parameter Description
form->type UI_BTNICN
form->ptr Pointer to the int value
form->value Bitmask for this button
form->icon Pointer to an ui_image_t struct