You.i Engine
YiApp.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2017. All rights reserved.
2 #ifndef _YI_APP_H_
3 #define _YI_APP_H_
4 
5 #include "framework/YiPredef.h"
6 #include "renderer/YiSurface.h"
7 #include "event/YiEvent.h"
8 #include "signal/YiSignal.h"
9 #include "view/YiViewProperty.h"
10 
11 class CYIAppPriv;
12 class CYIBindingContext;
13 class CYIColor;
14 class CYIDevPanel;
15 class CYIEventHandler;
16 class CYIEvent;
17 class CYIFramework;
18 class CYIKeyEvent;
19 class CYIRenderSystem;
20 class CYISceneManager;
21 class CYIScreen;
23 
28 
43 class CYIApp
44 {
45 public:
46  friend class CYIFPSWidget;
47 
48  CYIApp();
49  virtual ~CYIApp();
50 
52  {
56  };
57 
63  bool Init();
64 
69  bool IsInitialized() const;
70 
73 
76 
79 
80  bool SetScreenProperties(int screenSizeX, int screenSizeY, int screenDensityX, int screenDensityY);
81  bool SetSurface(CYISurface *pSurface);
88  void SurfaceWasResized(int32_t nWidth, int32_t nHeight);
89 
96 
100  void HandleKeyInputs(const CYIKeyEvent & keyEvent);
101 
114  void HandleActionInputs(int32_t nX, int32_t nY, YI_EVENT_TYPE eEventType, uint8_t uPointerID = 0, bool bHover = false);
115 
119  void HandleActionInputs(int32_t nX, int32_t nY, int32_t nWheelDelta, uint8_t uButton, YI_EVENT_TYPE eEventType, uint8_t uPointerID = 0, bool bHover = false);
120 
124  virtual void HandleLowMemory(MEMORY_LEVEL eMemoryLevel);
125 
130  bool LoadFont(const CYIString &URI, ssize_t *pnFontID, bool bLocal = false);
131 
137  bool LoadFont(const uint8_t *pFontData, uint32_t nDataSize, ssize_t *pnFontID);
138 
143 
148 
154 
159  bool PostEvent(std::unique_ptr<CYIEvent> pEvent, YI_EVENT_PRIORITY priority = YI_EVENT_PRIORITY_DEFAULT, bool bBump = false);
160 
164  bool PostEvent(std::unique_ptr<CYIEvent> pEvent, CYIEventHandler *pDestination, YI_EVENT_PRIORITY priority = YI_EVENT_PRIORITY_DEFAULT, bool bBump = false);
165 
169  bool SendEvent(std::unique_ptr<CYIEvent> pEvent);
170 
174  bool SendEvent(std::unique_ptr<CYIEvent> pEvent, CYIEventHandler *pDestination);
175 
183  bool Update(bool bForceDirty = false, bool bUpdateTime = true);
184 
189  virtual void Draw();
190 
197  virtual void OnPreDraw() {}
198 
205  virtual void OnPostDraw() {}
206 
210  virtual void Swap();
211 
215  void SetShowFPS(bool bShow);
216 
220  bool GetShowFPS() const;
221 
227  CYIDevPanel *GetDevPanel() const;
228 
232  void InitializeDevPanel();
233 
237  void DestroyDevPanel();
238 
242  void SetAssetsPath(const CYIString &assetsPath);
243 
247  const CYIString& GetAssetsPath() const;
248 
252  void SetCachePath(const CYIString &cachePath);
253 
257  const CYIString &GetCachePath() const;
258 
263  void SetDataPath(const CYIString &dataPath);
264 
268  const CYIString& GetDataPath() const;
269 
274  void SetExternalPath(const CYIString &externalPath);
275 
281  const CYIString &GetExternalPath() const;
282 
286  void SetVersion(const CYIString &version);
287 
291  const CYIString& GetVersion() const;
292 
296  void SetMultiTouchEnabled(bool bEnabled);
297 
301  bool IsMultiTouchEnabled() const;
302 
306  void SetBindingContext(std::unique_ptr<CYIBindingContext> pBindingContext);
307 
312 
318  void SetBackgroundColor(const CYIColor &color);
319 
325  const CYIColor &GetBackgroundColor();
326 
327  CYISignal<int32_t /* width */, int32_t /* height */> SurfaceSizeChanged;
328 
329 protected:
330  CYIApp(CYIAppPriv *pPriv);
331 
335  virtual bool UserInit() = 0;
336 
341  virtual bool UserStart() = 0;
342 
347  virtual void UserUpdate() {}
348 
361  virtual void OnSurfaceSizeChanged(int32_t nWidth, int32_t nHeight);
362 
363 protected:
364  friend class CYIAppPriv;
366 
367 private:
369 };
370 
373 #endif // _YI_APP_H_
void SetDefaultStatusBarVisibility(YIViewProperty::StatusBar statusbar)
MEMORY_LEVEL
Definition: YiApp.h:51
Definition: YiApp.h:55
#define YI_DISALLOW_COPY_AND_ASSIGN(TypeName)
Delete the copy constructor and assignment operator (and consequently the move constructor as well) ...
Definition: YiPredef.h:114
void SetDataPath(const CYIString &dataPath)
void HandleKeyInputs(const CYIKeyEvent &keyEvent)
Definition: YiApp.h:53
Definition: YiApp.h:54
Class for key events.
Definition: YiKeyEvent.h:15
YIViewProperty::Orientation GetDefaultOrientation() const
Allows registering of event filters which can be used to perform processing on an event before and af...
Definition: YiEventHandler.h:25
Scene trees composed of CYISceneNode objects are registered with the scene manager in order for them ...
Definition: YiSceneManager.h:73
YIViewProperty::StatusBar GetDefaultStatusBarVisibility() const
const CYIString & GetDataPath() const
Base class for events.
Definition: YiEvent.h:489
bool GetShowFPS() const
Container class for Unicode strings. Conceptually, a CYIString object is a sequence of Unicode charac...
Definition: YiString.h:35
Definition: YiScreen.h:25
CYIAppPriv * m_pPriv
Definition: YiApp.h:365
bool IsMultiTouchEnabled() const
YI_EVENT_TYPE
The event type of the CYIEvent class instance.
Definition: YiEvent.h:23
Definition: YiEvent.h:481
void SetBindingContext(std::unique_ptr< CYIBindingContext > pBindingContext)
bool SendEvent(std::unique_ptr< CYIEvent > pEvent)
virtual bool UserStart()=0
void SetCachePath(const CYIString &cachePath)
virtual void Draw()
StatusBar
Definition: YiViewProperty.h:23
virtual void OnPreDraw()
Definition: YiApp.h:197
bool SetSurface(CYISurface *pSurface)
void SetDefaultNavigationBarVisibility(YIViewProperty::NavigationBar navigationBar)
virtual void Swap()
YI_EVENT_PRIORITY
Priority of the event in the event queue.
Definition: YiEvent.h:473
bool IsInitialized() const
NavigationBar
Definition: YiViewProperty.h:29
bool SetScreenProperties(int screenSizeX, int screenSizeY, int screenDensityX, int screenDensityY)
CYIFrameworkConfiguration is used to specify configuration settings for the CYIFramework class...
Definition: YiFrameworkConfiguration.h:17
const CYIColor & GetBackgroundColor()
void HandleActionInputs(int32_t nX, int32_t nY, YI_EVENT_TYPE eEventType, uint8_t uPointerID=0, bool bHover=false)
bool Update(bool bForceDirty=false, bool bUpdateTime=true)
CYIRenderSystem is a singleton class used to acquire global instances of a number of classes...
Definition: YiRenderSystem.h:28
virtual void OnSurfaceSizeChanged(int32_t nWidth, int32_t nHeight)
virtual bool UserInit()=0
const CYIString & GetExternalPath() const
The entry point for executing script source code in You.i Engine.
Definition: YiBindingContext.h:29
void SetBackgroundColor(const CYIColor &color)
void SetDefaultOrientation(YIViewProperty::Orientation orientation)
YIViewProperty::NavigationBar GetDefaultNavigationBarVisibility() const
void SetShowFPS(bool bShow)
void SetAssetsPath(const CYIString &assetsPath)
void SetExternalPath(const CYIString &externalPath)
CYIRenderSystem * GetMainRenderSystem()
const CYIString & GetVersion() const
Definition: YiSurface.h:28
void InitializeDevPanel()
CYIFramework * GetMainFramework()
bool LoadFont(const CYIString &URI, ssize_t *pnFontID, bool bLocal=false)
int ssize_t
Definition: YiPredefWin32.h:133
const CYIString & GetAssetsPath() const
virtual void OnPostDraw()
Definition: YiApp.h:205
void SetMultiTouchEnabled(bool bEnabled)
CYIDevPanel * GetDevPanel() const
friend class CYIAppPriv
Definition: YiApp.h:364
void SetVersion(const CYIString &version)
bool PostEvent(std::unique_ptr< CYIEvent > pEvent, YI_EVENT_PRIORITY priority=YI_EVENT_PRIORITY_DEFAULT, bool bBump=false)
A class used to represent a color value.
Definition: YiColor.h:31
bool Init()
CYISceneManager * GetSceneManager() const
A class used to manipulate developer utilities.
Definition: YiDevPanel.h:52
CYIFramework is a singleton class used to acquire global instances of a number of classes...
Definition: YiFramework.h:32
Signals and slots are a thread-safe and flexible communication framework that will allow various obje...
Definition: YiSignal.h:164
virtual ~CYIApp()
virtual CYIFrameworkConfiguration UserConfiguration()
Orientation
Definition: YiViewProperty.h:12
virtual void HandleLowMemory(MEMORY_LEVEL eMemoryLevel)
virtual void UserUpdate()
Definition: YiApp.h:347
The base class for all applications.
Definition: YiApp.h:43
CYISignal< int32_t, int32_t > SurfaceSizeChanged
Definition: YiApp.h:327
const CYIString & GetCachePath() const
void SurfaceWasResized(int32_t nWidth, int32_t nHeight)
CYIBindingContext * GetBindingContext()
void DestroyDevPanel()
friend class CYIFPSWidget
Definition: YiApp.h:46