FreeRDP
Loading...
Searching...
No Matches
SDL3/dialogs/sdl_connection_dialog.hpp
1
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 <freerdp/freerdp.h>
30
31#include "sdl_widget.hpp"
32#include "sdl_buttons.hpp"
33#include "sdl_connection_dialog_wrapper.hpp"
34
36{
37 public:
38 explicit SDLConnectionDialog(rdpContext* context);
39 SDLConnectionDialog(const SDLConnectionDialog& other) = delete;
40 SDLConnectionDialog(const SDLConnectionDialog&& other) = delete;
41 virtual ~SDLConnectionDialog();
42
43 SDLConnectionDialog& operator=(const SDLConnectionDialog& other) = delete;
44 SDLConnectionDialog& operator=(SDLConnectionDialog&& other) = delete;
45
46 bool visible() const;
47
48 bool setTitle(const char* fmt, ...);
49 bool showInfo(const char* fmt, ...);
50 bool showWarn(const char* fmt, ...);
51 bool showError(const char* fmt, ...);
52
53 bool show();
54 bool hide();
55
56 bool running() const;
57 bool wait(bool ignoreRdpContextQuit = false);
58
59 bool handle(const SDL_Event& event);
60
61 private:
62 bool createWindow();
63 void destroyWindow();
64
65 bool update();
66
67 bool setModal();
68
69 static bool clearWindow(SDL_Renderer* renderer);
70
71 bool update(SDL_Renderer* renderer);
72
73 bool show(SdlConnectionDialogWrapper::MsgType type, const char* fmt, va_list ap);
74 bool show(SdlConnectionDialogWrapper::MsgType type);
75
76 static std::string print(const char* fmt, va_list ap);
77 bool setTimer(Uint32 timeoutMS = 15000);
78 void resetTimer();
79
80 static Uint32 timeout(void* pvthis, SDL_TimerID timerID, Uint32 intervalMS);
81
82 struct widget_cfg_t
83 {
84 SDL_Color fgcolor = {};
85 SDL_Color bgcolor = {};
86 SdlWidget widget;
87 };
88
89 rdpContext* _context = nullptr;
90 SDL_Window* _window = nullptr;
91 SDL_Renderer* _renderer = nullptr;
92 mutable std::mutex _mux;
93 std::string _title;
94 std::string _msg;
95 SdlConnectionDialogWrapper::MsgType _type = SdlConnectionDialogWrapper::MSG_NONE;
96 SdlConnectionDialogWrapper::MsgType _type_active = SdlConnectionDialogWrapper::MSG_NONE;
97 SDL_TimerID _timer = 0;
98 bool _running = false;
99 std::vector<widget_cfg_t> _list;
100 SdlButtonList _buttons;
101};
102
104{
105 public:
106 explicit SDLConnectionDialogHider(freerdp* instance);
107 explicit SDLConnectionDialogHider(rdpContext* context);
108
111 SDLConnectionDialogHider& operator=(const SDLConnectionDialogHider& other) = delete;
112 SDLConnectionDialogHider& operator=(SDLConnectionDialogHider&& other) = delete;
113
115
116 private:
117 rdpContext* _context = nullptr;
118 bool _visible = false;
119};