// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #pragma once #include #include #include #include namespace gui { class Item; enum class Arrow : bool { Disabled, Enabled }; namespace option { class Base { public: virtual ~Base() = default; [[nodiscard]] virtual auto build() const -> Item * = 0; [[nodiscard]] virtual auto str() const -> std::string { return ""; } }; class Simple : public Base { private: const UTF8 text = ""; std::function activatedCallback = nullptr; Arrow arrow = Arrow::Disabled; public: Simple(const UTF8 text, std::function activatedCallback, Arrow arrow) : text(text), activatedCallback(activatedCallback), arrow(arrow) {} [[nodiscard]] auto build() const -> Item * override; [[nodiscard]] auto str() const -> std::string override { return text; } }; }; // namespace option struct Option { private: std::unique_ptr option; public: Option(std::unique_ptr option) : option(std::move(option)) {} /// old one Option(const UTF8 text, std::function cb, Arrow arrow = Arrow::Disabled) : Option(std::make_unique(text, cb, arrow)) {} Option(const Option &o) = delete; Option(Option &&o) { this->option = std::move(o.option); } [[nodiscard]] auto build() const -> Item *; }; } // namespace gui