Skip to content

Commit e15c7f4

Browse files
committed
ui: shorten home screen device title
1 parent 36776fe commit e15c7f4

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

main/gui.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ static void make_status_bar(void)
150150
#if HOME_SCREEN_DEEP_STATUS_BAR
151151
// Make an hsplit for the logo on the left, and info on the right
152152
gui_view_node_t* hsplit;
153-
gui_make_hsplit(&hsplit, GUI_SPLIT_RELATIVE, 2, 65, 35);
153+
gui_make_hsplit(&hsplit, GUI_SPLIT_RELATIVE, 2, 100 - HOME_SCREEN_STATUS_BAR_TITLE_WIDTH_PERCENT,
154+
HOME_SCREEN_STATUS_BAR_TITLE_WIDTH_PERCENT);
154155
gui_set_padding(hsplit, GUI_MARGIN_ALL_DIFFERENT, 0, 2, 0, 2);
155156
gui_set_parent(hsplit, status_bar.root);
156157

@@ -175,7 +176,7 @@ static void make_status_bar(void)
175176
name_alignment = GUI_ALIGN_RIGHT;
176177
#else
177178
// Make an hsplit for the icon, name, and status icons
178-
gui_make_hsplit(&status_parent, GUI_SPLIT_RELATIVE, 5, 10, 57, 8, 8, 17);
179+
gui_make_hsplit(&status_parent, GUI_SPLIT_RELATIVE, 5, 10, HOME_SCREEN_STATUS_BAR_TITLE_WIDTH_PERCENT, 8, 8, 17);
179180
gui_set_padding(status_parent, GUI_MARGIN_ALL_DIFFERENT, 3, 0, 0, 4);
180181
gui_set_parent(status_parent, status_bar.root);
181182

main/gui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ extern uint8_t GUI_DEFAULT_FONT;
4343

4444
// Whether to use a deep status bar on the home screen, better suited to larger displays
4545
#define HOME_SCREEN_DEEP_STATUS_BAR (CONFIG_DISPLAY_HEIGHT >= 170)
46+
#define HOME_SCREEN_STATUS_BAR_TITLE_WIDTH_PERCENT (HOME_SCREEN_DEEP_STATUS_BAR ? 35 : 57)
4647

4748
// Fill all the remaining space in an {h,v}split
4849
#define GUI_SPLIT_FILL_REMAINING 0xFF

main/ui/dashboard.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#ifndef AMALGAMATED_BUILD
2+
#include <string.h>
3+
24
#include "../button_events.h"
35
#include "../display.h"
46
#include "../jade_assert.h"
@@ -47,6 +49,21 @@ static gui_view_node_t* make_home_screen_panel_item(const color_t color, home_me
4749
return item;
4850
}
4951

52+
static const char* get_home_screen_title(const char* device_name)
53+
{
54+
// Match the status-bar title column width from make_status_bar().
55+
const int title_width = (CONFIG_DISPLAY_WIDTH * HOME_SCREEN_STATUS_BAR_TITLE_WIDTH_PERCENT) / 100;
56+
57+
display_set_font(GUI_TITLE_FONT);
58+
if (display_get_string_width(device_name) <= title_width
59+
|| strncmp(device_name, "Jade ", strlen("Jade ")) != 0) {
60+
return device_name;
61+
}
62+
63+
// Remove "Jade " prefix to allow the device ID to be shown.
64+
return device_name + strlen("Jade ");
65+
}
66+
5067
gui_activity_t* make_home_screen_activity(const char* device_name, const char* firmware_version,
5168
home_menu_entry_t* selected_entry, home_menu_entry_t* next_entry, gui_view_node_t** status_light,
5269
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
6279
// NOTE: The home screen is created as an 'unmanaged' activity as
6380
// its lifetime is same as that of the entire application
6481
gui_activity_t* act = NULL;
65-
gui_make_activity_ex(&act, true, device_name, false);
82+
gui_make_activity_ex(&act, true, get_home_screen_title(device_name), false);
6683
JADE_ASSERT(act);
6784

6885
gui_view_node_t* node;

0 commit comments

Comments
 (0)