Merge pull request #10640 from akallabeth/sdl-hicpp

[client,sdl] fix class constructors and operators
This commit is contained in:
akallabeth 2024-09-19 08:26:52 +02:00 committed by GitHub
commit c5e8326d07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
37 changed files with 148 additions and 44 deletions

View File

@ -31,7 +31,7 @@ class SDL2ResourceManager : public SDLResourceManager
SDL2ResourceManager(const SDL2ResourceManager& other) = delete;
SDL2ResourceManager(const SDL2ResourceManager&& other) = delete;
~SDL2ResourceManager() = delete;
SDL2ResourceManager operator=(const SDL2ResourceManager& other) = delete;
SDL2ResourceManager& operator=(const SDL2ResourceManager& other) = delete;
SDL2ResourceManager& operator=(SDL2ResourceManager&& other) = delete;
static SDL_RWops* get(const std::string& type, const std::string& id);

View File

@ -41,6 +41,8 @@ SdlButton::SdlButton(SdlButton&& other) noexcept
{
}
SdlButton::~SdlButton() = default;
bool SdlButton::highlight(SDL_Renderer* renderer)
{
assert(renderer);

View File

@ -8,8 +8,12 @@ class SdlButton : public SdlWidget
{
public:
SdlButton(SDL_Renderer* renderer, std::string label, int id, SDL_Rect rect);
SdlButton(const SdlButton& other) = delete;
SdlButton(SdlButton&& other) noexcept;
~SdlButton() override = default;
~SdlButton() override;
SdlButton& operator=(const SdlButton& other) = delete;
SdlButton& operator=(SdlButton&& other) = delete;
bool highlight(SDL_Renderer* renderer);
bool mouseover(SDL_Renderer* renderer);
@ -18,8 +22,6 @@ class SdlButton : public SdlWidget
[[nodiscard]] int id() const;
private:
SdlButton(const SdlButton& other) = delete;
std::string _name;
int _id;
};

View File

@ -5,6 +5,8 @@
static const Uint32 hpadding = 10;
SdlButtonList::~SdlButtonList() = default;
bool SdlButtonList::populate(SDL_Renderer* renderer, const std::vector<std::string>& labels,
const std::vector<int>& ids, Sint32 total_width, Sint32 offsetY,
Sint32 width, Sint32 height)

View File

@ -9,7 +9,7 @@ class SdlButtonList
{
public:
SdlButtonList() = default;
virtual ~SdlButtonList() = default;
virtual ~SdlButtonList();
bool populate(SDL_Renderer* renderer, const std::vector<std::string>& labels,
const std::vector<int>& ids, Sint32 total_width, Sint32 offsetY, Sint32 width,
@ -25,10 +25,12 @@ class SdlButtonList
void clear();
private:
SdlButtonList(const SdlButtonList& other) = delete;
SdlButtonList(SdlButtonList&& other) = delete;
SdlButtonList& operator=(const SdlButtonList& other) = delete;
SdlButtonList& operator=(SdlButtonList&& other) = delete;
private:
std::vector<SdlButton> _list;
SdlButton* _highlighted = nullptr;
size_t _highlight_index = 0;

View File

@ -39,6 +39,9 @@ class SDLConnectionDialog
SDLConnectionDialog(const SDLConnectionDialog&& other) = delete;
virtual ~SDLConnectionDialog();
SDLConnectionDialog& operator=(const SDLConnectionDialog& other) = delete;
SDLConnectionDialog& operator=(SDLConnectionDialog&& other) = delete;
bool visible() const;
bool setTitle(const char* fmt, ...);
@ -112,6 +115,10 @@ class SDLConnectionDialogHider
explicit SDLConnectionDialogHider(rdpContext* context);
explicit SDLConnectionDialogHider(SDLConnectionDialog* dialog);
SDLConnectionDialogHider(const SDLConnectionDialogHider& other) = delete;
SDLConnectionDialogHider(SDLConnectionDialogHider&& other) = delete;
SDLConnectionDialogHider& operator=(const SDLConnectionDialogHider& other) = delete;
SDLConnectionDialogHider& operator=(SDLConnectionDialogHider& other) = delete;
~SDLConnectionDialogHider();

View File

@ -37,6 +37,10 @@ class SdlInputWidget
SdlInputWidget(SDL_Renderer* renderer, std::string label, std::string initial, Uint32 flags,
size_t offset, size_t width, size_t height);
SdlInputWidget(SdlInputWidget&& other) noexcept;
SdlInputWidget(const SdlInputWidget& other) = delete;
SdlInputWidget& operator=(const SdlInputWidget& other) = delete;
SdlInputWidget& operator=(SdlInputWidget&& other) = delete;
bool fill_label(SDL_Renderer* renderer, SDL_Color color);
bool update_label(SDL_Renderer* renderer);
@ -59,8 +63,6 @@ class SdlInputWidget
bool update_input(SDL_Renderer* renderer, SDL_Color fgcolor);
private:
SdlInputWidget(const SdlInputWidget& other) = delete;
Uint32 _flags;
std::string _text;
std::string _text_label;

View File

@ -12,6 +12,12 @@ class SdlInputWidgetList
public:
SdlInputWidgetList(const std::string& title, const std::vector<std::string>& labels,
const std::vector<std::string>& initial, const std::vector<Uint32>& flags);
SdlInputWidgetList(const SdlInputWidgetList& other) = delete;
SdlInputWidgetList(SdlInputWidgetList&& other) = delete;
SdlInputWidgetList& operator=(const SdlInputWidgetList& other) = delete;
SdlInputWidgetList& operator=(SdlInputWidgetList&& other) = delete;
virtual ~SdlInputWidgetList();
int run(std::vector<std::string>& result);
@ -21,9 +27,6 @@ class SdlInputWidgetList
ssize_t get_index(const SDL_MouseButtonEvent& button);
private:
SdlInputWidgetList(const SdlInputWidgetList& other) = delete;
SdlInputWidgetList(SdlInputWidgetList&& other) = delete;
enum
{
INPUT_BUTTON_ACCEPT = 1,

View File

@ -48,6 +48,8 @@ SdlSelectWidget::SdlSelectWidget(SdlSelectWidget&& other) noexcept
{
}
SdlSelectWidget::~SdlSelectWidget() = default;
bool SdlSelectWidget::set_mouseover(SDL_Renderer* renderer, bool mouseOver)
{
_mouseover = mouseOver;

View File

@ -30,15 +30,17 @@ class SdlSelectWidget : public SdlWidget
public:
SdlSelectWidget(SDL_Renderer* renderer, std::string label, SDL_Rect rect);
SdlSelectWidget(SdlSelectWidget&& other) noexcept;
~SdlSelectWidget() override = default;
~SdlSelectWidget() override;
bool set_mouseover(SDL_Renderer* renderer, bool mouseOver);
bool set_highlight(SDL_Renderer* renderer, bool highlight);
bool update_text(SDL_Renderer* renderer);
private:
SdlSelectWidget(const SdlSelectWidget& other) = delete;
SdlSelectWidget& operator=(const SdlSelectWidget& other) = delete;
SdlSelectWidget& operator=(SdlSelectWidget&& other) = delete;
private:
std::string _text;
bool _mouseover;
bool _highlight;

View File

@ -17,10 +17,12 @@ class SdlSelectList
int run();
private:
SdlSelectList(const SdlSelectList& other) = delete;
SdlSelectList(SdlSelectList&& other) = delete;
SdlSelectList& operator=(const SdlSelectList& other) = delete;
SdlSelectList& operator=(SdlSelectList&& other) = delete;
private:
enum
{
INPUT_BUTTON_ACCEPT = 0,

View File

@ -69,9 +69,11 @@ class SdlWidget
static bool error_ex(Uint32 res, const char* what, const char* file, size_t line,
const char* fkt);
private:
SdlWidget(const SdlWidget& other) = delete;
SdlWidget& operator=(const SdlWidget& other) = delete;
SdlWidget& operator=(SdlWidget&& other) = delete;
private:
SDL_Texture* render_text(SDL_Renderer* renderer, const std::string& text, SDL_Color fgcolor,
SDL_Rect& src, SDL_Rect& dst);
SDL_Texture* render_text_wrapped(SDL_Renderer* renderer, const std::string& text,

View File

@ -31,8 +31,13 @@ class sdlDispContext
public:
explicit sdlDispContext(SdlContext* sdl);
sdlDispContext(const sdlDispContext& other) = delete;
sdlDispContext(sdlDispContext&& other) = delete;
~sdlDispContext();
sdlDispContext& operator=(const sdlDispContext& other) = delete;
sdlDispContext& operator=(sdlDispContext&& other) = delete;
BOOL init(DispClientContext* disp);
BOOL uninit(DispClientContext* disp);

View File

@ -47,6 +47,11 @@ class SdlContext
{
public:
explicit SdlContext(rdpContext* context);
SdlContext(const SdlContext& other) = delete;
SdlContext(SdlContext&& other) = delete;
SdlContext& operator=(const SdlContext& other) = delete;
SdlContext& operator=(SdlContext&& other) = delete;
private:
rdpContext* _context;

View File

@ -34,8 +34,13 @@ class sdlInput
{
public:
explicit sdlInput(SdlContext* sdl);
sdlInput(const sdlInput& other) = delete;
sdlInput(sdlInput&& other) = delete;
~sdlInput() = default;
sdlInput& operator=(const sdlInput& other) = delete;
sdlInput& operator=(sdlInput&& other) = delete;
BOOL keyboard_sync_state();
BOOL keyboard_focus_in();

View File

@ -30,8 +30,13 @@ class CriticalSection
{
public:
CriticalSection();
CriticalSection(const CriticalSection& other) = delete;
CriticalSection(CriticalSection&& other) = delete;
~CriticalSection();
CriticalSection& operator=(const CriticalSection& other) = delete;
CriticalSection& operator=(const CriticalSection&& other) = delete;
void lock();
void unlock();

View File

@ -27,9 +27,13 @@ class SdlWindow
public:
SdlWindow(const std::string& title, Sint32 startupX, Sint32 startupY, Sint32 width,
Sint32 height, Uint32 flags);
SdlWindow(const SdlWindow& other) = delete;
SdlWindow(SdlWindow&& other) noexcept;
~SdlWindow();
SdlWindow& operator=(const SdlWindow& other) = delete;
SdlWindow& operator=(SdlWindow&& other) = delete;
[[nodiscard]] Uint32 id() const;
[[nodiscard]] int displayIndex() const;
[[nodiscard]] SDL_Rect rect() const;
@ -57,6 +61,4 @@ class SdlWindow
SDL_Window* _window = nullptr;
Sint32 _offset_x = 0;
Sint32 _offset_y = 0;
SdlWindow(const SdlWindow& other) = delete;
};

View File

@ -31,7 +31,7 @@ class SDL3ResourceManager : public SDLResourceManager
SDL3ResourceManager(const SDL3ResourceManager& other) = delete;
SDL3ResourceManager(const SDL3ResourceManager&& other) = delete;
~SDL3ResourceManager() = delete;
SDL3ResourceManager operator=(const SDL3ResourceManager& other) = delete;
SDL3ResourceManager& operator=(const SDL3ResourceManager& other) = delete;
SDL3ResourceManager& operator=(SDL3ResourceManager&& other) = delete;
static SDL_IOStream* get(const std::string& type, const std::string& id);

View File

@ -41,6 +41,8 @@ SdlButton::SdlButton(SdlButton&& other) noexcept
{
}
SdlButton::~SdlButton() = default;
bool SdlButton::highlight(SDL_Renderer* renderer)
{
assert(renderer);

View File

@ -9,7 +9,11 @@ class SdlButton : public SdlWidget
public:
SdlButton(SDL_Renderer* renderer, std::string label, int id, const SDL_FRect& rect);
SdlButton(SdlButton&& other) noexcept;
~SdlButton() override = default;
SdlButton(const SdlButton& other) = delete;
~SdlButton() override;
SdlButton& operator=(const SdlButton& other) = delete;
SdlButton& operator=(SdlButton&& other) = delete;
bool highlight(SDL_Renderer* renderer);
bool mouseover(SDL_Renderer* renderer);
@ -18,8 +22,6 @@ class SdlButton : public SdlWidget
[[nodiscard]] int id() const;
private:
SdlButton(const SdlButton& other) = delete;
std::string _name;
int _id;
};

View File

@ -5,6 +5,8 @@
static const Uint32 hpadding = 10;
SdlButtonList::~SdlButtonList() = default;
bool SdlButtonList::populate(SDL_Renderer* renderer, const std::vector<std::string>& labels,
const std::vector<int>& ids, Sint32 total_width, Sint32 offsetY,
Sint32 width, Sint32 height)

View File

@ -9,7 +9,12 @@ class SdlButtonList
{
public:
SdlButtonList() = default;
virtual ~SdlButtonList() = default;
SdlButtonList(const SdlButtonList& other) = delete;
SdlButtonList(SdlButtonList&& other) = delete;
virtual ~SdlButtonList();
SdlButtonList& operator=(const SdlButtonList& other) = delete;
SdlButtonList& operator=(SdlButtonList&& other) = delete;
bool populate(SDL_Renderer* renderer, const std::vector<std::string>& labels,
const std::vector<int>& ids, Sint32 total_width, Sint32 offsetY, Sint32 width,
@ -26,9 +31,6 @@ class SdlButtonList
void clear();
private:
SdlButtonList(const SdlButtonList& other) = delete;
SdlButtonList(SdlButtonList&& other) = delete;
std::vector<SdlButton> _list;
SdlButton* _highlighted = nullptr;
size_t _highlight_index = 0;

View File

@ -39,6 +39,9 @@ class SDLConnectionDialog
SDLConnectionDialog(const SDLConnectionDialog&& other) = delete;
virtual ~SDLConnectionDialog();
SDLConnectionDialog& operator=(const SDLConnectionDialog& other) = delete;
SDLConnectionDialog& operator=(SDLConnectionDialog& other) = delete;
bool visible() const;
bool setTitle(const char* fmt, ...);
@ -113,6 +116,11 @@ class SDLConnectionDialogHider
explicit SDLConnectionDialogHider(SDLConnectionDialog* dialog);
SDLConnectionDialogHider(const SDLConnectionDialogHider& other) = delete;
SDLConnectionDialogHider(SDLConnectionDialogHider&& other) = delete;
SDLConnectionDialogHider& operator=(const SDLConnectionDialogHider& other) = delete;
SDLConnectionDialogHider& operator=(SDLConnectionDialogHider& other) = delete;
~SDLConnectionDialogHider();
private:

View File

@ -37,6 +37,10 @@ class SdlInputWidget
SdlInputWidget(SDL_Renderer* renderer, std::string label, std::string initial, Uint32 flags,
size_t offset, size_t width, size_t height);
SdlInputWidget(SdlInputWidget&& other) noexcept;
SdlInputWidget(const SdlInputWidget& other) = delete;
SdlInputWidget& operator=(const SdlInputWidget& other) = delete;
SdlInputWidget& operator=(SdlInputWidget&& other) = delete;
bool fill_label(SDL_Renderer* renderer, SDL_Color color);
bool update_label(SDL_Renderer* renderer);
@ -59,8 +63,6 @@ class SdlInputWidget
bool update_input(SDL_Renderer* renderer, SDL_Color fgcolor);
private:
SdlInputWidget(const SdlInputWidget& other) = delete;
Uint32 _flags;
std::string _text;
std::string _text_label;

View File

@ -12,8 +12,14 @@ class SdlInputWidgetList
public:
SdlInputWidgetList(const std::string& title, const std::vector<std::string>& labels,
const std::vector<std::string>& initial, const std::vector<Uint32>& flags);
SdlInputWidgetList(const SdlInputWidgetList& other) = delete;
SdlInputWidgetList(SdlInputWidgetList&& other) = delete;
virtual ~SdlInputWidgetList();
SdlInputWidgetList& operator=(const SdlInputWidgetList& other) = delete;
SdlInputWidgetList& operator=(SdlInputWidgetList&& other) = delete;
int run(std::vector<std::string>& result);
protected:
@ -21,9 +27,6 @@ class SdlInputWidgetList
ssize_t get_index(const SDL_MouseButtonEvent& button);
private:
SdlInputWidgetList(const SdlInputWidgetList& other) = delete;
SdlInputWidgetList(SdlInputWidgetList&& other) = delete;
enum
{
INPUT_BUTTON_ACCEPT = 1,

View File

@ -30,15 +30,16 @@ class SdlSelectWidget : public SdlWidget
public:
SdlSelectWidget(SDL_Renderer* renderer, std::string label, const SDL_FRect& rect);
SdlSelectWidget(SdlSelectWidget&& other) noexcept;
~SdlSelectWidget() override = default;
SdlSelectWidget(const SdlSelectWidget& other) = delete;
SdlSelectWidget& operator=(const SdlSelectWidget& other) = delete;
SdlSelectWidget& operator=(SdlSelectWidget&& other) = delete;
bool set_mouseover(SDL_Renderer* renderer, bool mouseOver);
bool set_highlight(SDL_Renderer* renderer, bool highlight);
bool update_text(SDL_Renderer* renderer);
private:
SdlSelectWidget(const SdlSelectWidget& other) = delete;
std::string _text;
bool _mouseover;
bool _highlight;

View File

@ -13,14 +13,16 @@ class SdlSelectList
{
public:
SdlSelectList(const std::string& title, const std::vector<std::string>& labels);
SdlSelectList(const SdlSelectList& other) = delete;
SdlSelectList(SdlSelectList&& other) = delete;
virtual ~SdlSelectList();
SdlSelectList& operator=(const SdlSelectList& other) = delete;
SdlSelectList& operator=(SdlSelectList&& other) = delete;
int run();
private:
SdlSelectList(const SdlSelectList& other) = delete;
SdlSelectList(SdlSelectList&& other) = delete;
enum
{
INPUT_BUTTON_ACCEPT = 0,

View File

@ -50,9 +50,13 @@ class SdlWidget
public:
SdlWidget(SDL_Renderer* renderer, const SDL_FRect& rect, bool input);
SdlWidget(SDL_Renderer* renderer, const SDL_FRect& rect, SDL_IOStream* ops);
SdlWidget(const SdlWidget& other) = delete;
SdlWidget(SdlWidget&& other) noexcept;
virtual ~SdlWidget();
SdlWidget& operator=(const SdlWidget& other) = delete;
SdlWidget& operator=(SdlWidget&& other) = delete;
bool fill(SDL_Renderer* renderer, SDL_Color color);
bool fill(SDL_Renderer* renderer, const std::vector<SDL_Color>& colors);
bool update_text(SDL_Renderer* renderer, const std::string& text, SDL_Color fgcolor);
@ -68,8 +72,6 @@ class SdlWidget
const char* fkt);
private:
SdlWidget(const SdlWidget& other) = delete;
SDL_Texture* render_text(SDL_Renderer* renderer, const std::string& text, SDL_Color fgcolor,
SDL_FRect& src, SDL_FRect& dst);
SDL_Texture* render_text_wrapped(SDL_Renderer* renderer, const std::string& text,

View File

@ -43,6 +43,9 @@ class ClipRequest
ClipRequest(ClipRequest&& other) = default;
~ClipRequest() = default;
ClipRequest& operator=(const ClipRequest& other) = delete;
ClipRequest& operator=(ClipRequest&& other) = delete;
[[nodiscard]] uint32_t format() const;
[[nodiscard]] std::string formatstr() const;
[[nodiscard]] std::string mime() const;

View File

@ -31,8 +31,13 @@ class sdlDispContext
public:
explicit sdlDispContext(SdlContext* sdl);
sdlDispContext(const sdlDispContext& other) = delete;
sdlDispContext(sdlDispContext&& other) = delete;
~sdlDispContext();
sdlDispContext& operator=(const sdlDispContext& other) = delete;
sdlDispContext& operator=(sdlDispContext&& other) = delete;
BOOL init(DispClientContext* disp);
BOOL uninit(DispClientContext* disp);

View File

@ -47,6 +47,11 @@ class SdlContext
{
public:
explicit SdlContext(rdpContext* context);
SdlContext(const SdlContext& other) = delete;
SdlContext(SdlContext&& other) = delete;
SdlContext& operator=(const SdlContext& other) = delete;
SdlContext& operator=(SdlContext&& other) = delete;
private:
rdpContext* _context;

View File

@ -34,8 +34,13 @@ class sdlInput
{
public:
explicit sdlInput(SdlContext* sdl);
sdlInput(const sdlInput& other) = delete;
sdlInput(sdlInput&& other) = delete;
~sdlInput() = default;
sdlInput& operator=(const sdlInput& other) = delete;
sdlInput& operator=(sdlInput&& other) = delete;
BOOL keyboard_sync_state();
BOOL keyboard_focus_in();

View File

@ -34,8 +34,13 @@ class CriticalSection
{
public:
CriticalSection();
CriticalSection(const CriticalSection& other) = delete;
CriticalSection(CriticalSection&& other) = delete;
~CriticalSection();
CriticalSection& operator=(const CriticalSection& other) = delete;
CriticalSection& operator=(CriticalSection&& other) = delete;
void lock();
void unlock();

View File

@ -28,8 +28,12 @@ class SdlWindow
SdlWindow(const std::string& title, Sint32 startupX, Sint32 startupY, Sint32 width,
Sint32 height, Uint32 flags);
SdlWindow(SdlWindow&& other) noexcept;
SdlWindow(const SdlWindow& other) = delete;
~SdlWindow();
SdlWindow& operator=(const SdlWindow& other) = delete;
SdlWindow& operator=(SdlWindow&& other) = delete;
[[nodiscard]] Uint32 id() const;
[[nodiscard]] int displayIndex() const;
[[nodiscard]] SDL_Rect rect() const;
@ -57,6 +61,4 @@ class SdlWindow
SDL_Window* _window = nullptr;
Sint32 _offset_x = 0;
Sint32 _offset_y = 0;
SdlWindow(const SdlWindow& other) = delete;
};

View File

@ -23,3 +23,5 @@ SDLResourceFile::SDLResourceFile(const std::string& type, const std::string& id,
{
SDLResourceManager::insert(type, id, data);
}
SDLResourceFile::~SDLResourceFile() = default;

View File

@ -25,9 +25,10 @@ class SDLResourceFile
public:
SDLResourceFile(const std::string& type, const std::string& id,
const std::vector<unsigned char>& data);
virtual ~SDLResourceFile() = default;
virtual ~SDLResourceFile();
private:
SDLResourceFile(const SDLResourceFile& other) = delete;
SDLResourceFile(const SDLResourceFile&& other) = delete;
SDLResourceFile& operator=(const SDLResourceFile& other) = delete;
SDLResourceFile& operator=(SDLResourceFile&& other) = delete;
};

View File

@ -48,8 +48,8 @@ class ScopeGuard
ScopeGuard(const ScopeGuard&) = delete;
ScopeGuard(ScopeGuard&& other) noexcept = delete;
auto operator=(const ScopeGuard&) = delete;
auto operator=(const ScopeGuard&&) = delete;
ScopeGuard& operator=(const ScopeGuard&) = delete;
ScopeGuard& operator=(const ScopeGuard&&) = delete;
private:
std::function<void()> f;