Skip to content

Commit

Permalink
Fix startup, shutdown and full screen dialog layouts.
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz committed Dec 16, 2024
1 parent 02530c8 commit b5ffd62
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 30 deletions.
6 changes: 3 additions & 3 deletions radio/src/gui/colorlcd/libui/fullscreen_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void FullScreenDialog::build()

if (!action.empty()) {
auto btn = new TextButton(
this, {(LCD_W - 280) / 2, LCD_H - 48, 280, 40}, action.c_str(),
this, {(LCD_W - ONEBTN_W) / 2, LCD_H - ONEBTN_H - PAD_LARGE, ONEBTN_W, ONEBTN_H}, action.c_str(),
[=]() {
closeDialog();
return 0;
Expand All @@ -116,15 +116,15 @@ void FullScreenDialog::build()
} else {
if (type == WARNING_TYPE_CONFIRM) {
auto btn = new TextButton(
this, {LCD_W / 3 - 50, LCD_H - 48, 100, 40}, STR_EXIT,
this, {LCD_W / 3 - TWOBTN_W / 2, LCD_H - TWOBTN_H - PAD_LARGE, TWOBTN_W, TWOBTN_H}, STR_EXIT,
[=]() {
deleteLater();
return 0;
});
etx_bg_color(btn->getLvObj(), COLOR_THEME_SECONDARY3_INDEX);
etx_txt_color(btn->getLvObj(), COLOR_THEME_PRIMARY1_INDEX);
btn = new TextButton(
this, {LCD_W * 2 / 3 - 50, LCD_H - 48, 100, 40}, STR_OK,
this, {LCD_W * 2 / 3 - TWOBTN_W / 2, LCD_H - TWOBTN_H - PAD_LARGE, TWOBTN_W, TWOBTN_H}, STR_OK,
[=]() {
closeDialog();
return 0;
Expand Down
4 changes: 4 additions & 0 deletions radio/src/gui/colorlcd/libui/fullscreen_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class FullScreenDialog : public Window
static LAYOUT_VAL(ALERT_TITLE_LEFT, 146, 140, LS(146))
static LAYOUT_VAL(ALERT_MESSAGE_TOP, ALERT_TITLE_TOP + 85, ALERT_TITLE_TOP + 130, ALERT_TITLE_TOP + LS(85))
static LAYOUT_VAL(ALERT_MESSAGE_LEFT, ALERT_TITLE_LEFT, 15, ALERT_TITLE_LEFT)
static LAYOUT_VAL(ONEBTN_W, 280, 280, LS(280))
static LAYOUT_VAL(ONEBTN_H, 40, 40, LS(40))
static LAYOUT_VAL(TWOBTN_W, 100, 100, LS(100))
static LAYOUT_VAL(TWOBTN_H, 40, 40, LS(40))

protected:
uint8_t type;
Expand Down
35 changes: 8 additions & 27 deletions radio/src/gui/colorlcd/startup_shutdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern void checkSpeakerVolume();
const std::string ver_str = "" VERSION_TAG;
const std::string nam_str = "" CODENAME;
#if PORTRAIT_LCD
#define TXT_Y 404
#define TXT_Y (LCD_H * 21 / 25))
#else
#define TXT_Y (LCD_H * 3 / 4)
#endif
Expand All @@ -40,13 +40,15 @@ const std::string ver_str = "" VERSION;
const std::string nam_str = "" VERSION_SUFFIX;
const std::string git_str = "(" GIT_STR ")";
#if PORTRAIT_LCD
#define TXT_Y 380
#define TXT_Y (LCD_H * 19 / 24)
#else
#define TXT_Y (LCD_H * 2 / 3)
#endif
#endif

static LAYOUT_VAL(TXT_W, 200, 200, LS(200))
static LAYOUT_VAL(TXT_H, 24, 24, LS(24))
static LAYOUT_VAL(TXT_XO, 100, 100, LS(100))

#if !PORTRAIT_LCD
#define TXT_X (LCD_W * 4 / 5)
Expand All @@ -62,27 +64,6 @@ const uint8_t __bmp_splash_logo[]{
#include "splash_logo.lbm"
};

void draw_splash_cb(lv_event_t* e)
{
auto draw_ctx = lv_event_get_draw_ctx(e);
auto splashImg = (BitmapBuffer*)lv_event_get_user_data(e);

if (splashImg) {
lv_draw_img_dsc_t img_dsc;
lv_draw_img_dsc_init(&img_dsc);

lv_area_t coords;
coords.x1 = (LCD_W / 2) - (splashImg->width() / 2);
coords.y1 = (LCD_H / 2) - (splashImg->height() / 2);
coords.x2 = coords.x1 + splashImg->width() - 1;
coords.y2 = coords.y1 + splashImg->height() - 1;

lv_draw_img_decoded(draw_ctx, &img_dsc, &coords,
(const uint8_t*)splashImg->getData(),
LV_IMG_CF_TRUE_COLOR);
}
}

static Window* splashScreen = nullptr;

void drawSplash()
Expand All @@ -103,11 +84,11 @@ void drawSplash()
new StaticLZ4Image(splashScreen, IMG_X - logo->width / 2,
IMG_Y - logo->height / 2, logo);

new StaticText(splashScreen, {TXT_X - 100, TXT_Y, 200, 24}, ver_str.c_str(), COLOR_GREY_INDEX, CENTERED);
new StaticText(splashScreen, {TXT_X - 100, TXT_Y + TXT_H, 200, TXT_H},
new StaticText(splashScreen, {TXT_X - TXT_XO, TXT_Y, TXT_W, TXT_H}, ver_str.c_str(), COLOR_GREY_INDEX, CENTERED);
new StaticText(splashScreen, {TXT_X - TXT_XO, TXT_Y + TXT_H, TXT_W, TXT_H},
nam_str.c_str(), COLOR_GREY_INDEX, CENTERED);
#if !defined(VERSION_TAG)
new StaticText(splashScreen, {TXT_X - 100, TXT_Y + TXT_H * 2, 200, TXT_H},
new StaticText(splashScreen, {TXT_X - TXT_XO, TXT_Y + TXT_H * 2, TXT_W, TXT_H},
git_str.c_str(), COLOR_GREY_INDEX, CENTERED);
#endif
}
Expand Down Expand Up @@ -174,7 +155,7 @@ void waitSplash()
cancelSplash();
}

#define SHUTDOWN_CIRCLE_RADIUS 75
static LAYOUT_VAL(SHUTDOWN_CIRCLE_RADIUS, 75, 75, LS(75))

const int8_t bmp_shutdown_xo[] = {0, 0, -SHUTDOWN_CIRCLE_RADIUS,
-SHUTDOWN_CIRCLE_RADIUS};
Expand Down

0 comments on commit b5ffd62

Please sign in to comment.