Skip to content

Commit

Permalink
gui: update where uint8_t type is used in gui display code
Browse files Browse the repository at this point in the history
A single byte is not sufficient for screen dimensions of larger devices
  • Loading branch information
JamieDriver committed Feb 11, 2025
1 parent 26bcd1a commit 73c8563
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
14 changes: 7 additions & 7 deletions main/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -997,17 +997,17 @@ static void make_split_node(
data->parts = parts;

// copy the values
data->values = JADE_CALLOC(1, sizeof(uint8_t) * parts);
data->values = JADE_CALLOC(1, sizeof(uint16_t) * parts);

for (uint8_t i = 0; i < parts; ++i) {
data->values[i] = va_arg(values, uint32_t);
data->values[i] = (uint16_t)va_arg(values, uint32_t);
};

// ... and also set a destructor to free them later
make_view_node(ptr, split_kind, data, free_view_node_split_data);
}

void gui_make_hsplit(gui_view_node_t** ptr, enum gui_split_type kind, uint32_t parts, ...)
void gui_make_hsplit(gui_view_node_t** ptr, enum gui_split_type kind, uint8_t parts, ...)
{
JADE_INIT_OUT_PPTR(ptr);

Expand All @@ -1017,7 +1017,7 @@ void gui_make_hsplit(gui_view_node_t** ptr, enum gui_split_type kind, uint32_t p
va_end(args);
}

void gui_make_vsplit(gui_view_node_t** ptr, enum gui_split_type kind, uint32_t parts, ...)
void gui_make_vsplit(gui_view_node_t** ptr, enum gui_split_type kind, uint8_t parts, ...)
{
JADE_INIT_OUT_PPTR(ptr);

Expand Down Expand Up @@ -1453,7 +1453,7 @@ static bool text_scroll_frame_callback(gui_view_node_t* node, void* extra_args)
// the string can fit entirely in its box, no need to scroll. we might need to reset stuff though, if the text has
// changed
if (can_text_fit(node->render_data.resolved_text, node->text->font, node->render_data.padded_constraints)) {
uint8_t old_offset = node->text->scroll->offset;
const size_t old_offset = node->text->scroll->offset;

// set offset to zero and wait a little before checking again
node->text->scroll->going_back = false;
Expand Down Expand Up @@ -1686,7 +1686,7 @@ void gui_update_picture(gui_view_node_t* node, const Picture* picture, const boo
}
}

static inline color_t DEBUG_COLOR(uint8_t depth)
static inline color_t DEBUG_COLOR(const uint8_t depth)
{
switch (depth) {
case 0:
Expand Down Expand Up @@ -1910,7 +1910,7 @@ static void render_text(gui_view_node_t* node, dispWin_t cs)
} else {
// normal print with wrap
if (node->text->noise) { // with noise
color_t color = node->is_selected ? node->text->selected_color : node->text->color;
const color_t color = node->is_selected ? node->text->selected_color : node->text->color;

int pos_x = 0;
switch (node->text->halign) {
Expand Down
11 changes: 5 additions & 6 deletions main/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "jlocale.h"

extern color_t _fg;
extern uint8_t text_wrap;

// Additional colour tokens
extern const color_t GUI_BLOCKSTREAM_JADE_GREEN;
Expand Down Expand Up @@ -195,7 +194,7 @@ struct view_node_split_data {
// type of split
enum gui_split_type kind;
// their values
uint8_t* values;
uint16_t* values;
// how many parts
uint8_t parts;
};
Expand All @@ -217,9 +216,9 @@ struct view_node_text_scroll_data {
bool going_back;

// chars to skip
uint8_t offset;
size_t offset;
// chars we skipped the last time we rendered it
uint8_t prev_offset;
size_t prev_offset;
// iterations left to wait here (without moving the text)
// used when we reach one end of the string and we want to wait a while there
uint8_t wait;
Expand Down Expand Up @@ -416,8 +415,8 @@ gui_activity_t* gui_make_activity(void);

void gui_set_parent(gui_view_node_t* child, gui_view_node_t* parent);
void gui_chain_activities(const link_activity_t* link_act, linked_activities_info_t* pActInfo);
void gui_make_hsplit(gui_view_node_t** ptr, enum gui_split_type kind, uint32_t parts, ...);
void gui_make_vsplit(gui_view_node_t** ptr, enum gui_split_type kind, uint32_t parts, ...);
void gui_make_hsplit(gui_view_node_t** ptr, enum gui_split_type kind, uint8_t parts, ...);
void gui_make_vsplit(gui_view_node_t** ptr, enum gui_split_type kind, uint8_t parts, ...);
void gui_make_button(gui_view_node_t** ptr, color_t color, color_t selected_color, uint32_t event_id, void* args);
void gui_make_fill(gui_view_node_t** ptr, color_t color);
void gui_make_text(gui_view_node_t** ptr, const char* text, color_t color);
Expand Down
2 changes: 1 addition & 1 deletion main/ui/dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ gui_view_node_t* make_even_split(const ui_button_layout_t layout, const uint8_t
// num_splits range asserted in switch below

// Make the split relevant for the number of buttons
typedef void (*make_split_fn)(gui_view_node_t * *ptr, enum gui_split_type kind, uint32_t parts, ...);
typedef void (*make_split_fn)(gui_view_node_t * *ptr, enum gui_split_type kind, uint8_t parts, ...);
make_split_fn make_split = (layout == UI_COLUMN) ? gui_make_vsplit : gui_make_hsplit;

// Make a split for the number of buttons (if greater than one)
Expand Down

0 comments on commit 73c8563

Please sign in to comment.