From: Adeel Kazmi Date: Thu, 2 Apr 2015 17:57:46 +0000 (-0700) Subject: Merge "Size negotiation patch 1: Removed SetPreferred size" into tizen X-Git-Tag: accepted/tizen/common/20150407.101646~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=6e824d3bfb11cab305d0d8375b202076d59222b0;hp=389593ad328d5a86972e32148a0ba45bad687b41 Merge "Size negotiation patch 1: Removed SetPreferred size" into tizen --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Alignment.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Alignment.cpp index 0749da4..0f62a2a 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Alignment.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Alignment.cpp @@ -935,7 +935,7 @@ int UtcDaliAlignmentOnSizeSet(void) application.SendNotification(); Vector2 size( 100.0f, 200.0f ); - alignment.SetPreferredSize(size); + alignment.SetSize(size); application.Render(); application.SendNotification(); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp index 3a6900e..12e85b6 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Button.cpp @@ -144,6 +144,7 @@ int UtcDaliButtonSize(void) // First an image is set, then SetSize is called. pushButton = PushButton::New(); + Stage::GetCurrent().Add( pushButton ); pushButton.SetBackgroundImage( image01 ); pushButton.SetSize( 10.f, 10.f ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-CheckBoxButton.cpp b/automated-tests/src/dali-toolkit/utc-Dali-CheckBoxButton.cpp index 32bb9de..d6dc8d4 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-CheckBoxButton.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-CheckBoxButton.cpp @@ -111,6 +111,7 @@ int UtcDaliCheckBoxButtonSetImages(void) Image image02 = CreateSolidColorImage( Color::RED, 30, 30 ); ImageActor imageActor02 = CreateSolidColorActor( Color::RED ); imageActor02.SetSize( 40, 40 ); + imageActor02.SetName( "imageActor02" ); Image image03 = CreateSolidColorImage( Color::RED, 50, 50 ); ImageActor imageActor03 = CreateSolidColorActor( Color::RED ); @@ -122,6 +123,8 @@ int UtcDaliCheckBoxButtonSetImages(void) Vector3 size; CheckBoxButton checkBoxButton = CheckBoxButton::New(); + checkBoxButton.SetName( "UtcDaliCheckBoxButtonSetImages" ); + Stage::GetCurrent().Add( checkBoxButton ); application.SendNotification(); application.Render(); @@ -133,79 +136,12 @@ int UtcDaliCheckBoxButtonSetImages(void) application.SendNotification(); application.Render(); - size = checkBoxButton.GetBackgroundImage().GetCurrentSize(); + size = checkBoxButton.GetCurrentSize(); DALI_TEST_EQUALS( size.width, 10.f, TEST_LOCATION ); DALI_TEST_EQUALS( size.height, 10.f, TEST_LOCATION ); checkBoxButton.SetBackgroundImage( imageActor01 ); - application.SendNotification(); - application.Render(); - - size = checkBoxButton.GetBackgroundImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION ); - - checkBoxButton.SetSelectedImage( image02 ); - - application.SendNotification(); - application.Render(); - - size = checkBoxButton.GetSelectedImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 30.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 30.f, TEST_LOCATION ); - - checkBoxButton.SetSelectedImage( imageActor02 ); - - application.SendNotification(); - application.Render(); - - size = checkBoxButton.GetSelectedImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 40.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 40.f, TEST_LOCATION ); - - checkBoxButton.SetDisabledBackgroundImage( image03 ); - - application.SendNotification(); - application.Render(); - - size = checkBoxButton.GetDisabledBackgroundImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 50.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 50.f, TEST_LOCATION ); - - checkBoxButton.SetDisabledBackgroundImage( imageActor03 ); - - application.SendNotification(); - application.Render(); - - size = checkBoxButton.GetDisabledBackgroundImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 60.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 60.f, TEST_LOCATION ); - - checkBoxButton.SetDisabledSelectedImage( image04 ); - - application.SendNotification(); - application.Render(); - - size = checkBoxButton.GetDisabledSelectedImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 70.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 70.f, TEST_LOCATION ); - - checkBoxButton.SetDisabledSelectedImage( imageActor04 ); - - application.SendNotification(); - application.Render(); - - size = checkBoxButton.GetDisabledSelectedImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 80.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 80.f, TEST_LOCATION ); END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp index aa9e46c..beeb619 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp @@ -328,6 +328,12 @@ int UtcDaliControlTestParameters(void) DummyControl test = DummyControl::New(); test.SetSize( 0.7f, 0.7f, 0.7f ); + + Stage::GetCurrent().Add( test ); + + application.SendNotification(); + application.Render(); + float width = 640.0f; float height = test.GetHeightForWidth( width ); DALI_TEST_CHECK( test.GetWidthForHeight( height ) == width ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp index 3d0a489..f7926a5 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp @@ -219,7 +219,7 @@ int UtcDaliControlImplOnGestureMethods(void) { DummyControl dummy = DummyControl::New(true); dummy.SetRelayoutEnabled( true ); - dummy.SetPreferredSize( Vector2(100.0f, 100.0f ) ); + dummy.SetSize( Vector2(100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); @@ -280,7 +280,7 @@ int UtcDaliControlImplOnGestureMethods(void) { DummyControl dummy = DummyControl::New(); dummy.SetRelayoutEnabled( true ); - dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) ); + dummy.SetSize( Vector2( 100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); @@ -454,7 +454,7 @@ int UtcDaliControlImplSizeSet(void) DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION ); // Called from size negotiation Vector2 size(100.0f, 200.0f); - dummy.SetPreferredSize(size); + dummy.SetSize(size); application.Render(); application.SendNotification(); @@ -479,7 +479,7 @@ int UtcDaliControlImplSizeSet(void) application.Render(); application.SendNotification(); - dummy.SetPreferredSize(size); + dummy.SetSize(size); application.Render(); application.SendNotification(); @@ -549,7 +549,7 @@ int UtcDaliControlImplTouchEvent(void) dummy.SetRelayoutEnabled( true ); DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); - dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) ); + dummy.SetSize( Vector2( 100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); @@ -573,7 +573,7 @@ int UtcDaliControlImplTouchEvent(void) DummyControl dummy = DummyControl::New(); dummy.SetRelayoutEnabled( true ); - dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) ); + dummy.SetSize( Vector2( 100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); @@ -776,7 +776,7 @@ int UtcDaliControlImplMouseWheelEvent(void) dummy.SetRelayoutEnabled( true ); DummyControlImplOverride& dummyImpl = static_cast(dummy.GetImplementation()); - dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) ); + dummy.SetSize( Vector2( 100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); @@ -803,7 +803,7 @@ int UtcDaliControlImplMouseWheelEvent(void) DummyControl dummy = DummyControl::New(); dummy.SetRelayoutEnabled( true ); - dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) ); + dummy.SetSize( Vector2( 100.0f, 100.0f ) ); dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-PageTurnView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-PageTurnView.cpp index 443de6f..955f19d 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-PageTurnView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-PageTurnView.cpp @@ -371,6 +371,7 @@ int UtcDaliPageTurnViewEnterLeaveEditMode(void) factory.EnableOffscreenRendering( ); PageTurnView pageTurnView = PageTurnLandscapeView::New( factory, PAGE_SIZE ); + pageTurnView.SetRelayoutEnabled( false ); pageTurnView.SetPositionInheritanceMode( USE_PARENT_POSITION ); Stage::GetCurrent().Add( pageTurnView ); @@ -422,6 +423,7 @@ int UtcDaliPageTurnViewGetHitActor(void) factory.EnableOffscreenRendering( ); PageTurnView pageTurnView = PageTurnPortraitView::New( factory, PAGE_SIZE ); + pageTurnView.SetRelayoutEnabled( false ); pageTurnView.SetParentOrigin( ParentOrigin::TOP_LEFT ); pageTurnView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); Stage::GetCurrent().Add( pageTurnView ); @@ -458,6 +460,7 @@ int UtcDaliPageTurnViewRefresh(void) TestPageFactory factory(application); factory.EnableOffscreenRendering( ); PageTurnView pageTurnView = PageTurnPortraitView::New( factory, PAGE_SIZE ); + pageTurnView.SetRelayoutEnabled( false ); pageTurnView.SetParentOrigin( ParentOrigin::TOP_LEFT ); pageTurnView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); Stage::GetCurrent().Add( pageTurnView ); @@ -498,6 +501,7 @@ int UtcDaliPageTurnViewSignals(void) TestPageFactory factory(application); Vector2 size = Stage::GetCurrent().GetSize(); PageTurnView portraitView = PageTurnPortraitView::New( factory, size ); + portraitView.SetRelayoutEnabled( false ); portraitView.SetPositionInheritanceMode( USE_PARENT_POSITION ); Stage::GetCurrent().Add( portraitView ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp index 1f2ecc7..0ba0800 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Popup.cpp @@ -342,9 +342,9 @@ int UtcDaliPopupShowHide(void) PushButton button1 = PushButton::New(); PushButton button2 = PushButton::New(); - button1.SetPreferredSize(DEFAULT_BUTTON_SIZE.GetVectorXY()); + button1.SetSize(DEFAULT_BUTTON_SIZE.GetVectorXY()); popup.AddButton(button1); - button2.SetPreferredSize(DEFAULT_BUTTON_SIZE.GetVectorXY()); + button2.SetSize(DEFAULT_BUTTON_SIZE.GetVectorXY()); popup.AddButton(button2); // Showing/Hiding popup, results in all child Actors being diff --git a/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp b/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp index 4a2a33d..84a020e 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp @@ -279,27 +279,10 @@ int UtcDaliPushButtonSetImages(void) Actor imageActor; Image image01 = CreateSolidColorImage( Color::RED, 10, 10 ); - ImageActor imageActor01 = CreateSolidColorActor( Color::RED ); - imageActor01.SetSize( 20.f, 20.f ); - - Image image02 = CreateSolidColorImage( Color::RED, 30, 30 ); - ImageActor imageActor02 = CreateSolidColorActor( Color::RED ); - imageActor02.SetSize( 40.f, 40.f ); - - Image image03 = CreateSolidColorImage( Color::RED, 50, 50 ); - ImageActor imageActor03 = CreateSolidColorActor( Color::RED ); - imageActor03.SetSize( 60.f, 60.f ); - - Image image04 = CreateSolidColorImage( Color::RED, 70, 70 ); - ImageActor imageActor04 = CreateSolidColorActor( Color::RED ); - imageActor04.SetSize( 80.f, 80.f ); - - Image image05 = CreateSolidColorImage( Color::RED, 90, 90 ); - ImageActor imageActor05 = CreateSolidColorActor( Color::RED ); - imageActor05.SetSize( 100.f, 100.f ); Vector3 size; PushButton pushButton = PushButton::New(); + Stage::GetCurrent().Add( pushButton ); application.SendNotification(); application.Render(); @@ -311,100 +294,11 @@ int UtcDaliPushButtonSetImages(void) application.SendNotification(); application.Render(); - size = pushButton.GetButtonImage().GetCurrentSize(); + size = pushButton.GetCurrentSize(); DALI_TEST_EQUALS( size.width, 10.f, TEST_LOCATION ); DALI_TEST_EQUALS( size.height, 10.f, TEST_LOCATION ); - pushButton.SetButtonImage( imageActor01 ); - - application.SendNotification(); - application.Render(); - - size = pushButton.GetButtonImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION ); - - pushButton.SetBackgroundImage( image02 ); - - application.SendNotification(); - application.Render(); - - size = pushButton.GetBackgroundImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 30.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 30.f, TEST_LOCATION ); - - pushButton.SetBackgroundImage( imageActor02 ); - - application.SendNotification(); - application.Render(); - - size = pushButton.GetBackgroundImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 40.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 40.f, TEST_LOCATION ); - - pushButton.SetSelectedImage( image03 ); - - application.SendNotification(); - application.Render(); - - size = pushButton.GetSelectedImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 50.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 50.f, TEST_LOCATION ); - - pushButton.SetSelectedImage( imageActor03 ); - - application.SendNotification(); - application.Render(); - - size = pushButton.GetSelectedImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 60.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 60.f, TEST_LOCATION ); - - pushButton.SetDisabledBackgroundImage( image04 ); - - application.SendNotification(); - application.Render(); - - size = pushButton.GetDisabledBackgroundImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 70.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 70.f, TEST_LOCATION ); - - pushButton.SetDisabledBackgroundImage( imageActor04 ); - - application.SendNotification(); - application.Render(); - - size = pushButton.GetDisabledBackgroundImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 80.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 80.f, TEST_LOCATION ); - - pushButton.SetDisabledImage( image05 ); - - application.SendNotification(); - application.Render(); - - size = pushButton.GetDisabledImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 90.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 90.f, TEST_LOCATION ); - - pushButton.SetDisabledImage( imageActor05 ); - - application.SendNotification(); - application.Render(); - - size = pushButton.GetDisabledImage().GetCurrentSize(); - - DALI_TEST_EQUALS( size.width, 100.f, TEST_LOCATION ); - DALI_TEST_EQUALS( size.height, 100.f, TEST_LOCATION ); END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Slider.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Slider.cpp index d5d2ef0..89090da 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Slider.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Slider.cpp @@ -125,7 +125,7 @@ int UtcDaliSliderSignals(void) Stage::GetCurrent().Add( slider ); slider.SetParentOrigin(ParentOrigin::TOP_LEFT); slider.SetAnchorPoint(ParentOrigin::TOP_LEFT); - slider.SetPreferredSize( Vector2( Stage::GetCurrent().GetSize().x, 20.0f ) ); + slider.SetSize( Vector2( Stage::GetCurrent().GetSize().x, 20.0f ) ); slider.SetPosition( 0.0f, 0.0f ); const float MIN_BOUND = 0.0f; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp index 5fd205c..b7e662e 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-SuperBlurView.cpp @@ -197,6 +197,7 @@ int UtcDaliSuperBlurViewGetBlurredImage(void) tet_infoline( "UtcDaliSuperBlurViewGetBlurredImage" ); SuperBlurView blurView = SuperBlurView::New( BLUR_LEVELS ); + blurView.SetRelayoutEnabled( false ); blurView.SetSize( 100.f,100.f ); Image inputImage = CreateSolidColorImage( application, Color::GREEN, 100, 100 ); blurView.SetImage( inputImage ); @@ -207,8 +208,8 @@ int UtcDaliSuperBlurViewGetBlurredImage(void) DALI_TEST_CHECK( image1 ); Image image2 = blurView.GetBlurredImage( 2 ); - DALI_TEST_CHECK( image2.GetWidth() == 25 ); - DALI_TEST_CHECK( image2.GetHeight() == 25 ); + DALI_TEST_EQUALS( image2.GetWidth(), 25, TEST_LOCATION ); + DALI_TEST_EQUALS( image2.GetHeight(), 25, TEST_LOCATION ); Image image3 = blurView.GetBlurredImage( 3 ); DALI_TEST_CHECK( FrameBufferImage::DownCast( image2 ) ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp index 484453c..0e99819 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TableView.cpp @@ -73,18 +73,18 @@ static void SetupTableViewAndActors(TableView& tableView, Actor& actor1, Actor& tableView.SetRelayoutEnabled( true ); Stage::GetCurrent().Add( tableView ); - tableView.SetPreferredSize( Dali::Vector2( 100.0f, 100.0f ) ); + tableView.SetSize( Dali::Vector2( 100.0f, 100.0f ) ); actor1 = Actor::New(); actor2 = Actor::New(); actor3 = Actor::New(); actor1.SetRelayoutEnabled( true ); - actor1.SetPreferredSize( Dali::Vector2( 10, 10 ) ); + actor1.SetSize( Dali::Vector2( 10, 10 ) ); actor2.SetRelayoutEnabled( true ); - actor2.SetPreferredSize( Dali::Vector2( 10, 10 ) ); + actor2.SetSize( Dali::Vector2( 10, 10 ) ); actor3.SetRelayoutEnabled( true ); - actor3.SetPreferredSize( Dali::Vector2( 10, 10 ) ); + actor3.SetSize( Dali::Vector2( 10, 10 ) ); tableView.AddChild( actor1, TableView::CellPosition( 0, 0 ) ); tableView.AddChild( actor2, TableView::CellPosition( 0, 1 ) ); @@ -541,7 +541,7 @@ int UtcDaliTableViewSetGetProperty(void) // Create a 1x1 table-view TableView tableView = TableView::New(1,1); - tableView.SetPreferredSize( Vector2( 100.0f, 100.0f ) ); + tableView.SetSize( Vector2( 100.0f, 100.0f ) ); DALI_TEST_CHECK( tableView ); // Test "rows" property diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ToolBar.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ToolBar.cpp index e1042b2..d359334 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ToolBar.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ToolBar.cpp @@ -114,23 +114,18 @@ int UtcDaliToolBarAddControl01(void) try { ImageActor control1 = CreateSolidColorActor( Color::RED ); - control1.SetPreferredSize( Vector2( 100.f, 100.f ) ); - control1.SetResizePolicy( FIXED, ALL_DIMENSIONS ); + control1.SetSize( Vector2( 100.f, 100.f ) ); ImageActor control2 = CreateSolidColorActor( Color::RED ); - control2.SetPreferredSize( Vector2( 100.f, 100.f ) ); - control2.SetResizePolicy( FIXED, ALL_DIMENSIONS ); + control2.SetSize( Vector2( 100.f, 100.f ) ); ImageActor control3 = CreateSolidColorActor( Color::RED ); - control3.SetPreferredSize( Vector2( 100.f, 100.f ) ); - control3.SetResizePolicy( FIXED, ALL_DIMENSIONS ); + control3.SetSize( Vector2( 100.f, 100.f ) ); ImageActor control4 = CreateSolidColorActor( Color::RED ); - control4.SetPreferredSize( Vector2( 100.f, 100.f ) ); - control4.SetResizePolicy( FIXED, ALL_DIMENSIONS ); + control4.SetSize( Vector2( 100.f, 100.f ) ); ImageActor control5 = CreateSolidColorActor( Color::RED ); - control5.SetPreferredSize( Vector2( 100.f, 100.f ) ); - control5.SetResizePolicy( FIXED, ALL_DIMENSIONS ); + control5.SetSize( Vector2( 100.f, 100.f ) ); ToolBar toolbar = ToolBar::New(); - toolbar.SetPreferredSize( Vector2( 600.f, 100.f ) ); + toolbar.SetSize( Vector2( 600.f, 100.f ) ); application.Render(); application.SendNotification(); @@ -144,14 +139,11 @@ int UtcDaliToolBarAddControl01(void) toolbar.AddControl( control5, 0.1f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) ); ImageActor control6 = CreateSolidColorActor( Color::RED ); - control6.SetPreferredSize( Vector2( 100.f, 100.f ) ); - control6.SetResizePolicy( FIXED, ALL_DIMENSIONS ); + control6.SetSize( Vector2( 100.f, 100.f ) ); ImageActor control7 = CreateSolidColorActor( Color::RED ); - control7.SetPreferredSize( Vector2( 100.f, 100.f ) ); - control7.SetResizePolicy( FIXED, ALL_DIMENSIONS ); + control7.SetSize( Vector2( 100.f, 100.f ) ); ImageActor control8 = CreateSolidColorActor( Color::RED ); - control8.SetPreferredSize( Vector2( 100.f, 100.f ) ); - control8.SetResizePolicy( FIXED, ALL_DIMENSIONS ); + control8.SetSize( Vector2( 100.f, 100.f ) ); application.Render(); application.SendNotification(); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-View.cpp b/automated-tests/src/dali-toolkit/utc-Dali-View.cpp index 2d28fd2..ad124e1 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-View.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-View.cpp @@ -308,7 +308,7 @@ int UtcDaliViewOrientationChanged(void) view.SetRelayoutEnabled( true ); Stage::GetCurrent().Add( view ); - view.SetPreferredSize( Vector2( 480, 800 ) ); + view.SetSize( Vector2( 480, 800 ) ); view.OrientationAnimationStartedSignal().Connect( &StartAnimation ); diff --git a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp index 207d3f0..a2cb95d 100644 --- a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp @@ -128,6 +128,10 @@ void PushButton::OnButtonImageSet() Actor& buttonImage = GetButtonImage(); buttonImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + buttonImage.RelayoutRequestTree(); + + RelayoutRequest(); } void PushButton::OnSelectedImageSet() @@ -135,6 +139,10 @@ void PushButton::OnSelectedImageSet() Actor& selectedImage = GetSelectedImage(); selectedImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + selectedImage.RelayoutRequestTree(); + + RelayoutRequest(); } void PushButton::OnBackgroundImageSet() @@ -142,6 +150,10 @@ void PushButton::OnBackgroundImageSet() Actor& backgroundImage = GetBackgroundImage(); backgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + backgroundImage.RelayoutRequestTree(); + + RelayoutRequest(); } void PushButton::OnSelectedBackgroundImageSet() @@ -156,6 +168,10 @@ void PushButton::OnDisabledImageSet() Actor& disabledImage = GetDisabledImage(); disabledImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + disabledImage.RelayoutRequestTree(); + + RelayoutRequest(); } void PushButton::OnDisabledBackgroundImageSet() @@ -163,6 +179,10 @@ void PushButton::OnDisabledBackgroundImageSet() Actor& disabledBackgroundImage = GetDisabledBackgroundImage(); disabledBackgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + + disabledBackgroundImage.RelayoutRequestTree(); + + RelayoutRequest(); } bool PushButton::OnSelected() @@ -558,62 +578,31 @@ void PushButton::OnControlSizeSet( const Vector3& targetSize ) Vector3 PushButton::GetNaturalSize() { - Vector3 size = Control::GetNaturalSize(); + Vector3 size; - const bool widthIsZero = EqualsZero( size.width ); - const bool heightIsZero = EqualsZero( size.height ); - - if( widthIsZero || heightIsZero ) + // If background and background not scale9 try get size from that + ImageActor imageActor = FindImageActor( GetButtonImage() ); + if( imageActor && imageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH ) { - // If background and background not scale9 try get size from that - ImageActor imageActor = FindImageActor( GetButtonImage() ); - if( imageActor && imageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH ) - { - Vector3 imageSize = imageActor.GetNaturalSize(); - - if( widthIsZero ) - { - size.width = imageSize.width; - } - - if( heightIsZero ) - { - size.height = imageSize.height; - } - } - - ImageActor backgroundImageActor = FindImageActor( GetBackgroundImage() ); - if( backgroundImageActor && backgroundImageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH ) - { - Vector3 imageSize = backgroundImageActor.GetNaturalSize(); - - if( widthIsZero ) - { - size.width = std::max( size.width, imageSize.width ); - } - - if( heightIsZero ) - { - size.height = std::max( size.height, imageSize.height ); - } - } + size.width = imageActor.GetRelayoutSize( WIDTH ); + size.height = imageActor.GetRelayoutSize( HEIGHT ); + } - // If label, test against it's size - Toolkit::TextView textView = Toolkit::TextView::DownCast( GetLabel() ); - if( textView ) - { - Vector3 textViewSize = textView.GetNaturalSize(); + ImageActor backgroundImageActor = FindImageActor( GetBackgroundImage() ); + if( backgroundImageActor && backgroundImageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH ) + { + size.width = std::max( size.width, backgroundImageActor.GetRelayoutSize( WIDTH ) ); + size.height = std::max( size.height, backgroundImageActor.GetRelayoutSize( HEIGHT ) ); + } - if( widthIsZero ) - { - size.width = std::max( size.width, textViewSize.width + TEXT_PADDING * 2.0f ); - } + // If label, test against it's size + Toolkit::TextView textView = Toolkit::TextView::DownCast( GetLabel() ); + if( textView ) + { + Vector3 textViewSize = textView.GetNaturalSize(); - if( heightIsZero ) - { - size.height = std::max( size.height, textViewSize.height + TEXT_PADDING * 2.0f ); - } - } + size.width = std::max( size.width, textViewSize.width + TEXT_PADDING * 2.0f ); + size.height = std::max( size.height, textViewSize.height + TEXT_PADDING * 2.0f ); } return size; diff --git a/dali-toolkit/internal/controls/popup/popup-impl.cpp b/dali-toolkit/internal/controls/popup/popup-impl.cpp index 7b8e420..69df006 100755 --- a/dali-toolkit/internal/controls/popup/popup-impl.cpp +++ b/dali-toolkit/internal/controls/popup/popup-impl.cpp @@ -223,11 +223,10 @@ void Popup::SetBackgroundImage( Actor image ) // OnDialogTouched only consume the event. It prevents the touch event to be caught by the backing. mBackgroundImage.TouchedSignal().Connect( this, &Popup::OnDialogTouched ); - mBackgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mBackgroundImage.SetResizePolicy( SIZE_FIXED_OFFSET_FROM_PARENT, ALL_DIMENSIONS ); mBackgroundImage.SetAnchorPoint( AnchorPoint::CENTER ); mBackgroundImage.SetParentOrigin( ParentOrigin::CENTER ); - mBackgroundImage.SetSizeMode( SIZE_FIXED_OFFSET_FROM_PARENT ); Vector3 border( mPopupStyle->backgroundOuterBorder.x, mPopupStyle->backgroundOuterBorder.z, 0.0f ); mBackgroundImage.SetSizeModeFactor( border ); @@ -288,7 +287,7 @@ void Popup::SetTitle( Toolkit::TextView titleActor ) { mTitle.SetPadding( Padding( 0.0f, 0.0f, mPopupStyle->margin, mPopupStyle->margin ) ); mTitle.SetResizePolicy( FILL_TO_PARENT, WIDTH ); - mTitle.SetDimensionDependency( HEIGHT, WIDTH ); // HeightForWidth + mTitle.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); mPopupLayout.AddChild( mTitle, Toolkit::TableView::CellPosition( 0, 0 ) ); } diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp index fbc3626..9ac90b9 100644 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -471,8 +471,7 @@ void ItemView::ActivateLayout(unsigned int layoutIndex, const Vector3& targetSiz if(mActiveLayout->GetItemSize(itemId, targetSize, size)) { // resize immediately - actor.SetResizePolicy( FIXED, ALL_DIMENSIONS ); - actor.SetPreferredSize( size.GetVectorXY() ); + actor.SetSize( size.GetVectorXY() ); } mActiveLayout->ApplyConstraints(actor, itemId, durationSeconds, mScrollPositionObject, Self() ); @@ -994,8 +993,7 @@ void ItemView::SetupActor( Item item, float durationSeconds ) Vector3 size; if( mActiveLayout->GetItemSize( item.first, mActiveLayoutTargetSize, size ) ) { - item.second.SetResizePolicy( FIXED, ALL_DIMENSIONS ); - item.second.SetPreferredSize( size.GetVectorXY() ); + item.second.SetSize( size.GetVectorXY() ); } mActiveLayout->ApplyConstraints( item.second, item.first, durationSeconds, mScrollPositionObject, Self() ); diff --git a/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp b/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp index 5ce5e22..a1ad3b6 100644 --- a/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp +++ b/dali-toolkit/internal/controls/shadow-view/shadow-view-impl.cpp @@ -168,6 +168,7 @@ void ShadowView::SetShadowPlane(Actor shadowPlane) mShadowPlaneBg = shadowPlane; mShadowPlane = ImageActor::New(); + mShadowPlane.SetName( "SHADOW_PLANE" ); mShadowPlane.SetParentOrigin(ParentOrigin::CENTER); mShadowPlane.SetAnchorPoint(AnchorPoint::CENTER); @@ -275,8 +276,9 @@ void ShadowView::OnInitialize() mBlurFilter.SetPixelFormat(Pixel::RGBA8888); mBlurRootActor = Actor::New(); - + mBlurRootActor.SetName( "BLUR_ROOT_ACTOR" ); mBlurRootActor.SetRelayoutEnabled( true ); + // Turn off inheritance to ensure filter renders properly mBlurRootActor.SetPositionInheritanceMode(USE_PARENT_POSITION); mBlurRootActor.SetInheritOrientation(false); diff --git a/dali-toolkit/internal/controls/text-input/text-input-handles-impl.cpp b/dali-toolkit/internal/controls/text-input/text-input-handles-impl.cpp index aa5ca7d..8249889 100644 --- a/dali-toolkit/internal/controls/text-input/text-input-handles-impl.cpp +++ b/dali-toolkit/internal/controls/text-input/text-input-handles-impl.cpp @@ -62,7 +62,7 @@ Actor CreateGrabArea( const std::string& name, const Vector3& relativeScale ) Actor handleGrabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move handleGrabArea.SetName( name ); - handleGrabArea.SetSizeMode( SIZE_RELATIVE_TO_PARENT ); + handleGrabArea.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); handleGrabArea.SetSizeModeFactor( relativeScale ); handleGrabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); diff --git a/dali-toolkit/internal/controls/text-input/text-input-impl.cpp b/dali-toolkit/internal/controls/text-input/text-input-impl.cpp index 304e560..fc289f8 100644 --- a/dali-toolkit/internal/controls/text-input/text-input-impl.cpp +++ b/dali-toolkit/internal/controls/text-input/text-input-impl.cpp @@ -3036,7 +3036,7 @@ void TextInput::CreateGrabArea( Actor& parent ) mGrabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move mGrabArea.SetName( "GrabArea" ); mGrabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); - mGrabArea.SetSizeMode( SIZE_RELATIVE_TO_PARENT ); + mGrabArea.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); mGrabArea.SetSizeModeFactor( DEFAULT_GRAB_HANDLE_RELATIVE_SIZE ); mGrabArea.TouchedSignal().Connect(this,&TextInput::OnPressDown); mTapDetector.Attach( mGrabArea ); @@ -3273,7 +3273,7 @@ void TextInput::CreateSelectionHandles( std::size_t start, std::size_t end, Dali mHandleOneGrabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move mHandleOneGrabArea.SetName("SelectionHandleOneGrabArea"); - mHandleOneGrabArea.SetSizeMode( SIZE_RELATIVE_TO_PARENT ); + mHandleOneGrabArea.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); mHandleOneGrabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE ); mHandleOneGrabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); @@ -3301,7 +3301,7 @@ void TextInput::CreateSelectionHandles( std::size_t start, std::size_t end, Dali mHandleTwoGrabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move mHandleTwoGrabArea.SetName("SelectionHandleTwoGrabArea"); - mHandleTwoGrabArea.SetSizeMode( SIZE_RELATIVE_TO_PARENT ); + mHandleTwoGrabArea.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS ); mHandleTwoGrabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE ); mHandleTwoGrabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); diff --git a/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp b/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp index 73654a4..274ca56 100644 --- a/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp +++ b/dali-toolkit/internal/controls/tool-bar/tool-bar-impl.cpp @@ -74,7 +74,7 @@ void ToolBar::SetBackground( Actor background ) // ToolBar image background.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); background.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); - background.SetPreferredSize( Vector2( mToolBarSize.width, mToolBarSize.height ) ); + background.SetSize( Vector2( mToolBarSize.width, mToolBarSize.height ) ); RenderableActor renderableActor = RenderableActor::DownCast( background ); if ( renderableActor ) @@ -359,7 +359,7 @@ void ToolBar::OnControlChildAdd(Actor& child) void ToolBar::OnControlSizeSet( const Vector3& targetSize ) { mToolBarSize = targetSize; - mBackground.SetPreferredSize( Vector2( mToolBarSize.width, mToolBarSize.height ) ); + mBackground.SetSize( Vector2( mToolBarSize.width, mToolBarSize.height ) ); } } // namespace Internal diff --git a/dali-toolkit/internal/filters/blur-two-pass-filter.cpp b/dali-toolkit/internal/filters/blur-two-pass-filter.cpp index ee152de..af62fb3 100644 --- a/dali-toolkit/internal/filters/blur-two-pass-filter.cpp +++ b/dali-toolkit/internal/filters/blur-two-pass-filter.cpp @@ -142,7 +142,7 @@ void BlurTwoPassFilter::Enable() // create actor to render input with applied emboss effect mActorForInput = ImageActor::New( mInputImage ); mActorForInput.SetParentOrigin( ParentOrigin::CENTER ); - mActorForInput.SetSize(mTargetSize); + mActorForInput.SetSize( mTargetSize ); mActorForInput.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // create internal offscreen for result of horizontal pass @@ -151,7 +151,7 @@ void BlurTwoPassFilter::Enable() // create an actor to render mImageForHorz for vertical blur pass mActorForHorz = ImageActor::New( mImageForHorz ); mActorForHorz.SetParentOrigin( ParentOrigin::CENTER ); - mActorForHorz.SetSize(mTargetSize); + mActorForHorz.SetSize( mTargetSize ); mActorForHorz.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // create internal offscreen for result of the two pass blurred image @@ -160,7 +160,7 @@ void BlurTwoPassFilter::Enable() // create an actor to blend the blurred image and the input image with the given blur strength mActorForBlending = ImageActor::New( mBlurredImage ); mActorForBlending.SetParentOrigin( ParentOrigin::CENTER ); - mActorForBlending.SetSize(mTargetSize); + mActorForBlending.SetSize( mTargetSize ); mActorForBlending.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); mRootActor.Add( mActorForInput ); diff --git a/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp b/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp index 2872ffa..1a58f8d 100644 --- a/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp +++ b/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.cpp @@ -116,10 +116,10 @@ void CubeTransitionEffect::Initialize() // helper actor to create a off-screen image using shader effect mEmptyImage = ImageActor::New( placeHolder ); + mEmptyImage.SetRelayoutEnabled( false ); mEmptyImage.SetSize(Stage::GetCurrent().GetSize()); mEmptyImage.SetParentOrigin( ParentOrigin::CENTER ); mEmptyImage.SetAnchorPoint( AnchorPoint::CENTER ); - mEmptyImage.SetRelayoutEnabled( false ); mFullImageCreator = FullAreaImageCreator::New(); mEmptyImage.SetShaderEffect( mFullImageCreator ); Stage::GetCurrent().Add(mEmptyImage); @@ -140,9 +140,9 @@ void CubeTransitionEffect::Initialize() ImageActor CubeTransitionEffect::CreateTile( Image image, const Vector4& color ) { ImageActor tile = ImageActor::New( image ); + tile.SetRelayoutEnabled( false ); tile.SetParentOrigin( ParentOrigin::CENTER ); tile.SetAnchorPoint( AnchorPoint::CENTER ); - tile.SetRelayoutEnabled( false ); tile.SetSize( mTileSize ); tile.SetColorMode( Dali::USE_OWN_COLOR ); tile.SetColor( color ); diff --git a/dali-toolkit/public-api/controls/buttons/push-button.cpp b/dali-toolkit/public-api/controls/buttons/push-button.cpp index 2e2d857..f128778 100644 --- a/dali-toolkit/public-api/controls/buttons/push-button.cpp +++ b/dali-toolkit/public-api/controls/buttons/push-button.cpp @@ -76,7 +76,9 @@ PushButton PushButton::DownCast( BaseHandle handle ) void PushButton::SetButtonImage( Image image ) { - Dali::Toolkit::GetImplementation( *this ).SetButtonImage( ImageActor::New( image ) ); + Actor imageActor = ImageActor::New( image ); + imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); + Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageActor ); } void PushButton::SetButtonImage( Actor image ) @@ -91,7 +93,9 @@ Actor PushButton::GetButtonImage() const void PushButton::SetBackgroundImage( Image image ) { - Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( ImageActor::New( image ) ); + Actor imageActor = ImageActor::New( image ); + imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); + Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( imageActor ); } void PushButton::SetBackgroundImage( Actor image ) @@ -106,7 +110,9 @@ Actor PushButton::GetBackgroundImage() const void PushButton::SetSelectedImage( Image image ) { - Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( ImageActor::New( image ) ); + Actor imageActor = ImageActor::New( image ); + imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); + Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageActor ); } void PushButton::SetSelectedImage( Actor image ) @@ -136,7 +142,9 @@ Actor PushButton::GetSelectedBackgroundImage() const void PushButton::SetDisabledBackgroundImage( Image image ) { - Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( ImageActor::New( image ) ); + Actor imageActor = ImageActor::New( image ); + imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); + Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( imageActor ); } void PushButton::SetDisabledBackgroundImage( Actor image ) @@ -151,7 +159,9 @@ Actor PushButton::GetDisabledBackgroundImage() const void PushButton::SetDisabledImage( Image image ) { - Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( ImageActor::New( image ) ); + Actor imageActor = ImageActor::New( image ); + imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS ); + Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( imageActor ); } void PushButton::SetDisabledImage( Actor image ) diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 19f2619..39fa68a 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -138,8 +138,12 @@ void SetupBackgroundActor( Actor actor, Property::Index constrainingIndex, const actor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION ); actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR ); actor.SetZ( BACKGROUND_ACTOR_Z_POSITION ); - actor.SetRelayoutEnabled( true ); - actor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + actor.SetRelayoutEnabled( false ); + + Constraint constraint = Constraint::New( constrainingIndex, + ParentSource( Actor::Property::SIZE ), + EqualToConstraint() ); + actor.ApplyConstraint( constraint ); } } // unnamed namespace diff --git a/docs/content/programming-guide/size-negotiation-controls.h b/docs/content/programming-guide/size-negotiation-controls.h index 641da16..1663e79 100644 --- a/docs/content/programming-guide/size-negotiation-controls.h +++ b/docs/content/programming-guide/size-negotiation-controls.h @@ -65,8 +65,7 @@ mBacking.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); @endcode The popup control is added to the layer and a background image is specified to fill the size of the popup and add a border by the following. @code -mBackgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); -mBackgroundImage.SetSizeMode( SIZE_FIXED_OFFSET_FROM_PARENT ); +mBackgroundImage.SetResizePolicy( SIZE_FIXED_OFFSET_FROM_PARENT, ALL_DIMENSIONS ); Vector3 border( mPopupStyle->backgroundOuterBorder.x, mPopupStyle->backgroundOuterBorder.z, 0.0f ); mBackgroundImage.SetSizeModeFactor( border ); @endcode diff --git a/docs/content/programming-guide/size-negotiation.h b/docs/content/programming-guide/size-negotiation.h index 536a8f8..c8bcb89 100644 --- a/docs/content/programming-guide/size-negotiation.h +++ b/docs/content/programming-guide/size-negotiation.h @@ -29,9 +29,11 @@ If a method can process width and height at the same time then the ALL_DIMENSION The ResizePolicy enum specifies a range of options for controlling the way actors resize. These are powerful rules that enable much automatic resizing behaviour. They are as following: -- FIXED: This is the option to use when you want the specific definite size as set by SetPreferredSize +- FIXED: This is the option to use when you want the specific definite size as set by SetSize (This is the default for all actors) - USE_NATURAL_SIZE: Use this option for objects such as images or text to get their natural size e.g. The dimensions of the image, or the size of the text without wrapping. Also use this on TableViews when the size of the table is dependent on its children. - FILL_TO_PARENT: Size will fill up to the size of its parent's size, taking a size factor into account to allow proportionate filling +- SIZE_RELATIVE_TO_PARENT: Fill up the parent with a relative scale. Use SetSizeModeFactor to specify the ratio to fill up to the parent. +- SIZE_FIXED_OFFSET_FROM_PARENT: Fill up the parent and add a fixed offset using SetSizeModeFactor. - FIT_TO_CHILDREN: Size will scale around the size of the actor's children. E.g. A popup's height may resize itself around it's contents. - DIMENSION_DEPENDENCY: This covers rules such as width-for-height and height-for-width. You specify that one dimension depends on another. @@ -44,13 +46,17 @@ This section details how an actor may be used with size negotiation.

Enabling Size Negotiation

The first thing to do is to specify whether you want an actor to be included or excluded from the relayout process. The following method is used to enable or disable the relayout -for an individual actor. +for an individual actor. Make sure this is the first thing that is called after the actor is created otherwise the actor may still be negotiated. @code void SetRelayoutEnabled( bool enabled ) @endcode Text and image actors have relayout enabled by default, while a plain Actor is disabled. Be aware that if desiring to use an Actor in relayout then relayout needs to be explicitly enabled first.

Specifying Size Policies

+Actors have different size policies by default. For example ImageActor is set to USE_NATURAL_SIZE. This ensures that when an image actor is +placed on the stage it will use its natural size by default. However if the user calls SetSize with non-zero sizes on the image actor then the current +size policy is overridden by the FIXED size policy and the actor will take on the size specified. + The next step is to specify how an actor will be size negotiated. The resize policies for an actor may be specified by the following method: @code void SetResizePolicy( ResizePolicy policy, Dimension dimension ) @endcode It is common to specifiy different policies for the different dimensions of width and height to achive different layouts. Different actors have @@ -81,24 +87,20 @@ After: This example shows an actor rootActor set to expand to its parent's width and contract/expand around its child's height. The child image actor is set to natural size which means it will display at the acutal size of the image. -To specify that a dimension has a dependency on another dimension use the following method. Calling this method will automatically set the resize policy to be DIMENSION_DEPENDENCY -for the given dimension. -@code void SetDimensionDependency( Dimension dimension, Dimension dependency ) @endcode -For example if dimension is HEIGHT and dependency is WIDTH then there is a height-for-width dependency in effect. The classic use case for this +To specify that a dimension has a dependency on another dimension use DIMENSION_DEPENDENCY. For example if dimension is HEIGHT and dependency is +WIDTH then there is a height-for-width dependency in effect. The classic use case for this is a text view that wraps its text. The following example snippet shows a text view that expands its width to the size of its parent, wraps its contents and then determines its height based on the width. @code TextView text = TextView::New( "Example" ); text.SetMultilinePolicy( SplitByWord ); text.SetResizePolicy( FILL_TO_PARENT, WIDTH ); -text.SetDimensionDependency( HEIGHT, WIDTH ); +text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); @endcode

Specifying Sizes and Size Limits

-When wanting a specific fixed size for an actor then specify the resize policy to be FIXED and set the desired, or preferred size using the following method. -This method is to be used instead of SetSize when wishing to specify a size for an actor being size negotiated. -@code void SetPreferredSize( const Vector2& size ) @endcode +When wanting a specific fixed size for an actor then specify the resize policy to be FIXED and set the desired, or preferred size using SetSize. If only one dimension is FIXED then the other value in the size parameter will be ignored, so it is safe to set it to zero. To constrain the final negotiated size of an actor, set the following for minimum and maximum sizes respectively. @@ -109,14 +111,6 @@ void SetMaximumSize( const Vector2& size )

Altering Negotiated Size

-The following method specifies a size mode to use. Use one of: USE_OWN_SIZE, SIZE_RELATIVE_TO_PARENT or SIZE_FIXED_OFFSET_FROM_PARENT. SIZE_RELATIVE_TO_PARENT will -scale the image relative to it's parent size when the resize policy of FILL_TO_PARENT is in effect. While SIZE_FIXED_OFFSET_FROM_PARENT will -add an offset to this parent size, for example when wanting an image to act as a border around its parent. -@code void SetSizeMode( const SizeMode mode ) @endcode - -Use the following with SetSizeMode to specify either the size relative to parent or the fixed offset to apply. -@code void SetSizeModeFactor( const Vector3& factor ) @endcode - When an actor is required to maintain the aspect ratio of its natural size the following method can be used. This is useful for size negotiating images to ensure they maintain their aspect ratio while still fitting within the bounds they have been allocated. This can be one of USE_SIZE_SET, FIT_WITH_ASPECT_RATIO or FILL_WITH_ASPECT_RATIO. The first is the default. The second will fit the actor within the bounds it has been allocated while maintaining aspect ratio. The @@ -152,14 +146,14 @@ text.SetMultilinePolicy( Toolkit::TextView::SplitByWord ); text.SetWidthExceedPolicy( Toolkit::TextView::Split ); text.SetLineJustification( Toolkit::TextView::Left ); text.SetResizePolicy( FILL_TO_PARENT, WIDTH ); -text.SetDimensionDependency( HEIGHT, WIDTH ); +text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) ); // Image ImageActor image = ImageActor::New( ResourceImage::New( IMAGE1 ) ); image.SetResizePolicy( FILL_TO_PARENT, WIDTH ); -image.SetDimensionDependency( HEIGHT, WIDTH ); +image.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) ); content.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) ); @@ -176,8 +170,7 @@ Dali::Image checked = Dali::ResourceImage::New( CHECKBOX_CHECKED_IMAGE ); Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New(); checkBox.SetBackgroundImage( unchecked ); checkBox.SetSelectedImage( checked ); -checkBox.SetPreferredSize( Vector2( 48, 48 ) ); -checkBox.SetResizePolicy( FIXED, ALL_DIMENSIONS ); +checkBox.SetSize( Vector2( 48, 48 ) ); root.AddChild( checkBox, Toolkit::TableView::CellPosition( 0, 0 ) ); @@ -213,13 +206,13 @@ will result in a text view that fills up its width to available space in the tab height based on its new width. The table view will then fit its height taking the height of the text view into account. @code text.SetResizePolicy( FILL_TO_PARENT, WIDTH ); -text.SetDimensionDependency( HEIGHT, WIDTH ); +text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); @endcode The image view performs a similar relayout. It fits its width to the size of the cell and calculates its height based on the new width. Some padding is added to the left of it as well to center it more. @code image.SetResizePolicy( FILL_TO_PARENT, WIDTH ); -image.SetDimensionDependency( HEIGHT, WIDTH ); +image.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT ); image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) ); @endcode The sub table view is similar as well in that it expands its width to the size of its cell. When it is added to the table view it diff --git a/plugins/dali-script-v8/src/constants/constants-wrapper.cpp b/plugins/dali-script-v8/src/constants/constants-wrapper.cpp index 938e485..9815aa7 100644 --- a/plugins/dali-script-v8/src/constants/constants-wrapper.cpp +++ b/plugins/dali-script-v8/src/constants/constants-wrapper.cpp @@ -201,10 +201,6 @@ const IntegerPair EnumTable[] = { "CULL_BACK_FACE", CullBack }, { "CULL_FRONT_AND_BACK_FACE", CullFrontAndBack }, - { "USE_OWN_SIZE", USE_OWN_SIZE }, - { "SIZE_RELATIVE_TO_PARENT", SIZE_RELATIVE_TO_PARENT }, - { "SIZE_FIXED_OFFSET_FROM_PARENT", SIZE_FIXED_OFFSET_FROM_PARENT }, - { "CAMERA_FREE_LOOK" , Camera::FREE_LOOK }, { "CAMERA_LOOK_AT_TARGET" , Camera::LOOK_AT_TARGET }, { "CAMERA_PERSPECTIVE_PROJECTION" , Camera::PERSPECTIVE_PROJECTION },