Lysa  0.0
Lysa 3D Engine
Window Class Reference

Detailed Description

A virtual UI Window displayed inside the rendering Window. All UI widgets must belong to a UI window.

+ Inheritance diagram for Window:

Public Types

enum  ResizeableBorder {
  RESIZEABLE_NONE = 0b0000, RESIZEABLE_LEFT = 0b0001, RESIZEABLE_RIGHT = 0b0010, RESIZEABLE_TOP = 0b0100,
  RESIZEABLE_BOTTOM = 0b1000
}
 

Public Member Functions

 Window (const Rect &rect)
 
void setResizeableBorders (const uint32 borders)
 
auto getResizeableBorders () const
 
std::shared_ptr< StylegetStyle () const
 
void setStyle (const std::shared_ptr< Style > &style)
 
WidgetgetWidget () const
 
void setWidget (std::shared_ptr< Widget > child=nullptr, const std::string &resources="", float padding=0)
 
template<typename T >
auto add (const std::shared_ptr< T > &child, const Widget::AlignmentType alignment, const std::string &resource="", const bool overlap=false) const
 
void remove (const std::shared_ptr< Widget > &child) const
 
void setFocusedWidget (const std::shared_ptr< Widget > &widget)
 
auto getWidth () const
 
auto getHeight () const
 
void setRect (const Rect &newRect)
 
void setWidth (float width)
 
void setHeight (float height)
 
void setPos (float x, float y)
 
void setPos (const float2 &pos)
 
void setX (float x)
 
void setY (float y)
 
const auto & getRect () const
 
auto isVisible () const
 
void setVisible (bool isVisible)
 
void hide ()
 
void show ()
 
void setTransparency (float)
 
virtual void onCreate ()
 
virtual void onDestroy ()
 
virtual void onShow ()
 
virtual void onHide ()
 
virtual void onResize ()
 
virtual void onMove ()
 
virtual bool onKeyDown (Key key)
 
virtual bool onKeyUp (Key key)
 
virtual bool onMouseDown (MouseButton button, float x, float y)
 
virtual bool onMouseUp (MouseButton button, float x, float y)
 
virtual bool onMouseMove (uint32 buttonsState, float x, float y)
 
virtual void onGotFocus ()
 
virtual void onLostFocus ()
 
void setMinimumSize (float width, float height)
 
void setMaximumSize (float width, float height)
 
auto getMinimumWidth () const
 
auto getMinimumHeight () const
 
auto getMaximumWidth () const
 
auto getMaximumHeight () const
 
std::shared_ptr< FontgetFont () const
 
void setFont (const std::shared_ptr< Font > &font)
 
float getFontScale () const
 
void setFontScale (float fontScale)
 
auto & getTextColor () const
 
void setTextColor (const float4 &color)
 
void refresh () const
 
void eventCreate ()
 
void eventDestroy ()
 
void eventShow ()
 
void eventResize ()
 
void eventMove ()
 
void eventHide ()
 
bool eventKeyDown (Key)
 
bool eventKeyUp (Key)
 
bool eventMouseDown (MouseButton, float, float)
 
bool eventMouseUp (MouseButton, float, float)
 
bool eventMouseMove (uint32, float, float)
 
void eventGotFocus ()
 
void eventLostFocus ()
 
void draw () const
 
void attach (WindowManager *windowManager)
 
void detach ()
 
WindowManagergetWindowManager () const
 
- Public Member Functions inherited from Object
void connect (const Signal::signal &name, const Signal::Handler &handler)
 
void connect (const Signal::signal &name, const std::function< void ()> &handler)
 
void emit (const Signal::signal &name, void *params=nullptr)
 
virtual std::string toString () const
 
 Object () = default
 
virtual ~Object () = default
 

Member Enumeration Documentation

Which Window borders can be used to resize the Window

Enum ValuesDocumentation
RESIZEABLE_NONE 
RESIZEABLE_LEFT 
RESIZEABLE_RIGHT 
RESIZEABLE_TOP 
RESIZEABLE_BOTTOM 

Constructor & Destructor Documentation

Window ( const Rect rect)

Creates a virtual UI window with a given position & size

Member Function Documentation

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

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

Parameters
child: child widget to add
alignment: placement
resource: resource std::string
overlap: overlap widget on top of other widgets
void attach ( WindowManager windowManager)
void detach ( )
void draw ( ) const
void eventCreate ( )
void eventDestroy ( )
void eventGotFocus ( )
void eventHide ( )
bool eventKeyDown ( Key  )
bool eventKeyUp ( Key  )
void eventLostFocus ( )
bool eventMouseDown ( MouseButton  ,
float  ,
float   
)
bool eventMouseMove ( uint32  ,
float  ,
float   
)
bool eventMouseUp ( MouseButton  ,
float  ,
float   
)
void eventMove ( )
void eventResize ( )
void eventShow ( )
std::shared_ptr<Font> getFont ( ) const

Returns the default font loaded at startup

float getFontScale ( ) const
auto getHeight ( ) const
inline

Returns the height of the client area

auto getMaximumHeight ( ) const
inline

Returns the maximum height of the Window

auto getMaximumWidth ( ) const
inline

Returns the maximum width of the Window

auto getMinimumHeight ( ) const
inline

Returns the minimum height of the Window

auto getMinimumWidth ( ) const
inline

Returns the minimum width of the Window

const auto& getRect ( ) const
inline

Returns the size & position of the widget

auto getResizeableBorders ( ) const
inline

Returns the borders that can be used to resize the Window

std::shared_ptr<Style> getStyle ( ) const

Returns the current style layout or null

auto& getTextColor ( ) const
inline
Widget& getWidget ( ) const

Returns the main widget . This is the widget that covers the entire Window and is the parent of all the widgets in the Window.

auto getWidth ( ) const
inline

Returns the width of the client area

WindowManager& getWindowManager ( ) const
inline
void hide ( )

Hides the Window. The change will be effective at the start of the next frame : it needs to be called before adding the Window to the manager if you want the Window to be hidden at startup

auto isVisible ( ) const
inline

Returns true if Window is currently visible

virtual void onCreate ( )
inlinevirtual

Event called after Window creation (by the Window manager)

virtual void onDestroy ( )
inlinevirtual

Event called after Window destruction (by the Window manager)

virtual void onGotFocus ( )
inlinevirtual

Event called when the Window got the keyboard focus

virtual void onHide ( )
inlinevirtual

Event called when (after) the Window manager need to hide the Window

virtual bool onKeyDown ( Key  key)
inlinevirtual

Event called when a key was pressed

virtual bool onKeyUp ( Key  key)
inlinevirtual

Event called when a key was released

virtual void onLostFocus ( )
inlinevirtual

Event called when the Window lost the keyboard focus

virtual bool onMouseDown ( MouseButton  button,
float  x,
float  y 
)
inlinevirtual

Event called when a mouse button was pressed inside the Window

virtual bool onMouseMove ( uint32  buttonsState,
float  x,
float  y 
)
inlinevirtual

Event called when the mouse is moved above the Window client area

virtual bool onMouseUp ( MouseButton  button,
float  x,
float  y 
)
inlinevirtual

Event called when a mouse button was released inside the Window

virtual void onMove ( )
inlinevirtual

Event called after a position change

virtual void onResize ( )
inlinevirtual

Event called after a size change

virtual void onShow ( )
inlinevirtual

Event called when (before) the Window manager need to show the Window

void refresh ( ) const
void remove ( const std::shared_ptr< Widget > &  child) const
inline

Removes a child widget

void setFocusedWidget ( const std::shared_ptr< Widget > &  widget)

Changes the focus

void setFont ( const std::shared_ptr< Font > &  font)
void setFontScale ( float  fontScale)
void setHeight ( float  height)

Sets the height of the client area

void setMaximumSize ( float  width,
float  height 
)

Sets the maximum size of the Window (default to VECTOR_SCALE)

void setMinimumSize ( float  width,
float  height 
)

Sets the minimum size of the Window (default to {2.0f, 2.0f})

void setPos ( const float2 &  pos)

Sets the position of the Window, bottom-left

void setPos ( float  x,
float  y 
)

Sets the position of the Window, bottom-left

void setRect ( const Rect newRect)

Sets the client area position & size

void setResizeableBorders ( const uint32  borders)
inline

Sets the borders that can be used to resize the Window

void setStyle ( const std::shared_ptr< Style > &  style)

Sets the current style layout. If null, installs a default layout

void setTextColor ( const float4 &  color)
inline
void setTransparency ( float  )

Sets the alpha value for transparency

void setVisible ( bool  isVisible)

Sets the Window visibility. The change will be effective at the start of the next frame

void setWidget ( std::shared_ptr< Widget child = nullptr,
const std::string &  resources = "",
float  padding = 0 
)

Sets the main widget with optional resource std::string. Call SetLayout(nullptr) if no layout have been set previously

Parameters
child: child widget to add
resourcesplacement
padding: new widget padding
void setWidth ( float  width)

Sets the width of the client area

void setX ( float  x)

Sets the X position of the Window, bottom-left

void setY ( float  y)

Sets the Y position of the Window, bottom-left

void show ( )

Shows the Window. The change will be effective at the start of the next frame

Friends And Related Function Documentation

friend class WindowManager
friend