Refactored to use selection grid during round (#348)
* Added wrapping to selection grid * Added return value to on_selection_changed to allow aborting on wrap * Extracted button code to button.c/.h * Bounds checking changes for selection_grid_move_selection_horz() --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Rickey <ric@rf3.xyz>
This commit is contained in:
co-authored by
Copilot
Rickey
parent
b7cc3ec5d6
commit
5300846f73
@@ -37,9 +37,10 @@ typedef struct SelectionGrid SelectionGrid;
|
||||
* Contains the previous cursor position
|
||||
* @param new_selection Pointer to the Selection state after the change occurred.
|
||||
* Contains the new cursor position
|
||||
* @return false if the selection change needs to be aborted, true if can proceed.
|
||||
*
|
||||
*/
|
||||
typedef void (*RowOnSelectionChangedFunc)(
|
||||
typedef bool (*RowOnSelectionChangedFunc)(
|
||||
SelectionGrid* selection_grid,
|
||||
int row_idx,
|
||||
const Selection* prev_selection,
|
||||
@@ -71,6 +72,18 @@ typedef int (*RowGetSizeFunc)();
|
||||
*/
|
||||
typedef void (*RowOnKeyTransitFunc)(SelectionGrid* selection_grid, Selection* selection);
|
||||
|
||||
/**
|
||||
* @brief A set of attributes to the selection grid row affecting selection grid behavior.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Whether to wrap selection when it passes the end of the row.
|
||||
*/
|
||||
bool wrap;
|
||||
} SelGridRowAttributes;
|
||||
|
||||
/**
|
||||
* @brief A single row in the selection grid, defined by its callback functions.
|
||||
*
|
||||
@@ -82,6 +95,7 @@ struct SelectionGridRow
|
||||
RowGetSizeFunc get_size;
|
||||
RowOnSelectionChangedFunc on_selection_changed;
|
||||
RowOnKeyTransitFunc on_key_transit;
|
||||
SelGridRowAttributes attributes;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user