[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / docs / content / programming-guide / size-negotiation.h
index 92beacd..d33109b 100644 (file)
@@ -49,17 +49,17 @@ Text and image actors have relayout enabled by default, while a plain Actor is d
 
 <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
+Actors have different size policies by default. For example ImageView 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::Type policy, Dimension::Type dimension ) @endcode
 It is common to specifiy different policies for the different dimensions of width and height to achive different layouts. Different actors have
-different resize policies specified by default. For example ImageActors are set to use USE_NATURAL_SIZE.
+different resize policies specified by default. For example ImageViews are set to use USE_NATURAL_SIZE.
 
 The following example code snippet shows rootActor having its width policy set to ResizePolicy::FILL_TO_PARENT and its height policy set to ResizePolicy::FIT_TO_CHILDREN.
-It has an ImageActor added to it with an explicit call to USE_NATURAL_SIZE in both dimensions called on it. This will make an actor that will
+It has an ImageView added to it with an explicit call to USE_NATURAL_SIZE in both dimensions called on it. This will make an actor that will
 fill up the space of its parent in the width dimension and fit to its child in the height dimension. As the image actor child is using natural size
 the height of the root actor will fit to the height of the child image.
 
@@ -67,7 +67,7 @@ the height of the root actor will fit to the height of the child image.
 Actor rootActor = Actor::New();
 rootActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
 rootActor.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
-ImageActor image = ImageActor::New( Image::New( MY_IMAGE_PATH ) );
+Toolkit::ImageView image = Toolkit::ImageView::New( MY_IMAGE_PATH );
 image.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
 rootActor.Add( image );
 @endcode
@@ -99,8 +99,8 @@ If only one dimension is FIXED then the other value in the size parameter will b
 
 To constrain the final negotiated size of an actor, set the following for minimum and maximum sizes respectively.
 @code
-void SetMinimumSize( const Vector2& size )
-void SetMaximumSize( const Vector2& size )
+actor.SetProperty( Actor::Property::MINIMUM_SIZE, minSize );
+actor.SetProperty( Actor::Property::MAXIMUM_SIZE, maxSize );
 @endcode
 
 <h3>Altering Negotiated Size</h3>
@@ -109,13 +109,13 @@ When an actor is required to maintain the aspect ratio of its natural size the f
 to ensure they maintain their aspect ratio while still fitting within the bounds they have been allocated. This can be one of SizeScalePolicy::USE_SIZE_SET, SizeScalePolicy::FIT_WITH_ASPECT_RATIO
 or SizeScalePolicy::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
 third will fill all available space, potentially overflowing its bounds, while maintaining apsect ratio.
-@code void SetSizeScalePolicy( SizeScalePolicy::Type policy ) @endcode
+@code actor.SetProperty( Actor::Property::SIZE_SCALE_POLICY, policy ); @endcode
 
 <h3>Using Actors in Containers</h3>
 
 When laying out actors in containers such as TableView it is useful to be able to specify padding that surrounds the actor. E.g. You may
 want some white space around an image actor placed in a table cell. The padding specifies the left, right, bottom and top padding values.
-@code void SetPadding( const Padding& padding ) @endcode
+@code actor.SetProperty( Actor::Property::PADDING, padding ); @endcode
 
 <h2 class="pg">An Example</h2>
 
@@ -131,7 +131,7 @@ content.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
 content.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
 content.SetFitHeight( 0 );
 content.SetFitHeight( 1 );
-content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) );
+content.SetProperty( Actor::Property::PADDING, Padding( 20.0f, 20.0f, 20.0f, 0.0f ) );
 
 // Text
 Toolkit::TextLabel text = Toolkit::TextLabel::New( "Do you really want to quit?" );
@@ -141,10 +141,10 @@ text.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT );
 content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) );
 
 // Image
-ImageActor image = ImageActor::New( ResourceImage::New( IMAGE1 ) );
+Toolkit::ImageView image = Toolkit::ImageView::New( IMAGE_PATH );
 image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
 image.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT );
-image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) );
+image.SetProperty( Actor::Property::PADDING, Padding( 20.0f, 0.0f, 0.0f, 0.0f ) );
 content.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) );
 
 // Checkbox and text
@@ -153,19 +153,19 @@ root.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
 root.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
 root.SetFitHeight( 0 );
 root.SetFitWidth( 0 );
-root.SetPadding( Padding( 0.0f, 0.0f, 0.0f, 20.0f ) );
+root.SetProperty( Actor::Property::PADDING, Padding( 0.0f, 0.0f, 0.0f, 20.0f ) );
 
 Dali::Image unchecked = Dali::ResourceImage::New( CHECKBOX_UNCHECKED_IMAGE );
 Dali::Image checked = Dali::ResourceImage::New( CHECKBOX_CHECKED_IMAGE );
 Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New();
 checkBox.SetBackgroundImage( unchecked );
 checkBox.SetSelectedImage( checked );
-checkBox.SetSize( Vector2( 48, 48 ) );
+checkBox.SetProperty( Actor::Property::SIZE, Vector2( 48, 48 ) );
 
 root.AddChild( checkBox, Toolkit::TableView::CellPosition( 0, 0 ) );
 
 Toolkit::TextLabel text2 = Toolkit::TextLabel::New( "Don't show again" );
-text2.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 10.0f ) );
+text2.SetProperty( Actor::Property::PADDING, Padding( 20.0f, 0.0f, 0.0f, 10.0f ) );
 
 root.AddChild( text2, Toolkit::TableView::CellPosition( 0, 1 ) );
 
@@ -187,7 +187,7 @@ content.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
 @endcode
 To add a little space around the left, right and bottom of the table view, some padding is added.
 @code
-content.SetPadding( Padding( 20.0f, 20.0f, 20.0f, 0.0f ) );
+content.SetProperty( Actor::Property::PADDING, Padding( 20.0f, 20.0f, 20.0f, 0.0f ) );
 @endcode
 The first text view has its width set to ResizePolicy::FILL_TO_PARENT and its height has a dimension dependency on its width. This
 will result in a text view that fills up its width to available space in the table cell and then then calculates its
@@ -201,7 +201,7 @@ width. Some padding is added to the left of it as well to center it more.
 @code
 image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
 image.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT );
-image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) );
+image.SetProperty( Actor::Property::PADDING, 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
 will span two columns. Its height is set to natural size so that it will grow or shrink based on its children cells. Note that for
@@ -244,7 +244,7 @@ PushButton, OKAY_BUTTON - Pos: [185, 0, 0.1] Size: [165, 76, 76], Dirty: (FALSE,
 
 The format is as follows:
 
-[Actor type], [Actor name]  Pos:[X, Y, Z] Size[Dimension::WIDTH, Dimension::HEIGHT, DEPTH], Dirty:(Dimension::WIDTH, Dimension::HEIGHT), Negotiated: (Dimension::WIDTH, Dimension::HEIGHT), Enabled: BOOLEAN, (Object address)
+[Actor type], [Actor name] ? Pos:[X, Y, Z] Size[Dimension::WIDTH, Dimension::HEIGHT, DEPTH], Dirty:(Dimension::WIDTH, Dimension::HEIGHT), Negotiated: (Dimension::WIDTH, Dimension::HEIGHT), Enabled: BOOLEAN, (Object address)
 - <i>Actor type</i>: The type name of the actor E.g. PushButton
 - <i>Actor name</i>: The name set on the actor with SetName(). Useful for debugging.
 - <i>Pos</i>: The position of the actor