application.SendNotification();
Vector2 size( 100.0f, 200.0f );
- alignment.SetPreferredSize(size);
+ alignment.SetSize(size);
application.Render();
application.SendNotification();
// 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 );
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 );
Vector3 size;
CheckBoxButton checkBoxButton = CheckBoxButton::New();
+ checkBoxButton.SetName( "UtcDaliCheckBoxButtonSetImages" );
+ Stage::GetCurrent().Add( checkBoxButton );
application.SendNotification();
application.Render();
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;
}
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 );
{
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);
{
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);
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();
application.Render();
application.SendNotification();
- dummy.SetPreferredSize(size);
+ dummy.SetSize(size);
application.Render();
application.SendNotification();
dummy.SetRelayoutEnabled( true );
DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(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);
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);
dummy.SetRelayoutEnabled( true );
DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(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);
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);
factory.EnableOffscreenRendering( );
PageTurnView pageTurnView = PageTurnLandscapeView::New( factory, PAGE_SIZE );
+ pageTurnView.SetRelayoutEnabled( false );
pageTurnView.SetPositionInheritanceMode( USE_PARENT_POSITION );
Stage::GetCurrent().Add( pageTurnView );
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 );
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 );
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 );
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
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();
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;
}
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;
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 );
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 ) );
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 ) );
// 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
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();
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();
view.SetRelayoutEnabled( true );
Stage::GetCurrent().Add( view );
- view.SetPreferredSize( Vector2( 480, 800 ) );
+ view.SetSize( Vector2( 480, 800 ) );
view.OrientationAnimationStartedSignal().Connect( &StartAnimation );
Actor& buttonImage = GetButtonImage();
buttonImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+
+ buttonImage.RelayoutRequestTree();
+
+ RelayoutRequest();
}
void PushButton::OnSelectedImageSet()
Actor& selectedImage = GetSelectedImage();
selectedImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+
+ selectedImage.RelayoutRequestTree();
+
+ RelayoutRequest();
}
void PushButton::OnBackgroundImageSet()
Actor& backgroundImage = GetBackgroundImage();
backgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+
+ backgroundImage.RelayoutRequestTree();
+
+ RelayoutRequest();
}
void PushButton::OnSelectedBackgroundImageSet()
Actor& disabledImage = GetDisabledImage();
disabledImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+
+ disabledImage.RelayoutRequestTree();
+
+ RelayoutRequest();
}
void PushButton::OnDisabledBackgroundImageSet()
Actor& disabledBackgroundImage = GetDisabledBackgroundImage();
disabledBackgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+
+ disabledBackgroundImage.RelayoutRequestTree();
+
+ RelayoutRequest();
}
bool PushButton::OnSelected()
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;
// 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 );
{
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 ) );
}
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() );
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() );
mShadowPlaneBg = shadowPlane;
mShadowPlane = ImageActor::New();
+ mShadowPlane.SetName( "SHADOW_PLANE" );
mShadowPlane.SetParentOrigin(ParentOrigin::CENTER);
mShadowPlane.SetAnchorPoint(AnchorPoint::CENTER);
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);
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 );
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 );
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 );
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 );
// 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 )
void ToolBar::OnControlSizeSet( const Vector3& targetSize )
{
mToolBarSize = targetSize;
- mBackground.SetPreferredSize( Vector2( mToolBarSize.width, mToolBarSize.height ) );
+ mBackground.SetSize( Vector2( mToolBarSize.width, mToolBarSize.height ) );
}
} // namespace Internal
// 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
// 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
// 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 );
// 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);
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 );
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 )
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 )
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 )
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 )
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 )
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<Vector3>( constrainingIndex,
+ ParentSource( Actor::Property::SIZE ),
+ EqualToConstraint() );
+ actor.ApplyConstraint( constraint );
}
} // unnamed namespace
@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
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.
<h3>Enabling Size Negotiation</h3>
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.
<h3>Specifying Size Policies</h3>
+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
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
<h3>Specifying Sizes and Size Limits</h3>
-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.
<h3>Altering Negotiated Size</h3>
-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
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 ) );
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 ) );
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
{ "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 },