Rose
Public Member Functions | Protected Attributes | List of all members
rose::sdl::DrawColorGuard Class Reference

Store the current draw color replacing it with a new draw color. More...

#include <Renderer.h>

Collaboration diagram for rose::sdl::DrawColorGuard:
Collaboration graph
[legend]

Public Member Functions

 DrawColorGuard ()=delete
 Deleted default constructor.
 
 DrawColorGuard (const DrawColorGuard &)=delete
 Deleted copy constructor.
 
 DrawColorGuard (DrawColorGuard &&)=default
 
DrawColorGuardoperator= (const DrawColorGuard &)=delete
 
 ~DrawColorGuard () noexcept(false)
 Set the old clip rectangle back on the renderer when destroyed.
 
 DrawColorGuard (Renderer &renderer, SDL_Color color)
 Construct DrawColorGuard with and SDL_Color. More...
 
 DrawColorGuard (Renderer &renderer, color::RGBA color)
 Construct DrawColorGuard with a rose::Color. More...
 
 operator bool () const noexcept
 Test the validity of the DrawColorGuard. More...
 
int setDrawColor (SDL_Color color)
 Set the drow Color on the renderer without pushing the old color on the stack. More...
 
int setDrawColor (color::RGBA color)
 Set the draw Color on the renderer without pushing the old color on the stack. More...
 

Protected Attributes

RenderermRenderer
 The renderer to which the draw colors are set.
 
SDL_Color mOldColor {}
 The old draw color.
 
int mStatus
 The status of the last SDL operation.
 

Detailed Description

Store the current draw color replacing it with a new draw color.

When the object is destroyed (by going out of scope) the old draw color is set.

Constructor & Destructor Documentation

◆ DrawColorGuard() [1/2]

rose::sdl::DrawColorGuard::DrawColorGuard ( Renderer renderer,
SDL_Color  color 
)

Construct DrawColorGuard with and SDL_Color.

Parameters
rendererThe renderer to set the color on.
colorThe SDL_Color.

◆ DrawColorGuard() [2/2]

rose::sdl::DrawColorGuard::DrawColorGuard ( Renderer renderer,
color::RGBA  color 
)

Construct DrawColorGuard with a rose::Color.

Parameters
rendererThe renderer to set the color on.
colorThe rose::Color.

Member Function Documentation

◆ operator bool()

rose::sdl::DrawColorGuard::operator bool ( ) const
inlineexplicitnoexcept

Test the validity of the DrawColorGuard.

Returns
False if the last SDL operation return an error.

◆ setDrawColor() [1/2]

int rose::sdl::DrawColorGuard::setDrawColor ( SDL_Color  color)

Set the drow Color on the renderer without pushing the old color on the stack.

Parameters
colorThe SDL_Color to set.
Returns
The SDL2 API return status code.

◆ setDrawColor() [2/2]

int rose::sdl::DrawColorGuard::setDrawColor ( color::RGBA  color)
inline

Set the draw Color on the renderer without pushing the old color on the stack.

Parameters
colorThe Color to set.
Returns
The SDL2 API return status code.

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