From 73c856393b66ae64bc0f0c70cf80d9d4a16c75fc Mon Sep 17 00:00:00 2001 From: "Jamie C. Driver" Date: Tue, 11 Feb 2025 11:06:20 +0000 Subject: [PATCH] gui: update where uint8_t type is used in gui display code A single byte is not sufficient for screen dimensions of larger devices --- main/gui.c | 14 +++++++------- main/gui.h | 11 +++++------ main/ui/dialogs.c | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/main/gui.c b/main/gui.c index 6c16e07a..e49a4d78 100644 --- a/main/gui.c +++ b/main/gui.c @@ -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); @@ -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); @@ -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; @@ -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: @@ -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) { diff --git a/main/gui.h b/main/gui.h index b032d444..d2dd90fe 100644 --- a/main/gui.h +++ b/main/gui.h @@ -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; @@ -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; }; @@ -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; @@ -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); diff --git a/main/ui/dialogs.c b/main/ui/dialogs.c index a21e311e..4d91e8bf 100644 --- a/main/ui/dialogs.c +++ b/main/ui/dialogs.c @@ -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)