5 Struct N_GUI_BUTTON_DATA
gullradriel edited this page 2026-10-09 00:55:18 +02:00

N_GUI_BUTTON_DATA

Module: GUI: allegro5 widget system with pseudo-windows

button specific data

#include "n_gui.h"

Public Attributes

Name
void * user_data
user data for callback
int toggled
toggle state: 0 = off/unclicked, 1 = on/clicked (only used when toggle_mode=1)
int toggle_mode
toggle mode: 0 = momentary (default), 1 = toggle (stays clicked/unclicked)
int shape
shape type: N_GUI_SHAPE_RECT, N_GUI_SHAPE_ROUNDED, N_GUI_SHAPE_BITMAP
void(*)(int widget_id, void *user_data) on_click
callback on click (widget_id passed)
char[128] label
label displayed on the button
int keycode
bound keyboard keycode (0 = none).
int[8] key_sources
widget IDs that can trigger this focused key binding.
double key_press_until
absolute al_get_time() deadline until which the button is rendered in its pressed (N_GUI_STATE_ACTIVE) visual state after a keybind trigger.
int key_modifiers
required modifier key flags for the keybind (0 = no modifier requirement, matches any modifier state for backward compatibility).
int key_focus_only
if 1, keycode fires only when the button itself or a source widget has focus.
int glyph
N_GUI_GLYPH_* icon drawn centred in the button's text colour instead of the label (N_GUI_GLYPH_NONE, the default, draws the label).
ALLEGRO_BITMAP * bitmap_hover
optional bitmap for hover state
ALLEGRO_BITMAP * bitmap_active
optional bitmap for active/pressed state
ALLEGRO_BITMAP * bitmap
optional bitmap for the button (NULL = color theme)

Public Attributes Documentation

variable user_data

void * user_data;

user data for callback

variable toggled

int toggled;

toggle state: 0 = off/unclicked, 1 = on/clicked (only used when toggle_mode=1)

variable toggle_mode

int toggle_mode;

toggle mode: 0 = momentary (default), 1 = toggle (stays clicked/unclicked)

variable shape

int shape;

shape type: N_GUI_SHAPE_RECT, N_GUI_SHAPE_ROUNDED, N_GUI_SHAPE_BITMAP

variable on_click

void(*)(int widget_id, void *user_data) on_click;

callback on click (widget_id passed)

variable label

char[128] label;

label displayed on the button

variable keycode

int keycode;

bound keyboard keycode (0 = none).

When this key is pressed and no text input widget has focus, the button's on_click callback is triggered.

variable key_sources

int[8] key_sources;

widget IDs that can trigger this focused key binding.

Terminated by -1. Only used when key_focus_only == 1. Up to N_GUI_KEY_SOURCES_MAX entries.

variable key_press_until

double key_press_until;

absolute al_get_time() deadline until which the button is rendered in its pressed (N_GUI_STATE_ACTIVE) visual state after a keybind trigger.

0.0 = no pending key-press flash.

variable key_modifiers

int key_modifiers;

required modifier key flags for the keybind (0 = no modifier requirement, matches any modifier state for backward compatibility).

Use ALLEGRO_KEYMOD_SHIFT, ALLEGRO_KEYMOD_CTRL, ALLEGRO_KEYMOD_ALT, ALLEGRO_KEYMOD_ALTGR ORed together. When non-zero, only the specified modifier combination triggers the keybind (exact match on N_GUI_KEY_MOD_MASK bits).

variable key_focus_only

int key_focus_only;

if 1, keycode fires only when the button itself or a source widget has focus.

if 0 (default), keycode fires globally when no interactive widget has focus.

variable glyph

int glyph;

N_GUI_GLYPH_* icon drawn centred in the button's text colour instead of the label (N_GUI_GLYPH_NONE, the default, draws the label).

Set with n_gui_button_set_glyph. The label is kept and is still a good place for a tooltip-free accessible name.

variable bitmap_hover

ALLEGRO_BITMAP * bitmap_hover;

optional bitmap for hover state

variable bitmap_active

ALLEGRO_BITMAP * bitmap_active;

optional bitmap for active/pressed state

variable bitmap

ALLEGRO_BITMAP * bitmap;

optional bitmap for the button (NULL = color theme)