// 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 #include #include namespace gui::nav_bar { enum class Side { Left, Center, Right }; /// Footer for most design windows /// /// Consists of 3 areas right now `[ left ] [ center ] [ right ]` /// these areas most of times inform user about possibility to execute action with keys /// left is left action key, center describes center (enter) key, and right right action key /// depending on screen selected elements will be visible /// @note when in Text widget it will show input mode if enabled in [ left ] area class NavBar : public Rect { protected: struct Cache { private: struct { bool isVisible = false; UTF8 text; bool stored = false; } left, center, right; public: auto get(Side side) -> auto & { switch (side) { case Side::Left: return left; case Side::Right: return right; case Side::Center: return center; } return left; } } cache; Label *left = nullptr; Label *center = nullptr; Label *right = nullptr; gui::Label *prepareLabel(nav_bar::Side side); Label *getSide(nav_bar::Side side); public: NavBar(); NavBar(Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h); virtual ~NavBar(); void setActive(nav_bar::Side side, bool active); bool isActive(nav_bar::Side side); void setText(nav_bar::Side side, const UTF8 &str, bool active = true); UTF8 getText(nav_bar::Side side); void store(); void store(Side side); void restore(); void restore(Side side); void setFont(Side side, const UTF8 &fontName); bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override; void accept(GuiVisitor &visitor) override; }; } // namespace gui::nav_bar