-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGComponent.h
150 lines (115 loc) · 4.77 KB
/
GComponent.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#ifndef __GCOMPONENT_H__
#define __GCOMPONENT_H__
#include "FairyGUIMacros.h"
#include "GObject.h"
#include "Margin.h"
#include "ScrollPane.h"
#include "Transition.h"
#include "cocos2d.h"
#include "display/FUIContainer.h"
#include "event/HitTest.h"
NS_FGUI_BEGIN
class GComponent : public GObject
{
public:
GComponent();
virtual ~GComponent();
CREATE_FUNC(GComponent);
GObject* addChild(GObject* child);
virtual GObject* addChildAt(GObject* child, int index);
void removeChild(GObject* child);
virtual void removeChildAt(int index);
void removeChildren() { removeChildren(0, -1); }
void removeChildren(int beginIndex, int endIndex);
GObject* getChildAt(int index) const;
GObject* getChild(const std::string& name) const;
GObject* getChildByPath(const std::string& path) const;
GObject* getChildInGroup(const GGroup* group, const std::string& name) const;
GObject* getChildById(const std::string& id) const;
const cocos2d::Vector<GObject*>& getChildren() const { return _children; }
int getChildIndex(const GObject* child) const;
void setChildIndex(GObject* child, int index);
int setChildIndexBefore(GObject* child, int index);
void swapChildren(GObject* child1, GObject* child2);
void swapChildrenAt(int index1, int index2);
int numChildren() const;
bool isAncestorOf(const GObject* obj) const;
virtual bool isChildInView(GObject* child);
virtual int getFirstChildInView();
void addController(GController* c);
GController* getControllerAt(int index) const;
GController* getController(const std::string& name) const;
const cocos2d::Vector<GController*>& getControllers() const { return _controllers; }
void removeController(GController* c);
void applyController(GController* c);
void applyAllControllers();
Transition* getTransition(const std::string& name) const;
Transition* getTransitionAt(int index) const;
const cocos2d::Vector<Transition*>& getTransitions() const { return _transitions; }
bool getOpaque() const { return _opaque; }
void setOpaque(bool value);
const Margin& getMargin() { return _margin; }
void setMargin(const Margin& value);
ChildrenRenderOrder getChildrenRenderOrder() const { return _childrenRenderOrder; }
void setChildrenRenderOrder(ChildrenRenderOrder value);
int getApexIndex() const { return _apexIndex; }
void setApexIndex(int value);
cocos2d::Node* getMask() const;
void setMask(cocos2d::Node* value, bool inverted = false);
IHitTest* getHitArea() const { return _hitArea; }
void setHitArea(IHitTest* value);
ScrollPane* getScrollPane() const { return _scrollPane; }
float getViewWidth() const;
void setViewWidth(float value);
float getViewHeight() const;
void setViewHeight(float value);
void setBoundsChangedFlag();
void ensureBoundsCorrect();
virtual GObject* hitTest(const cocos2d::Vec2& worldPoint, const cocos2d::Camera* camera) override;
virtual cocos2d::Vec2 getSnappingPosition(const cocos2d::Vec2& pt);
//internal use
void childSortingOrderChanged(GObject* child, int oldValue, int newValue);
void childStateChanged(GObject* child);
void adjustRadioGroupDepth(GObject* obj, GController* c);
virtual void constructFromResource() override;
void constructFromResource(std::vector<GObject*>* objectPool, int poolIndex);
bool _buildingDisplayList;
protected:
virtual void constructExtension(ByteBuffer* buffer);
virtual void onConstruct();
virtual void setup_afterAdd(ByteBuffer* buffer, int beginPos) override;
virtual void handleInit() override;
virtual void handleSizeChanged() override;
virtual void handleGrayedChanged() override;
virtual void handleControllerChanged(GController* c) override;
virtual void onEnter() override;
virtual void onExit() override;
virtual void updateBounds();
void setBounds(float ax, float ay, float aw, float ah);
void setupOverflow(OverflowType overflow);
void setupScroll(ByteBuffer* buffer);
cocos2d::Vector<GObject*> _children;
cocos2d::Vector<GController*> _controllers;
cocos2d::Vector<Transition*> _transitions;
FUIInnerContainer* _container;
ScrollPane* _scrollPane;
Margin _margin;
cocos2d::Vec2 _alignOffset;
ChildrenRenderOrder _childrenRenderOrder;
int _apexIndex;
bool _boundsChanged;
bool _trackBounds;
GObject* _maskOwner;
IHitTest* _hitArea;
private:
int getInsertPosForSortingChild(GObject* target);
int moveChild(GObject* child, int oldIndex, int index);
CALL_LATER_FUNC(GComponent, doUpdateBounds);
CALL_LATER_FUNC(GComponent, buildNativeDisplayList);
bool _opaque;
int _sortingChildCount;
GController* _applyingController;
friend class ScrollPane;
};
NS_FGUI_END
#endif