Skip to content

Commit

Permalink
Edit ScreenFatalWarning layout to fit all languages
Browse files Browse the repository at this point in the history
  • Loading branch information
michalrudolf authored and dragomirecky committed Jan 24, 2024
1 parent 6989c36 commit 2e35b4e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 21 deletions.
6 changes: 5 additions & 1 deletion src/gui/screen_blue_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@

using namespace crash_dump;

static const constexpr Rect16 fw_version_rect = GuiDefaults::EnableDialogBigLayout ? Rect16(30, ScreenBlueError::fw_line_top, display::GetW() - 30, 20) : Rect16(6, 295, display::GetW() - 6, 13);
static const constexpr Rect16 header_rect = GuiDefaults::EnableDialogBigLayout ? Rect16(14, 10, 240, GuiDefaults::HeaderHeight - 10) : GuiDefaults::RectHeader;
static const constexpr Rect16 title_rect = GuiDefaults::EnableDialogBigLayout ? Rect16(30, 44, display::GetW() - 60, 20) : Rect16(13, 12, display::GetW() - 26, 20);

ScreenBlueError::ScreenBlueError()
: AddSuperWindow<ScreenResetError>()
: AddSuperWindow<ScreenResetError>(fw_version_rect)
///@note No translations on blue screens.
, header(this, header_rect, is_multiline::no, is_closed_on_click_t::no, string_view_utf8::MakeCPUFLASH(reinterpret_cast<const uint8_t *>("UNKNOWN ERROR")))
, title(this, title_rect, is_multiline::no, is_closed_on_click_t::no, string_view_utf8::MakeCPUFLASH(reinterpret_cast<const uint8_t *>("Unable to show details")))
Expand Down
6 changes: 2 additions & 4 deletions src/gui/screen_blue_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ class ScreenBlueError : public AddSuperWindow<ScreenResetError> {
public:
ScreenBlueError();

static const constexpr ResourceId header_font = IDR_FNT_SMALL;
static const constexpr Rect16 header_rect = GuiDefaults::EnableDialogBigLayout ? Rect16(14, 10, 240, GuiDefaults::HeaderHeight - 10) : GuiDefaults::RectHeader;
static const constexpr Rect16 title_rect = GuiDefaults::EnableDialogBigLayout ? Rect16(30, 44, display::GetW() - 60, 20) : Rect16(13, 12, display::GetW() - 26, 20);
static const constexpr Rect16 description_rect = Rect16(13, title_rect.Bottom() + 5, display::GetW() - 26, fw_version_rect.Top() - title_rect.Bottom() - 10);
static const constexpr uint16_t fw_line_top = 265;
static const constexpr Rect16 description_rect = Rect16(13, title_rect.Bottom() + 5, display::GetW() - 26, fw_line_top - title_rect.Bottom() - 10);

// Expected size of the description text
static const constexpr ResourceId description_font = IDR_FNT_SMALL;
Expand Down
19 changes: 8 additions & 11 deletions src/gui/screen_fatal_warning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,29 @@
using namespace crash_dump;

static const constexpr uint16_t left_padding = ScreenFatalWarning::title_rect.Left();
static const constexpr uint16_t warining_icon_size = 48;
static const constexpr uint16_t text_start_x = left_padding + warining_icon_size + 10 /* visual delimeter */;
static const constexpr uint16_t text_start_y = 85;
static const constexpr uint16_t qr_start_x = (display::GetW() * 2) / 3;
static const constexpr uint16_t qr_size = 130;
static const constexpr uint16_t info_text_width = 235;
static const constexpr uint16_t info_text_width = 293;

static const constexpr Rect16 warning_rect = Rect16(left_padding, text_start_y, warining_icon_size, warining_icon_size);
static const constexpr Rect16 QR_rect = Rect16(qr_start_x, 44, qr_size, qr_size);
static const constexpr Rect16 QR_rect = Rect16(qr_start_x, 74, qr_size, qr_size);
static const constexpr Rect16 hand_rect = Rect16(qr_start_x + /* center under qr */ (qr_size - 59) / 2, qr_size + QR_rect.Top() + 5 /* visual delimeter */, 59, 72);
static const constexpr Rect16 descr_rect = Rect16(text_start_x, text_start_y, info_text_width, 135);
static const constexpr Rect16 help_txt_rect = Rect16(text_start_x, 222, info_text_width, 20);
static const constexpr Rect16 link_rect = Rect16(text_start_x, 244, info_text_width, 20);
static const constexpr Rect16 qr_code_rect = Rect16(180, 265, 100, 20);
static const constexpr Rect16 descr_rect = Rect16(left_padding, text_start_y, info_text_width, 155);
static const constexpr Rect16 help_txt_rect = Rect16(left_padding, 242, info_text_width, 20);
static const constexpr Rect16 link_rect = Rect16(left_padding, 264, info_text_width, 20);
static const constexpr Rect16 qr_code_rect = Rect16(180, 295, 100, 20);
static const constexpr Rect16 fw_version_rect = Rect16(30, 295, display::GetW() - 30, 20);

static constexpr const char *const header_label = N_("Wrong hardware");
static constexpr const char *const help_text = N_("More detail at");
static constexpr const char *const unknown_err_txt = N_("Unknown Error");

ScreenFatalWarning::ScreenFatalWarning()
: AddSuperWindow<ScreenResetError>()
: AddSuperWindow<ScreenResetError>(fw_version_rect)
, header(this)
, err_title(this, title_rect, is_multiline::no)
, err_description(this, descr_rect, is_multiline::yes)
, hand_icon(this, hand_rect, &img::hand_qr_59x72)
, warning_icon(this, warning_rect, &img::warning_48x48)
, qr(this, QR_rect, 1, Align_t::RightTop()) // error code is passed in the constructor
, help_txt(this, help_txt_rect, is_multiline::no)
, help_link(this, link_rect, is_multiline::no)
Expand Down
1 change: 0 additions & 1 deletion src/gui/screen_fatal_warning.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class ScreenFatalWarning : public AddSuperWindow<ScreenResetError> {
window_text_t err_title;
window_text_t err_description;
window_icon_t hand_icon;
window_icon_t warning_icon;
window_qr_t qr;
window_text_t help_txt;
window_text_t help_link;
Expand Down
3 changes: 2 additions & 1 deletion src/gui/screen_qr_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ static const constexpr Rect16 link_rect = GuiDefaults::EnableDialogBigLayout ? R
static const constexpr Rect16 qr_code_rect = GuiDefaults::EnableDialogBigLayout ? Rect16(180, 265, 100, 20) : Rect16(100, 295, 64, 13);
static const constexpr Rect16 help_txt_rect = Rect16(30, 200, 215, 20);
static const constexpr Rect16 title_line_rect = GuiDefaults::EnableDialogBigLayout ? Rect16(30, 70, 420, 1) : Rect16(10, 44, 219, 1);
static const constexpr Rect16 fw_version_rect = GuiDefaults::EnableDialogBigLayout ? Rect16(30, 265, display::GetW() - 30, 20) : Rect16(6, 295, display::GetW() - 6, 13);

static constexpr const char *const header_label = N_("ERROR");
static constexpr const char *const help_text = N_("More detail at");
static constexpr const char *const unknown_err_txt = N_("Unknown Error");

ScreenErrorQR::ScreenErrorQR()
: AddSuperWindow<ScreenResetError>()
: AddSuperWindow<ScreenResetError>(fw_version_rect)
, header(this)
, err_title(this, title_rect, is_multiline::no)
, err_description(this, descr_rect, is_multiline::yes)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/screen_reset_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "version.h"
#include "support_utils.h"

ScreenResetError::ScreenResetError()
ScreenResetError::ScreenResetError(const Rect16 &fw_version_rect)
: AddSuperWindow<screen_t>()
, fw_version_txt(this, fw_version_rect, is_multiline::no)
, sound_started(false) {
Expand Down
3 changes: 1 addition & 2 deletions src/gui/screen_reset_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ class ScreenResetError : public AddSuperWindow<screen_t> {
bool sound_started;

public:
ScreenResetError();
ScreenResetError(const Rect16 &fw_version_rect);

static const constexpr Rect16 title_rect = GuiDefaults::EnableDialogBigLayout ? Rect16(30, 44, display::GetW() - 60, 20) : Rect16(10, 24, display::GetW() - 26, 20);
static const constexpr Rect16 fw_version_rect = GuiDefaults::EnableDialogBigLayout ? Rect16(30, 265, display::GetW() - 30, 20) : Rect16(6, 295, display::GetW() - 6, 13);

protected:
/// starts sound and avoids repetitive starting
Expand Down

0 comments on commit 2e35b4e

Please sign in to comment.