Files
MuditaOS/module-apps/application-meditation/widgets/IntervalBox.hpp
Maciej-Mudita cd54ba0589 [MOS-202] Add meditation parameters to non-volatile memory
The meditation parameters set by the user will be remembered.

style check fix
2023-02-24 13:16:55 +01:00

40 lines
1.2 KiB
C++

// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
#include <gui/widgets/BoxLayout.hpp>
#include <gui/widgets/Image.hpp>
#include <gui/widgets/text/Label.hpp>
#include <apps-common/widgets/TextSpinnerBoxWithLabel.hpp>
#include <list>
#include <chrono>
namespace gui
{
class TimerProperty;
class IntervalBox : public HBox
{
TimerProperty *timerSetter = nullptr;
TextSpinnerBoxWithLabel *chimeSpinner = nullptr;
void build();
void updateIntervals();
[[nodiscard]] std::string intervalToString(std::chrono::minutes time);
[[nodiscard]] std::chrono::minutes stringToInterval(const std::string &description);
void rescaleIntervals();
public:
using OnChangeCallback = std::function<void(std::chrono::minutes newValue)>;
IntervalBox(Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h, TimerProperty *timerSetter);
[[nodiscard]] std::chrono::seconds getIntervalValue() noexcept;
bool setIntervalValue(std::chrono::minutes newValue);
void setOnChangeCallback(OnChangeCallback &callback);
};
} // namespace gui