Gorgon Game Engine
Layer Class Reference

This layer allows drawing texture images on. More...

Inheritance diagram for Layer:
[legend]

Public Member Functions

 Layer ()
 Constructor that sets the layer to cover entire parent, no matter how big it is. More...
 
 Layer (const Geometry::Bounds &bounds)
 Initializing constructor. More...
 
 Layer (const Geometry::Point &location)
 Constructor that places the layer to the given location. More...
 
 Layer (const Layer &)=delete
 Copy constructor is disabled. More...
 
 Layer (Layer &&other)
 Move constructor. More...
 
virtual void Clear () override
 Clears drawing buffer, in layer architecture this request only affects the layer itself, not its children. More...
 
void DisableClipping ()
 Disables graphics clipping. More...
 
virtual void Draw (const Geometry::Pointf &location, const Geometry::Sizef &size, RGBAf color=RGBAf(1.f))
 Draws a textureless solid colored rectangle on the screen. More...
 
virtual void Draw (const Geometry::Pointf &location, float w, float h, RGBAf color=RGBAf(1.f))
 Draws a textureless solid colored rectangle on the screen. More...
 
virtual void Draw (const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, RGBAf color=RGBAf(1.f)) override
 Prefer using Draw functions of image or animations. More...
 
virtual void Draw (const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, RGBAf color=RGBAf(1.f))=0
 Draws a textureless solid colored rectangle on the screen. More...
 
virtual void Draw (const Geometry::Rectanglef &location, RGBAf color=RGBAf(1.f))
 Draws a textureless solid colored rectangle on the screen. More...
 
virtual void Draw (const TextureSource &image, const Geometry::Pointf &location, RGBAf color)
 Draws a simple image to the screen to the given position. More...
 
virtual void Draw (const TextureSource &image, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, const Geometry::Pointf &tex1, const Geometry::Pointf &tex2, const Geometry::Pointf &tex3, const Geometry::Pointf &tex4, RGBAf color=RGBAf(1.f)) override
 Prefer using Draw functions of image or animations. More...
 
virtual void Draw (const TextureSource &image, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, const Geometry::Pointf &tex1, const Geometry::Pointf &tex2, const Geometry::Pointf &tex3, const Geometry::Pointf &tex4, RGBAf color=RGBAf(1.f))=0
 Draws a simple texture to the screen. More...
 
virtual void Draw (const TextureSource &image, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, RGBAf color=RGBAf(1.f)) override
 Prefer using Draw functions of image or animations. More...
 
virtual void Draw (const TextureSource &image, const Geometry::Pointf &p1, const Geometry::Pointf &p2, const Geometry::Pointf &p3, const Geometry::Pointf &p4, RGBAf color=RGBAf(1.f))=0
 Draws a simple texture to the screen. More...
 
virtual void Draw (const TextureSource &image, const Geometry::Rectanglef &location, RGBAf color=RGBAf(1.f))
 Draws a simple image to the screen to the given position with the given size. More...
 
virtual void Draw (const TextureSource &image, Tiling tiling, const Geometry::Rectanglef &location, RGBAf color=RGBAf(1.f)) override
 Prefer using Draw functions of image or animations. More...
 
virtual void Draw (const TextureSource &image, Tiling tiling, const Geometry::Rectanglef &location, RGBAf color=RGBAf(1.f))=0
 Draws a simple image to the screen using the given tiling method, coordinates and size. More...
 
virtual void Draw (float x, float y, const Geometry::Sizef &size, RGBAf color=RGBAf(1.f))
 Draws a textureless solid colored rectangle on the screen. More...
 
virtual void Draw (float x, float y, float w, float h, RGBAf color=RGBAf(1.f))
 Draws a textureless solid colored rectangle on the screen. More...
 
virtual void Draw (int x, int y, int w, int h, RGBAf color=RGBAf(1.f))
 Draws a textureless solid colored rectangle on the screen. More...
 
virtual void Draw (RGBAf color=RGBAf(1.f))
 Draws a textureless solid colored rectangle to cover the texture target. More...
 
void EnableClipping ()
 Enables graphics clipping from the visible borders of the layer. More...
 
virtual RGBAf GetColor () const
 Changes the tint color of the layer, every image pixel will be multiplied by this color. More...
 
virtual DrawMode GetDrawMode () const override
 Get current drawing mode. See Layer page to see available drawing modes. More...
 
virtual Geometry::Size GetTargetSize () const override
 Get size of the target. More...
 
virtual RGBAf GetTintColor () const
 Returns the tint color of the layer, every image pixel will be multiplied by this color. More...
 
bool IsClippingEnabled () const
 Returns if the clipping is enabled. More...
 
virtual void NewMask () override
 Queues the start of a new mask. Only one mask buffer exists and it will be cleared and reused. More...
 
virtual void Render () override
 Render this layer to the GL. This function is used internally and not necessary to be called. More...
 
virtual void SetColor (RGBAf value)
 Changes the tint color of the layer, every image pixel will be multiplied by this color. More...
 
virtual void SetDrawMode (DrawMode mode) override
 Change current drawing mode. See Layer page to see available drawing modes. More...
 
virtual void SetTintColor (RGBAf value)
 Changes the tint color of the layer, every image pixel will be multiplied by this color. More...
 
void Swap (Layer &other)
 
- Public Member Functions inherited from Layer
 Layer ()
 Constructor that sets the layer to cover entire parent, no matter how big it is. More...
 
 Layer (const Geometry::Bounds &bounds)
 Initializing constructor. More...
 
 Layer (const Geometry::Point &location)
 Constructor that places the layer to the given location. More...
 
 Layer (const Layer &)=delete
 Copy constructor is disabled. More...
 
 Layer (Layer &&other)
 Move constructor. More...
 
virtual ~Layer ()
 Destructor. More...
 
virtual void Hide ()
 Hides this layer. More...
 
virtual bool IsVisible () const
 Returns whether this layer is effectively visible. More...
 
Layeroperator= (const Layer &)=delete
 Copy assignment is deleted. More...
 
Layeroperator= (Layer &&other)
 Move assignment. More...
 
virtual bool propagate_mouseevent (Input::Mouse::EventType evet, Geometry::Point location, Input::Mouse::Button button, float amount, MouseHandler &handlers)
 Propagates a mouse event. More...
 
virtual void Show ()
 Displays this layer. More...
 
void Swap (Layer &other)
 Swaps two layers, mostly used for move semantics. More...
 
void Add (Layer &layer)
 Adds the given layer as a child. More...
 
void Add (Layer *layer)
 Adds the given layer as a child. More...
 
void setname (std::string value)
 For debugging. More...
 
void Insert (Layer &layer, long under)
 Inserts the given layer before the given index. More...
 
void Insert (Layer *layer, long under)
 Inserts the given layer before the given index. More...
 
void Remove (Layer &layer)
 Removes the given layer. More...
 
void Remove (Layer *layer)
 Removes the given layer. More...
 
bool HasParent () const
 Returns whether this layer has a parent. More...
 
virtual LayerGetParent () const
 Returns the parent of this layer. More...
 
LayerGetTopLevel () const
 Returns the top level layer that contains this layer. More...
 
virtual Geometry::Point TranslateToTopLevel (Geometry::Point location={0, 0}) const
 Translates the given location to the top level. More...
 
LayerGetTopLevel ()
 
Containers::Collection< Layer >::ConstIterator begin () const
 An iterator pointing to the start of the children. More...
 
Containers::Collection< Layer >::ConstIterator end () const
 An iterator pointing to the end of the children. More...
 
Containers::Collection< Layer >::ConstIterator First () const
 An iterator pointing to the start of the children. More...
 
Containers::Collection< Layer >::ConstIterator Last () const
 An iterator pointing to the last item of the children. More...
 
void PlaceBefore (int before)
 Places this layer before the given index. More...
 
void PlaceToTop ()
 Places this layer to the top of the layer stack its in. More...
 
void PlaceToBottom ()
 Places this layer to the bottom of the layer stack. More...
 
int GetOrder () const
 Gets the current order of the stack. More...
 
virtual void Move (const Geometry::Point &location)
 Moves this layer to the given location. More...
 
virtual void Move (int x, int y)
 Moves this layer to the given location. More...
 
virtual void Resize (const Geometry::Size &size)
 Resizes the layer to the given size. More...
 
virtual void Resize (int width, int height)
 Resizes the layer to the given size. More...
 
void SetWidth (int width)
 Resizes the layer to the given size. More...
 
void SetHeight (int height)
 Resizes the layer to the given size. More...
 
void SetBounds (const Geometry::Bounds &bounds)
 Sets the boundaries of this layer. More...
 
Geometry::Size GetSize () const
 Returns the size of the layer. More...
 
Geometry::Size GetCalculatedSize () const
 Returns the size of the layer. More...
 
int GetWidth () const
 Returns the width of the layer. More...
 
int GetHeight () const
 Returns the height of the layer. More...
 
Geometry::Point GetLocation () const
 Returns the current location of the layer. More...
 
int GetLeft () const
 Returns the current location of the layer. More...
 
int GetTop () const
 Returns the current location of the layer. More...
 
Geometry::Bounds GetBounds () const
 Returns the boundaries of the layer. More...
 
Geometry::Bounds GetEffectiveBounds () const
 Returns the effective boundaries of the layer. More...
 
- Public Member Functions inherited from TextureTarget
virtual void Draw (const Geometry::Pointf &location, const Geometry::Sizef &size, RGBAf color=RGBAf(1.f))
 Draws a textureless solid colored rectangle on the screen. More...
 
virtual void Draw (const Geometry::Pointf &location, float w, float h, RGBAf color=RGBAf(1.f))
 Draws a textureless solid colored rectangle on the screen. More...
 
virtual void Draw (const Geometry::Rectanglef &location, RGBAf color=RGBAf(1.f))
 Draws a textureless solid colored rectangle on the screen. More...
 
virtual void Draw (const TextureSource &image, const Geometry::Pointf &location, RGBAf color)
 Draws a simple image to the screen to the given position. More...
 
virtual void Draw (const TextureSource &image, const Geometry::Rectanglef &location, RGBAf color=RGBAf(1.f))
 Draws a simple image to the screen to the given position with the given size. More...
 
virtual void Draw (float x, float y, const Geometry::Sizef &size, RGBAf color=RGBAf(1.f))
 Draws a textureless solid colored rectangle on the screen. More...
 
virtual void Draw (float x, float y, float w, float h, RGBAf color=RGBAf(1.f))
 Draws a textureless solid colored rectangle on the screen. More...
 
virtual void Draw (int x, int y, int w, int h, RGBAf color=RGBAf(1.f))
 Draws a textureless solid colored rectangle on the screen. More...
 
virtual void Draw (RGBAf color=RGBAf(1.f))
 Draws a textureless solid colored rectangle to cover the texture target. More...
 

Additional Inherited Members

- Public Types inherited from TextureTarget
enum  DrawMode { Normal, FrameBuffer, ToMask, UseMask }
 
- Public Attributes inherited from Layer
const Containers::Collection< Layer > & Children
 Sub-layers that this layer holds, all the sub-layers are considered to be above current layer. More...
 
- Static Public Attributes inherited from Layer
static const Geometry::Bounds EntireRegion
 When used as layer bounds, represents the entire region its placed in. More...
 
- Protected Member Functions inherited from Layer
virtual void added (Layer &layer)
 Will be called when a layer is added. More...
 
void dotransformandclip (bool inverse=false)
 Performs transformation and clipping. Use inverse for reverse mapping for mouse events. More...
 
virtual void located (Layer *parent)
 Will be called when this layer is added to another. More...
 
virtual void removed (Layer &layer)
 Will be called when a layer is removed. More...
 
void reverttransformandclip ()
 Reverts previously done transformation. More...
 
- Protected Attributes inherited from Layer
Geometry::Bounds bounds
 Bounds of this layer. More...
 
Containers::Collection< Layerchildren
 Child layers that this layer holds, all child layers are considered to be above current layer. More...
 
bool isvisible
 Whether this layer is visible, invisible layers will not be drawn or receive any events. More...
 
std::string name
 For debugging. More...
 
Layerparent
 Parent layer, could be nullptr. More...
 

Detailed Description

This layer allows drawing texture images on.

Any graphics that are drawn over a layer stays there unless Clear function is called. This allows static layers to be drawn only once. Layers stack, and child layers are drawn on top of parent. Clearing parent layer will not clear child layers.

It is possible to draw surfaces without a texture to this layer. Graphics clipping is optional and disabled by default. This means any texture falling outside the layer will still be visible. Use EnableClipping to change this behavior. Additionally, this layer allows tinting the textures given to it. Use SetTintColor to change the tinting color. Tint color is multiplicatively effective to the underlying layers. This means if you set tint color of a layer, you don't need to set it separately for its children. It is better to use Draw functions of the images or animations instead of Draw functions of the layer.

Drawing modes

Currently Normal, and FrameBuffer modes are supported.

Constructor & Destructor Documentation

◆ Layer() [1/5]

Layer ( const Geometry::Bounds bounds)

Initializing constructor.

◆ Layer() [2/5]

Layer ( )

Constructor that sets the layer to cover entire parent, no matter how big it is.

The location of the layer is set to be the origin

◆ Layer() [3/5]

Layer ( const Geometry::Point location)

Constructor that places the layer to the given location.

◆ Layer() [4/5]

Layer ( const Layer )
delete

Copy constructor is disabled.

◆ Layer() [5/5]

Layer ( Layer &&  other)

Move constructor.

References Layer::Swap().

Member Function Documentation

◆ Clear()

virtual void Clear ( )
overridevirtual

Clears drawing buffer, in layer architecture this request only affects the layer itself, not its children.

Implements TextureTarget.

◆ DisableClipping()

void DisableClipping ( )

Disables graphics clipping.

◆ Draw() [1/17]

virtual void Draw

Draws a textureless solid colored rectangle on the screen.

References TextureTarget::Draw().

◆ Draw() [2/17]

virtual void Draw

Draws a textureless solid colored rectangle on the screen.

References TextureTarget::Draw().

◆ Draw() [3/17]

virtual void Draw ( const Geometry::Pointf p1,
const Geometry::Pointf p2,
const Geometry::Pointf p3,
const Geometry::Pointf p4,
RGBAf  color = RGBAf(1.f) 
)
overridevirtual

Prefer using Draw functions of image or animations.

Implements TextureTarget.

◆ Draw() [4/17]

virtual void Draw

Draws a textureless solid colored rectangle on the screen.

◆ Draw() [5/17]

◆ Draw() [6/17]

virtual void Draw

Draws a simple image to the screen to the given position.

References TextureTarget::Draw(), and TextureSource::GetImageSize().

◆ Draw() [7/17]

virtual void Draw ( const TextureSource image,
const Geometry::Pointf p1,
const Geometry::Pointf p2,
const Geometry::Pointf p3,
const Geometry::Pointf p4,
const Geometry::Pointf tex1,
const Geometry::Pointf tex2,
const Geometry::Pointf tex3,
const Geometry::Pointf tex4,
RGBAf  color = RGBAf(1.f) 
)
overridevirtual

Prefer using Draw functions of image or animations.

Implements TextureTarget.

◆ Draw() [8/17]

virtual void Draw

Draws a simple texture to the screen.

This variant allows every corner on the target and on the texture be specified. The texture target should be cleared before the texture drawn on it is destroyed

◆ Draw() [9/17]

virtual void Draw ( const TextureSource image,
const Geometry::Pointf p1,
const Geometry::Pointf p2,
const Geometry::Pointf p3,
const Geometry::Pointf p4,
RGBAf  color = RGBAf(1.f) 
)
overridevirtual

Prefer using Draw functions of image or animations.

Implements TextureTarget.

◆ Draw() [10/17]

virtual void Draw

Draws a simple texture to the screen.

This variant allows every corner on the target to be specified. The texture target should be cleared before the texture drawn on it is destroyed

◆ Draw() [11/17]

virtual void Draw

◆ Draw() [12/17]

◆ Draw() [13/17]

virtual void Draw

Draws a simple image to the screen using the given tiling method, coordinates and size.

◆ Draw() [14/17]

virtual void Draw

Draws a textureless solid colored rectangle on the screen.

References TextureTarget::Draw().

◆ Draw() [15/17]

virtual void Draw

Draws a textureless solid colored rectangle on the screen.

References TextureTarget::Draw().

◆ Draw() [16/17]

virtual void Draw

Draws a textureless solid colored rectangle on the screen.

References TextureTarget::Draw().

◆ Draw() [17/17]

virtual void Draw

Draws a textureless solid colored rectangle to cover the texture target.

References TextureTarget::Draw(), and TextureTarget::GetTargetSize().

◆ EnableClipping()

void EnableClipping ( )

Enables graphics clipping from the visible borders of the layer.

◆ GetColor()

virtual RGBAf GetColor ( ) const
virtual

Changes the tint color of the layer, every image pixel will be multiplied by this color.

◆ GetDrawMode()

virtual DrawMode GetDrawMode ( ) const
overridevirtual

Get current drawing mode. See Layer page to see available drawing modes.

Implements TextureTarget.

◆ GetTargetSize()

virtual Geometry::Size GetTargetSize ( ) const
overridevirtual

◆ GetTintColor()

virtual RGBAf GetTintColor ( ) const
virtual

Returns the tint color of the layer, every image pixel will be multiplied by this color.

◆ IsClippingEnabled()

bool IsClippingEnabled ( ) const

Returns if the clipping is enabled.

◆ NewMask()

virtual void NewMask ( )
overridevirtual

Queues the start of a new mask. Only one mask buffer exists and it will be cleared and reused.

Implements TextureTarget.

◆ Render()

◆ SetColor()

virtual void SetColor ( RGBAf  value)
virtual

Changes the tint color of the layer, every image pixel will be multiplied by this color.

This value effects only the images drawn after it is set.

◆ SetDrawMode()

virtual void SetDrawMode ( DrawMode  mode)
overridevirtual

Change current drawing mode. See Layer page to see available drawing modes.

Implements TextureTarget.

◆ SetTintColor()

virtual void SetTintColor ( RGBAf  value)
virtual

Changes the tint color of the layer, every image pixel will be multiplied by this color.

◆ Swap()


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