You.i Engine
YiViewTemplate.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_VIEW_TEMPLATE_H_
3 #define _YI_VIEW_TEMPLATE_H_
4 
6 #include "animation/YiTimeline.h"
8 #include "framework/YiPredef.h"
11 #include "utility/YiString.h"
12 
14 class CYIColor;
15 class CYISceneView;
16 
30 {
31  friend class CYISceneView;
32 
33 public:
37  class Source
38  {
39  public:
43  enum class Type
44  {
45  Composition = 0,
46  Image,
47  Solid,
48  Null,
49  NPatch,
50  Mask,
51  None,
52  Sprite,
53  Adjustment,
54  Font
55  };
56 
57  Source();
58 
59  const CYIString &GetName() const;
60  void SetName(const CYIString &name);
61  Type GetSourceType() const;
62  void SetSourceType(Type sourceType);
63 
64  private:
65  CYIString m_name;
66  Type m_sourceType;
67  };
68 
69  virtual ~CYIViewTemplate() {}
70 
78  static std::shared_ptr<CYIAssetViewTemplate> GetViewTemplate(const CYIString &viewTemplateName);
79 
89  static glm::vec2 GetViewTemplateSize(const CYIString &viewTemplateName);
90 
106  std::unique_ptr<CYISceneView> BuildView(CYISceneManager *pSceneManager, const std::shared_ptr<CYIAssetViewTemplate> &pAssetViewTemplate);
107 
113  virtual void SetTimelineSource(std::shared_ptr<CYIAssetTimelineSource> pTimelineSource) = 0;
114 
120  virtual std::shared_ptr<CYIAssetTimelineSource> GetTimelineSource() = 0;
121 
125  virtual std::unique_ptr<CYITimeline> BuildTimeline(CYISceneNode *pRootNode) = 0;
126 
134  virtual std::unique_ptr<CYITimeline> BuildTimeline(CYISceneNode *pRootNode, const CYIString &markerName) = 0;
135 
143  virtual std::unique_ptr<CYITimeline> BuildTimeline(CYISceneNode *pRootNode, CYIMarkerData::ID id) = 0;
144 
150  virtual std::unique_ptr<CYITimeline> BuildTimeline(CYISceneNode *pRootNode, int32_t startOffset, int32_t duration) = 0;
151 
157  virtual void GetSize(float &width, float &height) = 0;
158 
164  virtual float GetHeight() = 0;
165 
171  virtual float GetWidth() = 0;
172 
176  virtual float GetDefaultCameraDistance();
177 
181  virtual CYIString GetName() const = 0;
182 
186  virtual const CYIString &GetViewClassName() const = 0;
187 
191  virtual bool GetBackgroundColor(CYIColor *pColor) = 0;
192 
198  virtual const std::vector<CYIString> &GetChildTemplateNames() = 0;
199 
203  virtual size_t GetApproximateSize() const = 0;
204 
208  virtual std::vector<Source> GetSources() const = 0;
209 
210 protected:
212 
213 private:
214  virtual bool BuildTree(CYISceneNode *pRootNode, const CYIString &path, CYISceneManager::MissingClassHandlingMode missingHandlingMode = CYISceneManager::MissingClassHandlingMode::Abort) = 0;
215 
217 };
218 
221 #endif // _YI_VIEW_TEMPLATE_H_
const CYIString & GetName() const
Represents a source that has no type.
virtual const std::vector< CYIString > & GetChildTemplateNames()=0
static std::shared_ptr< CYIAssetViewTemplate > GetViewTemplate(const CYIString &viewTemplateName)
Scene trees composed of CYISceneNode objects are registered with the scene manager in order for them ...
Definition: YiSceneManager.h:75
virtual std::shared_ptr< CYIAssetTimelineSource > GetTimelineSource()=0
Represents a composition source.
The base class for all view types. Views are containers of renderable elements that often define inte...
Definition: YiSceneView.h:47
Container class for Unicode strings. Conceptually, a CYIString object is a sequence of Unicode charac...
Definition: YiString.h:36
Represents a solid source.
ID
Definition: YiMarkerData.h:35
Represents an image 9-patch source.
Type
Definition: YiViewTemplate.h:43
virtual std::unique_ptr< CYITimeline > BuildTimeline(CYISceneNode *pRootNode)=0
Defines information about the sources a view template may have.
Definition: YiViewTemplate.h:37
virtual ~CYIViewTemplate()
Definition: YiViewTemplate.h:69
Represents a sprite source.
void SetSourceType(Type sourceType)
static glm::vec2 GetViewTemplateSize(const CYIString &viewTemplateName)
virtual void GetSize(float &width, float &height)=0
virtual float GetWidth()=0
Represents a font source.
MissingClassHandlingMode
Optional fallback rules for missing view types during scene loading.
Definition: YiSceneManager.h:138
virtual float GetHeight()=0
A view template defines information about a view, so it can be built automatically.
Definition: YiViewTemplate.h:29
A scene node is the base type for all nodes which are used by the scene manager; it is an integral pa...
Definition: YiSceneNode.h:99
ViewTemplate asset. Wrapper around a CYIViewTemplate.
Definition: YiAssetViewTemplate.h:21
CYIViewTemplate()
Definition: YiViewTemplate.h:211
virtual std::vector< Source > GetSources() const =0
Represents an adjustment layer source.
Represents a mask source.
virtual const CYIString & GetViewClassName() const =0
Represents an image source.
An interface to a class that provides key-value properties.
Definition: YiPropertiesSource.h:21
virtual size_t GetApproximateSize() const =0
Represents a null source.
virtual void SetTimelineSource(std::shared_ptr< CYIAssetTimelineSource > pTimelineSource)=0
std::unique_ptr< CYISceneView > BuildView(CYISceneManager *pSceneManager, const std::shared_ptr< CYIAssetViewTemplate > &pAssetViewTemplate)
#define YI_TYPE_BASES(CLASS, BASES...)
Definition: YiRtti.h:257
A class used to represent a color value.
Definition: YiColor.h:31
virtual float GetDefaultCameraDistance()
virtual bool GetBackgroundColor(CYIColor *pColor)=0
void SetName(const CYIString &name)
Type GetSourceType() const