6 Struct N_GUI_GRID_CALLBACKS
gullradriel edited this page 2026-10-12 07:59:13 +02:00

N_GUI_GRID_CALLBACKS

Module: GUI GRID: a virtualised, vertically scrolled grid

What the grid asks of its caller. More...

#include "n_gui_grid.h"

Public Attributes

Name
int(*)(int widget_id, int dz, int modifiers, void *user_data) wheel
A wheel turn of dz notches over the grid, positive away from the user, with the modifier keys held (ALLEGRO_KEYMOD_* ORed, see n_gui_get_key_modifiers()).
void(*)(int widget_id, size_t first, size_t last, void *user_data) visible
Called after each draw with the cells drawn and one row beyond, first included and last excluded: what to have ready.
void(*)(int widget_id, size_t index, int button, float x, float y, void *user_data) press
A press of button (1 or 2) on cell index, at screen x, y.
void(*)(int widget_id, size_t index, float x, float y, float w, float h, void *user_data) draw_cell
Draw cell index in the box at x, y, w by h, on screen.
void(*)(int widget_id, float x, float y, float w, float h, void *user_data) draw_background
Draw behind the cells, over the whole grid, before any cell; with no cells, the only thing drawn.

Detailed Description

struct N_GUI_GRID_CALLBACKS;

What the grid asks of its caller.

Only draw_cell is required.

Public Attributes Documentation

variable wheel

int(*)(int widget_id, int dz, int modifiers, void *user_data) wheel;

A wheel turn of dz notches over the grid, positive away from the user, with the modifier keys held (ALLEGRO_KEYMOD_* ORed, see n_gui_get_key_modifiers()).

Asked before the grid scrolls: return non-zero to take the turn, for a Ctrl+wheel zoom say, and the grid does not scroll; zero and it scrolls as usual. May be NULL.

variable visible

void(*)(int widget_id, size_t first, size_t last, void *user_data) visible;

Called after each draw with the cells drawn and one row beyond, first included and last excluded: what to have ready.

May be NULL.

variable press

void(*)(int widget_id, size_t index, int button, float x, float y, void *user_data) press;

A press of button (1 or 2) on cell index, at screen x, y.

Not called for a press between cells or past the last. May be NULL.

variable draw_cell

void(*)(int widget_id, size_t index, float x, float y, float w, float h, void *user_data) draw_cell;

Draw cell index in the box at x, y, w by h, on screen.

The clipping rectangle is the grid's, so a cell partly scrolled off is cut there.

variable draw_background

void(*)(int widget_id, float x, float y, float w, float h, void *user_data) draw_background;

Draw behind the cells, over the whole grid, before any cell; with no cells, the only thing drawn.

May be NULL.