Simple GUI Library
Sgl::Component Class Referenceabstract
Inheritance diagram for Sgl::Component:
Collaboration diagram for Sgl::Component:

Public Types

enum class  Visibility { INVISIBLE_DISABLED = 0b00 , INVISIBLE_INTERACTABLE = 0b01 , VISIBLE_DISABLED = 0b10 , VISIBLE_INTERACTABLE = 0b11 }
 Used to determine if Component should be rendered and targeted by events. More...
 

Public Member Functions

virtual ComponentgetHitComponent (int32_t x, int32_t y)
 
virtual void render (const Sml::Rectangle< int32_t > &targetRegion)=0
 
virtual void layout ()
 
virtual void prerender ()
 
virtual bool containsComponent (Component *component)
 
virtual Sml::EventDispatchChain * buildEventDispatchChain (Sml::EventDispatchChain *chain) override
 
bool isVisible () const
 
void setVisible (bool visible)
 
bool isInteractable () const
 
void setInteractable (bool interactable)
 
Visibility getVisibility () const
 
void setVisibility (Visibility visibility)
 
bool isFocused () const
 
bool isHovered () const
 
virtual bool isResizable () const =0
 
void requestFocus ()
 
void requestDrag ()
 
const ShadowgetShadow () const
 
void setShadow (const ShadowSpecification *specification)
 
GuiEventDispatchergetEventDispatcher ()
 
ScenegetScene ()
 
void setScene (Scene *scene)
 
const ParentgetParent () const
 
ParentgetModifiableParent ()
 
void setParent (Parent *parent)
 
Sml::Vec2i computeLocalToScenePos (const Sml::Vec2i &localPos) const
 
Sml::Vec2i computeSceneToLocalPos (const Sml::Vec2i &scenePos) const
 
Sml::Rectangle< int32_t > getOriginBounds () const
 
const Sml::Rectangle< int32_t > & getLayoutBounds () const
 
const Sml::Vec2i & getLayoutPos () const
 
int32_t getLayoutX () const
 
int32_t getLayoutY () const
 
int32_t getLayoutWidth () const
 
int32_t getLayoutHeight () const
 
void setLayoutX (int32_t x)
 
void setLayoutY (int32_t y)
 
void setLayoutWidth (int32_t width)
 
void setLayoutHeight (int32_t height)
 
Sml::Vec2i computeScenePos ()
 
virtual int32_t computePrefWidth (int32_t height=-1) const =0
 
virtual int32_t computePrefHeight (int32_t width=-1) const =0
 
virtual int32_t computeMinWidth (int32_t height=-1) const =0
 
virtual int32_t computeMinHeight (int32_t width=-1) const =0
 
virtual int32_t computeMaxWidth (int32_t height=-1) const =0
 
virtual int32_t computeMaxHeight (int32_t width=-1) const =0
 

Public Attributes

friend Scene
 

Static Public Attributes

static const int32_t USE_COMPUTED_SIZE = INT32_MIN
 
static const int32_t UNLIMITED_SIZE = INT32_MAX
 

Protected Member Functions

void updateShadow ()
 
void renderShadow (const Sml::Rectangle< int32_t > &targetRegion)
 
virtual void setSceneInSceneTree (Scene *scene)
 

Protected Attributes

Visibility m_Visibility = Visibility::VISIBLE_INTERACTABLE
 
bool m_Focused = false
 
bool m_Hovered = false
 
Shadow m_Shadow
 
GuiEventDispatcher m_Dispatcher
 
Scenem_Scene = nullptr
 
Parentm_Parent = nullptr
 
Sml::Rectangle< int32_t > m_LayoutBounds = {{0, 0}, 0, 0}
 

Detailed Description

Definition at line 26 of file component.h.

Member Enumeration Documentation

◆ Visibility

enum class Sgl::Component::Visibility
strong

Used to determine if Component should be rendered and targeted by events.

Note
The least significant bit specifies interactability, and the following one specifies visibility.

Definition at line 35 of file component.h.

Member Function Documentation

◆ buildEventDispatchChain()

Sml::EventDispatchChain * Sgl::Component::buildEventDispatchChain ( Sml::EventDispatchChain *  chain)
overridevirtual

Definition at line 33 of file component.cpp.

◆ computeLocalToScenePos()

Sml::Vec2i Sgl::Component::computeLocalToScenePos ( const Sml::Vec2i &  localPos) const

Definition at line 148 of file component.cpp.

◆ computeScenePos()

Sml::Vec2i Sgl::Component::computeScenePos ( )

Definition at line 215 of file component.cpp.

◆ computeSceneToLocalPos()

Sml::Vec2i Sgl::Component::computeSceneToLocalPos ( const Sml::Vec2i &  scenePos) const

Definition at line 154 of file component.cpp.

◆ containsComponent()

bool Sgl::Component::containsComponent ( Component component)
virtual

Definition at line 27 of file component.cpp.

◆ getEventDispatcher()

GuiEventDispatcher * Sgl::Component::getEventDispatcher ( )

Definition at line 113 of file component.cpp.

◆ getHitComponent()

Component * Sgl::Component::getHitComponent ( int32_t  x,
int32_t  y 
)
virtual

Definition at line 14 of file component.cpp.

◆ getLayoutBounds()

const Sml::Rectangle< int32_t > & Sgl::Component::getLayoutBounds ( ) const

Definition at line 165 of file component.cpp.

◆ getLayoutHeight()

int32_t Sgl::Component::getLayoutHeight ( ) const

Definition at line 190 of file component.cpp.

◆ getLayoutPos()

const Sml::Vec2i & Sgl::Component::getLayoutPos ( ) const

Definition at line 170 of file component.cpp.

◆ getLayoutWidth()

int32_t Sgl::Component::getLayoutWidth ( ) const

Definition at line 185 of file component.cpp.

◆ getLayoutX()

int32_t Sgl::Component::getLayoutX ( ) const

Definition at line 175 of file component.cpp.

◆ getLayoutY()

int32_t Sgl::Component::getLayoutY ( ) const

Definition at line 180 of file component.cpp.

◆ getModifiableParent()

Parent * Sgl::Component::getModifiableParent ( )

Definition at line 133 of file component.cpp.

◆ getOriginBounds()

Sml::Rectangle< int32_t > Sgl::Component::getOriginBounds ( ) const

Definition at line 160 of file component.cpp.

◆ getParent()

const Parent * Sgl::Component::getParent ( ) const

Definition at line 128 of file component.cpp.

◆ getScene()

Scene * Sgl::Component::getScene ( )

Definition at line 118 of file component.cpp.

◆ getShadow()

const Shadow & Sgl::Component::getShadow ( ) const

Definition at line 103 of file component.cpp.

◆ getVisibility()

Component::Visibility Sgl::Component::getVisibility ( ) const

Definition at line 83 of file component.cpp.

◆ isFocused()

bool Sgl::Component::isFocused ( ) const

Definition at line 86 of file component.cpp.

◆ isHovered()

bool Sgl::Component::isHovered ( ) const

Definition at line 87 of file component.cpp.

◆ isInteractable()

bool Sgl::Component::isInteractable ( ) const

Definition at line 65 of file component.cpp.

◆ isVisible()

bool Sgl::Component::isVisible ( ) const

Definition at line 47 of file component.cpp.

◆ layout()

void Sgl::Component::layout ( )
virtual

Definition at line 24 of file component.cpp.

◆ prerender()

void Sgl::Component::prerender ( )
virtual

Definition at line 25 of file component.cpp.

◆ renderShadow()

void Sgl::Component::renderShadow ( const Sml::Rectangle< int32_t > &  targetRegion)
protected

Definition at line 254 of file component.cpp.

◆ requestDrag()

void Sgl::Component::requestDrag ( )

Definition at line 96 of file component.cpp.

◆ requestFocus()

void Sgl::Component::requestFocus ( )

Definition at line 89 of file component.cpp.

◆ setInteractable()

void Sgl::Component::setInteractable ( bool  interactable)

Definition at line 67 of file component.cpp.

◆ setLayoutHeight()

void Sgl::Component::setLayoutHeight ( int32_t  height)

Definition at line 210 of file component.cpp.

◆ setLayoutWidth()

void Sgl::Component::setLayoutWidth ( int32_t  width)

Definition at line 205 of file component.cpp.

◆ setLayoutX()

void Sgl::Component::setLayoutX ( int32_t  x)

Definition at line 195 of file component.cpp.

◆ setLayoutY()

void Sgl::Component::setLayoutY ( int32_t  y)

Definition at line 200 of file component.cpp.

◆ setParent()

void Sgl::Component::setParent ( Parent parent)

Definition at line 138 of file component.cpp.

◆ setScene()

void Sgl::Component::setScene ( Scene scene)

Definition at line 123 of file component.cpp.

◆ setSceneInSceneTree()

void Sgl::Component::setSceneInSceneTree ( Scene scene)
protectedvirtual

Definition at line 262 of file component.cpp.

◆ setShadow()

void Sgl::Component::setShadow ( const ShadowSpecification specification)

Definition at line 108 of file component.cpp.

◆ setVisibility()

void Sgl::Component::setVisibility ( Visibility  visibility)

Definition at line 84 of file component.cpp.

◆ setVisible()

void Sgl::Component::setVisible ( bool  visible)

Definition at line 49 of file component.cpp.

◆ updateShadow()

void Sgl::Component::updateShadow ( )
protected

Definition at line 229 of file component.cpp.

Member Data Documentation

◆ m_Dispatcher

GuiEventDispatcher Sgl::Component::m_Dispatcher
protected

Definition at line 123 of file component.h.

◆ m_Focused

bool Sgl::Component::m_Focused = false
protected

Definition at line 119 of file component.h.

◆ m_Hovered

bool Sgl::Component::m_Hovered = false
protected

Definition at line 120 of file component.h.

◆ m_LayoutBounds

Sml::Rectangle<int32_t> Sgl::Component::m_LayoutBounds = {{0, 0}, 0, 0}
protected

Definition at line 127 of file component.h.

◆ m_Parent

Parent* Sgl::Component::m_Parent = nullptr
protected

Definition at line 126 of file component.h.

◆ m_Scene

Scene* Sgl::Component::m_Scene = nullptr
protected

Definition at line 125 of file component.h.

◆ m_Shadow

Shadow Sgl::Component::m_Shadow
protected

Definition at line 121 of file component.h.

◆ m_Visibility

Visibility Sgl::Component::m_Visibility = Visibility::VISIBLE_INTERACTABLE
protected

Definition at line 118 of file component.h.

◆ Scene

friend Sgl::Component::Scene

Definition at line 48 of file component.h.

◆ UNLIMITED_SIZE

const int32_t Sgl::Component::UNLIMITED_SIZE = INT32_MAX
static

Definition at line 45 of file component.h.

◆ USE_COMPUTED_SIZE

const int32_t Sgl::Component::USE_COMPUTED_SIZE = INT32_MIN
static

Definition at line 44 of file component.h.


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