~aleteoryx/muditaos

ref: 7fbaf735ed99f5b0d26adb686cfa6ed2bb4267d5 muditaos/module-apps/apps-common/windows/AppWindow.hpp -rw-r--r-- 4.3 KiB
7fbaf735 — Przemyslaw Brudny [EGD-7813] Option Window titles localizations fix 4 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// 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 <gui/widgets/StatusBar.hpp>
#include <gui/widgets/header/Header.hpp>
#include <gui/widgets/BottomBar.hpp>
#include <gui/widgets/Window.hpp>
#include <Service/Service.hpp>
#include <Service/Message.hpp>

namespace app
{
    class ApplicationCommon;
};

namespace gui
{
    namespace name
    {
        namespace window
        {
            inline constexpr auto main_window = "MainWindow";
            inline constexpr auto no_window   = "";
        } // namespace window
    }     // namespace name

    /*
     * @brief This is wrapper for gui window used within applications.
     */
    class AppWindow : public Window
    {
      protected:
        /**
         * Information bar for signal, battery and lock icon on the top of the screen.
         */
        gui::status_bar::StatusBar *statusBar = nullptr;
        /**
         * Information bar for window title and additional action buttons.
         */
        gui::header::Header *header = nullptr;
        /**
         * Information bar for the buttons on the bottom of the page.
         */
        gui::BottomBar *bottomBar = nullptr;
        /**
         * Pointer to the application object that owns the window.
         */
        app::ApplicationCommon *application = nullptr;

        /**
         * A function that applies configuration changes to the current status bar configuration.
         */
        using StatusBarConfigurationChangeFunction =
            std::function<status_bar::Configuration(status_bar::Configuration)>;

        /**
         * A flag that is set if current window state requires the phone to stay unlocked
         */
        bool preventsAutoLock = false;

      public:
        AppWindow() = delete;
        AppWindow(app::ApplicationCommon *app, std::string name);

        app::ApplicationCommon *getApplication()
        {
            return application;
        };

        std::string getUniqueName() override;

        virtual bool onDatabaseMessage(sys::Message *msg);

        bool updateBluetooth(sys::bluetooth::BluetoothMode mode);
        bool updateAlarmClock(bool status);
        bool updateSim();
        bool updateBatteryStatus();
        bool updateSignalStrength();
        bool updateNetworkAccessTechnology();
        void updatePhoneMode(sys::phone_modes::PhoneMode mode);
        [[nodiscard]] bool preventsAutoLocking() const noexcept;
        virtual bool updateTime();

        void rebuild() override;
        void buildInterface() override;
        void destroyInterface() override;
        bool onInput(const InputEvent &inputEvent) override;
        void accept(GuiVisitor &visitor) override;

        /**
         * Configure the status bar using window-specific configuration.
         * @param appConfiguration      Application-wide status bar configuration that it to be modified.
         * @return window-specific configuration of the status bar.
         */
        virtual status_bar::Configuration configureStatusBar(status_bar::Configuration appConfiguration);

        /**
         * Applies configuration change on the current status bar configuration.
         * @param configChange  The function that contains the status bar configuration changes.
         */
        void applyToStatusBar(StatusBarConfigurationChangeFunction configChange);

        void setTitle(const UTF8 &text);
        [[nodiscard]] UTF8 getTitle();

        /// Setting bottom bar temporary text
        /// @param text - bottomBar text
        /// @param overwriteOthers - set or not other bottomBar texts to "" (default true)
        void bottomBarTemporaryMode(const UTF8 &text, bool emptyOthers = true);
        void bottomBarTemporaryMode(const UTF8 &text, BottomBar::Side side, bool emptyOthers = true);
        void bottomBarRestoreFromTemporaryMode();
        void setBottomBarText(const UTF8 &text, BottomBar::Side side);
        void clearBottomBarText(BottomBar::Side side);
        bool selectSpecialCharacter();
        void setBottomBarActive(BottomBar::Side side, bool value);

        /// get BoundingBox size of Window "body" area
        /// @note it would be much better to just have "body item" instead
        /// but it would mean not insignificant refactor
        BoundingBox bodySize();
    };

} /* namespace gui */