![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
A virtualised grid of cells for N_GUI, scrolled vertically. More...
Go to the source code of this file.
Data Structures | |
| struct | N_GUI_GRID_CALLBACKS |
| What the grid asks of its caller. More... | |
Functions | |
| int | n_gui_grid_cell_rect (N_GUI_CTX *ctx, int widget_id, size_t index, float *x, float *y, float *w, float *h) |
| Where a cell is on screen, whether or not it is scrolled into view. | |
| int | n_gui_grid_columns (N_GUI_CTX *ctx, int widget_id) |
| How many cells a row holds at the grid's width. | |
| float | n_gui_grid_get_scroll (N_GUI_CTX *ctx, int widget_id) |
| The scroll offset, in pixels from the top of the content. | |
| int | n_gui_grid_index_at (N_GUI_CTX *ctx, int widget_id, float x, float y, size_t *index) |
| Which cell is at a point on screen. | |
| int | n_gui_grid_new (N_GUI_CTX *ctx, int window_id, const N_GUI_GRID_CALLBACKS *callbacks, void *user_data) |
| Add a grid, and its scrollbar, to a window. | |
| void | n_gui_grid_scroll_to (N_GUI_CTX *ctx, int widget_id, size_t index) |
| Scroll the least that brings a cell's whole row into view. | |
| int | n_gui_grid_scrollbar (N_GUI_CTX *ctx, int widget_id) |
| The grid's scrollbar widget. | |
| int | n_gui_grid_scrollbar_showing (N_GUI_CTX *ctx, int widget_id) |
| Whether the scrollbar is shown, which is whether the rows overflow. | |
| void | n_gui_grid_set_cell_size (N_GUI_CTX *ctx, int widget_id, float cell_w, float cell_h, float gap) |
| Set the size of a cell and the gap around cells. | |
| void | n_gui_grid_set_count (N_GUI_CTX *ctx, int widget_id, size_t count) |
| Set how many cells there are. | |
| void | n_gui_grid_set_rect (N_GUI_CTX *ctx, int widget_id, float x, float y, float w, float h, float bar_w) |
| Place the grid and its scrollbar in a rectangle of the window. | |
| void | n_gui_grid_set_scroll (N_GUI_CTX *ctx, int widget_id, float scroll) |
| Set the scroll offset, clamped to the content. | |
| void | n_gui_grid_set_visible (N_GUI_CTX *ctx, int widget_id, int visible) |
| Show or hide the grid and its scrollbar together. | |
A virtualised grid of cells for N_GUI, scrolled vertically.
An icon view: a file manager, an asset browser, a sprite picker. Cells of one size are laid out in as many columns as the width holds and as many rows as the count needs, and only the cells on screen are drawn, so ten thousand cells cost what thirty do.
The grid owns the geometry and the scrolling: the columns, the scroll offset (in pixels, so a view can stop anywhere, and clamped so it never shows past the end), the wheel (one row a notch), a vertical scrollbar it places beside itself and shows only when the rows do not fit, "scroll so this cell is visible", and which cell is under a point.
The caller owns everything that is about the content, through callbacks: what a cell looks like, including any cursor or selection it wants to show, what is drawn behind the cells or when there are none, what to prepare when a range becomes visible, and what a press on a cell does. Keys are the caller's too: move a cursor, then n_gui_grid_scroll_to().
Built on a custom widget with n_gui_custom_set_mouse() and n_gui_custom_set_destroy(); the grid's state is the widget's.
Definition in file n_gui_grid.h.