// 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 "Text.hpp" #include #include namespace gui { class TextSpinner : public Text { public: using TextRange = std::vector; using Position = std::uint32_t; using Range = std::pair; TextSpinner() = delete; TextSpinner(const TextRange &range, Boundaries boundaries); /// Sets range of strings to spin over void setTextRange(const TextRange &range); /// Sets current position. Must be within valid @ref Range that can be checked by @ref getValidRange void setCurrentPosition(Position pos); [[nodiscard]] std::string getCurrentText() const noexcept; [[nodiscard]] Range getValidRange() const noexcept; void stepUp(); void stepDown(); // virtual methods from Item bool onInput(const InputEvent &inputEvent) override; bool onFocus(bool state) override; private: TextRange textRange; Position currentPosition = 0; Boundaries boundaries = Boundaries::Continuous; void update(); Position getRangeUpLimit() const; Position getRangeDownLimit() const; }; } // namespace gui