Merge HBoxLayout and VBoxLayout into LinearLayout. 55/181555/4
authorAnton Obzhirov <a.obzhirov@samsung.com>
Fri, 8 Jun 2018 16:30:45 +0000 (17:30 +0100)
committerDavid Steele <david.steele@samsung.com>
Tue, 19 Jun 2018 14:15:26 +0000 (15:15 +0100)
Change-Id: I4e1f6b50e37f8050312116f73048a026c1855b4f

automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp
dali-toolkit/devel-api/file.list
dali-toolkit/devel-api/layouting/hbox-layout.cpp [deleted file]
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/internal/file.list
dali-toolkit/internal/layouting/hbox-layout-impl.h [deleted file]
dali-toolkit/internal/layouting/linear-layout-impl.cpp [moved from dali-toolkit/internal/layouting/hbox-layout-impl.cpp with 50% similarity]
dali-toolkit/internal/layouting/linear-layout-impl.h [new file with mode: 0644]

index e5a57b3..1be1e66 100644 (file)
@@ -21,9 +21,8 @@
 
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
 
 #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/absolute-layout.h>
+#include <dali-toolkit/devel-api/layouting/linear-layout.h>
 
 #include <layout-utils.h>
 
 
 #include <layout-utils.h>
 
@@ -47,7 +46,7 @@ int UtcDaliLayouting_HboxLayout01(void)
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
 
   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");
   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
@@ -83,7 +82,7 @@ int UtcDaliLayouting_HboxLayout01(void)
   DALI_TEST_EQUALS( controls[3].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION );
 
   // Change a layout
   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 = HboxLayout::New();
+  auto newHBoxLayout = LinearLayout::New();
   newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
   DevelControl::SetLayout( hbox, newHBoxLayout );
 
   newHBoxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
   DevelControl::SetLayout( hbox, newHBoxLayout );
 
@@ -106,11 +105,11 @@ int UtcDaliLayouting_HboxLayout02(void)
   Stage stage = Stage::GetCurrent();
 
   auto hbox1 = Control::New();
   Stage stage = Stage::GetCurrent();
 
   auto hbox1 = Control::New();
-  auto hboxLayout1 = HboxLayout::New();
+  auto hboxLayout1 = LinearLayout::New();
   DevelControl::SetLayout( hbox1, hboxLayout1 );
 
   auto hbox2 = Control::New();
   DevelControl::SetLayout( hbox1, hboxLayout1 );
 
   auto hbox2 = Control::New();
-  auto hboxLayout2 = HboxLayout::New();
+  auto hboxLayout2 = LinearLayout::New();
   DevelControl::SetLayout( hbox2, hboxLayout2 );
 
   hbox1.SetName( "HBox1");
   DevelControl::SetLayout( hbox2, hboxLayout2 );
 
   hbox1.SetName( "HBox1");
@@ -146,7 +145,7 @@ int UtcDaliLayouting_HboxLayout02(void)
   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
 
   auto hbox3 = Control::New();
   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
 
   auto hbox3 = Control::New();
-  auto hboxLayout3 = HboxLayout::New();
+  auto hboxLayout3 = LinearLayout::New();
   DevelControl::SetLayout( hbox3, hboxLayout3 );
 
   hbox3.SetParentOrigin( ParentOrigin::CENTER );
   DevelControl::SetLayout( hbox3, hboxLayout3 );
 
   hbox3.SetParentOrigin( ParentOrigin::CENTER );
@@ -206,11 +205,11 @@ int UtcDaliLayouting_HboxLayout03(void)
   Stage stage = Stage::GetCurrent();
 
   auto hbox1 = Control::New();
   Stage stage = Stage::GetCurrent();
 
   auto hbox1 = Control::New();
-  auto hboxLayout1 = HboxLayout::New();
+  auto hboxLayout1 = LinearLayout::New();
   DevelControl::SetLayout( hbox1, hboxLayout1 );
 
   auto hbox2 = Control::New();
   DevelControl::SetLayout( hbox1, hboxLayout1 );
 
   auto hbox2 = Control::New();
-  auto hboxLayout2 = HboxLayout::New();
+  auto hboxLayout2 = LinearLayout::New();
   DevelControl::SetLayout( hbox2, hboxLayout2 );
 
   hbox1.SetName( "HBox1");
   DevelControl::SetLayout( hbox2, hboxLayout2 );
 
   hbox1.SetName( "HBox1");
@@ -250,7 +249,7 @@ int UtcDaliLayouting_HboxLayout03(void)
   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
 
   auto hbox3 = Control::New();
   hbox2.SetAnchorPoint( AnchorPoint::CENTER );
 
   auto hbox3 = Control::New();
-  auto hboxLayout3 = HboxLayout::New();
+  auto hboxLayout3 = LinearLayout::New();
   DevelControl::SetLayout( hbox3, hboxLayout3);
 
   hbox3.SetParentOrigin( ParentOrigin::CENTER );
   DevelControl::SetLayout( hbox3, hboxLayout3);
 
   hbox3.SetParentOrigin( ParentOrigin::CENTER );
@@ -311,11 +310,11 @@ int UtcDaliLayouting_HboxLayout04(void)
   Stage stage = Stage::GetCurrent();
 
   auto hbox1 = Control::New();
   Stage stage = Stage::GetCurrent();
 
   auto hbox1 = Control::New();
-  auto hboxLayout1 = HboxLayout::New();
+  auto hboxLayout1 = LinearLayout::New();
   DevelControl::SetLayout( hbox1, hboxLayout1 );
 
   auto hbox2 = Control::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
   DevelControl::SetLayout( hbox2, hboxLayout2 );
 
   hbox1.SetName( "HBox1"); // Default spec is to wrap content
@@ -352,7 +351,7 @@ int UtcDaliLayouting_HboxLayout04(void)
 
   controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT );
   auto hbox3 = Control::New();
 
   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 );
   DevelControl::SetLayout( hbox3, hboxLayout3 );
 
   hbox3.SetParentOrigin( ParentOrigin::CENTER );
@@ -410,7 +409,7 @@ int UtcDaliLayouting_HboxLayout05(void)
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
 
   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");
   hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) );
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
@@ -460,7 +459,7 @@ int UtcDaliLayouting_HboxLayout_Padding01(void)
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
-  auto hboxLayout = HboxLayout::New();
+  auto hboxLayout = LinearLayout::New();
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
 
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
 
@@ -525,7 +524,7 @@ int UtcDaliLayouting_HboxLayout_Padding02(void)
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
-  auto hboxLayout = HboxLayout::New();
+  auto hboxLayout = LinearLayout::New();
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
 
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
 
@@ -604,7 +603,7 @@ int UtcDaliLayouting_HboxLayout_Padding03(void)
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
-  auto hboxLayout = HboxLayout::New();
+  auto hboxLayout = LinearLayout::New();
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
 
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
 
@@ -690,7 +689,7 @@ int UtcDaliLayouting_HboxLayout_Margin01(void)
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
 
   Stage stage = Stage::GetCurrent();
   auto hbox = Control::New();
-  auto hboxLayout = HboxLayout::New();
+  auto hboxLayout = LinearLayout::New();
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
 
   DevelControl::SetLayout( hbox, hboxLayout );
   hbox.SetName( "HBox");
 
@@ -752,7 +751,8 @@ int UtcDaliLayouting_VboxLayout01(void)
 
   Stage stage = Stage::GetCurrent();
   auto vbox = Control::New();
 
   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");
 
   DevelControl::SetLayout( vbox, vboxLayout );
   vbox.SetName( "Vbox");
 
@@ -811,7 +811,8 @@ int UtcDaliLayouting_VboxLayout02(void)
   stage.Add( rootControl );
 
   auto vbox = Control::New();
   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");
   rootControl.Add( vbox );
   DevelControl::SetLayout( vbox, vboxLayout );
   vbox.SetName( "Vbox");
   rootControl.Add( vbox );
@@ -875,14 +876,15 @@ int UtcDaliLayouting_VboxLayout03(void)
   //
   // For this test, add an hbox instead
   auto hbox = Control::New();
   //
   // 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();
   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.SetCellPadding( LayoutSize( 0, 10 ) );
+  vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL );
 
   DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
 
 
   DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION );
 
index 52466e4..dadce6e 100755 (executable)
@@ -33,8 +33,7 @@ devel_api_src_files = \
   $(devel_api_src_dir)/image-loader/texture-manager.cpp \
   $(devel_api_src_dir)/layouting/flex-layout.cpp \
   $(devel_api_src_dir)/layouting/absolute-layout.cpp \
   $(devel_api_src_dir)/image-loader/texture-manager.cpp \
   $(devel_api_src_dir)/layouting/flex-layout.cpp \
   $(devel_api_src_dir)/layouting/absolute-layout.cpp \
-  $(devel_api_src_dir)/layouting/hbox-layout.cpp \
-  $(devel_api_src_dir)/layouting/vbox-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 \
   $(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 \
@@ -85,8 +84,7 @@ 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/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 \
   $(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 \
diff --git a/dali-toolkit/devel-api/layouting/hbox-layout.cpp b/dali-toolkit/devel-api/layouting/hbox-layout.cpp
deleted file mode 100644 (file)
index 7f05745..0000000
+++ /dev/null
@@ -1,74 +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/devel-api/layouting/hbox-layout.h>
-
-//EXTERNAL HEADERS
-//INTERNAL HEADERS
-#include <dali-toolkit/internal/layouting/hbox-layout-impl.h>
-
-namespace Dali
-{
-namespace Toolkit
-{
-
-HboxLayout::HboxLayout()
-{
-}
-
-HboxLayout HboxLayout::New()
-{
-  Internal::HboxLayoutPtr internal = Internal::HboxLayout::New();
-  return HboxLayout( internal.Get() );
-}
-
-HboxLayout HboxLayout::DownCast( BaseHandle handle )
-{
-  return HboxLayout( dynamic_cast< Dali::Toolkit::Internal::HboxLayout*>( handle.GetObjectPtr() ) );
-}
-
-HboxLayout::HboxLayout( const HboxLayout& other )
-: LayoutGroup( other )
-{
-}
-
-HboxLayout& HboxLayout::operator=( const HboxLayout& other )
-{
-  if( &other != this )
-  {
-    LayoutGroup::operator=( 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 )
-: LayoutGroup( object )
-{
-}
-
-} // namespace Toolkit
-} // namespace Dali
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.
 
 /*
  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
@@ -30,14 +30,14 @@ namespace Toolkit
 
 namespace Internal DALI_INTERNAL
 {
 
 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.
  */
  * right to left or left to right direction change.
  */
-class DALI_IMPORT_API HboxLayout : public LayoutGroup
+class DALI_IMPORT_API LinearLayout : public LayoutGroup
 {
 public:
 
 {
 public:
 
@@ -47,63 +47,55 @@ public:
     CHILD_PROPERTY_END_INDEX   = LINEAR_LAYOUT_CHILD_PROPERTY_END_INDEX
   };
 
     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.
    */
    * 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
    * 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
    */
 
   /**
    * @brief Copy constructor
    */
-  HboxLayout( const HboxLayout& other );
+  LinearLayout( const LinearLayout& other );
 
   /**
    * @brief Assigment operator
    */
 
   /**
    * @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
    */
 
   /**
    * @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
 
   /**
    * @brief Set the padding between cells in the layout
@@ -119,19 +111,33 @@ public:
    */
   LayoutSize GetCellPadding();
 
    */
   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
   /**
 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
    */
    *
    * @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
 
   /// @endcond
 };
 
 } // namespace Toolkit
 } // namespace Dali
 
-#endif // DALI_TOOLKIT_LAYOUTING_HBOX_LAYOUT_H
+#endif // DALI_TOOLKIT_LAYOUTING_LINEAR_LAYOUT_H
index 6442c6f..328d1d6 100755 (executable)
@@ -13,8 +13,7 @@ toolkit_src_files = \
    $(toolkit_src_dir)/builder/replacement.cpp \
    $(toolkit_src_dir)/layouting/flex-layout-impl.cpp \
    $(toolkit_src_dir)/layouting/absolute-layout-impl.cpp \
    $(toolkit_src_dir)/builder/replacement.cpp \
    $(toolkit_src_dir)/layouting/flex-layout-impl.cpp \
    $(toolkit_src_dir)/layouting/absolute-layout-impl.cpp \
-   $(toolkit_src_dir)/layouting/hbox-layout-impl.cpp \
-   $(toolkit_src_dir)/layouting/vbox-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 \
    $(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/hbox-layout-impl.h b/dali-toolkit/internal/layouting/hbox-layout-impl.h
deleted file mode 100644 (file)
index 2057376..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-#ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_HBOX_LAYOUT_H
-#define DALI_TOOLKIT_INTERNAL_LAYOUTING_HBOX_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/hbox-layout.h>
-
-namespace Dali
-{
-namespace Toolkit
-{
-namespace Internal
-{
-
-class HboxLayout;
-using HboxLayoutPtr = IntrusivePtr<HboxLayout>;
-
-class HboxLayout final : public LayoutGroup
-{
-public:
-  static HboxLayoutPtr New();
-
-public:
-  void SetCellPadding( LayoutSize size );
-  LayoutSize GetCellPadding();
-
-protected:
-  HboxLayout();
-  virtual ~HboxLayout();
-
-  /**
-   * @copydoc LayoutItem::DoInitialize
-   */
-  virtual void DoInitialize() override;
-
-  /**
-   * @copydoc LayoutItem::DoRegisterChildProperties()
-   */
-  virtual void DoRegisterChildProperties( const std::string& containerType ) override;
-
-  /**
-   * @copydoc LayoutItem::OnChildAdd
-   */
-  virtual void OnChildAdd( LayoutItem& child ) override;
-
-  /**
-   * @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:
-  HboxLayout( const HboxLayout& other ) = delete;
-  HboxLayout& operator=( const HboxLayout& other ) = delete;
-
-  void ForceUniformHeight( int count, MeasureSpec widthMeasureSpec );
-
-private:
-  LayoutSize mCellPadding;
-  LayoutLength mTotalLength;
-};
-
-} // namespace Internal
-
-inline Internal::HboxLayout& GetImplementation( Dali::Toolkit::HboxLayout& handle )
-{
-  DALI_ASSERT_ALWAYS( handle && "HboxLayout handle is empty" );
-  BaseObject& object = handle.GetBaseObject();
-  return static_cast<Internal::HboxLayout&>( object );
-}
-
-inline const Internal::HboxLayout& GetImplementation( const Dali::Toolkit::HboxLayout& handle )
-{
-  DALI_ASSERT_ALWAYS( handle && "HboxLayout handle is empty" );
-  const BaseObject& object = handle.GetBaseObject();
-  return static_cast<const Internal::HboxLayout&>( object );
-}
-
-} // namespace Toolkit
-} // namespace Dali
-
-#endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_HBOX_LAYOUT_H
  */
 
 //CLASS HEADER
  */
 
 //CLASS HEADER
-#include <dali-toolkit/internal/layouting/hbox-layout-impl.h>
+#include "linear-layout-impl.h"
 
 
-//EXTERNAL HEADERS
-//INTERNAL HEADERS
+//PUBLIC INCLUDES
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/common/extents.h>
 #include <dali/public-api/actors/actor.h>
 #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>
 #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>
@@ -40,76 +41,96 @@ namespace Toolkit
 namespace Internal
 {
 
 namespace Internal
 {
 
-HboxLayoutPtr HboxLayout::New()
+LinearLayoutPtr LinearLayout::New()
 {
 {
-  HboxLayoutPtr layout( new HboxLayout() );
+  LinearLayoutPtr layout( new LinearLayout() );
   return layout;
 }
 
   return layout;
 }
 
-HboxLayout::HboxLayout()
+LinearLayout::LinearLayout()
 : LayoutGroup(),
   mCellPadding( 0, 0 ),
 : LayoutGroup(),
   mCellPadding( 0, 0 ),
+  mOrientation( Dali::Toolkit::LinearLayout::Orientation::HORIZONTAL ),
   mTotalLength( 0 )
 {
 }
 
   mTotalLength( 0 )
 {
 }
 
-HboxLayout::~HboxLayout()
+LinearLayout::~LinearLayout()
 {
 }
 
 {
 }
 
-void HboxLayout::DoInitialize()
+void LinearLayout::SetCellPadding( LayoutSize size )
 {
 {
+  mCellPadding = size;
 }
 
 }
 
-void HboxLayout::DoRegisterChildProperties( const std::string& containerType )
+LayoutSize LinearLayout::GetCellPadding()
 {
 {
-  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 );
-    }
-  }
+  return mCellPadding;
 }
 
 }
 
-void HboxLayout::OnChildAdd( LayoutItem& child )
+void LinearLayout::SetOrientation( Dali::Toolkit::LinearLayout::Orientation orientation )
 {
 {
-  auto owner = child.GetOwner();
-  owner.SetProperty( Toolkit::HboxLayout::ChildProperty::WEIGHT, 1.0f );
+  mOrientation = orientation;
 }
 
 }
 
-void HboxLayout::SetCellPadding( LayoutSize size )
+Dali::Toolkit::LinearLayout::Orientation LinearLayout::GetOrientation()
 {
 {
-  mCellPadding = size;
+  return mOrientation;
 }
 
 }
 
-LayoutSize HboxLayout::GetCellPadding()
+void LinearLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec )
 {
 {
-  return mCellPadding;
+#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 HboxLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec 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;
 {
 #if defined(DEBUG_ENABLED)
   auto actor = Actor::DownCast(GetOwner());
 
   std::ostringstream oss;
-  oss << "HBoxLayout::OnMeasure  ";
+  oss << "LinearLayout::OnLayout  ";
   if( actor )
   {
     oss << "Actor Id:" << actor.GetId() << " Name:" << actor.GetName() << "  ";
   }
   if( actor )
   {
     oss << "Actor Id:" << actor.GetId() << " Name:" << actor.GetName() << "  ";
   }
-  oss << "widthMeasureSpec:" << widthMeasureSpec << " heightMeasureSpec:" << heightMeasureSpec << std::endl;
+  oss << "left:" << left << " top:" << top << " right:" << right << " bottom:" << bottom << std::endl;
   DALI_LOG_INFO( gLogFilter, Debug::Concise, oss.str().c_str() );
 #endif
 
   DALI_LOG_INFO( gLogFilter, Debug::Concise, oss.str().c_str() );
 #endif
 
-  DALI_LOG_INFO( gLogFilter, Debug::Concise, "HboxLayout::OnMeasure widthSize(%d) \n", widthMeasureSpec.GetSize());
+  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);
   auto widthMode = widthMeasureSpec.GetMode();
   auto heightMode = heightMeasureSpec.GetMode();
   bool isExactly = (widthMode == MeasureSpec::Mode::EXACTLY);
@@ -136,7 +157,7 @@ void HboxLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeas
       auto childWidth = childLayout->GetMeasuredWidth();
       auto childMargin = childLayout->GetMargin();
 
       auto childWidth = childLayout->GetMeasuredWidth();
       auto childMargin = childLayout->GetMargin();
 
-      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "HboxLayout::OnMeasure childWidth(%d)\n", MeasureSpec::IntType( childWidth ) );
+      DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LinearLayout::OnMeasure childWidth(%d)\n", MeasureSpec::IntType( childWidth ) );
 
       auto length = childWidth + LayoutLength::IntType(childMargin.start + childMargin.end);
 
 
       auto length = childWidth + LayoutLength::IntType(childMargin.start + childMargin.end);
 
@@ -203,7 +224,7 @@ void HboxLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeas
   }
 }
 
   }
 }
 
-void HboxLayout::ForceUniformHeight( int count, MeasureSpec 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
 {
   // 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
@@ -233,7 +254,7 @@ void HboxLayout::ForceUniformHeight( int count, MeasureSpec widthMeasureSpec )
   }
 }
 
   }
 }
 
-void HboxLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom )
+void LinearLayout::LayoutHorizontal( LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom )
 {
   auto owner = GetOwner();
   auto actor = Actor::DownCast(owner);
 {
   auto owner = GetOwner();
   auto actor = Actor::DownCast(owner);
@@ -271,7 +292,6 @@ void HboxLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, La
     {
       auto childWidth = childLayout->GetMeasuredWidth();
       auto childHeight = childLayout->GetMeasuredHeight();
     {
       auto childWidth = childLayout->GetMeasuredWidth();
       auto childHeight = childLayout->GetMeasuredHeight();
-
       auto childMargin = childLayout->GetMargin();
 
       childTop = LayoutLength(padding.top) + ((childSpace - childHeight) / 2) + childMargin.top - childMargin.bottom;
       auto childMargin = childLayout->GetMargin();
 
       childTop = LayoutLength(padding.top) + ((childSpace - childHeight) / 2) + childMargin.top - childMargin.bottom;
@@ -283,6 +303,150 @@ void HboxLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, La
   }
 }
 
   }
 }
 
+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 };
+
+  // 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
 } // 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