mirror of https://github.com/axmolengine/axmol.git
make ListView::setGlobalZOrder() work (#17098)
* make ListView::setGlobalZOrder() work * revert modification of UIButton * reset background color * change global z order to test
This commit is contained in:
parent
b3279bafa7
commit
79126ea72a
|
@ -100,9 +100,8 @@ void ProtectedNode::addProtectedChild(Node *child, int zOrder, int tag)
|
||||||
this->insertProtectedChild(child, zOrder);
|
this->insertProtectedChild(child, zOrder);
|
||||||
|
|
||||||
child->setTag(tag);
|
child->setTag(tag);
|
||||||
|
child->setGlobalZOrder(_globalZOrder);
|
||||||
child->setParent(this);
|
child->setParent(this);
|
||||||
|
|
||||||
child->updateOrderOfArrival();
|
child->updateOrderOfArrival();
|
||||||
|
|
||||||
if( _running )
|
if( _running )
|
||||||
|
@ -467,4 +466,11 @@ void ProtectedNode::setCameraMask(unsigned short mask, bool applyChildren)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProtectedNode::setGlobalZOrder(float globalZOrder)
|
||||||
|
{
|
||||||
|
Node::setGlobalZOrder(globalZOrder);
|
||||||
|
for (auto &child : _protectedChildren)
|
||||||
|
child->setGlobalZOrder(globalZOrder);
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -181,6 +181,7 @@ public:
|
||||||
virtual void disableCascadeColor() override;
|
virtual void disableCascadeColor() override;
|
||||||
virtual void disableCascadeOpacity()override;
|
virtual void disableCascadeOpacity()override;
|
||||||
virtual void setCameraMask(unsigned short mask, bool applyChildren = true) override;
|
virtual void setCameraMask(unsigned short mask, bool applyChildren = true) override;
|
||||||
|
virtual void setGlobalZOrder(float globalZOrder) override;
|
||||||
CC_CONSTRUCTOR_ACCESS:
|
CC_CONSTRUCTOR_ACCESS:
|
||||||
ProtectedNode();
|
ProtectedNode();
|
||||||
virtual ~ProtectedNode();
|
virtual ~ProtectedNode();
|
||||||
|
|
|
@ -126,6 +126,18 @@ void Layout::onExit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Layout::setGlobalZOrder(float globalZOrder)
|
||||||
|
{
|
||||||
|
// _protectedChildren's global z order is set in ProtectedNode::setGlobalZOrder()
|
||||||
|
|
||||||
|
Widget::setGlobalZOrder(globalZOrder);
|
||||||
|
if (_clippingStencil)
|
||||||
|
_clippingStencil->setGlobalZOrder(globalZOrder);
|
||||||
|
|
||||||
|
for (auto &child : _children)
|
||||||
|
child->setGlobalZOrder(globalZOrder);
|
||||||
|
}
|
||||||
|
|
||||||
Layout* Layout::create()
|
Layout* Layout::create()
|
||||||
{
|
{
|
||||||
Layout* layout = new (std::nothrow) Layout();
|
Layout* layout = new (std::nothrow) Layout();
|
||||||
|
@ -166,6 +178,7 @@ void Layout::addChild(Node *child, int zOrder, int tag)
|
||||||
if (dynamic_cast<Widget*>(child)) {
|
if (dynamic_cast<Widget*>(child)) {
|
||||||
supplyTheLayoutParameterLackToChild(static_cast<Widget*>(child));
|
supplyTheLayoutParameterLackToChild(static_cast<Widget*>(child));
|
||||||
}
|
}
|
||||||
|
child->setGlobalZOrder(_globalZOrder);
|
||||||
Widget::addChild(child, zOrder, tag);
|
Widget::addChild(child, zOrder, tag);
|
||||||
_doLayoutDirty = true;
|
_doLayoutDirty = true;
|
||||||
}
|
}
|
||||||
|
@ -175,6 +188,7 @@ void Layout::addChild(Node* child, int zOrder, const std::string &name)
|
||||||
if (dynamic_cast<Widget*>(child)) {
|
if (dynamic_cast<Widget*>(child)) {
|
||||||
supplyTheLayoutParameterLackToChild(static_cast<Widget*>(child));
|
supplyTheLayoutParameterLackToChild(static_cast<Widget*>(child));
|
||||||
}
|
}
|
||||||
|
child->setGlobalZOrder(_globalZOrder);
|
||||||
Widget::addChild(child, zOrder, name);
|
Widget::addChild(child, zOrder, name);
|
||||||
_doLayoutDirty = true;
|
_doLayoutDirty = true;
|
||||||
}
|
}
|
||||||
|
@ -389,6 +403,7 @@ void Layout::setClippingEnabled(bool able)
|
||||||
if (able)
|
if (able)
|
||||||
{
|
{
|
||||||
_clippingStencil = DrawNode::create();
|
_clippingStencil = DrawNode::create();
|
||||||
|
_clippingStencil->setGlobalZOrder(_globalZOrder);
|
||||||
if (_running)
|
if (_running)
|
||||||
{
|
{
|
||||||
_clippingStencil->onEnter();
|
_clippingStencil->onEnter();
|
||||||
|
|
|
@ -414,6 +414,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void onExit() override;
|
virtual void onExit() override;
|
||||||
|
|
||||||
|
virtual void setGlobalZOrder(float globalZOrder) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a layout is loop focused which means that the focus movement will be inside the layout
|
* If a layout is loop focused which means that the focus movement will be inside the layout
|
||||||
*@param loop pass true to let the focus movement loop inside the layout
|
*@param loop pass true to let the focus movement loop inside the layout
|
||||||
|
|
|
@ -257,11 +257,13 @@ void ScrollView::addChild(Node * child, int localZOrder)
|
||||||
|
|
||||||
void ScrollView::addChild(Node *child, int zOrder, int tag)
|
void ScrollView::addChild(Node *child, int zOrder, int tag)
|
||||||
{
|
{
|
||||||
|
child->setGlobalZOrder(_globalZOrder);
|
||||||
_innerContainer->addChild(child, zOrder, tag);
|
_innerContainer->addChild(child, zOrder, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::addChild(Node* child, int zOrder, const std::string &name)
|
void ScrollView::addChild(Node* child, int zOrder, const std::string &name)
|
||||||
{
|
{
|
||||||
|
child->setGlobalZOrder(_globalZOrder);
|
||||||
_innerContainer->addChild(child, zOrder, name);
|
_innerContainer->addChild(child, zOrder, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,7 @@ bool UIListViewTest_Vertical::init()
|
||||||
_listView->setDirection(ui::ScrollView::Direction::VERTICAL);
|
_listView->setDirection(ui::ScrollView::Direction::VERTICAL);
|
||||||
_listView->setBounceEnabled(true);
|
_listView->setBounceEnabled(true);
|
||||||
_listView->setBackGroundImage("cocosui/green_edit.png");
|
_listView->setBackGroundImage("cocosui/green_edit.png");
|
||||||
|
_listView->setGlobalZOrder(200);
|
||||||
_listView->setBackGroundImageScale9Enabled(true);
|
_listView->setBackGroundImageScale9Enabled(true);
|
||||||
_listView->setContentSize(Size(240, 130));
|
_listView->setContentSize(Size(240, 130));
|
||||||
_listView->setPosition(Vec2((widgetSize - _listView->getContentSize()) / 2.0f));
|
_listView->setPosition(Vec2((widgetSize - _listView->getContentSize()) / 2.0f));
|
||||||
|
|
|
@ -61,6 +61,7 @@ bool UIPageViewTest::init()
|
||||||
pageView->setPosition((widgetSize - pageView->getContentSize()) / 2.0f);
|
pageView->setPosition((widgetSize - pageView->getContentSize()) / 2.0f);
|
||||||
pageView->removeAllItems();
|
pageView->removeAllItems();
|
||||||
pageView->setIndicatorEnabled(true);
|
pageView->setIndicatorEnabled(true);
|
||||||
|
pageView->setGlobalZOrder(200);
|
||||||
|
|
||||||
int pageCount = 4;
|
int pageCount = 4;
|
||||||
for (int i = 0; i < pageCount; ++i)
|
for (int i = 0; i < pageCount; ++i)
|
||||||
|
|
|
@ -60,6 +60,7 @@ bool UIScrollViewTest_Vertical::init()
|
||||||
scrollView->setScrollBarWidth(4);
|
scrollView->setScrollBarWidth(4);
|
||||||
scrollView->setScrollBarPositionFromCorner(Vec2(2, 2));
|
scrollView->setScrollBarPositionFromCorner(Vec2(2, 2));
|
||||||
scrollView->setScrollBarColor(Color3B::WHITE);
|
scrollView->setScrollBarColor(Color3B::WHITE);
|
||||||
|
scrollView->setGlobalZOrder(200);
|
||||||
_uiLayer->addChild(scrollView);
|
_uiLayer->addChild(scrollView);
|
||||||
|
|
||||||
ImageView* imageView = ImageView::create("cocosui/ccicon.png");
|
ImageView* imageView = ImageView::create("cocosui/ccicon.png");
|
||||||
|
|
Loading…
Reference in New Issue