namespace Toolkit
{
-Control CreateLeafControl( int width, int height )
+std::string CreateImageURL( Vector4 color, ImageDimensions size )
{
- auto control = Control::New();
- control.SetName( "Leaf" );
-
- auto pixelBuffer = Devel::PixelBuffer::New( 1, 1, Pixel::RGB888 );
+ auto pixelBuffer = Devel::PixelBuffer::New( size.GetWidth(), size.GetHeight(), Pixel::RGB888 );
unsigned char* pixels = pixelBuffer.GetBuffer();
- pixels[0] = 0xff;
- pixels[1] = 0x00;
- pixels[2] = 0x00;
- auto texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGB888, 1, 1 );
+ pixels[0] = static_cast<unsigned char>( color.r );
+ pixels[1] = static_cast<unsigned char>( color.g );
+ pixels[2] = static_cast<unsigned char>( color.b );
+ auto texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGB888, size.GetWidth(), size.GetHeight() );
auto pixelData = Devel::PixelBuffer::Convert( pixelBuffer );
texture.Upload( pixelData );
- std::string url = TextureManager::AddTexture( texture );
+ return TextureManager::AddTexture( texture );
+}
+
+Control CreateLeafControl( int width, int height )
+{
+ auto control = Control::New();
+ control.SetName( "Leaf" );
+ std::string url = CreateImageURL( Vector4( 255, 0, 0, 255 ), ImageDimensions( 1, 1 ) );
Property::Map map;
map[ Visual::Property::TYPE ] = Visual::IMAGE;
return control;
}
+TextLabel CreateTextLabel( const char* text )
+{
+ TextLabel textLabel = TextLabel::New(text);
+ textLabel.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+ textLabel.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
+ textLabel.SetName( "TextLabel" );
+ textLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ return textLabel;
+}
+
+ImageView CreateImageView( std::string& url, ImageDimensions size )
+{
+ ImageView imageView = ImageView::New( url, size );
+ imageView.SetName( "ImageView" );
+ imageView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ return imageView;
+}
+
} // namespace Toolkit
} // namespace Dali
{
/**
+ * @brief Creates an empty image buffer filled with the color for layout tests
+ *
+ * @param[in] color The color of the image buffer.
+ * @param[in] size The size of the image buffer.
+ * @param[out] string The url.
+ */
+std::string CreateImageURL( Vector4 color, ImageDimensions size );
+
+/**
* @brief Creates an empty leaf control filled with red color for layout tests
*
* @param[in] width The width of the control.
*/
Control CreateLeafControl( int width, int height );
+/**
+ * @brief Creates a text label for layout tests
+ *
+ * @param[in] text The text of the label.
+ * @param[out] TextLabel The text label.
+ */
+TextLabel CreateTextLabel( const char* text );
+
+/**
+ * @brief Creates an image view for layout tests
+ *
+ * @param[in] url The image url.
+ * @param[in] size The size of the image view.
+ * @param[out] ImageView The image view.
+ */
+ImageView CreateImageView( std::string& url, ImageDimensions size );
+
} // namespace Toolkit
} // namespace Dali
END_TEST;
}
+
+int UtcDaliLayouting_FlexLayout_NestedFlexboxWithSpec(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliLayouting_FlexLayout_NestedFlexboxWithSpec Test nested flex box with wrap content/match parent");
+
+ Stage stage = Stage::GetCurrent();
+
+ auto flexbox1 = Control::New();
+ auto flexLayout1 = FlexLayout::New();
+ DevelControl::SetLayout( flexbox1, flexLayout1 );
+ flexbox1.SetName( "Flexbox1");
+ flexbox1.SetParentOrigin( ParentOrigin::CENTER );
+ flexbox1.SetAnchorPoint( AnchorPoint::CENTER );
+
+ auto flexbox2 = Control::New();
+ auto flexLayout2 = FlexLayout::New();
+ DevelControl::SetLayout( flexbox2, flexLayout2 );
+ flexbox2.SetParentOrigin( ParentOrigin::CENTER );
+ flexbox2.SetAnchorPoint( AnchorPoint::CENTER );
+ flexbox2.SetName( "Flexbox2");
+ flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+ flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+
+ std::vector< Control > controls;
+ controls.push_back( CreateLeafControl( 100, 100 ) );
+ flexbox2.Add( controls[0] );
+ flexbox1.Add( flexbox2 );
+ stage.Add( flexbox1 );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ // Test flexbox2 is sized to wrap its content
+ DALI_TEST_EQUALS( flexbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( flexbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( flexbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( flexbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
+ flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ // Test flexbox2 width is sized to match parent
+ DALI_TEST_EQUALS( flexbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( flexbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( flexbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( flexbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+ flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ // Test flexbox2 height is sized to match parent
+ DALI_TEST_EQUALS( flexbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( flexbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( flexbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( flexbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
+ flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ // Test flexbox2 is sized to match its parent
+ DALI_TEST_EQUALS( flexbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( flexbox2.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( flexbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( flexbox2.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliLayouting_FlexLayout_WithTextLabel(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliLayouting_FlexLayout_WithTextLabel ");
+
+ Stage stage = Stage::GetCurrent();
+
+ auto flexbox1 = Control::New();
+ auto flexLayout1 = FlexLayout::New();
+ DevelControl::SetLayout( flexbox1, flexLayout1 );
+ flexbox1.SetName( "Flexbox1");
+ flexbox1.SetParentOrigin( ParentOrigin::CENTER );
+ flexbox1.SetAnchorPoint( AnchorPoint::CENTER );
+
+ std::vector< Control > controls;
+ controls.push_back( CreateTextLabel( "W" ) );
+ flexbox1.Add( controls[0] );
+ stage.Add( flexbox1 );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ // Test flexbox2 is sized to wrap its content
+ DALI_TEST_EQUALS( flexbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( flexbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ TextLabel::DownCast( controls[0] ).SetProperty( TextLabel::Property::TEXT, "WWWW" );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( flexbox1.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( flexbox1.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ END_TEST;
+}
#include <dali-toolkit/devel-api/image-loader/texture-manager.h>
#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <test-native-image.h>
#include <sstream>
END_TEST;
}
+
+int UtcDaliImageViewPaddingProperty(void)
+{
+ ToolkitTestApplication application;
+
+ ImageView imageView = ImageView::New();
+ Property::Map imagePropertyMap;
+ imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
+ imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/gallery-small-1.jpg" ;
+ imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
+ imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
+ imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
+ imageView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ imageView.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
+ Stage::GetCurrent().Add( imageView );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
+
+ ImageView childImage = ImageView::New();
+ childImage.SetBackgroundColor( Color::BLACK );
+ childImage.SetSize( 10.f, 10.f );
+ imageView.Add( childImage );
+
+ application.SendNotification();
+ application.Render();
+
+ // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
+ DALI_TEST_EQUALS( childImage.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 15, 5, 0 ), TEST_LOCATION );
+
+ // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
+ Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
+ Property::Map resultMap;
+ imageVisual.CreatePropertyMap( resultMap );
+
+ Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
+ DALI_TEST_CHECK( transformValue );
+ Property::Map* retMap = transformValue->GetMap();
+ DALI_TEST_CHECK( retMap );
+
+ // Image Visual should be positioned depending on ImageView's padding
+ DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliImageViewPaddingProperty02(void)
+{
+ ToolkitTestApplication application;
+
+ ImageView imageView = ImageView::New();
+ Property::Map imagePropertyMap;
+ imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
+ imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
+ imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
+ imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
+ imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
+ imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
+ imageView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ imageView.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
+ Stage::GetCurrent().Add( imageView );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
+
+ // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
+ Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
+ Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
+ Property::Map resultMap;
+ imageVisual.CreatePropertyMap( resultMap );
+
+ Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
+ DALI_TEST_CHECK( transformValue );
+ Property::Map* retMap = transformValue->GetMap();
+ DALI_TEST_CHECK( retMap );
+
+ // Image Visual should be positioned depending on ImageView's padding
+ DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
+
+ END_TEST;
+}
#include <iostream>
#include <stdlib.h>
#include <dali-toolkit-test-suite-utils.h>
+#include <toolkit-event-thread-callback.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/layouting/absolute-layout.h>
#include <dali-toolkit/devel-api/layouting/linear-layout.h>
+#include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
+#include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
#include <../custom-layout.h>
END_TEST;
}
-
int UtcDaliLayouting_HboxLayout07(void)
{
ToolkitTestApplication application;
Control control1 = CreateLeafControl( 40, 40 );
rootControl.Add( control1 );
-
auto hbox = Control::New();
auto hboxLayout = LinearLayout::New();
hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
END_TEST;
}
+namespace
+{
+const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/broken.png";
+}
+
+int UtcDaliLayouting_HboxLayout_ImageView(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliLayouting_HboxLayout - Use image view for leaf");
+
+ Stage stage = Stage::GetCurrent();
+ auto hbox = Control::New();
+ auto hboxLayout = LinearLayout::New();
+ DevelControl::SetLayout( hbox, hboxLayout );
+ hbox.SetName( "HBox" );
+
+ std::string url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 100, 100 ) );
+ ImageView imageView = CreateImageView( url, ImageDimensions() );
+
+ hbox.SetParentOrigin( ParentOrigin::CENTER );
+ hbox.SetAnchorPoint( AnchorPoint::CENTER );
+ hbox.Add( imageView );
+ stage.Add( hbox );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) );
+ imageView.SetImage( url );
+
+ // Ensure layouting happenss
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+ imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
+
+ // Ensure layouting happenss
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
+ imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+
+ // Ensure layouting happenss
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+ imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+
+ Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 );
+ imageView.SetImage( image );
+
+ // Ensure layouting happenss
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ Property::Map imagePropertyMap;
+ imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
+ imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME;
+ imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150;
+ imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150;
+ imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap );
+
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+ // Ensure layouting happenss
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( imageView.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliLayouting_HboxLayout_TextLabel(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf");
+
+ Stage stage = Stage::GetCurrent();
+
+ auto hbox = Control::New();
+ auto hboxLayout = LinearLayout::New();
+ DevelControl::SetLayout( hbox, hboxLayout );
+ hbox.SetName( "HBox" );
+ hbox.SetParentOrigin( ParentOrigin::CENTER );
+ hbox.SetAnchorPoint( AnchorPoint::CENTER );
+
+ std::vector< Control > controls;
+ TextLabel textLabel = CreateTextLabel( "W" );
+ controls.push_back( textLabel );
+ hbox.Add( textLabel );
+ stage.Add( hbox );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( textLabel.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 54.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 216.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+ controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
+ controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
// Padding tests
int UtcDaliLayouting_HboxLayout_Padding01(void)
int UtcDaliLayouting_HboxLayout_Padding03(void)
{
ToolkitTestApplication application;
- tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Adding Changing padding on a single child");
+ tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child");
Stage stage = Stage::GetCurrent();
auto hbox = Control::New();
END_TEST;
}
+int UtcDaliLayouting_HboxLayout_Padding04(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox");
+
+ // Adding padding to the layout should offset the positioning of the children.
+
+ const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
+ const Size CONTROL_SIZE = Size( 40, 40 );
+
+ Stage stage = Stage::GetCurrent();
+ // Create a root layout, ideally Dali would have a default layout in the root layer.
+ // Without this root layer the LinearLayout (or any other layout) will not
+ // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
+ // It uses the default stage size and ideally should have a layout added to it.
+ auto rootLayoutControl = Control::New();
+ rootLayoutControl.SetName( "AbsoluteLayout");
+ auto rootLayout = AbsoluteLayout::New();
+ DevelControl::SetLayout( rootLayoutControl, rootLayout );
+ rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
+ rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
+ stage.Add( rootLayoutControl );
+
+ auto hbox = Control::New();
+ auto hboxLayout = LinearLayout::New();
+ hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
+ DevelControl::SetLayout( hbox, hboxLayout );
+ hbox.SetName( "HBox");
+ hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
+ hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+ hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+
+ std::vector< Control > controls;
+ controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
+ controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
+ controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
+ controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
+
+ for( auto&& iter : controls )
+ {
+ hbox.Add( iter );
+ }
+
+ hbox.SetParentOrigin( ParentOrigin::CENTER );
+ hbox.SetAnchorPoint( AnchorPoint::CENTER );
+ rootLayoutControl.Add( hbox );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
+ application.SendNotification();
+
+ // hbox centers elements vertically, it fills test harness stage, which is 480x800.
+ // hbox left justifies elements
+ tet_infoline("Test Child Actor Position");
+
+ auto controlXPosition=0.0f;
+
+ controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
+ LAYOUT_PADDING.top,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+ controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
+ DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
+ LAYOUT_PADDING.top,
+ 0.0f ),
+ 0.0001f, TEST_LOCATION );
+
+ controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
+ DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
+ LAYOUT_PADDING.top,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+ controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
+ DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
+ LAYOUT_PADDING.top,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+ auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
+ auto totalControlsHeight = CONTROL_SIZE.height;
+
+ DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
+ totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+
+ END_TEST;
+}
+
+int UtcDaliLayouting_HboxLayout_Padding05(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding");
+
+ // Adding padding to the layout should offset the positioning of the children.
+
+ const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 );
+ const Size CONTROL_SIZE = Size( 40, 40 );
+
+ Stage stage = Stage::GetCurrent();
+ // Create a root layout, ideally Dali would have a default layout in the root layer.
+ // Without this root layer the LinearLayout (or any other layout) will not
+ // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
+ // It uses the default stage size and ideally should have a layout added to it.
+ auto rootLayoutControl = Control::New();
+ rootLayoutControl.SetName( "AbsoluteLayout");
+ auto rootLayout = AbsoluteLayout::New();
+ DevelControl::SetLayout( rootLayoutControl, rootLayout );
+ rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
+ rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
+ stage.Add( rootLayoutControl );
+
+ auto hbox = Control::New();
+ auto hboxLayout = LinearLayout::New();
+ hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
+ DevelControl::SetLayout( hbox, hboxLayout );
+ hbox.SetName( "HBox");
+ hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING );
+ hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+ hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+
+ std::vector< Control > controls;
+ controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
+ controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
+ controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
+ controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) );
+
+ for( auto&& iter : controls )
+ {
+ hbox.Add( iter );
+ }
+
+ hbox.SetParentOrigin( ParentOrigin::CENTER );
+ hbox.SetAnchorPoint( AnchorPoint::CENTER );
+ rootLayoutControl.Add( hbox );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
+ application.SendNotification();
+
+ // hbox centers elements vertically, it fills test harness stage, which is 480x800.
+ // hbox left justifies elements
+ tet_infoline("Test Child Actor Position");
+
+ auto controlXPosition=0.0f;
+
+ controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start,
+ LAYOUT_PADDING.top,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+ controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
+ DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
+ LAYOUT_PADDING.top,
+ 0.0f ),
+ 0.0001f, TEST_LOCATION );
+
+ controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
+ DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
+ LAYOUT_PADDING.top,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+ controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
+ DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
+ LAYOUT_PADDING.top,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+ auto totalControlsWidth = CONTROL_SIZE.width * controls.size();
+ auto totalControlsHeight = CONTROL_SIZE.height;
+
+ DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end,
+ totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+ // Change layout padding
+ const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 );
+ tet_printf( "\nChanging Padding to control at index 1 \n" );
+ hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING );
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen.
+ application.SendNotification();
+
+ controlXPosition = NEW_LAYOUT_PADDING.start; // First child positioned at offset defined by the padding
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start,
+ NEW_LAYOUT_PADDING.top,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+ controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width.
+ DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
+ NEW_LAYOUT_PADDING.top,
+ 0.0f ),
+ 0.0001f, TEST_LOCATION );
+
+ controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second
+ DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
+ NEW_LAYOUT_PADDING.top,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+
+ controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third
+ DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( controlXPosition,
+ NEW_LAYOUT_PADDING.top,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+ totalControlsWidth = CONTROL_SIZE.width * controls.size();
+ totalControlsHeight = CONTROL_SIZE.height;
+
+ DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end,
+ totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom,
+ 0.0f ), 0.0001f, TEST_LOCATION );
+ END_TEST;
+}
+
// Margin Tests
int UtcDaliLayouting_HboxLayout_Margin01(void)
END_TEST;
}
+
+int UtcDaliLayouting_RemoveLayout01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliLayouting_RemoveLayout");
+
+ Stage stage = Stage::GetCurrent();
+
+ auto rootControl = Control::New();
+ auto absoluteLayout = AbsoluteLayout::New();
+ DevelControl::SetLayout( rootControl, absoluteLayout );
+ rootControl.SetName( "AbsoluteLayout" );
+ stage.Add( rootControl );
+
+ auto hbox = Control::New();
+ auto hboxLayout = LinearLayout::New();
+ hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
+ DevelControl::SetLayout( hbox, hboxLayout );
+ hbox.SetName( "HBox" );
+
+ std::vector< Control > controls;
+ controls.push_back( CreateLeafControl( 40, 40 ) );
+ controls.push_back( CreateLeafControl( 60, 40 ) );
+
+ for( auto&& iter : controls )
+ {
+ hbox.Add( iter );
+ }
+ hbox.SetParentOrigin( ParentOrigin::CENTER );
+ hbox.SetAnchorPoint( AnchorPoint::CENTER );
+ rootControl.Add( hbox );
+
+ tet_infoline("Layout as normal");
+ application.SendNotification();
+ application.Render();
+
+ tet_infoline("Set an empty layout on hbox container");
+ LinearLayout emptyLayout;
+ DevelControl::SetLayout( hbox, emptyLayout );
+
+ tet_infoline("Run another layout");
+ application.SendNotification();
+ application.Render();
+
+ tet_infoline("Check leaf controls haven't moved");
+
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliLayouting_LayoutChildren01(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliLayouting_LayoutChildren01");
+
+ Stage stage = Stage::GetCurrent();
+
+ auto rootControl = Control::New();
+ auto absoluteLayout = AbsoluteLayout::New();
+ DevelControl::SetLayout( rootControl, absoluteLayout );
+ stage.Add( rootControl );
+
+ auto hbox = Control::New();
+ auto hboxLayout = LinearLayout::New();
+ DevelControl::SetLayout( hbox, hboxLayout );
+ rootControl.Add( hbox );
+
+ DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
+
+ tet_infoline("Test removal by setting empty layout to child container" );
+ DevelControl::SetLayout( hbox, LayoutItem{} );
+
+ DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
+
+ auto& hboxImpl = GetImplementation( hboxLayout );
+ Handle empty;
+ DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
+ DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliLayouting_LayoutChildren02(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliLayouting_LayoutChildren02");
+
+ Stage stage = Stage::GetCurrent();
+
+ auto rootControl = Control::New();
+ auto absoluteLayout = AbsoluteLayout::New();
+ DevelControl::SetLayout( rootControl, absoluteLayout );
+ stage.Add( rootControl );
+
+ auto hbox = Control::New();
+ auto hboxLayout = LinearLayout::New();
+ DevelControl::SetLayout( hbox, hboxLayout );
+ rootControl.Add( hbox );
+
+ DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
+
+ tet_infoline("Test removal by removing child actor from parent container" );
+ hbox.Unparent();
+
+ DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
+
+ auto& hboxImpl = GetImplementation( hboxLayout );
+ tet_infoline("Test child actor still has hbox layout " );
+ DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
+
+ tet_infoline("Test hbox layout has no parent " );
+ DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliLayouting_LayoutChildren03(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliLayouting_LayoutChildren02");
+
+ Stage stage = Stage::GetCurrent();
+
+ auto rootControl = Control::New();
+ auto absoluteLayout = AbsoluteLayout::New();
+ DevelControl::SetLayout( rootControl, absoluteLayout );
+ stage.Add( rootControl );
+
+ auto hbox = Control::New();
+ auto hboxLayout = LinearLayout::New();
+ DevelControl::SetLayout( hbox, hboxLayout );
+ rootControl.Add( hbox );
+
+ DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
+
+ tet_infoline("Test removal by removing child layout from parent layout" );
+ absoluteLayout.Remove( hboxLayout );
+
+ DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
+
+ auto& hboxImpl = GetImplementation( hboxLayout );
+
+ tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
+ DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
+ DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
+
+ tet_infoline("Check orphaned layout has no parent");
+ DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliLayouting_LayoutChildren04(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliLayouting_LayoutChildren03");
+
+ Stage stage = Stage::GetCurrent();
+
+ auto rootControl = Control::New();
+ auto absoluteLayout = AbsoluteLayout::New();
+ DevelControl::SetLayout( rootControl, absoluteLayout );
+ stage.Add( rootControl );
+
+ auto hbox = Control::New();
+ tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
+ auto hboxLayout = LinearLayout::New();
+ rootControl.Add( hbox );
+
+ DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
+
+ tet_infoline("Then setting a layout on the child container");
+ DevelControl::SetLayout( hbox, hboxLayout );
+
+ DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
+
+ auto& hboxImpl = GetImplementation( hboxLayout );
+ auto& absImpl = GetImplementation( absoluteLayout );
+ DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
+ DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliLayouting_SetLayoutOrder(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Call SetLayout after adding the control to the root layout");
+
+ Stage stage = Stage::GetCurrent();
+
+ auto rootControl = Control::New();
+ auto absoluteLayout = AbsoluteLayout::New();
+ DevelControl::SetLayout( rootControl, absoluteLayout );
+ rootControl.SetName( "AbsoluteLayout" );
+ stage.Add( rootControl );
+
+ tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
+ auto hbox = Control::New();
+ auto hboxLayout = LinearLayout::New();
+ hbox.SetName( "HBox");
+
+ tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
+ rootControl.Add( hbox );
+
+ tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
+ DevelControl::SetLayout( hbox, hboxLayout );
+
+ // Add a Child control
+ std::vector< Control > controls;
+ controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
+ for( auto&& iter : controls )
+ {
+ hbox.Add( iter );
+ }
+
+ // Ensure layouting happens
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+ END_TEST;
+}
AC_SUBST(DOXYGEN_DOCS_DIR)
AC_SUBST(DOXYGEN_ROOT_DIR)
+if test "x$enable_cxx03_abi" = "xyes"; then
+PKG_CHECK_MODULES(DALI, dali-core-cxx03)
+PKG_CHECK_MODULES(DALIDAPTOR, dali-adaptor-cxx03)
+else
+PKG_CHECK_MODULES(DALICORE, dali-core)
+PKG_CHECK_MODULES(DALIADAPTOR, dali-adaptor)
+fi
+
# Enable csharp plugin
build_csharp_plugin=no
build_ruby_flag=no
if test x$enable_csharp = xyes; then
[build_csharp_plugin=yes]
AC_MSG_NOTICE(Building DALi csharp plugin ...)
-
- PKG_CHECK_MODULES(DALIADAPTOR, dali-adaptor)
AC_PATH_PROG([SWIG], [swig])
# if gbs enable, then only use swig, without ruby or mcs
AC_SUBST(DALITOOLKIT_LIBS)
fi
-if test "x$enable_cxx03_abi" = "xyes"; then
-PKG_CHECK_MODULES(DALICORE, dali-core-cxx03)
-else
-PKG_CHECK_MODULES(DALICORE, dali-core)
-fi
-
#set a variable for the makefile to force compile the csharp plugin
AM_CONDITIONAL([ENABLE_CSHARP_PLUGIN], [test x$build_csharp_plugin = xyes])
AM_CONDITIONAL([ENABLE_RUBY_FLAG], [test x$build_ruby_flag = xyes])
-I../../../ \
$(DALI_TOOLKIT_CFLAGS) \
$(DALICORE_CFLAGS) \
+ $(DALIADAPTOR_CFLAGS) \
$(DLOG_CFLAGS) \
$(FRIBIDI_CFLAGS) \
$(HTMLCXX_CFLAGS)
LIBDALI_TOOLKIT_LA_LIBADD = \
$(DALICORE_LIBS) \
+ $(DALIADAPTOR_LIBS) \
$(DLOG_LIBS) \
$(FRIBIDI_LIBS) \
$(HTMLCXX_LIBS)
{
Internal::Control& internalControl = Toolkit::Internal::GetImplementation( control );
Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( internalControl );
- controlDataImpl.SetLayout( GetImplementation( layout ) );
+ if( layout )
+ {
+ controlDataImpl.SetLayout( GetImplementation( layout ) );
+ }
+ else
+ {
+ controlDataImpl.RemoveLayout();
+ }
+}
+
+void RequestLayout( Internal::Control& control )
+{
+ Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control );
+ Toolkit::Internal::LayoutItemPtr layoutItem = controlDataImpl.GetLayout();
+ if ( layoutItem )
+ {
+ layoutItem->RequestLayout();
+ }
}
} // namespace DevelControl
*/
DALI_TOOLKIT_API void SetLayout( Control control, Toolkit::LayoutItem layout );
+/**
+ * @brief Request the control layout.
+ *
+ * @param[in] control The internal Control to request the layout of
+ */
+DALI_TOOLKIT_API void RequestLayout( Internal::Control& control );
+
} // namespace DevelControl
} // namespace Toolkit
$(devel_api_src_dir)/layouting/child-layout-data.h \
$(devel_api_src_dir)/layouting/flex-layout.h \
$(devel_api_src_dir)/layouting/linear-layout.h \
- $(devel_api_src_dir)/layouting/layout-item.h \
- $(devel_api_src_dir)/layouting/layout-item-impl.h \
+ $(devel_api_src_dir)/layouting/layout-child-impl.h \
$(devel_api_src_dir)/layouting/layout-controller.h \
$(devel_api_src_dir)/layouting/layout-group.h \
$(devel_api_src_dir)/layouting/layout-group-impl.h \
+ $(devel_api_src_dir)/layouting/layout-item.h \
+ $(devel_api_src_dir)/layouting/layout-item-impl.h \
$(devel_api_src_dir)/layouting/layout-length.h \
+ $(devel_api_src_dir)/layouting/layout-parent-impl.h \
$(devel_api_src_dir)/layouting/layout-size.h \
$(devel_api_src_dir)/layouting/measured-size.h \
- $(devel_api_src_dir)/layouting/layout-parent-impl.h \
$(devel_api_src_dir)/layouting/measure-spec.h
devel_api_magnifier_header_files = \
--- /dev/null
+#ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_CHILD_H
+#define DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_CHILD_H
+
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal
+{
+class LayoutParent;
+
+/**
+ * Interface that allows a layout to determine its layout parent.
+ *
+ * This is useful for LayoutItem to determine it's parent, without accessing
+ * via LayoutGroup, which is a subclass of LayoutItem (Super classes shouldn't
+ * know / care about derived classes)
+ */
+class DALI_TOOLKIT_API LayoutChild
+{
+public:
+ /**
+ * Set the parent of this layout.
+ */
+ virtual void SetParent( LayoutParent* parent ) = 0;
+
+ /**
+ * Get the parent of this layout.
+ */
+ virtual LayoutParent* GetParent() = 0;
+
+protected:
+ virtual ~LayoutChild()
+ {
+ }
+};
+
+
+} // namespace Internal
+} // namespace Toolkit
+} // namespace Dali
+
+#endif //DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_CHILD_H
{
if( iter->layoutId == childId )
{
- OnChildRemove( *iter->child.Get() );
+ RemoveChild( *iter->child.Get() );
mImpl->mChildren.erase(iter);
break;
}
{
if( iter->child.Get() == &child )
{
- OnChildRemove( *iter->child.Get() );
+ RemoveChild( *iter->child.Get() );
mImpl->mChildren.erase(iter);
break;
}
{
for( auto iter = mImpl->mChildren.begin() ; iter != mImpl->mChildren.end() ; )
{
- OnChildRemove( *iter->child.Get() );
+ RemoveChild( *iter->child.Get() );
iter = mImpl->mChildren.erase(iter);
}
}
{
// Remove children
RemoveAll();
+}
- // Remove myself from parent
- LayoutParent* parent = GetParent();
- if( parent )
- {
- LayoutGroupPtr parentGroup( dynamic_cast< LayoutGroup* >( parent ) );
- if( parentGroup )
- {
- parentGroup->Remove( *this );
- }
- }
+void LayoutGroup::RemoveChild( LayoutItem& item )
+{
+ item.SetParent( nullptr );
+ OnChildRemove( item );
}
void LayoutGroup::ChildAddedToOwner( Actor child )
#include <dali/public-api/signals/connection-tracker.h>
#include <dali-toolkit/devel-api/layouting/child-layout-data.h>
#include <dali-toolkit/devel-api/layouting/layout-group.h>
+#include <dali-toolkit/devel-api/layouting/layout-parent-impl.h>
#include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
namespace Dali
* position and size; it should then call Layout() on the child layout to layout the child and it's hierarchy.
*/
class DALI_TOOLKIT_API LayoutGroup : public LayoutItem,
+ public LayoutParent,
public ConnectionTracker
{
public:
* @param[in] layoutChild The child to add
* @return The layout id of this child.
*/
- Toolkit::LayoutGroup::LayoutId Add( LayoutItem& layoutChild );
+ Toolkit::LayoutGroup::LayoutId Add( LayoutItem& layoutChild ) override;
/**
* @brief Remove a layout child from this group.
* @param[in] childId The layout child id
*/
- void Remove( Toolkit::LayoutGroup::LayoutId childId );
+ void Remove( Toolkit::LayoutGroup::LayoutId childId ) override;
/**
* @brief Remove a layout child from this group
* @param[in] child The layout child
*/
- void Remove( LayoutItem& child );
+ void Remove( LayoutItem& child ) override;
/**
* @brief Remove all layout children.
void OnUnparent() override final;
/**
+ * Method to remove a child from this group
+ */
+ void RemoveChild( LayoutItem& item );
+
+ /**
* Callback when child is added to owner
*/
void ChildAddedToOwner( Actor child );
#include <dali/public-api/object/type-registry-helper.h>
#include <dali-toolkit/public-api/controls/control.h>
#include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
+#include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
#include <dali-toolkit/internal/layouting/layout-item-data-impl.h>
namespace
// Enable directly derived types to first remove children
OnUnparent();
+ // Remove myself from parent
+ LayoutParent* parent = GetParent();
+ if( parent )
+ {
+ parent->Remove( *this );
+ }
+
+ // Remove parent reference
+ SetParent(nullptr);
+
// Last, clear owner
mImpl->mOwner = NULL;
}
{
bool changed = false;
- DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame(%d, %d, %d, %d)\n", left.mValue, top.mValue, right.mValue, bottom.mValue );
+ DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame enter(%d, %d, %d, %d)\n", left.mValue, top.mValue, right.mValue, bottom.mValue );
if( mImpl->mLeft != left || mImpl->mRight != right || mImpl->mTop != top || mImpl->mBottom != bottom )
{
SizeChange( LayoutSize( newWidth, newHeight ), LayoutSize( oldWidth, oldHeight ) );
}
}
+
+ DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame exit(%d, %d, %d, %d)\n", left.mValue, top.mValue, right.mValue, bottom.mValue );
+
return changed;
}
#include <dali/public-api/actors/actor-enumerations.h>
#include <dali-toolkit/devel-api/layouting/child-layout-data.h>
#include <dali-toolkit/devel-api/layouting/layout-item.h>
-#include <dali-toolkit/devel-api/layouting/layout-parent-impl.h>
+#include <dali-toolkit/devel-api/layouting/layout-child-impl.h>
#include <dali-toolkit/devel-api/layouting/layout-controller.h>
#include <dali-toolkit/devel-api/layouting/layout-size.h>
#include <dali-toolkit/devel-api/layouting/measure-spec.h>
* Base class for layouts.
*/
class DALI_TOOLKIT_API LayoutItem : public BaseObject,
- public LayoutParent
+ public LayoutChild
{
public:
/**
Handle GetOwner() const;
/**
- * @brief Unparent this layout from it's owner, and remove any layout children in derived types
+ * @brief Unparent this layout from it's parent, remove it from it's owner
+ * and remove any layout children in derived types.
*/
void Unparent();
static LayoutLength GetDefaultSize( LayoutLength size, MeasureSpec measureSpec );
/**
- * @copydoc LayoutParent::SetParent
+ * @copydoc LayoutChild::SetParent
*/
- virtual void SetParent( LayoutParent* parent ) override;
+ void SetParent( LayoutParent* parent ) override;
/**
- * @copydoc LayoutParent::GetParent
+ * @copydoc LayoutChild::GetParent
*/
- virtual LayoutParent* GetParent() override;
+ LayoutParent* GetParent() override;
/**
* @brief Request that this layout is re-laid out.
{
namespace Internal
{
+class LayoutItem;
/**
- * Interface that allows a layout to determine its layout parent.
- *
- * Needed to prevent circular inheritance - most LayoutBases have a parent,
- * but parenting is provided by LayoutGroup, which is a sub-class of LayoutBase.
+ * Interface that defines a layout Parent. Enables a layout child to access
+ * methods on its parent, e.g. Remove (during unparenting)
*/
class DALI_TOOLKIT_API LayoutParent
{
public:
/**
- * Set the parent of this layout.
+ * @brief Add a child to the parent
+ * @param[in] item The item to add to this layout parent
*/
- virtual void SetParent( LayoutParent* parent ) = 0;
+ virtual Toolkit::LayoutGroup::LayoutId Add( LayoutItem& item ) = 0;
/**
- * Get the parent of this layout.
+ * @brief Remove a layout child from this group.
+ * @param[in] childId The layout child id
*/
- virtual LayoutParent* GetParent() = 0;
+ virtual void Remove( Toolkit::LayoutGroup::LayoutId childId ) = 0;
+
+ /**
+ * @brief Remove a child from this parent
+ * @param[in] item The item to remove from this layout parent
+ */
+ virtual void Remove( LayoutItem& item ) = 0;
protected:
virtual ~LayoutParent()
};
+
} // namespace Internal
} // namespace Toolkit
} // namespace Dali
void Control::Impl::SetMargin( Extents margin )
{
mControlImpl.mImpl->mMargin = margin;
+
+ // Trigger a size negotiation request that may be needed when setting a margin.
+ mControlImpl.RelayoutRequest();
}
Extents Control::Impl::GetMargin() const
void Control::Impl::SetPadding( Extents padding )
{
mControlImpl.mImpl->mPadding = padding;
+
+ // Trigger a size negotiation request that may be needed when setting a padding.
+ mControlImpl.RelayoutRequest();
}
Extents Control::Impl::GetPadding() const
mLayout->Initialize( controlHandle, controlHandle.GetTypeName() ); // LayoutGroup takes ownership of existing children
}
+void Control::Impl::RemoveLayout()
+{
+ if( mLayout )
+ {
+ mLayout->Unparent();
+ mLayout.Reset();
+ }
+}
+
} // namespace Internal
} // namespace Toolkit
*/
void SetLayout( Toolkit::Internal::LayoutItem& layout );
+ /**
+ * @brief Remove the layout from this control
+ *
+ * @note This does not remove any children from this control, nor does it strip
+ * layouts from them but it does remove them from the layout hierarchy.
+ */
+ void RemoveLayout();
+
private:
/**
// Trigger a size negotiation request that may be needed when unregistering a visual.
RelayoutRequest();
}
+
+ Toolkit::DevelControl::RequestLayout( *this );
}
void ImageView::SetImage( const Property::Map& map )
// Trigger a size negotiation request that may be needed when unregistering a visual.
RelayoutRequest();
}
+
+ Toolkit::DevelControl::RequestLayout( *this );
}
void ImageView::SetImage( const std::string& url, ImageDimensions size )
// Trigger a size negotiation request that may be needed when unregistering a visual.
RelayoutRequest();
}
+
+ Toolkit::DevelControl::RequestLayout( *this );
}
Image ImageView::GetImage() const
{
Property::Map transformMap = Property::Map();
- // Don't transform if fitting mode is FILL
- if(Toolkit::GetImplementation(mVisual).GetFittingMode() == Visual::FittingMode::FIT_KEEP_ASPECT_RATIO)
+ Extents padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+
+ Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>(
+ Self().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+
+ if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
{
- Extents padding;
- padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+ std::swap( padding.start, padding.end );
+ }
- Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>(
- Self().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
+ auto finalOffset = Vector2( padding.start, padding.top );
- if (Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection)
- {
- std::swap(padding.start, padding.end);
- }
+ // remove padding from the size to know how much is left for the visual
+ auto finalSize = size - Vector2( padding.start + padding.end, padding.top + padding.bottom );
- // remove padding from the size to know how much is left for the visual
- auto paddedSize = size - Vector2(padding.start + padding.end, padding.top + padding.bottom);
+ // Should provide a transform that handles aspect ratio according to image size
+ if( Toolkit::GetImplementation(mVisual).GetFittingMode() == Visual::FittingMode::FIT_KEEP_ASPECT_RATIO )
+ {
+ auto availableVisualSize = finalSize;
Vector2 naturalSize;
- mVisual.GetNaturalSize(naturalSize);
+ mVisual.GetNaturalSize( naturalSize );
// scale to fit the padded area
- auto finalSize =
- naturalSize * std::min( ( naturalSize.width ? ( paddedSize.width / naturalSize.width ) : 0 ),
- ( naturalSize.height ? ( paddedSize.height / naturalSize.height ) : 0 ) );
+ finalSize = naturalSize * std::min( ( naturalSize.width ? ( availableVisualSize.width / naturalSize.width ) : 0 ),
+ ( naturalSize.height ? ( availableVisualSize.height / naturalSize.height ) : 0 ) );
// calculate final offset within the padded area
- auto finalOffset = Vector2(padding.start, padding.top) + (paddedSize - finalSize) * .5f;
-
- // populate the transform map
- transformMap.Add(Toolkit::Visual::Transform::Property::OFFSET, finalOffset)
- .Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
- Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE))
- .Add(Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN)
- .Add(Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN)
- .Add(Toolkit::Visual::Transform::Property::SIZE, finalSize)
- .Add(Toolkit::Visual::Transform::Property::SIZE_POLICY,
- Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE));
-
+ finalOffset += ( availableVisualSize - finalSize ) * .5f;
}
- // Should provide a transform that handles aspect ratio according to image size
+
+ // populate the transform map
+ transformMap.Add( Toolkit::Visual::Transform::Property::OFFSET, finalOffset )
+ .Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY,
+ Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) )
+ .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
+ .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN )
+ .Add( Toolkit::Visual::Transform::Property::SIZE, finalSize )
+ .Add( Toolkit::Visual::Transform::Property::SIZE_POLICY,
+ Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) );
+
mVisual.SetTransformAndSize( transformMap, size );
}
}
void TextLabel::RequestTextRelayout()
{
RelayoutRequest();
+ Toolkit::DevelControl::RequestLayout( *this );
}
void TextLabel::SetUpAutoScrolling()
YGMeasureMode widthMode,
float innerHeight,
YGMeasureMode heightMode ) {
- // TODO: this function should try to get use of LayoutGroup::GetChildMeasureSpec
- // or LayoutGroup::MeasureChild somehow since it is fixed now
LayoutItem* childLayout = static_cast<LayoutItem*>(node->getContext());
auto childOwner = childLayout->GetOwner();
auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
-
- MeasureSpec::Mode measureWidthMode = MeasureSpec::Mode::AT_MOST;
- MeasureSpec::Mode measureHeightMode = MeasureSpec::Mode::AT_MOST;
- if( desiredWidth == Toolkit::ChildLayoutData::MATCH_PARENT )
- {
- if( innerWidth != YGUndefined)
- {
- desiredWidth = innerWidth;
- }
- measureWidthMode = MeasureSpec::Mode::EXACTLY;
- }
-
- if( desiredHeight == Toolkit::ChildLayoutData::MATCH_PARENT )
- {
- if( innerHeight != YGUndefined)
- {
- desiredHeight = innerHeight;
- }
- measureHeightMode = MeasureSpec::Mode::EXACTLY;
- }
-
- if( desiredWidth == Toolkit::ChildLayoutData::WRAP_CONTENT )
+ auto parentWidthMeasureSpec = MeasureSpec( 0 );
+ if ( innerWidth != YGUndefined )
{
- measureWidthMode = MeasureSpec::Mode::UNSPECIFIED;
+ parentWidthMeasureSpec = MeasureSpec( innerWidth, static_cast<MeasureSpec::Mode>(widthMode) );
}
-
- if( desiredHeight == Toolkit::ChildLayoutData::WRAP_CONTENT )
+ auto parentHeightMeasureSpec = MeasureSpec( 0 );
+ if ( innerHeight != YGUndefined )
{
- measureHeightMode = MeasureSpec::Mode::UNSPECIFIED;
+ parentHeightMeasureSpec = MeasureSpec( innerHeight, static_cast<MeasureSpec::Mode>(heightMode) );
}
+ auto childWidthMeasureSpec = LayoutGroup::GetChildMeasureSpec( parentWidthMeasureSpec, 0, desiredWidth);
+ auto childHeightMeasureSpec = LayoutGroup::GetChildMeasureSpec( parentHeightMeasureSpec, 0, desiredHeight);
- MeasureSpec widthMeasureSpec = MeasureSpec( desiredWidth, measureWidthMode );
- MeasureSpec heightMeasureSpec = MeasureSpec( desiredHeight, measureHeightMode );
- if( measureWidthMode == MeasureSpec::Mode::UNSPECIFIED ||
- measureHeightMode == MeasureSpec::Mode::UNSPECIFIED )
+ // Force to fill parent if a child wants to match parent even if GetChildMeasureSpec sets otherwise
+ if( desiredWidth == Toolkit::ChildLayoutData::MATCH_PARENT && innerWidth != YGUndefined )
{
- // A measure just to get the size if the wrapped content
- childLayout->Measure( widthMeasureSpec, heightMeasureSpec );
- desiredWidth = childLayout->GetMeasuredWidth();
- desiredHeight = childLayout->GetMeasuredHeight();
- // Remove padding here since the second measure will add it back
- Extents padding = childLayout->GetPadding();
- desiredWidth = desiredWidth - padding.end - padding.start;
- desiredHeight = desiredHeight - padding.bottom - padding.top;
+ childWidthMeasureSpec = MeasureSpec( innerWidth, MeasureSpec::Mode::EXACTLY );
}
-
- // Safety check to avoid going out of boundary
- if( (innerWidth != YGUndefined && innerWidth != 0) && innerWidth < desiredWidth )
+ if( desiredHeight == Toolkit::ChildLayoutData::MATCH_PARENT && innerHeight != YGUndefined )
{
- desiredWidth = innerWidth;
+ childHeightMeasureSpec = MeasureSpec( innerHeight, MeasureSpec::Mode::EXACTLY );
}
- if( (innerHeight != YGUndefined && innerHeight != 0) && innerHeight < desiredHeight )
- {
- desiredHeight = innerHeight;
- }
-
- // Measure for Yoga
- MeasureSpec::Mode ygWidthMode = static_cast<MeasureSpec::Mode>(widthMode);
- if( measureWidthMode == MeasureSpec::Mode::EXACTLY )
- {
- ygWidthMode = MeasureSpec::Mode::EXACTLY;
- }
-
- MeasureSpec::Mode ygHeightMode = static_cast<MeasureSpec::Mode>(heightMode);
- if( measureHeightMode == MeasureSpec::Mode::EXACTLY )
- {
- ygHeightMode = MeasureSpec::Mode::EXACTLY;
- }
-
- MeasureSpec ygWidthMeasureSpec = MeasureSpec( desiredWidth, ygWidthMode );
- MeasureSpec ygHeightMeasureSpec = MeasureSpec( desiredHeight, ygHeightMode );
#if defined(DEBUG_ENABLED)
auto actor = Actor::DownCast(childOwner);
std::ostringstream oss;
{
oss << "Actor Id:" << actor.GetId() << " Name:" << actor.GetName() << " ";
}
- oss << "innerWidth:" << ((innerWidth == YGUndefined) ? "YGUndefined " : "") << innerWidth <<
- " innerHeight:" << ((innerHeight == YGUndefined) ? "YGUndefined " : "") << innerHeight <<
+ oss << "innerWidth:" << ( ( innerWidth == YGUndefined ) ? "YGUndefined " : "" ) << innerWidth <<
+ " innerHeight:" << ( ( innerHeight == YGUndefined ) ? "YGUndefined " : "" ) << innerHeight <<
" desiredWidth:" << desiredWidth << " desiredHeight:" << desiredHeight <<
- " widthMeasureSpec:" << widthMeasureSpec << " heightMeasureSpec:" << heightMeasureSpec <<
- " ygWidthMeasureSpec:" << ygWidthMeasureSpec << " ygHeightMeasureSpec:" << ygHeightMeasureSpec << std::endl;
+ " childWidthMeasureSpec:" << childWidthMeasureSpec << " childHeightMeasureSpec:" << childHeightMeasureSpec << std::endl;
DALI_LOG_INFO( gLogFilter, Debug::Concise, oss.str().c_str() );
#endif
- if( measureWidthMode == MeasureSpec::Mode::UNSPECIFIED ||
- measureHeightMode == MeasureSpec::Mode::UNSPECIFIED )
- {
- if( ygWidthMeasureSpec == widthMeasureSpec && ygHeightMeasureSpec == heightMeasureSpec )
- {
- return YGSize{
- .width = childLayout->GetMeasuredWidth(),
- .height = childLayout->GetMeasuredHeight(),
- };
- }
- }
+ childLayout->Measure( childWidthMeasureSpec, childHeightMeasureSpec );
+
+ // Remove padding here since Yoga doesn't consider it as a part of the node size
+ Extents padding = childLayout->GetPadding();
+ auto measuredWidth = childLayout->GetMeasuredWidth() - padding.end - padding.start;
+ auto measuredHeight = childLayout->GetMeasuredHeight() - padding.bottom - padding.top;
- childLayout->Measure( ygWidthMeasureSpec, ygHeightMeasureSpec );
return YGSize{
- .width = childLayout->GetMeasuredWidth(),
- .height = childLayout->GetMeasuredHeight(),
+ .width = measuredWidth,
+ .height = measuredHeight,
};
}
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
}
-/**
- * @brief Sets Control::Property::BACKGROUND visual
- * @param[in] controlImpl The control implementation
- * @param[in] visual The control background visual
- * @param[in] size The current size
- */
-void SetBackgroundVisual( Control::Impl& controlImpl, Toolkit::Visual::Base& visual, const Vector2& size )
-{
- Property::Map transformMap = Property::Map();
-
- Vector2 newSize( 0.f, 0.f );
- newSize.width = size.width + ( controlImpl.mPadding.start + controlImpl.mPadding.end );
- newSize.height = size.height + ( controlImpl.mPadding.top + controlImpl.mPadding.bottom );
-
- if( ( controlImpl.mMargin.start != 0 ) ||
- ( controlImpl.mMargin.end != 0 ) ||
- ( controlImpl.mMargin.top != 0 ) ||
- ( controlImpl.mMargin.bottom != 0 ) )
- {
- transformMap.Add( Toolkit::Visual::Transform::Property::SIZE, newSize )
- .Add( Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) )
- .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( controlImpl.mMargin.start, controlImpl.mMargin.top ) )
- .Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) )
- .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
- .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN );
- }
- else if( ( controlImpl.mPadding.start != 0 ) ||
- ( controlImpl.mPadding.end != 0 ) ||
- ( controlImpl.mPadding.top != 0 ) ||
- ( controlImpl.mPadding.bottom != 0 ) )
- {
- transformMap.Add( Toolkit::Visual::Transform::Property::SIZE, newSize )
- .Add( Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) )
- .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
- .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN );
- }
-
- visual.SetTransformAndSize( transformMap, newSize ); // Send an empty map as we do not want to modify the visual's set transform
-}
-
} // unnamed namespace
if( visual )
{
Vector2 size( targetSize );
- SetBackgroundVisual( *mImpl, visual, size );
-
+ visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform
}
}
Actor child = Self().GetChildAt( i );
Vector2 newChildSize( size );
- // When set the padding or margin on the control, child should be resized and repositioned.
+ // When setting the padding or margin on the control child should be resized and repositioned for legacy reasons.
if( ( mImpl->mPadding.start != 0 ) || ( mImpl->mPadding.end != 0 ) || ( mImpl->mPadding.top != 0 ) || ( mImpl->mPadding.bottom != 0 ) ||
( mImpl->mMargin.start != 0 ) || ( mImpl->mMargin.end != 0 ) || ( mImpl->mMargin.top != 0 ) || ( mImpl->mMargin.bottom != 0 ) )
{
- Extents padding = mImpl->mPadding;
-
- Dali::CustomActor ownerActor(GetOwner());
- Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( ownerActor.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+ // Cannot use childs Position property as it can already have margin applied on it,
+ // so we end up cumulatively applying them over and over again.
+ Toolkit::Control childControl = Toolkit::Control::DownCast( child );
- if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
+ // If control not a LayoutItem layout then must be the old Relayout algorithm hence account
+ // for margins and padding.
+ // Padding is incorrect but may have to keep this functionality for compatibility.
+ if ( childControl && ! Toolkit::DevelControl::GetLayout( childControl ) )
{
- std::swap( padding.start, padding.end );
- }
+ Extents padding = mImpl->mPadding;
- newChildSize.width = size.width - ( padding.start + padding.end );
- newChildSize.height = size.height - ( padding.top + padding.bottom );
+ Dali::CustomActor ownerActor(GetOwner());
+ Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>( ownerActor.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
- // Cannot use childs Position property as it can already have padding and margin applied on it,
- // so we end up cumulatively applying them over and over again.
- Vector2 childOffset( 0.f, 0.f );
- childOffset.x += ( mImpl->mMargin.start + padding.start );
- childOffset.y += ( mImpl->mMargin.top + padding.top );
+ if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
+ {
+ std::swap( padding.start, padding.end );
+ }
+
+ // Child size should include padding, this is the wrong use of padding but kept for compatibility.
+ newChildSize.width = size.width - ( padding.start + padding.end );
+ newChildSize.height = size.height - ( padding.top + padding.bottom );
- child.SetPosition( childOffset.x, childOffset.y );
+ // Cannot use childs Position property as it can already have padding and margin applied on it,
+ // so we end up cumulatively applying them over and over again.
+ Vector2 childOffset( 0.f, 0.f );
+ childOffset.x += ( mImpl->mMargin.start + padding.start );
+ childOffset.y += ( mImpl->mMargin.top + padding.top );
+
+ child.SetPosition( childOffset.x, childOffset.y );
+ }
}
- container.Add( child, newChildSize );
+ container.Add( child, size );
}
Toolkit::Visual::Base visual = mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND );
if( visual )
{
- SetBackgroundVisual( *mImpl, visual, size );
+ visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform
}
}
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 3;
-const unsigned int TOOLKIT_MICRO_VERSION = 30;
+const unsigned int TOOLKIT_MICRO_VERSION = 31;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
Name: dali-toolkit
Summary: Dali 3D engine Toolkit
-Version: 1.3.30
+Version: 1.3.31
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT
BuildRequires: pkgconfig
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(dali-core)
+BuildRequires: pkgconfig(dali-adaptor)
%if !0%{?disable_cxx03_build}
BuildRequires: pkgconfig(dali-core-cxx03)
+BuildRequires: pkgconfig(dali-adaptor-cxx03)
%endif
BuildRequires: gettext
-# dali-toolkit only need to know the interfaces(APIs) of dali-adaptor(the devel package).
-# It doesn't need to know which adaptor will be used by applications.
-# Applications or dali-addon will decide which one they will use.
-BuildRequires: dali-adaptor-devel
-%if !0%{?disable_cxx03_build}
-BuildRequires: dali-adaptor-devel-cxx03
-%endif
#need libtzplatform-config for directory if tizen version is 3.x