GBAlatro
A Demake of Balatro for the GBA
Loading...
Searching...
No Matches
selection_grid.h
Go to the documentation of this file.
1
13#ifndef SELECTION_GRID_H
14#define SELECTION_GRID_H
15
16#include <tonc.h>
17
18typedef POINT Selection;
19
20struct SelectionGridRow;
21struct SelectionGrid;
23typedef struct SelectionGrid SelectionGrid;
24
44 SelectionGrid* selection_grid,
45 int row_idx,
46 const Selection* prev_selection,
47 const Selection* new_selection
48);
49
58typedef int (*RowGetSizeFunc)();
59
73typedef void (*RowOnKeyTransitFunc)(SelectionGrid* selection_grid, Selection* selection);
74
78typedef struct
79{
80
84 bool wrap;
85
91
97
104{
105 int row_idx;
106 RowGetSizeFunc get_size;
107 RowOnSelectionChangedFunc on_selection_changed;
108 RowOnKeyTransitFunc on_key_transit;
109 SelGridRowAttributes attributes;
110};
111
119{
120 const SelectionGridRow* rows;
121 const int num_rows;
122 Selection selection;
123};
124
135void selection_grid_process_input(SelectionGrid* selection_grid);
136
152void selection_grid_move_selection_horz(SelectionGrid* selection_grid, int direction_tribool);
153
168void selection_grid_move_selection_vert(SelectionGrid* selection_grid, int direction_tribool);
169
170#endif
void selection_grid_move_selection_vert(SelectionGrid *selection_grid, int direction_tribool)
Moves the selection vertically within the selection grid.
bool(* RowOnSelectionChangedFunc)(SelectionGrid *selection_grid, int row_idx, const Selection *prev_selection, const Selection *new_selection)
Callback function type for handling selection changes in a SelectionGrid.
void selection_grid_move_selection_horz(SelectionGrid *selection_grid, int direction_tribool)
Moves the selection horizontally within the selection grid.
int(* RowGetSizeFunc)()
Function pointer type for retrieving the size of a row in a selection grid.
void selection_grid_process_input(SelectionGrid *selection_grid)
Processes user input for the selection grid.
void(* RowOnKeyTransitFunc)(SelectionGrid *selection_grid, Selection *selection)
Callback function type for handling non-directional key presses in a selection grid row.
A set of attributes to the selection grid row affecting selection grid behavior.
bool has_h_exit_idx
Whether this row have a horizontal exit index (a row to process horizontal inputs from).
u8 h_exit_idx
The index of the row to exit from when a horizontal input is received.
bool wrap
Whether to wrap selection when it passes the end of the row.
The core selection grid struct, represents the grid itself and its state.