 |
Gorgon Game Engine
|
Go to the documentation of this file.
4 #include "ConsumableEvent.h"
35 if(layer)
layers.Add(layer);
45 operator bool()
const {
46 return layers.GetCount() > 0;
128 if(
this == &other)
return;
143 auto otherparent = other.
parent;
149 myind = myparent->
Children.FindLocation(
this);
153 otherind = otherparent->Children.FindLocation(other);
157 myparent->Remove(
this);
158 myparent->Insert(other, myind);
162 otherparent->Remove(other);
163 otherparent->Insert(
this, otherind);
227 if(!
parent)
throw std::runtime_error(
"No parent is set");
235 return const_cast<Layer &
>(*this);
242 const Layer *cur =
this;
332 virtual void Move(
int x,
int y) {
342 virtual void Resize(
int width,
int height) {
385 s.Height = ps.Height;
438 auto w = pb.Width() - p.X;
439 auto h = pb.Height() - p.Y;
DrawMode
Definition: TextureTargets.h:14
virtual void Resize(const Geometry::Size &size)
Resizes the layer to the given size.
Definition: Layer.h:337
MaskedShader & SetDiffuse(GL::Texture value)
Sets diffuse texture.
Definition: Shaders.h:103
basic_Point< T_ > TopLeft() const
Returns the top left coordinates of the rectangle.
Definition: Rectangle.h:198
This class represents boundaries of 2D objects.
Definition: Bounds.h:27
void swap(Event< Source_, Args_... > &l, Event< Source_, Args_... > &r)
Swaps two events.
Definition: Event.h:351
Layer(const Geometry::Bounds &bounds)
Initializing constructor.
Definition: Layer.h:83
virtual ~Layer()
Destructor.
Definition: Layer.cpp:159
MaskedAlphaShader & SetTextureCoords(const GL::QuadTextureCoords &value)
Sets texture coordinates.
Definition: Shaders.h:204
void Remove(Layer *layer)
Removes the given layer.
Definition: Layer.h:212
void Move(const basic_Point< T_ > &p)
Changes the position of the bounds.
Definition: Bounds.h:212
Layer(const Geometry::Point &location)
Constructor that places the layer to the given location.
Definition: Layer.h:93
void Clear()
Clears the window pointed by the active context.
Definition: OpenGL.cpp:277
bool IsPartial() const
Returns whether this texture uses only a part of the GL::Texture.
Definition: Graphics.h:495
MaskedAlphaShader & SetAlpha(GL::Texture value)
Sets alpha texture.
Definition: Shaders.h:212
Layer(const Layer &)=delete
Copy constructor is disabled.
void Add(Layer &layer)
Adds the given layer as a child.
Definition: Layer.cpp:23
Layer(Layer &&other)
Move constructor.
Definition: Layer.h:101
Geometry::Point GetLocation() const
Returns the current location of the layer.
Definition: Layer.h:403
contains collection, a vector of references.
const Containers::Collection< Layer > & Children
Sub-layers that this layer holds, all the sub-layers are considered to be above current layer.
Definition: Layer.h:475
void ActivateQuadVertices()
Definition: Graphics.cpp:23
contains the Bounds class
void dotransformandclip(bool inverse=false)
Performs transformation and clipping. Use inverse for reverse mapping for mouse events.
Definition: Layer.cpp:115
T_ Height
Height of this size object.
Definition: Size.h:261
virtual void Render() override
Render this layer to the GL. This function is used internally and not necessary to be called.
Definition: Layer.cpp:61
void Add(Layer *layer)
Adds the given layer as a child.
Definition: Layer.h:177
T_ Width() const
Calculates and returns the width of the bounds.
Definition: Bounds.h:130
MaskedFillShader & SetVertexCoords(const GL::QuadVertices &value)
Definition: Shaders.h:287
Layer * parent
Parent layer, could be nullptr.
Definition: Layer.h:504
Geometry::Bounds Clip
Current clipping size, for mouse and clipping events.
Definition: Layer.cpp:20
MouseHandler(MouseHandler &&other)
Definition: Layer.h:24
float Float
Represents floating point data type.
Definition: Types.h:16
Containers::Collection< Layer >::ConstIterator end() const
An iterator pointing to the end of the children.
Definition: Layer.h:268
MaskedShader & SetTextureCoords(const GL::QuadTextureCoords &value)
Sets texture coordinates.
Definition: Shaders.h:95
Represents a four channel 32 bit float per channel color information.
Definition: Color.h:373
T_ Height() const
Calculates and returns the height of the bounds.
Definition: Bounds.h:135
T_ Width
Width of the rectangle.
Definition: Rectangle.h:360
MaskedShader & SetMask(GL::Texture value)
Definition: Shaders.h:117
Containers::Collection< Layer >::ConstIterator Last() const
An iterator pointing to the last item of the children.
Definition: Layer.h:278
basic_Size< int > Size
Definition: Size.h:385
void Swap(MouseHandler &other)
Definition: Layer.h:57
void ResetTransform(const Geometry::Size &size)
This should be called by the windows to reset transformation stack.
Definition: Layer.h:65
virtual bool IsVisible() const
Returns whether this layer is effectively visible.
Definition: Layer.h:459
static MaskedAlphaShader & Use()
Definition: Shaders.h:189
Geometry::Size GetCalculatedSize() const
Returns the size of the layer.
Definition: Layer.h:369
Geometry::Bounds GetBounds() const
Returns the boundaries of the layer.
Definition: Layer.h:418
T_ Left
Left-most boundary.
Definition: Bounds.h:399
int GetTop() const
Returns the current location of the layer.
Definition: Layer.h:413
static basic_Size Max()
Returns the maximum representable size.
Definition: Size.h:251
int GetLeft() const
Returns the current location of the layer.
Definition: Layer.h:408
Tiling
Details which directions a texture should tile.
Definition: Graphics.h:31
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
This class represents a 2D geometric size.
Definition: Size.h:23
void SetDefaultClear()
Sets default clear parameters as current.
Definition: OpenGL.cpp:268
@ UseMask
Definition: TextureTargets.h:18
virtual Layer & GetParent() const
Returns the parent of this layer.
Definition: Layer.h:226
void reverttransformandclip()
Reverts previously done transformation.
Definition: Layer.cpp:149
Geometry::Bounds bounds
Bounds of this layer.
Definition: Layer.h:507
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.
virtual const Geometry::Pointf * GetCoordinates() const =0
Should return the coordinates of the texture to be used.
@ FrameBuffer
Definition: TextureTargets.h:16
void PlaceBefore(int before)
Places this layer before the given index.
Definition: Layer.h:290
virtual bool propagate_mouseevent(Input::Mouse::EventType evet, Geometry::Point location, Input::Mouse::Button button, float amount, MouseHandler &handlers)
Propagates a mouse event.
Definition: Layer.cpp:63
virtual void located(Layer *parent)
Will be called when this layer is added to another.
Definition: Layer.h:491
virtual void Move(int x, int y)
Moves this layer to the given location.
Definition: Layer.h:332
void Clear()
Definition: Layer.h:49
MaskedFillShader & SetTint(const Graphics::RGBAf &value)
Definition: Shaders.h:294
void DrawQuadVertices()
Definition: Graphics.cpp:32
Collection is a container for reference typed objects.
Definition: Collection.h:21
basic_Point< int > Point
Definition: Point.h:598
MouseHandler & operator=(MouseHandler &&other)
Definition: Layer.h:28
Geometry::Transform3D Transform
Current layer transformation, only for render and mouse.
Definition: Layer.cpp:18
int GetWidth() const
Returns the width of the layer.
Definition: Layer.h:393
@ Normal
Definition: TextureTargets.h:15
virtual void Render()
Renders the current layer, default handling is to pass the request to the sub-layers....
Definition: Layer.cpp:51
virtual void Move(const Geometry::Point &location)
Moves this layer to the given location.
Definition: Layer.h:327
void SetBounds(const Geometry::Bounds &bounds)
Sets the boundaries of this layer.
Definition: Layer.h:357
void Insert(Layer *layer, long under)
Inserts the given layer before the given index.
Definition: Layer.h:196
basic_Point< T_ > TopRight() const
Returns the top right coordinates of the rectangle.
Definition: Rectangle.h:203
void Use()
Definition: Shader.cpp:87
Const iterator allows iteration of const collections.
Definition: Collection.h:137
basic_Bounds< int > Bounds
Definition: Bounds.h:722
This is a frame buffer object that can be used for render to texture tasks.
Definition: FrameBuffer.h:13
@ Alpha
8bit alpha only color mode
void Remove(Layer &layer)
Removes the given layer.
Definition: Layer.h:203
This class is the base class for all layer types.
Definition: Layer.h:79
This class represents a 2D point.
Definition: Point.h:32
Geometry::Bounds GetEffectiveBounds() const
Returns the effective boundaries of the layer.
Definition: Layer.h:423
int GetOrder() const
Gets the current order of the stack.
Definition: Layer.h:314
void SetWidth(int width)
Resizes the layer to the given size.
Definition: Layer.h:347
MaskedAlphaShader & SetMask(GL::Texture value)
Definition: Shaders.h:228
static const Containers::Collection< Window > & Windows
List of currently created windows.
Definition: Window.h:401
Containers::Collection< Layer >::ConstIterator First() const
An iterator pointing to the start of the children.
Definition: Layer.h:273
virtual void added(Layer &layer)
Will be called when a layer is added.
Definition: Layer.h:484
void SetHeight(const T_ &height)
Changes the height of the bounds, anchor is the topleft.
Definition: Bounds.h:207
T_ Right
Right-most boundary.
Definition: Bounds.h:405
void PlaceToTop()
Places this layer to the top of the layer stack its in.
Definition: Layer.h:301
@ Graphics
Definition: Template.h:164
T_ Height
Height of the rectangle.
Definition: Rectangle.h:363
This interface represents a GL texture source.
Definition: Graphics.h:480
static MaskedFillShader & Use()
Definition: Shaders.h:280
PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate
Definition: OpenGL.cpp:69
T_ Bottom
Bottom-most boundary.
Definition: Bounds.h:408
void SetDefaultBlending()
Sets default blending parameters as current.
Definition: OpenGL.cpp:264
std::vector< Geometry::Point > prev_Offset
Definition: Layer.cpp:16
void Resize(const basic_Size< T_ > &size)
Definition: Bounds.h:145
basic_Point< T_ > TopLeft() const
Returns top left corner.
Definition: Bounds.h:105
basic_Point< T_ > BottomLeft() const
Returns the bottom left coordinates of the rectangle.
Definition: Rectangle.h:208
virtual void Hide()
Hides this layer.
Definition: Layer.h:456
virtual void Show()
Displays this layer.
Definition: Layer.h:453
T_ Width
Width of this size object.
Definition: Size.h:258
void setname(std::string value)
For debugging.
Definition: Layer.h:184
basic_Point< T_ > BottomRight() const
Returns the bottom right coordinates of the rectangle.
Definition: Rectangle.h:213
basic_Size< T_ > GetSize() const
Returns the size of the bounds object.
Definition: Bounds.h:141
MaskedShader & SetTint(const Graphics::RGBAf &value)
Definition: Shaders.h:110
Layer & GetTopLevel() const
Returns the top level layer that contains this layer.
Definition: Layer.h:233
Layer()
Constructor that sets the layer to cover entire parent, no matter how big it is.
Definition: Layer.h:90
void SetWidth(const T_ &width)
Changes the width of the bounds, anchor is the topleft.
Definition: Bounds.h:202
void Swap(Layer &other)
Swaps two layers, mostly used for move semantics.
Definition: Layer.h:125
MaskedShader & SetVertexCoords(const GL::QuadVertices &value)
Definition: Shaders.h:87
int GetHeight() const
Returns the height of the layer.
Definition: Layer.h:398
std::vector< Geometry::Bounds > prev_Clip
Definition: Layer.cpp:15
Geometry::Point Offset
Current layer offset from the top left of the window.
Definition: Layer.cpp:21
void Add(Layer *l)
Definition: Layer.h:53
std::string name
For debugging.
Definition: Layer.h:515
MaskedFillShader & SetMask(GL::Texture value)
Definition: Shaders.h:301
Containers::Collection< Layer >::ConstIterator begin() const
An iterator pointing to the start of the children.
Definition: Layer.h:263
void PlaceToBottom()
Places this layer to the bottom of the layer stack.
Definition: Layer.h:307
Represents a rectangle in a 2D space.
Definition: Rectangle.h:19
MaskedAlphaShader & SetVertexCoords(const GL::QuadVertices &value)
Definition: Shaders.h:196
Containers::Collection< Layer > children
Child layers that this layer holds, all child layers are considered to be above current layer.
Definition: Layer.h:501
Containers::Collection< Layer > layers
Definition: Layer.h:61
bool HasParent() const
Returns whether this layer has a parent.
Definition: Layer.h:219
void SetHeight(int height)
Resizes the layer to the given size.
Definition: Layer.h:352
basic_Transform3D< Float > Transform3D
Definition: Transform3D.h:176
Layer & operator=(const Layer &)=delete
Copy assignment is deleted.
virtual Geometry::Size GetImageSize() const =0
Should return the size of the image stored in texture. Not the whole texture size.
virtual void removed(Layer &layer)
Will be called when a layer is removed.
Definition: Layer.h:488
virtual Geometry::Point TranslateToTopLevel(Geometry::Point location={0, 0}) const
Translates the given location to the top level.
Definition: Layer.h:241
bool isvisible
Whether this layer is visible, invisible layers will not be drawn or receive any events.
Definition: Layer.h:511
std::vector< Geometry::Transform3D > prev_Transform
Definition: Layer.cpp:14
Geometry::Size ScreenSize
Definition: Window.cpp:15
void Insert(Layer &layer, long under)
Inserts the given layer before the given index.
Definition: Layer.cpp:34
static const Geometry::Bounds EntireRegion
When used as layer bounds, represents the entire region its placed in.
Definition: Layer.h:478
Graphics::RGBAf LayerColor
Definition: Layer.cpp:172
void NotImplemented(const std::string &what="This feature")
Definition: Assert.h:187
static MaskedShader & Use()
Definition: Shaders.h:80
T_ Top
Top-most boundary.
Definition: Bounds.h:402
Geometry::Size GetSize() const
Returns the size of the layer.
Definition: Layer.h:362
Layer & GetTopLevel()
Definition: Layer.h:251
@ ToMask
Definition: TextureTargets.h:17
MaskedAlphaShader & SetTint(const Graphics::RGBAf &value)
Definition: Shaders.h:221
MouseHandler(Layer *layer=nullptr)
Definition: Layer.h:34