FreeRDP
Loading...
Searching...
No Matches
SdlWidgetList Class Referenceabstract
Inheritance diagram for SdlWidgetList:
Collaboration diagram for SdlWidgetList:

Public Member Functions

 SdlWidgetList (const SdlWidgetList &other)=delete
 
 SdlWidgetList (SdlWidgetList &&other)=delete
 
SdlWidgetListoperator= (const SdlWidgetList &other)=delete
 
SdlWidgetListoperator= (SdlWidgetList &&other)=delete
 
virtual bool reset (const std::string &title, size_t width, size_t height)
 
virtual bool visible () const
 

Protected Member Functions

bool update ()
 
virtual bool clearWindow ()
 
virtual bool updateInternal ()=0
 

Protected Attributes

std::shared_ptr< SDL_Window > _window
 
std::shared_ptr< SDL_Renderer > _renderer
 
SdlButtonList _buttons
 
SDL_Color _backgroundcolor { 0x38, 0x36, 0x35, 0xff }
 

Detailed Description

Definition at line 10 of file sdl_widget_list.hpp.

Member Function Documentation

◆ clearWindow()

bool SdlWidgetList::clearWindow ( )
protectedvirtual

Definition at line 33 of file sdl_widget_list.cpp.

34{
35 if (!_renderer)
36 return false;
37
38 SdlBlendModeGuard guard(_renderer, SDL_BLENDMODE_NONE);
39 const auto drc = SDL_SetRenderDrawColor(_renderer.get(), _backgroundcolor.r, _backgroundcolor.g,
40 _backgroundcolor.b, _backgroundcolor.a);
41 if (widget_log_error(drc, "SDL_SetRenderDrawColor"))
42 return false;
43
44 const auto rcls = SDL_RenderClear(_renderer.get());
45 return !widget_log_error(rcls, "SDL_RenderClear");
46}

◆ reset()

bool SdlWidgetList::reset ( const std::string &  title,
size_t  width,
size_t  height 
)
virtual

Definition at line 6 of file sdl_widget_list.cpp.

7{
8 auto w = WINPR_ASSERTING_INT_CAST(int, width);
9 auto h = WINPR_ASSERTING_INT_CAST(int, height);
10 SDL_Renderer* renderer = nullptr;
11 SDL_Window* window = nullptr;
12 auto rc = SDL_CreateWindowAndRenderer(title.c_str(), w, h,
13 SDL_WINDOW_MOUSE_FOCUS | SDL_WINDOW_INPUT_FOCUS |
14 SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_UTILITY |
15 SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS,
16 &window, &renderer);
17 _renderer = std::shared_ptr<SDL_Renderer>(renderer, SDL_DestroyRenderer);
18 _window = std::shared_ptr<SDL_Window>(window, SDL_DestroyWindow);
19 if (!rc)
20 widget_log_error(rc, "SDL_CreateWindowAndRenderer");
21 return rc;
22}

◆ update()

bool SdlWidgetList::update ( )
protected

Definition at line 48 of file sdl_widget_list.cpp.

49{
50 if (!visible())
51 return true;
52
53 if (!clearWindow())
54 return false;
55 if (!updateInternal())
56 return false;
57 if (!_buttons.update())
58 return false;
59 auto rc = SDL_RenderPresent(_renderer.get());
60 if (!rc)
61 {
62 SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "[%s] SDL_RenderPresent failed with %s", __func__,
63 SDL_GetError());
64 }
65 return rc;
66}

◆ visible()

bool SdlWidgetList::visible ( ) const
virtual

Definition at line 24 of file sdl_widget_list.cpp.

25{
26 if (!_window || !_renderer)
27 return false;
28
29 auto flags = SDL_GetWindowFlags(_window.get());
30 return (flags & (SDL_WINDOW_HIDDEN | SDL_WINDOW_MINIMIZED)) == 0;
31}

Field Documentation

◆ _backgroundcolor

SDL_Color SdlWidgetList::_backgroundcolor { 0x38, 0x36, 0x35, 0xff }
protected

Definition at line 33 of file sdl_widget_list.hpp.

33{ 0x38, 0x36, 0x35, 0xff };

◆ _buttons

SdlButtonList SdlWidgetList::_buttons
protected

Definition at line 32 of file sdl_widget_list.hpp.

◆ _renderer

std::shared_ptr<SDL_Renderer> SdlWidgetList::_renderer
protected

Definition at line 31 of file sdl_widget_list.hpp.

◆ _window

std::shared_ptr<SDL_Window> SdlWidgetList::_window
protected

Definition at line 30 of file sdl_widget_list.hpp.


The documentation for this class was generated from the following files: