Skylicht Engine
Loading...
Searching...
No Matches
CGUIImporter.h
1/*
2!@
3MIT License
4
5Copyright (c) 2019 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#pragma once
26
27#include "CCanvas.h"
28
29namespace Skylicht
30{
49 class SKYLICHT_API CGUIImporter
50 {
51 public:
60 static bool loadGUI(const char* file, CCanvas* canvas);
61
68 static bool beginImport(const char* file, CCanvas* canvas);
69
74 static bool updateLoadGUI();
75
80 static float getLoadingPercent();
81
88 static CObjectSerializable* loadGUIToSerializable(const char* file, CCanvas* canvas);
89
96
105 static CGUIElement* importGUI(CCanvas* canvas, CGUIElement* target, CObjectSerializable* obj, bool generateNewId = false);
106
114
119 static void reset(CCanvas* canvas);
120
121 protected:
128 static bool loadStep(CCanvas* canvas, io::IXMLReader* reader);
129
135 static void buildCanvas(CCanvas* canvas, io::IXMLReader* reader);
136
144 static bool loadObjStep(CObjectSerializable* obj, CCanvas* canvas, io::IXMLReader* reader);
145
153 static bool loadObjChilds(CObjectSerializable* obj, CCanvas* canvas, io::IXMLReader* reader);
154
155 static CGUIElement* createElementByType(const wchar_t* type, CCanvas* canvas, CGUIElement* parent);
156 };
157}
This class manages GUI components, including creating and deleting images and sprites.
Definition CCanvas.h:79
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 object class helps initialize GUI components for the CCanvas from files and data....
Definition CGUIImporter.h:50
static void reset(CCanvas *canvas)
Reset the canvas to default state after import (position, size, background color).
static void buildCanvas(CCanvas *canvas, io::IXMLReader *reader)
Build the initial canvas structure from XML reader.
static bool loadObjStep(CObjectSerializable *obj, CCanvas *canvas, io::IXMLReader *reader)
Internal loading step for a serializable object from XML reader.
static bool loadStep(CCanvas *canvas, io::IXMLReader *reader)
Internal loading step for canvas from XML reader.
static void loadGUIFromSerializable(CObjectSerializable *gui, CCanvas *canvas)
Initialize a canvas from a serializable GUI object.
static bool updateLoadGUI()
Perform one step in the GUI loading process. Used for asynchronous or progressive loading.
static float getLoadingPercent()
Get percent progress of the GUI loading process.
static CObjectSerializable * loadGUIToSerializable(const char *file, CCanvas *canvas)
Load a GUI layout from file into a serializable object structure.
static bool beginImport(const char *file, CCanvas *canvas)
Begin importing a GUI layout from file. Initializes structures for step-based loading.
static CObjectSerializable * getSerializableByPath(CObjectSerializable *obj, const char *path)
Find a serializable GUI object by its path in the hierarchy.
static CGUIElement * importGUI(CCanvas *canvas, CGUIElement *target, CObjectSerializable *obj, bool generateNewId=false)
Import a GUI element tree from a serializable object into the canvas.
static bool loadObjChilds(CObjectSerializable *obj, CCanvas *canvas, io::IXMLReader *reader)
Load all children for a serializable object from XML reader.
Definition CObjectSerializable.h:36
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
The gui namespace contains useful classes for easy creation of a graphical user interface.
Definition ICursorControl.h:15
IIrrXMLReader< wchar_t, IReferenceCounted > IXMLReader
An xml reader for wide characters, derived from IReferenceCounted.
Definition IXMLReader.h:19