![]() |
Gorgon Game Engine
|
This class is the base class for all layer types. More...
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 | ~Layer () |
Destructor. More... | |
virtual void | Hide () |
Hides this layer. More... | |
virtual bool | IsVisible () const |
Returns whether this layer is effectively visible. More... | |
Layer & | operator= (const Layer &)=delete |
Copy assignment is deleted. More... | |
Layer & | operator= (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 | Render () |
Renders the current layer, default handling is to pass the request to the sub-layers. Rendering is not thread safe. More... | |
virtual void | Show () |
Displays this layer. More... | |
void | Swap (Layer &other) |
Swaps two layers, mostly used for move semantics. More... | |
Public Attributes | |
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 | |
static const Geometry::Bounds | EntireRegion |
When used as layer bounds, represents the entire region its placed in. More... | |
Protected Member Functions | |
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 | |
Geometry::Bounds | bounds |
Bounds of this layer. More... | |
Containers::Collection< Layer > | children |
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... | |
Layer * | parent |
Parent layer, could be nullptr. More... | |
Children related functions | |
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 Layer & | GetParent () const |
Returns the parent of this layer. More... | |
Layer & | GetTopLevel () 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... | |
Layer & | GetTopLevel () |
Iterator related functions | |
These functions return an iterator that allows children to be iterated. | |
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... | |
Ordering functions | |
This layer should be a in another layer for these methods to work. | |
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... | |
Geometry related functions | |
These functions modify or return the boundaries of this layer | |
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... | |
This class is the base class for all layer types.
All common methods are implemented with a common way. This class always implements basic processing functions. Derived classes can override them. Unless overridden these basic functions only propagate the call. Copying a layer is dangerous and therefore disabled.
Layer | ( | const Geometry::Bounds & | bounds | ) |
Initializing constructor.
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 | ( | const Geometry::Point & | location | ) |
Constructor that places the layer to the given location.
References basic_Size< T_ >::Max().
Move constructor.
References Layer::Swap().
|
virtual |
Destructor.
References Layer::children, Layer::parent, Layer::Remove(), and Window::Windows.
void Add | ( | Layer & | layer | ) |
Adds the given layer as a child.
Notice that the newly added layer is drawn on top of others.
References Layer::added(), Layer::children, Layer::located(), Layer::parent, and Layer::Remove().
void Add | ( | Layer * | layer | ) |
Adds the given layer as a child.
Notice that the newly added layer is drawn on top of others.
References Layer::Add().
|
protectedvirtual |
Containers::Collection<Layer>::ConstIterator begin | ( | ) | const |
An iterator pointing to the start of the children.
References Layer::children.
|
protected |
Performs transformation and clipping. Use inverse for reverse mapping for mouse events.
References basic_Bounds< T_ >::Bottom, Layer::bounds, Gorgon::Clip, basic_Bounds< T_ >::GetSize(), basic_Bounds< T_ >::Height(), basic_Bounds< T_ >::Left, Gorgon::Offset, Gorgon::prev_Clip, Gorgon::prev_Offset, Gorgon::prev_Transform, basic_Bounds< T_ >::Right, basic_Bounds< T_ >::Top, basic_Bounds< T_ >::TopLeft(), Gorgon::Transform, basic_Transform3D< T_ >::Translate(), and basic_Bounds< T_ >::Width().
Containers::Collection<Layer>::ConstIterator end | ( | ) | const |
An iterator pointing to the end of the children.
References Layer::children.
Containers::Collection<Layer>::ConstIterator First | ( | ) | const |
An iterator pointing to the start of the children.
References Layer::children.
Geometry::Bounds GetBounds | ( | ) | const |
Returns the boundaries of the layer.
References Layer::bounds.
Geometry::Size GetCalculatedSize | ( | ) | const |
Returns the size of the layer.
If any dimension size is 0, it means the layer will span its parent, this function will perform necessary calculation to get parent size.
References Layer::bounds, Layer::GetCalculatedSize(), Layer::GetLocation(), basic_Bounds< T_ >::GetSize(), Layer::GetSize(), and Layer::parent.
Geometry::Bounds GetEffectiveBounds | ( | ) | const |
Returns the effective boundaries of the layer.
References Layer::bounds, Layer::GetEffectiveBounds(), Layer::GetLocation(), basic_Bounds< T_ >::GetSize(), Layer::GetSize(), and Layer::parent.
int GetHeight | ( | ) | const |
Returns the height of the layer.
References Layer::bounds, and basic_Bounds< T_ >::Height().
int GetLeft | ( | ) | const |
Returns the current location of the layer.
References Layer::bounds, and basic_Bounds< T_ >::Left.
Geometry::Point GetLocation | ( | ) | const |
Returns the current location of the layer.
References Layer::bounds, and basic_Bounds< T_ >::TopLeft().
int GetOrder | ( | ) | const |
Gets the current order of the stack.
0 means the layer is the bottommost layer in the stack
References Layer::children, and Layer::parent.
|
virtual |
Returns the parent of this layer.
Throws if no parent is set. Use HasParent to make sure this layer has a parent
std::runtime_error | if no parent is set |
References Layer::parent.
Geometry::Size GetSize | ( | ) | const |
Returns the size of the layer.
References Layer::bounds, and basic_Bounds< T_ >::GetSize().
int GetTop | ( | ) | const |
Returns the current location of the layer.
References Layer::bounds, and basic_Bounds< T_ >::Top.
Layer& GetTopLevel | ( | ) |
References Layer::GetTopLevel(), and Layer::parent.
Layer& GetTopLevel | ( | ) | const |
Returns the top level layer that contains this layer.
References Layer::GetTopLevel(), and Layer::parent.
int GetWidth | ( | ) | const |
Returns the width of the layer.
References Layer::bounds, and basic_Bounds< T_ >::Width().
bool HasParent | ( | ) | const |
Returns whether this layer has a parent.
References Layer::parent.
|
virtual |
void Insert | ( | Layer & | layer, |
long | under | ||
) |
Inserts the given layer before the given index.
The newly inserted layer will be drawn under the layer in the given index
References Layer::added(), Layer::bounds, Layer::children, basic_Bounds< T_ >::Height(), Layer::located(), Layer::parent, Layer::Remove(), basic_Bounds< T_ >::SetHeight(), basic_Bounds< T_ >::SetWidth(), and basic_Bounds< T_ >::Width().
void Insert | ( | Layer * | layer, |
long | under | ||
) |
Inserts the given layer before the given index.
The newly inserted layer will be drawn under the layer in the given index
References Layer::Insert().
|
virtual |
Returns whether this layer is effectively visible.
Reimplemented in Window, and Window.
References Layer::isvisible, and Layer::parent.
Containers::Collection<Layer>::ConstIterator Last | ( | ) | const |
An iterator pointing to the last item of the children.
References Layer::children.
|
protectedvirtual |
Will be called when this layer is added to another.
Reimplemented in Window.
|
virtual |
Moves this layer to the given location.
Reimplemented in Window.
References Layer::bounds, and basic_Bounds< T_ >::Move().
|
virtual |
Moves this layer to the given location.
Reimplemented in Window.
References Layer::bounds, and basic_Bounds< T_ >::Move().
Move assignment.
References Layer::children, Layer::parent, Layer::Remove(), and Layer::Swap().
void PlaceBefore | ( | int | before | ) |
Places this layer before the given index.
This layer will be drawn above the given index.
References Layer::children, and Layer::parent.
void PlaceToBottom | ( | ) |
Places this layer to the bottom of the layer stack.
References Layer::children, and Layer::parent.
void PlaceToTop | ( | ) |
Places this layer to the top of the layer stack its in.
This makes sure that its not being covered by other layers apart from its own children
References Layer::children, and Layer::parent.
|
virtual |
Propagates a mouse event.
Some events will be called directly. Do not use this function. Direct calls should never touch handlers. Input layers should cache perform transformations on direct calls. Direct calls should not be clipped. button is set only for Click/Down/Up events, amount will be set for Scroll/Zoom events. Mouse event system is not thread safe.
Reimplemented in Layer, and DropTarget.
References Layer::children, Layer::dotransformandclip(), Layer::GetCalculatedSize(), Gorgon::Input::needsclip(), Gorgon::Input::Mouse::Out, Layer::reverttransformandclip(), Gorgon::Transform, and Gorgon::Input::Keyboard::Keycodes::Up.
void Remove | ( | Layer & | layer | ) |
Removes the given layer.
References Layer::children, Layer::located(), Layer::parent, and Layer::removed().
void Remove | ( | Layer * | layer | ) |
Removes the given layer.
References Layer::Remove().
|
protectedvirtual |
Will be called when a layer is removed.
This function will be called even if the given layer is not a child of this layer.
|
virtual |
Renders the current layer, default handling is to pass the request to the sub-layers. Rendering is not thread safe.
Reimplemented in Window, ComponentStack, and Layer.
References Layer::children, Layer::dotransformandclip(), and Layer::reverttransformandclip().
|
virtual |
Resizes the layer to the given size.
Reimplemented in ComponentStack, and Window.
|
virtual |
Resizes the layer to the given size.
Reimplemented in Window.
|
protected |
Reverts previously done transformation.
References Gorgon::Clip, Gorgon::Offset, Gorgon::prev_Clip, Gorgon::prev_Offset, Gorgon::prev_Transform, and Gorgon::Transform.
void SetBounds | ( | const Geometry::Bounds & | bounds | ) |
Sets the boundaries of this layer.
References Layer::bounds.
void SetHeight | ( | int | height | ) |
Resizes the layer to the given size.
References Layer::bounds, and basic_Bounds< T_ >::SetHeight().
void setname | ( | std::string | value | ) |
For debugging.
References Layer::name.
void SetWidth | ( | int | width | ) |
Resizes the layer to the given size.
References Layer::bounds, and basic_Bounds< T_ >::SetWidth().
|
virtual |
void Swap | ( | Layer & | other | ) |
Swaps two layers, mostly used for move semantics.
References Layer::bounds, Layer::Children, Layer::children, Layer::isvisible, Layer::parent, and Gorgon::swap().
|
virtual |
Translates the given location to the top level.
|
protected |
Bounds of this layer.
const Containers::Collection<Layer>& Children |
Sub-layers that this layer holds, all the sub-layers are considered to be above current layer.
|
protected |
Child layers that this layer holds, all child layers are considered to be above current layer.
|
static |
When used as layer bounds, represents the entire region its placed in.
|
protected |
Whether this layer is visible, invisible layers will not be drawn or receive any events.
|
protected |
For debugging.
|
protected |
Parent layer, could be nullptr.