@@ -42,6 +42,7 @@ UILayoutTests::UILayoutTests()
42
42
ADD_TEST_CASE (UILayoutComponentTest);
43
43
ADD_TEST_CASE (UILayoutComponent_Berth_Test);
44
44
ADD_TEST_CASE (UILayoutComponent_Berth_Stretch_Test);
45
+ ADD_TEST_CASE (UILayoutTest_Issue19890);
45
46
}
46
47
47
48
// UILayoutTest
@@ -956,3 +957,62 @@ bool UILayoutComponent_Berth_Stretch_Test::init()
956
957
}
957
958
return false ;
958
959
}
960
+
961
+ bool UILayoutTest_Issue19890::init ()
962
+ {
963
+ if (!UIScene::init ())
964
+ {
965
+ return false ;
966
+ }
967
+
968
+ const Size widgetSize = _widget->getContentSize ();
969
+
970
+ auto label = Text::create (" Issue 19890" , " fonts/Marker Felt.ttf" , 32 );
971
+ label->setAnchorPoint (Vec2 (0 .5f , -1 .0f ));
972
+ label->setPosition (Vec2 (widgetSize.width / 2 .0f ,
973
+ widgetSize.height / 2 .0f + label->getContentSize ().height * 1 .5f ));
974
+ _uiLayer->addChild (label);
975
+
976
+ Text* alert = Text::create (" 3 panels should be completely visible" , " fonts/Marker Felt.ttf" , 20 );
977
+ alert->setColor (Color3B (159 , 168 , 176 ));
978
+ alert->setPosition (Vec2 (widgetSize.width / 2 .0f ,
979
+ widgetSize.height / 2 .0f - alert->getContentSize ().height * 3 .075f ));
980
+ _uiLayer->addChild (alert);
981
+
982
+ Layout* root = static_cast <Layout*>(_uiLayer->getChildByTag (81 ));
983
+
984
+ Layout* background = dynamic_cast <Layout*>(root->getChildByName (" background_Panel" ));
985
+ const Size backgroundSize = background->getContentSize ();
986
+
987
+ auto panel = ui::Layout::create ();
988
+ panel->setBackGroundColor (Color3B::RED);
989
+ panel->setBackGroundColorType (ui::Layout::BackGroundColorType::SOLID);
990
+ panel->setClippingType (ui::Layout::ClippingType::SCISSOR);
991
+ panel->setPosition (backgroundSize / 2 );
992
+ panel->setAnchorPoint (Vec2::ANCHOR_MIDDLE);
993
+ panel->setClippingEnabled (true );
994
+ panel->setContentSize (backgroundSize); // from the left to the screen end
995
+ background->addChild (panel);
996
+
997
+ auto panel2 = ui::Layout::create ();
998
+ panel2->setBackGroundColor (Color3B::BLUE);
999
+ panel2->setBackGroundColorType (ui::Layout::BackGroundColorType::SOLID);
1000
+ panel2->setClippingType (ui::Layout::ClippingType::SCISSOR);
1001
+ panel2->setPosition (panel->getContentSize () / 2 );
1002
+ panel2->setAnchorPoint (Vec2::ANCHOR_MIDDLE);
1003
+ panel2->setClippingEnabled (true );
1004
+ panel2->setContentSize (panel->getContentSize () / 2 ); // from the left to the screen end
1005
+ panel->addChild (panel2);
1006
+
1007
+ auto panel3 = ui::Layout::create ();
1008
+ panel3->setBackGroundColor (Color3B::GREEN);
1009
+ panel3->setBackGroundColorType (ui::Layout::BackGroundColorType::SOLID);
1010
+ panel3->setClippingType (ui::Layout::ClippingType::SCISSOR);
1011
+ panel3->setPosition (panel2->getContentSize () / 2 );
1012
+ panel3->setAnchorPoint (Vec2::ANCHOR_MIDDLE);
1013
+ panel3->setClippingEnabled (true );
1014
+ panel3->setContentSize (panel2->getContentSize () / 2 ); // from the left to the screen end
1015
+ panel2->addChild (panel3);
1016
+
1017
+ return true ;
1018
+ }
0 commit comments