27#include "Components/CComponentSystem.h"
29#include "Camera/CCamera.h"
31#include "GUI/CGUIElement.h"
32#include "GUI/CGUIImage.h"
33#include "GUI/CGUIText.h"
34#include "GUI/CGUISprite.h"
35#include "GUI/CGUIRect.h"
36#include "GUI/CGUIMask.h"
37#include "GUI/CGUILayout.h"
38#include "GUI/CGUIFitSprite.h"
39#include "GUI/CGUIElipse.h"
41#include "Entity/CEntityPrefab.h"
42#include "Entity/CEntityManager.h"
78 class SKYLICHT_API
CCanvas :
public CComponentSystem
134 std::function<void(
CGUIText*)> OnLocalize;
633 std::vector<T*> result;
634 std::queue<CGUIElement*> queueObjs;
644 while (queueObjs.size() != 0)
649 T* type =
dynamic_cast<T*
>(obj);
651 result.push_back(type);
654 queueObjs.push(child);
This is an object class used to set up the camera, including its position, viewing angle,...
Definition CCamera.h:70
CGUIElement * createElement(const core::rectf &r)
Create a GUI element with a specific rectangle as a child of root.
CGUIElement * searchGUI(const char *name)
Find a GUI element by name.
CGUIText * createText(const core::rectf &r, IFont *font)
Create a text element with a rectangle and font as a child of root.
void resetGUIScale()
Reset the GUI scaling to default (no scale).
CGUILayout * createLayout(const core::rectf &r)
Create a layout element with a rectangle.
CGUIFitSprite * createFitSprite(CGUIElement *e, SFrame *frame)
Create a fit sprite element with a parent and frame.
CGUIText * createText(CGUIElement *e, IFont *font)
Create a text element with a parent and font.
bool IsInEditor
True if the canvas is shown in editor mode.
Definition CCanvas.h:125
CGUIElement * getGUIByPath(CGUIElement *search, const char *path)
Find a GUI element by path starting from a specific element.
bool DrawOutline
True to draw outlines for GUI elements.
Definition CCanvas.h:128
bool m_haveScaleGUI
True if GUI scaling is applied.
Definition CCanvas.h:97
CGUIMask * createMask(CGUIElement *e, const core::rectf &r)
Create a mask element with a parent and rectangle.
CEntityPrefab * getEntityManager()
Get the entity manager.
Definition CCanvas.h:187
int getSortDepth()
Get the current sort depth value.
Definition CCanvas.h:206
virtual void initComponent()
Initialize the canvas component.
void render(CCamera *camera)
Render the GUI elements tree using the specified camera.
CGUIElement * getHitTest(CCamera *camera, float x, float y, const core::recti &viewport)
Perform hit-testing to find the GUI element under the given coordinates.
CGUIRect * createRect(CGUIElement *e, const core::rectf &r, const video::SColor &c)
Create a rectangle element with a parent, rectangle, and color.
void updateLocalizedText()
Find all CGUIText* and update localized text, the event OnLocalize must bind to the localize function...
void setRenderWorldTransform(core::matrix4 &w)
Set the world transform matrix for rendering.
Definition CCanvas.h:561
const core::matrix4 & getRenderWorldTransform()
Get the world transform matrix for rendering.
Definition CCanvas.h:552
void setRect(const core::rectf &r)
Set the canvas rectangle.
Definition CCanvas.h:215
CGUIElement * searchGUI(CGUIElement *search, const char *name)
Find a GUI element by name starting from a specific element.
CGUIElement * getRootElement()
Get the root GUI element.
Definition CCanvas.h:264
int m_sortDepth
Sorting depth for rendering.
Definition CCanvas.h:91
CGUIText * createText(CGUIElement *e, const core::rectf &r, IFont *font)
Create a text element with a parent, rectangle and font.
CGUILayout * createLayout(CGUIElement *e, const core::rectf &r)
Create a layout element with a parent and rectangle.
std::vector< IEntitySystem * > m_systems
List of entity systems for GUI logic.
Definition CCanvas.h:115
void setDefaultRect(const core::rectf &r)
Set the default rectangle value.
Definition CCanvas.h:224
void removeAllElements()
Remove all GUI elements from the canvas.
CCamera * getRenderCamera()
Get the camera currently used for rendering.
Definition CCanvas.h:570
virtual void updateComponent()
Update the canvas component.
void updateEntities()
Update internal entity lists and sorting for rendering.
virtual CGUIElement * createNullElement(CGUIElement *parent, const wchar_t *type)
Create a null GUI element by type (Unicode).
CGUISprite * createSprite(CGUIElement *e, SFrame *frame)
Create a sprite element with a parent and frame.
void setSortDepth(int d)
Set the sort depth for rendering.
Definition CCanvas.h:197
virtual CGUIElement * createNullElement(CGUIElement *parent, const char *type)
Create a null GUI element by type (UTF-8).
CGUISprite * createSprite(SFrame *frame)
Create a sprite element with a frame as a child of root.
CGUIElement * m_root
The root GUI element of the canvas.
Definition CCanvas.h:88
CGUISprite * createSprite(const core::rectf &r, SFrame *frame)
Create a sprite element with a rectangle and frame.
CGUIFitSprite * createFitSprite(SFrame *frame)
Create a fit sprite element with a frame as a child of root.
CGUIRect * createRect(const video::SColor &c)
Create a rectangle element with a color as a child of root.
CGUIImage * createImage(CGUIElement *e, const core::rectf &r)
Create an image element with a parent and rectangle.
void applyGUIScale(float widthOrHeight=1.0f)
Apply GUI scaling based on width or height ratio.
CGUIText * createText(IFont *font)
Create a text element with a font as a child of root.
const core::rectf & getDefaultRect()
Get the default rectangle.
Definition CCanvas.h:233
CGUIElipse * createElipse(CGUIElement *e, const core::rectf &r, const video::SColor &c)
Create an elipse element with a parent, rectangle, and color.
CGUIElement * getGUIByPath(const char *path)
Find a GUI element by its path (separated by / or ).
core::rectf m_defaultRect
The default rectangle size of the canvas.
Definition CCanvas.h:85
CGUIFitSprite * createFitSprite(const core::rectf &r, SFrame *frame)
Create a fit sprite element with a rectangle and frame.
void setEnable3DBillboard(bool b)
Enable or disable 3D billboard rendering.
Definition CCanvas.h:273
CFastArray< CEntity * > m_alives
List of alive entities.
Definition CCanvas.h:121
const core::vector3df & getRootScale()
Get the root element's scale vector.
core::matrix4 m_renderWorldTransform
The world transform used for rendering.
Definition CCanvas.h:103
float m_scaleGUI
Scale factor for GUI.
Definition CCanvas.h:94
CGUIImage * createImage()
Create an image element as a child of root.
CGUIElipse * createElipse(const video::SColor &c)
Create an elipse element with a color as a child of root.
CFastArray< CEntity * > m_depth[MAX_ENTITY_DEPTH]
Entities sorted by children depth.
Definition CCanvas.h:118
CGUIMask * m_currentMask
The current mask applied during rendering.
Definition CCanvas.h:109
CGUIElement * createElement(CGUIElement *e, const core::rectf &r)
Create a GUI element with a specific parent and rectangle.
CCamera * m_renderCamera
The camera currently used for rendering.
Definition CCanvas.h:106
virtual void onResize()
Handle canvas resizing (usually called when screen size changes).
CGUILayout * createLayout()
Create a layout element as a child of root.
std::vector< T * > getElementsInChild(bool addThis)
Find all child elements of a certain type.
Definition CCanvas.h:631
core::rectf m_rect
The rectangle representing the canvas size.
Definition CCanvas.h:82
CGUIElement * createElement()
Create a generic GUI element as a child of root.
CGUIRect * createRect(const core::rectf &r, const video::SColor &c)
Create a rectangle element with a rectangle and color.
bool m_is3DBillboard
Enable 3D billboard rendering for the canvas.
Definition CCanvas.h:100
CGUIFitSprite * createFitSprite(CGUIElement *e, const core::rectf &r, SFrame *frame)
Create a fit sprite element with a parent, rectangle and frame.
CGUIMask * createMask(const core::rectf &r)
Create a mask element with a rectangle as a child of root.
CGUISprite * createSprite(CGUIElement *e, const core::rectf &r, SFrame *frame)
Create a sprite element with a parent, rectangle, and frame.
CGUIElipse * createElipse(const core::rectf &r, const video::SColor &c)
Create an elipse element with a rectangle and color.
CGUIElement * getGUIByID(const char *id)
Find a GUI element by its ID.
virtual ~CCanvas()
Destructor. Cleans up GUI elements and systems.
CGUIImage * createImage(const core::rectf &r)
Create an image element with a rectangle as a child of root.
CEntityPrefab * m_entityMgr
Entity manager for managing GUI entities.
Definition CCanvas.h:112
bool is3DBillboardEnabled()
Check if 3D billboard rendering is enabled.
Definition CCanvas.h:282
This object class is created to store data in an array of multiple CEntities.
Definition CEntityPrefab.h:38
Definition CArrayUtils.h:31
This is the base object class from which other GUIs inherit. It's an empty GUI and can contain child ...
Definition CGUIElement.h:51
This is the object class for displaying an ellipse.
Definition CGUIElipse.h:42
This is the object class for displaying a frame image in sprite. But it will scale the image size whi...
Definition CGUIFitSprite.h:49
This is the object class for displaying a texture image.
Definition CGUIImage.h:43
This is the object class that arranges other GUIs horizontally or vertically.
Definition CGUILayout.h:49
This is the object class that represents a masked rectangle, and other GUIs will only display within ...
Definition CGUIMask.h:48
This is the object class for displaying a rectangle.
Definition CGUIRect.h:42
This is the object class for displaying a frame image in sprite.
Definition CGUISprite.h:54
This is the object class for displaying a text.
Definition CGUIText.h:60
Class representing a 32 bit ARGB color.
Definition SColor.h:285
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
rect< s32 > recti
Rectangle with int values.
Definition rect.h:273
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2241
rect< f32 > rectf
Rectangle with float values.
Definition rect.h:271
Definition CSpriteFrame.h:93