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

Store the current clip rectangle replacing it with a new clip rectangle. More...

#include <Renderer.h>

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

Public Member Functions

 ClipRectangleGuard ()=delete
 Deleted default constructor.
 
 ClipRectangleGuard (const ClipRectangleGuard &)=delete
 Deleted copy constructor.
 
 ~ClipRectangleGuard ()
 Set the old clip rectangle back on the renderer when destroyed.
 
 ClipRectangleGuard (Renderer &renderer)
 Speculative constructor. More...
 
 ClipRectangleGuard (Renderer &renderer, const SDL_Rect &clip)
 Constructor. More...
 
 ClipRectangleGuard (Renderer &renderer, int x, int y, int w, int h)
 Constructor. More...
 
 ClipRectangleGuard (Renderer &renderer, const Rectangle &clip)
 Conditional constructor. More...
 
ClipRectangleGuardoperator= (SDL_Rect &clip)
 Assign a new clip rectangle through the ClipRectangleGuard. More...
 
ClipRectangleGuardoperator= (Rectangle &clip)
 Assign a new clip rectangle through the ClipRectangleGuard. More...
 
ClipRectangleGuardintersection (Rectangle &clip)
 

Protected Attributes

RenderermRenderer
 The renderer to which the clip rectangles are set.
 
SDL_Rect mOldClip {}
 The old clip rectangle.
 

Detailed Description

Store the current clip rectangle replacing it with a new clip rectangle.

When the object is destroyed (by going out of scope) the old clip rectangle is set.

Constructor & Destructor Documentation

◆ ClipRectangleGuard() [1/4]

rose::sdl::ClipRectangleGuard::ClipRectangleGuard ( Renderer renderer)
inlineexplicit

Speculative constructor.

This constructor saves the current clip rectangle to be restored later, but does not set a new clip rectangle. A new clip rectangle may be set using the assignment operators.

Parameters
rendererThe renderer to guard the clip rectangle of.

◆ ClipRectangleGuard() [2/4]

rose::sdl::ClipRectangleGuard::ClipRectangleGuard ( Renderer renderer,
const SDL_Rect &  clip 
)
inline

Constructor.

Store the current clip rectangle and set the new one.

Parameters
rendererThe renderer to set the clip rectangles on.
clipThe new clip rectangle.

◆ ClipRectangleGuard() [3/4]

rose::sdl::ClipRectangleGuard::ClipRectangleGuard ( Renderer renderer,
int  x,
int  y,
int  w,
int  h 
)
inline

Constructor.

Store the current clip rectangle and set the new one.

Parameters
rendererThe renderer to set the clip rectangles on.
xX co-ordinate of the new clip rectangle.
yY co-ordinate of the new clip rectangle.
wWidth of the new clip rectangle.
hHeight of the new clip rectangle.

◆ ClipRectangleGuard() [4/4]

rose::sdl::ClipRectangleGuard::ClipRectangleGuard ( Renderer renderer,
const Rectangle clip 
)
inline

Conditional constructor.

This constructor saves the current clip rectangle to be restored later. If clip is valid it is converted to an SDL_Rect and set as the new clip rectangle

Parameters
rendererThe renderer to set the clip rectangles on.
clipA, possibly invalid, RectangleInt.

Member Function Documentation

◆ operator=() [1/2]

ClipRectangleGuard& rose::sdl::ClipRectangleGuard::operator= ( SDL_Rect &  clip)
inline

Assign a new clip rectangle through the ClipRectangleGuard.

Parameters
clipThe new clip rectangle.
Returns
The ClipRectangleGuard.

◆ operator=() [2/2]

ClipRectangleGuard& rose::sdl::ClipRectangleGuard::operator= ( Rectangle clip)
inline

Assign a new clip rectangle through the ClipRectangleGuard.

If clip is invalid no changes are made.

Parameters
clipThe new clip rectangle.
Returns
The ClipRectangleGuard.

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