-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGRoot.h
101 lines (79 loc) · 2.69 KB
/
GRoot.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef __GROOT_H__
#define __GROOT_H__
#include "FairyGUIMacros.h"
#include "GComponent.h"
#include "GGraph.h"
#include "Window.h"
#include "cocos2d.h"
#include "event/InputProcessor.h"
NS_FGUI_BEGIN
class WeakPtr;
class GRoot : public GComponent
{
public:
GRoot();
virtual ~GRoot();
static GRoot* create(cocos2d::Scene* scene, int zOrder = 1000);
static GRoot* getInstance() { return _inst; }
void showWindow(Window* win);
void hideWindow(Window* win);
void hideWindowImmediately(Window* win);
void bringToFront(Window* win);
void showModalWait();
void closeModalWait();
void closeAllExceptModals();
void closeAllWindows();
Window* getTopWindow();
GObject* getModalWaitingPane();
GGraph* getModalLayer();
bool hasModalWindow();
bool isModalWaiting();
InputProcessor* getInputProcessor() const { return _inputProcessor; }
cocos2d::Vec2 getTouchPosition(int touchId);
GObject* getTouchTarget();
cocos2d::Vec2 worldToRoot(const cocos2d::Vec2 &pt);
cocos2d::Vec2 rootToWorld(const cocos2d::Vec2 &pt);
void showPopup(GObject* popup);
void showPopup(GObject* popup, GObject* target, PopupDirection dir);
void togglePopup(GObject* popup);
void togglePopup(GObject* popup, GObject* target, PopupDirection dir);
void hidePopup();
void hidePopup(GObject* popup);
bool hasAnyPopup();
cocos2d::Vec2 getPoupPosition(GObject* popup, GObject* target, PopupDirection dir);
void showTooltips(const std::string& msg);
void showTooltipsWin(GObject* tooltipWin);
void hideTooltips();
void playSound(const std::string& url, float volumeScale = 1);
bool isSoundEnabled() const { return _soundEnabled; }
void setSoundEnabled(bool value);
float getSoundVolumeScale() const { return _soundVolumeScale; }
void setSoundVolumeScale(float value);
static int contentScaleLevel;
protected:
virtual void handlePositionChanged() override;
virtual void onEnter() override;
virtual void onExit() override;
private:
bool initWithScene(cocos2d::Scene* scene, int zOrder);
void onWindowSizeChanged();
void createModalLayer();
void adjustModalLayer();
void closePopup(GObject* target);
void checkPopups();
void onTouchEvent(int eventType);
void updateContentScaleLevel();
CALL_LATER_FUNC(GRoot, doShowTooltipsWin);
InputProcessor* _inputProcessor;
GGraph* _modalLayer;
GObject* _modalWaitPane;
std::vector<WeakPtr> _popupStack;
std::vector<WeakPtr> _justClosedPopups;
GObject* _tooltipWin;
GObject* _defaultTooltipWin;
static bool _soundEnabled;
static float _soundVolumeScale;
static GRoot* _inst;
};
NS_FGUI_END
#endif