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 "sdl_widget_list.hpp"
30#include "sdl_widget.hpp"
31#include "sdl_buttons.hpp"
32#include "sdl_connection_dialog_wrapper.hpp"
33
35{
36 public:
37 explicit SDLConnectionDialog(rdpContext* context);
38 SDLConnectionDialog(const SDLConnectionDialog& other) = delete;
39 SDLConnectionDialog(const SDLConnectionDialog&& other) = delete;
40 virtual ~SDLConnectionDialog() override;
41
42 SDLConnectionDialog& operator=(const SDLConnectionDialog& other) = delete;
43 SDLConnectionDialog& operator=(SDLConnectionDialog&& other) = delete;
44
45 bool setTitle(const char* fmt, ...);
46 bool showInfo(const char* fmt, ...);
47 bool showWarn(const char* fmt, ...);
48 bool showError(const char* fmt, ...);
49
50 bool show();
51 bool hide();
52
53 bool running() const;
54 bool wait(bool ignoreRdpContextQuit = false);
55
56 bool handle(const SDL_Event& event);
57
58 bool visible() const override;
59
60 protected:
61 bool updateInternal() override;
62
63 private:
64 bool createWindow();
65 void destroyWindow();
66
67 bool updateMsg(SdlConnectionDialogWrapper::MsgType type);
68
69 bool setModal();
70
71 bool show(SdlConnectionDialogWrapper::MsgType type, const char* fmt, va_list ap);
72 bool show(SdlConnectionDialogWrapper::MsgType type);
73
74 static std::string print(const char* fmt, va_list ap);
75 bool setTimer(Uint32 timeoutMS = 15000);
76 void resetTimer();
77
78 static Uint32 timeout(void* pvthis, SDL_TimerID timerID, Uint32 intervalMS);
79
80 struct widget_cfg_t
81 {
82 SDL_Color fgcolor = {};
83 SDL_Color bgcolor = {};
84 SdlWidget widget;
85 };
86
87 rdpContext* _context = nullptr;
88 mutable std::mutex _mux;
89 std::string _title;
90 std::string _msg;
91 SdlConnectionDialogWrapper::MsgType _type_active = SdlConnectionDialogWrapper::MSG_NONE;
92 SDL_TimerID _timer = 0;
93 bool _running = false;
94 std::vector<widget_cfg_t> _list{};
95};