Merge "Add new layouting support for TextLabel and ImageView." into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 5 Jul 2018 15:24:55 +0000 (15:24 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Thu, 5 Jul 2018 15:24:55 +0000 (15:24 +0000)
15 files changed:
automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp
automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp
build/tizen/configure.ac
build/tizen/dali-toolkit/Makefile.am
dali-toolkit/devel-api/file.list
dali-toolkit/devel-api/layouting/layout-child-impl.h [new file with mode: 0644]
dali-toolkit/devel-api/layouting/layout-group-impl.cpp
dali-toolkit/devel-api/layouting/layout-group-impl.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-parent-impl.h
dali-toolkit/internal/controls/control/control-data-impl.cpp
dali-toolkit/internal/controls/image-view/image-view-impl.cpp
dali-toolkit/public-api/controls/control-impl.cpp
packaging/dali-toolkit.spec

index c9cbdc5..02446a0 100644 (file)
@@ -26,6 +26,7 @@
 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 
 #include <test-native-image.h>
 #include <sstream>
@@ -1619,3 +1620,91 @@ int UtcDaliImageViewResourceReadySignalWithReusedImage02(void)
 
   END_TEST;
 }
+
+int UtcDaliImageViewPaddingProperty(void)
+{
+  ToolkitTestApplication application;
+
+  ImageView imageView = ImageView::New();
+  Property::Map imagePropertyMap;
+  imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
+  imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/gallery-small-1.jpg" ;
+  imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
+  imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
+  imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
+  imageView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  imageView.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
+  Stage::GetCurrent().Add( imageView );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
+
+  ImageView childImage = ImageView::New();
+  childImage.SetBackgroundColor( Color::BLACK );
+  childImage.SetSize( 10.f, 10.f );
+  imageView.Add( childImage );
+
+  application.SendNotification();
+  application.Render();
+
+  // Child ImageView should be positioned dependinig on Parent ImageView's Padding value
+  DALI_TEST_EQUALS( childImage.GetProperty<Vector3>( Dali::Actor::Property::POSITION ), Vector3( 15, 5, 0 ), TEST_LOCATION );
+
+  // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
+  Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
+  Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
+  Property::Map resultMap;
+  imageVisual.CreatePropertyMap( resultMap );
+
+  Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
+  DALI_TEST_CHECK( transformValue );
+  Property::Map* retMap = transformValue->GetMap();
+  DALI_TEST_CHECK( retMap );
+
+  // Image Visual should be positioned depending on ImageView's padding
+  DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliImageViewPaddingProperty02(void)
+{
+  ToolkitTestApplication application;
+
+  ImageView imageView = ImageView::New();
+  Property::Map imagePropertyMap;
+  imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
+  imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = TEST_RESOURCE_DIR "/Kid1.svg" ;
+  imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 128;
+  imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 128;
+  imagePropertyMap[ DevelVisual::Property::VISUAL_FITTING_MODE ] = Toolkit::DevelVisual::FIT_KEEP_ASPECT_RATIO;
+  imageView.SetProperty( Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
+  imageView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  imageView.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  imageView.SetProperty( Control::Property::PADDING, Extents( 15, 10, 5, 10 ) );
+  Stage::GetCurrent().Add( imageView );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( imageView.GetProperty<Extents>( Control::Property::PADDING ), Extents( 15, 10, 5, 10 ), TEST_LOCATION );
+
+  // Check whether Image Visual transforms on ImageVieiw::OnRelayout()
+  Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( imageView );
+  Toolkit::Visual::Base imageVisual = DevelControl::GetVisual( controlImpl, ImageView::Property::IMAGE );
+  Property::Map resultMap;
+  imageVisual.CreatePropertyMap( resultMap );
+
+  Property::Value* transformValue = resultMap.Find( Visual::Property::TRANSFORM );
+  DALI_TEST_CHECK( transformValue );
+  Property::Map* retMap = transformValue->GetMap();
+  DALI_TEST_CHECK( retMap );
+
+  // Image Visual should be positioned depending on ImageView's padding
+  DALI_TEST_EQUALS( retMap->Find( Visual::Transform::Property::OFFSET )->Get< Vector2 >(), Vector2( 15, 5 ), TEST_LOCATION );
+
+  END_TEST;
+}
index 17fc90f..cd82d5e 100644 (file)
@@ -24,6 +24,8 @@
 #include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali-toolkit/devel-api/layouting/absolute-layout.h>
 #include <dali-toolkit/devel-api/layouting/linear-layout.h>
+#include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
+#include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
 
 #include <../custom-layout.h>
 
@@ -1607,7 +1609,6 @@ int UtcDaliLayouting_HboxLayout_TargetSize(void)
   END_TEST;
 }
 
-
 int UtcDaliLayouting_RemoveLayout01(void)
 {
   ToolkitTestApplication application;
@@ -1661,3 +1662,179 @@ int UtcDaliLayouting_RemoveLayout01(void)
 
   END_TEST;
 }
+
+int UtcDaliLayouting_LayoutChildren01(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliLayouting_LayoutChildren01");
+
+  Stage stage = Stage::GetCurrent();
+
+  auto rootControl = Control::New();
+  auto absoluteLayout = AbsoluteLayout::New();
+  DevelControl::SetLayout( rootControl, absoluteLayout );
+  stage.Add( rootControl );
+
+  auto hbox = Control::New();
+  auto hboxLayout = LinearLayout::New();
+  DevelControl::SetLayout( hbox, hboxLayout );
+  rootControl.Add( hbox );
+
+  DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
+
+  tet_infoline("Test removal by setting empty layout to child container" );
+  DevelControl::SetLayout( hbox, LayoutItem{} );
+
+  DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
+
+  auto& hboxImpl = GetImplementation( hboxLayout );
+  Handle empty;
+  DALI_TEST_EQUALS( hboxLayout.GetOwner(), empty, TEST_LOCATION );
+  DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliLayouting_LayoutChildren02(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliLayouting_LayoutChildren02");
+
+  Stage stage = Stage::GetCurrent();
+
+  auto rootControl = Control::New();
+  auto absoluteLayout = AbsoluteLayout::New();
+  DevelControl::SetLayout( rootControl, absoluteLayout );
+  stage.Add( rootControl );
+
+  auto hbox = Control::New();
+  auto hboxLayout = LinearLayout::New();
+  DevelControl::SetLayout( hbox, hboxLayout );
+  rootControl.Add( hbox );
+
+  DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
+
+  tet_infoline("Test removal by removing child actor from parent container" );
+  hbox.Unparent();
+
+  DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
+
+  auto& hboxImpl = GetImplementation( hboxLayout );
+  tet_infoline("Test child actor still has hbox layout " );
+  DALI_TEST_EQUALS( (bool)hboxLayout.GetOwner(), true, TEST_LOCATION );
+
+  tet_infoline("Test hbox layout has no parent " );
+  DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliLayouting_LayoutChildren03(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliLayouting_LayoutChildren02");
+
+  Stage stage = Stage::GetCurrent();
+
+  auto rootControl = Control::New();
+  auto absoluteLayout = AbsoluteLayout::New();
+  DevelControl::SetLayout( rootControl, absoluteLayout );
+  stage.Add( rootControl );
+
+  auto hbox = Control::New();
+  auto hboxLayout = LinearLayout::New();
+  DevelControl::SetLayout( hbox, hboxLayout );
+  rootControl.Add( hbox );
+
+  DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
+
+  tet_infoline("Test removal by removing child layout from parent layout" );
+  absoluteLayout.Remove( hboxLayout );
+
+  DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 0, TEST_LOCATION );
+
+  auto& hboxImpl = GetImplementation( hboxLayout );
+
+  tet_infoline("Check child actor has orphaned layout (Moving child keeps old layout)");
+  DALI_TEST_EQUALS( hboxLayout.GetOwner(), hbox, TEST_LOCATION );
+  DALI_TEST_EQUALS( DevelControl::GetLayout(hbox), hboxLayout, TEST_LOCATION );
+
+  tet_infoline("Check orphaned layout has no parent");
+  DALI_TEST_EQUALS( (void*)hboxImpl.GetParent(), (void*)nullptr, TEST_LOCATION );
+
+  END_TEST;
+}
+
+
+int UtcDaliLayouting_LayoutChildren04(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliLayouting_LayoutChildren03");
+
+  Stage stage = Stage::GetCurrent();
+
+  auto rootControl = Control::New();
+  auto absoluteLayout = AbsoluteLayout::New();
+  DevelControl::SetLayout( rootControl, absoluteLayout );
+  stage.Add( rootControl );
+
+  auto hbox = Control::New();
+  tet_infoline("Test unparenting by adding child with no layout to parent (should auto-generate LayoutItem) ");
+  auto hboxLayout = LinearLayout::New();
+  rootControl.Add( hbox );
+
+  DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
+
+  tet_infoline("Then setting a layout on the child container");
+  DevelControl::SetLayout( hbox, hboxLayout );
+
+  DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION );
+
+  auto& hboxImpl = GetImplementation( hboxLayout );
+  auto& absImpl = GetImplementation( absoluteLayout );
+  DALI_TEST_EQUALS( hboxLayout.GetOwner(), Handle(hbox), TEST_LOCATION );
+  DALI_TEST_EQUALS( hboxImpl.GetParent(), (Dali::Toolkit::Internal::LayoutParent*)&absImpl, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliLayouting_SetLayoutOrder(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Call SetLayout after adding the control to the root layout");
+
+  Stage stage = Stage::GetCurrent();
+
+  auto rootControl = Control::New();
+  auto absoluteLayout = AbsoluteLayout::New();
+  DevelControl::SetLayout( rootControl, absoluteLayout );
+  rootControl.SetName( "AbsoluteLayout" );
+  stage.Add( rootControl );
+
+  tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Creating control");
+  auto hbox = Control::New();
+  auto hboxLayout = LinearLayout::New();
+  hbox.SetName( "HBox");
+
+  tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Add control to root layout");
+  rootControl.Add( hbox );
+
+  tet_infoline(" UtcDaliLayouting_SetLayoutOrder - Set layout to control AFTER control added to root");
+  DevelControl::SetLayout( hbox, hboxLayout );
+
+  // Add a Child control
+  std::vector< Control > controls;
+  controls.push_back( CreateLeafControl( 100, 100 ) ); // Single control
+  for( auto&& iter : controls )
+  {
+    hbox.Add( iter );
+  }
+
+  // Ensure layouting happens
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS( controls[0].GetProperty<Vector3>( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION );
+
+  END_TEST;
+}
index 96c78cd..40bdf27 100755 (executable)
@@ -195,14 +195,20 @@ DOXYGEN_ROOT_DIR=../../..
 AC_SUBST(DOXYGEN_DOCS_DIR)
 AC_SUBST(DOXYGEN_ROOT_DIR)
 
+if test "x$enable_cxx03_abi" = "xyes"; then
+PKG_CHECK_MODULES(DALI, dali-core-cxx03)
+PKG_CHECK_MODULES(DALIDAPTOR, dali-adaptor-cxx03)
+else
+PKG_CHECK_MODULES(DALICORE, dali-core)
+PKG_CHECK_MODULES(DALIADAPTOR, dali-adaptor)
+fi
+
 # Enable csharp plugin
 build_csharp_plugin=no
 build_ruby_flag=no
 if test x$enable_csharp = xyes; then
   [build_csharp_plugin=yes]
   AC_MSG_NOTICE(Building DALi csharp plugin ...)
-
-  PKG_CHECK_MODULES(DALIADAPTOR, dali-adaptor)
   AC_PATH_PROG([SWIG], [swig])
 
   # if gbs enable, then only use swig, without ruby or mcs
@@ -225,12 +231,6 @@ if test x$enable_csharp = xyes; then
   AC_SUBST(DALITOOLKIT_LIBS)
 fi
 
-if test "x$enable_cxx03_abi" = "xyes"; then
-PKG_CHECK_MODULES(DALICORE, dali-core-cxx03)
-else
-PKG_CHECK_MODULES(DALICORE, dali-core)
-fi
-
 #set a variable for the makefile to force compile the csharp plugin
 AM_CONDITIONAL([ENABLE_CSHARP_PLUGIN], [test x$build_csharp_plugin = xyes])
 AM_CONDITIONAL([ENABLE_RUBY_FLAG], [test x$build_ruby_flag = xyes])
index 29fe4a0..bbaf116 100644 (file)
@@ -77,12 +77,14 @@ LIBDALI_TOOLKIT_LA_CXXFLAGS = -DDALI_COMPILATION \
                       -I../../../ \
                       $(DALI_TOOLKIT_CFLAGS) \
                       $(DALICORE_CFLAGS) \
+                      $(DALIADAPTOR_CFLAGS) \
                       $(DLOG_CFLAGS) \
                       $(FRIBIDI_CFLAGS) \
                       $(HTMLCXX_CFLAGS)
 
 LIBDALI_TOOLKIT_LA_LIBADD = \
                       $(DALICORE_LIBS) \
+                      $(DALIADAPTOR_LIBS) \
                       $(DLOG_LIBS) \
                       $(FRIBIDI_LIBS) \
                       $(HTMLCXX_LIBS)
index dadce6e..411afe1 100755 (executable)
@@ -85,15 +85,16 @@ devel_api_layouting_header_files = \
   $(devel_api_src_dir)/layouting/child-layout-data.h \
   $(devel_api_src_dir)/layouting/flex-layout.h \
   $(devel_api_src_dir)/layouting/linear-layout.h \
-  $(devel_api_src_dir)/layouting/layout-item.h \
-  $(devel_api_src_dir)/layouting/layout-item-impl.h \
+  $(devel_api_src_dir)/layouting/layout-child-impl.h \
   $(devel_api_src_dir)/layouting/layout-controller.h \
   $(devel_api_src_dir)/layouting/layout-group.h \
   $(devel_api_src_dir)/layouting/layout-group-impl.h \
+  $(devel_api_src_dir)/layouting/layout-item.h \
+  $(devel_api_src_dir)/layouting/layout-item-impl.h \
   $(devel_api_src_dir)/layouting/layout-length.h \
+  $(devel_api_src_dir)/layouting/layout-parent-impl.h \
   $(devel_api_src_dir)/layouting/layout-size.h \
   $(devel_api_src_dir)/layouting/measured-size.h \
-  $(devel_api_src_dir)/layouting/layout-parent-impl.h \
   $(devel_api_src_dir)/layouting/measure-spec.h
 
 devel_api_magnifier_header_files = \
diff --git a/dali-toolkit/devel-api/layouting/layout-child-impl.h b/dali-toolkit/devel-api/layouting/layout-child-impl.h
new file mode 100644 (file)
index 0000000..79cea9c
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_CHILD_H
+#define DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_CHILD_H
+
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dali-toolkit/public-api/dali-toolkit-common.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal
+{
+class LayoutParent;
+
+/**
+ * Interface that allows a layout to determine its layout parent.
+ *
+ * This is useful for LayoutItem to determine it's parent, without accessing
+ * via LayoutGroup, which is a subclass of LayoutItem (Super classes shouldn't
+ * know / care about derived classes)
+ */
+class DALI_TOOLKIT_API LayoutChild
+{
+public:
+  /**
+   * Set the parent of this layout.
+   */
+  virtual void SetParent( LayoutParent* parent ) = 0;
+
+  /**
+   * Get the parent of this layout.
+   */
+  virtual LayoutParent* GetParent() = 0;
+
+protected:
+  virtual ~LayoutChild()
+  {
+  }
+};
+
+
+} // namespace Internal
+} // namespace Toolkit
+} // namespace Dali
+
+#endif //DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_CHILD_H
index d28ec90..f3856de 100644 (file)
@@ -100,7 +100,7 @@ void LayoutGroup::Remove( Toolkit::LayoutGroup::LayoutId childId )
   {
     if( iter->layoutId == childId )
     {
-      OnChildRemove( *iter->child.Get() );
+      RemoveChild( *iter->child.Get() );
       mImpl->mChildren.erase(iter);
       break;
     }
@@ -114,7 +114,7 @@ void LayoutGroup::Remove( LayoutItem& child )
   {
     if( iter->child.Get() == &child )
     {
-      OnChildRemove( *iter->child.Get() );
+      RemoveChild( *iter->child.Get() );
       mImpl->mChildren.erase(iter);
       break;
     }
@@ -126,7 +126,7 @@ void LayoutGroup::RemoveAll()
 {
   for( auto iter = mImpl->mChildren.begin() ; iter != mImpl->mChildren.end() ; )
   {
-    OnChildRemove( *iter->child.Get() );
+    RemoveChild( *iter->child.Get() );
     iter = mImpl->mChildren.erase(iter);
   }
 }
@@ -434,17 +434,12 @@ 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::RemoveChild( LayoutItem& item )
+{
+  item.SetParent( nullptr );
+  OnChildRemove( item );
 }
 
 void LayoutGroup::ChildAddedToOwner( Actor child )
index 90c40fa..36e0312 100644 (file)
@@ -23,6 +23,7 @@
 #include <dali/public-api/signals/connection-tracker.h>
 #include <dali-toolkit/devel-api/layouting/child-layout-data.h>
 #include <dali-toolkit/devel-api/layouting/layout-group.h>
+#include <dali-toolkit/devel-api/layouting/layout-parent-impl.h>
 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
 
 namespace Dali
@@ -55,6 +56,7 @@ using LayoutGroupPtr = IntrusivePtr<LayoutGroup>;
  * position and size; it should then call Layout() on the child layout to layout the child and it's hierarchy.
  */
 class DALI_TOOLKIT_API LayoutGroup : public LayoutItem,
+                                     public LayoutParent,
                                      public ConnectionTracker
 {
 public:
@@ -79,19 +81,19 @@ public:
    * @param[in] layoutChild The child to add
    * @return The layout id of this child.
    */
-  Toolkit::LayoutGroup::LayoutId Add( LayoutItem& layoutChild );
+  Toolkit::LayoutGroup::LayoutId Add( LayoutItem& layoutChild ) override;
 
   /**
    * @brief Remove a layout child from this group.
    * @param[in] childId The layout child id
    */
-  void Remove( Toolkit::LayoutGroup::LayoutId childId );
+  void Remove( Toolkit::LayoutGroup::LayoutId childId ) override;
 
   /**
    * @brief Remove a layout child from this group
    * @param[in] child The layout child
    */
-  void Remove( LayoutItem& child );
+  void Remove( LayoutItem& child ) override;
 
   /**
    * @brief Remove all layout children.
@@ -245,6 +247,11 @@ private:
   void OnUnparent() override final;
 
   /**
+   * Method to remove a child from this group
+   */
+  void RemoveChild( LayoutItem& item );
+
+  /**
    * Callback when child is added to owner
    */
   void ChildAddedToOwner( Actor child );
index b5e7720..4c1e6b9 100644 (file)
@@ -20,6 +20,7 @@
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali-toolkit/public-api/controls/control.h>
 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
+#include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
 #include <dali-toolkit/internal/layouting/layout-item-data-impl.h>
 
 namespace
@@ -78,6 +79,16 @@ void LayoutItem::Unparent()
   // Enable directly derived types to first remove children
   OnUnparent();
 
+  // Remove myself from parent
+  LayoutParent* parent = GetParent();
+  if( parent )
+  {
+    parent->Remove( *this );
+  }
+
+  // Remove parent reference
+  SetParent(nullptr);
+
   // Last, clear owner
   mImpl->mOwner = NULL;
 }
index ce5250a..cfbe8ea 100644 (file)
@@ -24,7 +24,7 @@
 #include <dali/public-api/actors/actor-enumerations.h>
 #include <dali-toolkit/devel-api/layouting/child-layout-data.h>
 #include <dali-toolkit/devel-api/layouting/layout-item.h>
-#include <dali-toolkit/devel-api/layouting/layout-parent-impl.h>
+#include <dali-toolkit/devel-api/layouting/layout-child-impl.h>
 #include <dali-toolkit/devel-api/layouting/layout-controller.h>
 #include <dali-toolkit/devel-api/layouting/layout-size.h>
 #include <dali-toolkit/devel-api/layouting/measure-spec.h>
@@ -45,7 +45,7 @@ using LayoutItemPtr = IntrusivePtr<LayoutItem>;
  * Base class for layouts.
  */
 class DALI_TOOLKIT_API LayoutItem : public BaseObject,
-                                    public LayoutParent
+                                    public LayoutChild
 {
 public:
   /**
@@ -94,7 +94,8 @@ public:
   Handle GetOwner() const;
 
   /**
-   * @brief Unparent this layout from it's owner, and remove any layout children in derived types
+   * @brief Unparent this layout from it's parent, remove it from it's owner
+   * and remove any layout children in derived types.
    */
   void Unparent();
 
@@ -158,14 +159,14 @@ public:
   static LayoutLength GetDefaultSize( LayoutLength size, MeasureSpec measureSpec );
 
   /**
-   * @copydoc LayoutParent::SetParent
+   * @copydoc LayoutChild::SetParent
    */
-  virtual void SetParent( LayoutParent* parent ) override;
+  void SetParent( LayoutParent* parent ) override;
 
   /**
-   * @copydoc LayoutParent::GetParent
+   * @copydoc LayoutChild::GetParent
    */
-  virtual LayoutParent* GetParent() override;
+  LayoutParent* GetParent() override;
 
   /**
    * @brief Request that this layout is re-laid out.
index d55fb42..677a8ff 100644 (file)
@@ -25,25 +25,32 @@ namespace Toolkit
 {
 namespace Internal
 {
+class LayoutItem;
 
 /**
- * Interface that allows a layout to determine its layout parent.
- *
- * Needed to prevent circular inheritance - most LayoutBases have a parent,
- * but parenting is provided by LayoutGroup, which is a sub-class of LayoutBase.
+ * Interface that defines a layout Parent. Enables a layout child to access
+ * methods on its parent, e.g. Remove (during unparenting)
  */
 class DALI_TOOLKIT_API LayoutParent
 {
 public:
   /**
-   * Set the parent of this layout.
+   * @brief Add a child to the parent
+   * @param[in] item The item to add to this layout parent
    */
-  virtual void SetParent( LayoutParent* parent ) = 0;
+  virtual Toolkit::LayoutGroup::LayoutId Add( LayoutItem& item ) = 0;
 
   /**
-   * Get the parent of this layout.
+   * @brief Remove a layout child from this group.
+   * @param[in] childId The layout child id
    */
-  virtual LayoutParent* GetParent() = 0;
+  virtual void Remove( Toolkit::LayoutGroup::LayoutId childId ) = 0;
+
+  /**
+   * @brief Remove a child from this parent
+   * @param[in] item The item to remove from this layout parent
+   */
+  virtual void Remove( LayoutItem& item ) = 0;
 
 protected:
   virtual ~LayoutParent()
@@ -52,6 +59,7 @@ protected:
 };
 
 
+
 } // namespace Internal
 } // namespace Toolkit
 } // namespace Dali
index a6d30d9..cbeb4c5 100755 (executable)
@@ -1391,6 +1391,9 @@ void Control::Impl::OnStageDisconnection()
 void Control::Impl::SetMargin( Extents margin )
 {
   mControlImpl.mImpl->mMargin = margin;
+
+  // Trigger a size negotiation request that may be needed when setting a margin.
+  mControlImpl.RelayoutRequest();
 }
 
 Extents Control::Impl::GetMargin() const
@@ -1401,6 +1404,9 @@ Extents Control::Impl::GetMargin() const
 void Control::Impl::SetPadding( Extents padding )
 {
   mControlImpl.mImpl->mPadding = padding;
+
+  // Trigger a size negotiation request that may be needed when setting a padding.
+  mControlImpl.RelayoutRequest();
 }
 
 Extents Control::Impl::GetPadding() const
index 4e8d266..11d5389 100755 (executable)
@@ -270,46 +270,47 @@ void ImageView::OnRelayout( const Vector2& size, RelayoutContainer& container )
   {
     Property::Map transformMap = Property::Map();
 
-    // Don't transform if fitting mode is FILL
-    if(Toolkit::GetImplementation(mVisual).GetFittingMode() == Visual::FittingMode::FIT_KEEP_ASPECT_RATIO)
+    Extents padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+
+    Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>(
+          Self().GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get<int>() );
+
+    if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection )
     {
-      Extents padding;
-      padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
+      std::swap( padding.start, padding.end );
+    }
 
-      Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>(
-              Self().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
+    auto finalOffset = Vector2( padding.start, padding.top );
 
-      if (Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection)
-      {
-        std::swap(padding.start, padding.end);
-      }
+    // remove padding from the size to know how much is left for the visual
+    auto finalSize = size - Vector2( padding.start + padding.end, padding.top + padding.bottom );
 
-      // remove padding from the size to know how much is left for the visual
-      auto paddedSize = size - Vector2(padding.start + padding.end, padding.top + padding.bottom);
+    // Should provide a transform that handles aspect ratio according to image size
+    if( Toolkit::GetImplementation(mVisual).GetFittingMode() == Visual::FittingMode::FIT_KEEP_ASPECT_RATIO )
+    {
+      auto availableVisualSize = finalSize;
 
       Vector2 naturalSize;
-      mVisual.GetNaturalSize(naturalSize);
+      mVisual.GetNaturalSize( naturalSize );
 
       // scale to fit the padded area
-      auto finalSize =
-             naturalSize * std::min( ( naturalSize.width  ? ( paddedSize.width  / naturalSize.width  ) : 0 ),
-                                     ( naturalSize.height ? ( paddedSize.height / naturalSize.height ) : 0 ) );
+      finalSize = naturalSize * std::min( ( naturalSize.width  ? ( availableVisualSize.width  / naturalSize.width  ) : 0 ),
+                                          ( naturalSize.height ? ( availableVisualSize.height / naturalSize.height ) : 0 ) );
 
       // calculate final offset within the padded area
-      auto finalOffset = Vector2(padding.start, padding.top) + (paddedSize - finalSize) * .5f;
-
-      // populate the transform map
-      transformMap.Add(Toolkit::Visual::Transform::Property::OFFSET, finalOffset)
-          .Add(Toolkit::Visual::Transform::Property::OFFSET_POLICY,
-              Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE))
-          .Add(Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN)
-          .Add(Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN)
-          .Add(Toolkit::Visual::Transform::Property::SIZE, finalSize)
-          .Add(Toolkit::Visual::Transform::Property::SIZE_POLICY,
-              Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE));
-
+      finalOffset += ( availableVisualSize - finalSize ) * .5f;
     }
-    // Should provide a transform that handles aspect ratio according to image size
+
+    // populate the transform map
+    transformMap.Add( Toolkit::Visual::Transform::Property::OFFSET, finalOffset )
+                .Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY,
+                    Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) )
+                .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
+                .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN )
+                .Add( Toolkit::Visual::Transform::Property::SIZE, finalSize )
+                .Add( Toolkit::Visual::Transform::Property::SIZE_POLICY,
+                    Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) );
+
     mVisual.SetTransformAndSize( transformMap, size );
   }
 }
index 8a79594..664c7e0 100755 (executable)
@@ -129,46 +129,6 @@ void CreateClippingRenderer( Control& controlImpl )
   }
 }
 
-/**
- * @brief Sets Control::Property::BACKGROUND visual
- * @param[in] controlImpl The control implementation
- * @param[in] visual The control background visual
- * @param[in] size The current size
- */
-void SetBackgroundVisual( Control::Impl& controlImpl, Toolkit::Visual::Base& visual, const Vector2& size )
-{
-  Property::Map transformMap = Property::Map();
-
-  Vector2 newSize( 0.f, 0.f );
-  newSize.width = size.width + ( controlImpl.mPadding.start + controlImpl.mPadding.end );
-  newSize.height = size.height + ( controlImpl.mPadding.top + controlImpl.mPadding.bottom );
-
-  if( ( controlImpl.mMargin.start != 0 ) ||
-      ( controlImpl.mMargin.end != 0 ) ||
-      ( controlImpl.mMargin.top != 0 ) ||
-      ( controlImpl.mMargin.bottom != 0 ) )
-  {
-    transformMap.Add( Toolkit::Visual::Transform::Property::SIZE, newSize )
-                .Add( Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) )
-                .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( controlImpl.mMargin.start, controlImpl.mMargin.top ) )
-                .Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) )
-                .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
-                .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN );
-  }
-  else if( ( controlImpl.mPadding.start != 0 ) ||
-           ( controlImpl.mPadding.end != 0 ) ||
-           ( controlImpl.mPadding.top != 0 ) ||
-           ( controlImpl.mPadding.bottom != 0 ) )
-  {
-    transformMap.Add( Toolkit::Visual::Transform::Property::SIZE, newSize )
-                .Add( Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) )
-                .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
-                .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN );
-  }
-
-  visual.SetTransformAndSize( transformMap, newSize ); // Send an empty map as we do not want to modify the visual's set transform
-}
-
 } // unnamed namespace
 
 
@@ -659,8 +619,7 @@ void Control::OnSizeSet(const Vector3& targetSize)
   if( visual )
   {
     Vector2 size( targetSize );
-    SetBackgroundVisual( *mImpl, visual, size );
-
+    visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform
   }
 }
 
@@ -739,7 +698,7 @@ void Control::OnRelayout( const Vector2& size, RelayoutContainer& container )
   Toolkit::Visual::Base visual = mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND );
   if( visual )
   {
-    SetBackgroundVisual( *mImpl, visual, size );
+    visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform
   }
 }
 
index 0dd28cb..4be149a 100644 (file)
@@ -17,18 +17,13 @@ Requires(postun): /sbin/ldconfig
 BuildRequires:  pkgconfig
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(dali-core)
+BuildRequires:  pkgconfig(dali-adaptor)
 %if !0%{?disable_cxx03_build}
 BuildRequires:  pkgconfig(dali-core-cxx03)
+BuildRequires:  pkgconfig(dali-adaptor-cxx03)
 %endif
 BuildRequires: gettext
 
-# dali-toolkit only need to know the interfaces(APIs) of dali-adaptor(the devel package).
-# It doesn't need to know which adaptor will be used by applications.
-# Applications or dali-addon will decide which one they will use.
-BuildRequires:  dali-adaptor-devel
-%if !0%{?disable_cxx03_build}
-BuildRequires:  dali-adaptor-devel-cxx03
-%endif
 
 #need libtzplatform-config for directory if tizen version is 3.x