mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-04-19 14:40:57 -04:00
80 lines
3.4 KiB
C++
80 lines
3.4 KiB
C++
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
|
|
#include <widgets/spinners/Spinners.hpp>
|
|
#include <gui/widgets/Style.hpp>
|
|
#include <gui/widgets/text/TextConstants.hpp>
|
|
|
|
#include <string>
|
|
|
|
namespace style::time_set_spinner
|
|
{
|
|
namespace focus
|
|
{
|
|
inline constexpr auto size = 6U;
|
|
} // namespace focus
|
|
|
|
inline constexpr auto small_margin = 6U;
|
|
inline constexpr auto big_margin = 6U;
|
|
} // namespace style::time_set_spinner
|
|
|
|
namespace gui
|
|
{
|
|
class ImageBox;
|
|
|
|
class TimeSetSpinner : public HBox
|
|
{
|
|
public:
|
|
explicit TimeSetSpinner(Item *parent);
|
|
TimeSetSpinner(Item *parent, Length x, Length y, Length w, Length h);
|
|
|
|
auto setTime(std::time_t time) noexcept -> void;
|
|
auto setTime(int hourValue, int minuteValue) noexcept -> void;
|
|
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 setEditMode(EditMode editMode) noexcept -> void;
|
|
auto setHourRange(std::uint32_t min, std::uint32_t max) -> void;
|
|
[[nodiscard]] auto getHour() const noexcept -> int;
|
|
[[nodiscard]] auto getMinute() const noexcept -> int;
|
|
|
|
private:
|
|
std::map<std::string, std::string> colonFontMap = {
|
|
{style::window::font::verybiglight, "alarm_colon_W_M"},
|
|
{style::window::font::largelight, "alarm_colon_W_M"},
|
|
{style::window::font::supersizemelight, "alarm_colon_select_W_M"},
|
|
{style::window::font::huge, "alarm_colon_clock_W_M"}};
|
|
|
|
std::map<std::string, Margins> colonMarginsMap = {
|
|
{style::window::font::verybiglight,
|
|
{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::supersizemelight,
|
|
{style::time_set_spinner::big_margin, 0, style::time_set_spinner::big_margin, 0}},
|
|
{style::window::font::huge,
|
|
{style::time_set_spinner::big_margin, 0, style::time_set_spinner::big_margin, 0}}};
|
|
|
|
UIntegerSpinner *hour = nullptr;
|
|
ImageBox *colon = nullptr;
|
|
UIntegerSpinnerFixed *minute = nullptr;
|
|
EditMode editMode = EditMode::Edit;
|
|
Item *lastFocus = nullptr;
|
|
std::string focusFontName = style::window::font::supersizeme;
|
|
std::string noFocusFontName = style::window::font::supersizemelight;
|
|
|
|
void updateFocus(Item *newFocus);
|
|
auto handleEnterKey() -> bool;
|
|
auto handleRightFunctionKey() -> bool;
|
|
auto applySizeRestrictions() -> void;
|
|
auto onInput(const InputEvent &inputEvent) -> bool override;
|
|
[[nodiscard]] auto getFontHeight(const std::string &fontName) const noexcept -> uint16_t;
|
|
[[nodiscard]] auto getColonImage(const std::string &colonFont) const noexcept -> std::string;
|
|
[[nodiscard]] auto getColonMargins(const std::string &colonFont) const noexcept -> Margins;
|
|
};
|
|
} /* namespace gui */
|