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 30 of file sdl_widget_list.cpp.

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

◆ 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(
13 title.c_str(), w, h, SDL_WINDOW_MOUSE_FOCUS | SDL_WINDOW_INPUT_FOCUS, &window, &renderer);
14 _renderer = std::shared_ptr<SDL_Renderer>(renderer, SDL_DestroyRenderer);
15 _window = std::shared_ptr<SDL_Window>(window, SDL_DestroyWindow);
16 if (!rc)
17 widget_log_error(rc, "SDL_CreateWindowAndRenderer");
18 return rc;
19}

◆ update()

bool SdlWidgetList::update ( )
protected

Definition at line 45 of file sdl_widget_list.cpp.

46{
47 clearWindow();
48 updateInternal();
49 if (!_buttons.update())
50 return false;
51 auto rc = SDL_RenderPresent(_renderer.get());
52 if (!rc)
53 {
54 SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "SDL_RenderPresent failed with %s",
55 SDL_GetError());
56 }
57 return rc;
58}

◆ visible()

bool SdlWidgetList::visible ( ) const
virtual

Definition at line 21 of file sdl_widget_list.cpp.

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

Field Documentation

◆ _backgroundcolor

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

Definition at line 34 of file sdl_widget_list.hpp.

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

◆ _buttons

SdlButtonList SdlWidgetList::_buttons
protected

Definition at line 33 of file sdl_widget_list.hpp.

◆ _renderer

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

Definition at line 32 of file sdl_widget_list.hpp.

32{};

◆ _window

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

Definition at line 31 of file sdl_widget_list.hpp.

31{};

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