FreeRDP
Loading...
Searching...
No Matches
SDL3/dialogs/sdl_connection_dialog.hpp
1
19
20#pragma once
21
22#include <memory>
23#include <mutex>
24#include <string>
25#include <vector>
26
27#include <SDL3/SDL.h>
28
29#include "sdl_buttons.hpp"
30#include "sdl_connection_dialog_wrapper.hpp"
31#include "sdl_widget.hpp"
32#include "sdl_widget_list.hpp"
33
35{
36 public:
37 explicit SDLConnectionDialog(rdpContext* context);
38 SDLConnectionDialog(const SDLConnectionDialog& other) = delete;
39 SDLConnectionDialog(const SDLConnectionDialog&& other) = delete;
40 ~SDLConnectionDialog() override;
41
42 SDLConnectionDialog& operator=(const SDLConnectionDialog& other) = delete;
43 SDLConnectionDialog& operator=(SDLConnectionDialog&& other) = delete;
44
45 WINPR_ATTR_FORMAT_ARG(2, 3)
46 [[nodiscard]] bool setTitle(WINPR_FORMAT_ARG const char* fmt, ...);
47 WINPR_ATTR_FORMAT_ARG(2, 3)
48 [[nodiscard]] bool showInfo(WINPR_FORMAT_ARG const char* fmt, ...);
49 WINPR_ATTR_FORMAT_ARG(2, 3)
50 [[nodiscard]] bool showWarn(WINPR_FORMAT_ARG const char* fmt, ...);
51 WINPR_ATTR_FORMAT_ARG(2, 3)
52 [[nodiscard]] bool showError(WINPR_FORMAT_ARG const char* fmt, ...);
53
54 [[nodiscard]] bool show();
55 [[nodiscard]] bool hide();
56
57 [[nodiscard]] bool running() const;
58 [[nodiscard]] bool wait(bool ignoreRdpContextQuit = false);
59
60 [[nodiscard]] bool handle(const SDL_Event& event);
61
62 [[nodiscard]] bool visible() const override;
63
64 protected:
65 [[nodiscard]] bool updateInternal() override;
66
67 private:
68 [[nodiscard]] bool createWindow();
69 void destroyWindow();
70
71 [[nodiscard]] bool updateMsg(SdlConnectionDialogWrapper::MsgType type);
72
73 [[nodiscard]] bool setModal();
74
75 [[nodiscard]] bool show(SdlConnectionDialogWrapper::MsgType type, const char* fmt, va_list ap);
76 [[nodiscard]] bool show(SdlConnectionDialogWrapper::MsgType type);
77
78 [[nodiscard]] static std::string print(const char* fmt, va_list ap);
79 [[nodiscard]] bool setTimer(Uint32 timeoutMS = 15000);
80 void resetTimer();
81
82 [[nodiscard]] static Uint32 timeout(void* pvthis, SDL_TimerID timerID, Uint32 intervalMS);
83
84 struct widget_cfg_t
85 {
86 SDL_Color fgcolor = {};
87 SDL_Color bgcolor = {};
88 SdlWidget widget;
89 };
90
91 rdpContext* _context = nullptr;
92 mutable std::mutex _mux;
93 std::string _title;
94 std::string _msg;
95 SdlConnectionDialogWrapper::MsgType _type_active = SdlConnectionDialogWrapper::MSG_NONE;
96 SDL_TimerID _timer = 0;
97 bool _running = false;
98 std::vector<widget_cfg_t> _list;
99};