~aleteoryx/muditaos

ref: 103af76459540f4a5fbf93e04496ca25f07313b4 muditaos/module-apps/application-desktop/windows/MenuWindow.hpp -rw-r--r-- 1.7 KiB
103af764 — SP2FET [EGD-4836] Add firmware update test 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// 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 <vector>

#include "AppWindow.hpp"
#include "GridLayout.hpp"
#include "widgets/BottomBar.hpp"
#include "widgets/Label.hpp"
#include "widgets/Rect.hpp"
#include "widgets/TopBar.hpp"

#include "utf8/UTF8.hpp"

namespace gui
{
    /// icon, description, name of application to run
    struct Tile : public Rect
    {
        Tile(UTF8 icon,
             std::string title,
             std::function<bool(Item &)> activatedCallback,
             unsigned int notifications = 0);
    };

    class MenuPage : public gui::GridLayout
    {
      public:
        bool first_time_selection = true;
        /// position of element which should be selected on start
        const unsigned int first_time_selected = 3;

        UTF8 title;
        MenuPage(gui::Item *parent, UTF8 title, std::vector<Tile *> tiles);
        /// set child which should be selected on start of desktop
        void setFirstTimeSelection();
    };

    class MenuWindow : public AppWindow
    {
      protected:
        // page that is currently selected by the user.
        MenuPage *mainMenu  = nullptr;
        MenuPage *toolsMenu = nullptr;

      public:
        MenuWindow(app::Application *app);

        void onBeforeShow(ShowMode mode, SwitchData *data) override;
        bool onInput(const InputEvent &inputEvent) override;

        void rebuild() override;
        void buildInterface() override;
        void destroyInterface() override;

        void switchMenu(MenuPage *page);

      private:
        void invalidate() noexcept;
    };

} /* namespace gui */