From 89962fa4396f51e9dd0fdcf4df1b82c424429db4 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Fri, 18 Nov 2022 00:48:39 +0100 Subject: [PATCH] [BH-1598] Add clock faces with dates Add classic and vertical face with dates for both 12h and 24h format. Fix centering of battery indicator when level is smaller than 100%. Fix incorrect time format of the alarm in clock face settings. Change placement of battery and time format indicators on ClassicWithAmPm screen while charging. --- harmony_changelog.md | 18 ++- .../apps-common/widgets/BellBaseLayout.cpp | 75 +++++----- .../apps-common/widgets/BellBaseLayout.hpp | 27 ++-- .../apps-common/widgets/TimeSetFmtSpinner.cpp | 27 ++-- .../apps-common/widgets/TimeSetFmtSpinner.hpp | 7 +- .../apps-common/widgets/TimeSetSpinner.hpp | 3 + module-gui/gui/widgets/Style.hpp | 1 + module-gui/gui/widgets/text/Text.hpp | 8 +- products/BellHybrid/CMakeLists.txt | 4 +- .../presenter/LayoutWindowPresenter.cpp | 15 +- .../BellHybrid/apps/common/CMakeLists.txt | 4 + .../include/common/data/BellMainStyle.hpp | 2 + .../layouts/HomeScreenLayoutClassic.hpp | 24 ++-- .../HomeScreenLayoutClassicWithAmPm.hpp | 2 + .../HomeScreenLayoutClassicWithDate.hpp | 32 +++++ .../layouts/HomeScreenLayoutVertical.hpp | 2 + .../HomeScreenLayoutVerticalWithAmPm.hpp | 4 +- .../HomeScreenLayoutVerticalWithDate.hpp | 32 +++++ .../include/common/widgets/BellBattery.hpp | 11 +- .../common/widgets/BellStatusClock.hpp | 6 +- .../include/common/widgets/LayoutVertical.hpp | 22 +-- .../src/layouts/HomeScreenLayoutClassic.cpp | 24 ++-- .../HomeScreenLayoutClassicWithAmPm.cpp | 27 +++- .../HomeScreenLayoutClassicWithDate.cpp | 92 +++++++++++++ .../HomeScreenLayoutClassicWithTemp.cpp | 4 +- .../src/layouts/HomeScreenLayoutVertical.cpp | 33 ++++- .../HomeScreenLayoutVerticalWithAmPm.cpp | 20 +-- .../HomeScreenLayoutVerticalWithDate.cpp | 129 ++++++++++++++++++ .../common/src/layouts/HomeScreenLayouts.cpp | 11 +- .../apps/common/src/widgets/BellBattery.cpp | 42 ++++-- .../common/src/widgets/BellStatusClock.cpp | 7 +- .../common/src/widgets/LayoutVertical.cpp | 16 ++- .../apps/common/src/widgets/ListItems.cpp | 4 +- .../BellHybrid/assets/assets_proprietary.json | 5 + 34 files changed, 563 insertions(+), 177 deletions(-) create mode 100644 products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithDate.hpp create mode 100644 products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithDate.hpp create mode 100644 products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithDate.cpp create mode 100644 products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalWithDate.cpp diff --git a/harmony_changelog.md b/harmony_changelog.md index f87a98dcec88f9a2bf0ef2b6574dd13549d44b6d..f8bc89d6c8754f763483a9d845ac10a34db0ed9d 100644 --- a/harmony_changelog.md +++ b/harmony_changelog.md @@ -5,19 +5,31 @@ ### Added #### Home Screen: -* Font size increased +* Font size increased. +* Clock faces with dates. #### General: -* Bedside lamp mode +* Bedside lamp mode. #### UI/UX: * Improve refreshing of the display. #### Onboarding -* Shortcuts instruction +* Shortcuts instruction. + +### Changed + +#### Home Screen: +* Placement of battery and time format indicators. ### Fixed +#### Home Screen: +* Centering of battery indicator. + +#### Settings: +* Incorrect time format of the alarm in clock face settings. + ## [1.7.0 2022-11-14] ### Added diff --git a/module-apps/apps-common/widgets/BellBaseLayout.cpp b/module-apps/apps-common/widgets/BellBaseLayout.cpp index bca973a45bee0533fd822fb8dd3250dce29e29bd..47a98af511843f74ad4d05fd4c665516c1976272 100644 --- a/module-apps/apps-common/widgets/BellBaseLayout.cpp +++ b/module-apps/apps-common/widgets/BellBaseLayout.cpp @@ -6,13 +6,7 @@ namespace gui { - BellBaseLayout::BellBaseLayout(Item *parent, - Position x, - Position y, - Length w, - Length h, - bool withSideArrows, - style::bell_base_layout::ParentType type) + BellBaseLayout::BellBaseLayout(Item *parent, Position x, Position y, Length w, Length h, bool withSideArrows) : VThreeBox(parent, x, y, w, h) { setMinimumSize(style::bell_base_layout::w, style::bell_base_layout::h); @@ -37,10 +31,6 @@ namespace gui lastBox->setEdges(RectangleEdge::None); lastBox->activeItem = false; - if (type == style::bell_base_layout::ParentType::SideListView) { - lastBox->setMargins(Margins(0, 0, 0, style::bell_base_layout::outer_layout_margin)); - } - resizeItems(); if (withSideArrows) { @@ -50,8 +40,8 @@ namespace gui Item *BellBaseLayout::getCenterBox() const noexcept { - if (centerThreeBox != nullptr) { - return centerThreeBox->centerBox; + if (arrowsThreeBox != nullptr) { + return arrowsThreeBox->centerBox; } return centerBox; } @@ -59,8 +49,8 @@ namespace gui void BellBaseLayout::resizeCenter() { centerBox->resizeItems(); - if (centerThreeBox != nullptr) { - centerThreeBox->resizeItems(); + if (arrowsThreeBox != nullptr) { + arrowsThreeBox->resizeItems(); } } @@ -74,40 +64,41 @@ namespace gui void BellBaseLayout::addSideArrows() { - centerThreeBox = new HThreeBox(centerBox); - centerThreeBox->setMinimumSize(style::bell_base_layout::w, style::bell_base_layout::center_layout_h); - centerThreeBox->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); - centerThreeBox->setEdges(RectangleEdge::None); - - centerThreeBox->firstBox = new HBox(centerThreeBox); - centerThreeBox->firstBox->setAlignment(Alignment(Alignment::Vertical::Center)); - centerThreeBox->firstBox->setEdges(RectangleEdge::None); - centerThreeBox->firstBox->activeItem = false; - - leftArrow = new ImageBox(centerThreeBox->firstBox, new Image("bell_arrow_left_W_M")); + arrowsThreeBox = new HThreeBox(centerBox); + arrowsThreeBox->setMinimumSize(style::bell_base_layout::arrows_layout_w, + style::bell_base_layout::center_layout_h); + arrowsThreeBox->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); + arrowsThreeBox->setEdges(RectangleEdge::None); + + arrowsThreeBox->firstBox = new HBox(arrowsThreeBox); + arrowsThreeBox->firstBox->setAlignment(Alignment(Alignment::Vertical::Center)); + arrowsThreeBox->firstBox->setEdges(RectangleEdge::None); + arrowsThreeBox->firstBox->activeItem = false; + + leftArrow = new ImageBox(arrowsThreeBox->firstBox, new Image("bell_arrow_left_W_M")); leftArrow->setAlignment(Alignment(Alignment::Horizontal::Right, Alignment::Vertical::Center)); leftArrow->setMinimumSizeToFitImage(); leftArrow->setVisible(true); leftArrow->setEdges(RectangleEdge::None); - centerThreeBox->firstBox->setMinimumSize(leftArrow->widgetMinimumArea.w, leftArrow->widgetMinimumArea.h); + arrowsThreeBox->firstBox->setMinimumSize(leftArrow->widgetMinimumArea.w, leftArrow->widgetMinimumArea.h); - centerThreeBox->centerBox = new HBox(centerThreeBox); - centerThreeBox->centerBox->setEdges(RectangleEdge::None); - centerThreeBox->centerBox->setAlignment(Alignment(gui::Alignment::Horizontal::Center)); - centerThreeBox->centerBox->setMaximumSize(style::bell_base_layout::center_layout_w, + arrowsThreeBox->centerBox = new HBox(arrowsThreeBox); + arrowsThreeBox->centerBox->setEdges(RectangleEdge::None); + arrowsThreeBox->centerBox->setAlignment(Alignment(gui::Alignment::Horizontal::Center)); + arrowsThreeBox->centerBox->setMaximumSize(style::bell_base_layout::center_layout_w, style::bell_base_layout::center_layout_h); - centerThreeBox->lastBox = new HBox(centerThreeBox); - centerThreeBox->lastBox->setAlignment(Alignment(Alignment::Vertical::Center)); - centerThreeBox->lastBox->setEdges(RectangleEdge::None); - centerThreeBox->lastBox->activeItem = false; + arrowsThreeBox->lastBox = new HBox(arrowsThreeBox); + arrowsThreeBox->lastBox->setAlignment(Alignment(Alignment::Vertical::Center)); + arrowsThreeBox->lastBox->setEdges(RectangleEdge::None); + arrowsThreeBox->lastBox->activeItem = false; - rightArrow = new ImageBox(centerThreeBox->lastBox, new Image("bell_arrow_right_W_M")); + rightArrow = new ImageBox(arrowsThreeBox->lastBox, new Image("bell_arrow_right_W_M")); rightArrow->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Center)); rightArrow->setMinimumSizeToFitImage(); rightArrow->setVisible(true); rightArrow->setEdges(RectangleEdge::None); - centerThreeBox->lastBox->setMinimumSize(rightArrow->widgetMinimumArea.w, rightArrow->widgetMinimumArea.h); + arrowsThreeBox->lastBox->setMinimumSize(rightArrow->widgetMinimumArea.w, rightArrow->widgetMinimumArea.h); } void BellBaseLayout::setArrowVisible(Arrow arrow, bool isVisible) @@ -122,12 +113,12 @@ namespace gui { setArrowVisible(BellBaseLayout::Arrow::Left, !minCondition); setArrowVisible(BellBaseLayout::Arrow::Right, !maxCondition); - if (centerThreeBox != nullptr) { - if (centerThreeBox->firstBox != nullptr) { - centerThreeBox->firstBox->resizeItems(); + if (arrowsThreeBox != nullptr) { + if (arrowsThreeBox->firstBox != nullptr) { + arrowsThreeBox->firstBox->resizeItems(); } - if (centerThreeBox->lastBox != nullptr) { - centerThreeBox->lastBox->resizeItems(); + if (arrowsThreeBox->lastBox != nullptr) { + arrowsThreeBox->lastBox->resizeItems(); } } } diff --git a/module-apps/apps-common/widgets/BellBaseLayout.hpp b/module-apps/apps-common/widgets/BellBaseLayout.hpp index a67117fadd0d36f3e3c03263085abe2f696df006..971ca8229eee13c18dedd5754218bbabaaa13d14 100644 --- a/module-apps/apps-common/widgets/BellBaseLayout.hpp +++ b/module-apps/apps-common/widgets/BellBaseLayout.hpp @@ -13,15 +13,9 @@ namespace style::bell_base_layout constexpr inline auto first_layout_min_h = 30U; constexpr inline auto outer_layouts_w = 448U; constexpr inline auto outer_layouts_h = 102U; - constexpr inline auto outer_layout_margin = 38U; - constexpr inline auto center_layout_w = 504U; - constexpr inline auto center_layout_h = h - 2 * outer_layout_margin - 2 * outer_layouts_h; - - enum class ParentType - { - SideListView, - Window - }; + constexpr inline auto center_layout_w = w; + constexpr inline auto center_layout_h = 200U; + constexpr inline auto arrows_layout_w = 504U; } // namespace style::bell_base_layout namespace gui @@ -35,13 +29,8 @@ namespace gui Right }; - explicit BellBaseLayout(Item *parent, - Position x = 0, - Position y = 0, - Length w = 0, - Length h = 0, - bool withSideArrows = true, - style::bell_base_layout::ParentType type = style::bell_base_layout::ParentType::Window); + explicit BellBaseLayout( + Item *parent, Position x = 0, Position y = 0, Length w = 0, Length h = 0, bool withSideArrows = true); [[nodiscard]] Item *getCenterBox() const noexcept; void resizeCenter(); @@ -51,9 +40,9 @@ namespace gui void setMinMaxArrowsVisibility(bool minCondition, bool maxCondition); private: - HThreeBox *centerThreeBox{nullptr}; - ImageBox *leftArrow{nullptr}; - ImageBox *rightArrow{nullptr}; + HThreeBox *arrowsThreeBox = nullptr; + ImageBox *leftArrow = nullptr; + ImageBox *rightArrow = nullptr; void addSideArrows(); }; diff --git a/module-apps/apps-common/widgets/TimeSetFmtSpinner.cpp b/module-apps/apps-common/widgets/TimeSetFmtSpinner.cpp index 6095f5b6a292da5ecb1f44e58a066ef0040b938c..0a370f97289405427406816da781e9ec8465689d 100644 --- a/module-apps/apps-common/widgets/TimeSetFmtSpinner.cpp +++ b/module-apps/apps-common/widgets/TimeSetFmtSpinner.cpp @@ -11,9 +11,7 @@ namespace gui { - TimeSetFmtSpinner::TimeSetFmtSpinner( - Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h, utils::time::Locale::TimeFormat timeFormat) - : HBox{parent, x, y, w, h} + TimeSetFmtSpinner::TimeSetFmtSpinner(Item *parent, utils::time::Locale::TimeFormat timeFormat) : HBox{parent} { using namespace utils; @@ -218,6 +216,14 @@ namespace gui return timeFormat; } + void TimeSetFmtSpinner::setVisible(bool value) + { + HBox::setVisible(value); + // This is a workaround for fmt visibility not changed properly + // It's probably caused by a bug in BoxLayout + fmt->setVisible(value); + } + auto TimeSetFmtSpinner::setTime(std::time_t time) noexcept -> void { using namespace utils::time; @@ -258,16 +264,17 @@ namespace gui void TimeSetFmtSpinner::handleContentChanged() { - fmt->setMinimumWidthToFitText(); - fmt->setMargins(getFmtMargins(noFocusFontName)); + auto widthToSet = timeSetSpinner->widgetMinimumArea.w; - auto widthToSet = - timeFormat == utils::time::Locale::TimeFormat::FormatTime12H - ? timeSetSpinner->widgetMinimumArea.w + fmt->widgetMinimumArea.w + fmt->margins.getSumInAxis(Axis::X) - : timeSetSpinner->widgetMinimumArea.w; + if (timeFormat == utils::time::Locale::TimeFormat::FormatTime12H && fmt->visible) { + fmt->setMinimumWidthToFitText(); + fmt->setMargins(getFmtMargins(noFocusFontName)); + widthToSet = + timeSetSpinner->widgetMinimumArea.w + fmt->widgetMinimumArea.w + fmt->margins.getSumInAxis(Axis::X); + } setMinimumWidth(widthToSet); - setMaximumWidth(widgetMinimumArea.w); + setMaximumWidth(widthToSet); HBox::handleContentChanged(); } diff --git a/module-apps/apps-common/widgets/TimeSetFmtSpinner.hpp b/module-apps/apps-common/widgets/TimeSetFmtSpinner.hpp index ca9f6b94d4084e81c9bdea18d9cdbdd1deea9c80..7ce008c56a3e33bebed28d0c44cd46d28f6b5766 100644 --- a/module-apps/apps-common/widgets/TimeSetFmtSpinner.hpp +++ b/module-apps/apps-common/widgets/TimeSetFmtSpinner.hpp @@ -37,10 +37,6 @@ namespace gui }; explicit TimeSetFmtSpinner( 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 @@ -64,6 +60,8 @@ namespace gui auto getTimeFormat() const noexcept -> utils::time::Locale::TimeFormat; + void setVisible(bool value) override; + private: enum class TraverseDir : bool { @@ -73,6 +71,7 @@ namespace gui std::map fmtMarginsMap = { {style::window::font::verybiglight, {style::time_set_fmt_spinner::small_margin, 0, 0, 0}}, + {style::window::font::veryverybiglight, {style::time_set_fmt_spinner::small_margin, 0, 0, 0}}, {style::window::font::largelight, {style::time_set_fmt_spinner::small_margin, 0, 0, 0}}, {style::window::font::supersizemelight, {style::time_set_fmt_spinner::big_margin, 0, 0, 0}}, {style::window::font::huge, {style::time_set_fmt_spinner::big_margin, 0, 0, 0}}, diff --git a/module-apps/apps-common/widgets/TimeSetSpinner.hpp b/module-apps/apps-common/widgets/TimeSetSpinner.hpp index 0afd18a776312513fe55ea7e4d717b88157e3d82..8a882c4584fefe8087d06681b620ff3fb4e6d058 100644 --- a/module-apps/apps-common/widgets/TimeSetSpinner.hpp +++ b/module-apps/apps-common/widgets/TimeSetSpinner.hpp @@ -47,6 +47,7 @@ namespace gui private: std::map colonFontMap = { {style::window::font::verybiglight, "alarm_colon_W_M"}, + {style::window::font::veryverybiglight, "alarm_colon_W_M"}, {style::window::font::largelight, "alarm_colon_W_M"}, {style::window::font::supersizeme, "alarm_colon_select_W_M"}, {style::window::font::supersizemelight, "alarm_colon_select_W_M"}, @@ -56,6 +57,8 @@ namespace gui std::map colonMarginsMap = { {style::window::font::verybiglight, {style::time_set_spinner::small_margin, 0, style::time_set_spinner::small_margin, 0}}, + {style::window::font::veryverybiglight, + {style::time_set_spinner::small_margin, 0, style::time_set_spinner::small_margin, 0}}, {style::window::font::largelight, {style::time_set_spinner::small_margin, 0, style::time_set_spinner::small_margin, 0}}, {style::window::font::supersizeme, diff --git a/module-gui/gui/widgets/Style.hpp b/module-gui/gui/widgets/Style.hpp index bcd94a65326e1cb0810cb60455c22e99cd6741f6..590d7d6a6c35ea586a5c518613d9c0b39c08c743 100644 --- a/module-gui/gui/widgets/Style.hpp +++ b/module-gui/gui/widgets/Style.hpp @@ -65,6 +65,7 @@ namespace style inline constexpr auto supersizemelight = "supersizemelight"; inline constexpr auto largelight = "largelight"; inline constexpr auto large = "large"; + inline constexpr auto veryverybiglight = "veryverybiglight"; inline constexpr auto verybiglight = "verybiglight"; inline constexpr auto verybig = "verybig"; inline constexpr auto mediumbigbold = "mediumbigbold"; diff --git a/module-gui/gui/widgets/text/Text.hpp b/module-gui/gui/widgets/text/Text.hpp index dc754cb405e304cffdedbd2845d81fb79ca40d09..8a854b5bccfc0bcad0fc526be68cdffb25b73ebb 100644 --- a/module-gui/gui/widgets/text/Text.hpp +++ b/module-gui/gui/widgets/text/Text.hpp @@ -119,10 +119,10 @@ namespace gui public: Text(); Text(Item *parent, - const uint32_t &x, - const uint32_t &y, - const uint32_t &w, - const uint32_t &h, + const uint32_t &x = 0, + const uint32_t &y = 0, + const uint32_t &w = 0, + const uint32_t &h = 0, ExpandMode expandMode = ExpandMode::None, TextType textType = TextType::MultiLine); ~Text() override; diff --git a/products/BellHybrid/CMakeLists.txt b/products/BellHybrid/CMakeLists.txt index 6b3d85bbe7feecf3ccd02df141a7f3adba93d00b..d75e478259e296e8ed20def5839e6b819b5fe328 100644 --- a/products/BellHybrid/CMakeLists.txt +++ b/products/BellHybrid/CMakeLists.txt @@ -115,14 +115,14 @@ download_asset_release_json(json-common-target ${CMAKE_CURRENT_SOURCE_DIR}/assets/assets_common.json ${CMAKE_BINARY_DIR}/sysroot/sys/current/ MuditaOSPublicAssets - 0.0.13 + 0.0.14 ${MUDITA_CACHE_DIR} ) download_asset_release_json(json-community-target ${CMAKE_CURRENT_SOURCE_DIR}/assets/assets_community.json ${CMAKE_BINARY_DIR}/sysroot/sys/current/ MuditaOSPublicAssets - 0.0.13 + 0.0.14 ${MUDITA_CACHE_DIR} ) download_asset_json(json-rt1051-target diff --git a/products/BellHybrid/apps/application-bell-settings/presenter/LayoutWindowPresenter.cpp b/products/BellHybrid/apps/application-bell-settings/presenter/LayoutWindowPresenter.cpp index 5c5b4b9b89a34a734aed58607bc8ae8dbaf04138..e59b8cbebdca87fde66aec7c87306cd959f35e6d 100644 --- a/products/BellHybrid/apps/application-bell-settings/presenter/LayoutWindowPresenter.cpp +++ b/products/BellHybrid/apps/application-bell-settings/presenter/LayoutWindowPresenter.cpp @@ -11,8 +11,8 @@ #include #include -constexpr auto alarmTime = 1000 * 60 * 60 * 12; -constexpr auto clockTime = 1000 * 60 * 60 * 12; +constexpr auto alarmTime = 0; +constexpr auto clockTime = 0; constexpr Store::Battery batteryState = { .levelState = Store::Battery::LevelState::Normal, .state = Store::Battery::State::Discharging, @@ -71,16 +71,17 @@ namespace app::bell_settings void LayoutWindowPresenter::initLayoutOptions() { - - auto layoutsList = timeModel->getTimeFormat() == utils::time::Locale::TimeFormat::FormatTime24H - ? gui::factory::getLayoutsFormat24h() - : gui::factory::getLayoutsFormat12h(); + const auto timeFormat = timeModel->getTimeFormat(); + auto layoutsList = timeFormat == utils::time::Locale::TimeFormat::FormatTime24H + ? gui::factory::getLayoutsFormat24h() + : gui::factory::getLayoutsFormat12h(); for (auto &layoutEntry : layoutsList) { auto layout = layoutEntry.second(); layout->setViewState(app::home_screen::ViewState::Activated); - layout->setTimeFormat(timeModel->getTimeFormat()); + layout->setTimeFormat(timeFormat); layout->setTime(clockTime); + layout->setAlarmTimeFormat(timeFormat); layout->setAlarmTime(alarmTime); layout->setBatteryLevelState(batteryState); layout->setTemperature(temperature); diff --git a/products/BellHybrid/apps/common/CMakeLists.txt b/products/BellHybrid/apps/common/CMakeLists.txt index 625b4bec38c2ab7bff51d8e401f1c27dfa57c47c..e0b7ac8e6cad37174f55a8444b18bc649ec1f25c 100644 --- a/products/BellHybrid/apps/common/CMakeLists.txt +++ b/products/BellHybrid/apps/common/CMakeLists.txt @@ -55,10 +55,12 @@ target_sources(application-bell-common src/layouts/HomeScreenLayoutClassic.cpp src/layouts/HomeScreenLayoutClassicWithAmPm.cpp src/layouts/HomeScreenLayoutClassicWithBattery.cpp + src/layouts/HomeScreenLayoutClassicWithDate.cpp src/layouts/HomeScreenLayoutClassicWithTemp.cpp src/layouts/HomeScreenLayoutVertical.cpp src/layouts/HomeScreenLayoutVerticalSimple.cpp src/layouts/HomeScreenLayoutVerticalWithAmPm.cpp + src/layouts/HomeScreenLayoutVerticalWithDate.cpp PUBLIC include/common/BellListItemProvider.hpp @@ -109,10 +111,12 @@ target_sources(application-bell-common include/common/layouts/HomeScreenLayoutClassic.hpp include/common/layouts/HomeScreenLayoutClassicWithAmPm.hpp include/common/layouts/HomeScreenLayoutClassicWithBattery.hpp + include/common/layouts/HomeScreenLayoutClassicWithDate.hpp include/common/layouts/HomeScreenLayoutClassicWithTemp.hpp include/common/layouts/HomeScreenLayoutVertical.hpp include/common/layouts/HomeScreenLayoutVerticalSimple.hpp include/common/layouts/HomeScreenLayoutVerticalWithAmPm.hpp + include/common/layouts/HomeScreenLayoutVerticalWithDate.hpp ) target_link_libraries(application-bell-common diff --git a/products/BellHybrid/apps/common/include/common/data/BellMainStyle.hpp b/products/BellHybrid/apps/common/include/common/data/BellMainStyle.hpp index a990cdef972a13fefd5d685914f205e543377e0a..3cd7f5003a6462600b29039a94a25c15e389882b 100644 --- a/products/BellHybrid/apps/common/include/common/data/BellMainStyle.hpp +++ b/products/BellHybrid/apps/common/include/common/data/BellMainStyle.hpp @@ -12,6 +12,7 @@ namespace bellMainStyle namespace time { inline constexpr auto font = style::window::font::gargantuan; + inline constexpr auto font_small = style::window::font::veryverybiglight; } // namespace time namespace alarmSetSpinner @@ -22,6 +23,7 @@ namespace bellMainStyle namespace bottomDescription { inline constexpr auto font_normal = style::window::font::largelight; + inline constexpr auto font_smallnormal = style::window::font::veryverybiglight; inline constexpr auto font_small = style::window::font::verybiglight; } // namespace bottomDescription diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassic.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassic.hpp index 8f6bf36a567826674b5f75a29734a7e9c38c1fa9..8dad5bc74c90151955dfb3d7c5e0430449184613 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassic.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassic.hpp @@ -9,8 +9,7 @@ namespace style::homescreen_classic { - constexpr inline auto bottom_box_w = 390U; - constexpr inline auto bottom_box_h = 102U; + constexpr inline auto status_box_layout_w = 350U; } // namespace style::homescreen_classic namespace gui { @@ -39,7 +38,7 @@ namespace gui SnoozeIconAndTime, }; - class HomeScreenLayoutClassic : public BaseHomeScreenLayoutProvider, BellBaseLayout + class HomeScreenLayoutClassic : public BaseHomeScreenLayoutProvider, protected BellBaseLayout { public: HomeScreenLayoutClassic(std::string name); @@ -59,16 +58,17 @@ namespace gui auto getLayout() -> Item * override; protected: - auto setHeaderViewMode(HeaderViewMode mode) -> void; - virtual auto buildInterface() -> void; + void setHeaderViewMode(HeaderViewMode mode); + virtual void buildInterface(); virtual bool isBatteryVisibilityAllowed(const Store::Battery &batteryContext); - auto removeTextDescription() -> void; + void removeTextDescription(); - TimeSetFmtSpinner *time{}; - DuoHBox *statusBox{}; - BellBattery *battery{}; - TextFixedSize *bottomText{}; - AlarmSetSpinner *alarm{}; - SnoozeTimer *snoozeTimer{}; + HBox *timeHBox = nullptr; + TimeSetFmtSpinner *time = nullptr; + HBox *statusBox = nullptr; + BellBattery *battery = nullptr; + TextFixedSize *bottomText = nullptr; + AlarmSetSpinner *alarm = nullptr; + SnoozeTimer *snoozeTimer = nullptr; }; }; // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithAmPm.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithAmPm.hpp index 4fc098dc6915eadfedb33f1be58965ff8721cdcc..169afe1c7698ee1755bd50de78812f243f5fe262 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithAmPm.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithAmPm.hpp @@ -16,6 +16,8 @@ namespace gui protected: auto buildInterface() -> void override; + bool isBatteryVisibilityAllowed(const Store::Battery &batteryContext) override; + void handleContentChanged() override; TextFixedSize *fmt{}; }; diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithDate.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithDate.hpp new file mode 100644 index 0000000000000000000000000000000000000000..0125b479e5024002f5d7ccab379074b00d001010 --- /dev/null +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutClassicWithDate.hpp @@ -0,0 +1,32 @@ +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include "HomeScreenLayoutClassic.hpp" + +namespace style::homescreen_classic +{ + constexpr inline auto ampm_layout_w = 51U; + constexpr inline auto ampm_margin_w = 5U; + constexpr inline auto ampm_time_margin_w = ampm_layout_w + ampm_margin_w; +} // namespace style::homescreen_classic +namespace gui +{ + class HomeScreenLayoutClassicWithDate : public HomeScreenLayoutClassic + { + public: + HomeScreenLayoutClassicWithDate(std::string name); + + void setTime(std::time_t newTime) override; + void setTimeFormat(utils::time::Locale::TimeFormat fmt) override; + + protected: + void buildInterface() override; + bool isBatteryVisibilityAllowed(const Store::Battery &batteryContext) override; + + Text *date = nullptr; + TextFixedSize *ampm = nullptr; + bool showAMPM = false; + }; +}; // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVertical.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVertical.hpp index 2b3a08bb3968c194e2ec89f9210ee11e9bc9836d..4e3027596d708cee284bf273da4ebe2f1a243a13 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVertical.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVertical.hpp @@ -51,5 +51,7 @@ namespace gui protected: auto setScreenMode(ScreenMode mode) -> void; virtual bool isBatteryVisibilityAllowed(const Store::Battery &batteryContext); + virtual bool isAlarmTimeVisibilityAllowed(); + bool isBatteryCharging(const Store::Battery::State state); }; }; // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithAmPm.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithAmPm.hpp index 298fd218d2fca3de3d1338f8d1e879f93a581706..2eb05433fd77460a4e381d329057be8e4f19c6a8 100644 --- a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithAmPm.hpp +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithAmPm.hpp @@ -9,7 +9,7 @@ namespace style::homescreen_vertical_ampm { constexpr inline auto alarm_margin_top = 83U; constexpr inline auto battery_margin_bot = 68U; - constexpr inline auto fmt_margin_bot = 77U; + constexpr inline auto ampm_margin_bot = 77U; } // namespace style::homescreen_vertical_ampm namespace gui @@ -22,6 +22,6 @@ namespace gui auto setTime(std::time_t newTime) -> void override; - TextFixedSize *fmt{}; + TextFixedSize *ampm{}; }; }; // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithDate.hpp b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithDate.hpp new file mode 100644 index 0000000000000000000000000000000000000000..cf40659416e8bd74158361a2d7e618e5ef83fec0 --- /dev/null +++ b/products/BellHybrid/apps/common/include/common/layouts/HomeScreenLayoutVerticalWithDate.hpp @@ -0,0 +1,32 @@ +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#pragma once + +#include "HomeScreenLayoutVertical.hpp" + +namespace style::homescreen_vertical_date +{ + constexpr inline auto margin_top = 64U; + constexpr inline auto margin_bot = 70U; +} // namespace style::homescreen_vertical_date + +namespace gui +{ + + class HomeScreenLayoutVerticalWithDate : public HomeScreenLayoutVertical + { + public: + HomeScreenLayoutVerticalWithDate(std::string name); + + void setTime(std::time_t newTime) override; + void setTimeFormat(utils::time::Locale::TimeFormat fmt) override; + + private: + void setBatteryLevelState(const Store::Battery &batteryContext) override; + bool isAlarmTimeVisibilityAllowed() override; + + TextFixedSize *ampm = nullptr; + TextFixedSize *date = nullptr; + }; +}; // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/widgets/BellBattery.hpp b/products/BellHybrid/apps/common/include/common/widgets/BellBattery.hpp index 9176e4a4f6d0992e60d2dfce92009db255c1c72a..812f8fcd223789e60f3f75329d969272e3ef6a24 100644 --- a/products/BellHybrid/apps/common/include/common/widgets/BellBattery.hpp +++ b/products/BellHybrid/apps/common/include/common/widgets/BellBattery.hpp @@ -18,7 +18,7 @@ namespace gui constexpr auto percent_h = 102U; constexpr auto percent_w = 106U; constexpr auto battery_widget_h = 64U; - constexpr auto battery_widget_w = 240U; + constexpr auto battery_widget_w = 184U; } // namespace battery @@ -31,13 +31,16 @@ namespace gui class BellBattery : public gui::HBox { public: - BellBattery(Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h); + BellBattery(Item *parent); + void setFont(const UTF8 &fontName); void update(units::SOC soc, bool isCharging); void setBatteryPercentMode(BatteryPercentMode mode); private: + void setWidthsToFitContent(); + BatteryPercentMode batteryPercentMode = BatteryPercentMode::Show; - TextFixedSize *percentText; - Image *img; + Text *percentText = nullptr; + Image *img = nullptr; }; } // namespace gui diff --git a/products/BellHybrid/apps/common/include/common/widgets/BellStatusClock.hpp b/products/BellHybrid/apps/common/include/common/widgets/BellStatusClock.hpp index 0b55936a60378540e21321b6adabacf44f8f282c..4be72793d98698d97acc39927d72ce0077088ff5 100644 --- a/products/BellHybrid/apps/common/include/common/widgets/BellStatusClock.hpp +++ b/products/BellHybrid/apps/common/include/common/widgets/BellStatusClock.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 @@ -12,10 +12,6 @@ namespace gui public: explicit BellStatusClock( 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); }; diff --git a/products/BellHybrid/apps/common/include/common/widgets/LayoutVertical.hpp b/products/BellHybrid/apps/common/include/common/widgets/LayoutVertical.hpp index 935420615f166eaa9f647045bf595080206288e4..fe4f29dee06a3bfe667f81a307d973f34bee944d 100644 --- a/products/BellHybrid/apps/common/include/common/widgets/LayoutVertical.hpp +++ b/products/BellHybrid/apps/common/include/common/widgets/LayoutVertical.hpp @@ -16,6 +16,7 @@ namespace style::homescreen_vertical constexpr inline auto leftMargin = 60U; constexpr inline auto rightMargin = 60U; constexpr inline auto topNegativeMargin = -35; + constexpr inline auto info_line_h = 44U; } // namespace style::homescreen_vertical namespace gui @@ -37,19 +38,20 @@ namespace gui LayoutVertical( Item *parent, const uint32_t &x = 0, const uint32_t &y = 0, const uint32_t &w = 0, const uint32_t &h = 0); - HBox *mainScreen{}; - BellBaseLayout *setAlarmScreen{}; - Icon *alarmActivatedDeactivatedScreen{}; - AlarmIcon *alarmMainIcon{}; - BellBattery *battery{}; + HBox *mainScreen = nullptr; + BellBaseLayout *setAlarmScreen = nullptr; + Icon *alarmActivatedDeactivatedScreen = nullptr; + AlarmIcon *alarmMainIcon = nullptr; + TimeSetFmtSpinner *alarmMainTime = nullptr; + BellBattery *battery = nullptr; // Main Screen - ClockVertical *time{}; - VBox *leftBox{}; - VBox *rightBox{}; + ClockVertical *time = nullptr; + VBox *leftBox = nullptr; + VBox *rightBox = nullptr; // Set Alarm Screen - AlarmIcon *alarmTopIcon{}; - TimeSetFmtSpinner *setAlarmFmtSpinner{}; + AlarmIcon *alarmTopIcon = nullptr; + TimeSetFmtSpinner *setAlarmFmtSpinner = nullptr; }; }; // namespace gui diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp index 270b697c339bf85c5db4397e90e7ae042c70d9a9..448e979854125cd923a22efe79c919ec4d25dd66 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassic.cpp @@ -21,7 +21,7 @@ namespace bool isBatteryCharging(const Store::Battery::State state) { using State = Store::Battery::State; - return state == State::Charging or state == State::ChargingDone; + return (state == State::Charging) || (state == State::ChargingDone); } } // namespace @@ -50,28 +50,32 @@ namespace gui snoozeTimer->setVisible(false); snoozeTimer->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); - time = new TimeSetFmtSpinner(this->centerBox); - time->setMaximumSize(style::bell_base_layout::w, style::bell_base_layout::h); + timeHBox = new HBox(this->centerBox); + timeHBox->setMaximumSize(style::bell_base_layout::center_layout_w, style::bell_base_layout::center_layout_h); + timeHBox->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); + timeHBox->setEdges(RectangleEdge::None); + + time = new TimeSetFmtSpinner(timeHBox); + time->setMaximumSize(style::bell_base_layout::center_layout_w, style::bell_base_layout::center_layout_h); time->setFont(mainWindow::time::font); time->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); time->setEditMode(EditMode::Browse); time->activeItem = false; - statusBox = new DuoHBox(this->lastBox, 0, 0, 0, 0); - statusBox->setMinimumSize(style::bell_base_layout::outer_layouts_w, style::bell_base_layout::outer_layouts_h); + statusBox = new HBox(this->lastBox); + statusBox->setMinimumSize(style::homescreen_classic::status_box_layout_w, + style::bell_base_layout::outer_layouts_h); statusBox->setEdges(RectangleEdge::None); statusBox->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); statusBox->setVisible(true); - battery = new BellBattery(nullptr, 0, 0, 0, 0); - battery->setMinimumSize(battery::battery_widget_w, battery::battery_widget_h); + battery = new BellBattery(statusBox); + battery->setMaximumSize(battery::battery_widget_w, battery::battery_widget_h); battery->setEdges(RectangleEdge::None); battery->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); battery->setVisible(true); battery->setBatteryPercentMode(BatteryPercentMode::Show); - statusBox->setItems(battery, nullptr); - bottomText = new TextFixedSize(this->lastBox, 0, 0, 0, 0); bottomText->setMaximumSize(style::bell_base_layout::outer_layouts_w, style::bell_base_layout::outer_layouts_h); bottomText->setFont(mainWindow::bottomDescription::font_small); @@ -226,6 +230,8 @@ namespace gui void HomeScreenLayoutClassic::setTimeFormat(utils::time::Locale::TimeFormat fmt) { time->setTimeFormat(fmt); + // setTimeFormat makes AM/PM "visible" so disable it + time->setTimeFormatSpinnerVisibility(false); } void HomeScreenLayoutClassic::setAlarmTimeFormat(utils::time::Locale::TimeFormat fmt) diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithAmPm.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithAmPm.cpp index e7372cad01b1ae6c92c0fb6c37dc4baa9c48111f..dc8969e5aa30df260aebb48a7d89e2420f42f3b9 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithAmPm.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithAmPm.cpp @@ -21,15 +21,16 @@ namespace gui { using namespace bellMainStyle; - fmt = new TextFixedSize(nullptr, 0, 0, 0, 0); - fmt->setMaximumSize(style::homescreen_classic::bottom_box_w, style::homescreen_classic::bottom_box_h); + battery->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); + + fmt = new TextFixedSize(statusBox); + fmt->setMaximumSize(style::homescreen_classic::status_box_layout_w, style::bell_base_layout::outer_layouts_h); + fmt->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center)); fmt->setFont(mainWindow::bottomDescription::font_normal); fmt->setEdges(RectangleEdge::None); fmt->activeItem = false; fmt->drawUnderline(false); fmt->setText(""); - - statusBox->setItems(battery, fmt); } auto HomeScreenLayoutClassicWithAmPm::setTime(std::time_t newTime) -> void @@ -40,5 +41,23 @@ namespace gui const auto hours = std::chrono::hours{t->tm_hour}; const auto isPM = date::is_pm(hours); fmt->setText(isPM ? utils::time::Locale::getPM() : utils::time::Locale::getAM()); + fmt->setMinimumWidthToFitText(); + fmt->setMaximumWidth(fmt->widgetMinimumArea.w); + } + + bool HomeScreenLayoutClassicWithAmPm::isBatteryVisibilityAllowed(const Store::Battery &batteryContext) + { + return HomeScreenLayoutClassic::isBatteryVisibilityAllowed(batteryContext); + } + + void HomeScreenLayoutClassicWithAmPm::handleContentChanged() + { + if (battery->visible) { + fmt->setMargins({20, 0, 0, 0}); + } + else { + fmt->setMargins({0, 0, 0, 0}); + } + HomeScreenLayoutClassic::handleContentChanged(); } }; // namespace gui diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithDate.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithDate.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8c3d497b5fa112a1c7aff8fe8ab8153c2545826d --- /dev/null +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithDate.cpp @@ -0,0 +1,92 @@ +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "layouts/HomeScreenLayoutClassicWithDate.hpp" +#include "data/BellMainStyle.hpp" +#include "widgets/BellBattery.hpp" +#include "widgets/DuoHBox.hpp" + +#include +#include +#include + +namespace gui +{ + HomeScreenLayoutClassicWithDate::HomeScreenLayoutClassicWithDate(std::string name) + : HomeScreenLayoutClassic(std::move(name)) + { + buildInterface(); + } + + void HomeScreenLayoutClassicWithDate::buildInterface() + { + using namespace bellMainStyle; + + date = new Text(nullptr); + date->setMaximumSize(style::homescreen_classic::status_box_layout_w, style::bell_base_layout::outer_layouts_h); + date->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Center)); + date->setFont(mainWindow::bottomDescription::font_normal); + date->setEdges(RectangleEdge::None); + date->activeItem = false; + date->drawUnderline(false); + date->setText("00/00"); + date->setMargins({0, 0, 20, 0}); + + statusBox->removeWidget(battery); + statusBox->addWidget(date); + statusBox->addWidget(battery); + + // Assume format is 12h + time->setMargins({style::homescreen_classic::ampm_time_margin_w, 0, 0, 0}); + + ampm = new TextFixedSize(timeHBox); + ampm->setMinimumSize(style::homescreen_classic::ampm_layout_w, style::bell_base_layout::center_layout_h); + ampm->setMaximumSize(style::homescreen_classic::ampm_layout_w, style::bell_base_layout::center_layout_h); + ampm->setMargins({style::homescreen_classic::ampm_margin_w, 0, 0, 0}); + ampm->setFont(mainWindow::time::font_small); + ampm->setAlignment(Alignment(Alignment::Horizontal::Left, Alignment::Vertical::Top)); + ampm->setEdges(RectangleEdge::None); + ampm->activeItem = false; + ampm->drawUnderline(false); + + resizeItems(); + } + + void HomeScreenLayoutClassicWithDate::setTime(std::time_t newTime) + { + HomeScreenLayoutClassic::setTime(newTime); + + const auto t = std::localtime(&newTime); + std::stringstream ss; + ss << std::setfill('0') << std::setw(2) << t->tm_mday; + ss << '/'; + ss << std::setfill('0') << std::setw(2) << (t->tm_mon + 1); + + date->setText(ss.str()); + + if (ampm->visible) { + const auto hours = std::chrono::hours{t->tm_hour}; + const auto isPM = date::is_pm(hours); + ampm->setText(isPM ? utils::time::Locale::getPM() : utils::time::Locale::getAM()); + } + } + + void HomeScreenLayoutClassicWithDate::setTimeFormat(utils::time::Locale::TimeFormat fmt) + { + HomeScreenLayoutClassic::setTimeFormat(fmt); + if (fmt == utils::time::Locale::TimeFormat::FormatTime12H) { + time->setMargins({style::homescreen_classic::ampm_time_margin_w, 0, 0, 0}); + ampm->setVisible(true); + } + else { + time->setMargins({0, 0, 0, 0}); + ampm->setVisible(false); + } + } + + bool HomeScreenLayoutClassicWithDate::isBatteryVisibilityAllowed(const Store::Battery &batteryContext) + { + return true; + } + +}; // namespace gui diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithTemp.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithTemp.cpp index 27eb09639a0d481e08f279b8a2eb0d4aba52254b..c5eec038d7064eb29030df9dc1e637d98753dcda 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithTemp.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutClassicWithTemp.cpp @@ -20,14 +20,12 @@ namespace gui { using namespace bellMainStyle; - tempText = new TextFixedSize(nullptr, 0, 0, 0, 0); + tempText = new TextFixedSize(statusBox); tempText->setMaximumSize(style::homescreen_classic::temperature_w, style::homescreen_classic::temperature_h); tempText->setFont(mainWindow::bottomDescription::font_normal); tempText->setEdges(RectangleEdge::None); tempText->activeItem = false; tempText->drawUnderline(false); - - statusBox->setItems(battery, tempText); } auto HomeScreenLayoutClassicWithTemp::setTemperature(utils::temperature::Temperature newTemp) -> void diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp index 4c11ce770516d88d70346fe5326e6cd75a7a14a9..078aa2fb95b1c95697c503cdbf832cb29cf1e1ae 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVertical.cpp @@ -18,12 +18,6 @@ namespace { constexpr auto dischargingLevelShowTop = 20; - - bool isBatteryCharging(const Store::Battery::State state) - { - using State = Store::Battery::State; - return state == State::Charging or state == State::ChargingDone; - } } // namespace namespace gui @@ -44,6 +38,7 @@ namespace gui case app::home_screen::ViewState::Deactivated: alarmActivatedDeactivatedScreen->image->set("big_no-alarm_W_G", {}); alarmMainIcon->setVisible(false); + alarmMainTime->setVisible(false); alarmTopIcon->setStatus(AlarmIcon::Status::DEACTIVATED); setScreenMode(ScreenMode::Main); break; @@ -67,12 +62,21 @@ namespace gui alarmActivatedDeactivatedScreen->image->set("big_alarm_W_G", {}); alarmMainIcon->setVisible(true); alarmMainIcon->setStatus(AlarmIcon::Status::ACTIVATED); + if (isAlarmTimeVisibilityAllowed()) { + alarmMainTime->setVisible(true); + // For unknown reason the mode is modified by showing/hiding windows + alarmMainTime->setEditMode(EditMode::Browse); + } + else { + alarmMainTime->setVisible(false); + } alarmTopIcon->setStatus(AlarmIcon::Status::ACTIVATED); setScreenMode(ScreenMode::Main); break; case app::home_screen::ViewState::AlarmRinging: setScreenMode(ScreenMode::Main); alarmMainIcon->setStatus(AlarmIcon::Status::RINGING); + alarmMainTime->setVisible(false); break; case app::home_screen::ViewState::AlarmRingingDeactivatedWait: setScreenMode(ScreenMode::AlarmActivatedDeactivated); @@ -80,11 +84,13 @@ namespace gui break; case app::home_screen::ViewState::AlarmSnoozedWait: alarmMainIcon->setStatus(AlarmIcon::Status::SNOOZE); + alarmMainTime->setVisible(false); alarmActivatedDeactivatedScreen->image->set("big_alarm_snoozed_W_M", {}); setScreenMode(ScreenMode::AlarmActivatedDeactivated); break; case app::home_screen::ViewState::AlarmSnoozed: alarmMainIcon->setStatus(AlarmIcon::Status::SNOOZE); + alarmMainTime->setVisible(false); setScreenMode(ScreenMode::Main); break; } @@ -126,7 +132,18 @@ namespace gui bool HomeScreenLayoutVertical::isBatteryVisibilityAllowed(const Store::Battery &batteryContext) { - return (batteryContext.level < dischargingLevelShowTop) or isBatteryCharging(batteryContext.state); + return (batteryContext.level < dischargingLevelShowTop) || isBatteryCharging(batteryContext.state); + } + + bool HomeScreenLayoutVertical::isAlarmTimeVisibilityAllowed() + { + return false; + } + + bool HomeScreenLayoutVertical::isBatteryCharging(const Store::Battery::State state) + { + using State = Store::Battery::State; + return (state == State::Charging) || (state == State::ChargingDone); } void HomeScreenLayoutVertical::setBatteryLevelState(const Store::Battery &batteryContext) @@ -149,6 +166,7 @@ namespace gui void HomeScreenLayoutVertical::setAlarmTimeFormat(utils::time::Locale::TimeFormat fmt) { setAlarmFmtSpinner->setTimeFormat(fmt); + alarmMainTime->setTimeFormat(fmt); } void HomeScreenLayoutVertical::setTimeFormat(utils::time::Locale::TimeFormat fmt) @@ -169,6 +187,7 @@ namespace gui void HomeScreenLayoutVertical::setAlarmTime(std::time_t newTime) { setAlarmFmtSpinner->setTime(newTime); + alarmMainTime->setTime(newTime); } auto HomeScreenLayoutVertical::getLayout() -> Item * diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalWithAmPm.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalWithAmPm.cpp index a98a7fda4df8bf461fa85563b638181e82e91916..c04a6973c67c5f2e31fc0102ff879e282b25c56a 100644 --- a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalWithAmPm.cpp +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalWithAmPm.cpp @@ -44,18 +44,18 @@ namespace gui battery->setMargins(Margins{0, 0, 0, style::homescreen_vertical_ampm::battery_margin_bot}); rightBox->setAlignment(Alignment(Alignment::Horizontal::Right, Alignment::Vertical::Bottom)); - fmt = new TextFixedSize(rightBox, 0, 0, 0, 0); - fmt->setMaximumSize(style::bell_base_layout::outer_layouts_w, style::bell_base_layout::outer_layouts_h); - fmt->setFont(mainWindow::bottomDescription::font_normal); - fmt->setEdges(RectangleEdge::None); - fmt->activeItem = false; - fmt->drawUnderline(false); - fmt->setMargins(Margins{0, 0, 0, style::homescreen_vertical_ampm::fmt_margin_bot}); - fmt->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Bottom)); + ampm = new TextFixedSize(rightBox, 0, 0, 0, 0); + ampm->setMaximumSize(style::bell_base_layout::outer_layouts_w, style::bell_base_layout::outer_layouts_h); + ampm->setFont(mainWindow::bottomDescription::font_normal); + ampm->setEdges(RectangleEdge::None); + ampm->activeItem = false; + ampm->drawUnderline(false); + ampm->setMargins(Margins{0, 0, 0, style::homescreen_vertical_ampm::ampm_margin_bot}); + ampm->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Bottom)); alarmMainIcon->informContentChanged(); battery->informContentChanged(); - fmt->informContentChanged(); + ampm->informContentChanged(); } auto HomeScreenLayoutVerticalWithAmPm::setTime(std::time_t newTime) -> void @@ -65,6 +65,6 @@ namespace gui const auto t = std::localtime(&newTime); const auto hours = std::chrono::hours{t->tm_hour}; const auto isPM = date::is_pm(hours); - fmt->setText(isPM ? utils::time::Locale::getPM() : utils::time::Locale::getAM()); + ampm->setText(isPM ? utils::time::Locale::getPM() : utils::time::Locale::getAM()); } }; // namespace gui diff --git a/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalWithDate.cpp b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalWithDate.cpp new file mode 100644 index 0000000000000000000000000000000000000000..96113aa8dcd308de38f687978153625f9a920a40 --- /dev/null +++ b/products/BellHybrid/apps/common/src/layouts/HomeScreenLayoutVerticalWithDate.cpp @@ -0,0 +1,129 @@ +// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved. +// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md + +#include "layouts/HomeScreenLayoutVerticalWithDate.hpp" +#include "data/BellMainStyle.hpp" +#include "widgets/BellBattery.hpp" +#include "widgets/SnoozeTimer.hpp" + +#include +#include +#include +#include +#include +#include