Skip to content

Commit f9e71e1

Browse files
jplexergmarull
authored andcommitted
fw: replace platform checks with display height for UI layout
Replace hardcoded PLATFORM_ROBERT/OBELIX/GETAFIX checks with display height checks (PBL_DISPLAY_HEIGHT >= 200) for all UI layout constants. This fixes inconsistencies where emulator was using different layout values than hardware despite having identical displays. This ensures consistent UI rendering across all platforms with the same display dimensions. Signed-off-by: Joshua Jun <joshuajun@proton.me>
1 parent 5bbbab7 commit f9e71e1

File tree

8 files changed

+33
-23
lines changed

8 files changed

+33
-23
lines changed

src/fw/applib/preferred_content_size.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
#pragma once
55

6+
#if !PUBLIC_SDK
7+
#include "board/display.h"
8+
#endif
9+
610
//! PreferredContentSize represents the display scale of all the app's UI components. The enum
711
//! contains all sizes that all platforms as a whole are capable of displaying, but each individual
812
//! platform may not be able to display all sizes.
@@ -17,8 +21,8 @@ typedef enum PreferredContentSize {
1721
} PreferredContentSize;
1822

1923
#if !PUBLIC_SDK
20-
//! TODO PBL-41920: This belongs in a platform specific location
21-
#if PLATFORM_ROBERT || PLATFORM_OBELIX || PLATFORM_GETAFIX
24+
//! Use display height to determine default content size: larger displays (>= 200px height) use Large
25+
#if PBL_DISPLAY_HEIGHT >= 200
2226
#define PreferredContentSizeDefault PreferredContentSizeLarge
2327
#else
2428
#define PreferredContentSizeDefault PreferredContentSizeMedium

src/fw/applib/ui/dialogs/simple_dialog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int prv_get_rendered_text_height(const char *text, const GRect *text_box)
5151

5252
static int prv_get_icon_top_margin(bool has_status_bar, int icon_height, int window_height) {
5353
const uint16_t status_layer_offset = has_status_bar ? 6 : 0;
54-
#if PLATFORM_ROBERT || PLATFORM_CALCULUS || PLATFORM_OBELIX || PLATFORM_GETAFIX
54+
#if PBL_DISPLAY_HEIGHT >= 200
5555
const uint16_t icon_top_default_margin_px = 42 + status_layer_offset;
5656
#else
5757
const uint16_t icon_top_default_margin_px = 18 + status_layer_offset;

src/fw/apps/core_apps/spinner_ui_window.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ static void prv_draw_spinner_circles(Layer *layer, GContext* ctx) {
5050
SpinnerUIData *data = window_get_user_data(layer_get_window(layer));
5151

5252
// This is the background image's circle.
53-
#if PLATFORM_ROBERT || PLATFORM_CALCULUS || PLATFORM_OBELIX
53+
// Only applies to rectangular displays >= 200px height (ROBERT, CALCULUS, OBELIX)
54+
#if PBL_DISPLAY_HEIGHT >= 200 && PBL_RECT
5455
const unsigned int center_of_circle_y_val = 103;
5556
#else
5657
const unsigned int center_of_circle_y_val = PBL_IF_RECT_ELSE(72, layer->bounds.size.h / 2);

src/fw/apps/system_apps/launcher/default/launcher_app_glance_settings.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static GTextNode *prv_create_subtitle_node(LauncherAppGlanceStructured *structur
206206
vertically_centered_battery_percent_text_node);
207207
}
208208

209-
#if PLATFORM_ROBERT || PLATFORM_OBELIX || PLATFORM_GETAFIX
209+
#if PBL_DISPLAY_HEIGHT >= 200
210210
const int16_t subtitle_icon_offset_y = 5;
211211
#else
212212
const int16_t subtitle_icon_offset_y = 2;

src/fw/apps/system_apps/launcher/default/launcher_app_glance_structured.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
#include "util/attributes.h"
1717
#include "util/string.h"
1818
#include "util/struct.h"
19+
#include "board/display.h"
1920

20-
#if PLATFORM_ROBERT || PLATFORM_OBELIX || PLATFORM_GETAFIX
21+
// Use display height to determine icon margins: larger displays use more margin
22+
#if PBL_DISPLAY_HEIGHT >= 200
2123
#define LAUNCHER_APP_GLANCE_STRUCTURED_ICON_HORIZONTAL_MARGIN (9)
2224
#else
2325
#define LAUNCHER_APP_GLANCE_STRUCTURED_ICON_HORIZONTAL_MARGIN (5)
@@ -347,7 +349,7 @@ static GTextNode *prv_create_structured_glance_title_subtitle_node(
347349
// We require a valid title node
348350
PBL_ASSERTN(title_node);
349351
// Push the title node a little up or down to match the relevant design spec
350-
#if PLATFORM_ROBERT || PLATFORM_OBELIX || PLATFORM_GETAFIX
352+
#if PBL_DISPLAY_HEIGHT >= 200
351353
title_node->offset.y += 1;
352354
#else
353355
title_node->offset.y -= 1;
@@ -423,8 +425,7 @@ static void prv_draw_processed(KinoReel *reel, GContext *ctx, GPoint offset,
423425
}
424426

425427
GRect glance_frame = (GRect) { .origin = offset, .size = structured_glance->glance.size };
426-
#if PLATFORM_GETAFIX
427-
// Create arc effect following the circular display edge
428+
#if PBL_ROUND && PBL_DISPLAY_HEIGHT >= 200
428429
// For a circle: x = R - sqrt(R^2 - (y - R)^2), where R = display_size / 2
429430
const int16_t radius = PBL_DISPLAY_HEIGHT / 2;
430431

@@ -442,7 +443,7 @@ static void prv_draw_processed(KinoReel *reel, GContext *ctx, GPoint offset,
442443
// Extra 2px shift for non-center rows to push content slightly more inward
443444
const int16_t base_inset = 10;
444445
const int16_t horizontal_inset = base_inset + circle_inset;
445-
#elif PLATFORM_ROBERT || PLATFORM_OBELIX
446+
#elif PBL_DISPLAY_HEIGHT >= 200 && PBL_RECT
446447
const int16_t horizontal_inset = 10;
447448
#else
448449
const int16_t horizontal_inset = PBL_IF_RECT_ELSE(6, 23);

src/fw/apps/system_apps/launcher/default/launcher_menu_layer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
#include "launcher_app_glance_service.h"
77

88
#include "process_management/app_menu_data_source.h"
9+
#include "board/display.h"
910

10-
#if PLATFORM_ROBERT || PLATFORM_OBELIX || PLATFORM_GETAFIX
11+
// Use display height to determine launcher fonts: larger displays use larger fonts
12+
#if PBL_DISPLAY_HEIGHT >= 200
1113
#define LAUNCHER_MENU_LAYER_TITLE_FONT (FONT_KEY_GOTHIC_24_BOLD)
1214
#define LAUNCHER_MENU_LAYER_SUBTITLE_FONT (FONT_KEY_GOTHIC_18)
1315
#else

src/fw/apps/system_apps/launcher/default/launcher_menu_layer_private.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@
44
#pragma once
55

66
#include "util/math.h"
7+
#include "board/display.h"
78

8-
#if PLATFORM_ROBERT || PLATFORM_OBELIX || PLATFORM_GETAFIX
9+
// Use display height to determine launcher cell height: larger displays use taller cells
10+
#if PBL_DISPLAY_HEIGHT >= 200
911
#define LAUNCHER_MENU_LAYER_CELL_RECT_CELL_HEIGHT (53)
1012
#else
1113
#define LAUNCHER_MENU_LAYER_CELL_RECT_CELL_HEIGHT (42)
1214
#endif
1315

14-
#if PLATFORM_GETAFIX
16+
#if PBL_ROUND && PBL_DISPLAY_HEIGHT >= 200
1517
#define LAUNCHER_MENU_LAYER_CELL_ROUND_FOCUSED_CELL_HEIGHT (55)
1618
#define LAUNCHER_MENU_LAYER_CELL_ROUND_UNFOCUSED_CELL_HEIGHT (45)
1719
#else
1820
#define LAUNCHER_MENU_LAYER_CELL_ROUND_FOCUSED_CELL_HEIGHT (52)
1921
#define LAUNCHER_MENU_LAYER_CELL_ROUND_UNFOCUSED_CELL_HEIGHT (38)
2022
#endif
2123

22-
#if PLATFORM_GETAFIX
24+
#if PBL_ROUND && PBL_DISPLAY_HEIGHT >= 200
2325
//! Two "unfocused" cells above and below one centered "focused" cell (5 total for larger display)
2426
#define LAUNCHER_MENU_LAYER_NUM_UNFOCUSED_ROWS_PER_SIDE (2)
2527
#define LAUNCHER_MENU_LAYER_NUM_VISIBLE_ROWS (5)

src/fw/popups/bluetooth_pairing_ui.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static void prv_update_text_layer_with_translation(TextLayer *text_layer,
117117
}
118118

119119
static void prv_update_prf_info_text_layers_text(BTPairingUIData *data) {
120-
#if PLATFORM_ROBERT || PLATFORM_CALCULUS || PLATFORM_OBELIX || PLATFORM_GETAFIX
120+
#if PBL_DISPLAY_HEIGHT >= 200
121121
const char *font_key_default = FONT_KEY_GOTHIC_28_BOLD;
122122
const char *font_key_japanese = FONT_KEY_MINCHO_24_PAIR;
123123
#else
@@ -262,7 +262,7 @@ static void prv_adjust_background_frame_for_state(BTPairingUIData *data) {
262262
switch (data->ui_state) {
263263
case BTPairingUIStateAwaitingUserConfirmation:
264264
alignment = GAlignTopLeft;
265-
#if PLATFORM_ROBERT || PLATFORM_CALCULUS || PLATFORM_OBELIX || PLATFORM_GETAFIX
265+
#if PBL_DISPLAY_HEIGHT >= 200
266266
x_offset = 39;
267267
y_offset = 85;
268268
#else
@@ -273,7 +273,7 @@ static void prv_adjust_background_frame_for_state(BTPairingUIData *data) {
273273
break;
274274
case BTPairingUIStateAwaitingResult:
275275
alignment = GAlignLeft;
276-
#if PLATFORM_ROBERT || PLATFORM_CALCULUS || PLATFORM_OBELIX || PLATFORM_GETAFIX
276+
#if PBL_DISPLAY_HEIGHT >= 200
277277
x_offset = 76;
278278
y_offset = 30;
279279
#else
@@ -285,7 +285,7 @@ static void prv_adjust_background_frame_for_state(BTPairingUIData *data) {
285285
case BTPairingUIStateFailed:
286286
case BTPairingUIStateSuccess:
287287
alignment = GAlignTop;
288-
#if PLATFORM_ROBERT || PLATFORM_CALCULUS || PLATFORM_OBELIX || PLATFORM_GETAFIX
288+
#if PBL_DISPLAY_HEIGHT >= 200
289289
x_offset = 0;
290290
y_offset = 59;
291291
#else
@@ -373,7 +373,7 @@ static void prv_window_load(Window *window) {
373373
const int32_t width_of_action_bar_with_padding = ACTION_BAR_WIDTH + PBL_IF_RECT_ELSE(2, -4);
374374
const int32_t width = window->layer.bounds.size.w - width_of_action_bar_with_padding;
375375
const int32_t x_offset = PBL_IF_RECT_ELSE(0, 22);
376-
#if PLATFORM_ROBERT || PLATFORM_CALCULUS || PLATFORM_OBELIX || PLATFORM_GETAFIX
376+
#if PBL_DISPLAY_HEIGHT >= 200
377377
const int32_t info_text_y_offset = 36;
378378
#else
379379
const int32_t info_text_y_offset = PBL_IF_RECT_ELSE(10, 12);
@@ -383,13 +383,13 @@ static void prv_window_load(Window *window) {
383383
kino_layer_init(kino_layer, &window->layer.bounds);
384384
layer_add_child(&window->layer, &kino_layer->layer);
385385

386-
#if PLATFORM_ROBERT || PLATFORM_CALCULUS || PLATFORM_OBELIX || PLATFORM_GETAFIX
386+
#if PBL_DISPLAY_HEIGHT >= 200
387387
GRect pair_text_area = GRect(0, -2, width, 44);
388388
#else
389389
GRect pair_text_area = GRect(0, -2, width, 30);
390390
#endif
391391

392-
#if PLATFORM_ROBERT || PLATFORM_CALCULUS || PLATFORM_OBELIX || PLATFORM_GETAFIX
392+
#if PBL_DISPLAY_HEIGHT >= 200
393393
layer_set_frame(&data->info_text_mask_layer, &GRect(x_offset, info_text_y_offset, width, 30));
394394
#else
395395
layer_set_frame(&data->info_text_mask_layer, &GRect(x_offset, info_text_y_offset, width, 26));
@@ -401,7 +401,7 @@ static void prv_window_load(Window *window) {
401401
text_layer_init_with_parameters(info_text_layer,
402402
&pair_text_area,
403403
data->info_text_layer_buffer,
404-
#if PLATFORM_ROBERT || PLATFORM_CALCULUS || PLATFORM_OBELIX || PLATFORM_GETAFIX
404+
#if PBL_DISPLAY_HEIGHT >= 200
405405
fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD),
406406
#else
407407
fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD),
@@ -423,7 +423,7 @@ static void prv_window_load(Window *window) {
423423

424424
prv_add_prf_layers(pair_text_area, data);
425425

426-
#if PLATFORM_ROBERT || PLATFORM_CALCULUS || PLATFORM_OBELIX || PLATFORM_GETAFIX
426+
#if PBL_DISPLAY_HEIGHT >= 200
427427
const int16_t y_offset = 55;
428428
#else
429429
const int16_t y_offset = PBL_IF_RECT_ELSE(0, 2);

0 commit comments

Comments
 (0)