Skip to content

Commit 28f9c6d

Browse files
committed
Moved all objects (rows) into a container
Moving the objects (rows of text) to a container removes the need to individually position each one. This also allows for easily adding and removing objects in the future without needing to reposition the others.
1 parent f51685d commit 28f9c6d

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/displayapp/screens/WatchFaceTerminal.cpp

+17-18
Original file line numberDiff line numberDiff line change
@@ -28,44 +28,43 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController,
2828
heartRateController {heartRateController},
2929
motionController {motionController} {
3030

31-
notificationIcon = lv_label_create(lv_scr_act(), nullptr);
32-
lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -90);
31+
container = lv_cont_create(lv_scr_act(), nullptr);
32+
lv_cont_set_layout(container, LV_LAYOUT_COLUMN_LEFT);
33+
lv_cont_set_fit(container, LV_FIT_TIGHT);
34+
lv_obj_set_style_local_pad_inner(container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, -3);
35+
lv_obj_set_style_local_bg_opa(container, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
3336

34-
label_prompt_1 = lv_label_create(lv_scr_act(), nullptr);
37+
notificationIcon = lv_label_create(container, nullptr);
38+
39+
label_prompt_1 = lv_label_create(container, nullptr);
3540
lv_obj_set_style_local_text_color(label_prompt_1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
36-
lv_obj_align(label_prompt_1, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -70);
3741
lv_label_set_text_static(label_prompt_1, "user@watch:~ $ now");
3842

39-
label_time = lv_label_create(lv_scr_act(), nullptr);
43+
label_time = lv_label_create(container, nullptr);
4044
lv_label_set_recolor(label_time, true);
41-
lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -50);
4245

43-
label_date = lv_label_create(lv_scr_act(), nullptr);
46+
label_date = lv_label_create(container, nullptr);
4447
lv_label_set_recolor(label_date, true);
45-
lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -30);
4648

47-
batteryValue = lv_label_create(lv_scr_act(), nullptr);
49+
batteryValue = lv_label_create(container, nullptr);
4850
lv_label_set_recolor(batteryValue, true);
49-
lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -10);
5051

51-
stepValue = lv_label_create(lv_scr_act(), nullptr);
52+
stepValue = lv_label_create(container, nullptr);
5253
lv_label_set_recolor(stepValue, true);
5354
lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
54-
lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 10);
5555

56-
heartbeatValue = lv_label_create(lv_scr_act(), nullptr);
56+
heartbeatValue = lv_label_create(container, nullptr);
5757
lv_label_set_recolor(heartbeatValue, true);
58-
lv_obj_align(heartbeatValue, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 30);
5958

60-
connectState = lv_label_create(lv_scr_act(), nullptr);
59+
connectState = lv_label_create(container, nullptr);
6160
lv_label_set_recolor(connectState, true);
62-
lv_obj_align(connectState, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 50);
6361

64-
label_prompt_2 = lv_label_create(lv_scr_act(), nullptr);
62+
label_prompt_2 = lv_label_create(container, nullptr);
6563
lv_obj_set_style_local_text_color(label_prompt_2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
66-
lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 70);
6764
lv_label_set_text_static(label_prompt_2, "user@watch:~ $");
6865

66+
lv_obj_align(container, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 20);
67+
6968
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
7069
Refresh();
7170
}

src/displayapp/screens/WatchFaceTerminal.h

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ namespace Pinetime {
4747
Utility::DirtyValue<bool> notificationState {};
4848
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
4949

50+
lv_obj_t* container;
5051
lv_obj_t* notificationIcon;
5152
lv_obj_t* label_prompt_1;
5253
lv_obj_t* label_time;

0 commit comments

Comments
 (0)