Workspace 6.21.5
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
WorkspaceGraphicsEffect Class Reference

General graphic effect class for shapes displayed in the Workspace canvas.

#include <Workspace/Presentation/workspacegraphicseffect.h>

Inheritance diagram for WorkspaceGraphicsEffect:
[legend]

Classes

struct  EffectState
 State class for storing the current state of the effect. More...
 

Public Types

enum  Type {
  None = 0 , Outline = 1 << 1 , Shade = 1 << 2 , ShadeBackground = 1 << 3 ,
  Desaturate = 1 << 4
}
 

Public Member Functions

 WorkspaceGraphicsEffect (const QPainterPath &path, QObject *parent=nullptr, const EffectState &initialState=EffectState())
 
 ~WorkspaceGraphicsEffect () override
 
QRectF boundingRectFor (const QRectF &sourceRect) const override
 
QColor getOutlineColor () const
 
qreal getOutlineWidth () const
 
QColor getShadeColor () const
 
EffectType getShapeEffect () const
 
bool popEffectState ()
 
void pushEffectState ()
 
void restoreInitialState ()
 
void setEffectType (EffectType effects)
 
void setOutlineColor (QColor color)
 
void setOutlineWidth (qreal width)
 
void setPath (const QPainterPath &path)
 
void setShadeColor (QColor color)
 
void toggleEffect (EffectType effect, bool toggle)
 

Static Public Member Functions

static const QColor & getDefaultHighlightColor ()
 
static double getDefaultHighlightWidthHover ()
 
static double getDefaultHighlightWidthHoverSelected ()
 

Protected Member Functions

void draw (QPainter *painter) override
 
EffectStatestate ()
 
const EffectStatestate () const
 

Member Enumeration Documentation

◆ Type

enum Type
Enumerator
None 
Outline 
Shade 
ShadeBackground 
Desaturate 

Constructor & Destructor Documentation

◆ WorkspaceGraphicsEffect()

WorkspaceGraphicsEffect ( const QPainterPath &  path,
QObject *  parent = nullptr,
const EffectState initialState = EffectState() 
)

◆ ~WorkspaceGraphicsEffect()

~WorkspaceGraphicsEffect ( )
overridedefault

Member Function Documentation

◆ boundingRectFor()

QRectF boundingRectFor ( const QRectF &  sourceRect) const
override

This graphics effect will draw stuff beyond the source pixmap's bounding rectangle. We need need to expand the graphics effect's rectangle to ensure it is always rendered correctly.

◆ draw()

void draw ( QPainter *  painter)
overrideprotected

◆ getDefaultHighlightColor()

const QColor & getDefaultHighlightColor ( )
static
Returns
The default color for highlighted items.

◆ getDefaultHighlightWidthHover()

double getDefaultHighlightWidthHover ( )
static
Returns
The default outline width for highlighted items.

◆ getDefaultHighlightWidthHoverSelected()

double getDefaultHighlightWidthHoverSelected ( )
static
Returns
The default outline width for highlighted items that are also selected.

◆ getOutlineColor()

QColor getOutlineColor ( ) const

◆ getOutlineWidth()

qreal getOutlineWidth ( ) const

◆ getShadeColor()

QColor getShadeColor ( ) const

◆ getShapeEffect()

WorkspaceGraphicsEffect::EffectType getShapeEffect ( ) const

◆ popEffectState()

bool popEffectState ( )
Returns
true if the pop() was effectual. False if there we are already at the top of the state stack.

Pops the current effect state off the top of the effect stack, restoring the previous state.

◆ pushEffectState()

void pushEffectState ( )

Clones the current effect state and pushes another onto the top of the state stack. This allows local changes to be made to the state while allowing it to be easily restored.

Note
Ideally, rather than using this we would be able to have multiple graphics effects attached to a single graphics item, but this is not the way the Qt API works. For example, rather than pushing the graphics state, changing it, rendering, popping, then rendering again to restore, we would attach an additional graphics effect with different properties, then remove it. Instead, we have to internalise all our possible effect configurations within this class (or a derived class).

◆ restoreInitialState()

void restoreInitialState ( )

Restores the initial state of the graphics effect, removing any items from the top of the stack.

◆ setEffectType()

void setEffectType ( EffectType  effects)

◆ setOutlineColor()

void setOutlineColor ( QColor  color)

◆ setOutlineWidth()

void setOutlineWidth ( qreal  width)

◆ setPath()

void setPath ( const QPainterPath &  path)

◆ setShadeColor()

void setShadeColor ( QColor  color)

◆ state() [1/2]

WorkspaceGraphicsEffect::EffectState & state ( )
protected
Returns
The current state of the graphics effect.

◆ state() [2/2]

const WorkspaceGraphicsEffect::EffectState & state ( ) const
protected
Returns
The current state of the graphics effect.

◆ toggleEffect()

void toggleEffect ( EffectType  effect,
bool  toggle 
)