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 * @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 * Return an array of children
* *
@ -615,7 +615,7 @@ public:
* *
* @return The amount of children. * @return The amount of children.
*/ */
ssize_t getChildrenCount() const; virtual ssize_t getChildrenCount() const;
/** /**
* Sets the parent node * Sets the parent node

View File

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

View File

@ -112,6 +112,8 @@ public:
*/ */
void removeItem(int index); void removeItem(int index);
void removeAllItems();
/** /**
* Returns a item whose index is same as the parameter. * 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 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 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 Vector<Node*>& getChildren() override{return ScrollView::getChildren();};
virtual const Vector<Node*>& getChildren() const 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; virtual bool init() override;
void updateInnerContainerSize(); void updateInnerContainerSize();
void remedyLayoutParameter(Widget* item); void remedyLayoutParameter(Widget* item);

View File

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

View File

@ -165,8 +165,12 @@ protected:
virtual void addChild(Node* child, int zOrder, int tag) override; virtual void addChild(Node* child, int zOrder, int tag) override;
virtual void removeChild(Node* widget, bool cleanup = true) override; virtual void removeChild(Node* widget, bool cleanup = true) override;
virtual void removeAllChildren() override; virtual void removeAllChildren() override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual Vector<Node*>& getChildren() override{return Widget::getChildren();}; virtual Vector<Node*>& getChildren() override{return Widget::getChildren();};
virtual const Vector<Node*>& getChildren() const 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; virtual bool init() override;
Layout* createPage(); Layout* createPage();
float getPositionXByIndex(int idx); float getPositionXByIndex(int idx);

View File

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

View File

@ -259,6 +259,8 @@ public:
//override "removeAllChildrenAndCleanUp" method of widget. //override "removeAllChildrenAndCleanUp" method of widget.
virtual void removeAllChildren() override; virtual void removeAllChildren() override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
//override "removeChild" method of widget. //override "removeChild" method of widget.
virtual void removeChild(Node* child, bool cleaup = true) override; virtual void removeChild(Node* child, bool cleaup = true) override;
@ -266,6 +268,12 @@ public:
virtual Vector<Node*>& getChildren() override; virtual Vector<Node*>& getChildren() override;
virtual const Vector<Node*>& getChildren() const 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 bool onTouchBegan(Touch *touch, Event *unusedEvent) override;
virtual void onTouchMoved(Touch *touch, Event *unusedEvent) override; virtual void onTouchMoved(Touch *touch, Event *unusedEvent) override;
virtual void onTouchEnded(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; return _widgetChildren;
} }
long Widget::getChildrenCount() const ssize_t Widget::getChildrenCount() const
{ {
return _widgetChildren.size(); return _widgetChildren.size();
} }

View File

@ -232,7 +232,7 @@ public:
* *
* @return a Node object whose tag equals to the input parameter * @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; virtual void sortAllChildren() override;
/** /**
@ -259,14 +259,14 @@ public:
* *
* @return The amount of children. * @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. * Removes this node itself from its parent node with a cleanup.
* If the node orphan, then nothing happens. * If the node orphan, then nothing happens.
* @see `removeFromParentAndCleanup(bool)` * @see `removeFromParentAndCleanup(bool)`
*/ */
virtual void removeFromParent(); virtual void removeFromParent() override;
/** /**
* Removes this node itself from its parent node. * Removes this node itself from its parent node.
* If the node orphan, then nothing happens. * If the node orphan, then nothing happens.
@ -274,7 +274,7 @@ public:
* @js removeFromParent * @js removeFromParent
* @lua 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. * 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 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. * @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 * 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 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. * @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. * Removes all children from the container with a cleanup.
* *
* @see `removeAllChildrenWithCleanup(bool)` * @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. * 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 * @js removeAllChildren
* @lua removeAllChildren * @lua removeAllChildren
*/ */
virtual void removeAllChildrenWithCleanup(bool cleanup); virtual void removeAllChildrenWithCleanup(bool cleanup) override;
/** /**
* Gets a child from the container with its name * 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 * @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(); virtual void visit();
@ -663,36 +663,27 @@ protected:
bool _focus; ///< is the widget on focus bool _focus; ///< is the widget on focus
BrightStyle _brightStyle; ///< bright style BrightStyle _brightStyle; ///< bright style
bool _updateEnabled; ///< is "update" method scheduled bool _updateEnabled; ///< is "update" method scheduled
// Node* _renderer; ///< base renderer
Point _touchStartPos; ///< touch began point Point _touchStartPos; ///< touch began point
Point _touchMovePos; ///< touch moved point Point _touchMovePos; ///< touch moved point
Point _touchEndPos; ///< touch ended point Point _touchEndPos; ///< touch ended point
Object* _touchEventListener; Object* _touchEventListener;
SEL_TouchEvent _touchEventSelector; SEL_TouchEvent _touchEventSelector;
std::string _name; std::string _name;
WidgetType _widgetType; WidgetType _widgetType;
int _actionTag; int _actionTag;
Size _size; Size _size;
Size _customSize; Size _customSize;
Map<int, LayoutParameter*> _layoutParameterDictionary;
bool _ignoreSize; bool _ignoreSize;
Vector<Node*> _widgetChildren;
bool _affectByClipping; bool _affectByClipping;
SizeType _sizeType; SizeType _sizeType;
Point _sizePercent; Point _sizePercent;
PositionType _positionType; PositionType _positionType;
Point _positionPercent; Point _positionPercent;
bool _reorderWidgetChildDirty; bool _reorderWidgetChildDirty;
bool _hitted; bool _hitted;
EventListenerTouchOneByOne* _touchListener; EventListenerTouchOneByOne* _touchListener;
Map<int, LayoutParameter*> _layoutParameterDictionary;
Vector<Node*> _widgetChildren;
}; };
} }