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_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 [[nodiscard]] bool setTitle(const char* fmt, ...);
46 [[nodiscard]] bool showInfo(const char* fmt, ...);
47 [[nodiscard]] bool showWarn(const char* fmt, ...);
48 [[nodiscard]] bool showError(const char* fmt, ...);
49
50 [[nodiscard]] bool show();
51 [[nodiscard]] bool hide();
52
53 [[nodiscard]] bool running() const;
54 [[nodiscard]] bool wait(bool ignoreRdpContextQuit = false);
55
56 [[nodiscard]] bool handle(const SDL_Event& event);
57
58 [[nodiscard]] bool visible() const override;
59
60 protected:
61 [[nodiscard]] bool updateInternal() override;
62
63 private:
64 [[nodiscard]] bool createWindow();
65 void destroyWindow();
66
67 [[nodiscard]] bool updateMsg(SdlConnectionDialogWrapper::MsgType type);
68
69 [[nodiscard]] bool setModal();
70
71 [[nodiscard]] bool show(SdlConnectionDialogWrapper::MsgType type, const char* fmt, va_list ap);
72 [[nodiscard]] bool show(SdlConnectionDialogWrapper::MsgType type);
73
74 [[nodiscard]] static std::string print(const char* fmt, va_list ap);
75 [[nodiscard]] bool setTimer(Uint32 timeoutMS = 15000);
76 void resetTimer();
77
78 [[nodiscard]] 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};