From 1d19c549cfd4560766992949349cec9364623c86 Mon Sep 17 00:00:00 2001 From: Maciej Janicki Date: Fri, 29 Apr 2022 16:59:18 +0200 Subject: [PATCH] [BH-1444] Fix vertical layout Fix vertical layout: - fix wrong hour displayed - fix scrambled layout --- .../BellHybrid/apps/common/CMakeLists.txt | 4 +- .../layouts/HomeScreenLayoutVertical.hpp | 2 +- ...tSpinnerVertical.hpp => ClockVertical.hpp} | 38 +-- .../include/common/widgets/LayoutVertical.hpp | 17 +- .../src/layouts/HomeScreenLayoutVertical.cpp | 2 +- .../HomeScreenLayoutVerticalSimple.cpp | 2 +- .../HomeScreenLayoutVerticalWithAmPm.cpp | 2 +- .../apps/common/src/widgets/ClockVertical.cpp | 225 +++++++++++++++ .../common/src/widgets/LayoutVertical.cpp | 6 +- .../src/widgets/TimeSetSpinnerVertical.cpp | 271 ------------------ 10 files changed, 256 insertions(+), 313 deletions(-) rename products/BellHybrid/apps/common/include/common/widgets/{TimeSetSpinnerVertical.hpp => ClockVertical.hpp} (59%) create mode 100644 products/BellHybrid/apps/common/src/widgets/ClockVertical.cpp delete mode 100644 products/BellHybrid/apps/common/src/widgets/TimeSetSpinnerVertical.cpp diff --git a/products/BellHybrid/apps/common/CMakeLists.txt b/products/BellHybrid/apps/common/CMakeLists.txt index 7e3f503267b162fa63ad570a7a80c74f20df4873..94cbda585bbce65ca35dc6d890da6ecf1ce045e8 100644 --- a/products/BellHybrid/apps/common/CMakeLists.txt +++ b/products/BellHybrid/apps/common/CMakeLists.txt @@ -42,7 +42,7 @@ target_sources(application-bell-common src/widgets/ProgressTimerWithSnoozeTimer.cpp src/widgets/SnoozeTimer.cpp src/widgets/LayoutVertical.cpp - src/widgets/TimeSetSpinnerVertical.cpp + src/widgets/ClockVertical.cpp src/options/BellOptionWindow.cpp src/options/BellShortOptionWindow.cpp @@ -98,7 +98,7 @@ target_sources(application-bell-common include/common/widgets/SnoozeTimer.hpp include/common/widgets/ListItems.hpp include/common/widgets/LayoutVertical.hpp - include/common/widgets/TimeSetSpinnerVertical.hpp + include/common/widgets/ClockVertical.hpp include/common/options/BellOptionWindow.hpp include/common/options/BellShortOptionWindow.hpp include/common/options/OptionBellMenu.hpp diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVertical.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVertical.hpp index f56352b87947068bf99459db30b7e6cfce961cb9..0423bf3cff557743e2f6439c10564f923c1e9d43 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVertical.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVertical.hpp @@ -16,7 +16,7 @@ namespace gui class TextFixedSize; class AlarmIcon; class AlarmSetSpinner; - class TimeSetSpinnerVertical; + class ClockVertical; class TimeSetFmtSpinner; class SnoozeTimer; class BellBattery; diff --git a/products/BellHybrid/apps/common/include/common/widgets/TimeSetSpinnerVertical.hpp b/products/BellHybrid/apps/common/include/common/widgets/ClockVertical.hpp similarity index 59% rename from products/BellHybrid/apps/common/include/common/widgets/TimeSetSpinnerVertical.hpp rename to products/BellHybrid/apps/common/include/common/widgets/ClockVertical.hpp index 90ba6399b35da828347ea5c0725b468783b13645..a49411aab12d05379db1778ed9a1926e30e3ecf6 100644 --- a/products/BellHybrid/apps/common/include/common/widgets/TimeSetSpinnerVertical.hpp +++ b/products/BellHybrid/apps/common/include/common/widgets/ClockVertical.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved. +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once @@ -16,10 +16,6 @@ namespace style::time_set_spinner_vertical { inline constexpr auto size = 6U; } // namespace focus - - inline constexpr auto small_margin = 6U; - inline constexpr auto big_margin = 44U; - inline constexpr auto colossal_margin = -40; } // namespace style::time_set_spinner_vertical namespace gui @@ -32,16 +28,15 @@ namespace gui /// Two time formats are supported: /// utils::time::Locale::TimeFormat::FormatTime12H /// utils::time::Locale::TimeFormat::FormatTime24H - class TimeSetSpinnerVertical : public VBox + class ClockVertical : public VBox { public: - TimeSetSpinnerVertical( - Item *parent = nullptr, - uint32_t x = 0U, - uint32_t y = 0U, - uint32_t w = 0U, - uint32_t h = 0U, - utils::time::Locale::TimeFormat timeFormat = utils::time::Locale::TimeFormat::FormatTime12H); + ClockVertical(Item *parent = nullptr, + uint32_t x = 0U, + uint32_t y = 0U, + uint32_t w = 0U, + uint32_t h = 0U, + utils::time::Locale::TimeFormat timeFormat = utils::time::Locale::TimeFormat::FormatTime12H); /// Switches currently displayed time format auto setTimeFormat(utils::time::Locale::TimeFormat fmt) noexcept -> void; @@ -57,25 +52,18 @@ namespace gui auto getTimeFormat() const noexcept -> utils::time::Locale::TimeFormat; - auto getHourMargins(const std::string &font) const noexcept -> Margins; - private: - std::map spaceMarginsMap = { - {style::window::font::verybiglight, {0, 0, 0, style::time_set_spinner_vertical::small_margin}}, - {style::window::font::largelight, {0, 0, 0, style::time_set_spinner_vertical::small_margin}}, - {style::window::font::supersizemelight, {0, 0, 0, style::time_set_spinner_vertical::big_margin}}, - {style::window::font::huge, {0, 0, 0, style::time_set_spinner_vertical::big_margin}}, - {style::window::font::colossal, {0, 0, 0, style::time_set_spinner_vertical::colossal_margin}}}; - - void handleContentChanged() override; - gui::HBox *hBoxHours = nullptr; + gui::HBox *hBoxHoursLeft = nullptr; + gui::HBox *hBoxHoursRight = nullptr; gui::HBox *hBoxMinutes = nullptr; + gui::HBox *hBoxMinutesLeft = nullptr; + gui::HBox *hBoxMinutesRight = nullptr; gui::TextFixedSize *hourFirst = nullptr; gui::TextFixedSize *hourSecond = nullptr; gui::TextFixedSize *minuteFirst = nullptr; gui::TextFixedSize *minuteSecond = nullptr; - std::string fontName = style::window::font::supersizemelight; + std::string fontName = style::window::font::supersizemelight; utils::time::Locale::TimeFormat timeFormat = utils::time::Locale::TimeFormat::FormatTime12H; }; diff --git a/products/BellHybrid/apps/common/include/common/widgets/LayoutVertical.hpp b/products/BellHybrid/apps/common/include/common/widgets/LayoutVertical.hpp index 0db0a61d480c9f5081c7f6bd8ac71a547bfd2086..935420615f166eaa9f647045bf595080206288e4 100644 --- a/products/BellHybrid/apps/common/include/common/widgets/LayoutVertical.hpp +++ b/products/BellHybrid/apps/common/include/common/widgets/LayoutVertical.hpp @@ -9,12 +9,13 @@ namespace style::homescreen_vertical { - constexpr inline auto side_box_w = 120U; - constexpr inline auto center_box_w = 240U; - constexpr inline auto center_box_h = 220U; - constexpr inline auto bottomMargin = 35U; - constexpr inline auto leftMargin = 60U; - constexpr inline auto rightMargin = 60U; + constexpr inline auto side_box_w = 115U; + constexpr inline auto center_box_w = 250U; + constexpr inline auto center_box_h = 220U; + constexpr inline auto digit_box_w = 125U; + constexpr inline auto leftMargin = 60U; + constexpr inline auto rightMargin = 60U; + constexpr inline auto topNegativeMargin = -35; } // namespace style::homescreen_vertical namespace gui @@ -23,7 +24,7 @@ namespace gui class TextFixedSize; class AlarmIcon; class AlarmSetSpinner; - class TimeSetSpinnerVertical; + class ClockVertical; class TimeSetFmtSpinner; class SnoozeTimer; class BellBattery; @@ -43,7 +44,7 @@ namespace gui BellBattery *battery{}; // Main Screen - TimeSetSpinnerVertical *time{}; + ClockVertical *time{}; VBox *leftBox{}; VBox *rightBox{}; diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp index 8fc68ff255fefab7ea9ccba5af414ee26b44a520..0f5b00fdbe6d404ef0c4fa58448abea78456da8b 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp @@ -16,7 +16,7 @@ #include