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

N_GUI_LISTBOX_DATA

Module: GUI: allegro5 widget system with pseudo-windows

listbox specific data

#include "n_gui.h"

Public Attributes

Name
void * user_data
user data for callback
int selection_mode
selection mode: N_GUI_SELECT_NONE, N_GUI_SELECT_SINGLE, N_GUI_SELECT_MULTIPLE
int scroll_offset
scroll offset in items
void(*)(int widget_id, int index, int selected, void *user_data) on_select
callback on selection change (widget_id, item_index, selected, user_data)
size_t nb_items
number of items
size_t items_capacity
allocated capacity
N_GUI_LISTITEM * items
dynamic array of items
ALLEGRO_BITMAP * item_selected_bitmap
optional bitmap for per-item background, selected/highlighted (NULL = color theme)
float item_height
item height in pixels
ALLEGRO_BITMAP * item_bg_bitmap
optional bitmap for per-item background, normal state (NULL = color theme)
int hover_row
index of the row the mouse is currently over, or -1.
int h_scroll_dragging
1 while the user is dragging the horizontal scrollbar thumb, so the shared scrollbar-drag handler routes the drag to h_scroll rather than to the vertical scroll position.
float h_scroll
horizontal scroll offset in pixels: how far the item text is scrolled to the left when the widest item is wider than the widget.
ALLEGRO_BITMAP * bg_bitmap
optional bitmap for the listbox background (NULL = color theme)

Public Attributes Documentation

variable user_data

void * user_data;

user data for callback

variable selection_mode

int selection_mode;

selection mode: N_GUI_SELECT_NONE, N_GUI_SELECT_SINGLE, N_GUI_SELECT_MULTIPLE

variable scroll_offset

int scroll_offset;

scroll offset in items

variable on_select

void(*)(int widget_id, int index, int selected, void *user_data) on_select;

callback on selection change (widget_id, item_index, selected, user_data)

variable nb_items

size_t nb_items;

number of items

variable items_capacity

size_t items_capacity;

allocated capacity

variable items

N_GUI_LISTITEM * items;

dynamic array of items

variable item_selected_bitmap

ALLEGRO_BITMAP * item_selected_bitmap;

optional bitmap for per-item background, selected/highlighted (NULL = color theme)

variable item_height

float item_height;

item height in pixels

variable item_bg_bitmap

ALLEGRO_BITMAP * item_bg_bitmap;

optional bitmap for per-item background, normal state (NULL = color theme)

variable hover_row

int hover_row;

index of the row the mouse is currently over, or -1.

Updated in the event loop when the widget gains N_GUI_STATE_HOVER; consumed by the draw path to paint a hover highlight.

variable h_scroll_dragging

int h_scroll_dragging;

1 while the user is dragging the horizontal scrollbar thumb, so the shared scrollbar-drag handler routes the drag to h_scroll rather than to the vertical scroll position.

variable h_scroll

float h_scroll;

horizontal scroll offset in pixels: how far the item text is scrolled to the left when the widest item is wider than the widget.

0 = leftmost. A horizontal scrollbar is drawn (and the text stops being truncated with an ellipsis) only while the content overflows.

variable bg_bitmap

ALLEGRO_BITMAP * bg_bitmap;

optional bitmap for the listbox background (NULL = color theme)