Skip to content

Commit a9ba0b9

Browse files
apurvclaude
andcommitted
fw/timeline: scale the all-day pin's top offset with content size
The "All day" header in the timeline list sat flush against the top of the screen on Pebble Time 2, about 5 px higher than a timed pin's header. The offset that cancels TextStyleFont_Title's internal leading was a fixed -13. That font scales with the preferred content size (Gothic 24 at Medium, Gothic 28 at Large), so a value tuned against Medium over-corrects at Large. Pebble Time selects Medium and was always correct; Time 2 selects Large and lost 5 px. Switch the offset on content size, keeping -13 everywhere except large rect displays, which take -8 and land the header level with timed pins at y=9. Round centres its list layout vertically and is unaffected, so it keeps -13. There was no all-day coverage in the list-view suite at all, which is how this shipped. Add future and past all-day cases and enable the suite on asterix, which also exercises ten already-committed asterix goldens for the first time. Verified against stock firmware: only the two obelix goldens differ, by 468 px each; gabbro and asterix are byte-identical. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: apurv <pataniapurv@gmail.com>
1 parent 0f3e578 commit a9ba0b9

9 files changed

Lines changed: 38 additions & 2 deletions

src/fw/services/timeline/timeline_layout.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,14 @@ static GTextNode *prv_create_all_day_text_node(const TimelineLayout *layout) {
387387
.text.style_font = TextStyleFont_Title,
388388
.text.fixed_lines = 1,
389389
.text.alignment = PBL_IF_RECT_ELSE(LayoutTextAlignment_Left, LayoutTextAlignment_Right),
390-
.text.extent.offset.y = -13,
390+
// Cancels TextStyleFont_Title's internal leading. The font scales with content size but
391+
// this did not, leaving "All day" 5px high on large rect displays. Round centres its list
392+
// layout vertically, so it is unaffected and keeps the original value.
393+
.text.extent.offset.y = PREFERRED_CONTENT_SIZE_SWITCH(PreferredContentSizeDefault,
394+
/* small */ -13,
395+
/* medium */ -13,
396+
/* large */ PBL_IF_RECT_ELSE(-8, -13),
397+
/* extralarge */ PBL_IF_RECT_ELSE(-8, -13)),
391398
.text.extent.margin.h = -7,
392399
};
393400
GTextNodeText *text_node =

tests/fw/apps/system_apps/timeline/test_timeline_list_view.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ typedef struct TimelineItemConfig {
3737
const char *title;
3838
const char *subtitle;
3939
TimelineResourceId icon;
40+
bool all_day;
4041
} TimelineItemConfig;
4142

4243
typedef struct ListViewConfig {
@@ -63,6 +64,7 @@ static void prv_add_timeline_item(const TimelineItemConfig *config, bool past) {
6364
&list, NULL);
6465
attribute_list_destroy_list(&list);
6566
PBL_ASSERTN(item);
67+
item->header.all_day = config->all_day;
6668
}
6769
if (item) {
6870
pin_db_insert_item(item);
@@ -252,3 +254,30 @@ void test_timeline_list_view__pin_and_fin_past(void) {
252254
FAKE_GRAPHICS_CONTEXT_CHECK_DEST_BITMAP_FILE();
253255
}
254256

257+
258+
void prv_create_and_render_all_day(bool past) {
259+
prv_create_list_view_and_render(&(ListViewConfig) {
260+
.pins = {
261+
&(TimelineItemConfig) {
262+
// Must sit further back than the duration, or the past view correctly excludes it
263+
// for still being in progress.
264+
.relative_timestamp = 2 * SECONDS_PER_DAY,
265+
.title = "Independence Day",
266+
.duration = MINUTES_PER_DAY,
267+
.icon = TIMELINE_RESOURCE_TIMELINE_CALENDAR,
268+
.all_day = true,
269+
}
270+
},
271+
.past = past,
272+
});
273+
}
274+
275+
void test_timeline_list_view__all_day_future(void) {
276+
prv_create_and_render_all_day(false /* past */);
277+
FAKE_GRAPHICS_CONTEXT_CHECK_DEST_BITMAP_FILE();
278+
}
279+
280+
void test_timeline_list_view__all_day_past(void) {
281+
prv_create_and_render_all_day(true /* past */);
282+
FAKE_GRAPHICS_CONTEXT_CHECK_DEST_BITMAP_FILE();
283+
}

tests/fw/apps/system_apps/timeline/wscript_build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ clar(ctx,
131131
defines=ctx.env.test_image_defines + ["USE_DISPLAY_PERIMETER_ON_FONT_LAYOUT=1"],
132132
runtime_deps=ctx.env.test_pngs + ctx.env.test_pbis + ctx.env.test_pfos,
133133
override_includes=['dummy_board'],
134-
platforms=['obelix', 'gabbro'])
134+
platforms=['obelix', 'gabbro', 'asterix'])
135135

136136
clar(ctx,
137137
sources_ant_glob=(
709 Bytes
Loading
2.84 KB
Loading
1.8 KB
Loading
709 Bytes
Loading
2.88 KB
Loading
1.8 KB
Loading

0 commit comments

Comments
 (0)