[dali_1.3.27] Merge branch 'devel/master' 44/180744/1
authorDavid Steele <david.steele@samsung.com>
Fri, 1 Jun 2018 13:17:04 +0000 (14:17 +0100)
committerDavid Steele <david.steele@samsung.com>
Fri, 1 Jun 2018 13:17:04 +0000 (14:17 +0100)
Change-Id: I298d52f8d05cc51850927e9553c02e0ea1d2bfd2

18 files changed:
automated-tests/src/dali-toolkit-internal/utc-Dali-DebugRendering.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.cpp
automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp
dali-toolkit/devel-api/layouting/layout-group-impl.cpp
dali-toolkit/devel-api/layouting/layout-item-impl.cpp
dali-toolkit/devel-api/layouting/layout-item-impl.h
dali-toolkit/internal/layouting/hbox-layout-impl.cpp
dali-toolkit/internal/layouting/layout-controller-impl.cpp
dali-toolkit/internal/layouting/layout-item-data-impl.cpp
dali-toolkit/internal/layouting/layout-item-data-impl.h
dali-toolkit/internal/layouting/vbox-layout-impl.cpp
dali-toolkit/internal/visuals/text/text-visual.h
dali-toolkit/internal/visuals/visual-base-impl.cpp
dali-toolkit/internal/visuals/visual-base-impl.h
dali-toolkit/internal/visuals/wireframe/wireframe-visual.cpp
dali-toolkit/internal/visuals/wireframe/wireframe-visual.h
dali-toolkit/public-api/dali-toolkit-version.cpp
packaging/dali-toolkit.spec

index b4ea19b..0cc5c2d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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.
@@ -19,6 +19,8 @@
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/internal/visuals/wireframe/wireframe-visual.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
+#include <dali-toolkit/internal/visuals/text/text-visual.h>
 
 #include <dali-toolkit/dali-toolkit.h>
 
@@ -238,3 +240,100 @@ int UtcDaliDebugRenderingGetVisual2(void)
   EnvironmentVariable::SetTestingEnvironmentVariable(false);
   END_TEST;
 }
+
+int UtcDaliDebugRenderingGetVisualObject01(void)
+{
+  EnvironmentVariable::SetTestingEnvironmentVariable( true );
+  ToolkitTestApplication application;
+
+  VisualFactory factory = VisualFactory::Get();
+  DALI_TEST_CHECK( factory );
+
+  tet_infoline( "Create a TextVisual when debugging is enabled, thus creating a proxy Wireframe Visual" );
+
+  Dali::Property::Map map;
+  map[ Toolkit::Visual::Property::TYPE ] = Visual::TEXT;
+  map[ TextVisual::Property::TEXT ] = "Hello";
+
+  Visual::Base textVisual = factory.CreateVisual( map);
+  DALI_TEST_CHECK( textVisual );
+
+  tet_infoline( "Check that GetVisualObject returns the actual TextVisual" );
+  Toolkit::Internal::Visual::Base& visualImpl = GetImplementation( textVisual ).GetVisualObject();
+  DALI_TEST_CHECK( dynamic_cast< Toolkit::Internal::TextVisual* >( &visualImpl ) );
+
+  tet_infoline( "Compare the returned TextVisual with the visual implementation, should differ" );
+  DALI_TEST_CHECK( textVisual.GetObjectPtr() != &visualImpl );
+
+  END_TEST;
+}
+
+int UtcDaliDebugRenderingGetVisualObject02(void)
+{
+  ToolkitTestApplication application;
+
+  VisualFactory factory = VisualFactory::Get();
+  DALI_TEST_CHECK( factory );
+
+  tet_infoline( "Create a TextVisual without debugging enabled, thus no proxy Wireframe Visual" );
+
+  Dali::Property::Map map;
+  map[ Toolkit::Visual::Property::TYPE ] = Visual::TEXT;
+  map[ TextVisual::Property::TEXT ] = "Hello";
+
+  Visual::Base textVisual = factory.CreateVisual( map);
+  DALI_TEST_CHECK( textVisual );
+
+  tet_infoline( "Check that GetVisualObject returns the actual TextVisual" );
+  Toolkit::Internal::Visual::Base& visualImpl = GetImplementation( textVisual ).GetVisualObject();
+  DALI_TEST_CHECK( dynamic_cast< Toolkit::Internal::TextVisual* >( &visualImpl ) );
+
+  tet_infoline( "Compare the returned TextVisual with the visual implementation, should be the same" );
+  DALI_TEST_CHECK( textVisual.GetObjectPtr() == &visualImpl );
+
+  END_TEST;
+}
+
+int UtcDaliDebugRenderingGetVisualObject03(void)
+{
+  ToolkitTestApplication application;
+
+  VisualFactory factory = VisualFactory::Get();
+  DALI_TEST_CHECK( factory );
+
+  tet_infoline( "Create a WireframeVisual without debugging enabled, thus no proxy Wireframe Visual either" );
+
+  Dali::Property::Map map;
+  map[ Toolkit::Visual::Property::TYPE ] = Visual::WIREFRAME;
+
+  Visual::Base textVisual = factory.CreateVisual( map);
+  DALI_TEST_CHECK( textVisual );
+
+  tet_infoline( "Check that GetVisualObject returns the WireframeVisual" );
+  Toolkit::Internal::Visual::Base& visualImpl = GetImplementation( textVisual ).GetVisualObject();
+  DALI_TEST_CHECK( dynamic_cast< Toolkit::Internal::WireframeVisual* >( &visualImpl ) );
+
+  tet_infoline( "Compare the returned Visual with the visual implementation, should be the same" );
+  DALI_TEST_CHECK( textVisual.GetObjectPtr() == &visualImpl );
+
+  END_TEST;
+}
+
+int UtcDaliDebugRenderingRenderText(void)
+{
+  EnvironmentVariable::SetTestingEnvironmentVariable( true );
+  ToolkitTestApplication application;
+  tet_infoline( "Ensure we can render text when in debug mode" );
+
+  try
+  {
+    Toolkit::TextLabel label = TextLabel::New( "Hello" );
+    Stage::GetCurrent().Add( label );
+    DALI_TEST_CHECK( true );
+  } catch( ... )
+  {
+    DALI_TEST_CHECK( false );
+  }
+
+  END_TEST;
+}
index b38428b..cf97813 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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.
@@ -107,14 +107,15 @@ void DALI_TEST_EQUALS( const Matrix3& matrix1, const Matrix3& matrix2, const cha
 
   if( !equivalent )
   {
-    fprintf(stderr, "%s, checking\n"
-               "(%f, %f, %f)    (%f, %f, %f)\n"
-               "(%f, %f, %f) == (%f, %f, %f)\n"
-               "(%f, %f, %f)    (%f, %f, %f)\n",
+    // Align each float to 1234.67, i.e. 3.6 will be "   3.60"
+    fprintf( stderr, "%s, checking\n"
+               "%7.2f %7.2f %7.2f    %7.2f %7.2f %7.2f\n"
+               "%7.2f %7.2f %7.2f == %7.2f %7.2f %7.2f\n"
+               "%7.2f %7.2f %7.2f    %7.2f %7.2f %7.2f\n",
                location,
-               m1[0],  m1[1], m1[2],   m2[0],  m2[1], m2[2],
-               m1[3],  m1[4], m1[5],   m2[3],  m2[4], m2[5],
-               m1[6],  m1[7], m1[8],   m2[6],  m2[7], m2[8]);
+               m1[0], m1[3], m1[6],    m2[0], m2[3], m2[6],
+               m1[1], m1[4], m1[7],    m2[1], m2[4], m2[7],
+               m1[2], m1[5], m1[8],    m2[2], m2[5], m2[8] );
 
     tet_result(TET_FAIL);
     throw("TET_FAIL");
@@ -138,14 +139,15 @@ void DALI_TEST_EQUALS( const Matrix3& matrix1, const Matrix3& matrix2, float eps
 
   if (!equivalent)
   {
-    fprintf(stderr, "%s, checking\n"
-               "(%f, %f, %f)    (%f, %f, %f)\n"
-               "(%f, %f, %f) == (%f, %f, %f)\n"
-               "(%f, %f, %f)    (%f, %f, %f)\n",
+    // Align each float to 1234.67, i.e. 3.6 will be "   3.60"
+    fprintf( stderr, "%s, checking\n"
+               "%7.2f %7.2f %7.2f    %7.2f %7.2f %7.2f\n"
+               "%7.2f %7.2f %7.2f == %7.2f %7.2f %7.2f\n"
+               "%7.2f %7.2f %7.2f    %7.2f %7.2f %7.2f\n",
                location,
-               m1[0],  m1[1], m1[2],   m2[0],  m2[1], m2[2],
-               m1[3],  m1[4], m1[5],   m2[3],  m2[4], m2[5],
-               m1[6],  m1[7], m1[8],   m2[6],  m2[7], m2[8]);
+               m1[0], m1[3], m1[6],    m2[0], m2[3], m2[6],
+               m1[1], m1[4], m1[7],    m2[1], m2[4], m2[7],
+               m1[2], m1[5], m1[8],    m2[2], m2[5], m2[8] );
 
     tet_result(TET_FAIL);
     throw("TET_FAIL");
@@ -174,15 +176,17 @@ void DALI_TEST_EQUALS( const Matrix& matrix1, const Matrix& matrix2, const char*
 
   if (!identical)
   {
-    fprintf(stderr, "%s, checking\n"
-               "(%f, %f, %f, %f)    (%f, %f, %f, %f)\n"
-               "(%f, %f, %f, %f) == (%f, %f, %f, %f)\n"
-               "(%f, %f, %f, %f)    (%f, %f, %f, %f)\n"
-               "(%f, %f, %f, %f)    (%f, %f, %f, %f)\n", location,
-               m1[0],  m1[1],  m1[2],  m1[3],   m2[0],  m2[1],  m2[2],  m2[3],
-               m1[4],  m1[5],  m1[6],  m1[7],   m2[4],  m2[5],  m2[6],  m2[7],
-               m1[8],  m1[9], m1[10], m1[11],   m2[8],  m2[9], m2[10], m2[11],
-              m1[12], m1[13], m1[14], m1[15],  m2[12], m2[13], m2[14], m2[15]);
+    // Align each float to 1234.67, i.e. 3.6 will be "   3.60"
+    fprintf( stderr, "%s, checking\n"
+             "%7.2f %7.2f %7.2f %7.2f    %7.2f %7.2f %7.2f %7.2f\n"
+             "%7.2f %7.2f %7.2f %7.2f == %7.2f %7.2f %7.2f %7.2f\n"
+             "%7.2f %7.2f %7.2f %7.2f    %7.2f %7.2f %7.2f %7.2f\n"
+             "%7.2f %7.2f %7.2f %7.2f    %7.2f %7.2f %7.2f %7.2f\n",
+             location,
+             m1[0], m1[4], m1[8],  m1[12],    m2[0], m2[4], m2[8],  m2[12],
+             m1[1], m1[5], m1[9],  m1[13],    m2[1], m2[5], m2[9],  m2[13],
+             m1[2], m1[6], m1[10], m1[14],    m2[2], m2[6], m2[10], m2[14],
+             m1[3], m1[7], m1[11], m1[15],    m2[3], m2[7], m2[11], m2[15] );
 
     tet_result(TET_FAIL);
     throw("TET_FAIL");
@@ -206,15 +210,17 @@ void DALI_TEST_EQUALS( const Matrix& matrix1, const Matrix& matrix2, float epsil
 
   if (!equivalent)
   {
-    fprintf(stderr, "%s, checking\n"
-               "(%f, %f, %f, %f)    (%f, %f, %f, %f)\n"
-               "(%f, %f, %f, %f) == (%f, %f, %f, %f)\n"
-               "(%f, %f, %f, %f)    (%f, %f, %f, %f)\n"
-               "(%f, %f, %f, %f)    (%f, %f, %f, %f)\n", location,
-               m1[0],  m1[1],  m1[2],  m1[3],   m2[0],  m2[1],  m2[2],  m2[3],
-               m1[4],  m1[5],  m1[6],  m1[7],   m2[4],  m2[5],  m2[6],  m2[7],
-               m1[8],  m1[9], m1[10], m1[11],   m2[8],  m2[9], m2[10], m2[11],
-              m1[12], m1[13], m1[14], m1[15],  m2[12], m2[13], m2[14], m2[15]);
+    // Align each float to 1234.67, i.e. 3.6 will be "   3.60"
+    fprintf( stderr, "%s, checking\n"
+             "%7.2f %7.2f %7.2f %7.2f    %7.2f %7.2f %7.2f %7.2f\n"
+             "%7.2f %7.2f %7.2f %7.2f == %7.2f %7.2f %7.2f %7.2f\n"
+             "%7.2f %7.2f %7.2f %7.2f    %7.2f %7.2f %7.2f %7.2f\n"
+             "%7.2f %7.2f %7.2f %7.2f    %7.2f %7.2f %7.2f %7.2f\n",
+             location,
+             m1[0], m1[4], m1[8],  m1[12],    m2[0], m2[4], m2[8],  m2[12],
+             m1[1], m1[5], m1[9],  m1[13],    m2[1], m2[5], m2[9],  m2[13],
+             m1[2], m1[6], m1[10], m1[14],    m2[2], m2[6], m2[10], m2[14],
+             m1[3], m1[7], m1[11], m1[15],    m2[3], m2[7], m2[11], m2[15] );
 
     tet_result(TET_FAIL);
     throw("TET_FAIL");
index 989ad95..deb8eb8 100644 (file)
@@ -109,9 +109,6 @@ int UtcDaliLayouting_HboxLayout01(void)
   END_TEST;
 }
 
-
-
-
 int UtcDaliLayouting_HboxLayout02(void)
 {
   ToolkitTestApplication application;
@@ -317,9 +314,6 @@ int UtcDaliLayouting_HboxLayout03(void)
   END_TEST;
 }
 
-
-
-
 int UtcDaliLayouting_HboxLayout04(void)
 {
   ToolkitTestApplication application;
@@ -420,6 +414,299 @@ int UtcDaliLayouting_HboxLayout04(void)
   END_TEST;
 }
 
+// Padding tests
+
+int UtcDaliLayouting_HboxLayout_Padding01(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child");
+
+  Stage stage = Stage::GetCurrent();
+  auto hbox = Control::New();
+  auto hboxLayout = HboxLayout::New();
+  DevelControl::SetLayout( hbox, hboxLayout );
+  hbox.SetName( "HBox");
+
+  std::vector< Control > controls;
+  controls.push_back( CreateLeafControl( 40, 40 ) );
+  controls.push_back( CreateLeafControl( 60, 40 ) );
+  controls.push_back( CreateLeafControl( 80, 40 ) );
+  controls.push_back( CreateLeafControl( 100, 40 ) );
+
+  const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
+  tet_printf( "\nAdding Padding to control at index %u \n", 1 );
+  controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
+
+  for( auto&& iter : controls )
+  {
+    hbox.Add( iter );
+  }
+  hbox.SetParentOrigin( ParentOrigin::CENTER );
+  hbox.SetAnchorPoint( AnchorPoint::CENTER );
+  stage.Add( hbox );
+
+  // Ensure layouting happens
+  application.SendNotification();
+  application.Render();
+
+  // hbox centers elements vertically, it fills test harness stage, which is 480x800.
+  // hbox left justifies elements
+  tet_infoline("Test Child Actor Position");
+  float xPositionOfControlBeingTested = 0.0f;
+  DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+                                                                                            380.0f,
+                                                                                            0.0f ), 0.0001f, TEST_LOCATION );
+  xPositionOfControlBeingTested += 40.0f;
+
+  DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+                                                                                            380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
+                                                                                            0.0001f, TEST_LOCATION );
+
+  xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
+  DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  xPositionOfControlBeingTested += 80.0f;
+  DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  tet_infoline("Test Child Actor Size");
+  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 + CONTROL_PADDING.start + CONTROL_PADDING.end,
+                                                                                        40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ),
+                                                                                        0.0001f, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+  DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliLayouting_HboxLayout_Padding02(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children");
+
+  Stage stage = Stage::GetCurrent();
+  auto hbox = Control::New();
+  auto hboxLayout = HboxLayout::New();
+  DevelControl::SetLayout( hbox, hboxLayout );
+  hbox.SetName( "HBox");
+
+  std::vector< Control > controls;
+  controls.push_back( CreateLeafControl( 40, 40 ) );
+  controls.push_back( CreateLeafControl( 60, 40 ) );
+  controls.push_back( CreateLeafControl( 80, 40 ) );
+  controls.push_back( CreateLeafControl( 100, 40 ) );
+
+  const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
+
+  for( auto&& iter : controls )
+  {
+    iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
+    hbox.Add( iter );
+  }
+  hbox.SetParentOrigin( ParentOrigin::CENTER );
+  hbox.SetAnchorPoint( AnchorPoint::CENTER );
+  stage.Add( hbox );
+
+  // Ensure layouting happens
+  application.SendNotification();
+  application.Render();
+
+  // hbox centers elements vertically, it fills test harness stage, which is 480x800.
+  // hbox left justifies elements
+  tet_infoline("Test Child Actor Position");
+  float xPositionOfControlBeingTested = 0.0f;
+  float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) );
+
+  DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+                                                                                            yPositionOfControlBeingTested,
+                                                                                            0.0f ), 0.0001f, TEST_LOCATION );
+  xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
+
+  DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+                                                                                            yPositionOfControlBeingTested,
+                                                                                            0.0f ),
+                                                                                            0.0001f, TEST_LOCATION );
+
+  xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
+  DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+                                                                                            yPositionOfControlBeingTested,
+                                                                                            0.0f ), 0.0001f, TEST_LOCATION );
+
+  xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
+  DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+                                                                                            yPositionOfControlBeingTested,
+                                                                                            0.0f ), 0.0001f, TEST_LOCATION );
+
+  tet_infoline("Test Child Actor Size");
+  DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
+                                                                                        40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
+                                                                                        0.0f ), 0.0001f, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
+                                                                                        40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
+                                                                                        0.0f ), 0.0001f, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end ,
+                                                                                        40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
+                                                                                        0.0f ), 0.0001f, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end,
+                                                                                        40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom,
+                                                                                        0.0f ), 0.0001f, TEST_LOCATION );
+
+  END_TEST;
+}
+
+
+int UtcDaliLayouting_HboxLayout_Padding03(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Adding Changing padding on a single child");
+
+  Stage stage = Stage::GetCurrent();
+  auto hbox = Control::New();
+  auto hboxLayout = HboxLayout::New();
+  DevelControl::SetLayout( hbox, hboxLayout );
+  hbox.SetName( "HBox");
+
+  std::vector< Control > controls;
+  controls.push_back( CreateLeafControl( 40, 40 ) );
+  controls.push_back( CreateLeafControl( 40, 40 ) );
+  controls.push_back( CreateLeafControl( 40, 40 ) );
+
+  const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 );
+  tet_printf( "\nAdding Padding to control at index 1 \n" );
+  controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING );
+
+  for( auto&& iter : controls )
+  {
+    hbox.Add( iter );
+  }
+  hbox.SetParentOrigin( ParentOrigin::CENTER );
+  hbox.SetAnchorPoint( AnchorPoint::CENTER );
+  stage.Add( hbox );
+
+  // Ensure layouting happens
+  application.SendNotification();
+  application.Render();
+
+  // hbox centers elements vertically, it fills test harness stage, which is 480x800.
+  // hbox left justifies elements
+  tet_infoline("Test Child Actor Position");
+  float xPositionOfControlBeingTested = 0.0f;
+  DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+                                                                                            380.0f,
+                                                                                            0.0f ), 0.0001f, TEST_LOCATION );
+  xPositionOfControlBeingTested += 40.0f;
+
+  DALI_TEST_EQUALS( controls[ 1 ].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+                                                                                            380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
+                                                                                            0.0001f, TEST_LOCATION );
+
+  xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end;
+  DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 );
+  tet_printf( "\nChanging Padding to control at index 1 \n" );
+  controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING );
+
+  // Ensure layouting happens
+  application.SendNotification();
+  application.Render();
+
+  xPositionOfControlBeingTested = 0.0f; // reset
+
+  tet_infoline("Test Child Actor Position");
+  DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+                                                                                            380.0f,
+                                                                                            0.0f ), 0.0001f, TEST_LOCATION );
+  xPositionOfControlBeingTested += 40.0f;
+
+  DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+                                                                                            380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ),                                                                                            0.0f ),
+                                                                                            0.0001f, TEST_LOCATION );
+
+  xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end;
+  tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end );
+  DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  tet_infoline("Test Child Actor Size");
+  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( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end,
+                                                                                        40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ),
+                                                                                        0.0001f, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  END_TEST;
+}
+
+// Margin Tests
+
+int UtcDaliLayouting_HboxLayout_Margin01(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child");
+
+  Stage stage = Stage::GetCurrent();
+  auto hbox = Control::New();
+  auto hboxLayout = HboxLayout::New();
+  DevelControl::SetLayout( hbox, hboxLayout );
+  hbox.SetName( "HBox");
+
+  std::vector< Control > controls;
+  controls.push_back( CreateLeafControl( 40, 40 ) );
+  controls.push_back( CreateLeafControl( 60, 40 ) );
+  controls.push_back( CreateLeafControl( 80, 40 ) );
+  controls.push_back( CreateLeafControl( 100, 40 ) );
+
+  const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 );
+  tet_printf( "\nAdding Margin to control at index 1 \n" );
+  controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN );
+
+  for( auto&& iter : controls )
+  {
+    hbox.Add( iter );
+  }
+  hbox.SetParentOrigin( ParentOrigin::CENTER );
+  hbox.SetAnchorPoint( AnchorPoint::CENTER );
+  stage.Add( hbox );
+
+  // Ensure layouting happens
+  application.SendNotification();
+  application.Render();
+
+  // hbox centers elements vertically, it fills test harness stage, which is 480x800.
+  // hbox left justifies elements
+  tet_infoline("Test Child Actor Position");
+  auto xPositionOfControlBeingTested = 0.0f;
+  DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+                                                                                            380.0f,
+                                                                                            0.0f ), 0.0001f, TEST_LOCATION );
+  xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start;
+
+  DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,
+                                                                                            380.0f + CONTROL_MARGIN.top, 0.0f ),
+                                                                                            0.0001f, TEST_LOCATION );
+
+  xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end;
+  DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  xPositionOfControlBeingTested += 80.0f;
+  DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  tet_infoline("Test Child Actor Size is the same after Margin added");
+  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 );
+  DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+  DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  END_TEST;
+}
+
 
 int UtcDaliLayouting_VboxLayout01(void)
 {
index 21fb391..9df05c6 100644 (file)
  */
 
 // CLASS HEADER
+#include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
+
+// EXTERNAL INCLUDES
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali/devel-api/actors/actor-devel.h>
 #include <dali/devel-api/object/handle-devel.h>
-#include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
+#include <dali/integration-api/debug.h>
+
+// INTERNAL INCLUDES
 #include <dali-toolkit/internal/layouting/layout-group-data-impl.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
 
-
 namespace
 {
-const char* MARGIN_SPECIFICATION_NAME( "marginSpec" );
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_LAYOUT" );
+#endif
 }
 
 namespace Dali
@@ -176,7 +182,12 @@ void LayoutGroup::DoRegisterChildProperties( const std::string& containerType )
 
 void LayoutGroup::OnSetChildProperties( Handle& handle, Property::Index index, Property::Value value )
 {
-  if ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) )
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnSetChildProperties");
+
+  if ( ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) &&
+         ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) )
+       ||
+       ( index == Toolkit::Control::Property::MARGIN || index == Toolkit::Control::Property::PADDING ) )
   {
     // If any child properties are set, must perform relayout
     RequestLayout();
@@ -189,7 +200,6 @@ void LayoutGroup::GenerateDefaultChildPropertyValues( Handle child )
                      Toolkit::ChildLayoutData::WRAP_CONTENT );
   child.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION,
                      Toolkit::ChildLayoutData::WRAP_CONTENT );
-  child.SetProperty( Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION, Extents() );
 }
 
 void LayoutGroup::MeasureChildren( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec)
@@ -207,11 +217,47 @@ void LayoutGroup::MeasureChild( LayoutItemPtr child,
                                 MeasureSpec parentWidthMeasureSpec,
                                 MeasureSpec parentHeightMeasureSpec )
 {
+  DALI_LOG_TRACE_METHOD( gLogFilter );
+
   auto childOwner = child->GetOwner();
+
+  auto control = Toolkit::Control::DownCast( childOwner );
+
+#if defined( DEBUG_ENABLED )
+  if ( control )
+  {
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins naturalSizewidth(%f)\n",  control.GetNaturalSize().width );
+  }
+#endif
+
+  // Get last stored width and height specifications for the child
   auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
   auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
 
-  auto padding = GetPadding();
+  // The size of the control could have changed due to padding being altered, the XXX_SPECIFICATIONs will not have been updated.
+  // So GetNaturalSize is called, if the control's natural size includes padding then th size will be updated.
+  if ( control )
+  {
+    auto desiredSize = control.GetNaturalSize();  // Get's child control's size which could include new padding values.
+
+    // Check if WIDTH_SPECIFICATION was a size value, if so then get update to child controls's width.
+    if ( desiredWidth > 0  )
+    {
+      desiredWidth = desiredSize.width;
+      childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, LayoutLength::IntType( desiredWidth ) );
+    }
+
+    // Check if HEIGHT_SPECIFICATION was a size value, if so then get update to child controls's height.
+    if ( desiredHeight > 0)
+    {
+      desiredHeight = desiredSize.height;
+      childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, LayoutLength::IntType( desiredHeight ) );
+    }
+  }
+
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChild desiredWidth(%d)\n",  desiredWidth );
+
+  auto padding = GetPadding(); // Padding of this layout's owner, not of the child being measured.
 
   const MeasureSpec childWidthMeasureSpec = GetChildMeasureSpec( parentWidthMeasureSpec,
                                                                  padding.start + padding.end,
@@ -230,17 +276,20 @@ void LayoutGroup::MeasureChildWithMargins( LayoutItemPtr child,
   auto childOwner = child->GetOwner();
   auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
   auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
-  auto desiredMargin = childOwner.GetProperty<Extents>( Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION );
-  auto padding = GetPadding();
+
+  auto padding = GetPadding(); // Padding of this layout's owner, not of the child being measured.
+
+
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins desiredWidth(%d)\n",  desiredWidth );
 
   MeasureSpec childWidthMeasureSpec = GetChildMeasureSpec( parentWidthMeasureSpec,
                                                            padding.start + padding.end +
-                                                           desiredMargin.start + desiredMargin.end +
                                                            widthUsed, desiredWidth );
 
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins desiredHeight(%d)\n",  desiredHeight );
+
   MeasureSpec childHeightMeasureSpec = GetChildMeasureSpec( parentHeightMeasureSpec,
                                                             padding.top + padding.bottom +
-                                                            desiredMargin.top + desiredMargin.end +
                                                             heightUsed, desiredHeight );
 
   child->Measure( childWidthMeasureSpec, childHeightMeasureSpec );
@@ -255,7 +304,7 @@ MeasureSpec LayoutGroup::GetChildMeasureSpec(
   auto specMode = measureSpec.GetMode();
   LayoutLength specSize = measureSpec.GetSize();
 
-  auto size = std::max( LayoutLength(0), specSize - padding );
+  auto size = std::max( LayoutLength(0), specSize - padding ); // reduce available size by the owners padding
 
   MeasureSpec::IntType resultSize = 0;
   MeasureSpec::Mode resultMode = MeasureSpec::Mode::UNSPECIFIED;
@@ -265,15 +314,19 @@ MeasureSpec LayoutGroup::GetChildMeasureSpec(
     // Parent has imposed an exact size on us
     case MeasureSpec::Mode::EXACTLY:
     {
-
+      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec MeasureSpec::Mode::EXACTLY\n");
       if (childDimension == Toolkit::ChildLayoutData::MATCH_PARENT)
       {
+        DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec childDimension MATCH_PARENT\n");
+
         // Child wants to be our size. So be it.
         resultSize = size;
         resultMode = MeasureSpec::Mode::EXACTLY;
       }
       else if (childDimension == Toolkit::ChildLayoutData::WRAP_CONTENT)
       {
+        DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec childDimension WRAP_CONTENT\n");
+
         // Child wants to determine its own size. It can't be
         // bigger than us.
         resultSize = size;
@@ -281,6 +334,7 @@ MeasureSpec LayoutGroup::GetChildMeasureSpec(
       }
       else
       {
+        DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec childDimension UNSPECIFIED\n");
         resultSize = childDimension;
         resultMode = MeasureSpec::Mode::EXACTLY;
       }
@@ -291,6 +345,7 @@ MeasureSpec LayoutGroup::GetChildMeasureSpec(
       // Parent has imposed a maximum size on us
     case MeasureSpec::Mode::AT_MOST:
     {
+      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec MeasureSpec::Mode::AT_MOST\n");
       if (childDimension == Toolkit::ChildLayoutData::MATCH_PARENT)
       {
         // Child wants to be our size, but our size is not fixed.
@@ -308,7 +363,7 @@ MeasureSpec LayoutGroup::GetChildMeasureSpec(
       else
       {
         // Child wants a specific size... so be it
-        resultSize = childDimension;
+        resultSize = childDimension + padding;
         resultMode = MeasureSpec::Mode::EXACTLY;
       }
 
@@ -318,6 +373,8 @@ MeasureSpec LayoutGroup::GetChildMeasureSpec(
       // Parent asked to see how big we want to be
     case MeasureSpec::Mode::UNSPECIFIED:
     {
+      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec MeasureSpec::Mode::UNSPECIFIED\n");
+
       if (childDimension == Toolkit::ChildLayoutData::MATCH_PARENT)
       {
         // Child wants to be our size... find out how big it should be
@@ -334,13 +391,16 @@ MeasureSpec LayoutGroup::GetChildMeasureSpec(
       else
       {
         // Child wants a specific size... let him have it
-        resultSize = childDimension;
+        resultSize = childDimension + padding;
         resultMode = MeasureSpec::Mode::EXACTLY;
       }
       break;
     }
   }
 
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec resultSize(%u)\n", resultSize );
+
+
   //noinspection ResourceType
   return MeasureSpec( resultSize, resultMode );
 }
@@ -366,19 +426,6 @@ void LayoutGroup::OnInitialize()
 
 void LayoutGroup::OnRegisterChildProperties( const std::string& containerType )
 {
-  auto typeInfo = TypeRegistry::Get().GetTypeInfo( containerType );
-  if( typeInfo )
-  {
-    Property::IndexContainer indices;
-    typeInfo.GetChildPropertyIndices( indices );
-
-    if( std::find( indices.Begin(), indices.End(), Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION ) ==
-        indices.End() )
-    {
-      ChildPropertyRegistration( typeInfo.GetName(), MARGIN_SPECIFICATION_NAME, Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION, Property::EXTENTS );
-    }
-  }
-
   DoRegisterChildProperties( containerType );
 }
 
@@ -391,6 +438,7 @@ void LayoutGroup::ChildAddedToOwner( Actor child )
 {
   LayoutItemPtr childLayout;
   Toolkit::Control control = Toolkit::Control::DownCast( child );
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner(%s)\n", control.GetName().c_str() );
 
   if( control ) // Can only support adding Controls, not Actors to layout
   {
@@ -405,12 +453,13 @@ void LayoutGroup::ChildAddedToOwner( Actor child )
       childLayout->SetAnimateLayout( IsLayoutAnimated() ); // @todo this essentially forces animation inheritance. Bad?
 
       auto desiredSize = control.GetNaturalSize();
+      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner desiredSize(%f,%f) (naturalSize)\n", desiredSize.width, desiredSize.height );
+
       childControlDataImpl.SetLayout( *childLayout.Get() );
 
-      // HBoxLayout will apply default layout data for this object
+      // Default layout data for this object
       child.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, LayoutLength::IntType( desiredSize.width ) );
       child.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, LayoutLength::IntType( desiredSize.height ) );
-      child.SetProperty( Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION, Extents() );
     }
 
     Add( *childLayout.Get() );
@@ -434,14 +483,20 @@ void LayoutGroup::ChildRemovedFromOwner( Actor child )
 
 void LayoutGroup::OnOwnerPropertySet( Handle& handle, Property::Index index, Property::Value value )
 {
+  DALI_LOG_INFO( gLogFilter, Debug::Concise, "LayoutGroup::OnOwnerPropertySet\n");
   auto actor = Actor::DownCast( handle );
-  if( actor && index == Actor::Property::LAYOUT_DIRECTION )
+  if( actor &&
+      (
+        index == Actor::Property::LAYOUT_DIRECTION  ||
+        index == Toolkit::Control::Property::PADDING  ||
+        index == Toolkit::Control::Property::MARGIN
+      )
+    )
   {
     RequestLayout();
   }
 }
 
-
 } // namespace Internal
 } // namespace Toolkit
 } // namespace Dali
index e31045f..be5b0ed 100644 (file)
 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
 #include <dali-toolkit/internal/layouting/layout-item-data-impl.h>
 
+namespace
+{
+
 #if defined(DEBUG_ENABLED)
-    Debug::Filter* gLayoutFilter = Debug::Filter::New( Debug::Verbose, false, "LOG_LAYOUT" );
+Debug::Filter* gLayoutFilter = Debug::Filter::New( Debug::Verbose, false, "LOG_LAYOUT" );
 #endif
 
-namespace
-{
 const char* WIDTH_SPECIFICATION_NAME( "widthSpecification" );
 const char* HEIGHT_SPECIFICATION_NAME( "heightSpecification" );
 
@@ -121,6 +122,8 @@ void LayoutItem::OnRegisterChildProperties( const std::string& containerType )
 
 void LayoutItem::Measure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec )
 {
+  DALI_LOG_TRACE_METHOD( gLayoutFilter );
+
   const bool forceLayout = mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT );
 
   const bool specChanged =
@@ -199,7 +202,34 @@ void LayoutItem::SetMinimumHeight( LayoutLength minimumHeight )
 
 Extents LayoutItem::GetPadding() const
 {
-  return mImpl->mPadding;
+  Toolkit::Control control = Toolkit::Control::DownCast( mImpl->mOwner );
+  if( control )
+  {
+    Extents padding = control.GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+
+    DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutBase::Padding for %s : (%d,%d,%d,%d) \n",
+                   control.GetName().c_str(),
+                   padding.start, padding.end, padding.top, padding.bottom
+                 );
+    return padding;
+  }
+  else
+  {
+    return Extents();
+  }
+}
+
+Extents LayoutItem::GetMargin() const
+{
+  Toolkit::Control control = Toolkit::Control::DownCast( mImpl->mOwner );
+  if ( control )
+  {
+    return control.GetProperty<Extents>( Toolkit::Control::Property::MARGIN );
+  }
+  else
+  {
+    return Extents();
+  }
 }
 
 LayoutLength LayoutItem::GetDefaultSize( LayoutLength size, MeasureSpec measureSpec )
@@ -255,6 +285,11 @@ bool LayoutItem::IsLayoutRequested() const
 
 void LayoutItem::SetMeasuredDimensions( MeasuredSize measuredWidth, MeasuredSize measuredHeight )
 {
+  DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutBase::SetMeasuredDimensions width(%d) height(%d) \n",
+                                                 MeasureSpec::IntType( measuredWidth.GetSize() ),
+                                                 MeasureSpec::IntType( measuredHeight.GetSize() )
+               );
+
   mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_MEASURED_DIMENSION_SET );
   mImpl->mMeasuredWidth = measuredWidth;
   mImpl->mMeasuredHeight = measuredHeight;
index fb12913..e91e7f9 100644 (file)
@@ -289,11 +289,17 @@ public:
   LayoutLength GetMinimumHeight() const;
 
   /**
-   * Get the padding information
+   * Get the padding information.
    * @return The padding information
    */
   Extents GetPadding() const;
 
+  /**
+   * Get the margin information.
+   * @return The margin information
+   */
+  Extents GetMargin() const;
+
 protected:
   /**
    * @brief Allow directly deriving classes to remove layout children when unparented
@@ -307,7 +313,6 @@ protected:
    */
   virtual void OnRegisterChildProperties( const std::string& containerType );
 
-
   /**
    * @brief Measure the layout and its content to determine the measured width and the
    * measured height.
index ca86db6..0caf08d 100644 (file)
 #include <dali-toolkit/public-api/controls/control-impl.h>
 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
 
-
+namespace
+{
 #if defined(DEBUG_ENABLED)
 static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_LAYOUT" );
 #endif
+}
 
 namespace Dali
 {
@@ -106,6 +108,8 @@ void HboxLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeas
   DALI_LOG_INFO( gLogFilter, Debug::Concise, oss.str().c_str() );
 #endif
 
+  DALI_LOG_INFO( gLogFilter, Debug::Concise, "HboxLayout::OnMeasure widthSize(%d) \n", widthMeasureSpec.GetSize());
+
   auto widthMode = widthMeasureSpec.GetMode();
   auto heightMode = heightMeasureSpec.GetMode();
   bool isExactly = (widthMode == MeasureSpec::Mode::EXACTLY);
@@ -128,9 +132,12 @@ void HboxLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeas
       auto childOwner = childLayout->GetOwner();
       auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
 
-      MeasureChildWithMargins( childLayout, widthMeasureSpec, 0, heightMeasureSpec, 0 );
+      MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec );
       auto childWidth = childLayout->GetMeasuredWidth();
-      auto childMargin = childOwner.GetProperty<Extents>( Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION );
+      auto childMargin = childLayout->GetMargin();
+
+      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "HboxLayout::OnMeasure childWidth(%d)\n", MeasureSpec::IntType( childWidth ) );
+
       auto length = childWidth + LayoutLength::IntType(childMargin.start + childMargin.end);
 
       auto cellPadding = i<GetChildCount()-1 ? mCellPadding.width: 0;
@@ -265,8 +272,7 @@ void HboxLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, La
       auto childWidth = childLayout->GetMeasuredWidth();
       auto childHeight = childLayout->GetMeasuredHeight();
 
-      auto childOwner = childLayout->GetOwner();
-      auto childMargin = childOwner.GetProperty<Extents>( Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION );
+      auto childMargin = childLayout->GetMargin();
 
       childTop = LayoutLength(padding.top) + ((childSpace - childHeight) / 2) + childMargin.top - childMargin.bottom;
 
index 90f125b..0ca1847 100644 (file)
 
 using namespace Dali;
 
+namespace
+{
+
 #if defined(DEBUG_ENABLED)
 static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_LAYOUT" );
 #endif
 
+}
+
 namespace Dali
 {
 namespace Toolkit
@@ -105,7 +110,9 @@ void LayoutController::MeasureHierarchy( Actor root, MeasureSpec widthSpec, Meas
   Toolkit::Control control = Toolkit::Control::DownCast( root );
   if( control )
   {
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::Measuring leaf\n" );
     Internal::Control& controlImpl = GetImplementation( control );
+
     Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
     LayoutItemPtr layout = controlDataImpl.GetLayout();
 
@@ -116,6 +123,7 @@ void LayoutController::MeasureHierarchy( Actor root, MeasureSpec widthSpec, Meas
   }
   else
   {
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::Measuring (%u) children\n", root.GetChildCount() );
     // Depth first descent through actor children
     for( unsigned int i = 0, count = root.GetChildCount(); i < count; ++i )
     {
@@ -130,17 +138,20 @@ void LayoutController::PerformLayout( Actor root, int left, int top, int right,
   Toolkit::Control control = Toolkit::Control::DownCast( root );
   if( control )
   {
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::PerformLayout on leaf\n" );
     Internal::Control& controlImpl = GetImplementation( control );
     Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl );
     LayoutItemPtr layout = controlDataImpl.GetLayout();
 
     if( layout )
     {
+      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::PerformLayout on layout\n" );
       layout->Layout( left, top, right, bottom );
     }
   }
   else
   {
+    DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::PerformLayout (%u) children\n", root.GetChildCount() );
     // Depth first descent through actor children
     for( unsigned int i = 0, count = root.GetChildCount(); i < count; ++i )
     {
index d3b394d..cd0460d 100644 (file)
@@ -41,7 +41,7 @@ LayoutItem::Impl::Impl()
   mBottom( 0 ),
   mViewFlags( 0 ),
   mPrivateFlags( 0 ),
-  mAnimated(false)
+  mAnimated( false )
 {
 }
 
index 3758460..0e5c0e7 100644 (file)
@@ -46,9 +46,6 @@ public:
   MeasuredSize mMeasuredWidth;
   MeasuredSize mMeasuredHeight;
 
-  Extents mMargin; ///< Distances in pixels from the edges of this view to this view's parent.
-  Extents mPadding; ///< Distances in pixels from the edges of this view to this view's content.
-
   LayoutLength mLeft;
   LayoutLength mRight;
   LayoutLength mTop;
index 56fb230..3097a21 100644 (file)
@@ -17,7 +17,6 @@
 //CLASS HEADER
 #include <dali-toolkit/internal/layouting/vbox-layout-impl.h>
 
-//EXTERNAL HEADERS
 //INTERNAL HEADERS
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/common/extents.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
 
-
+namespace
+{
 #if defined(DEBUG_ENABLED)
 static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_LAYOUT" );
 #endif
+}
 
 namespace Dali
 {
@@ -165,7 +166,6 @@ void VboxLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeas
       alternativeMaxWidth = std::max( alternativeMaxWidth, matchWidthLocally ? marginWidth : childWidth );
     }
   }
-
   Extents padding = GetPadding();
   mTotalLength += padding.top + padding.bottom;
   auto heightSize = mTotalLength;
@@ -223,7 +223,6 @@ void VboxLayout::ForceUniformWidth( int count, MeasureSpec heightMeasureSpec )
 
 void VboxLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom )
 {
-  auto owner = GetOwner();
   Extents padding = GetPadding();
 
   LayoutLength childTop( 0 );
index 6fbf8ed..f1d7e12 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_INTERNAL_TEXT_VISUAL_H
 
 /*
- * 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.
@@ -220,13 +220,13 @@ private:
   Shader GetTextShader( VisualFactoryCache& factoryCache, bool hasMultipleTextColors, bool containsColorGlyph, bool styleEnabled );
 
   /**
-   * @brief Retrieve the text's controller.
-   * @param[in] visual The text visual.
-   * @return The text controller
+   * @brief Retrieve the TextVisual object.
+   * @param[in] visual A handle to the TextVisual
+   * @return The TextVisual object
    */
   static TextVisual& GetVisualObject( Toolkit::Visual::Base visual )
   {
-    return static_cast<TextVisual&>( visual.GetBaseObject() );
+    return static_cast< TextVisual& >( Toolkit::GetImplementation( visual ).GetVisualObject() );
   };
 
 private:
index 8d2158f..1ae6411 100755 (executable)
@@ -474,6 +474,11 @@ Visual::FittingMode Visual::Base::GetFittingMode() const
   return mImpl->mFittingMode;
 }
 
+Visual::Base& Visual::Base::GetVisualObject()
+{
+  return *this;
+}
+
 Renderer Visual::Base::GetRenderer()
 {
   return mImpl->mRenderer;
index 4839551..02419d2 100644 (file)
@@ -260,6 +260,13 @@ public:
    */
   FittingMode GetFittingMode() const;
 
+  /**
+   * @brief Get the actual Visual Object.
+   * @return The actual visual object
+   * @note Should be overridden by deriving controls if they are acting as a proxy to other visual objects.
+   */
+  virtual Base& GetVisualObject();
+
  protected:
 
   /**
index 238d4ac..227a780 100644 (file)
@@ -240,6 +240,16 @@ void WireframeVisual::OnSetTransform()
   }
 }
 
+Visual::Base& WireframeVisual::GetVisualObject()
+{
+  if( mActualVisual )
+  {
+    return *mActualVisual.Get();
+  }
+
+  return *this;
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
index 9edeca8..d63cfa8 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_INTERNAL_WIREFRAME_VISUAL_H
 
 /*
- * Copyright (c) 2016 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.
@@ -128,6 +128,13 @@ protected: // from Visual::Base
    */
   virtual void OnSetTransform();
 
+  /**
+   * @copydoc Visual::Base::GetVisualObject
+   *
+   * Overriding as this visual can sometimes act as a proxy to the actual visual, i.e. when using debug rendering.
+   */
+  virtual Base& GetVisualObject() override;
+
 private:
   /**
    * Create the geometry which presents the quad wireframe.
index eb6c22f..61a6eab 100644 (file)
@@ -31,7 +31,7 @@ namespace Toolkit
 
 const unsigned int TOOLKIT_MAJOR_VERSION = 1;
 const unsigned int TOOLKIT_MINOR_VERSION = 3;
-const unsigned int TOOLKIT_MICRO_VERSION = 26;
+const unsigned int TOOLKIT_MICRO_VERSION = 27;
 const char * const TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 825a32b..235eded 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali-toolkit
 Summary:    Dali 3D engine Toolkit
-Version:    1.3.26
+Version:    1.3.27
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT