~aleteoryx/muditaos

6591cdcef030af8dd757e9d580214e694104c8d2 — Mateusz Piesta 4 years ago 73469df
[BH-1021] Unify ListItem arrows behavior

From now min/max arrow indicators behave
the same throughout the GUI.
M image/assets/lang/English.json => image/assets/lang/English.json +0 -1
@@ 645,7 645,6 @@
  "app_bell_settings_frontlight_top_message": "Frontlight intensity",
  "app_bell_settings_frontlight_finished_message": "Frontlight is set",
  "app_bell_powernap_session_ended_message": "<text>Hello!<br />Rise & shine</text>",
  "app_bell_background_sounds_timer_off": "OFF",
  "app_bell_background_sounds_timer_title": "Timer",
  "app_bell_turn_off_question": "Turn off the device?",
  "app_bell_goodbye": "Goodbye",

M module-apps/apps-common/widgets/TimeSetFmtSpinner.hpp => module-apps/apps-common/widgets/TimeSetFmtSpinner.hpp +1 -0
@@ 62,6 62,7 @@ namespace gui
        };

        std::map<std::string, Margins> fmtMarginsMap = {
            {style::window::font::verybiglight, {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}}};

M module-apps/apps-common/widgets/TimeSetSpinner.hpp => module-apps/apps-common/widgets/TimeSetSpinner.hpp +3 -0
@@ 42,11 42,14 @@ namespace gui

      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,

M module-apps/apps-common/widgets/spinners/GenericSpinner.hpp => module-apps/apps-common/widgets/spinners/GenericSpinner.hpp +10 -0
@@ 27,6 27,8 @@ namespace gui
        void setFocusEdges(RectangleEdge edges);
        bool onInput(const InputEvent &inputEvent) override;
        bool onFocus(bool state) override;
        [[nodiscard]] bool isAtMin() const;
        [[nodiscard]] bool isAtMax() const;

        OnValueChanged onValueChanged;



@@ 142,4 144,12 @@ namespace gui
            onValueChanged(getCurrentValue());
        }
    }
    template <typename Policy> bool GenericSpinner<Policy>::isAtMin() const
    {
        return policy.isAtMin();
    }
    template <typename Policy> bool GenericSpinner<Policy>::isAtMax() const
    {
        return policy.isAtMax();
    }
} // namespace gui

M module-apps/apps-common/widgets/spinners/SpinnerPolicies.hpp => module-apps/apps-common/widgets/spinners/SpinnerPolicies.hpp +27 -0
@@ 85,6 85,15 @@ namespace gui
            }
        }

        [[nodiscard]] bool isAtMin() const
        {
            return pos == 0;
        }
        [[nodiscard]] bool isAtMax() const
        {
            return pos == upRange();
        }

      private:
        std::uint32_t upRange() const
        {


@@ 195,6 204,15 @@ namespace gui
            }
        }

        [[nodiscard]] bool isAtMin() const
        {
            return currentValue == range.min;
        }
        [[nodiscard]] bool isAtMax() const
        {
            return currentValue == range.max;
        }

      private:
        Range range;
        ValType currentValue{};


@@ 274,6 292,15 @@ namespace gui
            }
        }

        [[nodiscard]] bool isAtMin() const
        {
            return pos == 0;
        }
        [[nodiscard]] bool isAtMax() const
        {
            return pos == upRange();
        }

      private:
        std::uint32_t upRange() const
        {

M products/BellHybrid/apps/application-bell-background-sounds/data/BGSoundsStyle.hpp => products/BellHybrid/apps/application-bell-background-sounds/data/BGSoundsStyle.hpp +1 -0
@@ 11,6 11,7 @@ namespace gui::bgSoundsStyle
    inline constexpr auto titleFont       = style::window::font::largelight;
    inline constexpr auto timerValueFont  = style::window::font::supersizemelight;
    inline constexpr auto valumeValueFont = style::window::font::supersizemelight;
    inline constexpr auto bottomTimerFont = style::window::font::verybig;
    namespace progress
    {
        inline constexpr auto bottomDescTopMargin = 15U;

M products/BellHybrid/apps/application-bell-background-sounds/windows/BGSoundsProgressWindow.cpp => products/BellHybrid/apps/application-bell-background-sounds/windows/BGSoundsProgressWindow.cpp +1 -1
@@ 49,7 49,7 @@ namespace
        using namespace gui::bgSoundsStyle;
        auto timer = new gui::Text(
            parent, 0, 0, bell_base_layout::w, bell_base_layout::outer_layouts_h - progress::bottomDescTopMargin);
        timer->setFont(descriptionFont);
        timer->setFont(bottomTimerFont);
        timer->setMargins(gui::Margins(0, progress::bottomDescTopMargin, 0, 0));
        decorateProgressItem(timer, gui::Alignment::Vertical::Top);
        return timer;

M products/BellHybrid/apps/application-bell-background-sounds/windows/BGSoundsTimerSelectWindow.cpp => products/BellHybrid/apps/application-bell-background-sounds/windows/BGSoundsTimerSelectWindow.cpp +6 -2
@@ 16,7 16,7 @@ namespace

    const std::string &getOffValueText()
    {
        static const std::string offValueText = utils::translate("app_bell_background_sounds_timer_off");
        static const std::string offValueText = utils::translate("app_settings_toggle_off");
        return offValueText;
    }



@@ 85,7 85,7 @@ namespace gui
    {
        auto range = presenter->getTimerValuesRange();

        spinner = new UTF8Spinner(toUTF8Range(range));
        spinner = new UTF8Spinner(toUTF8Range(range), Boundaries::Fixed);
        spinner->setMaximumSize(style::bell_base_layout::w, style::bell_base_layout::h);
        spinner->setFont(bgSoundsStyle::timerValueFont);
        spinner->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));


@@ 93,7 93,11 @@ namespace gui
        spinner->setFocusEdges(RectangleEdge::None);
        auto currentValue = timerValueToUTF8(presenter->getCurrentTimerValue());
        spinner->setCurrentValue(std::move(currentValue));
        spinner->onValueChanged = [this](const auto &) {
            body->setMinMaxArrowsVisibility(spinner->isAtMin(), spinner->isAtMax());
        };
        body->getCenterBox()->addWidget(spinner);
        body->setMinMaxArrowsVisibility(spinner->isAtMin(), spinner->isAtMax());
    }

    void BGSoundsTimerSelectWindow::createBottomDescription()

M products/BellHybrid/apps/application-bell-settings/widgets/TemperatureUnitListItem.cpp => products/BellHybrid/apps/application-bell-settings/widgets/TemperatureUnitListItem.cpp +10 -4
@@ 15,13 15,15 @@ namespace gui
        setEdges(RectangleEdge::None);
        setFocusItem(body);

        temperatureUnit =
            new UTF8Spinner({utils::temperature::celsiusDegreeSymbol, utils::temperature::fahrenheitDegreeSymbol},
                            Boundaries::Continuous);
        temperatureUnit = new UTF8Spinner(
            {utils::temperature::celsiusDegreeSymbol, utils::temperature::fahrenheitDegreeSymbol}, Boundaries::Fixed);
        temperatureUnit->setMaximumSize(style::bell_base_layout::w, style::bell_base_layout::h);
        temperatureUnit->setFont(bell_settings_style::time_fmt_set_list_item::font);
        temperatureUnit->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));
        temperatureUnit->setFocusEdges(RectangleEdge::None);
        temperatureUnit->onValueChanged = [this](const auto &) {
            body->setMinMaxArrowsVisibility(temperatureUnit->isAtMin(), temperatureUnit->isAtMax());
        };

        body->getCenterBox()->addWidget(temperatureUnit);



@@ 34,7 36,10 @@ namespace gui
            return true;
        };

        inputCallback = [&](Item &, const InputEvent &inputEvent) -> bool { return body->onInput(inputEvent); };
        inputCallback = [this](Item &, const InputEvent &inputEvent) -> bool {
            const auto ret = body->onInput(inputEvent);
            return ret;
        };
    }

    auto TemperatureUnitListItem::getUnitAsStr() const noexcept -> UTF8


@@ 46,5 51,6 @@ namespace gui
        using namespace utils::temperature;
        temperatureUnit->setCurrentValue(unit == Temperature::Unit::Celsius ? celsiusDegreeSymbol
                                                                            : fahrenheitDegreeSymbol);
        body->setMinMaxArrowsVisibility(temperatureUnit->isAtMin(), temperatureUnit->isAtMax());
    }
} // namespace gui

M products/BellHybrid/apps/application-bell-settings/widgets/TimeFormatSetListItem.cpp => products/BellHybrid/apps/application-bell-settings/widgets/TimeFormatSetListItem.cpp +9 -2
@@ 26,11 26,14 @@ namespace gui
        setEdges(RectangleEdge::None);
        setFocusItem(body);

        timeFormat = new UTF8Spinner({fmtSpinner12H, fmtSpinner24H}, Boundaries::Continuous);
        timeFormat = new UTF8Spinner({fmtSpinner12H, fmtSpinner24H}, Boundaries::Fixed);
        timeFormat->setMaximumSize(style::bell_base_layout::w, style::bell_base_layout::center_layout_h);
        timeFormat->setFont(bell_settings_style::time_fmt_set_list_item::font);
        timeFormat->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));
        timeFormat->setFocusEdges(RectangleEdge::None);
        timeFormat->onValueChanged = [this](const auto &) {
            body->setMinMaxArrowsVisibility(timeFormat->isAtMin(), timeFormat->isAtMax());
        };

        body->getCenterBox()->addWidget(timeFormat);
        setupBottomDescription(botDesc);


@@ 53,7 56,10 @@ namespace gui
            return true;
        };

        inputCallback = [&](Item &, const InputEvent &inputEvent) -> bool { return body->onInput(inputEvent); };
        inputCallback = [this](Item &, const InputEvent &inputEvent) -> bool {
            const auto ret = body->onInput(inputEvent);
            return ret;
        };
    }

    auto TimeFormatSetListItem::getTimeFmt() const noexcept -> utils::time::Locale::TimeFormat


@@ 71,5 77,6 @@ namespace gui
        else if (fmt == Locale::TimeFormat::FormatTime24H) {
            timeFormat->setCurrentValue(fmtSpinner24H);
        }
        body->setMinMaxArrowsVisibility(timeFormat->isAtMin(), timeFormat->isAtMax());
    }
} // namespace gui