ZeroZero Game Engine  v0.0
A 3D game engine using Vulkan & Jolt
Public Types | Public Member Functions | List of all members
Widget Class Reference

Detailed Description

Base class for all UI widgets

Inheritance diagram for Widget:
Object CheckWidget Image Line Panel Text ToggleButton Box Frame Button

Public Types

enum  Type {
  WIDGET, PANEL, BOX, LINE,
  FRAME, BUTTON, TOGGLEBUTTON, TEXT,
  TEXTEDIT, SCROLLBAR, TREEVIEW, IMAGE
}
 Widget type. More...
 
enum  AlignmentType { ,
  FILL, CENTER, HCENTER, VCENTER,
  TOP, BOTTOM, LEFT, RIGHT,
  TOPCENTER, BOTTOMCENTER, LEFTCENTER, RIGHTCENTER,
  TOPLEFT, BOTTOMLEFT, BOTTOMRIGHT, TOPRIGHT,
  LEFTTOP, LEFTBOTTOM, RIGHTBOTTOM, RIGHTTOP
}
 Widget placement (relative to the parent widget) More...
 

Public Member Functions

 Widget (Type=WIDGET)
 
Type getType () const
 
bool isVisible () const
 
void show (bool=true)
 
bool isEnabled () const
 
void enable (bool isEnabled=true)
 
void setPos (float x, float y)
 
float getWidth () const
 
float getHeight () const
 
virtual void setSize (float width, float height)
 
const RectgetRect () const
 
void setRect (float x, float y, float width, float height)
 
void setRect (const Rect &)
 
AlignmentType getAlignment () const
 
void setAlignment (AlignmentType)
 
FontgetFont ()
 
void setFont (const shared_ptr< Font > &)
 
bool isFocused () const
 
Widget * getParent () const
 
template<typename T >
shared_ptr< T > add (shared_ptr< T > child, const AlignmentType alignment, const string &resource="", const bool overlap=false)
 
virtual void remove (const shared_ptr< Widget > &child)
 
virtual void removeAll ()
 
void setPadding (float)
 
float getPadding () const
 
bool isDrawBackground () const
 
void setDrawBackground (bool drawBackground)
 
void refresh () const
 
void setResource (shared_ptr< Resource >)
 
uint32_t getGroupIndex () const
 
void setGroupIndex (int32_t)
 
void * getUserData () const
 
void setUserData (void *)
 
float getTransparency () const
 
void setTransparency (float alpha)
 
- Public Member Functions inherited from Object
void connect (const Signal::signal &name, const Signal::Handler &handler)
 
void connect (const Signal::signal &name, const function< void ()> &handler)
 
void emit (const Signal::signal &name, void *params=nullptr)
 
virtual string toString () const
 

Member Enumeration Documentation

Widget placement (relative to the parent widget)

Enum ValuesDocumentation
FILL 

The child widget is centered and resized to the parent content size.

CENTER 

The child widget is centered (and take all the parent content size)

HCENTER 

The child widget is horizontally centered.

VCENTER 

The child widget is vertically centered.

TOP 

The children are stack on the top.

BOTTOM 

The children are stack on the bottom.

LEFT 

The children are stack on the left.

RIGHT 

The children are stack on the right.

TOPCENTER 

The children are stack on the top and horizontally centered.

BOTTOMCENTER 

The children are stack on the bottom and horizontally centered.

LEFTCENTER 

The children are stack on the left and vertically centered.

RIGHTCENTER 

The children are stack on the right and vertically centered.

TOPLEFT 

The children are stack on the top and left aligned.

BOTTOMLEFT 

The children are stack on the bottom and left aligned.

BOTTOMRIGHT 

The children are stack on the bottom and right aligned.

TOPRIGHT 

The children are stack on the top and right aligned.

LEFTTOP 

The children are stack on the left then on the top.

LEFTBOTTOM 

The children are stack on the left then on the bottom.

RIGHTBOTTOM 

The children are stack on the right then on the bottom.

RIGHTTOP 

The children are stack on the right then on the top.

enum Type

Widget type.

Enum ValuesDocumentation
WIDGET 

transparent widget

PANEL 

rectangular widget with only a background

BOX 

rectangular widget with a border and a background

LINE 

A horizontal or vertical line

FRAME 

A box with a title

BUTTON 

A push button

TOGGLEBUTTON 

A two states button

TEXT 

A single line of text

TEXTEDIT 

An editable single line of text.

SCROLLBAR 

A scroll bar. with min, max & pos

TREEVIEW 

Tree of Widget.

IMAGE 

2D Image

Constructor & Destructor Documentation

Widget ( Type  = WIDGET)
explicit

Creates a widget of a particular type

Member Function Documentation

shared_ptr<T> add ( shared_ptr< T >  child,
const AlignmentType  alignment,
const string &  resource = "",
const bool  overlap = false 
)
inline

Adds a child widget. Children widgets will be destroyed on parent destruction.

Parameters
child: child widget to add
alignmentplacement
resource: resource string
overlap: overlap widget on top of other widgets
void enable ( bool  isEnabled = true)

Enables or disables widget reactions to input events

AlignmentType getAlignment ( ) const
nodiscard

Returns the current widget placement

Font& getFont ( )
nodiscard

Returns the current font of the widget

uint32_t getGroupIndex ( ) const
nodiscard

Return the user defined group index

float getHeight ( ) const
nodiscardinline

Returns the height of the widget, in pixels

float getPadding ( ) const
nodiscard

Returns current children padding (space between children)

Widget* getParent ( ) const
inline

Returns the parent widget, or nullptr

const Rect& getRect ( ) const
nodiscard

Returns the size & the position of the widget

float getTransparency ( ) const
nodiscardinline

Return the transparency alpha value

Type getType ( ) const
nodiscard

Returns the type of the widget

void* getUserData ( ) const

Returns the user data

float getWidth ( ) const
nodiscardinline

Returns the width of the widget, in pixels

bool isDrawBackground ( ) const
nodiscard

Returns false if the background is transparent

bool isEnabled ( ) const
nodiscard

Returns true is the widget is reactive to user action (mouse & keyboard)

bool isFocused ( ) const
nodiscard

Returns true if the widget have keyboard focus

bool isVisible ( ) const
nodiscard

Returns true if the widget is visible

void refresh ( ) const

Force a refresh of the entire widget

virtual void remove ( const shared_ptr< Widget > &  child)
virtual

Removes a child widget

virtual void removeAll ( )
virtual

Removes all children widgets recursively

void setAlignment ( AlignmentType  )

Sets the widget placement. Calling this method involve redrawing the parent widget & resizing all the children widgets

void setDrawBackground ( bool  drawBackground)

Sets to false make the widget background transparent

void setFont ( const shared_ptr< Font > &  )

Sets the current font of the widget

void setGroupIndex ( int32_t  )

Set the user defined group index

void setPadding ( float  )

Changes children padding (space between children)

void setPos ( float  x,
float  y 
)

Moves the widget to a particular position.

void setRect ( const Rect )

Changes the size & position of the widget

void setRect ( float  x,
float  y,
float  width,
float  height 
)

Changes the size & position of the widget

void setResource ( shared_ptr< Resource )

Changes widget resources. Use with caution !

virtual void setSize ( float  width,
float  height 
)
virtual

Resizes the widget

void setTransparency ( float  alpha)

Changes the transparency alpha value

void setUserData ( void *  )

set user data

void show ( bool  = true)

Shows or hides the widget