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

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

#include <GraphicsModel.h>

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

Public Member Functions

 ClipRectangleGuard ()=delete
 Deleted default constructor.
 
 ClipRectangleGuard (const ClipRectangleGuard &)=delete
 Deleted copy constructor.
 
 operator bool () const
 
 ~ClipRectangleGuard ()
 Set the old clip rectangle back on the renderer when destroyed.
 
 ClipRectangleGuard (Context &context)
 Speculative constructor. More...
 
 ClipRectangleGuard (Context &context, const SDL_Rect &clip)
 Constructor. More...
 
 ClipRectangleGuard (Context &context, int x, int y, int w, int h)
 Constructor. More...
 
 ClipRectangleGuard (Context &context, 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

ContextmContext
 The renderer to which the clip rectangles are set.
 
SDL_Rect mOldClip {}
 The old clip rectangle.
 
int mStatus {0}
 

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::gm::ClipRectangleGuard::ClipRectangleGuard ( Context context)
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
contextThe renderer to guard the clip rectangle of.

◆ ClipRectangleGuard() [2/4]

rose::gm::ClipRectangleGuard::ClipRectangleGuard ( Context context,
const SDL_Rect &  clip 
)
inline

Constructor.

Store the current clip rectangle and set the new one.

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

◆ ClipRectangleGuard() [3/4]

rose::gm::ClipRectangleGuard::ClipRectangleGuard ( Context context,
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::gm::ClipRectangleGuard::ClipRectangleGuard ( Context context,
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::gm::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::gm::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: