@@ -14,6 +14,7 @@ UILayoutTests::UILayoutTests()
14
14
ADD_TEST_CASE (UILayoutTest_Layout_Linear_Horizontal);
15
15
ADD_TEST_CASE (UILayoutTest_Layout_Relative_Align_Parent);
16
16
ADD_TEST_CASE (UILayoutTest_Layout_Relative_Location);
17
+ ADD_TEST_CASE (UILayoutTest_Layout_Scaled_Widget);
17
18
ADD_TEST_CASE (UILayoutComponentTest);
18
19
ADD_TEST_CASE (UILayoutComponent_Berth_Test);
19
20
ADD_TEST_CASE (UILayoutComponent_Berth_Stretch_Test);
@@ -726,6 +727,62 @@ bool UILayoutTest_Layout_Relative_Location::init()
726
727
return false ;
727
728
}
728
729
730
+ // UILayoutTest_Layout_Relative_Location
731
+
732
+ UILayoutTest_Layout_Scaled_Widget::UILayoutTest_Layout_Scaled_Widget ()
733
+ {
734
+ }
735
+
736
+ UILayoutTest_Layout_Scaled_Widget::~UILayoutTest_Layout_Scaled_Widget ()
737
+ {
738
+ }
739
+
740
+ bool UILayoutTest_Layout_Scaled_Widget::init ()
741
+ {
742
+ if (UIScene::init ())
743
+ {
744
+ Size widgetSize = _widget->getContentSize ();
745
+
746
+ // Add the alert
747
+ Text* alert = Text::create (" Layout Scaled Widget" , " fonts/Marker Felt.ttf" , 20 );
748
+ alert->setColor (Color3B (159 , 168 , 176 ));
749
+ alert->setPosition (Vec2 (widgetSize.width / 2 .0f , widgetSize.height / 2 .0f - alert->getContentSize ().height * 4 .5f ));
750
+ _uiLayer->addChild (alert);
751
+
752
+ Layout* root = static_cast <Layout*>(_uiLayer->getChildByTag (81 ));
753
+
754
+ Layout* background = dynamic_cast <Layout*>(root->getChildByName (" background_Panel" ));
755
+
756
+ // Create the layout
757
+ Layout* layout = Layout::create ();
758
+ layout->setLayoutType (Layout::Type::HORIZONTAL);
759
+ layout->setContentSize (Size (280 , 150 ));
760
+ Size backgroundSize = background->getContentSize ();
761
+ layout->setPosition (Vec2 ((widgetSize.width - backgroundSize.width ) / 2 .0f +
762
+ (backgroundSize.width - layout->getContentSize ().width ) / 2 .0f ,
763
+ (widgetSize.height - backgroundSize.height ) / 2 .0f +
764
+ (backgroundSize.height - layout->getContentSize ().height ) / 2 .0f ));
765
+ _uiLayer->addChild (layout);
766
+
767
+ ImageView* imageView_Center1 = ImageView::create (" cocosui/scrollviewbg.png" );
768
+ imageView_Center1->setScale (0.5 );
769
+ layout->addChild (imageView_Center1);
770
+
771
+ ImageView* imageView_Center2 = ImageView::create (" cocosui/scrollviewbg.png" );
772
+ imageView_Center2->setScale (1.2 );
773
+ layout->addChild (imageView_Center2);
774
+
775
+ ImageView* imageView_Center3 = ImageView::create (" cocosui/scrollviewbg.png" );
776
+ imageView_Center3->setScale (0.8 );
777
+ layout->addChild (imageView_Center3);
778
+
779
+ return true ;
780
+ }
781
+
782
+ return false ;
783
+ }
784
+
785
+
729
786
bool UILayoutComponentTest::init ()
730
787
{
731
788
if (UIScene::init ())
0 commit comments