M module-apps/apps-common/widgets/AlarmSetSpinner.cpp => module-apps/apps-common/widgets/AlarmSetSpinner.cpp +2 -1
@@ 26,7 26,7 @@ namespace gui
alarmImg->setMargins(Margins(0, 0, 0, 0));
alarmImg->setMinimumSize(style::alarm_set_spinner::arrow::w, style::alarm_set_spinner::arrow::h);
- timeSpinner = new TimeSetFmtSpinner(this);
+ timeSpinner = new TimeSetFmtSpinner(this, TimeSetSpinner::Size::SMALL);
timeSpinner->setFont(style::window::font::largelight);
timeSpinner->setEditMode(EditMode::Browse);
timeSpinner->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));
@@ 103,6 103,7 @@ namespace gui
break;
case Status::RINGING:
alarmImg->setImage("bell_alarm_ringing_W_G");
+ alarmImg->setMinimumSizeToFitImage();
break;
case Status::SNOOZE:
alarmImg->setImage("bell_alarm_snooze_W_M");
M module-apps/apps-common/widgets/TimeSetFmtSpinner.cpp => module-apps/apps-common/widgets/TimeSetFmtSpinner.cpp +8 -4
@@ 2,7 2,6 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "TimeSetFmtSpinner.hpp"
-#include "TimeSetSpinner.hpp"
#include <date/date.h>
#include <gui/core/FontManager.hpp>
@@ 12,8 11,13 @@
namespace gui
{
- TimeSetFmtSpinner::TimeSetFmtSpinner(
- Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h, utils::time::Locale::TimeFormat timeFormat)
+ TimeSetFmtSpinner::TimeSetFmtSpinner(Item *parent,
+ TimeSetSpinner::Size size,
+ uint32_t x,
+ uint32_t y,
+ uint32_t w,
+ uint32_t h,
+ utils::time::Locale::TimeFormat timeFormat)
: HBox{parent, x, y, w, h}
{
using namespace utils;
@@ 21,7 25,7 @@ namespace gui
setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));
setEdges(RectangleEdge::None);
- timeSetSpinner = new TimeSetSpinner(this, 0, 0, 0, 0);
+ timeSetSpinner = new TimeSetSpinner(this, size, 0, 0, 0, 0);
timeSetSpinner->setFont(focusFontName, noFocusFontName);
timeSetSpinner->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));
timeSetSpinner->setMargins(Margins(0, 0, 0, 0));
M module-apps/apps-common/widgets/TimeSetFmtSpinner.hpp => module-apps/apps-common/widgets/TimeSetFmtSpinner.hpp +2 -2
@@ 7,13 7,12 @@
#include <gui/widgets/TextConstants.hpp>
#include <time/time_locale.hpp>
#include <widgets/spinners/Spinners.hpp>
+#include "TimeSetSpinner.hpp"
#include <string>
namespace gui
{
- class TimeSetSpinner;
-
/// Time set spinner widget class with option for dynamic switching between 24/12-hour format
/// Automatically recalculates hour upon switching format
/// Can be used as a basic time displaying widget when @ref EditMode set to 'Browse'
@@ 27,6 26,7 @@ namespace gui
public:
explicit TimeSetFmtSpinner(
Item *parent = nullptr,
+ TimeSetSpinner::Size size = TimeSetSpinner::Size::SMALL,
uint32_t x = 0U,
uint32_t y = 0U,
uint32_t w = 0U,
M module-apps/apps-common/widgets/TimeSetSpinner.cpp => module-apps/apps-common/widgets/TimeSetSpinner.cpp +22 -19
@@ 5,6 5,7 @@
#include <FontManager.hpp>
#include <RawFont.hpp>
+#include <gui/widgets/ImageBox.hpp>
#include <gui/widgets/Label.hpp>
static constexpr uint32_t hourMin = 0;
@@ 17,7 18,8 @@ static constexpr uint32_t noOfDigits = 2;
namespace gui
{
- TimeSetSpinner::TimeSetSpinner(Item *parent, Length x, Length y, Length w, Length h) : HBox(parent, x, y, w, h)
+ TimeSetSpinner::TimeSetSpinner(Item *parent, Size size, Length x, Length y, Length w, Length h)
+ : HBox(parent, x, y, w, h), colonIconData(getColonIconData(size))
{
setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));
setEdges(RectangleEdge::None);
@@ 33,12 35,10 @@ namespace gui
addWidget(hour);
- colon = new Label(this);
- updateColon(noFocusFontName);
+ colon = new ImageBox(this, 0, 0, colonIconData.w, colonIconData.h, new Image(colonIconData.iconName));
colon->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));
colon->setEdges(RectangleEdge::None);
colon->activeItem = false;
- colon->setText(":");
minute = new Spinner(minuteMin, minuteMax, minuteStep, Boundaries::Continuous);
updateFont(minute, noFocusFontName);
@@ 107,12 107,6 @@ namespace gui
return maxWidth;
}
- uint32_t TimeSetSpinner::getColonWidth(const std::string &fontName) const noexcept
- {
- const RawFont *font = FontManager::getInstance().getFont(fontName);
- return font->getCharPixelWidth(':');
- }
-
auto TimeSetSpinner::handleEnterKey() -> bool
{
if (focusItem == hour) {
@@ 152,10 146,9 @@ namespace gui
noFocusFontName = std::move(newNoFocusFontName);
updateFont(hour, noFocusFontName);
- updateColon(noFocusFontName);
updateFont(minute, noFocusFontName);
- setMinimumSize(hour->widgetMinimumArea.w + getColonWidth(noFocusFontName) + minute->widgetMinimumArea.w,
+ setMinimumSize(hour->widgetMinimumArea.w + colonIconData.w + minute->widgetMinimumArea.w,
getFontHeight(noFocusFontName));
resizeItems();
}
@@ 171,13 164,6 @@ namespace gui
elem->setText(elem->getText());
}
- auto TimeSetSpinner::updateColon(const std::string &fontName) noexcept -> void
- {
- colon->setFont(fontName);
- colon->setMinimumSize(getColonWidth(fontName), getFontHeight(fontName));
- colon->setText(":");
- }
-
auto TimeSetSpinner::setEditMode(EditMode editMode) noexcept -> void
{
this->editMode = editMode;
@@ 230,4 216,21 @@ namespace gui
setFocusItem(nullptr);
}
}
+
+ auto TimeSetSpinner::getColonIconData(Size size) const noexcept -> ColonIconData
+ {
+ using namespace style::time_set_spinner::colonIconSize;
+ static const ColonIconData smallColonIconData = {"alarm_colon_W_M", smallW, smallH};
+ static const ColonIconData mediumColonIconData = {"alarm_colon_select_W_M", mediumW, mediumH};
+ static const ColonIconData bigColonIconData = {"alarm_colon_clock_W_M", bigW, bigH};
+ switch (size) {
+ case Size::SMALL:
+ return smallColonIconData;
+ case Size::MEDIUM:
+ return mediumColonIconData;
+ case Size::BIG:
+ return bigColonIconData;
+ }
+ return {};
+ }
} /* namespace gui */
M module-apps/apps-common/widgets/TimeSetSpinner.hpp => module-apps/apps-common/widgets/TimeSetSpinner.hpp +33 -8
@@ 16,21 16,45 @@ namespace style::time_set_spinner
{
inline constexpr auto size = 6U;
} // namespace focus
+ namespace colonIconSize
+ {
+ inline constexpr auto smallW = 4U;
+ inline constexpr auto smallH = 21U;
+ inline constexpr auto mediumW = 7U;
+ inline constexpr auto mediumH = 26U;
+ inline constexpr auto bigW = 24U;
+ inline constexpr auto bigH = 84U;
+ } // namespace colonIconSize
} // namespace style::time_set_spinner
namespace gui
{
+ class ImageBox;
+
class TimeSetSpinner : public HBox
{
public:
- TimeSetSpinner(Item *parent, Length x, Length y, Length w, Length h);
+ enum class Size
+ {
+ SMALL,
+ MEDIUM,
+ BIG
+ };
+
+ struct ColonIconData
+ {
+ std::string iconName;
+ Length w;
+ Length h;
+ };
+
+ TimeSetSpinner(Item *parent, Size size, Length x, Length y, Length w, Length h);
auto setHour(int value) noexcept -> void;
auto setMinute(int value) noexcept -> void;
auto setFont(const std::string &newFontName) noexcept -> void;
auto setFont(std::string newFocusFontName, std::string newNoFocusFontName) noexcept -> void;
auto updateFont(TextFixedSize *elem, const std::string &fontName) noexcept -> void;
- auto updateColon(const std::string &fontName) noexcept -> void;
auto setEditMode(EditMode editMode) noexcept -> void;
auto setHourMax(std::uint32_t newMax) noexcept -> void;
auto setHourMin(std::uint32_t newMin) noexcept -> void;
@@ 38,11 62,12 @@ namespace gui
[[nodiscard]] auto getMinute() const noexcept -> int;
private:
- Spinner *hour = nullptr;
- Label *colon = nullptr;
- Spinner *minute = nullptr;
- EditMode editMode = EditMode::Edit;
- Item *lastFocus = nullptr;
+ Spinner *hour = nullptr;
+ ImageBox *colon = nullptr;
+ const ColonIconData colonIconData{};
+ Spinner *minute = nullptr;
+ EditMode editMode = EditMode::Edit;
+ Item *lastFocus = nullptr;
std::string focusFontName = style::window::font::supersizeme;
std::string noFocusFontName = style::window::font::supersizemelight;
@@ 52,6 77,6 @@ namespace gui
auto onInput(const InputEvent &inputEvent) -> bool override;
[[nodiscard]] auto getFontHeight(const std::string &fontName) const noexcept -> uint16_t;
[[nodiscard]] auto getWidestDigitWidth(const std::string &fontName) const noexcept -> uint32_t;
- [[nodiscard]] auto getColonWidth(const std::string &fontName) const noexcept -> uint32_t;
+ [[nodiscard]] auto getColonIconData(Size size) const noexcept -> ColonIconData;
};
} /* namespace gui */
M products/BellHybrid/apps/application-bell-alarm/windows/BellAlarmWindow.cpp => products/BellHybrid/apps/application-bell-alarm/windows/BellAlarmWindow.cpp +1 -1
@@ 45,7 45,7 @@ namespace gui
topText->activeItem = false;
topText->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));
- timeSetFmtSpinner = new TimeSetFmtSpinner(body->getCenterBox());
+ timeSetFmtSpinner = new TimeSetFmtSpinner(body->getCenterBox(), TimeSetSpinner::Size::MEDIUM);
timeSetFmtSpinner->setFont(bell_alarm_style::time_set_fmt_spinner::focusFont,
bell_alarm_style::time_set_fmt_spinner::noFocusFont);
timeSetFmtSpinner->setMaximumSize(style::bell_base_layout::w, style::bell_base_layout::h);
M products/BellHybrid/apps/application-bell-main/presenters/StateController.cpp => products/BellHybrid/apps/application-bell-main/presenters/StateController.cpp +7 -5
@@ 197,11 197,13 @@ namespace app::home_screen
namespace AlarmRinging
{
- auto entry = [](AbstractView &view, AbstractPresenter &presenter) {
- presenter.spawnTimer(defaultAlarmRingingTime);
- view.setAlarmTimeVisible(false);
- view.setAlarmTriggered();
- };
+ auto entry =
+ [](AbstractView &view, AbstractTemperatureModel &temperatureModel, AbstractPresenter &presenter) {
+ presenter.spawnTimer(defaultAlarmRingingTime);
+ view.setAlarmTimeVisible(false);
+ view.setAlarmTriggered();
+ view.setTemperature(temperatureModel.getTemperature());
+ };
auto exit = [](AbstractPresenter &presenter) { presenter.detachTimer(); };
} // namespace AlarmRinging
M products/BellHybrid/apps/application-bell-main/windows/BellHomeScreenWindow.cpp => products/BellHybrid/apps/application-bell-main/windows/BellHomeScreenWindow.cpp +2 -2
@@ 98,7 98,7 @@ namespace gui
alarm->setAlarmStatus(AlarmSetSpinner::Status::DEACTIVATED);
alarm->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));
- time = new TimeSetFmtSpinner(body->centerBox);
+ time = new TimeSetFmtSpinner(body->centerBox, TimeSetSpinner::Size::BIG);
time->setMaximumSize(style::bell_base_layout::w, style::bell_base_layout::h);
time->setFont(bellMainStyle::mainWindow::time::font);
time->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));
@@ 160,7 160,7 @@ namespace gui
void BellHomeScreenWindow::setTemperature(utils::temperature::Temperature newTemp)
{
bottomText->setFont(bellMainStyle::mainWindow::bottomDescription::font_normal);
- bottomText->setAlignment(Alignment(Alignment::Horizontal::Right, Alignment::Vertical::Center));
+ bottomText->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));
bottomText->setText(utils::temperature::tempToStrDec(newTemp));
bottomBox->resizeItems();
}
M products/BellHybrid/apps/application-bell-settings/widgets/TimeFormatSetListItem.cpp => products/BellHybrid/apps/application-bell-settings/widgets/TimeFormatSetListItem.cpp +2 -2
@@ 12,8 12,8 @@
namespace
{
- constexpr auto fmtSpinner12H = "12h";
- constexpr auto fmtSpinner24H = "24h";
+ constexpr auto fmtSpinner12H = "12 h";
+ constexpr auto fmtSpinner24H = "24 h";
} // namespace
namespace gui
M products/BellHybrid/apps/application-bell-settings/widgets/TimeSetListItem.cpp => products/BellHybrid/apps/application-bell-settings/widgets/TimeSetListItem.cpp +1 -1
@@ 14,7 14,7 @@ namespace gui
: BellSideListItem(std::move(description))
{
setMinimumSize(style::sidelistview::list_item::w, style::sidelistview::list_item::h);
- timeSetFmtSpinner = new TimeSetFmtSpinner(body->getCenterBox());
+ timeSetFmtSpinner = new TimeSetFmtSpinner(body->getCenterBox(), TimeSetSpinner::Size::MEDIUM);
timeSetFmtSpinner->setMaximumSize(style::bell_base_layout::w, style::bell_base_layout::h);
timeSetFmtSpinner->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));
setFocusItem(body);
M products/BellHybrid/apps/common/include/common/widgets/BellStatusClock.hpp => products/BellHybrid/apps/common/include/common/widgets/BellStatusClock.hpp +1 -0
@@ 12,6 12,7 @@ namespace gui
public:
explicit BellStatusClock(
Item *parent = nullptr,
+ TimeSetSpinner::Size size = TimeSetSpinner::Size::SMALL,
uint32_t x = 0U,
uint32_t y = 0U,
uint32_t w = 0U,
M products/BellHybrid/apps/common/src/TimeUtils.cpp => products/BellHybrid/apps/common/src/TimeUtils.cpp +2 -2
@@ 29,10 29,10 @@ namespace utils::time
return std::to_string(minutes) + " min";
}
else if (minutes == 0) {
- return std::to_string(hours) + " hrs";
+ return std::to_string(hours) + " h";
}
else {
- return std::to_string(hours) + " hrs & " + std::to_string(minutes) + " min";
+ return std::to_string(hours) + " h & " + std::to_string(minutes) + " min";
}
}(duration.getHours(), duration.getMinutes());
return UTF8("<text>" + prefix + "<br />" + translate("app_bellmain_home_screen_bottom_desc_in") + " " +
M products/BellHybrid/apps/common/src/widgets/BellStatusClock.cpp => products/BellHybrid/apps/common/src/widgets/BellStatusClock.cpp +8 -3
@@ 8,9 8,14 @@
namespace gui
{
- BellStatusClock::BellStatusClock(
- Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h, utils::time::Locale::TimeFormat timeFormat)
- : TimeSetFmtSpinner{parent, x, y, w, h, timeFormat}
+ BellStatusClock::BellStatusClock(Item *parent,
+ TimeSetSpinner::Size size,
+ uint32_t x,
+ uint32_t y,
+ uint32_t w,
+ uint32_t h,
+ utils::time::Locale::TimeFormat timeFormat)
+ : TimeSetFmtSpinner{parent, size, x, y, w, h, timeFormat}
{
setFont(bell_style::statusClockFont);
setEditMode(EditMode::Browse);