FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
fge::GuiElement Class Referenceabstract

A base class for all GUI elements. More...

#include <C_guiElement.hpp>

Inheritance diagram for fge::GuiElement:
fge::GuiElementDefault fge::GuiElementRectangle fge::GuiElementRecursive fge::ObjButton fge::ObjSelectBox fge::ObjSlider fge::ObjTextInputBox fge::GuiElementArray fge::ObjWindow

Public Types

using Priority = uint8_t
 

Public Member Functions

 GuiElement (fge::GuiElement::Priority priority)
 
virtual bool isRecursive () const
 Check if this GuiElement is recursive.
 
void setGuiScale (fge::Vector2f const &scale)
 Set the scale of the element.
 
fge::Vector2f const & getGuiScale () const
 Get the scale of the element.
 
void setPriority (fge::GuiElement::Priority priority) const
 Set the priority of the element.
 
fge::GuiElement::Priority getPriority () const
 Get the priority of the element.
 
bool verifyPriority (fge::GuiElement *element) const
 Verify if the priority of the element is higher than the given element.
 
virtual void onGuiVerify (fge::Event const &evt, SDL_EventType evtType, fge::GuiElementContext &context)=0
 Function called to verify if the element is hovered by the mouse.
 

Static Public Member Functions

static void setGlobalGuiScale (fge::Vector2f const &scale)
 
static fge::Vector2f const & getGlobalGuiScale ()
 

Public Attributes

fge::CallbackHandler< fge::Event const &, SDL_MouseWheelEvent const &, fge::GuiElementContext & > _onGuiMouseWheelScrolled
 Callback called when the element is verified and the mouse wheel is scrolled.
 
fge::CallbackHandler< fge::Event const &, SDL_MouseButtonEvent const &, fge::GuiElementContext & > _onGuiMouseButtonPressed
 Callback called when the element is verified and the mouse is pressed.
 
fge::CallbackHandler< fge::Event const &, SDL_MouseButtonEvent const &, fge::GuiElementContext & > _onGuiMouseButtonReleased
 Callback called when the element is verified and a mouse button is released.
 
fge::CallbackHandler< fge::Event const &, SDL_MouseMotionEvent const &, fge::GuiElementContext & > _onGuiMouseMoved
 Callback called when the element is verified and the mouse is moved.
 

Static Public Attributes

static fge::CallbackHandler< fge::Vector2f const & > _onGlobalGuiScaleChange
 

Protected Attributes

fge::GuiElement::Priority _g_priority { 50 }
 
fge::Vector2f _g_scale {1.0f, 1.0f}
 

Detailed Description

A base class for all GUI elements.

A GUI element is a utility to handle mouse events by priority for superposed elements.

Warning
Work in progress, this class will handle drawing elements in the future.

Member Function Documentation

◆ getGuiScale()

fge::Vector2f const & fge::GuiElement::getGuiScale ( ) const
inlinenodiscard

Get the scale of the element.

Returns
The scale of the element

◆ getPriority()

fge::GuiElement::Priority fge::GuiElement::getPriority ( ) const
inlinenodiscard

Get the priority of the element.

Returns
The priority of the element

◆ isRecursive()

virtual bool fge::GuiElement::isRecursive ( ) const
inlinenodiscardvirtual

Check if this GuiElement is recursive.

A gui element is recursive if it handle others GuiElements.

Returns
true if it is recursive, false otherwise

Reimplemented in fge::GuiElementRecursive.

◆ onGuiVerify()

virtual void fge::GuiElement::onGuiVerify ( fge::Event const & evt,
SDL_EventType evtType,
fge::GuiElementContext & context )
pure virtual

Function called to verify if the element is hovered by the mouse.

This function should call verifyPriority to verify the priority of the element. If the priority is higher than the given element, the function should replace the provided pointer reference element with the element itself.

Parameters
evtAn fge::Event
evtTypeThe type of the SDL event called
contextThe GuiElement context

Implemented in fge::GuiElementArray, fge::GuiElementDefault, and fge::GuiElementRectangle.

◆ setGuiScale()

void fge::GuiElement::setGuiScale ( fge::Vector2f const & scale)
inline

Set the scale of the element.

Parameters
scaleThe scale of the element

◆ setPriority()

void fge::GuiElement::setPriority ( fge::GuiElement::Priority priority) const
inline

Set the priority of the element.

The priority value can be used with the scene DepthPlan.

Parameters
priorityThe priority of the element

◆ verifyPriority()

bool fge::GuiElement::verifyPriority ( fge::GuiElement * element) const
inlinenodiscard

Verify if the priority of the element is higher than the given element.

If the provided element is null, the function will assume that the element is the highest priority.

Parameters
elementThe element to compare with
Returns
true if the priority of the element is higher than the given element, false otherwise

Member Data Documentation

◆ _onGuiMouseButtonPressed

fge::CallbackHandler<fge::Event const&, SDL_MouseButtonEvent const&, fge::GuiElementContext&> fge::GuiElement::_onGuiMouseButtonPressed

Callback called when the element is verified and the mouse is pressed.

◆ _onGuiMouseButtonReleased

fge::CallbackHandler<fge::Event const&, SDL_MouseButtonEvent const&, fge::GuiElementContext&> fge::GuiElement::_onGuiMouseButtonReleased

Callback called when the element is verified and a mouse button is released.

◆ _onGuiMouseMoved

fge::CallbackHandler<fge::Event const&, SDL_MouseMotionEvent const&, fge::GuiElementContext&> fge::GuiElement::_onGuiMouseMoved

Callback called when the element is verified and the mouse is moved.

◆ _onGuiMouseWheelScrolled

fge::CallbackHandler<fge::Event const&, SDL_MouseWheelEvent const&, fge::GuiElementContext&> fge::GuiElement::_onGuiMouseWheelScrolled

Callback called when the element is verified and the mouse wheel is scrolled.


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