~aleteoryx/muditaos

muditaos/module-apps/apps-common/WindowsPopupRequest.hpp -rw-r--r-- 1.1 KiB
a405cad6Aleteoryx trim readme 6 days 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
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#pragma once

#include "popups/data/PopupRequestParamsBase.hpp"
#include <time/time_conversion.hpp>
#include <functional>

namespace gui::popup
{
    /// Blueprint to create popup window/handle popup action if there is no window when required
    using Blueprint = std::function<bool(gui::popup::ID, std::unique_ptr<gui::PopupRequestParams> &)>;

    /// sortable class to select holding all data to handle popup
    class Request
    {
        const gui::popup::ID id;
        std::unique_ptr<gui::PopupRequestParams> params;
        utils::time::Timestamp timeRequested;
        Blueprint blueprint;

      public:
        Request(gui::popup::ID id, std::unique_ptr<gui::PopupRequestParams> &&params, Blueprint blueprint);
        /// with no Blueprint attached - will raise std::bad_function_call
        bool handle();
        bool operator<(const Request &p) const;
        const gui::PopupRequestParams &getPopupParams() const;
    };
} // namespace gui::popup