@@ -31,7 +31,7 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
3131 settingsController {settingsController} {
3232
3333 // This is the distance (padding) between all objects on this screen.
34- const int innerDistance = 10 ;
34+ static constexpr uint8_t innerDistance = 10 ;
3535
3636 // Time
3737 label_time = lv_label_create (lv_scr_act (), nullptr );
@@ -43,16 +43,22 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
4343 lv_label_set_text (batteryIcon, BatteryIcon::GetBatteryIcon (batteryController.PercentRemaining ()));
4444 lv_obj_align (batteryIcon, nullptr , LV_ALIGN_IN_TOP_RIGHT, 0 , 0 );
4545
46+ static constexpr uint8_t barHeight = 20 + innerDistance;
47+ static constexpr uint8_t buttonHeight = (LV_VER_RES_MAX - barHeight - innerDistance) / 2 ;
48+ static constexpr uint8_t buttonWidth = (LV_HOR_RES_MAX - innerDistance) / 2 ; // wide buttons
49+ // static constexpr uint8_t buttonWidth = buttonHeight; // square buttons
50+ static constexpr uint8_t buttonXOffset = (LV_HOR_RES_MAX - buttonWidth * 2 - innerDistance) / 2 ;
51+
4652 lv_style_init (&btn_style);
47- lv_style_set_radius (&btn_style, LV_STATE_DEFAULT, (LV_VER_RES - 20 - 2 * innerDistance) / 8 );
53+ lv_style_set_radius (&btn_style, LV_STATE_DEFAULT, buttonHeight / 4 );
4854 lv_style_set_bg_color (&btn_style, LV_STATE_DEFAULT, lv_color_hex (0x111111 ));
4955
5056 btn1 = lv_btn_create (lv_scr_act (), nullptr );
5157 btn1->user_data = this ;
5258 lv_obj_set_event_cb (btn1, ButtonEventHandler);
5359 lv_obj_add_style (btn1, LV_BTN_PART_MAIN, &btn_style);
54- lv_obj_set_size (btn1, (LV_HOR_RES - innerDistance) / 2 , (LV_VER_RES - 20 - 2 * innerDistance) / 2 );
55- lv_obj_align (btn1, nullptr , LV_ALIGN_IN_TOP_LEFT, 0 , 20 + innerDistance );
60+ lv_obj_set_size (btn1, buttonWidth, buttonHeight );
61+ lv_obj_align (btn1, nullptr , LV_ALIGN_IN_TOP_LEFT, buttonXOffset, barHeight );
5662
5763 btn1_lvl = lv_label_create (btn1, nullptr );
5864 lv_obj_set_style_local_text_font (btn1_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
@@ -62,8 +68,8 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
6268 btn2->user_data = this ;
6369 lv_obj_set_event_cb (btn2, ButtonEventHandler);
6470 lv_obj_add_style (btn2, LV_BTN_PART_MAIN, &btn_style);
65- lv_obj_set_size (btn2, (LV_HOR_RES - innerDistance) / 2 , (LV_VER_RES - 20 - 2 * innerDistance) / 2 );
66- lv_obj_align (btn2, nullptr , LV_ALIGN_IN_TOP_RIGHT, 0 , 20 + innerDistance );
71+ lv_obj_set_size (btn2, buttonWidth, buttonHeight );
72+ lv_obj_align (btn2, nullptr , LV_ALIGN_IN_TOP_RIGHT, - buttonXOffset, barHeight );
6773
6874 lv_obj_t * lbl_btn;
6975 lbl_btn = lv_label_create (btn2, nullptr );
@@ -76,8 +82,8 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
7682 lv_btn_set_checkable (btn3, true );
7783 lv_obj_add_style (btn3, LV_BTN_PART_MAIN, &btn_style);
7884 lv_obj_set_style_local_bg_color (btn3, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_GREEN);
79- lv_obj_set_size (btn3, (LV_HOR_RES - innerDistance) / 2 , (LV_VER_RES - 20 - 2 * innerDistance) / 2 );
80- lv_obj_align (btn3, nullptr , LV_ALIGN_IN_BOTTOM_LEFT, 0 , 0 );
85+ lv_obj_set_size (btn3, buttonWidth, buttonHeight );
86+ lv_obj_align (btn3, nullptr , LV_ALIGN_IN_BOTTOM_LEFT, buttonXOffset , 0 );
8187
8288 btn3_lvl = lv_label_create (btn3, nullptr );
8389 lv_obj_set_style_local_text_font (btn3_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
@@ -93,8 +99,8 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app,
9399 btn4->user_data = this ;
94100 lv_obj_set_event_cb (btn4, ButtonEventHandler);
95101 lv_obj_add_style (btn4, LV_BTN_PART_MAIN, &btn_style);
96- lv_obj_set_size (btn4, (LV_HOR_RES - innerDistance) / 2 , (LV_VER_RES - 20 - 2 * innerDistance) / 2 );
97- lv_obj_align (btn4, nullptr , LV_ALIGN_IN_BOTTOM_RIGHT, 0 , 0 );
102+ lv_obj_set_size (btn4, buttonWidth, buttonHeight );
103+ lv_obj_align (btn4, nullptr , LV_ALIGN_IN_BOTTOM_RIGHT, - buttonXOffset , 0 );
98104
99105 lbl_btn = lv_label_create (btn4, nullptr );
100106 lv_obj_set_style_local_text_font (lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48);
0 commit comments