Merge pull request #4701 from nutty898/develop_nutty_modify_framework_bugfixed

Develop nutty modify framework bugfixed
This commit is contained in:
minggo 2013-12-27 01:48:21 -08:00
commit 71f7fecd5e
9 changed files with 70 additions and 30 deletions

View File

@ -590,7 +590,7 @@ public:
*
* @return a Node object whose tag equals to the input parameter
*/
Node * getChildByTag(int tag);
virtual Node * getChildByTag(int tag);
/**
* Return an array of children
*
@ -615,7 +615,7 @@ public:
*
* @return The amount of children.
*/
ssize_t getChildrenCount() const;
virtual ssize_t getChildrenCount() const;
/**
* Sets the parent node

View File

@ -298,6 +298,12 @@ void ListView::removeLastItem()
{
removeItem(_items.size() -1);
}
void ListView::removeAllItems()
{
_items.clear();
removeAllChildren();
}
Widget* ListView::getItem(unsigned int index)
{
@ -434,7 +440,7 @@ void ListView::onSizeChanged()
std::string ListView::getDescription() const
{
return "ListViewEx";
return "ListView";
}
Widget* ListView::createCloneInstance()
@ -444,7 +450,7 @@ Widget* ListView::createCloneInstance()
void ListView::copyClonedWidgetChildren(Widget* model)
{
auto& arrayItems = getItems();
auto& arrayItems = static_cast<ListView*>(model)->getItems();
for (auto& item : arrayItems)
{
pushBackCustomItem(item->clone());

View File

@ -112,6 +112,8 @@ public:
*/
void removeItem(int index);
void removeAllItems();
/**
* Returns a item whose index is same as the parameter.
*
@ -173,9 +175,13 @@ protected:
virtual void addChild(Node* child, int zOrder, int tag) override{ScrollView::addChild(child, zOrder, tag);};
virtual void removeChild(Node* widget, bool cleanup = true) override{ScrollView::removeChild(widget, cleanup);};
virtual void removeAllChildren() override{ScrollView::removeAllChildren();};
virtual void removeAllChildren() override{removeAllChildrenWithCleanup(true);};
virtual void removeAllChildrenWithCleanup(bool cleanup) override {ScrollView::removeAllChildrenWithCleanup(cleanup);};
virtual Vector<Node*>& getChildren() override{return ScrollView::getChildren();};
virtual const Vector<Node*>& getChildren() const override{return ScrollView::getChildren();};
virtual ssize_t getChildrenCount() const override {return ScrollView::getChildrenCount();};
virtual Node * getChildByTag(int tag) override {return ScrollView::getChildByTag(tag);};
virtual Widget* getChildByName(const char* name) override {return ScrollView::getChildByName(name);};
virtual bool init() override;
void updateInnerContainerSize();
void remedyLayoutParameter(Widget* item);

View File

@ -295,9 +295,14 @@ void PageView::updateChildrenPosition()
}
void PageView::removeAllChildren()
{
removeAllChildrenWithCleanup(true);
}
void PageView::removeAllChildrenWithCleanup(bool cleanup)
{
_pages.clear();
Layout::removeAllChildren();
Layout::removeAllChildrenWithCleanup(cleanup);
}
void PageView::scrollToPage(int idx)
@ -602,7 +607,7 @@ Widget* PageView::createCloneInstance()
void PageView::copyClonedWidgetChildren(Widget* model)
{
auto& modelPages = dynamic_cast<PageView*>(model)->getPages();
auto& modelPages = static_cast<PageView*>(model)->getPages();
for (auto& page : modelPages)
{
addPage(dynamic_cast<Layout*>(page->clone()));

View File

@ -158,15 +158,19 @@ public:
* Returns the "class name" of widget.
*/
virtual std::string getDescription() const override;
protected:
virtual void addChild(Node * child) override;
virtual void addChild(Node * child, int zOrder) override;
virtual void addChild(Node* child, int zOrder, int tag) override;
virtual void removeChild(Node* widget, bool cleanup = true) override;
virtual void removeAllChildren() override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual Vector<Node*>& getChildren() override{return Widget::getChildren();};
virtual const Vector<Node*>& getChildren() const override{return Widget::getChildren();};
virtual ssize_t getChildrenCount() const override {return Widget::getChildrenCount();};
virtual Node * getChildByTag(int tag) override {return Widget::getChildByTag(tag);};
virtual Widget* getChildByName(const char* name) override {return Widget::getChildByName(name);};
virtual bool init() override;
Layout* createPage();
float getPositionXByIndex(int idx);

View File

@ -231,7 +231,12 @@ void ScrollView::addChild(Node *child, int zOrder, int tag)
void ScrollView::removeAllChildren()
{
_innerContainer->removeAllChildren();
removeAllChildrenWithCleanup(true);
}
void ScrollView::removeAllChildrenWithCleanup(bool cleanup)
{
_innerContainer->removeAllChildrenWithCleanup(cleanup);
}
void ScrollView::removeChild(Node* child, bool cleanup)
@ -249,6 +254,21 @@ const Vector<Node*>& ScrollView::getChildren() const
return _innerContainer->getChildren();
}
ssize_t ScrollView::getChildrenCount() const
{
return _innerContainer->getChildrenCount();
}
Node* ScrollView::getChildByTag(int tag)
{
return _innerContainer->getChildByTag(tag);
}
Widget* ScrollView::getChildByName(const char *name)
{
return _innerContainer->getChildByName(name);
}
void ScrollView::moveChildren(float offsetX, float offsetY)
{
_moveChildPoint = _innerContainer->getPosition() + Point(offsetX, offsetY);

View File

@ -259,6 +259,8 @@ public:
//override "removeAllChildrenAndCleanUp" method of widget.
virtual void removeAllChildren() override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
//override "removeChild" method of widget.
virtual void removeChild(Node* child, bool cleaup = true) override;
@ -266,6 +268,12 @@ public:
virtual Vector<Node*>& getChildren() override;
virtual const Vector<Node*>& getChildren() const override;
virtual ssize_t getChildrenCount() const override;
virtual Node * getChildByTag(int tag) override;
virtual Widget* getChildByName(const char* name) override;
virtual bool onTouchBegan(Touch *touch, Event *unusedEvent) override;
virtual void onTouchMoved(Touch *touch, Event *unusedEvent) override;
virtual void onTouchEnded(Touch *touch, Event *unusedEvent) override;

View File

@ -165,7 +165,7 @@ const Vector<Node*>& Widget::getChildren() const
return _widgetChildren;
}
long Widget::getChildrenCount() const
ssize_t Widget::getChildrenCount() const
{
return _widgetChildren.size();
}

View File

@ -232,7 +232,7 @@ public:
*
* @return a Node object whose tag equals to the input parameter
*/
Node * getChildByTag(int tag);
virtual Node * getChildByTag(int tag) override;
virtual void sortAllChildren() override;
/**
@ -259,14 +259,14 @@ public:
*
* @return The amount of children.
*/
long getChildrenCount() const;
virtual ssize_t getChildrenCount() const override;
/**
* Removes this node itself from its parent node with a cleanup.
* If the node orphan, then nothing happens.
* @see `removeFromParentAndCleanup(bool)`
*/
virtual void removeFromParent();
virtual void removeFromParent() override;
/**
* Removes this node itself from its parent node.
* If the node orphan, then nothing happens.
@ -274,7 +274,7 @@ public:
* @js removeFromParent
* @lua removeFromParent
*/
virtual void removeFromParentAndCleanup(bool cleanup);
virtual void removeFromParentAndCleanup(bool cleanup) override;
/**
* Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter.
@ -282,7 +282,7 @@ public:
* @param child The child node which will be removed.
* @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
*/
virtual void removeChild(Node* child, bool cleanup = true);
virtual void removeChild(Node* child, bool cleanup = true) override;
/**
* Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter
@ -290,13 +290,13 @@ public:
* @param tag An interger number that identifies a child node
* @param cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
*/
virtual void removeChildByTag(int tag, bool cleanup = true);
virtual void removeChildByTag(int tag, bool cleanup = true) override;
/**
* Removes all children from the container with a cleanup.
*
* @see `removeAllChildrenWithCleanup(bool)`
*/
virtual void removeAllChildren();
virtual void removeAllChildren() override;
/**
* Removes all children from the container, and do a cleanup to all running actions depending on the cleanup parameter.
*
@ -304,7 +304,7 @@ public:
* @js removeAllChildren
* @lua removeAllChildren
*/
virtual void removeAllChildrenWithCleanup(bool cleanup);
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
/**
* Gets a child from the container with its name
@ -313,7 +313,7 @@ public:
*
* @return a Widget object whose name equals to the input parameter
*/
Widget* getChildByName(const char* name);
virtual Widget* getChildByName(const char* name);
virtual void visit();
@ -663,36 +663,27 @@ protected:
bool _focus; ///< is the widget on focus
BrightStyle _brightStyle; ///< bright style
bool _updateEnabled; ///< is "update" method scheduled
// Node* _renderer; ///< base renderer
Point _touchStartPos; ///< touch began point
Point _touchMovePos; ///< touch moved point
Point _touchEndPos; ///< touch ended point
Object* _touchEventListener;
SEL_TouchEvent _touchEventSelector;
std::string _name;
WidgetType _widgetType;
int _actionTag;
Size _size;
Size _customSize;
Map<int, LayoutParameter*> _layoutParameterDictionary;
bool _ignoreSize;
Vector<Node*> _widgetChildren;
bool _affectByClipping;
SizeType _sizeType;
Point _sizePercent;
PositionType _positionType;
Point _positionPercent;
bool _reorderWidgetChildDirty;
bool _hitted;
EventListenerTouchOneByOne* _touchListener;
Map<int, LayoutParameter*> _layoutParameterDictionary;
Vector<Node*> _widgetChildren;
};
}