Merge "Exporting one constructor used by csharpbinder and making an API private....
authorDavid Steele <david.steele@samsung.com>
Wed, 20 Jun 2018 13:22:38 +0000 (13:22 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Wed, 20 Jun 2018 13:22:39 +0000 (13:22 +0000)
34 files changed:
automated-tests/src/dali-toolkit/CMakeLists.txt
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp
automated-tests/src/dali-toolkit/utc-Dali-AbsoluteLayout.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp
dali-toolkit/devel-api/file.list
dali-toolkit/devel-api/layouting/absolute-layout.cpp [moved from dali-toolkit/devel-api/layouting/hbox-layout.cpp with 51% similarity]
dali-toolkit/devel-api/layouting/absolute-layout.h [new file with mode: 0644]
dali-toolkit/devel-api/layouting/layout-controller.h
dali-toolkit/devel-api/layouting/layout-group-impl.cpp
dali-toolkit/devel-api/layouting/layout-group-impl.h
dali-toolkit/devel-api/layouting/layout-group.cpp
dali-toolkit/devel-api/layouting/layout-group.h
dali-toolkit/devel-api/layouting/layout-item-impl.cpp
dali-toolkit/devel-api/layouting/layout-item-impl.h
dali-toolkit/devel-api/layouting/layout-item.h
dali-toolkit/devel-api/layouting/layout-parent-impl.h
dali-toolkit/devel-api/layouting/linear-layout.cpp [new file with mode: 0644]
dali-toolkit/devel-api/layouting/linear-layout.h [moved from dali-toolkit/devel-api/layouting/hbox-layout.h with 59% similarity]
dali-toolkit/devel-api/layouting/measure-spec.h
dali-toolkit/devel-api/layouting/measured-size.h
dali-toolkit/devel-api/layouting/vbox-layout.h
dali-toolkit/devel-api/toolkit-property-index-ranges.h
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/file.list
dali-toolkit/internal/layouting/absolute-layout-impl.cpp [new file with mode: 0644]
dali-toolkit/internal/layouting/absolute-layout-impl.h [moved from dali-toolkit/internal/layouting/hbox-layout-impl.h with 50% similarity]
dali-toolkit/internal/layouting/flex-layout-impl.cpp
dali-toolkit/internal/layouting/hbox-layout-impl.cpp [deleted file]
dali-toolkit/internal/layouting/layout-controller-debug.cpp
dali-toolkit/internal/layouting/layout-controller-impl.cpp
dali-toolkit/internal/layouting/linear-layout-impl.cpp [new file with mode: 0644]
dali-toolkit/internal/layouting/linear-layout-impl.h [new file with mode: 0644]
dali-toolkit/internal/layouting/vbox-layout-impl.cpp

index 6af88aa..c3bbf75 100755 (executable)
@@ -7,6 +7,7 @@ SET(CAPI_LIB "dali-toolkit")
 
 # List of test case sources (Only these get parsed for test cases)
 SET(TC_SOURCES
+  utc-Dali-AbsoluteLayout.cpp
   utc-Dali-Alignment.cpp
   utc-Dali-AnimatedImageVisual.cpp
   utc-Dali-BloomView.cpp
index 3ff177c..eb1f2b8 100644 (file)
@@ -97,7 +97,7 @@ void Adaptor::Stop()
 {
 }
 
-bool Adaptor::AddIdle( CallbackBase* callback )
+bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue )
 {
   const bool isAvailable = IsAvailable();
 
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AbsoluteLayout.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AbsoluteLayout.cpp
new file mode 100644 (file)
index 0000000..e443b7e
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * 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 <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.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 <layout-utils.h>
+
+using namespace Dali;
+using namespace Toolkit;
+
+void utc_dali_toolkit_absolute_layout_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void utc_dali_toolkit_absolute_layoutg_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+
+int UtcDaliLayouting_AbsoluteLayoutDownCast(void)
+{
+  TestApplication application;
+  tet_infoline(" UtcDaliLayouting_AbsoluteLayoutDownCast - Testing Downcast");
+
+  AbsoluteLayout absoluteLayout = AbsoluteLayout::New();
+
+  LayoutGroup layoutGroup( absoluteLayout );
+
+  AbsoluteLayout absoluteLayoutCandidate = AbsoluteLayout::DownCast( layoutGroup );
+  DALI_TEST_CHECK( absoluteLayoutCandidate );
+
+  END_TEST;
+}
+
+int UtcDaliLayouting_AbsoluteLayoutAssignment(void)
+{
+  TestApplication application;
+  tet_infoline(" UtcDaliLayouting_AbsoluteLayoutAssignment - Testing operator=");
+
+  AbsoluteLayout absoluteLayout = AbsoluteLayout::New();
+  AbsoluteLayout absoluteLayout2;
+
+  absoluteLayout2 = absoluteLayout;
+
+  DALI_TEST_CHECK( absoluteLayout2 == absoluteLayout );
+
+  END_TEST;
+}
+
+
+int UtcDaliLayouting_AbsoluteLayout01(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliLayouting_AbsoluteLayout01 - Position an item with Actor::Property::POSITION");
+
+  Stage stage = Stage::GetCurrent();
+  auto absoluteLayout = Control::New();
+  auto layout = AbsoluteLayout::New();
+  DevelControl::SetLayout( absoluteLayout, layout );
+  absoluteLayout.SetName( "AsoluteLayout");
+
+  std::vector< Control > controls;
+  controls.push_back( CreateLeafControl( 100, 100 ) );
+  controls.push_back( CreateLeafControl( 100, 100 ) );
+  controls.push_back( CreateLeafControl( 100, 100 ) );
+  controls.push_back( CreateLeafControl( 100, 100 ) );
+
+  // Position one of the  controls using the actor property.
+  controls[1].SetProperty(Actor::Property::POSITION, Vector3( 100.0f, 0.0f, 0.0f) );
+
+  for( auto&& iter : controls )
+  {
+    absoluteLayout.Add( iter );
+  }
+  absoluteLayout.SetParentOrigin( ParentOrigin::CENTER );
+  absoluteLayout.SetAnchorPoint( AnchorPoint::CENTER );
+  stage.Add( absoluteLayout );
+
+  // Ensure layouting happens
+  application.SendNotification();
+  application.Render();
+
+  // AbsoluteLayout renders items at the positions given by their Actor::Property::POSITION relative to the top left of the container.
+  // Items can overlap or spill out of their parent container.
+  DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  // The controls[1] was the only control to have a defiend position
+  DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+  DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+  DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  // Items size should not change regardless of parent's size.
+  DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+  DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+  DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+  DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  END_TEST;
+}
\ No newline at end of file
index 6abc0c7..c081c33 100644 (file)
@@ -21,8 +21,8 @@
 
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
-#include <dali-toolkit/devel-api/layouting/hbox-layout.h>
-#include <dali-toolkit/devel-api/layouting/vbox-layout.h>
+#include <dali-toolkit/devel-api/layouting/absolute-layout.h>
+#include <dali-toolkit/devel-api/layouting/linear-layout.h>
 
 #include <layout-utils.h>
 
@@ -46,7 +46,7 @@ int UtcDaliLayouting_HboxLayout01(void)
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
-  auto hboxLayout = HboxLayout::New();
+  auto hboxLayout = LinearLayout::New();
   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
@@ -81,6 +81,19 @@ int UtcDaliLayouting_HboxLayout01(void)
   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 );
 
+  // Change a layout
+  auto newHBoxLayout = LinearLayout::New();
+  newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
+  DevelControl::SetLayout( hbox, newHBoxLayout );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+  DALI_TEST_EQUALS( controls[1].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+  DALI_TEST_EQUALS( controls[2].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+  DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
   END_TEST;
 }
 
@@ -92,11 +105,11 @@ int UtcDaliLayouting_HboxLayout02(void)
   Stage stage = Stage::GetCurrent();
 
   auto hbox1 = Control::New();
-  auto hboxLayout1 = HboxLayout::New();
+  auto hboxLayout1 = LinearLayout::New();
   DevelControl::SetLayout( hbox1, hboxLayout1 );
 
   auto hbox2 = Control::New();
-  auto hboxLayout2 = HboxLayout::New();
+  auto hboxLayout2 = LinearLayout::New();
   DevelControl::SetLayout( hbox2, hboxLayout2 );
 
   hbox1.SetName( "HBox1");
@@ -132,7 +145,7 @@ int UtcDaliLayouting_HboxLayout02(void)
   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
 
   auto hbox3 = Control::New();
-  auto hboxLayout3 = HboxLayout::New();
+  auto hboxLayout3 = LinearLayout::New();
   DevelControl::SetLayout( hbox3, hboxLayout3 );
 
   hbox3.SetParentOrigin( ParentOrigin::CENTER );
@@ -192,11 +205,11 @@ int UtcDaliLayouting_HboxLayout03(void)
   Stage stage = Stage::GetCurrent();
 
   auto hbox1 = Control::New();
-  auto hboxLayout1 = HboxLayout::New();
+  auto hboxLayout1 = LinearLayout::New();
   DevelControl::SetLayout( hbox1, hboxLayout1 );
 
   auto hbox2 = Control::New();
-  auto hboxLayout2 = HboxLayout::New();
+  auto hboxLayout2 = LinearLayout::New();
   DevelControl::SetLayout( hbox2, hboxLayout2 );
 
   hbox1.SetName( "HBox1");
@@ -236,7 +249,7 @@ int UtcDaliLayouting_HboxLayout03(void)
   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
 
   auto hbox3 = Control::New();
-  auto hboxLayout3 = HboxLayout::New();
+  auto hboxLayout3 = LinearLayout::New();
   DevelControl::SetLayout( hbox3, hboxLayout3);
 
   hbox3.SetParentOrigin( ParentOrigin::CENTER );
@@ -297,11 +310,11 @@ int UtcDaliLayouting_HboxLayout04(void)
   Stage stage = Stage::GetCurrent();
 
   auto hbox1 = Control::New();
-  auto hboxLayout1 = HboxLayout::New();
+  auto hboxLayout1 = LinearLayout::New();
   DevelControl::SetLayout( hbox1, hboxLayout1 );
 
   auto hbox2 = Control::New();
-  auto hboxLayout2 = HboxLayout::New();
+  auto hboxLayout2 = LinearLayout::New();
   DevelControl::SetLayout( hbox2, hboxLayout2 );
 
   hbox1.SetName( "HBox1"); // Default spec is to wrap content
@@ -338,7 +351,7 @@ int UtcDaliLayouting_HboxLayout04(void)
 
   controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
   auto hbox3 = Control::New();
-  auto hboxLayout3 = HboxLayout::New();
+  auto hboxLayout3 = LinearLayout::New();
   DevelControl::SetLayout( hbox3, hboxLayout3 );
 
   hbox3.SetParentOrigin( ParentOrigin::CENTER );
@@ -396,7 +409,7 @@ int UtcDaliLayouting_HboxLayout05(void)
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
-  auto hboxLayout = HboxLayout::New();
+  auto hboxLayout = LinearLayout::New();
   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
@@ -437,6 +450,85 @@ int UtcDaliLayouting_HboxLayout05(void)
   END_TEST;
 }
 
+int UtcDaliLayouting_HboxLayout06(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliLayouting_HboxLayout06 - Test nested layouts");
+
+  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 );
+
+  // Ensure layouting happens
+  application.SendNotification();
+  application.Render();
+
+  // hbox centers elements vertically, it fills test harness stage, which is 480x800.
+  // hbox left justifies elements
+  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 );
+
+  DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  // Change a layout
+  auto newHBoxLayout = LinearLayout::New();
+  newHBoxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
+  DevelControl::SetLayout( hbox, newHBoxLayout );
+
+  hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+  hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  // Change size specification
+  hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
+  hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  // Use WRAP_CONTENT again
+  hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+  hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( hbox.GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  END_TEST;
+}
+
 // Padding tests
 
 int UtcDaliLayouting_HboxLayout_Padding01(void)
@@ -446,7 +538,7 @@ int UtcDaliLayouting_HboxLayout_Padding01(void)
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
-  auto hboxLayout = HboxLayout::New();
+  auto hboxLayout = LinearLayout::New();
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
 
@@ -511,7 +603,7 @@ int UtcDaliLayouting_HboxLayout_Padding02(void)
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
-  auto hboxLayout = HboxLayout::New();
+  auto hboxLayout = LinearLayout::New();
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
 
@@ -590,7 +682,7 @@ int UtcDaliLayouting_HboxLayout_Padding03(void)
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
-  auto hboxLayout = HboxLayout::New();
+  auto hboxLayout = LinearLayout::New();
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
 
@@ -676,7 +768,7 @@ int UtcDaliLayouting_HboxLayout_Margin01(void)
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
-  auto hboxLayout = HboxLayout::New();
+  auto hboxLayout = LinearLayout::New();
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
 
@@ -738,7 +830,8 @@ int UtcDaliLayouting_VboxLayout01(void)
 
   Stage stage = Stage::GetCurrent();
   auto vbox = Control::New();
-  auto vboxLayout = VboxLayout::New();
+  auto vboxLayout = LinearLayout::New();
+  vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
   DevelControl::SetLayout( vbox, vboxLayout );
   vbox.SetName( "Vbox");
 
@@ -790,17 +883,18 @@ int UtcDaliLayouting_VboxLayout02(void)
   // LayoutGroup for this to happen automatically.
   //
   // For this test, add an hbox instead
-  auto hbox = Control::New();
-  auto hboxLayout = HboxLayout::New();
-  DevelControl::SetLayout( hbox, hboxLayout );
-  hbox.SetName( "Hbox");
-  stage.Add( hbox );
+  auto rootControl = Control::New();
+  auto absoluteLayout = AbsoluteLayout::New();
+  DevelControl::SetLayout( rootControl, absoluteLayout );
+  rootControl.SetName( "AbsoluteLayout");
+  stage.Add( rootControl );
 
   auto vbox = Control::New();
-  auto vboxLayout = VboxLayout::New();
+  auto vboxLayout = LinearLayout::New();
+  vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
   DevelControl::SetLayout( vbox, vboxLayout );
   vbox.SetName( "Vbox");
-  hbox.Add( vbox );
+  rootControl.Add( vbox );
 
   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
   vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
@@ -827,8 +921,8 @@ int UtcDaliLayouting_VboxLayout02(void)
   application.SendNotification();
   application.Render();
 
-  DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
-  DALI_TEST_EQUALS( hbox.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
+  DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION);
+  DALI_TEST_EQUALS( rootControl.GetProperty<Vector3>(Actor::Property::SIZE), Vector3(480,800,0),TEST_LOCATION);
 
   // vbox centers elements horizontally, it should wrap it's content horizontally, i.e. it should take the width of the largest element (100)
   DALI_TEST_EQUALS( vbox.GetProperty<Vector3>( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION );
@@ -861,14 +955,15 @@ int UtcDaliLayouting_VboxLayout03(void)
   //
   // For this test, add an hbox instead
   auto hbox = Control::New();
-  auto hboxLayout = HboxLayout::New();
+  auto hboxLayout = LinearLayout::New();
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "Hbox");
   stage.Add( hbox );
 
   auto vbox = Control::New();
-  auto vboxLayout = VboxLayout::New();
+  auto vboxLayout = LinearLayout::New();
   vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) );
+  vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
 
   DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
 
index 3e81854..dadce6e 100755 (executable)
@@ -32,8 +32,8 @@ devel_api_src_files = \
   $(devel_api_src_dir)/image-loader/image-atlas.cpp \
   $(devel_api_src_dir)/image-loader/texture-manager.cpp \
   $(devel_api_src_dir)/layouting/flex-layout.cpp \
-  $(devel_api_src_dir)/layouting/hbox-layout.cpp \
-  $(devel_api_src_dir)/layouting/vbox-layout.cpp \
+  $(devel_api_src_dir)/layouting/absolute-layout.cpp \
+  $(devel_api_src_dir)/layouting/linear-layout.cpp \
   $(devel_api_src_dir)/layouting/layout-item.cpp \
   $(devel_api_src_dir)/layouting/layout-item-impl.cpp \
   $(devel_api_src_dir)/layouting/layout-controller.cpp \
@@ -81,10 +81,10 @@ devel_api_effects_view_header_files = \
   $(devel_api_src_dir)/controls/effects-view/effects-view.h
 
 devel_api_layouting_header_files = \
+  $(devel_api_src_dir)/layouting/absolute-layout.h \
   $(devel_api_src_dir)/layouting/child-layout-data.h \
   $(devel_api_src_dir)/layouting/flex-layout.h \
-  $(devel_api_src_dir)/layouting/hbox-layout.h \
-  $(devel_api_src_dir)/layouting/vbox-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-controller.h \
  */
 
 //CLASS HEADER
-#include <dali-toolkit/devel-api/layouting/hbox-layout.h>
+#include <dali-toolkit/devel-api/layouting/absolute-layout.h>
 
-//EXTERNAL HEADERS
 //INTERNAL HEADERS
-#include <dali-toolkit/internal/layouting/hbox-layout-impl.h>
+#include <dali-toolkit/internal/layouting/absolute-layout-impl.h>
 
 namespace Dali
 {
 namespace Toolkit
 {
 
-HboxLayout::HboxLayout()
+AbsoluteLayout::AbsoluteLayout()
 {
 }
 
-HboxLayout HboxLayout::New()
+AbsoluteLayout AbsoluteLayout::New()
 {
-  Internal::HboxLayoutPtr internal = Internal::HboxLayout::New();
-  return HboxLayout( internal.Get() );
+  Internal::AbsoluteLayoutPtr internal = Internal::AbsoluteLayout::New();
+  return AbsoluteLayout( internal.Get() );
 }
 
-HboxLayout HboxLayout::DownCast( BaseHandle handle )
+AbsoluteLayout AbsoluteLayout::DownCast( BaseHandle handle )
 {
-  return HboxLayout( dynamic_cast< Dali::Toolkit::Internal::HboxLayout*>( handle.GetObjectPtr() ) );
+  return AbsoluteLayout( dynamic_cast< Dali::Toolkit::Internal::AbsoluteLayout*>( handle.GetObjectPtr() ) );
 }
 
-HboxLayout::HboxLayout( const HboxLayout& other )
+AbsoluteLayout::AbsoluteLayout( const AbsoluteLayout& other )
 : LayoutGroup( other )
 {
 }
 
-HboxLayout& HboxLayout::operator=( const HboxLayout& other )
+AbsoluteLayout& AbsoluteLayout::operator=( const AbsoluteLayout& other )
 {
   if( &other != this )
   {
@@ -55,17 +54,7 @@ HboxLayout& HboxLayout::operator=( const HboxLayout& other )
   return *this;
 }
 
-void HboxLayout::SetCellPadding( LayoutSize size )
-{
-  GetImplementation(*this).SetCellPadding( size );
-}
-
-LayoutSize HboxLayout::GetCellPadding()
-{
-  return GetImplementation(*this).GetCellPadding();
-}
-
-HboxLayout::HboxLayout( Dali::Toolkit::Internal::HboxLayout* object )
+AbsoluteLayout::AbsoluteLayout( Dali::Toolkit::Internal::AbsoluteLayout* object )
 : LayoutGroup( object )
 {
 }
diff --git a/dali-toolkit/devel-api/layouting/absolute-layout.h b/dali-toolkit/devel-api/layouting/absolute-layout.h
new file mode 100644 (file)
index 0000000..5face16
--- /dev/null
@@ -0,0 +1,109 @@
+#ifndef DALI_TOOLKIT_LAYOUTING_ABSOLUTE_LAYOUT_H
+#define DALI_TOOLKIT_LAYOUTING_ABSOLUTE_LAYOUT_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/public-api/common/dali-common.h>
+#include <dali/public-api/object/base-handle.h>
+#include <dali-toolkit/devel-api/layouting/layout-group.h>
+#include <dali-toolkit/devel-api/layouting/layout-size.h>
+#include <dali-toolkit/public-api/toolkit-property-index-ranges.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+namespace Internal DALI_INTERNAL
+{
+class AbsoluteLayout;
+}
+
+/**
+ * This class implements a absolute layout, allowing explict positioning of
+ * children.
+ * Positions are from the top left of the layout and can be set using the
+ * Actor::Property::POSITION and alike.
+ */
+class DALI_TOOLKIT_API AbsoluteLayout : public LayoutGroup
+{
+public:
+
+  enum PropertyRange
+  {
+    CHILD_PROPERTY_START_INDEX = ABSOLUTE_LAYOUT_CHILD_PROPERTY_START_INDEX,
+    CHILD_PROPERTY_END_INDEX   = ABSOLUTE_LAYOUT_CHILD_PROPERTY_END_INDEX
+  };
+
+  /**
+   * @brief Creates an uninitialized AbsoluteLayout handle.
+   *
+   * Initialize it using AbsoluteLayout::New().
+   * Calling member functions with an uninitialized handle is not allowed.
+   */
+  AbsoluteLayout();
+
+  /**
+   * @brief Creates a AbsoluteLayout object.
+   */
+  static AbsoluteLayout New();
+
+  /**
+   * @brief Downcasts a handle to a AbsoluteLayout handle.
+   *
+   * If handle points to a AbsoluteLayout, the downcast produces a valid handle.
+   * If not, the returned handle is left uninitialized.
+
+   * @param[in] handle to an object
+   * @return Handle to a AbsoluteLayout or an uninitialized handle
+   */
+  static AbsoluteLayout DownCast( BaseHandle handle );
+
+  /**
+   * @brief Copy constructor
+   */
+  AbsoluteLayout( const AbsoluteLayout& other );
+
+  /**
+   * @brief Assigment operator
+   */
+  AbsoluteLayout& operator=( const AbsoluteLayout& other );
+
+  /**
+   * @brief Default destructor.
+   *
+   * This is non-virtual, since derived Handle types must not contain data or virtual methods
+   */
+  ~AbsoluteLayout()=default;
+
+
+public: // Not intended for application developers
+
+  /// @cond internal
+  /**
+   * @brief This constructor is used by AbsoluteLayout::New() methods.
+   *
+   * @param[in] actor A pointer to a newly allocated Dali resource
+   */
+  explicit DALI_INTERNAL AbsoluteLayout( Internal::AbsoluteLayout* body );
+  /// @endcond
+};
+
+} // namespace Toolkit
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_LAYOUTING_ABSOLUTE_LAYOUT_H
index db5cc5b..fe955a4 100644 (file)
@@ -36,7 +36,7 @@ class LayoutController;
  * @brief Controls the process of layouting the control tree. It provides methods to enable
  * controls to re-layout and internal systems to separately measure and layout controls.
  */
-class DALI_IMPORT_API LayoutController : public BaseHandle
+class DALI_TOOLKIT_API LayoutController : public BaseHandle
 {
 public:
   /**
index 10bfe2d..1f643cc 100644 (file)
@@ -31,7 +31,7 @@
 namespace
 {
 #if defined(DEBUG_ENABLED)
-Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_LAYOUT" );
+Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" );
 #endif
 }
 
@@ -71,6 +71,8 @@ Toolkit::LayoutGroup::LayoutId LayoutGroup::Add( LayoutItem& child )
   childLayout.child = &child;
   mImpl->mChildren.emplace_back( childLayout );
 
+  child.SetParent( this );
+
   auto owner = child.GetOwner();
 
   // If the owner does not have any LayoutItem child properties, add them
@@ -122,7 +124,7 @@ void LayoutGroup::Remove( LayoutItem& child )
 
 void LayoutGroup::RemoveAll()
 {
-  for( auto iter = mImpl->mChildren.begin() ; iter != mImpl->mChildren.end() ; ++iter )
+  for( auto iter = mImpl->mChildren.begin() ; iter != mImpl->mChildren.end() ; )
   {
     OnChildRemove( *iter->child.Get() );
     iter = mImpl->mChildren.erase(iter);
@@ -406,6 +408,20 @@ void LayoutGroup::OnInitialize()
     DevelActor::ChildAddedSignal( control ).Connect( mSlotDelegate, &LayoutGroup::ChildAddedToOwner );
     DevelActor::ChildRemovedSignal( control ).Connect( mSlotDelegate, &LayoutGroup::ChildRemovedFromOwner );
     DevelHandle::PropertySetSignal( control ).Connect( mSlotDelegate, &LayoutGroup::OnOwnerPropertySet );
+
+    if( control.GetParent() )
+    {
+      auto parent = Toolkit::Control::DownCast( control.GetParent() );
+      if( parent )
+      {
+        auto parentLayout = Toolkit::LayoutGroup::DownCast( DevelControl::GetLayout( parent ) );
+        if( parentLayout )
+        {
+          Internal::LayoutGroup& parentLayoutImpl = GetImplementation( parentLayout );
+          parentLayoutImpl.Add( *this );
+        }
+      }
+    }
   }
 }
 
@@ -416,7 +432,19 @@ void LayoutGroup::OnRegisterChildProperties( const std::string& containerType )
 
 void LayoutGroup::OnUnparent()
 {
+  // 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::ChildAddedToOwner( Actor child )
index 025950c..f827c30 100644 (file)
@@ -54,8 +54,8 @@ using LayoutGroupPtr = IntrusivePtr<LayoutGroup>;
  * OnLayout should use it's own layout parameters and the measured children's size to determine the children's
  * position and size; it should then call Layout() on the child layout to layout the child and it's hierarchy.
  */
-class DALI_IMPORT_API LayoutGroup : public LayoutItem,
-                                    public ConnectionTracker
+class DALI_TOOLKIT_API LayoutGroup : public LayoutItem,
+                                     public ConnectionTracker
 {
 public:
   /**
index dd36ddc..b13da31 100644 (file)
@@ -27,6 +27,11 @@ LayoutGroup::LayoutGroup()
 {
 }
 
+LayoutGroup LayoutGroup::DownCast( BaseHandle handle )
+{
+  return LayoutGroup( dynamic_cast< Dali::Toolkit::Internal::LayoutGroup* >( handle.GetObjectPtr() ) );
+}
+
 LayoutGroup::LayoutId LayoutGroup::Add( LayoutItem& child )
 {
   return GetImplementation( *this ).Add( GetImplementation(child) );
index c6b777b..1d9ad5d 100644 (file)
@@ -49,7 +49,7 @@ class LayoutGroup;
  * To write a new layout, inherit from both LayoutGroup handle and Internal::LayoutGroup body.
  *
  */
-class DALI_IMPORT_API LayoutGroup : public LayoutItem
+class DALI_TOOLKIT_API LayoutGroup : public LayoutItem
 {
 public:
   using LayoutId = unsigned int;
@@ -59,7 +59,6 @@ public:
   {
     enum
     {
-      MARGIN_SPECIFICATION = LAYOUT_GROUP_CHILD_PROPERTY_START_INDEX,
     };
   };
 
index 217ffa6..409ff46 100644 (file)
@@ -26,7 +26,7 @@ namespace
 {
 
 #if defined(DEBUG_ENABLED)
-Debug::Filter* gLayoutFilter = Debug::Filter::New( Debug::Verbose, false, "LOG_LAYOUT" );
+Debug::Filter* gLayoutFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" );
 #endif
 
 const char* WIDTH_SPECIFICATION_NAME( "widthSpecification" );
@@ -140,11 +140,18 @@ void LayoutItem::Measure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasur
 
   const bool needsLayout = specChanged && ( !isSpecExactly || !matchesSpecSize );
 
+  DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::Measure("<<widthMeasureSpec<<", "<<heightMeasureSpec<<") Owner:"<<Actor::DownCast(GetOwner()).GetName() <<"  forceLayout="<<forceLayout<<", specChanged="<<specChanged<<", isSpecExactly="<<isSpecExactly<<", matchesSpecSize="<<matchesSpecSize<<", needsLayout="<<needsLayout <<std::endl <<(forceLayout||needsLayout?"  Remeasuring":"  NoChange"));
+
   if( forceLayout || needsLayout )
   {
     mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_MEASURED_DIMENSION_SET );
 
     // measure ourselves, this should set the measured dimension flag back
+#if defined(DEBUG_ENABLED)
+    std::ostringstream o;
+    o<<widthMeasureSpec<<","<<heightMeasureSpec;
+    DALI_LOG_INFO( gLayoutFilter, Debug::Concise, "Calling %s OnMeasure( %s )\n", Actor::DownCast(GetOwner()).GetName().c_str(), o.str().c_str());
+#endif
     OnMeasure( widthMeasureSpec, heightMeasureSpec );
     mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_MEASURE_NEEDED_BEFORE_LAYOUT );
 
@@ -277,6 +284,11 @@ void LayoutItem::OnLayout( bool changed, LayoutLength left, LayoutLength top, La
 {
 }
 
+void LayoutItem::SetParent( LayoutParent* parent )
+{
+  mImpl->mLayoutParent = parent;
+}
+
 LayoutParent* LayoutItem::GetParent()
 {
   return mImpl->mLayoutParent;
index c44d251..8e4cdf3 100644 (file)
@@ -44,8 +44,8 @@ using LayoutItemPtr = IntrusivePtr<LayoutItem>;
 /**
  * Base class for layouts.
  */
-class DALI_IMPORT_API LayoutItem : public BaseObject,
-                                   public LayoutParent
+class DALI_TOOLKIT_API LayoutItem : public BaseObject,
+                                    public LayoutParent
 {
 public:
   /**
@@ -158,6 +158,11 @@ public:
   static LayoutLength GetDefaultSize( LayoutLength size, MeasureSpec measureSpec );
 
   /**
+   * @copydoc LayoutParent::SetParent
+   */
+  virtual void SetParent( LayoutParent* parent ) override;
+
+  /**
    * @copydoc LayoutParent::GetParent
    */
   virtual LayoutParent* GetParent() override;
index 6722f22..5b042c6 100644 (file)
@@ -24,6 +24,7 @@
 #include <dali/public-api/object/property-index-ranges.h>
 #include <dali-toolkit/devel-api/layouting/child-layout-data.h>
 #include <dali-toolkit/devel-api/layouting/measure-spec.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
 
 namespace Dali
 {
@@ -42,7 +43,7 @@ using LayoutId = unsigned int;
  * Base class for layouts. It is used to layout a control (or visual).
  * It can be laid out by a LayoutGroup.
  */
-class DALI_IMPORT_API LayoutItem : public BaseHandle
+class DALI_TOOLKIT_API LayoutItem : public BaseHandle
 {
 public:
 
index 392a2ab..d55fb42 100644 (file)
@@ -17,6 +17,8 @@
  * limitations under the License.
  */
 
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
 namespace Dali
 {
 namespace Toolkit
@@ -30,10 +32,15 @@ namespace Internal
  * Needed to prevent circular inheritance - most LayoutBases have a parent,
  * but parenting is provided by LayoutGroup, which is a sub-class of LayoutBase.
  */
-class DALI_IMPORT_API LayoutParent
+class DALI_TOOLKIT_API LayoutParent
 {
 public:
   /**
+   * Set the parent of this layout.
+   */
+  virtual void SetParent( LayoutParent* parent ) = 0;
+
+  /**
    * Get the parent of this layout.
    */
   virtual LayoutParent* GetParent() = 0;
diff --git a/dali-toolkit/devel-api/layouting/linear-layout.cpp b/dali-toolkit/devel-api/layouting/linear-layout.cpp
new file mode 100644 (file)
index 0000000..e9e7e5b
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+//CLASS HEADER
+#include "linear-layout.h"
+
+//INTERNAL INCLUDES
+#include <dali-toolkit/internal/layouting/linear-layout-impl.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+
+LinearLayout::LinearLayout()
+{
+}
+
+LinearLayout LinearLayout::New()
+{
+  Internal::LinearLayoutPtr internal = Internal::LinearLayout::New();
+  return LinearLayout( internal.Get() );
+}
+
+LinearLayout LinearLayout::DownCast( BaseHandle handle )
+{
+  return LinearLayout( dynamic_cast< Dali::Toolkit::Internal::LinearLayout*>( handle.GetObjectPtr() ) );
+}
+
+LinearLayout::LinearLayout( const LinearLayout& other )
+: LayoutGroup( other )
+{
+}
+
+LinearLayout& LinearLayout::operator=( const LinearLayout& other )
+{
+  if( &other != this )
+  {
+    LayoutGroup::operator=( other );
+  }
+  return *this;
+}
+
+void LinearLayout::SetCellPadding( LayoutSize size )
+{
+  GetImplementation(*this).SetCellPadding( size );
+  GetImplementation(*this).RequestLayout();
+}
+
+LayoutSize LinearLayout::GetCellPadding()
+{
+  return GetImplementation(*this).GetCellPadding();
+  GetImplementation(*this).RequestLayout();
+}
+
+void LinearLayout::SetOrientation( LinearLayout::Orientation orientation )
+{
+  GetImplementation(*this).SetOrientation( orientation );
+  GetImplementation(*this).RequestLayout();
+}
+
+LinearLayout::Orientation LinearLayout::GetOrientation()
+{
+  return GetImplementation(*this).GetOrientation();
+  GetImplementation(*this).RequestLayout();
+}
+
+LinearLayout::LinearLayout( Dali::Toolkit::Internal::LinearLayout* object )
+: LayoutGroup( object )
+{
+}
+
+} // namespace Toolkit
+} // namespace Dali
@@ -1,5 +1,5 @@
-#ifndef DALI_TOOLKIT_LAYOUTING_HBOX_LAYOUT_H
-#define DALI_TOOLKIT_LAYOUTING_HBOX_LAYOUT_H
+#ifndef DALI_TOOLKIT_LAYOUTING_LINEAR_LAYOUT_H
+#define DALI_TOOLKIT_LAYOUTING_LINEAR_LAYOUT_H
 
 /*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
@@ -30,14 +30,14 @@ namespace Toolkit
 
 namespace Internal DALI_INTERNAL
 {
-class HboxLayout;
+class LinearLayout;
 }
 
 /**
- * This class implements a horizontal box layout, automatically handling
+ * This class implements a linear box layout, automatically handling
  * right to left or left to right direction change.
  */
-class DALI_IMPORT_API HboxLayout : public LayoutGroup
+class DALI_TOOLKIT_API LinearLayout : public LayoutGroup
 {
 public:
 
@@ -47,63 +47,55 @@ public:
     CHILD_PROPERTY_END_INDEX   = LINEAR_LAYOUT_CHILD_PROPERTY_END_INDEX
   };
 
-  struct Property
-  {
-    // @todo When we can have event-only properties for BaseObject, this will be useful.
-    enum
-    {
-      CELL_PADDING = PROPERTY_REGISTRATION_START_INDEX + 2000
-    };
-  };
-
-  struct ChildProperty
+  /**
+   * @brief Enumeration for the direction in which the content is laid out
+   */
+  enum class Orientation
   {
-    enum
-    {
-      WEIGHT = CHILD_PROPERTY_START_INDEX
-    };
+    HORIZONTAL,                 ///< Horizontal (row)
+    VERTICAL                    ///< Vertical (column)
   };
 
   /**
-   * @brief Creates an uninitialized HboxLayout handle.
+   * @brief Creates an uninitialized LinearLayout handle.
    *
-   * Initialize it using HboxLayout::New().
+   * Initialize it using LinearLayout::New().
    * Calling member functions with an uninitialized handle is not allowed.
    */
-  HboxLayout();
+  LinearLayout();
 
   /**
-   * @brief Creates a HboxLayout object.
+   * @brief Creates a LinearLayout object.
    */
-  static HboxLayout New();
+  static LinearLayout New();
 
   /**
-   * @brief Downcasts a handle to a HboxLayout handle.
+   * @brief Downcasts a handle to a LinearLayout handle.
    *
-   * If handle points to a HboxLayout, the downcast produces a valid handle.
+   * If handle points to a LinearLayout, the downcast produces a valid handle.
    * If not, the returned handle is left uninitialized.
 
    * @param[in] handle to an object
-   * @return Handle to a HboxLayout or an uninitialized handle
+   * @return Handle to a LinearLayout or an uninitialized handle
    */
-  static HboxLayout DownCast( BaseHandle handle );
+  static LinearLayout DownCast( BaseHandle handle );
 
   /**
    * @brief Copy constructor
    */
-  HboxLayout( const HboxLayout& other );
+  LinearLayout( const LinearLayout& other );
 
   /**
    * @brief Assigment operator
    */
-  HboxLayout& operator=( const HboxLayout& other );
+  LinearLayout& operator=( const LinearLayout& other );
 
   /**
    * @brief Default destructor.
    *
    * This is non-virtual, since derived Handle types must not contain data or virtual methods
    */
-  ~HboxLayout()=default;
+  ~LinearLayout()=default;
 
   /**
    * @brief Set the padding between cells in the layout
@@ -119,19 +111,33 @@ public:
    */
   LayoutSize GetCellPadding();
 
+  /**
+   * @brief Set the orientation in the layout
+   *
+   * @param[in] orientation The orientation.
+   */
+  void SetOrientation( Orientation orientation );
+
+  /**
+   * @brief Get the orientation in the layout
+   *
+   * @return The orientation.
+   */
+  Orientation GetOrientation();
+
 public: // Not intended for application developers
 
   /// @cond internal
   /**
-   * @brief This constructor is used by HboxLayout::New() methods.
+   * @brief This constructor is used by LinearLayout::New() methods.
    *
    * @param[in] actor A pointer to a newly allocated Dali resource
    */
-  explicit DALI_INTERNAL HboxLayout( Internal::HboxLayout* body );
+  explicit DALI_INTERNAL LinearLayout( Internal::LinearLayout* body );
   /// @endcond
 };
 
 } // namespace Toolkit
 } // namespace Dali
 
-#endif // DALI_TOOLKIT_LAYOUTING_HBOX_LAYOUT_H
+#endif // DALI_TOOLKIT_LAYOUTING_LINEAR_LAYOUT_H
index 92a03f2..04c4d01 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <dali/public-api/common/dali-common.h>
 #include <dali-toolkit/devel-api/layouting/layout-length.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
 
 #include <sstream>
 
@@ -32,7 +33,7 @@ namespace Toolkit
  * how to be measured. For instance, it may measure a child with an exact width and an unspecified
  * height in order to determine height for width.
  */
-class DALI_IMPORT_API MeasureSpec
+class DALI_TOOLKIT_API MeasureSpec
 {
 public:
   using IntType = LayoutLength::IntType;
index 3e38a1e..4acdd70 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <dali/public-api/common/dali-common.h>
 #include <dali-toolkit/devel-api/layouting/layout-length.h>
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
 
 namespace Dali
 {
@@ -28,7 +29,7 @@ namespace Toolkit
 /**
  * Class that encodes a measurement and a measure state, which is set if the measured size is too small.
  */
-class DALI_IMPORT_API MeasuredSize
+class DALI_TOOLKIT_API MeasuredSize
 {
 public:
 
index f04a4bd..220872e 100644 (file)
@@ -36,7 +36,7 @@ class VboxLayout;
  * This class implements a vertical box layout, automatically handling
  * right to left or left to right direction change.
  */
-class DALI_IMPORT_API VboxLayout : public LayoutGroup
+class DALI_TOOLKIT_API VboxLayout : public LayoutGroup
 {
 public:
 
index c5db50c..1861a93 100644 (file)
@@ -32,14 +32,16 @@ namespace Toolkit
  */
 enum DevelPropertyRanges
 {
-  LAYOUT_GROUP_CHILD_PROPERTY_START_INDEX = CHILD_PROPERTY_REGISTRATION_START_INDEX + 1000,   ///< Layout Group Property Start Index.
-  LAYOUT_GROUP_CHILD_PROPERTY_END_INDEX   = LAYOUT_GROUP_CHILD_PROPERTY_START_INDEX + 999,    ///< Layout Group Property End Index.
-  LINEAR_LAYOUT_CHILD_PROPERTY_START_INDEX = LAYOUT_GROUP_CHILD_PROPERTY_END_INDEX + 1,       ///< Linear Layout Property Start Index.
-  LINEAR_LAYOUT_CHILD_PROPERTY_END_INDEX   = LINEAR_LAYOUT_CHILD_PROPERTY_START_INDEX + 999,  ///< Linear Layout Property End Index.
-  GRID_LAYOUT_CHILD_PROPERTY_START_INDEX = LINEAR_LAYOUT_CHILD_PROPERTY_END_INDEX + 1,        ///< Grid Layout Property Start Index.
-  GRID_LAYOUT_CHILD_PROPERTY_END_INDEX   = GRID_LAYOUT_CHILD_PROPERTY_START_INDEX + 999,      ///< Grid Layout Property End Index.
-  FLEX_LAYOUT_CHILD_PROPERTY_START_INDEX = GRID_LAYOUT_CHILD_PROPERTY_END_INDEX + 1,          ///< Flex Layout Property Start Index.
-  FLEX_LAYOUT_CHILD_PROPERTY_END_INDEX   = FLEX_LAYOUT_CHILD_PROPERTY_START_INDEX + 999,      ///< Flex Layout Property End Index.
+  LAYOUT_GROUP_CHILD_PROPERTY_START_INDEX = CHILD_PROPERTY_REGISTRATION_START_INDEX + 1000,     ///< Layout Group Property Start Index.
+  LAYOUT_GROUP_CHILD_PROPERTY_END_INDEX   = LAYOUT_GROUP_CHILD_PROPERTY_START_INDEX + 999,      ///< Layout Group Property End Index.
+  LINEAR_LAYOUT_CHILD_PROPERTY_START_INDEX = LAYOUT_GROUP_CHILD_PROPERTY_END_INDEX + 1,         ///< Linear Layout Property Start Index.
+  LINEAR_LAYOUT_CHILD_PROPERTY_END_INDEX   = LINEAR_LAYOUT_CHILD_PROPERTY_START_INDEX + 999,    ///< Linear Layout Property End Index.
+  GRID_LAYOUT_CHILD_PROPERTY_START_INDEX = LINEAR_LAYOUT_CHILD_PROPERTY_END_INDEX + 1,          ///< Grid Layout Property Start Index.
+  GRID_LAYOUT_CHILD_PROPERTY_END_INDEX   = GRID_LAYOUT_CHILD_PROPERTY_START_INDEX + 999,        ///< Grid Layout Property End Index.
+  FLEX_LAYOUT_CHILD_PROPERTY_START_INDEX = GRID_LAYOUT_CHILD_PROPERTY_END_INDEX + 1,            ///< Flex Layout Property Start Index.
+  FLEX_LAYOUT_CHILD_PROPERTY_END_INDEX   = FLEX_LAYOUT_CHILD_PROPERTY_START_INDEX + 999,        ///< Flex Layout Property End Index.
+  ABSOLUTE_LAYOUT_CHILD_PROPERTY_START_INDEX = FLEX_LAYOUT_CHILD_PROPERTY_END_INDEX +1,         ///< Absolute Layout Property Start Index.
+  ABSOLUTE_LAYOUT_CHILD_PROPERTY_END_INDEX = ABSOLUTE_LAYOUT_CHILD_PROPERTY_START_INDEX + 999,  ///< Absolute Layout Property End Index.
 };
 
 } // namespace Toolkit
index 80e884a..3360256 100755 (executable)
@@ -1387,7 +1387,7 @@ void TextEditor::OnRelayout( const Vector2& size, RelayoutContainer& container )
       {
         // @note: The callback manager takes the ownership of the callback object.
         mIdleCallback = MakeCallback( this, &TextEditor::OnIdleSignal );
-        adaptor.AddIdle( mIdleCallback );
+        adaptor.AddIdle( mIdleCallback, false );
       }
     }
   }
index d92be64..dd34031 100755 (executable)
@@ -1433,7 +1433,7 @@ void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
       {
         // @note: The callback manager takes the ownership of the callback object.
         mIdleCallback = MakeCallback( this, &TextField::OnIdleSignal );
-        adaptor.AddIdle( mIdleCallback );
+        adaptor.AddIdle( mIdleCallback, false );
       }
     }
   }
index 5421132..328d1d6 100755 (executable)
@@ -12,8 +12,8 @@ toolkit_src_files = \
    $(toolkit_src_dir)/builder/tree-node-manipulator.cpp \
    $(toolkit_src_dir)/builder/replacement.cpp \
    $(toolkit_src_dir)/layouting/flex-layout-impl.cpp \
-   $(toolkit_src_dir)/layouting/hbox-layout-impl.cpp \
-   $(toolkit_src_dir)/layouting/vbox-layout-impl.cpp \
+   $(toolkit_src_dir)/layouting/absolute-layout-impl.cpp \
+   $(toolkit_src_dir)/layouting/linear-layout-impl.cpp \
    $(toolkit_src_dir)/layouting/layout-item-data-impl.cpp \
    $(toolkit_src_dir)/layouting/layout-group-data-impl.cpp \
    $(toolkit_src_dir)/layouting/layout-controller-debug.cpp \
diff --git a/dali-toolkit/internal/layouting/absolute-layout-impl.cpp b/dali-toolkit/internal/layouting/absolute-layout-impl.cpp
new file mode 100644 (file)
index 0000000..3f499ef
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ * 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.
+ */
+
+//CLASS HEADER
+#include <dali-toolkit/internal/layouting/absolute-layout-impl.h>
+
+//INTERNAL HEADERS
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/common/extents.h>
+#include <dali/public-api/actors/actor.h>
+#include <dali-toolkit/devel-api/layouting/layout-item.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::NoLogging, false, "LOG_LAYOUT" );
+#endif
+}
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal
+{
+
+AbsoluteLayoutPtr AbsoluteLayout::New()
+{
+  AbsoluteLayoutPtr layout( new AbsoluteLayout() );
+  return layout;
+}
+
+AbsoluteLayout::AbsoluteLayout()
+: LayoutGroup()
+{
+}
+
+AbsoluteLayout::~AbsoluteLayout()
+{
+}
+
+void AbsoluteLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec )
+{
+#if defined(DEBUG_ENABLED)
+  auto actor = Actor::DownCast(GetOwner());
+
+  std::ostringstream oss;
+  oss << "AbsoluteLayout::OnMeasure  ";
+  if( actor )
+  {
+    oss << "Actor Id:" << actor.GetId() << " Name:" << actor.GetName() << "  ";
+  }
+  oss << "widthMeasureSpec:" << widthMeasureSpec << " heightMeasureSpec:" << heightMeasureSpec << std::endl;
+  DALI_LOG_INFO( gLogFilter, Debug::Concise, oss.str().c_str() );
+#endif
+
+  LayoutLength totalHeight( 0 );
+  LayoutLength totalWidth( 0 );
+
+  struct
+  {
+    MeasuredSize::State widthState;
+    MeasuredSize::State heightState;
+  } childState = { MeasuredSize::State::MEASURED_SIZE_OK, MeasuredSize::State::MEASURED_SIZE_OK };
+
+  auto minPosition = Vector3( Vector3::ZERO );
+  auto maxPosition = Vector3( Vector3::ZERO );
+
+  // measure children
+  for( unsigned int i=0; i<GetChildCount(); ++i )
+  {
+    auto childLayout = GetChildAt( i );
+    if( childLayout )
+    {
+      auto childOwner = childLayout->GetOwner();
+
+      // Get size of child
+      MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec );
+      auto childWidth = childLayout->GetMeasuredWidth();
+      auto childHeight = childLayout->GetMeasuredHeight();
+
+      // Determine the width and height needed by the children using their given position and size.
+      // Children could overlap so find the left most and right most child.
+      auto childPosition = childOwner.GetProperty< Vector3 >( Actor::Property::POSITION );
+      minPosition.x = std::min( minPosition.x, childPosition.x );
+      maxPosition.x = std::max( maxPosition.x, childPosition.x + childWidth );
+      // Children could overlap so find the highest and lowest child.
+      minPosition.y = std::min( minPosition.y, childPosition.y );
+      maxPosition.y = std::max( maxPosition.y, childPosition.y + childHeight );
+
+      // Store current width and height needed to contain all children.
+      totalWidth = maxPosition.x - minPosition.x;
+      totalHeight = maxPosition.y - minPosition.y;
+      DALI_LOG_INFO( gLogFilter, Debug::Concise, "AbsoluteLayout::OnMeasure child width(%f) height(%f) \n", (float)totalWidth, (float)totalHeight  );
+
+      if( childLayout->GetMeasuredWidthAndState().GetState() == MeasuredSize::State::MEASURED_SIZE_TOO_SMALL )
+      {
+        childState.widthState = MeasuredSize::State::MEASURED_SIZE_TOO_SMALL;
+      }
+      if( childLayout->GetMeasuredHeightAndState().GetState() == MeasuredSize::State::MEASURED_SIZE_TOO_SMALL )
+      {
+        childState.heightState = MeasuredSize::State::MEASURED_SIZE_TOO_SMALL;
+      }
+    }
+  }
+
+  MeasuredSize widthSizeAndState = ResolveSizeAndState( totalWidth, widthMeasureSpec, MeasuredSize::State::MEASURED_SIZE_OK);
+  MeasuredSize heightSizeAndState = ResolveSizeAndState( totalHeight, heightMeasureSpec, MeasuredSize::State::MEASURED_SIZE_OK);
+  totalWidth = widthSizeAndState.GetSize();
+  totalHeight = heightSizeAndState.GetSize();
+
+  // Ensure layout respects it's given minimum size
+  totalWidth = std::max( totalWidth, GetSuggestedMinimumWidth() );
+  totalHeight = std::max( totalHeight, GetSuggestedMinimumHeight() );
+
+  widthSizeAndState.SetState( childState.widthState );
+  heightSizeAndState.SetState( childState.heightState );
+
+  SetMeasuredDimensions( ResolveSizeAndState( totalWidth, widthMeasureSpec, childState.widthState ),
+                         ResolveSizeAndState( totalHeight, heightMeasureSpec, childState.heightState ) );
+
+}
+
+void AbsoluteLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom )
+{
+  // Absolute layout positions it's children at their Actor positions.
+  // Children could overlap or spill outside the parent, as is the nature of absolute positions.
+  auto count = GetChildCount();
+
+  for( unsigned int i = 0; i < count; i++)
+  {
+    LayoutItemPtr childLayout = GetChildAt( i );
+    if( childLayout != nullptr )
+    {
+      auto childOwner = childLayout->GetOwner();
+      auto childWidth = childLayout->GetMeasuredWidth();
+      auto childHeight = childLayout->GetMeasuredHeight();
+
+      auto childPosition = childOwner.GetProperty< Vector3 >( Actor::Property::POSITION );
+
+      auto childTop = childPosition.y;
+      auto childLeft = childPosition.x;
+
+      childLayout->Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight );
+    }
+  }
+}
+
+} // namespace Internal
+} // namespace Toolkit
+} // namespace Dali
@@ -1,5 +1,5 @@
-#ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_HBOX_LAYOUT_H
-#define DALI_TOOLKIT_INTERNAL_LAYOUTING_HBOX_LAYOUT_H
+#ifndef DALI_TOOLKIT_INTERNAL_ABSOLUTE_LAYOUT_H
+#define DALI_TOOLKIT_INTERNAL_ABSOLUTE_LAYOUT_H
 
 /*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
@@ -20,7 +20,7 @@
 #include <dali/public-api/common/intrusive-ptr.h>
 #include <dali/public-api/object/base-object.h>
 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
-#include <dali-toolkit/devel-api/layouting/hbox-layout.h>
+#include <dali-toolkit/devel-api/layouting/absolute-layout.h>
 
 namespace Dali
 {
@@ -29,36 +29,25 @@ namespace Toolkit
 namespace Internal
 {
 
-class HboxLayout;
-using HboxLayoutPtr = IntrusivePtr<HboxLayout>;
+class AbsoluteLayout;
+using AbsoluteLayoutPtr = IntrusivePtr<AbsoluteLayout>;
 
-class HboxLayout final : public LayoutGroup
+class AbsoluteLayout final : public LayoutGroup
 {
 public:
-  static HboxLayoutPtr New();
-
-public:
-  void SetCellPadding( LayoutSize size );
-  LayoutSize GetCellPadding();
+  static AbsoluteLayoutPtr New();
 
 protected:
-  HboxLayout();
-  virtual ~HboxLayout();
-
-  /**
-   * @copydoc LayoutItem::DoInitialize
-   */
-  virtual void DoInitialize() override;
 
   /**
-   * @copydoc LayoutItem::DoRegisterChildProperties()
+   * Constructor
    */
-  virtual void DoRegisterChildProperties( const std::string& containerType ) override;
+  AbsoluteLayout();
 
   /**
-   * @copydoc LayoutItem::OnChildAdd
+   * Destructor
    */
-  virtual void OnChildAdd( LayoutItem& child ) override;
+  virtual ~AbsoluteLayout();
 
   /**
    * @copydoc LayoutItem::OnMeasure
@@ -71,33 +60,30 @@ protected:
   virtual void OnLayout( bool changed, LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b ) override;
 
 private:
-  HboxLayout( const HboxLayout& other ) = delete;
-  HboxLayout& operator=( const HboxLayout& other ) = delete;
+  AbsoluteLayout( const AbsoluteLayout& other ) = delete;
+  AbsoluteLayout& operator=( const AbsoluteLayout& other ) = delete;
 
   void ForceUniformHeight( int count, MeasureSpec widthMeasureSpec );
 
-private:
-  LayoutSize mCellPadding;
-  LayoutLength mTotalLength;
 };
 
 } // namespace Internal
 
-inline Internal::HboxLayout& GetImplementation( Dali::Toolkit::HboxLayout& handle )
+inline Internal::AbsoluteLayout& GetImplementation( Dali::Toolkit::AbsoluteLayout& handle )
 {
-  DALI_ASSERT_ALWAYS( handle && "HboxLayout handle is empty" );
+  DALI_ASSERT_ALWAYS( handle && "AbsoluteLayout handle is empty" );
   BaseObject& object = handle.GetBaseObject();
-  return static_cast<Internal::HboxLayout&>( object );
+  return static_cast<Internal::AbsoluteLayout&>( object );
 }
 
-inline const Internal::HboxLayout& GetImplementation( const Dali::Toolkit::HboxLayout& handle )
+inline const Internal::AbsoluteLayout& GetImplementation( const Dali::Toolkit::AbsoluteLayout& handle )
 {
-  DALI_ASSERT_ALWAYS( handle && "HboxLayout handle is empty" );
+  DALI_ASSERT_ALWAYS( handle && "AbsoluteLayout handle is empty" );
   const BaseObject& object = handle.GetBaseObject();
-  return static_cast<const Internal::HboxLayout&>( object );
+  return static_cast<const Internal::AbsoluteLayout&>( object );
 }
 
 } // namespace Toolkit
 } // namespace Dali
 
-#endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_HBOX_LAYOUT_H
+#endif // DALI_TOOLKIT_INTERNAL_ABSOLUTE_LAYOUT_H
index 7bba696..8766c58 100644 (file)
@@ -30,7 +30,7 @@
 #include <dali-toolkit/third-party/yoga/YGNode.h>
 
 #if defined(DEBUG_ENABLED)
-static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_LAYOUT" );
+static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" );
 #endif
 
 namespace Dali
@@ -191,7 +191,7 @@ void FlexLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeas
   oss << "FlexLayout::OnMeasure  ";
   if( actor )
   {
-       oss << "Actor Id:" << actor.GetId() << " Name:" << actor.GetName() << " Layout direction:" << actor.GetProperty( Actor::Property::LAYOUT_DIRECTION ).Get<int>() << " ";
+    oss << "Actor Id:" << actor.GetId() << " Name:" << actor.GetName() << " Layout direction:" << actor.GetProperty( Actor::Property::LAYOUT_DIRECTION ).Get<int>() << " ";
   }
   oss << "widthMeasureSpec:" << widthMeasureSpec << " heightMeasureSpec:" << heightMeasureSpec << std::endl;
   DALI_LOG_INFO( gLogFilter, Debug::Concise, oss.str().c_str() );
diff --git a/dali-toolkit/internal/layouting/hbox-layout-impl.cpp b/dali-toolkit/internal/layouting/hbox-layout-impl.cpp
deleted file mode 100644 (file)
index 0caf08d..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * 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.
- */
-
-//CLASS HEADER
-#include <dali-toolkit/internal/layouting/hbox-layout-impl.h>
-
-//EXTERNAL HEADERS
-//INTERNAL HEADERS
-#include <dali/integration-api/debug.h>
-#include <dali/public-api/common/extents.h>
-#include <dali/public-api/actors/actor.h>
-#include <dali-toolkit/devel-api/layouting/layout-item.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
-{
-namespace Toolkit
-{
-namespace Internal
-{
-
-HboxLayoutPtr HboxLayout::New()
-{
-  HboxLayoutPtr layout( new HboxLayout() );
-  return layout;
-}
-
-HboxLayout::HboxLayout()
-: LayoutGroup(),
-  mCellPadding( 0, 0 ),
-  mTotalLength( 0 )
-{
-}
-
-HboxLayout::~HboxLayout()
-{
-}
-
-void HboxLayout::DoInitialize()
-{
-}
-
-void HboxLayout::DoRegisterChildProperties( const std::string& containerType )
-{
-  auto typeInfo = Dali::TypeRegistry::Get().GetTypeInfo( containerType );
-  if( typeInfo )
-  {
-    Property::IndexContainer indices;
-    typeInfo.GetChildPropertyIndices( indices );
-
-    if( std::find( indices.Begin(), indices.End(), Toolkit::HboxLayout::ChildProperty::WEIGHT ) == indices.End() )
-    {
-      ChildPropertyRegistration( typeInfo.GetName(), "weight",
-                                 Toolkit::HboxLayout::ChildProperty::WEIGHT, Property::FLOAT );
-    }
-  }
-}
-
-void HboxLayout::OnChildAdd( LayoutItem& child )
-{
-  auto owner = child.GetOwner();
-  owner.SetProperty( Toolkit::HboxLayout::ChildProperty::WEIGHT, 1.0f );
-}
-
-void HboxLayout::SetCellPadding( LayoutSize size )
-{
-  mCellPadding = size;
-}
-
-LayoutSize HboxLayout::GetCellPadding()
-{
-  return mCellPadding;
-}
-
-void HboxLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec )
-{
-#if defined(DEBUG_ENABLED)
-  auto actor = Actor::DownCast(GetOwner());
-
-  std::ostringstream oss;
-  oss << "HBoxLayout::OnMeasure  ";
-  if( actor )
-  {
-    oss << "Actor Id:" << actor.GetId() << " Name:" << actor.GetName() << "  ";
-  }
-  oss << "widthMeasureSpec:" << widthMeasureSpec << " heightMeasureSpec:" << heightMeasureSpec << std::endl;
-  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);
-  bool matchHeight = false;
-  bool allFillParent = true;
-  LayoutLength maxHeight = 0;
-  LayoutLength alternativeMaxHeight = 0;
-  struct
-  {
-    MeasuredSize::State widthState;
-    MeasuredSize::State heightState;
-  } childState = { MeasuredSize::State::MEASURED_SIZE_OK, MeasuredSize::State::MEASURED_SIZE_OK };
-
-  // measure children, and determine if further resolution is required
-  for( unsigned int i=0; i<GetChildCount(); ++i )
-  {
-    auto childLayout = GetChildAt( i );
-    if( childLayout )
-    {
-      auto childOwner = childLayout->GetOwner();
-      auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
-
-      MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec );
-      auto childWidth = childLayout->GetMeasuredWidth();
-      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;
-
-      if( isExactly )
-      {
-        mTotalLength += length;
-      }
-      else
-      {
-        auto totalLength = mTotalLength;
-        mTotalLength = std::max( totalLength, totalLength + length + cellPadding );
-      }
-
-      bool matchHeightLocally = false;
-      if( heightMode != MeasureSpec::Mode::EXACTLY && desiredHeight == Toolkit::ChildLayoutData::MATCH_PARENT )
-      {
-        // Will have to re-measure at least this child when we know exact height.
-        matchHeight = true;
-        matchHeightLocally = true;
-      }
-
-      auto marginHeight = LayoutLength( childMargin.top + childMargin.bottom );
-      auto childHeight = childLayout->GetMeasuredHeight() + marginHeight;
-
-      if( childLayout->GetMeasuredWidthAndState().GetState() == MeasuredSize::State::MEASURED_SIZE_TOO_SMALL )
-      {
-        childState.widthState = MeasuredSize::State::MEASURED_SIZE_TOO_SMALL;
-      }
-      if( childLayout->GetMeasuredHeightAndState().GetState() == MeasuredSize::State::MEASURED_SIZE_TOO_SMALL )
-      {
-        childState.heightState = MeasuredSize::State::MEASURED_SIZE_TOO_SMALL;
-      }
-
-      maxHeight = std::max( maxHeight, childHeight );
-      allFillParent = ( allFillParent && desiredHeight == Toolkit::ChildLayoutData::MATCH_PARENT );
-      alternativeMaxHeight = std::max( alternativeMaxHeight, matchHeightLocally ? marginHeight : childHeight );
-    }
-  }
-
-  Extents padding = GetPadding();
-  mTotalLength += padding.start + padding.end;
-  auto widthSize = mTotalLength;
-  widthSize = std::max( widthSize, GetSuggestedMinimumWidth() );
-  MeasuredSize widthSizeAndState = ResolveSizeAndState( widthSize, widthMeasureSpec, MeasuredSize::State::MEASURED_SIZE_OK);
-  widthSize = widthSizeAndState.GetSize();
-
-  if( !allFillParent && heightMode != MeasureSpec::Mode::EXACTLY )
-  {
-    maxHeight = alternativeMaxHeight;
-  }
-  maxHeight += padding.top + padding.bottom;
-  maxHeight = std::max( maxHeight, GetSuggestedMinimumHeight() );
-
-  widthSizeAndState.SetState( childState.widthState );
-
-  SetMeasuredDimensions( widthSizeAndState,
-                         ResolveSizeAndState( maxHeight, heightMeasureSpec, childState.heightState ) );
-
-  if( matchHeight )
-  {
-    ForceUniformHeight( GetChildCount(), widthMeasureSpec );
-  }
-}
-
-void HboxLayout::ForceUniformHeight( int count, MeasureSpec widthMeasureSpec )
-{
-  // Pretend that the linear layout has an exact size. This is the measured height of
-  // ourselves. The measured height should be the max height of the children, changed
-  // to accommodate the heightMeasureSpec from the parent
-  auto uniformMeasureSpec = MeasureSpec( GetMeasuredHeight(), MeasureSpec::Mode::EXACTLY );
-  for (int i = 0; i < count; ++i)
-  {
-    LayoutItemPtr childLayout = GetChildAt(i);
-    if( childLayout != nullptr )
-    {
-      auto childOwner = childLayout->GetOwner();
-      auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
-      auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
-
-      if( desiredHeight == Toolkit::ChildLayoutData::MATCH_PARENT )
-      {
-        // Temporarily force children to reuse their old measured width
-        int oldWidth = desiredWidth;
-        childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, childLayout->GetMeasuredWidth().mValue );
-
-        // Remeasure with new dimensions
-        MeasureChildWithMargins( childLayout, widthMeasureSpec, 0, uniformMeasureSpec, 0);
-
-        childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, oldWidth );
-      }
-    }
-  }
-}
-
-void HboxLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom )
-{
-  auto owner = GetOwner();
-  auto actor = Actor::DownCast(owner);
-  bool isLayoutRtl = actor ? actor.GetProperty<bool>( Actor::Property::LAYOUT_DIRECTION ) : false;
-
-  Extents padding = GetPadding();
-
-  LayoutLength childTop( 0 );
-  LayoutLength childLeft( padding.start );
-
-  // Where bottom of child should go
-  auto height = bottom - top;
-
-  // Space available for child
-  auto childSpace = height - padding.top - padding.bottom;
-
-  auto count = GetChildCount();
-
-  int start = 0;
-  int dir = 1;
-
-  // In case of RTL, start drawing from the last child.
-  // @todo re-work to draw the first child from the right edge, and move leftwards.
-  // (Should have an alignment also)
-  if( isLayoutRtl ) {
-    start = count - 1;
-    dir = -1;
-  }
-
-  for( unsigned int i = 0; i < count; i++)
-  {
-    int childIndex = start + dir * i;
-    LayoutItemPtr childLayout = GetChildAt( childIndex );
-    if( childLayout != nullptr )
-    {
-      auto childWidth = childLayout->GetMeasuredWidth();
-      auto childHeight = childLayout->GetMeasuredHeight();
-
-      auto childMargin = childLayout->GetMargin();
-
-      childTop = LayoutLength(padding.top) + ((childSpace - childHeight) / 2) + childMargin.top - childMargin.bottom;
-
-      childLeft += childMargin.start;
-      childLayout->Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight );
-      childLeft += childWidth + childMargin.end + mCellPadding.width;
-    }
-  }
-}
-
-} // namespace Internal
-} // namespace Toolkit
-} // namespace Dali
index 85057c1..4b8f63e 100644 (file)
@@ -27,7 +27,7 @@ namespace Internal
 {
 
 #if defined( DEBUG_ENABLED )
-Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Verbose, false, "LOG_LAYOUT_TREE" );
+Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT_TREE" );
 
 
 void GetLayoutMeasureStateString( std::ostringstream& oss, LayoutItemPtr layout )
index 0ca1847..1f12c3f 100644 (file)
@@ -29,7 +29,7 @@ namespace
 {
 
 #if defined(DEBUG_ENABLED)
-static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_LAYOUT" );
+static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" );
 #endif
 
 }
diff --git a/dali-toolkit/internal/layouting/linear-layout-impl.cpp b/dali-toolkit/internal/layouting/linear-layout-impl.cpp
new file mode 100644 (file)
index 0000000..003c4e6
--- /dev/null
@@ -0,0 +1,458 @@
+/*
+ * 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.
+ */
+
+//CLASS HEADER
+#include "linear-layout-impl.h"
+
+//PUBLIC INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/common/extents.h>
+#include <dali/public-api/actors/actor.h>
+
+//INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/layouting/layout-item.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::NoLogging, false, "LOG_LAYOUT" );
+#endif
+}
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal
+{
+
+LinearLayoutPtr LinearLayout::New()
+{
+  LinearLayoutPtr layout( new LinearLayout() );
+  return layout;
+}
+
+LinearLayout::LinearLayout()
+: LayoutGroup(),
+  mCellPadding( 0, 0 ),
+  mOrientation( Dali::Toolkit::LinearLayout::Orientation::HORIZONTAL ),
+  mTotalLength( 0 )
+{
+}
+
+LinearLayout::~LinearLayout()
+{
+}
+
+void LinearLayout::SetCellPadding( LayoutSize size )
+{
+  mCellPadding = size;
+}
+
+LayoutSize LinearLayout::GetCellPadding()
+{
+  return mCellPadding;
+}
+
+void LinearLayout::SetOrientation( Dali::Toolkit::LinearLayout::Orientation orientation )
+{
+  mOrientation = orientation;
+}
+
+Dali::Toolkit::LinearLayout::Orientation LinearLayout::GetOrientation()
+{
+  return mOrientation;
+}
+
+void LinearLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec )
+{
+#if defined(DEBUG_ENABLED)
+  auto actor = Actor::DownCast(GetOwner());
+
+  std::ostringstream oss;
+  oss << "LinearLayout::OnMeasure  ";
+  if( actor )
+  {
+    oss << "Actor Id:" << actor.GetId() << " Name:" << actor.GetName() << "  ";
+  }
+  oss << "widthMeasureSpec:" << widthMeasureSpec << " heightMeasureSpec:" << heightMeasureSpec << std::endl;
+  DALI_LOG_INFO( gLogFilter, Debug::Concise, oss.str().c_str() );
+#endif
+
+  if( mOrientation == Dali::Toolkit::LinearLayout::Orientation::HORIZONTAL )
+  {
+    MeasureHorizontal( widthMeasureSpec, heightMeasureSpec );
+  }
+  else
+  {
+    MeasureVertical( widthMeasureSpec, heightMeasureSpec );
+  }
+}
+
+void LinearLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom )
+{
+#if defined(DEBUG_ENABLED)
+  auto actor = Actor::DownCast(GetOwner());
+
+  std::ostringstream oss;
+  oss << "LinearLayout::OnLayout  ";
+  if( actor )
+  {
+    oss << "Actor Id:" << actor.GetId() << " Name:" << actor.GetName() << "  ";
+  }
+  oss << "left:" << left << " top:" << top << " right:" << right << " bottom:" << bottom << std::endl;
+  DALI_LOG_INFO( gLogFilter, Debug::Concise, oss.str().c_str() );
+#endif
+
+  if( mOrientation == Dali::Toolkit::LinearLayout::Orientation::HORIZONTAL )
+  {
+    LayoutHorizontal( left, top, right, bottom );
+  }
+  else
+  {
+    LayoutVertical( left, top, right, bottom );
+  }
+}
+
+void LinearLayout::MeasureHorizontal( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec )
+{
+  auto widthMode = widthMeasureSpec.GetMode();
+  auto heightMode = heightMeasureSpec.GetMode();
+  bool isExactly = (widthMode == MeasureSpec::Mode::EXACTLY);
+  bool matchHeight = false;
+  bool allFillParent = true;
+  LayoutLength maxHeight = 0;
+  LayoutLength alternativeMaxHeight = 0;
+  struct
+  {
+    MeasuredSize::State widthState;
+    MeasuredSize::State heightState;
+  } childState = { MeasuredSize::State::MEASURED_SIZE_OK, MeasuredSize::State::MEASURED_SIZE_OK };
+
+  // Reset total length
+  mTotalLength = 0;
+
+  // measure children, and determine if further resolution is required
+  for( unsigned int i=0; i<GetChildCount(); ++i )
+  {
+    auto childLayout = GetChildAt( i );
+    if( childLayout )
+    {
+      auto childOwner = childLayout->GetOwner();
+      auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
+
+      MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec );
+      auto childWidth = childLayout->GetMeasuredWidth();
+      auto childMargin = childLayout->GetMargin();
+
+      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LinearLayout::OnMeasure childWidth(%d)\n", MeasureSpec::IntType( childWidth ) );
+
+      auto length = childWidth + LayoutLength::IntType(childMargin.start + childMargin.end);
+
+      auto cellPadding = i<GetChildCount()-1 ? mCellPadding.width: 0;
+
+      if( isExactly )
+      {
+        mTotalLength += length;
+      }
+      else
+      {
+        auto totalLength = mTotalLength;
+        mTotalLength = std::max( totalLength, totalLength + length + cellPadding );
+      }
+
+      bool matchHeightLocally = false;
+      if( heightMode != MeasureSpec::Mode::EXACTLY && desiredHeight == Toolkit::ChildLayoutData::MATCH_PARENT )
+      {
+        // Will have to re-measure at least this child when we know exact height.
+        matchHeight = true;
+        matchHeightLocally = true;
+      }
+
+      auto marginHeight = LayoutLength( childMargin.top + childMargin.bottom );
+      auto childHeight = childLayout->GetMeasuredHeight() + marginHeight;
+
+      if( childLayout->GetMeasuredWidthAndState().GetState() == MeasuredSize::State::MEASURED_SIZE_TOO_SMALL )
+      {
+        childState.widthState = MeasuredSize::State::MEASURED_SIZE_TOO_SMALL;
+      }
+      if( childLayout->GetMeasuredHeightAndState().GetState() == MeasuredSize::State::MEASURED_SIZE_TOO_SMALL )
+      {
+        childState.heightState = MeasuredSize::State::MEASURED_SIZE_TOO_SMALL;
+      }
+
+      maxHeight = std::max( maxHeight, childHeight );
+      allFillParent = ( allFillParent && desiredHeight == Toolkit::ChildLayoutData::MATCH_PARENT );
+      alternativeMaxHeight = std::max( alternativeMaxHeight, matchHeightLocally ? marginHeight : childHeight );
+    }
+  }
+
+  Extents padding = GetPadding();
+  mTotalLength += padding.start + padding.end;
+  auto widthSize = mTotalLength;
+  widthSize = std::max( widthSize, GetSuggestedMinimumWidth() );
+  MeasuredSize widthSizeAndState = ResolveSizeAndState( widthSize, widthMeasureSpec, MeasuredSize::State::MEASURED_SIZE_OK);
+  widthSize = widthSizeAndState.GetSize();
+
+  if( !allFillParent && heightMode != MeasureSpec::Mode::EXACTLY )
+  {
+    maxHeight = alternativeMaxHeight;
+  }
+  maxHeight += padding.top + padding.bottom;
+  maxHeight = std::max( maxHeight, GetSuggestedMinimumHeight() );
+
+  widthSizeAndState.SetState( childState.widthState );
+
+  SetMeasuredDimensions( widthSizeAndState,
+                         ResolveSizeAndState( maxHeight, heightMeasureSpec, childState.heightState ) );
+
+  if( matchHeight )
+  {
+    ForceUniformHeight( GetChildCount(), widthMeasureSpec );
+  }
+}
+
+void LinearLayout::ForceUniformHeight( int count, MeasureSpec widthMeasureSpec )
+{
+  // Pretend that the linear layout has an exact size. This is the measured height of
+  // ourselves. The measured height should be the max height of the children, changed
+  // to accommodate the heightMeasureSpec from the parent
+  auto uniformMeasureSpec = MeasureSpec( GetMeasuredHeight(), MeasureSpec::Mode::EXACTLY );
+  for (int i = 0; i < count; ++i)
+  {
+    LayoutItemPtr childLayout = GetChildAt(i);
+    if( childLayout != nullptr )
+    {
+      auto childOwner = childLayout->GetOwner();
+      auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
+      auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
+
+      if( desiredHeight == Toolkit::ChildLayoutData::MATCH_PARENT )
+      {
+        // Temporarily force children to reuse their old measured width
+        int oldWidth = desiredWidth;
+        childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, childLayout->GetMeasuredWidth().mValue );
+
+        // Remeasure with new dimensions
+        MeasureChildWithMargins( childLayout, widthMeasureSpec, 0, uniformMeasureSpec, 0);
+
+        childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, oldWidth );
+      }
+    }
+  }
+}
+
+void LinearLayout::LayoutHorizontal( LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom )
+{
+  auto owner = GetOwner();
+  auto actor = Actor::DownCast(owner);
+  bool isLayoutRtl = actor ? actor.GetProperty<bool>( Actor::Property::LAYOUT_DIRECTION ) : false;
+
+  Extents padding = GetPadding();
+
+  LayoutLength childTop( 0 );
+  LayoutLength childLeft( padding.start );
+
+  // Where bottom of child should go
+  auto height = bottom - top;
+
+  // Space available for child
+  auto childSpace = height - padding.top - padding.bottom;
+
+  auto count = GetChildCount();
+
+  int start = 0;
+  int dir = 1;
+
+  // In case of RTL, start drawing from the last child.
+  // @todo re-work to draw the first child from the right edge, and move leftwards.
+  // (Should have an alignment also)
+  if( isLayoutRtl ) {
+    start = count - 1;
+    dir = -1;
+  }
+
+  for( unsigned int i = 0; i < count; i++)
+  {
+    int childIndex = start + dir * i;
+    LayoutItemPtr childLayout = GetChildAt( childIndex );
+    if( childLayout != nullptr )
+    {
+      auto childWidth = childLayout->GetMeasuredWidth();
+      auto childHeight = childLayout->GetMeasuredHeight();
+      auto childMargin = childLayout->GetMargin();
+
+      childTop = LayoutLength(padding.top) + ((childSpace - childHeight) / 2) + childMargin.top - childMargin.bottom;
+
+      childLeft += childMargin.start;
+      childLayout->Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight );
+      childLeft += childWidth + childMargin.end + mCellPadding.width;
+    }
+  }
+}
+
+void LinearLayout::MeasureVertical( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec )
+{
+  auto widthMode = widthMeasureSpec.GetMode();
+
+  bool matchWidth = false;
+  bool allFillParent = true;
+  LayoutLength maxWidth = 0;
+  LayoutLength alternativeMaxWidth = 0;
+
+  struct
+  {
+    MeasuredSize::State widthState;
+    MeasuredSize::State heightState;
+  } childState = { MeasuredSize::State::MEASURED_SIZE_OK, MeasuredSize::State::MEASURED_SIZE_OK };
+
+  // Reset total length
+  mTotalLength = 0;
+
+  // measure children, and determine if further resolution is required
+  for( unsigned int i=0; i<GetChildCount(); ++i )
+  {
+    auto childLayout = GetChildAt( i );
+    if( childLayout )
+    {
+      auto childOwner = childLayout->GetOwner();
+      auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
+
+      MeasureChildWithMargins( childLayout, widthMeasureSpec, 0, heightMeasureSpec, 0 );
+      auto childHeight = childLayout->GetMeasuredHeight();
+      auto childMargin = childLayout->GetMargin();
+      auto length = childHeight + LayoutLength::IntType(childMargin.top + childMargin.bottom );
+
+      auto cellPadding = i<GetChildCount()-1 ? mCellPadding.height : 0;
+      auto totalLength = mTotalLength;
+      mTotalLength = std::max( totalLength, totalLength + length + cellPadding);
+
+      bool matchWidthLocally = false;
+      if( widthMode != MeasureSpec::Mode::EXACTLY && desiredWidth == Toolkit::ChildLayoutData::MATCH_PARENT )
+      {
+        // Will have to re-measure at least this child when we know exact height.
+        matchWidth = true;
+        matchWidthLocally = true;
+      }
+
+      auto marginWidth = LayoutLength( childMargin.start + childMargin.end );
+      auto childWidth = childLayout->GetMeasuredWidth() + marginWidth;
+
+      // was combineMeasuredStates()
+      if( childLayout->GetMeasuredWidthAndState().GetState() == MeasuredSize::State::MEASURED_SIZE_TOO_SMALL )
+      {
+        childState.widthState = MeasuredSize::State::MEASURED_SIZE_TOO_SMALL;
+      }
+      if( childLayout->GetMeasuredHeightAndState().GetState() == MeasuredSize::State::MEASURED_SIZE_TOO_SMALL )
+      {
+        childState.heightState = MeasuredSize::State::MEASURED_SIZE_TOO_SMALL;
+      }
+
+      maxWidth = std::max( maxWidth, childWidth );
+      allFillParent = ( allFillParent && desiredWidth == Toolkit::ChildLayoutData::MATCH_PARENT );
+      alternativeMaxWidth = std::max( alternativeMaxWidth, matchWidthLocally ? marginWidth : childWidth );
+    }
+  }
+  Extents padding = GetPadding();
+  mTotalLength += padding.top + padding.bottom;
+  auto heightSize = mTotalLength;
+  heightSize = std::max( heightSize, GetSuggestedMinimumHeight() );
+  MeasuredSize heightSizeAndState = ResolveSizeAndState( heightSize, heightMeasureSpec, MeasuredSize::State::MEASURED_SIZE_OK);
+  heightSize = heightSizeAndState.GetSize();
+
+  if( !allFillParent && widthMode != MeasureSpec::Mode::EXACTLY )
+  {
+    maxWidth = alternativeMaxWidth;
+  }
+  maxWidth += padding.start + padding.end;
+  maxWidth = std::max( maxWidth, GetSuggestedMinimumWidth() );
+
+  heightSizeAndState.SetState( childState.heightState );
+
+  SetMeasuredDimensions( ResolveSizeAndState( maxWidth, widthMeasureSpec, childState.widthState ),
+                         heightSizeAndState );
+
+  if( matchWidth )
+  {
+    ForceUniformWidth( GetChildCount(), heightMeasureSpec );
+  }
+}
+
+void LinearLayout::ForceUniformWidth( int count, MeasureSpec heightMeasureSpec )
+{
+  // Pretend that the linear layout has an exact size.
+  auto uniformMeasureSpec = MeasureSpec( GetMeasuredWidth(), MeasureSpec::Mode::EXACTLY );
+  for (int i = 0; i < count; ++i)
+  {
+    LayoutItemPtr childLayout = GetChildAt(i);
+    if( childLayout != nullptr )
+    {
+      auto childOwner = childLayout->GetOwner();
+      auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
+      auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
+
+      if( desiredWidth == Toolkit::ChildLayoutData::MATCH_PARENT )
+      {
+        // Temporarily force children to reuse their old measured height
+        int oldHeight = desiredHeight;
+        childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, childLayout->GetMeasuredHeight().mValue );
+
+        // Remeasure with new dimensions
+        MeasureChildWithMargins( childLayout, uniformMeasureSpec, 0, heightMeasureSpec, 0 );
+
+        childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, oldHeight );
+      }
+    }
+  }
+}
+
+void LinearLayout::LayoutVertical( LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom )
+{
+  Extents padding = GetPadding();
+
+  LayoutLength childTop( 0 );
+  LayoutLength childLeft( padding.start );
+
+  // Where bottom of child should go
+  auto width = right - left;
+
+  // Space available for child
+  auto childSpace = width - padding.start - padding.end;
+  auto count = GetChildCount();
+
+  for( unsigned int childIndex = 0; childIndex < count; childIndex++)
+  {
+    LayoutItemPtr childLayout = GetChildAt( childIndex );
+    if( childLayout != nullptr )
+    {
+      auto childWidth = childLayout->GetMeasuredWidth();
+      auto childHeight = childLayout->GetMeasuredHeight();
+      auto childMargin = childLayout->GetMargin();
+
+      childTop += childMargin.top;
+      childLeft = ( childSpace - childWidth ) / 2 + childMargin.start - childMargin.end;
+
+      childLayout->Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight );
+      childTop += childHeight + childMargin.bottom + mCellPadding.height;
+    }
+  }
+}
+
+} // namespace Internal
+} // namespace Toolkit
+} // namespace Dali
diff --git a/dali-toolkit/internal/layouting/linear-layout-impl.h b/dali-toolkit/internal/layouting/linear-layout-impl.h
new file mode 100644 (file)
index 0000000..d9fb90a
--- /dev/null
@@ -0,0 +1,119 @@
+#ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_LINEAR_LAYOUT_H
+#define DALI_TOOLKIT_INTERNAL_LAYOUTING_LINEAR_LAYOUT_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/public-api/common/intrusive-ptr.h>
+#include <dali/public-api/object/base-object.h>
+#include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
+#include <dali-toolkit/devel-api/layouting/linear-layout.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal
+{
+
+class LinearLayout;
+using LinearLayoutPtr = IntrusivePtr<LinearLayout>;
+
+class LinearLayout final : public LayoutGroup
+{
+public:
+  static LinearLayoutPtr New();
+
+public:
+  void SetCellPadding( LayoutSize size );
+  LayoutSize GetCellPadding();
+  void SetOrientation( Dali::Toolkit::LinearLayout::Orientation orientation );
+  Dali::Toolkit::LinearLayout::Orientation GetOrientation();
+
+protected:
+  LinearLayout();
+  virtual ~LinearLayout();
+
+  /**
+   * @copydoc LayoutItem::OnMeasure
+   */
+  virtual void OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) override;
+
+  /**
+   * @copydoc LayoutItem::OnLayout
+   */
+  virtual void OnLayout( bool changed, LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b ) override;
+
+private:
+  LinearLayout( const LinearLayout& other ) = delete;
+  LinearLayout& operator=( const LinearLayout& other ) = delete;
+
+ /**
+  * Measure children for horizontal orientation
+  */
+  void MeasureHorizontal( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec );
+
+ /**
+  * Apply a uniform height to the children
+  */
+  void ForceUniformHeight( int count, MeasureSpec widthMeasureSpec );
+
+ /**
+  * Layout the children horizontally
+  */
+  void LayoutHorizontal( LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b );
+
+ /**
+  * Measure children for horizontal orientation
+  */
+  void MeasureVertical( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec );
+
+ /**
+  * Apply a uniform width to the children
+  */
+  void ForceUniformWidth( int count, MeasureSpec heightMeasureSpec );
+
+ /**
+  * Layout the children vertically
+  */
+  void LayoutVertical( LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b );
+
+private:
+  LayoutSize mCellPadding;
+  Dali::Toolkit::LinearLayout::Orientation mOrientation;
+  LayoutLength mTotalLength;
+};
+
+} // namespace Internal
+
+inline Internal::LinearLayout& GetImplementation( Dali::Toolkit::LinearLayout& handle )
+{
+  DALI_ASSERT_ALWAYS( handle && "LinearLayout handle is empty" );
+  BaseObject& object = handle.GetBaseObject();
+  return static_cast<Internal::LinearLayout&>( object );
+}
+
+inline const Internal::LinearLayout& GetImplementation( const Dali::Toolkit::LinearLayout& handle )
+{
+  DALI_ASSERT_ALWAYS( handle && "LinearLayout handle is empty" );
+  const BaseObject& object = handle.GetBaseObject();
+  return static_cast<const Internal::LinearLayout&>( object );
+}
+
+} // namespace Toolkit
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_LINEAR_LAYOUT_H
index 3097a21..22fba16 100644 (file)
@@ -29,7 +29,7 @@
 namespace
 {
 #if defined(DEBUG_ENABLED)
-static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_LAYOUT" );
+static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" );
 #endif
 }
 
@@ -133,7 +133,8 @@ void VboxLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeas
 
       MeasureChildWithMargins( childLayout, widthMeasureSpec, 0, heightMeasureSpec, 0 );
       auto childHeight = childLayout->GetMeasuredHeight();
-      auto childMargin = childOwner.GetProperty<Extents>( Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION );
+      auto childMargin = childLayout->GetMargin();
+
       auto length = childHeight + LayoutLength::IntType(childMargin.top + childMargin.bottom );
 
       auto cellPadding = i<GetChildCount()-1 ? mCellPadding.height : 0;
@@ -244,7 +245,7 @@ void VboxLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, La
       auto childHeight = childLayout->GetMeasuredHeight();
 
       auto childOwner = childLayout->GetOwner();
-      auto childMargin = childOwner.GetProperty<Extents>( Toolkit::LayoutGroup::ChildProperty::MARGIN_SPECIFICATION );
+      auto childMargin = childLayout->GetMargin();
 
       childTop += childMargin.top;
       childLeft = ( childSpace - childWidth ) / 2 + childMargin.start - childMargin.end;