From e15c7f47091529c0e3b0a33ba5612ae806e22118 Mon Sep 17 00:00:00 2001 From: oroderico Date: Sat, 11 Jul 2026 01:16:52 -0400 Subject: [PATCH] ui: shorten home screen device title --- main/gui.c | 5 +++-- main/gui.h | 1 + main/ui/dashboard.c | 19 ++++++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/main/gui.c b/main/gui.c index 4c6b3ef2..1dec77d1 100644 --- a/main/gui.c +++ b/main/gui.c @@ -150,7 +150,8 @@ static void make_status_bar(void) #if HOME_SCREEN_DEEP_STATUS_BAR // Make an hsplit for the logo on the left, and info on the right gui_view_node_t* hsplit; - gui_make_hsplit(&hsplit, GUI_SPLIT_RELATIVE, 2, 65, 35); + gui_make_hsplit(&hsplit, GUI_SPLIT_RELATIVE, 2, 100 - HOME_SCREEN_STATUS_BAR_TITLE_WIDTH_PERCENT, + HOME_SCREEN_STATUS_BAR_TITLE_WIDTH_PERCENT); gui_set_padding(hsplit, GUI_MARGIN_ALL_DIFFERENT, 0, 2, 0, 2); gui_set_parent(hsplit, status_bar.root); @@ -175,7 +176,7 @@ static void make_status_bar(void) name_alignment = GUI_ALIGN_RIGHT; #else // Make an hsplit for the icon, name, and status icons - gui_make_hsplit(&status_parent, GUI_SPLIT_RELATIVE, 5, 10, 57, 8, 8, 17); + gui_make_hsplit(&status_parent, GUI_SPLIT_RELATIVE, 5, 10, HOME_SCREEN_STATUS_BAR_TITLE_WIDTH_PERCENT, 8, 8, 17); gui_set_padding(status_parent, GUI_MARGIN_ALL_DIFFERENT, 3, 0, 0, 4); gui_set_parent(status_parent, status_bar.root); diff --git a/main/gui.h b/main/gui.h index 96e4f662..5cb44a2d 100644 --- a/main/gui.h +++ b/main/gui.h @@ -43,6 +43,7 @@ extern uint8_t GUI_DEFAULT_FONT; // Whether to use a deep status bar on the home screen, better suited to larger displays #define HOME_SCREEN_DEEP_STATUS_BAR (CONFIG_DISPLAY_HEIGHT >= 170) +#define HOME_SCREEN_STATUS_BAR_TITLE_WIDTH_PERCENT (HOME_SCREEN_DEEP_STATUS_BAR ? 35 : 57) // Fill all the remaining space in an {h,v}split #define GUI_SPLIT_FILL_REMAINING 0xFF diff --git a/main/ui/dashboard.c b/main/ui/dashboard.c index 2001468c..02773127 100644 --- a/main/ui/dashboard.c +++ b/main/ui/dashboard.c @@ -1,4 +1,6 @@ #ifndef AMALGAMATED_BUILD +#include + #include "../button_events.h" #include "../display.h" #include "../jade_assert.h" @@ -47,6 +49,21 @@ static gui_view_node_t* make_home_screen_panel_item(const color_t color, home_me return item; } +static const char* get_home_screen_title(const char* device_name) +{ + // Match the status-bar title column width from make_status_bar(). + const int title_width = (CONFIG_DISPLAY_WIDTH * HOME_SCREEN_STATUS_BAR_TITLE_WIDTH_PERCENT) / 100; + + display_set_font(GUI_TITLE_FONT); + if (display_get_string_width(device_name) <= title_width + || strncmp(device_name, "Jade ", strlen("Jade ")) != 0) { + return device_name; + } + + // Remove "Jade " prefix to allow the device ID to be shown. + return device_name + strlen("Jade "); +} + gui_activity_t* make_home_screen_activity(const char* device_name, const char* firmware_version, home_menu_entry_t* selected_entry, home_menu_entry_t* next_entry, gui_view_node_t** status_light, gui_view_node_t** status_text, gui_view_node_t** label) @@ -62,7 +79,7 @@ gui_activity_t* make_home_screen_activity(const char* device_name, const char* f // NOTE: The home screen is created as an 'unmanaged' activity as // its lifetime is same as that of the entire application gui_activity_t* act = NULL; - gui_make_activity_ex(&act, true, device_name, false); + gui_make_activity_ex(&act, true, get_home_screen_title(device_name), false); JADE_ASSERT(act); gui_view_node_t* node;