#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 ax::Vector& 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 ax::Vector& 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 ax::Vector& 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); ax::Node* getMask() const; void setMask(ax::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 ax::Vec2& worldPoint, const ax::Camera* camera) override; virtual ax::Vec2 getSnappingPosition(const ax::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* 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); ax::Vector _children; ax::Vector _controllers; ax::Vector _transitions; FUIInnerContainer* _container; ScrollPane* _scrollPane; Margin _margin; ax::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