From: Agnelo Vaz Date: Thu, 18 Apr 2019 15:20:53 +0000 (+0100) Subject: Removing native layouting X-Git-Tag: dali_1.4.17~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=b442c753b36a4bdc87d10a73e42af9fed6b88c4f Removing native layouting Change-Id: Ib22cdd94cc3159ecc991a44621636f67c0194b11 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 9114e20..57599c7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ ADD_DEFINITIONS( ) #head file path -INCLUDE_DIRECTORIES( +INCLUDE_DIRECTORIES( ./ ../dali-core ../dali-adaptor @@ -62,14 +62,6 @@ SET ( SOURCES ${SOURCES} ${devel_api_src_dir}/image-loader/atlas-upload-observer.cpp ${devel_api_src_dir}/image-loader/image-atlas.cpp ${devel_api_src_dir}/image-loader/texture-manager.cpp - ${devel_api_src_dir}/layouting/absolute-layout.cpp - ${devel_api_src_dir}/layouting/grid.cpp - ${devel_api_src_dir}/layouting/linear-layout.cpp - ${devel_api_src_dir}/layouting/layout-item-impl.cpp - ${devel_api_src_dir}/layouting/layout-item.cpp - ${devel_api_src_dir}/layouting/layout-group-impl.cpp - ${devel_api_src_dir}/layouting/layout-group.cpp - ${devel_api_src_dir}/layouting/layout-controller.cpp ${devel_api_src_dir}/scripting/script.cpp ${devel_api_src_dir}/styling/style-manager-devel.cpp ${devel_api_src_dir}/transition-effects/cube-transition-cross-effect.cpp @@ -96,15 +88,6 @@ SET( SOURCES ${SOURCES} ${internal_src_dir}/builder/style.cpp ${internal_src_dir}/builder/tree-node-manipulator.cpp ${internal_src_dir}/builder/replacement.cpp - ${internal_src_dir}/layouting/absolute-layout-impl.cpp - ${internal_src_dir}/layouting/grid-impl.cpp - ${internal_src_dir}/layouting/grid-locations.cpp - ${internal_src_dir}/layouting/linear-layout-impl.cpp - ${internal_src_dir}/layouting/layout-item-data-impl.cpp - ${internal_src_dir}/layouting/layout-group-data-impl.cpp - ${internal_src_dir}/layouting/layout-controller-impl.cpp - ${internal_src_dir}/layouting/layout-controller-debug.cpp - ${internal_src_dir}/layouting/layout-transition-data-impl.cpp ${internal_src_dir}/visuals/animated-image/animated-image-visual.cpp ${internal_src_dir}/visuals/animated-image/image-cache.cpp ${internal_src_dir}/visuals/animated-image/fixed-image-cache.cpp @@ -322,5 +305,5 @@ target_link_libraries(dali-toolkit WindowsPlatform.lib) add_dependencies(dali-toolkit dali-core) add_dependencies(dali-toolkit dali-adaptor) -#add link library +#add link library #TARGET_LINK_LIBRARIES(${FS_BUILD_BINARY_PREFIX}sqrt ${LIBRARIES}) diff --git a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt index 5e2e9ed..1494855 100755 --- a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt @@ -14,7 +14,6 @@ SET(TC_SOURCES utc-Dali-ItemView-internal.cpp utc-Dali-LogicalModel.cpp utc-Dali-PropertyHelper.cpp - utc-Dali-SizeNegotiationMapper.cpp utc-Dali-Text-CharacterSetConversion.cpp utc-Dali-Text-Circular.cpp utc-Dali-Text-Controller.cpp diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-SizeNegotiationMapper.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-SizeNegotiationMapper.cpp deleted file mode 100644 index 692cef7..0000000 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-SizeNegotiationMapper.cpp +++ /dev/null @@ -1,112 +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. - * - */ - -#include - -#include - -#include -#include -#include -#include -#include - -using namespace Dali; -using namespace Toolkit; - -int UtcDaliLayoutingSizeNegotiationMapper_01(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayoutingSizeNegotiationMapper_01 - Test mapping Dimension::ALL_DIMENSIONS"); - - auto control = Control::New(); - control.SetName( "fitToChildrenControl" ); - DevelControl::SetLayoutingRequired( control, true ); - control.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS ); - - Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control ); - Toolkit::Internal::Control::Impl& controlDataImpl = Toolkit::Internal::Control::Impl::Get( controlImpl ); - Toolkit::Internal::LayoutItemPtr layout = controlDataImpl.GetLayout(); - // Set defaults which should be overriden by mapper - control.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - control.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - // Set ALL_DIMENSIONS specifications using mapper - Toolkit::Internal::SizeNegotiationMapper::SetLayoutParametersUsingResizePolicy( control, layout, Dimension::ALL_DIMENSIONS ); - - // Test WIDTH and HEIGHT updated - DALI_TEST_EQUALS( control.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::WRAP_CONTENT ), TEST_LOCATION ); - DALI_TEST_EQUALS( control.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ), Property::Value( ChildLayoutData::WRAP_CONTENT ), TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayoutingSizeNegotiationMapper_02(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayoutingSizeNegotiationMapper_02 - Test mapping for Dimension::WIDTH only"); - - auto control = Control::New(); - control.SetName( "fitToChildrenControl" ); - DevelControl::SetLayoutingRequired( control, true ); - control.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS ); - - Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control ); - Toolkit::Internal::Control::Impl& controlDataImpl = Toolkit::Internal::Control::Impl::Get( controlImpl ); - Toolkit::Internal::LayoutItemPtr layout = controlDataImpl.GetLayout(); - - // Set defaults which should be overriden by mapper - control.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - control.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - // Set WIDTH specifications using mapper - Toolkit::Internal::SizeNegotiationMapper::SetLayoutParametersUsingResizePolicy( control, layout, Dimension::WIDTH ); - - // Test WIDTH only updated. - DALI_TEST_EQUALS( control.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::WRAP_CONTENT ), TEST_LOCATION ); - DALI_TEST_EQUALS( control.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayoutingSizeNegotiationMapper_03(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayoutingSizeNegotiationMapper_03 - Test mapping for Dimension::HEIGHT only"); - - auto control = Control::New(); - control.SetName( "fitToChildrenControl" ); - DevelControl::SetLayoutingRequired( control, true ); - control.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS ); - - Toolkit::Internal::Control& controlImpl = Toolkit::Internal::GetImplementation( control ); - Toolkit::Internal::Control::Impl& controlDataImpl = Toolkit::Internal::Control::Impl::Get( controlImpl ); - Toolkit::Internal::LayoutItemPtr layout = controlDataImpl.GetLayout(); - - // Set defaults which should be overriden by mapper - control.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - control.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - // Set HEIGHT specifications using mapper - Toolkit::Internal::SizeNegotiationMapper::SetLayoutParametersUsingResizePolicy( control, layout, Dimension::HEIGHT ); - - // Test HEIGHT only updated. - DALI_TEST_EQUALS( control.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION ); - DALI_TEST_EQUALS( control.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ), Property::Value( ChildLayoutData::WRAP_CONTENT), TEST_LOCATION ); - - END_TEST; -} \ No newline at end of file diff --git a/automated-tests/src/dali-toolkit/CMakeLists.txt b/automated-tests/src/dali-toolkit/CMakeLists.txt index 678a4ae..f0be18f 100755 --- a/automated-tests/src/dali-toolkit/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit/CMakeLists.txt @@ -7,11 +7,9 @@ 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-AnimatedVectorImageVisual.cpp - utc-Dali-BinLayout.cpp utc-Dali-BloomView.cpp utc-Dali-BubbleEmitter.cpp utc-Dali-Builder.cpp @@ -20,18 +18,11 @@ SET(TC_SOURCES utc-Dali-CubeTransitionEffect.cpp utc-Dali-EffectsView.cpp utc-Dali-FlexContainer.cpp - utc-Dali-FlexLayout.cpp utc-Dali-GaussianBlurView.cpp - utc-Dali-GridLayout.cpp utc-Dali-ImageView.cpp utc-Dali-ImageVisual.cpp utc-Dali-JsonParser.cpp utc-Dali-KeyInputFocusManager.cpp - utc-Dali-Layouting.cpp - utc-Dali-LayoutingAnimation.cpp - utc-Dali-LayoutingNesting.cpp - utc-Dali-LayoutingResizePolicy.cpp - utc-Dali-LayoutingSettingAndRemoval.cpp utc-Dali-PageTurnView.cpp utc-Dali-Scene3dView.cpp utc-Dali-Script.cpp @@ -82,8 +73,6 @@ SET(TC_SOURCES # Append list of test harness files (Won't get parsed for test cases) LIST(APPEND TC_SOURCES - custom-layout.cpp - custom-layout-impl.cpp dali-toolkit-test-utils/toolkit-adaptor.cpp dali-toolkit-test-utils/toolkit-accessibility-adaptor.cpp dali-toolkit-test-utils/toolkit-application.cpp @@ -106,7 +95,6 @@ LIST(APPEND TC_SOURCES dali-toolkit-test-utils/dali-test-suite-utils.cpp dali-toolkit-test-utils/dali-toolkit-test-suite-utils.cpp dali-toolkit-test-utils/dummy-control.cpp - dali-toolkit-test-utils/layout-utils.cpp dali-toolkit-test-utils/mesh-builder.cpp dali-toolkit-test-utils/test-actor-utils.cpp dali-toolkit-test-utils/test-animation-data.cpp diff --git a/automated-tests/src/dali-toolkit/custom-layout-impl.cpp b/automated-tests/src/dali-toolkit/custom-layout-impl.cpp deleted file mode 100644 index 37b6936..0000000 --- a/automated-tests/src/dali-toolkit/custom-layout-impl.cpp +++ /dev/null @@ -1,148 +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 "custom-layout-impl.h" - -// EXTERNAL INCLUDES -#include -#include - -namespace Test -{ - -namespace Internal -{ - -using Dali::Actor; -using Dali::Toolkit::MeasuredSize; - -CustomLayout::CustomLayout() -: mBehaviourFlags( 0 ) -{ -} - -CustomLayoutPtr CustomLayout::New() -{ - CustomLayoutPtr layout( new CustomLayout() ); - return layout; -} - -void CustomLayout::MeasureChildren( Dali::Toolkit::Internal::LayoutItemPtr childLayout, MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec, LayoutLength resultingWidth, LayoutLength resultingHeight ) -{ - // Initially use the measure spec of the child's parent - auto childWidthMeasureSpec = widthMeasureSpec; - auto childHeightMeasureSpec = heightMeasureSpec; - - if ( true == GetCustomBehaviourFlags( Test::CustomLayout::BEHAVIOUR_FLAG_UNCONSTRAINED_CHILD_WIDTH ) ) - { - // Use unspecified width measure spec, child can be any width it desires - childWidthMeasureSpec = MeasureSpec( widthMeasureSpec.GetSize(), MeasureSpec::Mode::UNSPECIFIED ); - } - - if ( true == GetCustomBehaviourFlags( Test::CustomLayout::BEHAVIOUR_FLAG_UNCONSTRAINED_CHILD_HEIGHT) ) - { - // Use unspecified height measure spec, child can be any height it desires - childHeightMeasureSpec = MeasureSpec( heightMeasureSpec.GetSize(), MeasureSpec::Mode::UNSPECIFIED ); - } - - MeasureChild( childLayout, childWidthMeasureSpec, childHeightMeasureSpec ); - resultingWidth += childLayout->GetMeasuredWidth(); - resultingHeight = std::max( childLayout->GetMeasuredHeight(), resultingHeight ); -} - -void CustomLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) -{ - auto accumulatedWidth = 0; - auto maxHeight = 0; - - // In this layout we will: - // Measuring the layout with the children in a horizontal configuration, one after another - // Set the required width to be the accumulated width of our children - // Set the required height to be the maximum height of any of our children - - for( unsigned int i=0; i -#include -#include - -// INTERNAL INCLUDES -#include "custom-layout.h" - -namespace Test -{ - -namespace Internal -{ - -using Dali::Toolkit::MeasureSpec; -using Dali::Toolkit::LayoutLength; - -class CustomLayout; -using CustomLayoutPtr = Dali::IntrusivePtr< CustomLayout >; - -/** - * @brief The implementation of our custom layout. - * - * Here we will override the methods that we require to mimic a very simple horizontal layout. - */ -class CustomLayout final : public Dali::Toolkit::Internal::LayoutGroup -{ -public: - - /** - * @brief Create a new CustomLayout object. - * @return An intrusive pointer to the created CustomLayout object - */ - static CustomLayoutPtr New(); - - // Movable but not copyable - CustomLayout( const CustomLayout& other ) = delete; - CustomLayout& operator=( const CustomLayout& ) = delete; - CustomLayout( CustomLayout&& other ) = default; - CustomLayout& operator=( CustomLayout&& other ) = default; - - /** - * @copydoc CustomLayout::SetCustomBehaviourFlag - */ - void SetCustomBehaviourFlag( int flag ); - - /** - * @copydoc CustomLayout::GetCustomBehaviourFlags - */ - bool GetCustomBehaviourFlags( int flagToCheck ); - - /** - * @copydoc CustomLayout::ClearPrivateFlag - */ - void ClearPrivateFlag( int flag ); - -private: - - /** - * @brief Default Constructor - */ - CustomLayout(); - - /** - * Virtual Destructor - */ - virtual ~CustomLayout() = default; - - /** - * @copydoc LayoutItem::OnMeasure - * - * Overriding this method so that we can calculate the size we require using our children's sizes - */ - virtual void OnMeasure( MeasureSpec widthMeasureSpec, Dali::Toolkit::MeasureSpec heightMeasureSpec ) override; - - /** - * @copydoc LayoutItem::OnLayout - * - * Overriding this method so that we can layout our children as required. - */ - virtual void OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ) override; - - /** - * Measure children with parent's measure spec unless BehaviourFlag set to use an unconstrained width or height. - * @param[in] childLayout child to measure - * @param[in] widthMeasureSpec default layout width measure spec - * @param[in] heightMeasureSpec default layout height measure spec - * @param[out] resultingWidth resulting width of layout after children are measured - * @param[out] resultingHeight resulting height of layout after children are measured - */ - void MeasureChildren( Dali::Toolkit::Internal::LayoutItemPtr childLayout, MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec, LayoutLength resultingWidth, LayoutLength resultingHeight ); - - using Dali::Toolkit::Internal::LayoutGroup::MeasureChildren; ///< To tell the compiler that we really do want to overload MeasureChildren in this class & were not trying to override it - - private: - - int mBehaviourFlags; // flags to alter behaviour of this custom layout - -}; - -} // namespace Internal - -inline Internal::CustomLayout& GetImplementation( Test::CustomLayout& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "CustomLayout handle is empty" ); - Dali::BaseObject& object = handle.GetBaseObject(); - return static_cast( object ); -} - -inline const Internal::CustomLayout& GetImplementation( const Test::CustomLayout& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "CustomLayout handle is empty" ); - const Dali::BaseObject& object = handle.GetBaseObject(); - return static_cast( object ); -} - -} // namespace Test - -#endif // TEST_INTERNAL_CUSTOM_LAYOUT_H diff --git a/automated-tests/src/dali-toolkit/custom-layout.cpp b/automated-tests/src/dali-toolkit/custom-layout.cpp deleted file mode 100644 index 8060840..0000000 --- a/automated-tests/src/dali-toolkit/custom-layout.cpp +++ /dev/null @@ -1,62 +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 "custom-layout.h" - -// INTERNAL HEADERS -#include "custom-layout-impl.h" - -namespace Test -{ - -CustomLayout CustomLayout::New() -{ - Internal::CustomLayoutPtr internal = Internal::CustomLayout::New(); - return CustomLayout( internal.Get() ); -} - -CustomLayout CustomLayout::DownCast( BaseHandle handle ) -{ - return CustomLayout( dynamic_cast< Test::Internal::CustomLayout* >( handle.GetObjectPtr() ) ); -} - -CustomLayout::CustomLayout( Internal::CustomLayout* object ) -: Dali::Toolkit::LayoutGroup( object ) -{ -} - -void CustomLayout::RequestLayout() -{ - GetImplementation( *this ).RequestLayout(); -} - -void CustomLayout::SetCustomBehaviourFlag( int flag ) -{ - GetImplementation(*this).SetCustomBehaviourFlag( flag ); -} - -bool CustomLayout::GetCustomBehaviourFlags( int flagToCheck ) -{ - return GetImplementation(*this).GetCustomBehaviourFlags( flagToCheck ); -} - -void CustomLayout::ClearPrivateFlag( int flag ) -{ - return GetImplementation(*this).ClearPrivateFlag( flag ); -} - -} // namespace Test diff --git a/automated-tests/src/dali-toolkit/custom-layout.h b/automated-tests/src/dali-toolkit/custom-layout.h deleted file mode 100644 index df07d4f..0000000 --- a/automated-tests/src/dali-toolkit/custom-layout.h +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef TEST_CUSTOM_LAYOUT_H -#define TEST_CUSTOM_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. - */ - -// EXTERNAL INCLUDES -#include -#include - -namespace Test -{ - -namespace Internal -{ -class CustomLayout; -} - -/** - * @brief This is the handle class to a very simple Custom Layout. - * - * This class lays out its children horizontally in a very simple manner. - */ -class CustomLayout : public Dali::Toolkit::LayoutGroup -{ -public: - - // Behaviour flags - static const int BEHAVIOUR_FLAG_UNCONSTRAINED_CHILD_WIDTH = 0x00000001; // Child width measured without constraint - static const int BEHAVIOUR_FLAG_UNCONSTRAINED_CHILD_HEIGHT = 0x00000002; // Child height measured without constraint - - /** - * @brief Creates an uninitialized CustomLayout handle. - * - * Initialize it using CustomLayout::New(). - * Calling member functions with an uninitialized handle is not allowed. - */ - CustomLayout() = default; - - /** - * @brief Creates a CustomLayout object. - */ - static CustomLayout New(); - - - /** - * @brief Default destructor. - * - * This is non-virtual, since derived Handle types must not contain data or virtual methods - */ - ~CustomLayout() = default; - - /** - * @brief Copy constructor - */ - CustomLayout( const CustomLayout& ) = default; - - /** - * @brief Assigment operator - */ - CustomLayout& operator=( const CustomLayout& ) = default; - - /** - * @brief Move constructor - */ - CustomLayout( CustomLayout&& ) = default; - - /** - * @brief Movable assignment operator - */ - CustomLayout& operator=( CustomLayout&& ) = default; - - /** - * @brief Downcasts a handle to a CustomLayout handle. - * - * If handle points to a CustomLayout, the downcast produces a valid handle. - * If not, the returned handle is left uninitialized. - - * @param[in] handle to an object - * @return Handle to a CustomLayout or an uninitialized handle - */ - static CustomLayout DownCast( BaseHandle handle ); - - /** - * Request for a relayout of this layout - */ - void RequestLayout(); - - /** - * Enables setting of flags corresponding to particular behaviour of this layout - * @param[in] flag the flag to set - */ - void SetCustomBehaviourFlag( int flag ); - - /** - * Returns true or false depending on whether flag is set - * @return bool returns true if flag set - */ - bool GetCustomBehaviourFlags( int flagToCheck ); - - /** - * Clears the flag if already set. - * @param[in] flag the flag to clear - */ - void ClearPrivateFlag( int flag ); - -public: // Not intended for application developers - - /// @cond internal - /** - * @brief This constructor is used by CustomLayout::New() methods. - * - * @param[in] actor A pointer to a newly allocated Dali resource - */ - explicit CustomLayout( Internal::CustomLayout* body ); - /// @endcond -}; - -} // namespace Test - -#endif // TEST_CUSTOM_LAYOUT_H diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/layout-utils.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/layout-utils.cpp deleted file mode 100755 index 81fd6bf..0000000 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/layout-utils.cpp +++ /dev/null @@ -1,84 +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. - * - */ - -// FILE HEADER -#include "layout-utils.h" - -// EXTERNAL INCLUDES -#include -#include -#include -#include -#include - -// INTERNAL INCLUDES - -namespace Dali -{ - -namespace Toolkit -{ - -std::string CreateImageURL( Vector4 color, ImageDimensions size ) -{ - auto pixelBuffer = Devel::PixelBuffer::New( size.GetWidth(), size.GetHeight(), Pixel::RGB888 ); - unsigned char* pixels = pixelBuffer.GetBuffer(); - pixels[0] = static_cast( color.r ); - pixels[1] = static_cast( color.g ); - pixels[2] = static_cast( color.b ); - auto texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGB888, size.GetWidth(), size.GetHeight() ); - auto pixelData = Devel::PixelBuffer::Convert( pixelBuffer ); - texture.Upload( pixelData ); - return TextureManager::AddTexture( texture ); -} - -Control CreateLeafControl( int width, int height ) -{ - auto control = Control::New(); - control.SetName( "Leaf" ); - std::string url = CreateImageURL( Vector4( 255, 0, 0, 255 ), ImageDimensions( 1, 1 ) ); - - Property::Map map; - map[ Visual::Property::TYPE ] = Visual::IMAGE; - map[ ImageVisual::Property::URL ] = url; - map[ ImageVisual::Property::DESIRED_WIDTH ] = (float) width; - map[ ImageVisual::Property::DESIRED_HEIGHT ] = (float) height; - control.SetProperty( Control::Property::BACKGROUND, map ); - return control; -} - -TextLabel CreateTextLabel( const char* text ) -{ - TextLabel textLabel = TextLabel::New(text); - textLabel.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); - textLabel.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); - textLabel.SetName( "TextLabel" ); - textLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - return textLabel; -} - -ImageView CreateImageView( std::string& url, ImageDimensions size ) -{ - ImageView imageView = ImageView::New( url, size ); - imageView.SetName( "ImageView" ); - imageView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - return imageView; -} - -} // namespace Toolkit - -} // namespace Dali diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/layout-utils.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/layout-utils.h deleted file mode 100644 index 6072140..0000000 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/layout-utils.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef __DALI_TOOLKIT_LAYOUT_UTILS_H__ -#define __DALI_TOOLKIT_LAYOUT_UTILS_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 - -namespace Dali -{ - -namespace Toolkit -{ - -/** - * @brief Creates an empty image buffer filled with the color for layout tests - * - * @param[in] color The color of the image buffer. - * @param[in] size The size of the image buffer. - * @param[out] string The url. - */ -std::string CreateImageURL( Vector4 color, ImageDimensions size ); - -/** - * @brief Creates an empty leaf control filled with red color for layout tests - * - * @param[in] width The width of the control. - * @param[in] height The height of the control. - * @param[out] Control The control. - */ -Control CreateLeafControl( int width, int height ); - -/** - * @brief Creates a text label for layout tests - * - * @param[in] text The text of the label. - * @param[out] TextLabel The text label. - */ -TextLabel CreateTextLabel( const char* text ); - -/** - * @brief Creates an image view for layout tests - * - * @param[in] url The image url. - * @param[in] size The size of the image view. - * @param[out] ImageView The image view. - */ -ImageView CreateImageView( std::string& url, ImageDimensions size ); - -} // namespace Toolkit - -} // namespace Dali - -#endif // __DALI_TOOLKIT_LAYOUT_UTILS_H__ diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AbsoluteLayout.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AbsoluteLayout.cpp deleted file mode 100644 index 98ea974..0000000 --- a/automated-tests/src/dali-toolkit/utc-Dali-AbsoluteLayout.cpp +++ /dev/null @@ -1,161 +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. - * - */ - -#include -#include -#include - -#include -#include -#include - -#include - -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(); - layout.SetAnimateLayout( true ); - 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( 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( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( 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( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_AbsoluteLayout_SetPosition(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_AbsoluteLayout_GetWorldPosition - Testing WorldPosition"); - - Stage stage = Stage::GetCurrent(); - - Dali::Toolkit::Control layoutControl = Dali::Toolkit::Control::New(); - layoutControl.SetName("AsoluteLayout"); - layoutControl.SetAnchorPoint( Dali::AnchorPoint::CENTER ); - layoutControl.SetParentOrigin( Dali::ParentOrigin::CENTER ); - - Dali::Toolkit::AbsoluteLayout absoluteLayout = Dali::Toolkit::AbsoluteLayout::New(); - Dali::Toolkit::DevelControl::SetLayout( layoutControl, absoluteLayout ); - - stage.GetRootLayer().Add( layoutControl ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(0); - - Dali::Toolkit::Control control = Dali::Toolkit::Control::New(); - control.SetSize( 100.0f, 100.0f ); - control.SetParentOrigin( ParentOrigin::CENTER ); - control.SetAnchorPoint( AnchorPoint::CENTER ); - Vector3 parentPosition( 1.0f, 2.0f, 3.0f ); - control.SetPosition( parentPosition ); - - layoutControl.Add( control ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(0); - - // The value of z should not be zero - DALI_TEST_EQUALS( control.GetCurrentPosition(), parentPosition, TEST_LOCATION ); - - END_TEST; -} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-BinLayout.cpp b/automated-tests/src/dali-toolkit/utc-Dali-BinLayout.cpp deleted file mode 100644 index 3122c71..0000000 --- a/automated-tests/src/dali-toolkit/utc-Dali-BinLayout.cpp +++ /dev/null @@ -1,495 +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. - * - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include <../custom-layout.h> - -#include - -using namespace Dali; -using namespace Toolkit; - -namespace -{ -// Turns the given control into a Root layout control and adds it to the stage. -void SetupRootLayoutControl( Control& rootControl ) -{ - rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "RootAbsoluteLayout" ); - Stage stage = Stage::GetCurrent(); - stage.Add( rootControl ); -} - -void CreateDefaultBinContainer( Control& binContainer ) -{ - binContainer = Control::New(); - binContainer.SetName( "binContainer" ); - DevelControl::SetLayout( binContainer, BinLayout::New() ); - binContainer.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - binContainer.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); -} - -} // namespace - -void utc_dali_toolkit_bin_layouting_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_toolkit_bin_layouting_cleanup(void) -{ - test_return_value = TET_PASS; -} - -int UtcDaliLayouting_BinLayoutDownCast(void) -{ - TestApplication application; - tet_infoline(" UtcDaliLayouting_BinLayoutDownCast - Testing Downcast"); - - BinLayout binLayout = BinLayout::New(); - - LayoutGroup layoutGroup( binLayout ); - - BinLayout binLayoutCandidate = BinLayout::DownCast( layoutGroup ); - DALI_TEST_CHECK( binLayoutCandidate ); - - END_TEST; -} - -int UtcDaliLayouting_BinLayoutAssignment(void) -{ - TestApplication application; - tet_infoline(" UtcDaliLayouting_BinLayoutAssignment - Testing operator="); - - BinLayout binLayout = BinLayout::New(); - BinLayout binLayout2; - - binLayout2 = binLayout; - - DALI_TEST_EQUALS( binLayout2, binLayout, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_BinLayoutCopyConstructor(void) -{ - TestApplication application; - tet_infoline(" UtcDaliLayouting_BinLayoutCopyConstructor - Testing copy constructor"); - - BinLayout binLayout1 = BinLayout::New(); - BinLayout binLayout2( binLayout1 ); - - DALI_TEST_EQUALS( binLayout1, binLayout2, TEST_LOCATION ); - END_TEST; -} - -int UtcDaliLayouting_BinLayout01(void) -{ - const auto NUMBER_OF_ITEMS = 4; - - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_BinLayout01 BinLayout WRAP_CONTENT"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "AbsoluteLayout" ); - stage.Add( rootControl ); - - auto binContainer = Control::New(); - auto binLayout = BinLayout::New(); - binContainer.SetName( "BinLayout"); - DevelControl::SetLayout( binContainer, binLayout ); - binContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - binContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - std::vector< Control > controls; - for( auto i=0; i < NUMBER_OF_ITEMS; i++ ) - { - controls.push_back( CreateLeafControl( 100, 100 ) ); - } - - for( auto&& iter : controls ) - { - binContainer.Add( iter ); - } - - rootControl.Add( binContainer ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // Items will be laid out at the same position - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Item sizes will not be changed - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // BinLayout size to be that of greatest child dimensions - DALI_TEST_EQUALS( binContainer.GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_BinLayout02(void) -{ - const auto NUMBER_OF_ITEMS = 4; - - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_BinLayout02 BinLayout MATCH_PARENT"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "AbsoluteLayout" ); - stage.Add( rootControl ); - - auto binContainer = Control::New(); - auto binLayout = BinLayout::New(); - binContainer.SetName( "BinLayout"); - DevelControl::SetLayout( binContainer, binLayout ); - binContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - binContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - std::vector< Control > controls; - for( auto i=0; i < NUMBER_OF_ITEMS; i++ ) - { - controls.push_back( CreateLeafControl( 100, 100 ) ); - } - - for( auto&& iter : controls ) - { - binContainer.Add( iter ); - } - - rootControl.Add( binContainer ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // Items will be laid out at the same position - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Item sizes will not be changed - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // BinLayout size to be that of greatest child dimensions - DALI_TEST_EQUALS( binContainer.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_BinLayout03(void) -{ - const auto NUMBER_OF_ITEMS = 4; - - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_BinLayout03 Explicit child Positioning when Bin layout MATCH_PARENT"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "AbsoluteLayout" ); - stage.Add( rootControl ); - - auto binContainer = Control::New(); - auto binLayout = BinLayout::New(); - binContainer.SetName( "BinLayout"); - DevelControl::SetLayout( binContainer, binLayout ); - binContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - binContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - std::vector< Control > controls; - for( auto i=0; i < NUMBER_OF_ITEMS; i++ ) - { - controls.push_back( CreateLeafControl( 100, 100 ) ); - } - - for( auto&& iter : controls ) - { - binContainer.Add( iter ); - } - - tet_infoline("Position child explicitly from top left"); - controls[0].SetProperty(Actor::Property::POSITION_X, 50.0f ); - - tet_infoline("Position child explicitly from top left"); - controls[2].SetProperty(Actor::Property::POSITION_Y, 50.0f ); - - rootControl.Add( binContainer ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // Items will be laid out at the same position - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 50.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Item sizes will not be changed - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // BinLayout size to be that of parent - DALI_TEST_EQUALS( binContainer.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayoutingBinLayoutResizePolicy_01(void) -{ - /* - Root - | - Control (LinearLayout Horizontal) - | - Control (BinLayout) - | - Control (ResizePolicy::FILL_TO_PARENT) - | - LeafControl - */ - - ToolkitTestApplication application; - tet_infoline("UtcDaliLayoutingBinLayoutResizePolicy_01 - Test ResizePolicy mapping with FILL_TO_PARENT on BinLayout child"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - SetupRootLayoutControl( rootControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "hBox" ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - auto binContainer = Control::New(); - CreateDefaultBinContainer( binContainer ); - hbox.Add( binContainer ); - - auto control = Control::New(); - control.SetName( "fillToParentControl" ); - DevelControl::SetLayoutingRequired( control, true ); - control.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - binContainer.Add( control ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - - for( auto&& iter : controls ) - { - control.Add( iter ); - } - - rootControl.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("Testing child of BinLayout is size of parent"); - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline("Testing BinLayout's child control has not altered it's children's sizes "); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline("Testing BinLayout is size of parent"); - DALI_TEST_EQUALS( binContainer.GetProperty( Actor::Property::SIZE ), hbox.GetProperty( Actor::Property::SIZE ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayoutingBinLayoutResizePolicy_02(void) -{ - /* - Root - | - Control (LinearLayout Horizontal) - | - Control (BinLayout) - | - Control (ResizePolicy::SIZE_RELATIVE_TO_PARENT) - | - LeafControl - */ - - ToolkitTestApplication application; - tet_infoline("UtcDaliLayoutingBinLayoutResizePolicy_02 - Set ResizePolicy SIZE_RELATIVE_TO_PARENT on BinLayout child"); - - const auto NUMBER_OF_ITEMS = 4; - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - SetupRootLayoutControl( rootControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "hBox" ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - auto binContainer = Control::New(); - CreateDefaultBinContainer( binContainer ); - hbox.Add( binContainer ); - - auto control = Control::New(); - control.SetName( "fitToChildrenControl" ); - DevelControl::SetLayoutingRequired( control, true ); - control.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); - control.SetSizeModeFactor( Vector3( 0.50f, 1.0f, 1.0f ) ); - binContainer.Add( control ); - - std::vector< Control > controls; - for( auto i=0; i < NUMBER_OF_ITEMS; i++ ) - { - controls.push_back( CreateLeafControl( 40, 40 ) ); - } - - for( auto&& iter : controls ) - { - control.Add( iter ); - } - - rootControl.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("Testing child of BinLayout is the defined relative size of parent"); - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::SIZE ), Vector3( 240.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline("Testing BinLayout's child control has not altered it's children's sizes "); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline("Testing BinLayout is size of parent"); - DALI_TEST_EQUALS( binContainer.GetProperty( Actor::Property::SIZE ), hbox.GetProperty( Actor::Property::SIZE ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliBinLayoutResizePolicy_03(void) -{ - /* - Root - | - Control (LinearLayout Horizontal) - | - Control (LayoutingRequired) - | - Control (ResizePolicy::SIZE_RELATIVE_TO_PARENT) - | - LeafControl - */ - - ToolkitTestApplication application; - tet_infoline("UtcDaliBinLayoutResizePolicy_03 - Set ResizePolicy SIZE_FIXED_OFFSET_FROM_PARENT on BinLayout child"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - SetupRootLayoutControl( rootControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "hBox" ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - auto binContainer = Control::New(); - CreateDefaultBinContainer( binContainer ); - hbox.Add( binContainer ); - - hbox.Add( binContainer ); - - auto control = Control::New(); - control.SetName( "fitToChildrenControl" ); - DevelControl::SetLayoutingRequired( control, true ); - control.SetResizePolicy( ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT, Dimension::ALL_DIMENSIONS ); - control.SetSizeModeFactor( Vector3( -100.0f, 10.0f, 0.0f ) ); - binContainer.Add( control ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - - for( auto&& iter : controls ) - { - control.Add( iter ); - } - - rootControl.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), true , 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::SIZE ), Vector3( 380.0f, 810.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} \ No newline at end of file diff --git a/automated-tests/src/dali-toolkit/utc-Dali-FlexLayout.cpp b/automated-tests/src/dali-toolkit/utc-Dali-FlexLayout.cpp deleted file mode 100755 index 46a7658..0000000 --- a/automated-tests/src/dali-toolkit/utc-Dali-FlexLayout.cpp +++ /dev/null @@ -1,853 +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. - * - */ - -#include -#include -#include - -#include -#include -#include - -#include - -using namespace Dali; -using namespace Toolkit; - -void utc_dali_toolkit_flexlayout_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_toolkit_flexlayout_cleanup(void) -{ - test_return_value = TET_PASS; -} - -int UtcDaliLayouting_FlexLayout01(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_FlexLayout01"); - - Stage stage = Stage::GetCurrent(); - auto flexBox = Control::New(); - auto flexLayout = FlexLayout::New(); - flexLayout.SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection::ROW ); - flexLayout.SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::CENTER ); - DevelControl::SetLayout( flexBox, flexLayout ); - flexBox.SetName( "Flexbox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 60 ) ); - controls.push_back( CreateLeafControl( 80, 80 ) ); - controls.push_back( CreateLeafControl( 100, 100 ) ); - - const Extents CONTROL_MARGIN = Extents( 0, 10, 0, 0 ); - for( auto&& iter : controls ) - { - iter.SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN ); - flexBox.Add( iter ); - } - flexBox.SetParentOrigin( ParentOrigin::CENTER ); - flexBox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( flexBox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // To see goto https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjIsImFsaWduQ29udGVudCI6MSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjQwIiwiaGVpZ2h0IjoiNDAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsInBhZGRpbmciOnsidG9wIjoiIiwicmlnaHQiOiIiLCJib3R0b20iOiIiLCJsZWZ0IjoiIn0sIm1hcmdpbiI6eyJyaWdodCI6IjEwIn0sInBvc2l0aW9uIjp7InRvcCI6bnVsbCwicmlnaHQiOm51bGwsImJvdHRvbSI6bnVsbCwibGVmdCI6bnVsbH19LHsid2lkdGgiOiI2MCIsImhlaWdodCI6IjYwIiwibWluV2lkdGgiOm51bGwsIm1pbkhlaWdodCI6bnVsbCwibWF4V2lkdGgiOm51bGwsIm1heEhlaWdodCI6bnVsbCwiYWxpZ25JdGVtcyI6MCwiYWxpZ25Db250ZW50IjowLCJwYWRkaW5nIjp7InRvcCI6IiIsInJpZ2h0IjoiIiwiYm90dG9tIjoiIiwibGVmdCI6IiJ9LCJtYXJnaW4iOnsicmlnaHQiOiIxMCJ9LCJwb3NpdGlvbiI6eyJ0b3AiOm51bGwsInJpZ2h0IjpudWxsLCJib3R0b20iOm51bGwsImxlZnQiOm51bGx9fSx7IndpZHRoIjoiODAiLCJoZWlnaHQiOiI4MCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjAsImFsaWduQ29udGVudCI6MCwicGFkZGluZyI6eyJ0b3AiOiIiLCJyaWdodCI6IiIsImJvdHRvbSI6IiIsImxlZnQiOiIifSwibWFyZ2luIjp7InJpZ2h0IjoiMTAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6MTAwLCJoZWlnaHQiOjEwMCwibWluV2lkdGgiOm51bGwsIm1pbkhlaWdodCI6bnVsbCwibWF4V2lkdGgiOm51bGwsIm1heEhlaWdodCI6bnVsbCwiYWxpZ25JdGVtcyI6MCwiYWxpZ25Db250ZW50IjowLCJwYWRkaW5nIjp7InRvcCI6IiIsInJpZ2h0IjoiIiwiYm90dG9tIjoiIiwibGVmdCI6IiJ9LCJtYXJnaW4iOnsicmlnaHQiOiIxMCJ9LCJwb3NpdGlvbiI6eyJ0b3AiOm51bGwsInJpZ2h0IjpudWxsLCJib3R0b20iOm51bGwsImxlZnQiOm51bGx9fV19 - DALI_TEST_EQUALS( flexBox.GetProperty(Actor::Property::POSITION), Vector3( 0, 0, 0 ),TEST_LOCATION); - DALI_TEST_EQUALS( flexBox.GetProperty(Actor::Property::SIZE), Vector3( 480, 800, 0 ),TEST_LOCATION); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 50.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 120.0f, 360.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 210.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - const Extents CONTROL_PADDING = Extents( 5, 10, 15, 15 ); - for( auto&& iter : controls ) - { - iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING ); - flexBox.Add( iter ); - } - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // To see go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjIsImFsaWduQ29udGVudCI6MSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjQwIiwiaGVpZ2h0IjoiNDAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsInBhZGRpbmciOnsidG9wIjoiMTUiLCJyaWdodCI6IjEwIiwiYm90dG9tIjoiMTUiLCJsZWZ0IjoiNSJ9LCJtYXJnaW4iOnsicmlnaHQiOiIxMCJ9LCJwb3NpdGlvbiI6eyJ0b3AiOm51bGwsInJpZ2h0IjpudWxsLCJib3R0b20iOm51bGwsImxlZnQiOm51bGx9fSx7IndpZHRoIjoiNjAiLCJoZWlnaHQiOiI2MCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjAsImFsaWduQ29udGVudCI6MCwicGFkZGluZyI6eyJ0b3AiOiIxNSIsInJpZ2h0IjoiMTAiLCJib3R0b20iOiIxNSIsImxlZnQiOiI1In0sIm1hcmdpbiI6eyJyaWdodCI6IjEwIn0sInBvc2l0aW9uIjp7InRvcCI6bnVsbCwicmlnaHQiOm51bGwsImJvdHRvbSI6bnVsbCwibGVmdCI6bnVsbH19LHsid2lkdGgiOiI4MCIsImhlaWdodCI6IjgwIiwibWluV2lkdGgiOm51bGwsIm1pbkhlaWdodCI6bnVsbCwibWF4V2lkdGgiOm51bGwsIm1heEhlaWdodCI6bnVsbCwiYWxpZ25JdGVtcyI6MCwiYWxpZ25Db250ZW50IjowLCJwYWRkaW5nIjp7InRvcCI6IjE1IiwicmlnaHQiOiIxMCIsImJvdHRvbSI6IjE1IiwibGVmdCI6IjUifSwibWFyZ2luIjp7InJpZ2h0IjoiMTAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6MTAwLCJoZWlnaHQiOjEwMCwibWluV2lkdGgiOm51bGwsIm1pbkhlaWdodCI6bnVsbCwibWF4V2lkdGgiOm51bGwsIm1heEhlaWdodCI6bnVsbCwiYWxpZ25JdGVtcyI6MCwiYWxpZ25Db250ZW50IjowLCJwYWRkaW5nIjp7InRvcCI6IjE1IiwicmlnaHQiOiIxMCIsImJvdHRvbSI6IjE1IiwibGVmdCI6IjUifSwibWFyZ2luIjp7InJpZ2h0IjoiMTAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX1dfQ== - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 65.0f, 355.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 150.0f, 345.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 255.0f, 335.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 75.0f, 90.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 95.0f, 110.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 115.0f, 130.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - const Extents FLEXBOX_PADDING = Extents( 25, 25, 25, 25 ); - flexBox.SetProperty(Toolkit::Control::Property::PADDING, FLEXBOX_PADDING ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // To see go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjIsImFsaWduQ29udGVudCI6MSwicGFkZGluZyI6eyJ0b3AiOiIyNSIsInJpZ2h0IjoiMjUiLCJib3R0b20iOiIyNSIsImxlZnQiOiIyNSJ9LCJwb3NpdGlvbiI6eyJ0b3AiOm51bGwsInJpZ2h0IjpudWxsLCJib3R0b20iOm51bGwsImxlZnQiOm51bGx9LCJmbGV4V3JhcCI6MSwiY2hpbGRyZW4iOlt7IndpZHRoIjoiNDAiLCJoZWlnaHQiOiI0MCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjAsImFsaWduQ29udGVudCI6MCwicGFkZGluZyI6eyJ0b3AiOiIxNSIsInJpZ2h0IjoiMTAiLCJib3R0b20iOiIxNSIsImxlZnQiOiI1In0sIm1hcmdpbiI6eyJyaWdodCI6IjEwIn0sInBvc2l0aW9uIjp7InRvcCI6bnVsbCwicmlnaHQiOm51bGwsImJvdHRvbSI6bnVsbCwibGVmdCI6bnVsbH19LHsid2lkdGgiOiI2MCIsImhlaWdodCI6IjYwIiwibWluV2lkdGgiOm51bGwsIm1pbkhlaWdodCI6bnVsbCwibWF4V2lkdGgiOm51bGwsIm1heEhlaWdodCI6bnVsbCwiYWxpZ25JdGVtcyI6MCwiYWxpZ25Db250ZW50IjowLCJwYWRkaW5nIjp7InRvcCI6IjE1IiwicmlnaHQiOiIxMCIsImJvdHRvbSI6IjE1IiwibGVmdCI6IjUifSwibWFyZ2luIjp7InJpZ2h0IjoiMTAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjgwIiwiaGVpZ2h0IjoiODAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsInBhZGRpbmciOnsidG9wIjoiMTUiLCJyaWdodCI6IjEwIiwiYm90dG9tIjoiMTUiLCJsZWZ0IjoiNSJ9LCJtYXJnaW4iOnsicmlnaHQiOiIxMCJ9LCJwb3NpdGlvbiI6eyJ0b3AiOm51bGwsInJpZ2h0IjpudWxsLCJib3R0b20iOm51bGwsImxlZnQiOm51bGx9fSx7IndpZHRoIjoxMDAsImhlaWdodCI6MTAwLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsInBhZGRpbmciOnsidG9wIjoiMTUiLCJyaWdodCI6IjEwIiwiYm90dG9tIjoiMTUiLCJsZWZ0IjoiNSJ9LCJtYXJnaW4iOnsicmlnaHQiOiIxMCJ9LCJwb3NpdGlvbiI6eyJ0b3AiOm51bGwsInJpZ2h0IjpudWxsLCJib3R0b20iOm51bGwsImxlZnQiOm51bGx9fV19 - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 25.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 90.0f, 355.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 175.0f, 345.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 280.0f, 335.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 75.0f, 90.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 95.0f, 110.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 115.0f, 130.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_FlexLayout02(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_FlexLayout02"); - - Stage stage = Stage::GetCurrent(); - auto flexBox = Control::New(); - auto flexLayout = FlexLayout::New(); - flexLayout.SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection::ROW ); - flexLayout.SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::CENTER ); - - DevelControl::SetLayout( flexBox, flexLayout ); - flexBox.SetName( "Flexbox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 60 ) ); - controls.push_back( CreateLeafControl( 80, 80 ) ); - controls.push_back( CreateLeafControl( 100, 100 ) ); - - const Extents CONTROL_MARGIN = Extents( 0, 10, 0, 0 ); - for( auto&& iter : controls ) - { - iter.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN ); - flexBox.Add( iter ); - } - - controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - flexBox.SetParentOrigin( ParentOrigin::CENTER ); - flexBox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( flexBox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // flexbox centers elements vertically, it fills test harness stage, which is 480x800. - DALI_TEST_EQUALS( flexBox.GetProperty(Actor::Property::POSITION), Vector3( 0, 0, 0 ),TEST_LOCATION); - DALI_TEST_EQUALS( flexBox.GetProperty(Actor::Property::SIZE), Vector3( 480, 800, 0 ),TEST_LOCATION); - - DALI_TEST_EQUALS( controls[1].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::WRAP_CONTENT ), TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION ); - - // left aligned elements with right margin 10 - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 50.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 120.0f, 360.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 210.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_FlexLayout03(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_FlexLayout03 Test nested flex boxes"); - - Stage stage = Stage::GetCurrent(); - - auto flexbox1 = Control::New(); - auto flexLayout1 = FlexLayout::New(); - DevelControl::SetLayout( flexbox1, flexLayout1 ); - flexbox1.SetName( "Flexbox1"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 20, 20 ) ); - controls.push_back( CreateLeafControl( 30, 30 ) ); - flexbox1.Add( controls[0] ); - flexbox1.Add( controls[1] ); - flexbox1.SetParentOrigin( ParentOrigin::CENTER ); - flexbox1.SetAnchorPoint( AnchorPoint::CENTER ); - - flexLayout1.SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection::ROW ); - flexLayout1.SetFlexWrap(Dali::Toolkit::FlexLayout::WrapType::NO_WRAP); - flexLayout1.SetFlexAlignment( Dali::Toolkit::FlexLayout::Alignment::FLEX_START ); - flexLayout1.SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::FLEX_START ); - flexLayout1.SetFlexJustification( Dali::Toolkit::FlexLayout::Justification::FLEX_START ); - - auto flexbox2 = Control::New(); - auto flexLayout2 = FlexLayout::New(); - DevelControl::SetLayout( flexbox2, flexLayout2 ); - flexbox2.SetName( "Flexbox2"); - - controls.push_back( CreateLeafControl( 25, 25 ) ); - controls.push_back( CreateLeafControl( 35, 35 ) ); - flexbox2.Add( controls[2] ); - flexbox2.Add( controls[3] ); - flexbox2.SetParentOrigin( ParentOrigin::CENTER ); - flexbox2.SetAnchorPoint( AnchorPoint::CENTER ); - - flexLayout2.SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection::COLUMN ); - flexLayout2.SetFlexWrap(Dali::Toolkit::FlexLayout::WrapType::NO_WRAP); - flexLayout2.SetFlexAlignment( Dali::Toolkit::FlexLayout::Alignment::FLEX_START ); - flexLayout2.SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::FLEX_START ); - flexLayout2.SetFlexJustification( Dali::Toolkit::FlexLayout::Justification::FLEX_START ); - - auto flexbox3 = Control::New(); - auto flexLayout3 = FlexLayout::New(); - DevelControl::SetLayout( flexbox3, flexLayout3 ); - flexbox3.SetParentOrigin( ParentOrigin::CENTER ); - flexbox3.SetName( "Flexbox3"); - flexbox3.Add( flexbox1 ); - flexbox3.Add( flexbox2 ); - stage.Add( flexbox3 ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 20.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 30.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 55.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 20.0f, 20.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 30.0f, 30.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 25.0f, 25.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 35.0f, 35.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Test flexbox1,2 are sized to wrap their content - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::SIZE ), Vector3( 50.0f, 30.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox2.GetProperty( Actor::Property::SIZE ), Vector3( 35.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox2.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 30.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Test flexbox3 matches parent (root layer) - DALI_TEST_EQUALS( flexbox3.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox3.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_FlexLayout04(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_FlexLayout04"); - - Stage stage = Stage::GetCurrent(); - auto flexBox = Control::New(); - auto flexLayout = FlexLayout::New(); - flexLayout.SetFlexAlignment( Dali::Toolkit::FlexLayout::Alignment::FLEX_START ); - flexLayout.SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::FLEX_START ); - flexLayout.SetFlexWrap(Dali::Toolkit::FlexLayout::WrapType::NO_WRAP); - flexLayout.SetFlexJustification( Dali::Toolkit::FlexLayout::Justification::FLEX_START ); - flexLayout.SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection::COLUMN ); - DevelControl::SetLayout( flexBox, flexLayout ); - flexBox.SetName( "Flexbox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 60 ) ); - for( auto&& iter : controls ) - { - flexBox.Add( iter ); - } - flexBox.SetParentOrigin( ParentOrigin::CENTER ); - flexBox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( flexBox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsImFsaWduQ29udGVudCI6MSwiZmxleERpcmVjdGlvbiI6MCwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjQwIiwiaGVpZ2h0IjoiNDAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJtYXJnaW4iOnsicmlnaHQiOiIwIn0sInBvc2l0aW9uIjp7InRvcCI6bnVsbCwicmlnaHQiOm51bGwsImJvdHRvbSI6bnVsbCwibGVmdCI6bnVsbH19LHsid2lkdGgiOiI2MCIsImhlaWdodCI6IjYwIiwibWluV2lkdGgiOm51bGwsIm1pbkhlaWdodCI6bnVsbCwibWF4V2lkdGgiOm51bGwsIm1heEhlaWdodCI6bnVsbCwibWFyZ2luIjp7InJpZ2h0IjoiMTAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX1dfQ== - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Ensure layouting happens - flexLayout.SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection::COLUMN_REVERSE ); - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsImFsaWduQ29udGVudCI6MSwiZmxleERpcmVjdGlvbiI6MSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjQwIiwiaGVpZ2h0IjoiNDAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJtYXJnaW4iOnsicmlnaHQiOiIwIn0sInBvc2l0aW9uIjp7InRvcCI6bnVsbCwicmlnaHQiOm51bGwsImJvdHRvbSI6bnVsbCwibGVmdCI6bnVsbH19LHsid2lkdGgiOiI2MCIsImhlaWdodCI6IjYwIiwibWluV2lkdGgiOm51bGwsIm1pbkhlaWdodCI6bnVsbCwibWF4V2lkdGgiOm51bGwsIm1heEhlaWdodCI6bnVsbCwibWFyZ2luIjp7InJpZ2h0IjoiMTAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX1dfQ== - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Ensure layouting happens - flexLayout.SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection::ROW ); - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsImFsaWduQ29udGVudCI6MSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjQwIiwiaGVpZ2h0IjoiNDAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJtYXJnaW4iOnsicmlnaHQiOiIwIn0sInBvc2l0aW9uIjp7InRvcCI6bnVsbCwicmlnaHQiOm51bGwsImJvdHRvbSI6bnVsbCwibGVmdCI6bnVsbH19LHsid2lkdGgiOiI2MCIsImhlaWdodCI6IjYwIiwibWluV2lkdGgiOm51bGwsIm1pbkhlaWdodCI6bnVsbCwibWF4V2lkdGgiOm51bGwsIm1heEhlaWdodCI6bnVsbCwibWFyZ2luIjp7InJpZ2h0IjoiMTAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX1dfQ== - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Ensure layouting happens - flexLayout.SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection::ROW_REVERSE ); - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsImFsaWduQ29udGVudCI6MSwiZmxleERpcmVjdGlvbiI6MywicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjQwIiwiaGVpZ2h0IjoiNDAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJtYXJnaW4iOnsicmlnaHQiOiIwIn0sInBvc2l0aW9uIjp7InRvcCI6bnVsbCwicmlnaHQiOm51bGwsImJvdHRvbSI6bnVsbCwibGVmdCI6bnVsbH19LHsid2lkdGgiOiI2MCIsImhlaWdodCI6IjYwIiwibWluV2lkdGgiOm51bGwsIm1pbkhlaWdodCI6bnVsbCwibWF4V2lkdGgiOm51bGwsIm1heEhlaWdodCI6bnVsbCwibWFyZ2luIjp7InJpZ2h0IjoiMTAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX1dfQ== - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 440.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 380.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Ensure layouting happens - flexLayout.SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection::ROW ); - flexLayout.SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::CENTER ); - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjIsImFsaWduQ29udGVudCI6MSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiY2hpbGRyZW4iOlt7IndpZHRoIjoiNDAiLCJoZWlnaHQiOiI0MCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjYwIiwiaGVpZ2h0IjoiNjAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJtYXJnaW4iOnsicmlnaHQiOiIxMCJ9LCJwb3NpdGlvbiI6eyJ0b3AiOm51bGwsInJpZ2h0IjpudWxsLCJib3R0b20iOm51bGwsImxlZnQiOm51bGx9fV19 - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Ensure layouting happens - flexLayout.SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::FLEX_END ); - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjMsImFsaWduQ29udGVudCI6MSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiY2hpbGRyZW4iOlt7IndpZHRoIjoiNDAiLCJoZWlnaHQiOiI0MCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjYwIiwiaGVpZ2h0IjoiNjAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJtYXJnaW4iOnsicmlnaHQiOiIxMCJ9LCJwb3NpdGlvbiI6eyJ0b3AiOm51bGwsInJpZ2h0IjpudWxsLCJib3R0b20iOm51bGwsImxlZnQiOm51bGx9fV19 - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Ensure layouting happens - flexLayout.SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::STRETCH ); - controls[0].SetProperty( Actor::Property::MAXIMUM_SIZE, Vector2(40.f, 40.f) ); - controls[1].SetProperty( Actor::Property::MAXIMUM_SIZE, Vector2(60.f, 60.f) ); - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsImFsaWduQ29udGVudCI6MSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiY2hpbGRyZW4iOlt7IndpZHRoIjoiNDAiLCJoZWlnaHQiOiI0MCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjAsImFsaWduQ29udGVudCI6MCwibWFyZ2luIjp7InJpZ2h0IjoiMCJ9LCJwb3NpdGlvbiI6eyJ0b3AiOm51bGwsInJpZ2h0IjpudWxsLCJib3R0b20iOm51bGwsImxlZnQiOm51bGx9fSx7IndpZHRoIjoiNjAiLCJoZWlnaHQiOiI2MCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjAsImFsaWduQ29udGVudCI6MCwibWFyZ2luIjp7InJpZ2h0IjoiMCJ9LCJwb3NpdGlvbiI6eyJ0b3AiOm51bGwsInJpZ2h0IjpudWxsLCJib3R0b20iOm51bGwsImxlZnQiOm51bGx9fV19 - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - flexLayout.SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::FLEX_START ); - flexLayout.SetFlexJustification( Dali::Toolkit::FlexLayout::Justification::FLEX_START ); - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsImFsaWduQ29udGVudCI6MSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiY2hpbGRyZW4iOlt7IndpZHRoIjoiNDAiLCJoZWlnaHQiOiI0MCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjAsImFsaWduQ29udGVudCI6MCwibWFyZ2luIjp7InJpZ2h0IjoiMCJ9LCJwb3NpdGlvbiI6eyJ0b3AiOm51bGwsInJpZ2h0IjpudWxsLCJib3R0b20iOm51bGwsImxlZnQiOm51bGx9fSx7IndpZHRoIjoiNjAiLCJoZWlnaHQiOiI2MCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjAsImFsaWduQ29udGVudCI6MCwibWFyZ2luIjp7InJpZ2h0IjoiMCJ9LCJwb3NpdGlvbiI6eyJ0b3AiOm51bGwsInJpZ2h0IjpudWxsLCJib3R0b20iOm51bGwsImxlZnQiOm51bGx9fV19 - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - flexLayout.SetFlexJustification( Dali::Toolkit::FlexLayout::Justification::CENTER ); - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImp1c3RpZnlDb250ZW50IjoxLCJhbGlnbkl0ZW1zIjoxLCJhbGlnbkNvbnRlbnQiOjEsInBvc2l0aW9uIjp7InRvcCI6bnVsbCwicmlnaHQiOm51bGwsImJvdHRvbSI6bnVsbCwibGVmdCI6bnVsbH0sImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjQwIiwiaGVpZ2h0IjoiNDAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjYwIiwiaGVpZ2h0IjoiNjAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX1dfQ== - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 190.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 230.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - flexLayout.SetFlexJustification( Dali::Toolkit::FlexLayout::Justification::FLEX_END ); - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImp1c3RpZnlDb250ZW50IjoyLCJhbGlnbkl0ZW1zIjoxLCJhbGlnbkNvbnRlbnQiOjEsInBvc2l0aW9uIjp7InRvcCI6bnVsbCwicmlnaHQiOm51bGwsImJvdHRvbSI6bnVsbCwibGVmdCI6bnVsbH0sImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjQwIiwiaGVpZ2h0IjoiNDAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjYwIiwiaGVpZ2h0IjoiNjAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX1dfQ== - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 380.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 420.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - flexLayout.SetFlexJustification( Dali::Toolkit::FlexLayout::Justification::SPACE_BETWEEN ); - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImp1c3RpZnlDb250ZW50IjozLCJhbGlnbkl0ZW1zIjoxLCJhbGlnbkNvbnRlbnQiOjEsInBvc2l0aW9uIjp7InRvcCI6bnVsbCwicmlnaHQiOm51bGwsImJvdHRvbSI6bnVsbCwibGVmdCI6bnVsbH0sImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjQwIiwiaGVpZ2h0IjoiNDAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjYwIiwiaGVpZ2h0IjoiNjAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX1dfQ== - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 420.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - flexLayout.SetFlexJustification( Dali::Toolkit::FlexLayout::Justification::SPACE_AROUND ); - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImp1c3RpZnlDb250ZW50Ijo0LCJhbGlnbkl0ZW1zIjoxLCJhbGlnbkNvbnRlbnQiOjEsInBvc2l0aW9uIjp7InRvcCI6bnVsbCwicmlnaHQiOm51bGwsImJvdHRvbSI6bnVsbCwibGVmdCI6bnVsbH0sImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjQwIiwiaGVpZ2h0IjoiNDAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjYwIiwiaGVpZ2h0IjoiNjAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX1dfQ== - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 95.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 325.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_FlexLayout05(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_FlexLayout05"); - - Stage stage = Stage::GetCurrent(); - auto flexBox = Control::New(); - auto flexLayout = FlexLayout::New(); - flexLayout.SetFlexAlignment( Dali::Toolkit::FlexLayout::Alignment::FLEX_START ); - flexLayout.SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::FLEX_START ); - flexLayout.SetFlexWrap(Dali::Toolkit::FlexLayout::WrapType::NO_WRAP); - flexLayout.SetFlexJustification( Dali::Toolkit::FlexLayout::Justification::FLEX_START ); - flexLayout.SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection::ROW ); - DevelControl::SetLayout( flexBox, flexLayout ); - flexBox.SetName( "Flexbox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 200, 200 ) ); - controls.push_back( CreateLeafControl( 400, 400 ) ); - for( auto&& iter : controls ) - { - flexBox.Add( iter ); - } - flexBox.SetParentOrigin( ParentOrigin::CENTER ); - flexBox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( flexBox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // Shrink is off - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 200.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 400.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - flexLayout.SetFlexWrap(Dali::Toolkit::FlexLayout::WrapType::WRAP); - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsImFsaWduQ29udGVudCI6MSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjIwMCIsImhlaWdodCI6IjIwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjQwMCIsImhlaWdodCI6IjQwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX1dfQ== - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 400.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - flexLayout.SetFlexAlignment(Dali::Toolkit::FlexLayout::Alignment::CENTER); - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsImFsaWduQ29udGVudCI6MiwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjIwMCIsImhlaWdodCI6IjIwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjQwMCIsImhlaWdodCI6IjQwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX1dfQ== - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 400.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - flexLayout.SetFlexAlignment(Dali::Toolkit::FlexLayout::Alignment::FLEX_END); - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsImFsaWduQ29udGVudCI6MiwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjIwMCIsImhlaWdodCI6IjIwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjQwMCIsImhlaWdodCI6IjQwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX1dfQ== - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 400.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - flexLayout.SetFlexAlignment(Dali::Toolkit::FlexLayout::Alignment::STRETCH); - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // To see the test go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsImFsaWduQ29udGVudCI6MiwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjIwMCIsImhlaWdodCI6IjIwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjQwMCIsImhlaWdodCI6IjQwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX1dfQ== - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 400.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_FlexLayout06(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_FlexLayout06"); - - Stage stage = Stage::GetCurrent(); - auto flexBox = Control::New(); - auto flexLayout = FlexLayout::New(); - flexLayout.SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection::COLUMN ); - flexLayout.SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::FLEX_START ); - DevelControl::SetLayout( flexBox, flexLayout ); - flexBox.SetName( "Flexbox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 60 ) ); - controls.push_back( CreateLeafControl( 80, 80 ) ); - controls.push_back( CreateLeafControl( 100, 100 ) ); - for( auto&& iter : controls ) - { - flexBox.Add( iter ); - } - flexBox.SetParentOrigin( ParentOrigin::CENTER ); - flexBox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( flexBox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // flexbox centers elements vertically, it fills test harness stage, which is 480x800. - // left aligned elements with right margin 10 - // To see goto https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsImFsaWduQ29udGVudCI6MSwiZmxleERpcmVjdGlvbiI6MCwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjQwIiwiaGVpZ2h0IjoiNDAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjYwIiwiaGVpZ2h0IjoiNjAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjgwIiwiaGVpZ2h0IjoiODAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6MTAwLCJoZWlnaHQiOjEwMCwibWluV2lkdGgiOm51bGwsIm1pbkhlaWdodCI6bnVsbCwibWF4V2lkdGgiOm51bGwsIm1heEhlaWdodCI6bnVsbCwiYWxpZ25JdGVtcyI6MCwiYWxpZ25Db250ZW50IjowLCJwb3NpdGlvbiI6eyJ0b3AiOm51bGwsInJpZ2h0IjpudWxsLCJib3R0b20iOm51bGwsImxlZnQiOm51bGx9fV19 - DALI_TEST_EQUALS( flexBox.GetProperty(Actor::Property::POSITION), Vector3(0, 0, 0),TEST_LOCATION); - DALI_TEST_EQUALS( flexBox.GetProperty(Actor::Property::SIZE), Vector3(480, 800, 0),TEST_LOCATION); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - flexBox.Remove( controls[1] ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // To see goto https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjEsImFsaWduQ29udGVudCI6MSwiZmxleERpcmVjdGlvbiI6MCwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjQwIiwiaGVpZ2h0IjoiNDAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjgwIiwiaGVpZ2h0IjoiODAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6MTAwLCJoZWlnaHQiOjEwMCwibWluV2lkdGgiOm51bGwsIm1pbkhlaWdodCI6bnVsbCwibWF4V2lkdGgiOm51bGwsIm1heEhlaWdodCI6bnVsbCwiYWxpZ25JdGVtcyI6MCwiYWxpZ25Db250ZW50IjowLCJwb3NpdGlvbiI6eyJ0b3AiOm51bGwsInJpZ2h0IjpudWxsLCJib3R0b20iOm51bGwsImxlZnQiOm51bGx9fV19 - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_FlexLayout07(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_FlexLayout07"); - - Stage stage = Stage::GetCurrent(); - auto flexBox = Control::New(); - auto flexLayout = FlexLayout::New(); - flexLayout.SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection::ROW ); - flexLayout.SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::CENTER ); - DevelControl::SetLayout( flexBox, flexLayout ); - flexBox.SetName( "Flexbox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 60 ) ); - controls.push_back( CreateLeafControl( 80, 80 ) ); - controls.push_back( CreateLeafControl( 100, 100 ) ); - - for( auto&& iter : controls ) - { - iter.SetProperty( Toolkit::FlexLayout::ChildProperty::FLEX, 0.f ); - iter.SetProperty( Toolkit::FlexLayout::ChildProperty::ALIGN_SELF, Dali::Toolkit::FlexLayout::Alignment::AUTO ); - flexBox.Add( iter ); - } - flexBox.SetParentOrigin( ParentOrigin::CENTER ); - flexBox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( flexBox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // To see goto https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjIsImFsaWduQ29udGVudCI6MSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjQwIiwiaGVpZ2h0IjoiNDAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjYwIiwiaGVpZ2h0IjoiNjAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjgwIiwiaGVpZ2h0IjoiODAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6MTAwLCJoZWlnaHQiOjEwMCwibWluV2lkdGgiOm51bGwsIm1pbkhlaWdodCI6bnVsbCwibWF4V2lkdGgiOm51bGwsIm1heEhlaWdodCI6bnVsbCwiYWxpZ25JdGVtcyI6MCwiYWxpZ25Db250ZW50IjowLCJtYXJnaW4iOnsicmlnaHQiOiIwIn0sInBvc2l0aW9uIjp7InRvcCI6bnVsbCwicmlnaHQiOm51bGwsImJvdHRvbSI6bnVsbCwibGVmdCI6bnVsbH19XX0= - DALI_TEST_EQUALS( flexBox.GetProperty(Actor::Property::POSITION), Vector3( 0, 0, 0 ),TEST_LOCATION); - DALI_TEST_EQUALS( flexBox.GetProperty(Actor::Property::SIZE), Vector3( 480, 800, 0 ),TEST_LOCATION); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 360.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 180.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - for( auto&& iter : controls ) - { - iter.SetProperty( Toolkit::FlexLayout::ChildProperty::FLEX, 0.25f ); - iter.SetProperty( Toolkit::FlexLayout::ChildProperty::ALIGN_SELF, Toolkit::FlexLayout::Alignment::AUTO ); - } - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // To see go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjIsImFsaWduQ29udGVudCI6MSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjQwIiwiaGVpZ2h0IjoiNDAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleEdyb3ciOiIwLjI1In0seyJ3aWR0aCI6IjYwIiwiaGVpZ2h0IjoiNjAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleEdyb3ciOiIwLjI1In0seyJ3aWR0aCI6IjgwIiwiaGVpZ2h0IjoiODAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleEdyb3ciOiIwLjI1In0seyJ3aWR0aCI6MTAwLCJoZWlnaHQiOjEwMCwibWluV2lkdGgiOm51bGwsIm1pbkhlaWdodCI6bnVsbCwibWF4V2lkdGgiOm51bGwsIm1heEhlaWdodCI6bnVsbCwiYWxpZ25JdGVtcyI6MCwiYWxpZ25Db250ZW50IjowLCJtYXJnaW4iOnsicmlnaHQiOiIwIn0sInBvc2l0aW9uIjp7InRvcCI6bnVsbCwicmlnaHQiOm51bGwsImJvdHRvbSI6bnVsbCwibGVmdCI6bnVsbH0sImZsZXhHcm93IjoiMC4yNSJ9XX0= - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 120.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 240.0f, 360.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 360.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - for( auto&& iter : controls ) - { - iter.SetProperty( Toolkit::FlexLayout::ChildProperty::FLEX, 0.f ); - } - controls[0].SetProperty( Toolkit::FlexLayout::ChildProperty::ALIGN_SELF, Toolkit::FlexLayout::Alignment::CENTER ); - controls[1].SetProperty( Toolkit::FlexLayout::ChildProperty::ALIGN_SELF, Toolkit::FlexLayout::Alignment::FLEX_START ); - controls[2].SetProperty( Toolkit::FlexLayout::ChildProperty::ALIGN_SELF, Toolkit::FlexLayout::Alignment::FLEX_END ); - controls[3].SetProperty( Toolkit::FlexLayout::ChildProperty::ALIGN_SELF, Toolkit::FlexLayout::Alignment::STRETCH ); - controls[3].SetProperty( Actor::Property::MAXIMUM_SIZE, Vector2(100.f, 100.f) ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // To see go to https://yogalayout.com/playground/#eyJ3aWR0aCI6IjQ4MCIsImhlaWdodCI6IjgwMCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjIsImFsaWduQ29udGVudCI6MSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfSwiZmxleFdyYXAiOjEsImNoaWxkcmVuIjpbeyJ3aWR0aCI6IjQwIiwiaGVpZ2h0IjoiNDAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnbkNvbnRlbnQiOjAsIm1hcmdpbiI6eyJyaWdodCI6IjAifSwicG9zaXRpb24iOnsidG9wIjpudWxsLCJyaWdodCI6bnVsbCwiYm90dG9tIjpudWxsLCJsZWZ0IjpudWxsfX0seyJ3aWR0aCI6IjYwIiwiaGVpZ2h0IjoiNjAiLCJtaW5XaWR0aCI6bnVsbCwibWluSGVpZ2h0IjpudWxsLCJtYXhXaWR0aCI6bnVsbCwibWF4SGVpZ2h0IjpudWxsLCJhbGlnbkl0ZW1zIjowLCJhbGlnblNlbGYiOjEsImFsaWduQ29udGVudCI6MCwibWFyZ2luIjp7InJpZ2h0IjoiMCJ9LCJwb3NpdGlvbiI6eyJ0b3AiOm51bGwsInJpZ2h0IjpudWxsLCJib3R0b20iOm51bGwsImxlZnQiOm51bGx9fSx7IndpZHRoIjoiODAiLCJoZWlnaHQiOiI4MCIsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjAsImFsaWduU2VsZiI6MywiYWxpZ25Db250ZW50IjowLCJtYXJnaW4iOnsicmlnaHQiOiIwIn0sInBvc2l0aW9uIjp7InRvcCI6bnVsbCwicmlnaHQiOm51bGwsImJvdHRvbSI6bnVsbCwibGVmdCI6bnVsbH19LHsid2lkdGgiOjEwMCwiaGVpZ2h0IjoxMDAsIm1pbldpZHRoIjpudWxsLCJtaW5IZWlnaHQiOm51bGwsIm1heFdpZHRoIjpudWxsLCJtYXhIZWlnaHQiOm51bGwsImFsaWduSXRlbXMiOjAsImFsaWduU2VsZiI6NCwiYWxpZ25Db250ZW50IjowLCJtYXJnaW4iOnsicmlnaHQiOiIwIn0sInBvc2l0aW9uIjp7InRvcCI6bnVsbCwicmlnaHQiOm51bGwsImJvdHRvbSI6bnVsbCwibGVmdCI6bnVsbH19XX0= - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 720.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 180.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_FlexLayout08(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_FlexLayout08"); - - Stage stage = Stage::GetCurrent(); - - auto flexbox1 = Control::New(); - auto flexLayout1 = FlexLayout::New(); - DevelControl::SetLayout( flexbox1, flexLayout1 ); - flexbox1.SetName( "Flexbox1"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 20, 20 ) ); - flexbox1.Add( controls[0] ); - flexbox1.SetParentOrigin( ParentOrigin::CENTER ); - flexbox1.SetAnchorPoint( AnchorPoint::CENTER ); - const Extents CONTROL_MARGIN = Extents( 10, 10, 10, 10 ); - const Extents CONTROL_PADDING = Extents( 5, 5, 5, 5 ); - flexbox1.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN ); - flexbox1.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING ); - flexbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - flexbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - auto flexbox2 = Control::New(); - auto flexLayout2 = FlexLayout::New(); - DevelControl::SetLayout( flexbox2, flexLayout2 ); - flexbox2.SetParentOrigin( ParentOrigin::CENTER ); - flexbox2.SetName( "Flexbox2"); - flexbox2.Add( flexbox1 ); - stage.Add( flexbox2 ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 15.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 20.0f, 20.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::SIZE ), Vector3( 30.0f, 30.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox2.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::POSITION ), Vector3( 10.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox2.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_FlexLayout_NestedFlexboxWithSpec(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_FlexLayout_NestedFlexboxWithSpec Test nested flex box with wrap content/match parent"); - - Stage stage = Stage::GetCurrent(); - - auto flexbox1 = Control::New(); - auto flexLayout1 = FlexLayout::New(); - DevelControl::SetLayout( flexbox1, flexLayout1 ); - flexbox1.SetName( "Flexbox1"); - flexbox1.SetParentOrigin( ParentOrigin::CENTER ); - flexbox1.SetAnchorPoint( AnchorPoint::CENTER ); - - auto flexbox2 = Control::New(); - auto flexLayout2 = FlexLayout::New(); - DevelControl::SetLayout( flexbox2, flexLayout2 ); - flexbox2.SetParentOrigin( ParentOrigin::CENTER ); - flexbox2.SetAnchorPoint( AnchorPoint::CENTER ); - flexbox2.SetName( "Flexbox2"); - flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 100, 100 ) ); - flexbox2.Add( controls[0] ); - flexbox1.Add( flexbox2 ); - stage.Add( flexbox1 ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Test flexbox2 is sized to wrap its content - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox2.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox2.GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Test flexbox2 width is sized to match parent - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox2.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox2.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Test flexbox2 height is sized to match parent - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox2.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox2.GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - flexbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Test flexbox2 is sized to match its parent - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox2.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox2.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_FlexLayout_WithTextLabel(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_FlexLayout_WithTextLabel "); - - Stage stage = Stage::GetCurrent(); - - auto flexbox1 = Control::New(); - auto flexLayout1 = FlexLayout::New(); - DevelControl::SetLayout( flexbox1, flexLayout1 ); - flexbox1.SetName( "Flexbox1"); - flexbox1.SetParentOrigin( ParentOrigin::CENTER ); - flexbox1.SetAnchorPoint( AnchorPoint::CENTER ); - - std::vector< Control > controls; - controls.push_back( CreateTextLabel( "W" ) ); - flexbox1.Add( controls[0] ); - stage.Add( flexbox1 ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 52.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Test flexbox2 is sized to wrap its content - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - TextLabel::DownCast( controls[0] ).SetProperty( TextLabel::Property::TEXT, "WWWW" ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 214.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( flexbox1.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-GridLayout.cpp b/automated-tests/src/dali-toolkit/utc-Dali-GridLayout.cpp deleted file mode 100644 index 9438589..0000000 --- a/automated-tests/src/dali-toolkit/utc-Dali-GridLayout.cpp +++ /dev/null @@ -1,668 +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. - * - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include <../custom-layout.h> - -#include - -using namespace Dali; -using namespace Toolkit; - -void utc_dali_toolkit_grid_layouting_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_toolkit_grid_layouting_cleanup(void) -{ - test_return_value = TET_PASS; -} - -int UtcDaliLayouting_GridLayout00(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_GridLayout00 1 Column, 0 Items"); - - const auto NUMBER_OF_COLUMNS = 1; - const auto NUMBER_OF_ITEMS = 0; - - tet_printf( "Testing %d columns with %d items\n", NUMBER_OF_COLUMNS, NUMBER_OF_ITEMS ); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "AbsoluteLayout" ); - stage.Add( rootControl ); - - auto gridContainer = Control::New(); - auto gridLayout = Grid::New(); - gridLayout.SetNumberOfColumns( NUMBER_OF_COLUMNS ); - gridContainer.SetName( "GridLayout"); - DevelControl::SetLayout( gridContainer, gridLayout ); - gridContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - gridContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - rootControl.Add( gridContainer ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_printf( "Confirm number of columns is as set\n"); - DALI_TEST_EQUALS( gridLayout.GetNumberOfColumns(), NUMBER_OF_COLUMNS, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_GridLayout01(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_GridLayout01 2 Column, 4 Items"); - - const auto NUMBER_OF_COLUMNS = 2; - const auto NUMBER_OF_ITEMS = 4; - - tet_printf( "Testing %d columns with %d items\n", NUMBER_OF_COLUMNS, NUMBER_OF_ITEMS ); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "AbsoluteLayout" ); - stage.Add( rootControl ); - - auto gridContainer = Control::New(); - auto gridLayout = Grid::New(); - gridLayout.SetNumberOfColumns( NUMBER_OF_COLUMNS ); - gridContainer.SetName( "GridLayout"); - DevelControl::SetLayout( gridContainer, gridLayout ); - gridContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - gridContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - std::vector< Control > controls; - for( auto i=0; i < NUMBER_OF_ITEMS; i++ ) - { - controls.push_back( CreateLeafControl( 100, 100 ) ); - } - - for( auto&& iter : controls ) - { - gridContainer.Add( iter ); - } - - rootControl.Add( gridContainer ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // Grid will layout first 2 items on first row then last 2 on second row. - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Item sizes will not be changed - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_printf( "Confirm number of columns is as set\n"); - DALI_TEST_EQUALS( gridLayout.GetNumberOfColumns(), NUMBER_OF_COLUMNS, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_GridLayout02(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_GridLayout02"); - - const auto NUMBER_OF_COLUMNS = 3; - const auto NUMBER_OF_ITEMS = 7; - - tet_printf( "Testing %d columns with %d items\n", NUMBER_OF_COLUMNS, NUMBER_OF_ITEMS ); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "AbsoluteLayout" ); - stage.Add( rootControl ); - - auto gridContainer = Control::New(); - auto gridLayout = Grid::New(); - gridLayout.SetNumberOfColumns( NUMBER_OF_COLUMNS ); - gridContainer.SetName( "GridLayout"); - DevelControl::SetLayout( gridContainer, gridLayout ); - gridContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - gridContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - std::vector< Control > controls; - for( auto i=0; i < NUMBER_OF_ITEMS; i++ ) - { - controls.push_back( CreateLeafControl( 100, 100 ) ); - } - - for( auto&& iter : controls ) - { - gridContainer.Add( iter ); - } - - rootControl.Add( gridContainer ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // grid layouts out 3 items per row, which is 480x800. - // Row 1 - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 200.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - // Row 2 - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[4].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[5].GetProperty( Actor::Property::POSITION ), Vector3( 200.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - // Row 3 - DALI_TEST_EQUALS( controls[6].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[4].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[5].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[6].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_GridLayout03(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_GridLayout03 Grid Padding"); - - const auto NUMBER_OF_COLUMNS = 2; - const auto NUMBER_OF_ITEMS = 4; - - tet_printf( "Testing %d columns with %d items\n", NUMBER_OF_COLUMNS, NUMBER_OF_ITEMS ); - - Extents GRID_PADDING( Extents( 10, 10, 20, 20 ) ); // start,end,top,bottom - - tet_printf( "Testing with Padding 10,10,20,20\n"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "AbsoluteLayout" ); - stage.Add( rootControl ); - - auto gridContainer = Control::New(); - auto gridLayout = Grid::New(); - gridLayout.SetNumberOfColumns( NUMBER_OF_COLUMNS ); - gridContainer.SetName( "GridLayout"); - DevelControl::SetLayout( gridContainer, gridLayout ); - gridContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - gridContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - gridContainer.SetProperty( Control::Property::PADDING, GRID_PADDING ); - - std::vector< Control > controls; - for( auto i=0; i < NUMBER_OF_ITEMS; i++ ) - { - controls.push_back( CreateLeafControl( 100, 100 ) ); - } - - for( auto&& iter : controls ) - { - gridContainer.Add( iter ); - } - - rootControl.Add( gridContainer ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline(" UtcDaliLayouting_GridLayout03 Grid Padding 2 Column, 4 Items"); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f + GRID_PADDING.start , 0.0f + GRID_PADDING.top, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f + GRID_PADDING.start, 0.0f + GRID_PADDING.top, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f + GRID_PADDING.start, 100.0f + GRID_PADDING.top , 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f + GRID_PADDING.start, 100.0f + GRID_PADDING.top, 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline(" UtcDaliLayouting_GridLayout03 Size of Grid should include padding"); - DALI_TEST_EQUALS( gridContainer.GetProperty( Actor::Property::SIZE ), Vector3( 100.0f * NUMBER_OF_COLUMNS + GRID_PADDING.start + + GRID_PADDING.end, - 100.0f * ( NUMBER_OF_ITEMS / NUMBER_OF_COLUMNS ) + - GRID_PADDING.top + GRID_PADDING.bottom, - 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline(" UtcDaliLayouting_GridLayout03 Item sizes unchanged"); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_GridLayout04(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_GridLayout04 Child Margin"); - - const auto NUMBER_OF_COLUMNS = 2; - const auto NUMBER_OF_ITEMS = 4; - - tet_printf( "Testing %d columns with %d items\n", NUMBER_OF_COLUMNS, NUMBER_OF_ITEMS ); - - Extents GRID_PADDING( Extents( 10, 10, 20, 20 ) ); // start,end,top,bottom - Extents ITEM_MARGIN( Extents( 10, 10, 5, 5 ) ); // start,end,top,bottom - - tet_printf( "Testing with Margin 10,10,5,5\n"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "AbsoluteLayout" ); - stage.Add( rootControl ); - - auto gridContainer = Control::New(); - auto gridLayout = Grid::New(); - gridLayout.SetNumberOfColumns( NUMBER_OF_COLUMNS ); - gridContainer.SetName( "GridLayout"); - DevelControl::SetLayout( gridContainer, gridLayout ); - gridContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - gridContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - gridContainer.SetProperty( Control::Property::PADDING, GRID_PADDING ); - - std::vector< Control > controls; - for( auto i=0; i < NUMBER_OF_ITEMS; i++ ) - { - auto control = CreateLeafControl( 100, 100 ); - control.SetProperty(Toolkit::Control::Property::MARGIN, ITEM_MARGIN ); - controls.push_back( control ); - } - - for( auto&& iter : controls ) - { - gridContainer.Add( iter ); - } - - rootControl.Add( gridContainer ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), - Vector3( 0.0f + GRID_PADDING.start + ITEM_MARGIN.start, - 0.0f + GRID_PADDING.top + ITEM_MARGIN.top, - 0.0f ), - 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), - Vector3( 100.0f + GRID_PADDING.start + ITEM_MARGIN.start *2 + ITEM_MARGIN.end, - 0.0f + GRID_PADDING.top + ITEM_MARGIN.top, - 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), - Vector3( 0.0f + GRID_PADDING.start + ITEM_MARGIN.start, - 100.0f + GRID_PADDING.top + ITEM_MARGIN.top*2 + ITEM_MARGIN.bottom, - 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), - Vector3( 100.0f + GRID_PADDING.start + ITEM_MARGIN.start*2 + ITEM_MARGIN.end, - 100.0f + GRID_PADDING.top + ITEM_MARGIN.top*2 + ITEM_MARGIN.bottom, - 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline(" UtcDaliLayouting_GridLayout03 Size of Grid should include padding and margins"); - - const auto NUMBER_OF_ROWS = ( NUMBER_OF_ITEMS / NUMBER_OF_COLUMNS ); - - DALI_TEST_EQUALS( gridContainer.GetProperty( Actor::Property::SIZE ), Vector3( 100.0f * NUMBER_OF_COLUMNS + GRID_PADDING.start + GRID_PADDING.end + - ITEM_MARGIN.start *NUMBER_OF_COLUMNS + ITEM_MARGIN.end *NUMBER_OF_COLUMNS, - 100.0f * NUMBER_OF_ROWS + - GRID_PADDING.top + GRID_PADDING.bottom + - ITEM_MARGIN.bottom *NUMBER_OF_ROWS + ITEM_MARGIN.bottom *NUMBER_OF_ROWS, - 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline(" UtcDaliLayouting_GridLayout03 Item sizes unchanged"); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_GridLayout05(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_GridLayout05 2 Column, 4 Items UNSPECIFIED width and height SPECIFICATIONS"); - - const auto NUMBER_OF_COLUMNS = 2; - const auto NUMBER_OF_ITEMS = 4; - - tet_printf( "Testing %d columns with %d items\n", NUMBER_OF_COLUMNS, NUMBER_OF_ITEMS ); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "AbsoluteLayout" ); - stage.Add( rootControl ); - - auto customLayout = Test::CustomLayout::New(); - tet_printf( "Set Flag so child is measured with an unconstrained measure spec\n"); - customLayout.SetCustomBehaviourFlag( Test::CustomLayout::BEHAVIOUR_FLAG_UNCONSTRAINED_CHILD_WIDTH ); - customLayout.SetCustomBehaviourFlag( Test::CustomLayout::BEHAVIOUR_FLAG_UNCONSTRAINED_CHILD_HEIGHT ); - auto customHBox = Control::New(); - customHBox.SetName("CustomHBox"); - DevelControl::SetLayout( customHBox, customLayout ); - tet_printf( "Set width of custom layout to be smaller than child Grid wants to be\n"); - customHBox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 150 ); - customHBox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 150 ); - rootControl.Add( customHBox ); - - auto gridContainer = Control::New(); - auto gridLayout = Grid::New(); - gridLayout.SetNumberOfColumns( NUMBER_OF_COLUMNS ); - gridContainer.SetName( "GridLayout"); - DevelControl::SetLayout( gridContainer, gridLayout ); - tet_printf( "Grid SPEC set to MATCH_PARENT, this will be ignored if BEHAVIOUR_FLAG_UNCONSTRAINED_CHILD_WIDTH or BEHAVIOUR_FLAG_UNCONSTRAINED_CHILD_HEIGHT flags are set\n"); - gridContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - gridContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - std::vector< Control > controls; - for( auto i=0; i < NUMBER_OF_ITEMS; i++ ) - { - controls.push_back( CreateLeafControl( 100, 100 ) ); - } - - for( auto&& iter : controls ) - { - gridContainer.Add( iter ); - } - - customHBox.Add( gridContainer ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // Grid will layout first 2 items on first row then last 2 on second row. - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Item sizes will not be changed - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_GridLayout06(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_GridLayout06 2 Column, 4 Items UNSPECIFIED width SPECIFICATION"); - - const auto NUMBER_OF_COLUMNS = 2; - const auto NUMBER_OF_ITEMS = 4; - - tet_printf( "Testing %d columns with %d items\n", NUMBER_OF_COLUMNS, NUMBER_OF_ITEMS ); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "AbsoluteLayout" ); - stage.Add( rootControl ); - - auto customLayout = Test::CustomLayout::New(); - tet_printf( "Set Flag so child is measured with an unconstrained measure spec\n"); - customLayout.SetCustomBehaviourFlag( Test::CustomLayout::BEHAVIOUR_FLAG_UNCONSTRAINED_CHILD_WIDTH ); - auto customHBox = Control::New(); - customHBox.SetName("CustomHBox"); - DevelControl::SetLayout( customHBox, customLayout ); - tet_printf( "Set width of custom layout to be smaller than child Grid wants to be\n"); - customHBox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 150 ); - customHBox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 150 ); - rootControl.Add( customHBox ); - - auto gridContainer = Control::New(); - auto gridLayout = Grid::New(); - gridLayout.SetNumberOfColumns( NUMBER_OF_COLUMNS ); - gridContainer.SetName( "GridLayout"); - DevelControl::SetLayout( gridContainer, gridLayout ); - tet_printf( "Grid SPEC set to MATCH_PARENT, this will be ignored if BEHAVIOUR_FLAG_UNCONSTRAINED_CHILD_WIDTH or BEHAVIOUR_FLAG_UNCONSTRAINED_CHILD_HEIGHT flags are set\n"); - gridContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - gridContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - std::vector< Control > controls; - for( auto i=0; i < NUMBER_OF_ITEMS; i++ ) - { - controls.push_back( CreateLeafControl( 100, 100 ) ); - } - - for( auto&& iter : controls ) - { - gridContainer.Add( iter ); - } - - customHBox.Add( gridContainer ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // Grid will layout first 2 items on first row then last 2 on second row. - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 75.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 75.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Item sizes will not be changed - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 75.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 75.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 75.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 75.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - - -int UtcDaliLayouting_GridLayout07(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_GridLayout07 2 Column, 4 Items UNSPECIFIED height SPECIFICATION"); - - const auto NUMBER_OF_COLUMNS = 2; - const auto NUMBER_OF_ITEMS = 4; - - tet_printf( "Testing %d columns with %d items\n", NUMBER_OF_COLUMNS, NUMBER_OF_ITEMS ); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "AbsoluteLayout" ); - stage.Add( rootControl ); - - auto customLayout = Test::CustomLayout::New(); - tet_printf( "Set Flag so child is measured with an unconstrained measure spec\n"); - customLayout.SetCustomBehaviourFlag( Test::CustomLayout::BEHAVIOUR_FLAG_UNCONSTRAINED_CHILD_HEIGHT ); - auto customHBox = Control::New(); - customHBox.SetName("CustomHBox"); - DevelControl::SetLayout( customHBox, customLayout ); - tet_printf( "Set width of custom layout to be smaller than child Grid wants to be\n"); - customHBox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 150 ); - customHBox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 150 ); - rootControl.Add( customHBox ); - - auto gridContainer = Control::New(); - auto gridLayout = Grid::New(); - gridLayout.SetNumberOfColumns( NUMBER_OF_COLUMNS ); - gridContainer.SetName( "GridLayout"); - DevelControl::SetLayout( gridContainer, gridLayout ); - tet_printf( "Grid SPEC set to MATCH_PARENT, this will be ignored if BEHAVIOUR_FLAG_UNCONSTRAINED_CHILD_WIDTH or BEHAVIOUR_FLAG_UNCONSTRAINED_CHILD_HEIGHT flags are set\n"); - gridContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - gridContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - std::vector< Control > controls; - for( auto i=0; i < NUMBER_OF_ITEMS; i++ ) - { - controls.push_back( CreateLeafControl( 100, 100 ) ); - } - - for( auto&& iter : controls ) - { - gridContainer.Add( iter ); - } - - customHBox.Add( gridContainer ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // Grid will layout first 2 items on first row then last 2 on second row. - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 75.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 75.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Item sizes will not be changed - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 75.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 75.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 75.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 75.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - - -int UtcDaliLayouting_GridLayout08(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_GridLayout08 2 Column, 4 Items Grid with children too wide for parent spec"); - - const auto NUMBER_OF_COLUMNS = 2; - const auto NUMBER_OF_ITEMS = 4; - - tet_printf( "Testing %d columns with %d items\n", NUMBER_OF_COLUMNS, NUMBER_OF_ITEMS ); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "AbsoluteLayout" ); - stage.Add( rootControl ); - - auto customLayout = Test::CustomLayout::New(); - auto customHBox = Control::New(); - customHBox.SetName("CustomHBox"); - DevelControl::SetLayout( customHBox, customLayout ); - tet_printf( "Set width of custom layout to be smaller than child Grid wants to be\n"); - customHBox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 150 ); - customHBox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 200 ); - rootControl.Add( customHBox ); - - auto gridContainer = Control::New(); - auto gridLayout = Grid::New(); - gridLayout.SetNumberOfColumns( NUMBER_OF_COLUMNS ); - gridContainer.SetName( "GridLayout"); - DevelControl::SetLayout( gridContainer, gridLayout ); - gridContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - gridContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - std::vector< Control > controls; - for( auto i=0; i < NUMBER_OF_ITEMS; i++ ) - { - controls.push_back( CreateLeafControl( 100, 100 ) ); - } - - for( auto&& iter : controls ) - { - gridContainer.Add( iter ); - } - - customHBox.Add( gridContainer ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_printf( "Children width reduced from 100 to 75\n", NUMBER_OF_COLUMNS, NUMBER_OF_ITEMS ); - // Grid will layout first 2 items on first row then last 2 on second row. - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 75.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 75.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Item sizes will be changed - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 75.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 75.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 75.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 75.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - - -int UtcDaliLayouting_GridLayoutDownCast(void) -{ - TestApplication application; - tet_infoline(" UtcDaliLayouting_GridLayoutDownCast - Testing Downcast"); - - Grid gridLayout = Grid::New(); - - LayoutGroup layoutGroup( gridLayout ); - - Grid gridLayoutCandidate = Grid::DownCast( layoutGroup ); - DALI_TEST_CHECK( gridLayoutCandidate ); - - END_TEST; -} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp deleted file mode 100755 index 835c845..0000000 --- a/automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp +++ /dev/null @@ -1,3217 +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. - * - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include <../custom-layout.h> - -#include - -using namespace Dali; -using namespace Toolkit; - -namespace -{ - -// Turns the given control into a Root layout control and adds it to the stage. -void SetupRootLayoutControl( Control& rootControl ) -{ - rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "RootAbsoluteLayout" ); - Stage stage = Stage::GetCurrent(); - stage.Add( rootControl ); -} - -} // unnamed namespace - -void utc_dali_toolkit_layouting_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_toolkit_layouting_cleanup(void) -{ - test_return_value = TET_PASS; -} - -int UtcDaliLayouting_LayoutLength_Types(void) -{ - tet_infoline("UtcDaliLayouting_LayoutLength Types"); - - // testing that operators return correct type - // operator+ - { - auto value = LayoutLength( 10 ) + LayoutLength(); - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - { - auto value = LayoutLength( 10 ) + 20; - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - { - auto value = 22 + LayoutLength( 10 ); - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - { - auto value = LayoutLength( 10 ) + 2.1f; - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - { - auto value = 2.2f + LayoutLength( 10 ); - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - // operator- - { - auto value = LayoutLength() - LayoutLength( 10 ); - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - { - auto value = LayoutLength( 10 ) - 99; - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - { - auto value = 20 - LayoutLength( 10 ); - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - { - auto value = LayoutLength( 10 ) - 9.9f; - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - { - auto value = 2.0f - LayoutLength( 10 ); - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - - // operator* - { - auto value = LayoutLength() * LayoutLength( 10 ); - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - { - auto value = LayoutLength( 10 ) * 2; - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - { - auto value = 10 * LayoutLength( 10 ); - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - { - auto value = LayoutLength( 10 ) * 2.1f; - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - { - auto value = 1.0f * LayoutLength( 10 ); - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - // operator/ - { - auto value = LayoutLength( 10 ) / 2.0f; - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - - // combinations - { - auto value = ( LayoutLength( 10 ) * 2.0f ) / 1.5f; - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - { - auto value = 20 + ( LayoutLength( 10 ) * 2.0f ) / 1.5f; - DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION ); - } - - END_TEST; -} - -int UtcDaliLayouting_LayoutLength_Values(void) -{ - tet_infoline("UtcDaliLayouting_LayoutLength Values"); - - // operator+ - { - LayoutLength value = LayoutLength( 10 ) + LayoutLength(); - DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION ); - } - { - LayoutLength value = LayoutLength( 10 ) + 20; - DALI_TEST_EQUALS( value.AsInteger(), 30.0f, 0.0001f, TEST_LOCATION ); - } - { - LayoutLength value = 22 - LayoutLength( 10 ); - DALI_TEST_EQUALS( value.AsInteger(), 12.0f, 0.0001f, TEST_LOCATION ); - } - { - LayoutLength value = LayoutLength( 10 ) + 2.1f; - DALI_TEST_EQUALS( value.AsDecimal(), 12.1f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsTruncated(), 12.0f, 0.0001f, TEST_LOCATION ); - } - { - LayoutLength value = 2.3f - LayoutLength( 10 ); - DALI_TEST_EQUALS( value.AsDecimal(), -7.7f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsInteger(), -8.0f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsTruncated(), -7.0f, 0.0001f, TEST_LOCATION ); - } - // operator- - { - LayoutLength value = LayoutLength() - LayoutLength( 10 ); - DALI_TEST_EQUALS( value.AsInteger(), -10.0f, 0.0001f, TEST_LOCATION ); - } - { - LayoutLength value = LayoutLength( 10 ) - 99; - DALI_TEST_EQUALS( value.AsInteger(), -89.0f, 0.0001f, TEST_LOCATION ); - } - { - LayoutLength value = 20 - LayoutLength( 10 ); - DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsTruncated(), 10.f, 0.0001f, TEST_LOCATION ); - } - { - LayoutLength value = LayoutLength( 10 ) - 9.9f; - DALI_TEST_EQUALS( value.AsInteger(), 0.0f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsDecimal(), 0.1f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsTruncated(), 0.0f, 0.0001f, TEST_LOCATION ); - } - { - LayoutLength value = 10.9f - LayoutLength( 10 ); - DALI_TEST_EQUALS( value.AsInteger(), 1.0f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsDecimal(), 0.9f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsTruncated(), 0.0f, 0.0001f, TEST_LOCATION ); - } - // operator* - { - LayoutLength value = LayoutLength() * LayoutLength( 10 ); - DALI_TEST_EQUALS( value.AsInteger(), 0.0f, 0.0001f, TEST_LOCATION ); - } - { - LayoutLength value = LayoutLength(1) * 10; - DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION ); - } - { - LayoutLength value = 11 * LayoutLength( 10 ); - DALI_TEST_EQUALS( value.AsInteger(), 110.0f, 0.0001f, TEST_LOCATION ); - } - { - LayoutLength value = LayoutLength( 10 ) * 2.12f; - DALI_TEST_EQUALS( value.AsDecimal(), 21.2f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsInteger(), 21.0f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsTruncated(), 21.0f, 0.0001f, TEST_LOCATION ); - } - { - LayoutLength value = 2.189f * LayoutLength( 10 ); - DALI_TEST_EQUALS( value.AsDecimal(), 21.89f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsInteger(), 22.0f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsTruncated(), 21.0f, 0.0001f, TEST_LOCATION ); - } - // operator/ - { - LayoutLength value = LayoutLength( 11 ) / 2.0f; - DALI_TEST_EQUALS( value.AsDecimal(), 5.5f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsInteger(), 6.0f, 0.0001f, TEST_LOCATION ); - } - - // combinations - { - LayoutLength value; - value = 20 + ( LayoutLength( 10 ) * 2.0f ) / 1.5f; - DALI_TEST_EQUALS( value.AsInteger(), 33.0f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsDecimal(), 33.3333f, 0.0001f, TEST_LOCATION ); - } - { - uint16_t padding( 1 ); - LayoutLength right(35), left(10), mTotalLength(2); - LayoutLength value; - value = padding + ( right - left - mTotalLength ) / 2.0f; - // = 1 + ( 35 - 10 - 2 ) / 2 - DALI_TEST_EQUALS( value.AsInteger(), 13.0f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsDecimal(), 12.5f, 0.0001f, TEST_LOCATION ); - } - { - uint16_t padding = 1, top = 2, bottom = 3; - LayoutLength childSpace( 44 ), childHeight( 23 ); - LayoutLength value; - value = padding + ( ( childSpace - childHeight ) / 2.0f ) + top - bottom; - // = 1 + ( ( 44 - 23 ) / 2 ) + 2 - 3 - DALI_TEST_EQUALS( value.AsInteger(), 11.0f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( value.AsDecimal(), 10.5f, 0.0001f, TEST_LOCATION ); - } - - END_TEST; -} - -int UtcDaliLayouting_LayoutLength_Operators(void) -{ - tet_infoline("UtcDaliLayouting_LayoutLength operators"); - - { - LayoutLength value = 10; - DALI_TEST_EQUALS( (int)value.AsInteger(), 10, TEST_LOCATION ); - value += 1; - DALI_TEST_EQUALS( (int)value.AsInteger(), 11, TEST_LOCATION ); - value -= 12; - DALI_TEST_EQUALS( (int)value.AsInteger(), -1, TEST_LOCATION ); - LayoutLength value2 = value; - DALI_TEST_EQUALS( value == value2, true, TEST_LOCATION ); - value2 = 123; - DALI_TEST_EQUALS( value != value2, true, TEST_LOCATION ); - DALI_TEST_EQUALS( value < value2, true, TEST_LOCATION ); - DALI_TEST_EQUALS( value <= value2, true, TEST_LOCATION ); - value = 456; - DALI_TEST_EQUALS( value > value2, true, TEST_LOCATION ); - DALI_TEST_EQUALS( value >= value2, true, TEST_LOCATION ); - } - - { - LayoutLength value( 123 ); - std::stringstream ss; - ss << value; - DALI_TEST_EQUALS( ss.str(), "123", TEST_LOCATION ); - } - { - LayoutLength value( 0.123f ); - std::stringstream ss; - ss << value; - DALI_TEST_EQUALS( ss.str(), "0.123", TEST_LOCATION ); - } - END_TEST; -} - -int UtcDaliLayouting_HboxLayout01(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_HboxLayout01"); - - Stage stage = Stage::GetCurrent(); - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 40 ) ); - controls.push_back( CreateLeafControl( 80, 40 ) ); - controls.push_back( CreateLeafControl( 100, 40 ) ); - - for( auto&& iter : controls ) - { - hbox.Add( iter ); - } - - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // hbox centers elements vertically, it fills test harness stage, which is 480x800. - // hbox left justifies elements - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( 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( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_HboxLayout02(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_HboxLayout02 Test nested hboxes with default spec of WRAP_CONTENT"); - - Stage stage = Stage::GetCurrent(); - - auto hbox1 = Control::New(); - auto hboxLayout1 = LinearLayout::New(); - DevelControl::SetLayout( hbox1, hboxLayout1 ); - - auto hbox2 = Control::New(); - auto hboxLayout2 = LinearLayout::New(); - DevelControl::SetLayout( hbox2, hboxLayout2 ); - - hbox1.SetName( "HBox1"); - hbox2.SetName( "HBox2"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 20, 40 ) ); - controls.push_back( CreateLeafControl( 30, 50 ) ); - controls.push_back( CreateLeafControl( 40, 60 ) ); - controls.push_back( CreateLeafControl( 50, 70 ) ); - - controls.push_back( CreateLeafControl( 25, 40 ) ); - controls.push_back( CreateLeafControl( 35, 50 ) ); - controls.push_back( CreateLeafControl( 45, 60 ) ); - controls.push_back( CreateLeafControl( 55, 70 ) ); - - int counter=0; - for( auto&& iter : controls ) - { - if( counter < 4 ) - { - hbox1.Add( iter ); - } - else - { - hbox2.Add( iter ); - } - ++counter; - } - hbox1.SetParentOrigin( ParentOrigin::CENTER ); - hbox1.SetAnchorPoint( AnchorPoint::CENTER ); - hbox2.SetParentOrigin( ParentOrigin::CENTER ); - hbox2.SetAnchorPoint( AnchorPoint::CENTER ); - - auto hbox3 = Control::New(); - auto hboxLayout3 = LinearLayout::New(); - DevelControl::SetLayout( hbox3, hboxLayout3 ); - - hbox3.SetParentOrigin( ParentOrigin::CENTER ); - hbox3.SetName( "HBox3"); - hbox3.Add( hbox1 ); - hbox3.Add( hbox2 ); - - stage.Add( hbox3 ); - - // 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( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 20.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 50.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 90.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - - DALI_TEST_EQUALS( controls[4].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[5].GetProperty( Actor::Property::POSITION ), Vector3( 25.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[6].GetProperty( Actor::Property::POSITION ), Vector3( 60.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[7].GetProperty( Actor::Property::POSITION ), Vector3( 105.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[4].GetProperty( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[5].GetProperty( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[6].GetProperty( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[7].GetProperty( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Test hbox1 and 2 are sized to wrap their content - DALI_TEST_EQUALS( hbox1.GetProperty( Actor::Property::SIZE ), Vector3( 140.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( hbox2.GetProperty( Actor::Property::SIZE ), Vector3( 160.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( hbox1.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( hbox2.GetProperty( Actor::Property::POSITION ), Vector3( 140.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Test hbox3 matches parent (root layer) - DALI_TEST_EQUALS( hbox3.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( hbox3.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - - -int UtcDaliLayouting_HboxLayout03(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_HboxLayout03 Test nested hboxes with MATCH_PARENT"); - - Stage stage = Stage::GetCurrent(); - - auto hbox1 = Control::New(); - auto hboxLayout1 = LinearLayout::New(); - DevelControl::SetLayout( hbox1, hboxLayout1 ); - - auto hbox2 = Control::New(); - auto hboxLayout2 = LinearLayout::New(); - DevelControl::SetLayout( hbox2, hboxLayout2 ); - - hbox1.SetName( "HBox1"); - hbox2.SetName( "HBox2"); - hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 20, 40 ) ); - controls.push_back( CreateLeafControl( 30, 50 ) ); - controls.push_back( CreateLeafControl( 40, 60 ) ); - controls.push_back( CreateLeafControl( 50, 70 ) ); - - controls.push_back( CreateLeafControl( 25, 40 ) ); - controls.push_back( CreateLeafControl( 35, 50 ) ); - controls.push_back( CreateLeafControl( 45, 60 ) ); - controls.push_back( CreateLeafControl( 55, 70 ) ); - - int counter=0; - for( auto&& iter : controls ) - { - if( counter < 4 ) - { - hbox1.Add( iter ); - } - else - { - hbox2.Add( iter ); - } - ++counter; - } - hbox1.SetParentOrigin( ParentOrigin::CENTER ); - hbox1.SetAnchorPoint( AnchorPoint::CENTER ); - hbox2.SetParentOrigin( ParentOrigin::CENTER ); - hbox2.SetAnchorPoint( AnchorPoint::CENTER ); - - auto hbox3 = Control::New(); - auto hboxLayout3 = LinearLayout::New(); - DevelControl::SetLayout( hbox3, hboxLayout3); - - hbox3.SetParentOrigin( ParentOrigin::CENTER ); - hbox3.SetName( "HBox3"); - hbox3.Add( hbox1 ); - hbox3.Add( hbox2 ); - - stage.Add( hbox3 ); - - //std::ostringstream oss; - //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() ); - //printf("Control hierarchy: \n%s\n", oss.str().c_str() ); - - // 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( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 20.0f,375.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 50.0f,370.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 90.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 30.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 50.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[4].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[5].GetProperty( Actor::Property::POSITION ), Vector3( 25.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[6].GetProperty( Actor::Property::POSITION ), Vector3( 60.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[7].GetProperty( Actor::Property::POSITION ), Vector3( 105.0f,365.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[4].GetProperty( Actor::Property::SIZE ), Vector3( 25.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[5].GetProperty( Actor::Property::SIZE ), Vector3( 35.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[6].GetProperty( Actor::Property::SIZE ), Vector3( 45.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[7].GetProperty( Actor::Property::SIZE ), Vector3( 55.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( hbox1.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( hbox2.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( hbox1.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( hbox2.GetProperty( Actor::Property::POSITION ), Vector3( 480.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Test hbox3 matches parent (root layer) - DALI_TEST_EQUALS( hbox3.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( hbox3.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_HboxLayout04(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_HboxLayout04 Test nested hboxes with explicit WRAP_CONTENT"); - - Stage stage = Stage::GetCurrent(); - - auto hbox1 = Control::New(); - auto hboxLayout1 = LinearLayout::New(); - DevelControl::SetLayout( hbox1, hboxLayout1 ); - - auto hbox2 = Control::New(); - auto hboxLayout2 = LinearLayout::New(); - DevelControl::SetLayout( hbox2, hboxLayout2 ); - - hbox1.SetName( "HBox1"); // Default spec is to wrap content - hbox2.SetName( "HBox2"); - hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - hbox1.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - hbox2.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 80, 40 ) ); - controls.push_back( CreateLeafControl( 80, 50 ) ); - controls.push_back( CreateLeafControl( 80, 60 ) ); - controls.push_back( CreateLeafControl( 80, 70 ) ); - - controls.push_back( CreateLeafControl( 80, 40 ) ); - controls.push_back( CreateLeafControl( 80, 50 ) ); - controls.push_back( CreateLeafControl( 80, 60 ) ); - controls.push_back( CreateLeafControl( 80, 70 ) ); - - int counter=0; - for( auto&& iter : controls ) - { - if( counter < 4 ) - { - hbox1.Add( iter ); - } - else - { - hbox2.Add( iter ); - } - ++counter; - } - - controls[6].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - auto hbox3 = Control::New(); - auto hboxLayout3 = LinearLayout::New(); - DevelControl::SetLayout( hbox3, hboxLayout3 ); - - hbox3.SetParentOrigin( ParentOrigin::CENTER ); - hbox3.SetName( "HBox3"); - hbox3.Add( hbox1 ); - hbox3.Add( hbox2 ); - stage.Add( hbox3 ); - - //std::ostringstream oss; - //DumpControlHierarchy( oss, Stage::GetCurrent().GetRootLayer() ); - //printf("Control hierarchy: \n%s\n", oss.str().c_str() ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 80.0f,10.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 160.0f, 5.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[4].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 15.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[5].GetProperty( Actor::Property::POSITION ), Vector3( 80.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[6].GetProperty( Actor::Property::POSITION ), Vector3( 160.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[7].GetProperty( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[4].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[5].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[6].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[7].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( hbox1.GetProperty( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( hbox2.GetProperty( Actor::Property::SIZE ), Vector3( 320.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( hbox1.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( hbox2.GetProperty( Actor::Property::POSITION ), Vector3( 320.0f, 365.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - - // Test hbox3 matches parent (root layer) - DALI_TEST_EQUALS( hbox3.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( hbox3.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_HboxLayout05(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_HboxLayout05 - Set children size explicitly via width & height specification"); - - Stage stage = Stage::GetCurrent(); - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 40 ) ); - controls.push_back( CreateLeafControl( 80, 40 ) ); - controls.push_back( CreateLeafControl( 100, 40 ) ); - - for( auto&& iter : controls ) - { - hbox.Add( iter ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 100 ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 50 ); - } - - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // hbox centers elements vertically, it fills test harness stage, which is 480x800. - // hbox left justifies elements - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 110.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 220.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 330.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - 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( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( hbox.GetProperty( 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( 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( 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( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_HboxLayout07(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set LTR/RTL direction"); - - Stage stage = Stage::GetCurrent(); - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetCellPadding( LayoutSize( 10, 0 ) ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 40 ) ); - controls.push_back( CreateLeafControl( 80, 40 ) ); - controls.push_back( CreateLeafControl( 100, 40 ) ); - - for( auto&& iter : controls ) - { - hbox.Add( iter ); - } - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( hbox ); - - hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::LEFT_TO_RIGHT ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right. - // hbox left justifies elements - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 50.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 210.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hbox.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 470.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 400.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 310.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 200.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_HboxLayout08(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_HboxLayout08 - Test layout animation"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - absoluteLayout.SetAnimateLayout( true ); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "AbsoluteLayout" ); - stage.Add( rootControl ); - - Control control1 = CreateLeafControl( 40, 40 ); - rootControl.Add( control1 ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox" ); - - Control control2 = CreateLeafControl( 40, 40 ); - hbox.Add( control2 ); - - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - rootControl.Add( hbox ); - - DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), true, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), true, TEST_LOCATION ); - DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), false, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), false, TEST_LOCATION ); - - tet_infoline(" Set hBoxLayout to animate"); - hboxLayout.SetAnimateLayout( true ); - tet_infoline(" Set absoluteLayout not to animate"); - absoluteLayout.SetAnimateLayout( false ); - - DALI_TEST_EQUALS( absoluteLayout.IsLayoutAnimated(), false, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelControl::GetLayout( control1 ).IsLayoutAnimated(), false, TEST_LOCATION ); - DALI_TEST_EQUALS( hboxLayout.IsLayoutAnimated(), true, TEST_LOCATION ); - DALI_TEST_EQUALS( DevelControl::GetLayout( control2 ).IsLayoutAnimated(), true, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_HboxLayout09(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set alignment"); - - Stage stage = Stage::GetCurrent(); - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 60 ) ); - - for( auto&& iter : controls ) - { - hbox.Add( iter ); - } - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( hbox ); - - // Check default orientation - DALI_TEST_EQUALS( static_cast( hboxLayout.GetOrientation() ), static_cast( LinearLayout::Orientation::HORIZONTAL ), TEST_LOCATION ); - // Check default alignment - DALI_TEST_EQUALS( hboxLayout.GetAlignment(), ( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL ), TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 380.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 420.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 380.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 420.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 190.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 230.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 380.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 190.0f, 760.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 230.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 190.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 230.0f, 370.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL ); - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 440.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 420.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::TOP ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::TOP ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 440.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 420.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::TOP ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::BOTTOM ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::END | Dali::Toolkit::LinearLayout::Alignment::BOTTOM ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 440.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 420.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 220.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 210.0f, 740.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 220.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 210.0f, 390.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_HboxLayout_Weight(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliLayouting_HboxLayout_Weight - Test LinearLayout weight horizontally" ); - - Stage stage = Stage::GetCurrent(); - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox" ); - - std::vector controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 40 ) ); - controls.push_back( CreateLeafControl( 80, 40 ) ); - controls.push_back( CreateLeafControl( 100, 40 ) ); - - // Set weight for each leaf to use quarter of available space - // 480 * 0.25, 480 * 0.25, 480 * 0.25, 480 * 0.25, - // width spec has to be set to 0 so not to consume any extra space. - for( auto&& iter : controls ) - { - iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - hbox.Add( iter ); - } - - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 120.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 240.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 360.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Set weight for 3, 4 leafs to use all remaining available space after 1, 2 content sized leafs. - // 40, 60, (480 - 40 - 60) * 0.5, (480 - 40 - 60) * 0.5 - controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f ); - controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 290.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 190.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 190.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Add intrinsic width for 3rd leaf so now we should get - // 40, 60, (480 - 40 - 60 - 80) * 0.5 + 80, (480 - 40 - 60 - 80) * 0.5 - controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 80 ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 330.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 230.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 150.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 ); - controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f ); - controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 ); - controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f ); - controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 ); - controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f ); - controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 40 ); - controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 110.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 330.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 440.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 110.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 220.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 110.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // WRAP_CONTENT doesn't affect weight - controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 180.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 300.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // MATCH_PARENT doesn't affect weight - for( auto&& iter : controls ) - { - iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - } - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 120.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 240.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 360.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - const Extents CONTROL_MARGIN = Extents( 10, 10, 0, 0 ); - for( auto&& iter : controls ) - { - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - iter.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN ); - } - - controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 ); - - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 10.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 70.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 150.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 250.0f, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 220.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_VboxLayout_Weight(void) -{ - ToolkitTestApplication application; - tet_infoline( " UtcDaliLayouting_VboxLayout_Weight - Test LinearLayout weight vertically" ); - - Stage stage = Stage::GetCurrent(); - auto vbox = Control::New(); - auto vboxLayout = LinearLayout::New(); - vboxLayout.SetOrientation( Dali::Toolkit::LinearLayout::Orientation::VERTICAL ); - DevelControl::SetLayout( vbox, vboxLayout ); - vbox.SetName( "VBox" ); - - std::vector controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 60 ) ); - controls.push_back( CreateLeafControl( 80, 80 ) ); - controls.push_back( CreateLeafControl( 100, 100 ) ); - - // Set weight for each leaf to use quarter of available space - // 800 * 0.25, 800 * 0.25, 800 * 0.25, 800 * 0.25, - // width spec has to be set to 0 so not to consume any extra space. - for( auto&& iter : controls ) - { - iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 ); - vbox.Add( iter ); - } - - vbox.SetParentOrigin( ParentOrigin::CENTER ); - vbox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( vbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 600.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Set weight for 3, 4 leafs to use all remaining available space after 1, 2 content sized leafs. - // 40, 60, (800 - 40 - 60) * 0.5, (800 - 40 - 60) * 0.5 - controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f ); - controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 450.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Add intrinsic width for 3rd leaf so now we should get - // 40, 60, (800 - 40 - 60 - 100) * 0.5 + 100, (800 - 40 - 60 - 100) * 0.5 - controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 500.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 ); - controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f ); - controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 ); - controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f ); - controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 ); - controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f ); - controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 ); - controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 525.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 700.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 175.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // WRAP_CONTENT doesn't affect weight - controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[1].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[3].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 620.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // MATCH_PARENT doesn't affect weight - for( auto&& iter : controls ) - { - iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.25f ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - } - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 600.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - const Extents CONTROL_MARGIN = Extents( 0, 0, 10, 10 ); - for( auto&& iter : controls ) - { - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - iter.SetProperty( Toolkit::Control::Property::MARGIN, CONTROL_MARGIN ); - } - - controls[0].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[1].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[2].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0 ); - controls[3].SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 1 ); - - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 70.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 250.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 540.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_NestedLinearLayout_Weight(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_NestedLinearLayout_Weight - test weighted children with wrapped parent"); - - Stage stage = Stage::GetCurrent(); - auto rootControl = Control::New(); - rootControl.SetName( "AbsoluteLayout"); - auto rootLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, rootLayout ); - rootControl.SetAnchorPoint( AnchorPoint::CENTER ); - rootControl.SetParentOrigin( ParentOrigin::CENTER ); - stage.Add( rootControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 60 ) ); - - // set equal share of wrapped content width (40 + 60 = 100) for both children 100 * 0.5, 100 * 0.5 - for( auto&& iter : controls ) - { - iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 0 ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - hbox.Add( iter ); - } - - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - rootControl.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( hbox.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( hbox.GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 50.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 50.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 50.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hboxLayout.SetOrientation(Dali::Toolkit::LinearLayout::Orientation::VERTICAL); - - // set equal share of wrapped content height (40 + 60 = 100) for both children 100 * 0.5, 100 * 0.5 - for( auto&& iter : controls ) - { - iter.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.5f ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - iter.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 0 ); - } - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( hbox.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( hbox.GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - - -namespace -{ -const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/broken.png"; -} - -int UtcDaliLayouting_HboxLayout_ImageView(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_HboxLayout - Use image view for leaf"); - - Stage stage = Stage::GetCurrent(); - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox" ); - - std::string url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 100, 100 ) ); - ImageView imageView = CreateImageView( url, ImageDimensions() ); - - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - hbox.Add( imageView ); - stage.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( imageView.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( imageView.GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline("UtcDaliLayouting_HboxLayout - Change image (new size)"); - url = CreateImageURL( Vector4( 0, 255, 0, 255), ImageDimensions( 200, 200 ) ); - imageView.SetImage( url ); - - // Ensure layouting happenss - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( imageView.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( imageView.GetProperty( Actor::Property::SIZE ), Vector3( 200.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - // Ensure layouting happenss - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( imageView.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( imageView.GetProperty( Actor::Property::SIZE ), Vector3( 200.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - // Ensure layouting happenss - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( imageView.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( imageView.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 200.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - imageView.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - Image image = FrameBufferImage::New( 50, 50, Pixel::RGBA8888 ); - imageView.SetImage( image ); - - // Ensure layouting happenss - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( imageView.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 375.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( imageView.GetProperty( Actor::Property::SIZE ), Vector3( 50.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - Property::Map imagePropertyMap; - imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE; - imagePropertyMap[ ImageVisual::Property::URL ] = TEST_IMAGE_FILE_NAME; - imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = 150; - imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = 150; - imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, imagePropertyMap ); - - DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); - // Ensure layouting happenss - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( imageView.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 325.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( imageView.GetProperty( Actor::Property::SIZE ), Vector3( 150.0f, 150.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_HboxLayout_TextLabel(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_HboxLayout - Use text label for leaf"); - - Stage stage = Stage::GetCurrent(); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox" ); - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - - std::vector< Control > controls; - TextLabel textLabel = CreateTextLabel( "W" ); - controls.push_back( textLabel ); - hbox.Add( textLabel ); - stage.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( textLabel.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( textLabel.GetProperty( Actor::Property::SIZE ), Vector3( 52.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - textLabel.SetProperty( TextLabel::Property::TEXT, "WWWW" ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 368.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 214.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10.0f ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - controls[0].SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 382.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 36.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -// Padding tests - -int UtcDaliLayouting_HboxLayout_Padding01(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_HboxLayout_Padding01 - Adding Padding to a single child"); - - Stage stage = Stage::GetCurrent(); - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 40 ) ); - controls.push_back( CreateLeafControl( 80, 40 ) ); - controls.push_back( CreateLeafControl( 100, 40 ) ); - - const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 ); - tet_printf( "\nAdding Padding to control at index %u \n", 1 ); - controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING ); - - for( auto&& iter : controls ) - { - hbox.Add( iter ); - } - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // hbox centers elements vertically, it fills test harness stage, which is 480x800. - // hbox left justifies elements - tet_infoline("Test Child Actor Position"); - float xPositionOfControlBeingTested = 0.0f; - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, - 380.0f, - 0.0f ), 0.0001f, TEST_LOCATION ); - xPositionOfControlBeingTested += 40.0f; - - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, - 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ), - 0.0001f, TEST_LOCATION ); - - xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end; - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - xPositionOfControlBeingTested += 80.0f; - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline("Test Child Actor Size"); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end, - 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom , 0.0f ), - 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_HboxLayout_Padding02(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_HboxLayout_Padding02 - Adding Padding to a all children"); - - Stage stage = Stage::GetCurrent(); - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 40 ) ); - controls.push_back( CreateLeafControl( 80, 40 ) ); - controls.push_back( CreateLeafControl( 100, 40 ) ); - - const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 ); - - for( auto&& iter : controls ) - { - iter.SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING ); - hbox.Add( iter ); - } - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // hbox centers elements vertically, it fills test harness stage, which is 480x800. - // hbox left justifies elements - tet_infoline("Test Child Actor Position"); - float xPositionOfControlBeingTested = 0.0f; - float yPositionOfControlBeingTested = ( 800.0f * 0.5) - ( 0.5 * ( 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom ) ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, - yPositionOfControlBeingTested, - 0.0f ), 0.0001f, TEST_LOCATION ); - xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end; - - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, - yPositionOfControlBeingTested, - 0.0f ), - 0.0001f, TEST_LOCATION ); - - xPositionOfControlBeingTested += 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end; - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, - yPositionOfControlBeingTested, - 0.0f ), 0.0001f, TEST_LOCATION ); - - xPositionOfControlBeingTested += 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end; - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, - yPositionOfControlBeingTested, - 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline("Test Child Actor Size"); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end, - 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom, - 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f + CONTROL_PADDING.start + CONTROL_PADDING.end, - 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom, - 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f + CONTROL_PADDING.start + CONTROL_PADDING.end , - 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom, - 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f + CONTROL_PADDING.start + CONTROL_PADDING.end, - 40.0f + CONTROL_PADDING.top + CONTROL_PADDING.bottom, - 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - - -int UtcDaliLayouting_HboxLayout_Padding03(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_HboxLayout_Padding03 - Changing padding on a single child"); - - Stage stage = Stage::GetCurrent(); - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 40, 40 ) ); - - const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 ); - tet_printf( "\nAdding Padding to control at index 1 \n" ); - controls[1].SetProperty(Toolkit::Control::Property::PADDING, CONTROL_PADDING ); - - for( auto&& iter : controls ) - { - hbox.Add( iter ); - } - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // hbox centers elements vertically, it fills test harness stage, which is 480x800. - // hbox left justifies elements - tet_infoline("Test Child Actor Position"); - float xPositionOfControlBeingTested = 0.0f; - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, - 380.0f, - 0.0f ), 0.0001f, TEST_LOCATION ); - xPositionOfControlBeingTested += 40.0f; - - DALI_TEST_EQUALS( controls[ 1 ].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, - 380.0f - ( ( CONTROL_PADDING.top + CONTROL_PADDING.bottom) * 0.5f ), 0.0f ), - 0.0001f, TEST_LOCATION ); - - xPositionOfControlBeingTested += 40.0f + CONTROL_PADDING.start + CONTROL_PADDING.end; - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - const Extents NEW_CONTROL_PADDING = Extents(10, 10, 20, 2 ); - tet_printf( "\nChanging Padding to control at index 1 \n" ); - controls[1].SetProperty(Toolkit::Control::Property::PADDING, NEW_CONTROL_PADDING ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - xPositionOfControlBeingTested = 0.0f; // reset - - tet_infoline("Test Child Actor Position"); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, - 380.0f, - 0.0f ), 0.0001f, TEST_LOCATION ); - xPositionOfControlBeingTested += 40.0f; - - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, - 380.0f - ( ( NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom) * 0.5f ), 0.0f ), - 0.0001f, TEST_LOCATION ); - - xPositionOfControlBeingTested += 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end; - tet_printf( "\nIf x position %u then change has not been processed \n", 40 + 40 + CONTROL_PADDING.start + CONTROL_PADDING.end ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline("Test Child Actor Size"); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ) , Vector3( 40.0f + NEW_CONTROL_PADDING.start + NEW_CONTROL_PADDING.end, - 40.0f + NEW_CONTROL_PADDING.top + NEW_CONTROL_PADDING.bottom , 0.0f ), - 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ) , Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_HboxLayout_Padding04(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_HboxLayout_Padding04 - Adding Padding to the hbox"); - - // Adding padding to the layout should offset the positioning of the children. - - const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 ); - const Size CONTROL_SIZE = Size( 40, 40 ); - - Stage stage = Stage::GetCurrent(); - // Create a root layout, ideally Dali would have a default layout in the root layer. - // Without this root layer the LinearLayout (or any other layout) will not - // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings. - // It uses the default stage size and ideally should have a layout added to it. - auto rootLayoutControl = Control::New(); - rootLayoutControl.SetName( "AbsoluteLayout"); - auto rootLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootLayoutControl, rootLayout ); - rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER ); - rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER ); - stage.Add( rootLayoutControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) ); - controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) ); - controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) ); - controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) ); - - for( auto&& iter : controls ) - { - hbox.Add( iter ); - } - - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - rootLayoutControl.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen. - application.SendNotification(); - - // hbox centers elements vertically, it fills test harness stage, which is 480x800. - // hbox left justifies elements - tet_infoline("Test Child Actor Position"); - - auto controlXPosition=0.0f; - - controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start, - LAYOUT_PADDING.top, - 0.0f ), 0.0001f, TEST_LOCATION ); - - controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width. - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( controlXPosition, - LAYOUT_PADDING.top, - 0.0f ), - 0.0001f, TEST_LOCATION ); - - controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( controlXPosition, - LAYOUT_PADDING.top, - 0.0f ), 0.0001f, TEST_LOCATION ); - - controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( controlXPosition, - LAYOUT_PADDING.top, - 0.0f ), 0.0001f, TEST_LOCATION ); - - auto totalControlsWidth = CONTROL_SIZE.width * controls.size(); - auto totalControlsHeight = CONTROL_SIZE.height; - - DALI_TEST_EQUALS( hbox.GetProperty( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end, - totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom, - 0.0f ), 0.0001f, TEST_LOCATION ); - - - END_TEST; -} - -int UtcDaliLayouting_HboxLayout_Padding05(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_HboxLayout_Padding05 - Changing the hbox Padding"); - - // Adding padding to the layout should offset the positioning of the children. - - const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 ); - const Size CONTROL_SIZE = Size( 40, 40 ); - - Stage stage = Stage::GetCurrent(); - // Create a root layout, ideally Dali would have a default layout in the root layer. - // Without this root layer the LinearLayout (or any other layout) will not - // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings. - // It uses the default stage size and ideally should have a layout added to it. - auto rootLayoutControl = Control::New(); - rootLayoutControl.SetName( "AbsoluteLayout"); - auto rootLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootLayoutControl, rootLayout ); - rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER ); - rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER ); - stage.Add( rootLayoutControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - hbox.SetProperty(Toolkit::Control::Property::PADDING, LAYOUT_PADDING ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) ); - controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) ); - controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) ); - controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) ); - - for( auto&& iter : controls ) - { - hbox.Add( iter ); - } - - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - rootLayoutControl.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen. - application.SendNotification(); - - // hbox centers elements vertically, it fills test harness stage, which is 480x800. - // hbox left justifies elements - tet_infoline("Test Child Actor Position"); - - auto controlXPosition=0.0f; - - controlXPosition = LAYOUT_PADDING.start; // First child positioned at offset defined by the padding - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start, - LAYOUT_PADDING.top, - 0.0f ), 0.0001f, TEST_LOCATION ); - - controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width. - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( controlXPosition, - LAYOUT_PADDING.top, - 0.0f ), - 0.0001f, TEST_LOCATION ); - - controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( controlXPosition, - LAYOUT_PADDING.top, - 0.0f ), 0.0001f, TEST_LOCATION ); - - controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( controlXPosition, - LAYOUT_PADDING.top, - 0.0f ), 0.0001f, TEST_LOCATION ); - - auto totalControlsWidth = CONTROL_SIZE.width * controls.size(); - auto totalControlsHeight = CONTROL_SIZE.height; - - DALI_TEST_EQUALS( hbox.GetProperty( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end, - totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom, - 0.0f ), 0.0001f, TEST_LOCATION ); - - // Change layout padding - const Extents NEW_LAYOUT_PADDING = Extents(5, 20, 10, 2 ); - tet_printf( "\nChanging Padding to control at index 1 \n" ); - hbox.SetProperty(Toolkit::Control::Property::PADDING, NEW_LAYOUT_PADDING ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen. - application.SendNotification(); - - controlXPosition = NEW_LAYOUT_PADDING.start; // First child positioned at offset defined by the padding - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( NEW_LAYOUT_PADDING.start, - NEW_LAYOUT_PADDING.top, - 0.0f ), 0.0001f, TEST_LOCATION ); - - controlXPosition+=CONTROL_SIZE.width; // Second child positioned is the position of the first child + the first child's width. - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( controlXPosition, - NEW_LAYOUT_PADDING.top, - 0.0f ), - 0.0001f, TEST_LOCATION ); - - controlXPosition+=CONTROL_SIZE.width; // Third child positioned adjacent to second - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( controlXPosition, - NEW_LAYOUT_PADDING.top, - 0.0f ), 0.0001f, TEST_LOCATION ); - - controlXPosition+=CONTROL_SIZE.width; // Forth passed adjacent to the third - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( controlXPosition, - NEW_LAYOUT_PADDING.top, - 0.0f ), 0.0001f, TEST_LOCATION ); - totalControlsWidth = CONTROL_SIZE.width * controls.size(); - totalControlsHeight = CONTROL_SIZE.height; - - DALI_TEST_EQUALS( hbox.GetProperty( Actor::Property::SIZE ), Vector3( totalControlsWidth + NEW_LAYOUT_PADDING.start + NEW_LAYOUT_PADDING.end, - totalControlsHeight + NEW_LAYOUT_PADDING.top + NEW_LAYOUT_PADDING.bottom, - 0.0f ), 0.0001f, TEST_LOCATION ); - END_TEST; -} - -// Margin Tests - -int UtcDaliLayouting_HboxLayout_Margin01(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_HboxLayout_Margin01 - Adding a margin to a single child"); - - Stage stage = Stage::GetCurrent(); - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 40 ) ); - controls.push_back( CreateLeafControl( 80, 40 ) ); - controls.push_back( CreateLeafControl( 100, 40 ) ); - - const Extents CONTROL_MARGIN = Extents(5, 10, 20, 0 ); - tet_printf( "\nAdding Margin to control at index 1 \n" ); - controls[1].SetProperty(Toolkit::Control::Property::MARGIN, CONTROL_MARGIN ); - - for( auto&& iter : controls ) - { - hbox.Add( iter ); - } - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // hbox centers elements vertically, it fills test harness stage, which is 480x800. - // hbox left justifies elements - tet_infoline("Test Child Actor Position"); - auto xPositionOfControlBeingTested = 0.0f; - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, - 380.0f, - 0.0f ), 0.0001f, TEST_LOCATION ); - xPositionOfControlBeingTested += 40.0f + CONTROL_MARGIN.start; - - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, - 380.0f + CONTROL_MARGIN.top, 0.0f ), - 0.0001f, TEST_LOCATION ); - - xPositionOfControlBeingTested += 60.0f + CONTROL_MARGIN.end; - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested, 380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - xPositionOfControlBeingTested += 80.0f; - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( xPositionOfControlBeingTested,380.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline("Test Child Actor Size is the same after Margin added"); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f , 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - - -int UtcDaliLayouting_VboxLayout01(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_VboxLayout01"); - - Stage stage = Stage::GetCurrent(); - auto vbox = Control::New(); - auto vboxLayout = LinearLayout::New(); - vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL ); - vboxLayout.SetAlignment( LinearLayout::Alignment::TOP | LinearLayout::Alignment::CENTER_HORIZONTAL ); - DevelControl::SetLayout( vbox, vboxLayout ); - vbox.SetName( "Vbox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 60 ) ); - controls.push_back( CreateLeafControl( 80, 80 ) ); - controls.push_back( CreateLeafControl( 100, 100 ) ); - - for( auto&& iter : controls ) - { - vbox.Add( iter ); - } - vbox.SetParentOrigin( ParentOrigin::CENTER ); - vbox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( vbox ); - - controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - // Check it. - DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // vbox centers elements horizontally, it fills test harness stage, which is 480x800. - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 220.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 210.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 190.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_VboxLayout02(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_VboxLayout01"); - - Stage stage = Stage::GetCurrent(); - - // @todo Can't set specification properties on root control. Really need to make LayoutController a root - // LayoutGroup for this to happen automatically. - // - // For this test, add an hbox instead - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "AbsoluteLayout"); - stage.Add( rootControl ); - - auto vbox = Control::New(); - auto vboxLayout = LinearLayout::New(); - vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL ); - vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL ); - DevelControl::SetLayout( vbox, vboxLayout ); - vbox.SetName( "Vbox"); - rootControl.Add( vbox ); - - vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 60 ) ); - controls.push_back( CreateLeafControl( 80, 80 ) ); - controls.push_back( CreateLeafControl( 100, 100 ) ); - - for( auto&& iter : controls ) - { - vbox.Add( iter ); - } - vbox.SetParentOrigin( ParentOrigin::CENTER ); - vbox.SetAnchorPoint( AnchorPoint::CENTER ); - - controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - // Check it. - DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( rootControl.GetProperty(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION); - DALI_TEST_EQUALS( rootControl.GetProperty(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( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( vbox.GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // 3rd control is set to match parent - this should also be 100 wide - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 20.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - - -int UtcDaliLayouting_VboxLayout03(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_VboxLayout03 test with cell padding set"); - - Stage stage = Stage::GetCurrent(); - - // @todo Can't set specification properties on root control. Really need to make LayoutController a root - // LayoutGroup for this to happen automatically. - // - // For this test, add an hbox instead - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "Hbox"); - stage.Add( hbox ); - - auto vbox = Control::New(); - auto vboxLayout = LinearLayout::New(); - vboxLayout.SetCellPadding( LayoutSize( 0, 10 ) ); - vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL ); - vboxLayout.SetAlignment( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL ); - - DALI_TEST_EQUALS( vboxLayout.GetCellPadding(), LayoutSize( 0, 10 ), TEST_LOCATION ); - - DevelControl::SetLayout( vbox, vboxLayout ); - vbox.SetName( "Vbox"); - hbox.Add( vbox ); - - vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 60 ) ); - controls.push_back( CreateLeafControl( 80, 80 ) ); - controls.push_back( CreateLeafControl( 100, 100 ) ); - - for( auto&& iter : controls ) - { - vbox.Add( iter ); - } - vbox.SetParentOrigin( ParentOrigin::CENTER ); - vbox.SetAnchorPoint( AnchorPoint::CENTER ); - - controls[2].SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - // Check it. - DALI_TEST_EQUALS( controls[2].GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ), Property::Value( ChildLayoutData::MATCH_PARENT ), TEST_LOCATION ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( hbox.GetProperty(Actor::Property::POSITION), Vector3(0,0,0),TEST_LOCATION); - DALI_TEST_EQUALS( hbox.GetProperty(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( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( vbox.GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // 3rd control is set to match parent - this should also be 100 wide - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 30.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 20.0f, 50.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 210.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_VboxLayout_Padding(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_VboxLayout_Padding - Adding Padding to the vbox"); - - // Adding padding to the layout should offset the positioning of the children. - - const Extents LAYOUT_PADDING = Extents(5, 10, 20, 2 ); - const Size CONTROL_SIZE = Size( 40, 40 ); - - Stage stage = Stage::GetCurrent(); - // Create a root layout, ideally Dali would have a default layout in the root layer. - // Without this root layer the LinearLayout (or any other layout) will not - // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings. - // It uses the default stage size and ideally should have a layout added to it. - auto rootLayoutControl = Control::New(); - rootLayoutControl.SetName( "AbsoluteLayout"); - auto rootLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootLayoutControl, rootLayout ); - rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER ); - rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER ); - stage.Add( rootLayoutControl ); - - auto vbox = Control::New(); - auto vboxLayout = LinearLayout::New(); - vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL ); - DevelControl::SetLayout( vbox, vboxLayout ); - vbox.SetName( "VBox"); - vbox.SetProperty( Toolkit::Control::Property::PADDING, LAYOUT_PADDING ); - vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) ); - controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) ); - controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) ); - controls.push_back( CreateLeafControl( CONTROL_SIZE.width, CONTROL_SIZE.height ) ); - - for( auto&& iter : controls ) - { - vbox.Add( iter ); - } - - vbox.SetParentOrigin( ParentOrigin::CENTER ); - vbox.SetAnchorPoint( AnchorPoint::CENTER ); - rootLayoutControl.Add( vbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // Extra update needed to Relayout one more time. Catches any position updates, false positive without this seen. - application.SendNotification(); - - // vbox centers elements horizontally, it fills test harness stage, which is 480x800. - tet_infoline("Test Child Actor Position"); - - auto controlYPosition = 0.0f; - - controlYPosition = LAYOUT_PADDING.top; // First child positioned at offset defined by the padding - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start, - LAYOUT_PADDING.top, - 0.0f ), 0.0001f, TEST_LOCATION ); - - controlYPosition += CONTROL_SIZE.height; // Second child positioned is the position of the first child + the first child's height. - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start, - controlYPosition, - 0.0f ), - 0.0001f, TEST_LOCATION ); - - controlYPosition += CONTROL_SIZE.height; // Third child positioned adjacent to second - DALI_TEST_EQUALS( controls[2].GetProperty( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start, - controlYPosition, - 0.0f ), 0.0001f, TEST_LOCATION ); - - controlYPosition += CONTROL_SIZE.height; // Forth passed adjacent to the third - DALI_TEST_EQUALS( controls[3].GetProperty( Actor::Property::POSITION ), Vector3( LAYOUT_PADDING.start, - controlYPosition, - 0.0f ), 0.0001f, TEST_LOCATION ); - - auto totalControlsWidth = CONTROL_SIZE.width; - auto totalControlsHeight = CONTROL_SIZE.height * controls.size(); - - DALI_TEST_EQUALS( vbox.GetProperty( Actor::Property::SIZE ), Vector3( totalControlsWidth + LAYOUT_PADDING.start + LAYOUT_PADDING.end, - totalControlsHeight + LAYOUT_PADDING.top + LAYOUT_PADDING.bottom, - 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - - -int UtcDaliLayouting_HboxLayout_TargetSize(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_HboxLayout07 - Set target size on leaf"); - - Stage stage = Stage::GetCurrent(); - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - for( auto&& iter : controls ) - { - iter.SetSize( 100, 100 ); - hbox.Add( iter ); - } - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - stage.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // hbox centers elements vertically, it fills test harness stage, which is 480x800 from left to right. - // hbox left justifies elements - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_LayoutChildren01(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_LayoutChildren01"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - stage.Add( rootControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - rootControl.Add( hbox ); - - DALI_TEST_EQUALS( absoluteLayout.GetChildCount(), 1, TEST_LOCATION ); - - tet_infoline("Test removal by 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_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 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_LayoutChildren03(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_SetLayoutOrder01 - 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( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - - -int UtcDaliLayouting_LayoutGroup01(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_LayoutGroup01 - Test adding a control to a layout then adding a TextLabel to that control"); - - Control rootControl; - SetupRootLayoutControl( rootControl ); - - // Create a parent layout - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hbox.SetName( "HBox"); - rootControl.Add( hbox ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 ); - hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - DevelControl::SetLayoutingRequired( hbox, true ); - hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally. - - tet_infoline("Add a control without SetLayout being called but with layout required set true"); - - auto control = Control::New(); - control.SetName("Control1"); - DevelControl::SetLayoutingRequired( control, true ); - hbox.Add( control ); - control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - tet_infoline("Add a Textlabel to the control"); - auto textLabel = TextLabel::New("Test text"); - textLabel.SetName("TextLabel"); - - control.Add( textLabel ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("Test text is it's natural size"); - DALI_TEST_EQUALS( textLabel.GetProperty( Actor::Property::SIZE ), Vector3( 228.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - tet_infoline("Test control is width of it's parent and height of it's child"); - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::SIZE ), Vector3( 600.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_LayoutGroup02(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_LayoutGroup02 - Test control is the size of it's largest child"); - - Control rootControl; - SetupRootLayoutControl( rootControl ); - - // Create a parent layout - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - rootControl.Add( hbox ); - hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 ); - hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally. - - tet_infoline("Add a control without SetLayout being called but with layout required set true"); - - auto control = Control::New(); - control.SetName("Control1"); - DevelControl::SetLayoutingRequired( control, true ); - hbox.Add( control ); - control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - tet_infoline("Add a Textlabel to the control"); - auto textLabel = TextLabel::New("Test text"); - textLabel.SetName("TextLabel"); - control.Add( textLabel ); - - tet_infoline("Add another Textlabel to the control"); - auto largeTextLabel = TextLabel::New("Test large text"); - largeTextLabel.SetName("TextLabel-Large"); - control.Add( largeTextLabel ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("Test text is it's natural size"); - DALI_TEST_EQUALS( textLabel.GetProperty( Actor::Property::SIZE ), Vector3( 228.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - tet_infoline("Test text is centered in the control, the control is the size of the largest child"); - DALI_TEST_EQUALS( textLabel.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline("Test large text is it's natural size"); - DALI_TEST_EQUALS( largeTextLabel.GetProperty( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - tet_infoline("Test text is aligned to start as is the size of the control"); - DALI_TEST_EQUALS( largeTextLabel.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline("Test control is width of it's parent and height of it's largest child"); - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::SIZE ), Vector3( 382.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_LayoutGroup03(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_LayoutGroup03 - Test control with a LayoutGroup as a leaf"); - - Control rootControl; - SetupRootLayoutControl( rootControl ); - - // Create a parent layout - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - rootControl.Add( hbox ); - hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 ); - hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally. - - tet_infoline("Add a control without SetLayout being called"); - - auto control = Control::New(); - control.SetName("Control1"); - hbox.Add( control ); - control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("Test control is width of it's parent and exact given height"); - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - - -int UtcDaliLayouting_LayoutGroup04(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_LayoutGroup04 - Test control with a LayoutGroup as a leaf and with SetLayotRequired = true"); - - Control rootControl; - SetupRootLayoutControl( rootControl ); - - // Create a parent layout - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - rootControl.Add( hbox ); - hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 ); - hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally. - - tet_infoline("Add a control without SetLayout being called"); - - auto control = Control::New(); - control.SetName("Control1"); - DevelControl::SetLayoutingRequired( control, true ); - hbox.Add( control ); - control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("Test control is width of it's parent and exact given height"); - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::SIZE ), Vector3( 600.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_IsLayoutingRequired(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_IsLayoutingRequired - Test setting the SetLayoutRequired and then check if flag was set"); - - Control rootControl; - SetupRootLayoutControl( rootControl ); - - // Create a parent layout - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - rootControl.Add( hbox ); - hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 ); - hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally. - - tet_infoline("Add a control without SetLayout being called"); - - auto control = Control::New(); - control.SetName("Control1"); - DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), false, TEST_LOCATION ); - DevelControl::SetLayoutingRequired( control, true ); - hbox.Add( control ); - control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 100 ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("Test control is width of it's parent and exact given height"); - DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), true, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_LayoutGroupWithPadding01(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_LayoutGroupWithPadding01 - Test adding a control to a layout that has padding"); - - Control rootControl; - SetupRootLayoutControl( rootControl ); - - // Create a parent layout - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hbox.SetName( "HBox"); - rootControl.Add( hbox ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 ); - hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally. - - tet_infoline("Add a control without SetLayout being called"); - - auto control = Control::New(); - control.SetName("Control1"); - DevelControl::SetLayoutingRequired( control, true ); - hbox.Add( control ); - control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 ); - tet_printf( "Adding Padding to control"); - control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING ); - - tet_infoline("Add a Textlabel to the control"); - auto textLabel = TextLabel::New("Test text"); - textLabel.SetName("TextLabel"); - control.Add( textLabel ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("Test text is it's natural size"); - DALI_TEST_EQUALS( textLabel.GetProperty( Actor::Property::SIZE ), Vector3( 228.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - tet_infoline("Test control is size of it's child and control it's own padding"); - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::SIZE ), Vector3( 243.0f, 86.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_LayoutGroupWithChildMargin01(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayouting_LayoutGroupWithChildMargin01 - Test adding a control with padding to a layout that has padding"); - - Control rootControl; - SetupRootLayoutControl( rootControl ); - - // Create a parent layout - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hbox.SetName( "HBox"); - rootControl.Add( hbox ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 600 ); - hbox.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - hbox.SetAnchorPoint( AnchorPoint::TOP_LEFT ); // LinearLayout will eventually do this internally. - - tet_infoline("Add a control without SetLayout being called"); - - auto control = Control::New(); - control.SetName("Control1"); - DevelControl::SetLayoutingRequired( control, true ); - hbox.Add( control ); - control.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - control.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - const Extents CONTROL_PADDING = Extents(5, 10, 20, 2 ); - tet_printf( "Adding Padding to control"); - control.SetProperty( Toolkit::Control::Property::PADDING, CONTROL_PADDING ); - - tet_infoline("Add a Textlabel to the control"); - auto textLabel = TextLabel::New("Test text"); - const Extents CHILD_MARGIN = Extents( 10, 0, 5, 0 ); - textLabel.SetProperty( Toolkit::Control::Property::MARGIN, CHILD_MARGIN ); - textLabel.SetName("TextLabel"); - control.Add( textLabel ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("Test text is it's natural size"); - DALI_TEST_EQUALS( textLabel.GetProperty( Actor::Property::SIZE ), Vector3( 228.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - tet_infoline("Test control is width of it's parent and height of it's child"); - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::SIZE ), Vector3( 253.0f, 91.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_SetLayout(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_SetLayout - Test reusing layouts"); - - Control rootControl; - SetupRootLayoutControl( rootControl ); - - auto container = Control::New(); - auto horizontalLayout = LinearLayout::New(); - horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - DevelControl::SetLayout( container, horizontalLayout ); - container.SetName( "Container" ); - rootControl.Add( container ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 60 ) ); - - for( auto&& iter : controls ) - { - container.Add( iter ); - } - - container.SetParentOrigin( ParentOrigin::CENTER ); - container.SetAnchorPoint( AnchorPoint::CENTER ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Change a layout - auto verticalLayout = LinearLayout::New(); - verticalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL ); - DevelControl::SetLayout( container, verticalLayout ); - - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Second round - DevelControl::SetLayout( container, horizontalLayout ); - - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Change a layout - DevelControl::SetLayout( container, verticalLayout ); - - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_StageAdd(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_StageAdd"); - - Stage stage = Stage::GetCurrent(); - - AbsoluteLayout absoluteLayout = AbsoluteLayout::New(); - Control container = Control::New(); - container.SetName( "Container" ); - DevelControl::SetLayout( container, absoluteLayout ); - container.SetAnchorPoint( Dali::AnchorPoint::CENTER ); - container.SetParentOrigin( Dali::ParentOrigin::CENTER ); - - Control child = Control::New(); - child.SetAnchorPoint( Dali::AnchorPoint::TOP_LEFT ); - child.SetPosition( 0.0f, 0.0f ); - child.SetSize( 480.0f, 180.0f ); - child.SetName( "Child Control" ); - container.Add( child ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( child.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); // Not re-laid out - DALI_TEST_EQUALS( child.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(); - - // Add container to stage here - // Should call RequestLayout() to measure and layout - stage.Add( container ); - - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( child.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); // Stage Size - DALI_TEST_EQUALS( child.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 180.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-LayoutingAnimation.cpp b/automated-tests/src/dali-toolkit/utc-Dali-LayoutingAnimation.cpp deleted file mode 100644 index 9750070..0000000 --- a/automated-tests/src/dali-toolkit/utc-Dali-LayoutingAnimation.cpp +++ /dev/null @@ -1,1869 +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. - * - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include <../custom-layout.h> -#include - -#include - -using namespace Dali; -using namespace Toolkit; - -void utc_dali_toolkit_layouting_animation_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_toolkit_layouting_animation_cleanup(void) -{ - test_return_value = TET_PASS; -} - -namespace -{ - -// Functor to test whether a Finish signal is emitted -struct LayoutTransitionFinishCheck -{ - LayoutTransitionFinishCheck( bool& signalReceived ) - : mSignalReceived( signalReceived ) - { - } - - void operator()( LayoutTransitionData::Type type, LayoutTransitionData& layoutTransitionData ) - { - mSignalReceived = true; - } - - void Reset() - { - mSignalReceived = false; - } - - void CheckSignalReceived() - { - if (!mSignalReceived) - { - tet_printf("Expected Finish signal was not received\n"); - tet_result(TET_FAIL); - } - else - { - tet_result(TET_PASS); - } - } - - void CheckSignalNotReceived() - { - if (mSignalReceived) - { - tet_printf("Unexpected Finish signal was received\n"); - tet_result(TET_FAIL); - } - else - { - tet_result(TET_PASS); - } - } - - bool& mSignalReceived; // owned by individual tests -}; - -} // anon namespace - -int UtcDaliLayouting_LayoutTransitionDataConstructorP(void) -{ - TestApplication application; - - LayoutTransitionData layoutTransitionData; - - DALI_TEST_CHECK( !layoutTransitionData ); - END_TEST; -} - -int UtcDaliLayouting_LayoutTransitionDataNewP(void) -{ - TestApplication application; - - LayoutTransitionData layoutTransitionData = LayoutTransitionData::New(); - - DALI_TEST_CHECK(layoutTransitionData); - END_TEST; -} - -int UtcDaliLayouting_LayoutTransitionDataDownCastP(void) -{ - TestApplication application; - - LayoutTransitionData layoutTransitionData = LayoutTransitionData::New(); - BaseHandle object(layoutTransitionData); - - LayoutTransitionData layoutTransitionData2 = LayoutTransitionData::DownCast(object); - DALI_TEST_CHECK(layoutTransitionData2); - - LayoutTransitionData layoutTransitionData3 = DownCast< LayoutTransitionData >(object); - DALI_TEST_CHECK(layoutTransitionData2); - END_TEST; -} - -int UtcDaliLayouting_LayoutTransitionDataDownCastN(void) -{ - TestApplication application; - - BaseHandle unInitializedObject; - - LayoutTransitionData layoutTransitionData1 = LayoutTransitionData::DownCast( unInitializedObject ); - DALI_TEST_CHECK( !layoutTransitionData1 ); - - LayoutTransitionData layoutTransitionData2 = DownCast< LayoutTransitionData >( unInitializedObject ); - DALI_TEST_CHECK( !layoutTransitionData2 ); - END_TEST; -} - -int UtcDaliLayouting_LayoutTransitionDataSetGetTransition(void) -{ - TestApplication application; - - auto layout = LinearLayout::New(); - auto layoutTransitionData = LayoutTransitionData::New(); - - layout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == layoutTransitionData ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() ); - - layout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, LayoutTransitionData() ); - layout.SetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE, layoutTransitionData ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == layoutTransitionData ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() ); - - layout.SetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE, LayoutTransitionData() ); - layout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == layoutTransitionData ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() ); - - layout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, LayoutTransitionData() ); - layout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, layoutTransitionData ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == layoutTransitionData ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() ); - - layout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, LayoutTransitionData() ); - layout.SetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE, layoutTransitionData ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == layoutTransitionData ); - - END_TEST; -} - -int UtcDaliLayouting_SetLayoutTransition01(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_SetLayoutTransition01" ); - - Stage stage = Stage::GetCurrent(); - auto container = Control::New(); - auto horizontalLayout = LinearLayout::New(); - horizontalLayout.SetAnimateLayout( false ); - horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - - auto verticalLayout = LinearLayout::New(); - verticalLayout.SetAnimateLayout( false ); - verticalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL ); - - DevelControl::SetLayout( container, horizontalLayout ); - container.SetName( "Container"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 100, 100 ) ); - controls.push_back( CreateLeafControl( 100, 100 ) ); - for( auto&& iter : controls ) - { - container.Add( iter ); - } - stage.Add( container ); - - auto layoutTransitionData = LayoutTransitionData::New(); - { - // Instant resize for parent - Property::Map map; - map["property"] = "size"; - map["targetValue"] = Property::Value(); // capture from layout update - map["animator"] = Property::Map() - .Add("alphaFunction", "LINEAR") - .Add("timePeriod", Property::Map() - .Add("delay", 0.0f) - .Add("duration", 0.0f)); - layoutTransitionData.AddPropertyAnimator( container, map ); - } - { - Property::Map map; - map["property"] = "opacity"; - map["initialValue"] = 0.0f; - map["targetValue"] = 1.0f; - map["animator"] = Property::Map() - .Add("alphaFunction", "LINEAR") - .Add("timePeriod", Property::Map() - .Add("delay", 0.0f) - .Add("duration", 0.5f)); - layoutTransitionData.AddPropertyAnimator( container, map ); - } - { - // Instant position for children - Property::Map map; - map["property"] = "position"; - map["animator"] = Property::Map() - .Add("alphaFunction", "LINEAR") - .Add("timePeriod", Property::Map() - .Add("delay", 0.0f) - .Add("duration", 0.0f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { - // Grow children from (0,0) size to full size (captured) - Property::Map map; - map["property"] = "size"; - map["initialValue"] = Vector3( 0.0f, 0.0f, 0 ); - map["animator"] = Property::Map() - .Add("alphaFunction", "LINEAR") - .Add("timePeriod", Property::Map() - .Add("delay", 0.0f) - .Add("duration", 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); - } - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - // First round, no animation - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - bool signalReceived(false); - LayoutTransitionFinishCheck finishCheck(signalReceived); - layoutTransitionData.FinishedSignal().Connect(&application, finishCheck); - - horizontalLayout.SetAnimateLayout( true ); - verticalLayout.SetAnimateLayout( true ); - - // Change a layout, start transition - verticalLayout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, layoutTransitionData ); - DevelControl::SetLayout( container, verticalLayout ); - - application.SendNotification(); - application.Render( 1u /*just very beginning of the animation*/ ); - - finishCheck.CheckSignalNotReceived(); - // Second round, animation just started - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( container.GetCurrentOpacity(), 0.0f, 0.1f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); - - // Third round, animation just finished - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( container.GetCurrentOpacity(), 1.0f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render( 10u /* wait a bit more for a signal */ ); - - finishCheck.CheckSignalReceived(); - - // Now sizes and positions are finally set - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - // Transition back now with default transition - DevelControl::SetLayout( container, horizontalLayout ); - - application.SendNotification(); - application.Render( 1u /*just very beginning of the animation*/ ); - - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( container.GetCurrentOpacity(), 1.0f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 1.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 1.0f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); - - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( container.GetCurrentOpacity(), 1.0f, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render( 10u /* wait a bit more for complete default animation */ ); - - // Now sizes and positions are finally set - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_AddChildLayoutTransition01(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition01" ); - - Stage stage = Stage::GetCurrent(); - auto container = Control::New(); - auto horizontalLayout = LinearLayout::New(); - horizontalLayout.SetAnimateLayout( true ); - horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - - DevelControl::SetLayout( container, horizontalLayout ); - container.SetName( "Container"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 100, 100 ) ); - stage.Add( container ); - - auto layoutTransitionData = LayoutTransitionData::New(); - { - // Instant resize for parent - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "size"; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( container, map ); - } - { - // Instant position for a child - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::NONE; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "position"; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { - // Grow a child from (0,0) size to full size (captured) - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_ADD; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "size"; - map[ LayoutTransitionData::AnimatorKey::INITIAL_VALUE ] = Vector3( 0.0f, 0.0f, 0 ); - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to an added child - } - - horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData ); - container.Add( controls[0] ); - - bool signalReceived(false); - LayoutTransitionFinishCheck finishCheck(signalReceived); - layoutTransitionData.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render( 1u /*just very beginning of the animation*/ ); - - finishCheck.CheckSignalNotReceived(); - // The animation just started - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); - - // The animation just finished - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render( 10u /* wait a bit more for a signal */ ); - - // Now sizes and positions are finally set - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - finishCheck.CheckSignalReceived(); - - END_TEST; -} - -int UtcDaliLayouting_RemoveChildLayoutTransition01(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_RemoveChildLayoutTransition01" ); - - Stage stage = Stage::GetCurrent(); - auto container = Control::New(); - auto horizontalLayout = LinearLayout::New(); - horizontalLayout.SetAnimateLayout( false ); - horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - - DevelControl::SetLayout( container, horizontalLayout ); - container.SetName( "Container" ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 100, 100 ) ); - controls.push_back( CreateLeafControl( 100, 100 ) ); - - stage.Add( container ); - container.Add( controls[0] ); - container.Add( controls[1] ); - - // Initial rendering done - application.SendNotification(); - application.Render(); - - horizontalLayout.SetAnimateLayout( true ); - - auto layoutTransitionData = LayoutTransitionData::New(); - { - // Instant resize for parent width - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_WIDTH; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" ) - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( container, map ); - } - { - // Instant resize for parent height - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_HEIGHT; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" ) - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( container, map ); - } - { - // Instant position for parent X position - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_X; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" ) - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( container, map ); - } - { - // Instant position for parent Y position - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_Y; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" ) - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( container, map ); - } - { - // Shrink the children - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_WIDTH; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 0.0f; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" ) - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); - } - { - // Shrink the children - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_HEIGHT; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 0.0f; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" ) - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); - } - { - // Shrink the removed child - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_REMOVE; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Size( 0.0f, 0.0f ); - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" ) - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); - } - { - // Instant position for children - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_X; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" ) - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { - // Instant position for children - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_Y; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" ) - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - - horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE, layoutTransitionData ); - container.Remove( controls[1] ); - - bool signalReceived(false); - LayoutTransitionFinishCheck finishCheck(signalReceived); - layoutTransitionData.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render( 1u /*just very beginning of the animation*/ ); - - finishCheck.CheckSignalNotReceived(); - // Animation just started - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); - // this control is already removed from the tree. - DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); - - // Animation just finished - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - // this control is already removed from the tree. - DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION ); - // this control is already removed from the tree. - DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render( 10u /* wait a bit more for a signal */ ); - - // Now sizes and positions are finally set - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - // this control is already removed from the tree. - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - // this control is already removed from the tree. - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); - - finishCheck.CheckSignalReceived(); - - END_TEST; -} - -int UtcDaliLayouting_FocusChildLayoutTransition01(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_FocusChildLayoutTransition01" ); - - Stage stage = Stage::GetCurrent(); - auto container = Control::New(); - auto horizontalLayout = LinearLayout::New(); - horizontalLayout.SetAnimateLayout( false ); - horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - - DevelControl::SetLayout( container, horizontalLayout ); - container.SetName( "Container" ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 100, 100 ) ); - controls.push_back( CreateLeafControl( 100, 100 ) ); - - stage.Add( container ); - container.Add( controls[0] ); - container.Add( controls[1] ); - - KeyInputFocusManager manager = KeyInputFocusManager::Get(); - manager.SetFocus( controls[0] ); - - // Initial rendering done - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - horizontalLayout.SetAnimateLayout( true ); - - auto layoutTransitionData = LayoutTransitionData::New(); - { - // Instant resize for parent - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( container, map ); - } - { - // Instant position for parent - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { - // Shrink the lost focus child - Property::Map map; - map[ "affectsSiblings" ] = false; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; - map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 80.0f, 80.0f, 0 ); - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child - } - { - // Grow the gained focus child - Property::Map map; - map[ "affectsSiblings" ] = false; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; - map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_GAINED; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 120.0f, 120.0f, 0 ); - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus gained child - } - - horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData ); - - bool signalReceived(false); - LayoutTransitionFinishCheck finishCheck(signalReceived); - layoutTransitionData.FinishedSignal().Connect(&application, finishCheck); - manager.SetFocus( controls[1] ); - - application.SendNotification(); - application.Render( 1u /*just very beginning of the animation*/ ); - - finishCheck.CheckSignalNotReceived(); - // Animation just started - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); - - // Animation just finished - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 80.0f, 80.0f, 0.0f ), 1.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 120.0f, 120.0f, 0.0f ), 1.0f, TEST_LOCATION ); - - application.SendNotification(); - application.Render( 10u /* wait a bit more for a signal */ ); - - // Now sizes and positions are finally set - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - finishCheck.CheckSignalReceived(); - - END_TEST; -} - -int UtcDaliLayouting_FocusChildLayoutTransition02(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_FocusChildLayoutTransition02" ); - - Stage stage = Stage::GetCurrent(); - auto container = Control::New(); - auto horizontalLayout = LinearLayout::New(); - horizontalLayout.SetAnimateLayout( false ); - horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - - DevelControl::SetLayout( container, horizontalLayout ); - container.SetName( "Container" ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 100, 100 ) ); - controls.push_back( CreateLeafControl( 100, 100 ) ); - - stage.Add( container ); - container.Add( controls[0] ); - container.Add( controls[1] ); - - KeyInputFocusManager manager = KeyInputFocusManager::Get(); - manager.SetFocus( controls[0] ); - - // Initial rendering done - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - horizontalLayout.SetAnimateLayout( true ); - - auto layoutTransitionData = LayoutTransitionData::New(); - { - // Shrink the lost focus child width - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = false; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION; - map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // move all children - } - { - // Shrink the lost focus child width - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_WIDTH; - map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 80.0f; - map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child - } - { - // Shrink the lost focus child height - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE_HEIGHT; - map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 80.0f; - map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child - } - { - // Grow the gained focus child - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; - map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_GAINED; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 120.0f, 120.0f, 0 ); - map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus gained child - } - - horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData ); - - bool signalReceived(false); - LayoutTransitionFinishCheck finishCheck(signalReceived); - layoutTransitionData.FinishedSignal().Connect(&application, finishCheck); - manager.SetFocus( controls[1] ); - - application.SendNotification(); - application.Render( 1u /*just very beginning of the animation*/ ); - - finishCheck.CheckSignalNotReceived(); - // Animation just started - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); - - // Animation just finished - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 360.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 80.0f, 340.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 80.0f, 80.0f, 0.0f ), 1.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 120.0f, 120.0f, 0.0f ), 1.0f, TEST_LOCATION ); - - application.SendNotification(); - application.Render( 10u /* wait a bit more for a signal */ ); - - // Now sizes and positions are finally set - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 360.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 80.0f, 340.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - finishCheck.CheckSignalReceived(); - - END_TEST; -} - -int UtcDaliLayouting_FocusChildLayoutTransition03(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_FocusChildLayoutTransition03" ); - - Stage stage = Stage::GetCurrent(); - auto container = Control::New(); - auto horizontalLayout = LinearLayout::New(); - horizontalLayout.SetAnimateLayout( false ); - horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - - DevelControl::SetLayout( container, horizontalLayout ); - container.SetName( "Container" ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 100, 100 ) ); - controls.push_back( CreateLeafControl( 100, 100 ) ); - - stage.Add( container ); - container.Add( controls[0] ); - container.Add( controls[1] ); - - KeyInputFocusManager manager = KeyInputFocusManager::Get(); - manager.SetFocus( controls[0] ); - - // Initial rendering done - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - horizontalLayout.SetAnimateLayout( true ); - - auto layoutTransitionData = LayoutTransitionData::New(); - { - // Shrink the lost focus child width - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = false; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION; - map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // move all children - } - { - // Shrink the lost focus child width - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SCALE_X; - map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 0.8f; - map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child - } - { - // Shrink the lost focus child height - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SCALE_Y; - map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = 0.8f; - map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child - } - { - // Grow the gained focus child - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ] = true; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SCALE; - map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_GAINED; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 1.2f, 1.2f, 1.0f ); - map[ LayoutTransitionData::AnimatorKey::TYPE ] = LayoutTransitionData::Animator::ANIMATE_TO; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus gained child - } - - horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData ); - - bool signalReceived(false); - LayoutTransitionFinishCheck finishCheck(signalReceived); - layoutTransitionData.FinishedSignal().Connect(&application, finishCheck); - manager.SetFocus( controls[1] ); - - application.SendNotification(); - application.Render( 1u /*just very beginning of the animation*/ ); - - finishCheck.CheckSignalNotReceived(); - // Animation just started - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); - - // Animation just finished - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( -10.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 90.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize() * controls[0].GetCurrentScale(), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentSize() * controls[1].GetCurrentScale(), Vector3( 120.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render( 10u /* wait a bit more for a signal */ ); - - // Now sizes and positions are finally set - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( -10.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 90.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ) * controls[0].GetProperty( Actor::Property::SCALE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ) * controls[1].GetProperty( Actor::Property::SCALE ), Vector3( 120.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - finishCheck.CheckSignalReceived(); - - END_TEST; -} - -int UtcDaliLayouting_AddChildLayoutTransition02_KeyFrames(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition02_KeyFrames" ); - - Stage stage = Stage::GetCurrent(); - auto container = Control::New(); - auto horizontalLayout = LinearLayout::New(); - horizontalLayout.SetAnimateLayout( true ); - horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - - DevelControl::SetLayout( container, horizontalLayout ); - container.SetName( "Container"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 100, 100 ) ); - stage.Add( container ); - - auto layoutTransitionData = LayoutTransitionData::New(); - { - // Instant resize for parent - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( container, map ); - } - { - // Instant position for a child - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { - // Grow a child from (0,0) size to full size with key frames - KeyFrames keyFrames = KeyFrames::New(); - keyFrames.Add( 0.0f, Vector3( 0.0f, 0.0f, 0 ) ); - keyFrames.Add( 0.5f, Vector3( 100.0f, 100.0f, 0 ) ); - - Property::Map map; - map[ "property" ] = Actor::Property::SIZE; - map[ "condition" ] = LayoutTransitionData::Condition::ON_ADD; - map[ "animator" ] = Property::Map() - .Add( "type", "ANIMATE_BETWEEN") - .Add( "alphaFunction", "LINEAR") - .Add( "timePeriod", Property::Map() - .Add( "delay", 0.0f) - .Add( "duration", 0.5f)); - layoutTransitionData.AddPropertyAnimator( Actor(), map, keyFrames, Animation::Interpolation::Linear ); - } - - horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData ); - container.Add( controls[0] ); - - bool signalReceived(false); - LayoutTransitionFinishCheck finishCheck(signalReceived); - layoutTransitionData.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render( 1u /*just very beginning of the animation*/ ); - - finishCheck.CheckSignalNotReceived(); - // The animation just started - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); - - // The animation just finished - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render( 10u /* wait a bit more for a signal */ ); - - // Now sizes and positions are finally set - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - finishCheck.CheckSignalReceived(); - - END_TEST; -} - -int UtcDaliLayouting_AddChildLayoutTransition03_Path(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition03_Path" ); - - Stage stage = Stage::GetCurrent(); - auto container = Control::New(); - auto horizontalLayout = LinearLayout::New(); - horizontalLayout.SetAnimateLayout( true ); - horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - - DevelControl::SetLayout( container, horizontalLayout ); - container.SetName( "Container"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 100, 100 ) ); - stage.Add( container ); - - auto layoutTransitionData = LayoutTransitionData::New(); - { - // Instant resize for parent - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( container, map ); - } - - Dali::Path path = Dali::Path::New(); - { - // Curve position for a child - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_PATH") - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f ) ); - - // Build the path - Vector3 position0( 30.0, 80.0, 0.0 ); - Vector3 position1( 70.0, 120.0, 0.0 ); - Vector3 position2( 0.0, 350.0, 0.0 ); - - //Dali::Path path = Dali::Path::New(); - path.AddPoint( position0 ); - path.AddPoint( position1 ); - path.AddPoint( position2 ); - - // Control points for first segment - path.AddControlPoint( Vector3( 39.0, 90.0, 0.0 ) ); - path.AddControlPoint( Vector3( 56.0, 119.0, 0.0 ) ); - - // Control points for second segment - path.AddControlPoint( Vector3( 78.0, 120.0, 0.0 ) ); - path.AddControlPoint( Vector3( 93.0, 104.0, 0.0 ) ); - - layoutTransitionData.AddPropertyAnimator( controls[0], map, path, Vector3::XAXIS ); - } - { - // Grow a child from (0,0) size to full size (captured) - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "size"; - map[ LayoutTransitionData::AnimatorKey::INITIAL_VALUE ] = Vector3( 0.0f, 0.0f, 0 ); - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( controls[0], map ); - } - - horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData ); - container.Add( controls[0] ); - - bool signalReceived(false); - LayoutTransitionFinishCheck finishCheck(signalReceived); - layoutTransitionData.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render( 0 ); - - finishCheck.CheckSignalNotReceived(); - // The animation just started - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - Vector3 position, tangent; - Quaternion rotation; - path.Sample( 0.0f, position, tangent ); - rotation = Quaternion( Vector3::XAXIS, tangent ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), position, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentOrientation(), rotation, 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); - - path.Sample( 1.0f, position, tangent ); - rotation = Quaternion( Vector3::XAXIS, tangent ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), position, 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentOrientation(), rotation, 0.0001f, TEST_LOCATION ); - - // The animation just finished - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render( 10u /* wait a bit more for a signal */ ); - - // Now sizes and positions are finally set - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - finishCheck.CheckSignalReceived(); - - END_TEST; -} - -int UtcDaliLayouting_AddChildLayoutTransition04_AnimateBy(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition04_AnimateBy" ); - - Stage stage = Stage::GetCurrent(); - auto container = Control::New(); - auto horizontalLayout = LinearLayout::New(); - horizontalLayout.SetAnimateLayout( true ); - horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - - DevelControl::SetLayout( container, horizontalLayout ); - container.SetName( "Container"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 100, 100 ) ); - stage.Add( container ); - - auto layoutTransitionData = LayoutTransitionData::New(); - { - // Instant resize for parent - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( container, map ); - } - { - // Instant position for a child - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 10.0f, 10.0f, 0 ); - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_BY") - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( controls[0], map ); - } - - horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData ); - container.Add( controls[0] ); - - bool signalReceived(false); - LayoutTransitionFinishCheck finishCheck(signalReceived); - layoutTransitionData.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render( 1u /*just very beginning of the animation*/ ); - - finishCheck.CheckSignalNotReceived(); - // The animation just started - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render( static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); - - // The animation just finished - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 110.0f, 110.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render( 10u /* wait a bit more for a signal */ ); - - // Now sizes and positions are finally set - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 110.0f, 110.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - finishCheck.CheckSignalReceived(); - - END_TEST; -} - -int UtcDaliLayouting_AddChildLayoutTransition05(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_AddChildLayoutTransition05" ); - - Stage stage = Stage::GetCurrent(); - auto container = Control::New(); - auto horizontalLayout = LinearLayout::New(); - horizontalLayout.SetAnimateLayout( true ); - horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - - DevelControl::SetLayout( container, horizontalLayout ); - container.SetName( "Container"); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 100, 100 ) ); - stage.Add( container ); - - auto layoutTransitionData = LayoutTransitionData::New(); - { - // Instant resize for parent - Property::Map map; - map[ "property" ] = Actor::Property::SIZE; - map[ "targetValue" ] = Property::Value(); // capture from layout update - map[ "animator" ] = Property::Map() - .Add( "name", "InstantAnimator" ) - .Add( "type", "ANIMATE_TO") - .Add( "alphaFunction", "LINEAR" ) - .Add( "timePeriod", Property::Map() - .Add( "delay", 0.0f ) - .Add( "duration", 0.0f ) ); - layoutTransitionData.AddPropertyAnimator( container, map ); - } - { - // Instant position for a child - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::COLOR_ALPHA; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = "InstantAnimator"; - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { - // Grow a child from (0,0) size to full size (captured) - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; - map[ LayoutTransitionData::AnimatorKey::INITIAL_VALUE ] = Vector3( 0.0f, 0.0f, 0 ); - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = std::string(); - layoutTransitionData.AddPropertyAnimator( controls[0], map ); - } - { - // Instant opacity for a child, for testing - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = "InstantAnimator"; - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - - // Just throw all other alpha functions in - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "WRONG" ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "REVERSE" ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_SQUARE" ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT_SQUARE" ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN" ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN" ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT" ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_OUT" ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_OUT_SINE" ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_IN_SINE" ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT_SINE" ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "BOUNCE" ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "SIN" ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "EASE_OUT_BACK" ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, Vector4( 0.0f, 1.0f, 2.0f, 3.0f ) ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - // valid - Property::Array array; - array.Reserve( 4 ); - array.PushBack( 0.0f ); - array.PushBack( 1.0f ); - array.PushBack( 2.0f ); - array.PushBack( 3.0f ); - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, array ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - // invalid - Property::Array array; - array.Reserve( 3 ); - array.PushBack( 0.0f ); - array.PushBack( 1.0f ); - array.PushBack( 2.0f ); - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, array ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - // invalid - Property::Array array; - array.Reserve( 4 ); - array.PushBack( 0.0f ); - array.PushBack( 10 ); - array.PushBack( 2.0f ); - array.PushBack( 3.0f ); - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, array ); - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - { // no property, not going to be used, but going to be parsed - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = 0; // invalid - layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent - } - - horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData ); - container.Add( controls[0] ); - - bool signalReceived(false); - LayoutTransitionFinishCheck finishCheck(signalReceived); - layoutTransitionData.FinishedSignal().Connect(&application, finishCheck); - - application.SendNotification(); - application.Render( 1u /*just very beginning of the animation*/ ); - - finishCheck.CheckSignalNotReceived(); - // The animation just started - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 1.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION ); - - application.SendNotification(); - application.Render(static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); - - // The animation just finished - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - application.SendNotification(); - application.Render( 10u /* wait a bit more for a signal */ ); - - // Now sizes and positions are finally set - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - finishCheck.CheckSignalReceived(); - - END_TEST; -} - -int UtcDaliLayouting_DefaultTransition01(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_DefaultTransition01" ); - - Stage stage = Stage::GetCurrent(); - auto container = Control::New(); - auto horizontalLayout = LinearLayout::New(); - horizontalLayout.SetAnimateLayout( false ); - horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - - DevelControl::SetLayout( container, horizontalLayout ); - container.SetName( "Container" ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 100, 100 ) ); - controls.push_back( CreateLeafControl( 100, 100 ) ); - - stage.Add( container ); - container.Add( controls[0] ); - container.Add( controls[1] ); - - // Initial rendering done - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - horizontalLayout.SetAnimateLayout( true ); - - auto layoutTransitionData0 = LayoutTransitionData::New(); - { - // Default instant resize - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData0.AddPropertyAnimator( controls[0], map ); - } - { - // Instant instant position - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData0.AddPropertyAnimator( controls[0], map ); - } - DevelControl::GetLayout( controls[0] ).SetTransitionData( LayoutTransitionData::Type::ON_LAYOUT_CHANGE, layoutTransitionData0 ); - - auto layoutTransitionData1 = LayoutTransitionData::New(); - { - // Default instant resize - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData1.AddPropertyAnimator( controls[1], map ); - } - { - // Instant instant position - Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION; - map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); - layoutTransitionData1.AddPropertyAnimator( controls[1], map ); - } - DevelControl::GetLayout( controls[1] ).SetTransitionData( LayoutTransitionData::Type::ON_LAYOUT_CHANGE, layoutTransitionData1 ); - - horizontalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL ); - - application.SendNotification(); - application.Render( 10u /*just very beginning of the animation*/ ); - - // Animation just finished - DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); - - // Now sizes and positions are set - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_CheckResourceLeak01(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_CheckResourceLeak01 - Remove animating layout and add child to stage" ); - - Dali::Toolkit::Impl::DummyControl::constructorCount = 0; - Dali::Toolkit::Impl::DummyControl::destructorCount = 0; - - Stage stage = Stage::GetCurrent(); - auto container = Control::New(); - auto linearLayout = LinearLayout::New(); - linearLayout.SetAnimateLayout( true ); - - DevelControl::SetLayout( container, linearLayout ); - container.SetName( "Container" ); - - stage.Add( container ); - - DummyControl control = DummyControl::New( true ); - control.SetName( "DummyControl01" ); - control.SetSize( 100, 100 ); - container.Add( control ); - - control = DummyControl::New( true ); - control.SetName( "DummyControl02" ); - control.SetSize( 100, 100 ); - container.Add( control ); - - linearLayout.SetAnimateLayout( true ); - - DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::constructorCount, 2, TEST_LOCATION ); - DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::destructorCount, 0, TEST_LOCATION ); - - // Initial rendering done - application.SendNotification(); - application.Render(static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); - - DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::constructorCount, 2, TEST_LOCATION ); - DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::destructorCount, 0, TEST_LOCATION ); - - stage.Remove( container ); - container.Reset(); - - application.SendNotification(); - application.Render(static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); - - DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::constructorCount, 2, TEST_LOCATION ); - DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::destructorCount, 1, TEST_LOCATION ); - - Stage::GetCurrent().Add( control ); - - application.SendNotification(); - application.Render(static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); - - DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::constructorCount, 2, TEST_LOCATION ); - DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::destructorCount, 1, TEST_LOCATION ); - - stage.Remove( control ); - control.Reset(); - - application.SendNotification(); - application.Render(static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); - - DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::constructorCount, 2, TEST_LOCATION ); - DALI_TEST_EQUALS( Dali::Toolkit::Impl::DummyControl::destructorCount, 2, TEST_LOCATION ); - - END_TEST; -} - diff --git a/automated-tests/src/dali-toolkit/utc-Dali-LayoutingNesting.cpp b/automated-tests/src/dali-toolkit/utc-Dali-LayoutingNesting.cpp deleted file mode 100755 index cbfb6ed..0000000 --- a/automated-tests/src/dali-toolkit/utc-Dali-LayoutingNesting.cpp +++ /dev/null @@ -1,254 +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. - * - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include <../custom-layout.h> - -#include - -using namespace Dali; -using namespace Toolkit; - -namespace -{ - -// Turns the given control into a Root layout control and adds it to the stage. -void SetupRootLayoutControl( Control& rootControl ) -{ - rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "RootAbsoluteLayout" ); - Stage stage = Stage::GetCurrent(); - stage.Add( rootControl ); -} - -} // unnamed namespace - -void utc_dali_toolkit_layouting_nesting_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_toolkit_layouting_nesting_cleanup(void) -{ - test_return_value = TET_PASS; -} - -// Test nesting of Layouts and Controls - -int UtcDaliLayoutingNesting_01(void) -{ - /* - - Root - | - Control (LinearLayout Horizontal) - | - Control (LinearLayout Vertical) - | - LeafControl - - */ - - ToolkitTestApplication application; - tet_infoline("UtcDaliLayoutingNesting_01 - Nesting a LinearLayout (MATCH_PARENT) containing a leaf control within a LinearLayout"); - - auto rootControl = Control::New(); - SetupRootLayoutControl( rootControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "hBox" ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 480 ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 800 ); - - - auto vbox = Control::New(); - auto vboxLayout = LinearLayout::New(); - vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL ); - DevelControl::SetLayout( vbox, vboxLayout ); - vbox.SetName( "vBox" ); - vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox.Add( vbox ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - - for( auto&& iter : controls ) - { - vbox.Add( iter ); - } - - rootControl.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( hbox.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( vbox.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayoutingNesting_02(void) -{ - /* - - Root - | - Control (LinearLayout Horizontal) - | | - Control (LinearLayout Vertical) - | | - LeafControl - - */ - - ToolkitTestApplication application; - tet_infoline("UtcDaliLayoutingNesting_02 - Nesting a LinearLayout (MATCH_PARENT) containing a leaf control within a LinearLayout"); - tet_infoline("Then change the parent's size and test child responded correctly"); - - auto rootControl = Control::New(); - SetupRootLayoutControl( rootControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "hBox" ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 480 ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, 800 ); - - - auto vbox = Control::New(); - auto vboxLayout = LinearLayout::New(); - vboxLayout.SetOrientation( LinearLayout::Orientation::VERTICAL ); - DevelControl::SetLayout( vbox, vboxLayout ); - vbox.SetName( "vBox" ); - vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - vbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox.Add( vbox ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - - for( auto&& iter : controls ) - { - vbox.Add( iter ); - } - - rootControl.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( hbox.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( vbox.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 400 ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - - DALI_TEST_EQUALS( hbox.GetProperty( Actor::Property::SIZE ), Vector3( 400.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( vbox.GetProperty( Actor::Property::SIZE ), Vector3( 400.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayoutingNesting_LeafSizeChange(void) -{ - /* - Root - | - Control (LayoutingRequired) - | - Control (LinearLayout Horizontal) (WRAP_CONTENT) - | | - TextLabel - */ - - ToolkitTestApplication application; - tet_infoline("UtcDaliLayoutingNesting_LeafSizeChange - Nesting a TextLabel within a layout that is parented to a control"); - tet_infoline("Then change the TextLabels size and test the parent resized to wrap the new size"); - - auto rootControl = Control::New(); - SetupRootLayoutControl( rootControl ); - - auto control = Control::New(); - DevelControl::SetLayoutingRequired( control, true ); - control.SetName( "control" ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "hBox" ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT ); - - control.Add( hbox ); - - TextLabel textLabel = CreateTextLabel("SmallText" ); - - hbox.Add( textLabel ); - - rootControl.Add( control ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( hbox.GetProperty( Actor::Property::SIZE ), Vector3( 254.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( textLabel.GetProperty( Actor::Property::SIZE ), Vector3( 254.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - tet_infoline("Changing to longer text"); - textLabel.SetProperty( TextLabel::Property::TEXT, "muchlongerText" ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( hbox.GetProperty( Actor::Property::SIZE ), Vector3( 426.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( textLabel.GetProperty( Actor::Property::SIZE ), Vector3( 426.0f, 64.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-LayoutingResizePolicy.cpp b/automated-tests/src/dali-toolkit/utc-Dali-LayoutingResizePolicy.cpp deleted file mode 100644 index 23923ce..0000000 --- a/automated-tests/src/dali-toolkit/utc-Dali-LayoutingResizePolicy.cpp +++ /dev/null @@ -1,393 +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. - * - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include <../custom-layout.h> - -#include - -using namespace Dali; -using namespace Toolkit; - -namespace -{ - -// Turns the given control into a Root layout control and adds it to the stage. -void SetupRootLayoutControl( Control& rootControl ) -{ - rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "RootAbsoluteLayout" ); - Stage stage = Stage::GetCurrent(); - stage.Add( rootControl ); -} - -} // unnamed namespace - -void utc_dali_toolkit_layouting_resize_policy_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_toolkit_layouting_resize_policy_cleanup(void) -{ - test_return_value = TET_PASS; -} - -// Test setting of the MeasureSpecs with the legacy ResizePolicies - -int UtcDaliLayoutingResizePolicy_01(void) -{ - /* - Root - | - Control (LinearLayout Horizontal) - | - Control (LayoutingRequired) - | - Control (ResizePolicy::FILL_TO_PARENT) - | - LeafControl - */ - - ToolkitTestApplication application; - tet_infoline("UtcDaliLayoutingResizePolicy_01 - Set ResizePolicy FILL_TO_PARENT on Control"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - SetupRootLayoutControl( rootControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "hBox" ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - auto layoutingControl = Control::New(); - layoutingControl.SetName( "layoutingRequiredControl" ); - DevelControl::SetLayoutingRequired( layoutingControl, true ); - layoutingControl.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - layoutingControl.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox.Add( layoutingControl ); - - auto control = Control::New(); - control.SetName( "fillToParentControl" ); - DevelControl::SetLayoutingRequired( control, true ); - control.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - layoutingControl.Add( control ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - - for( auto&& iter : controls ) - { - control.Add( iter ); - } - - rootControl.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), true , 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - - -int UtcDaliLayoutingResizePolicy_02(void) -{ - /* - Root - | - Control (LinearLayout Horizontal) - | - Control (LayoutingRequired) - | - Control (ResizePolicy::FIT_TO_CHILDREN) - | - LeafControl - */ - - ToolkitTestApplication application; - tet_infoline("UtcDaliLayoutingResizePolicy_02 - Set ResizePolicy FIT_TO_CHILDREN on Control"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - SetupRootLayoutControl( rootControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "hBox" ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - auto layoutingControl = Control::New(); - layoutingControl.SetName( "layoutingRequiredControl" ); - DevelControl::SetLayoutingRequired( layoutingControl, true ); - layoutingControl.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - layoutingControl.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox.Add( layoutingControl ); - - auto control = Control::New(); - control.SetName( "fitToChildrenControl" ); - DevelControl::SetLayoutingRequired( control, true ); - control.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS ); - layoutingControl.Add( control ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - - for( auto&& iter : controls ) - { - control.Add( iter ); - } - - rootControl.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), true , 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayoutingResizePolicy_03(void) -{ - /* - Root - | - Control (LinearLayout Horizontal) - | - Control (LayoutingRequired) - | - Control (ResizePolicy::SIZE_RELATIVE_TO_PARENT) - | - LeafControl - */ - - ToolkitTestApplication application; - tet_infoline("UtcDaliLayoutingResizePolicy_03 - Set ResizePolicy SIZE_RELATIVE_TO_PARENT on Control"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - SetupRootLayoutControl( rootControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "hBox" ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - auto layoutingControl = Control::New(); - layoutingControl.SetName( "layoutingRequiredControl" ); - DevelControl::SetLayoutingRequired( layoutingControl, true ); - layoutingControl.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - layoutingControl.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox.Add( layoutingControl ); - - auto control = Control::New(); - control.SetName( "fitToChildrenControl" ); - DevelControl::SetLayoutingRequired( control, true ); - control.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); - control.SetSizeModeFactor( Vector3( 0.50f, 1.0f, 1.0f ) ); - layoutingControl.Add( control ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - - for( auto&& iter : controls ) - { - control.Add( iter ); - } - - rootControl.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), true , 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::SIZE ), Vector3( 240.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayoutingResizePolicy_04(void) -{ - /* - Root - | - Control (LinearLayout Horizontal) - | - Control (LayoutingRequired) - | - Control (ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT) - | - LeafControl - */ - - ToolkitTestApplication application; - tet_infoline("UtcDaliLayoutingResizePolicy_04 - Set ResizePolicy SIZE_FIXED_OFFSET_FROM_PARENT on Control"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - SetupRootLayoutControl( rootControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "hBox" ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - auto layoutingControl = Control::New(); - layoutingControl.SetName( "layoutingRequiredControl" ); - DevelControl::SetLayoutingRequired( layoutingControl, true ); - layoutingControl.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - layoutingControl.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox.Add( layoutingControl ); - - auto control = Control::New(); - control.SetName( "fitToChildrenControl" ); - DevelControl::SetLayoutingRequired( control, true ); - control.SetResizePolicy( ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT, Dimension::ALL_DIMENSIONS ); - control.SetSizeModeFactor( Vector3( -100.0f, 10.0f, 0.0f ) ); - layoutingControl.Add( control ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - - for( auto&& iter : controls ) - { - control.Add( iter ); - } - - rootControl.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), true , 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::SIZE ), Vector3( 380.0f, 810.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayoutingResizePolicy_05(void) -{ - /* - Root - | - Control (LinearLayout Horizontal) - | - Control (LayoutingRequired) - | - Control (ResizePolicy::FIXED) - | - LeafControl - */ - - ToolkitTestApplication application; - tet_infoline("UtcDaliLayoutingResizePolicy_05 - Set ResizePolicy FIXED on Control"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - SetupRootLayoutControl( rootControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - hboxLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "hBox" ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - - auto layoutingControl = Control::New(); - layoutingControl.SetName( "layoutingRequiredControl" ); - DevelControl::SetLayoutingRequired( layoutingControl, true ); - layoutingControl.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - layoutingControl.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::MATCH_PARENT ); - hbox.Add( layoutingControl ); - - auto control = Control::New(); - control.SetName( "fitToChildrenControl" ); - DevelControl::SetLayoutingRequired( control, true ); - control.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); - control.SetSize( Vector3( 300.0f, 300.0f, 0.0f ) ); - layoutingControl.Add( control ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - - for( auto&& iter : controls ) - { - control.Add( iter ); - } - - rootControl.Add( hbox ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - DALI_TEST_EQUALS( DevelControl::IsLayoutingRequired( control ), true , 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( control.GetProperty( Actor::Property::SIZE ), Vector3( 300.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} \ No newline at end of file diff --git a/automated-tests/src/dali-toolkit/utc-Dali-LayoutingSettingAndRemoval.cpp b/automated-tests/src/dali-toolkit/utc-Dali-LayoutingSettingAndRemoval.cpp deleted file mode 100644 index 7e12c1c..0000000 --- a/automated-tests/src/dali-toolkit/utc-Dali-LayoutingSettingAndRemoval.cpp +++ /dev/null @@ -1,317 +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. - * - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - - -#include - -using namespace Dali; -using namespace Toolkit; - -namespace -{ - -// Turns the given control into a Root layout control and adds it to the stage. -void SetupRootLayoutControl( Control& rootControl ) -{ - rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "RootAbsoluteLayout" ); - Stage stage = Stage::GetCurrent(); - stage.Add( rootControl ); -} - -} // unnamed namespace - -void utc_dali_toolkit_layouting_setting_and_removal_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_toolkit_layouting_setting_and_removal_cleanup(void) -{ - test_return_value = TET_PASS; -} - -int UtcDaliLayoutingSettingAndRemoval_RemoveLayout(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayoutingSettingAndRemoval_RemoveLayout - Remove a layout from a control"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - SetupRootLayoutControl( rootControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - rootControl.Add( hbox ); - - // Add child controls - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 100, 100 ) ); // 0 - controls.push_back( CreateLeafControl( 100, 100 ) ); // 1 - controls.push_back( CreateLeafControl( 100, 100 ) ); // 2 - - for( auto&& iter : controls ) - { - hbox.Add( iter ); - } - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("Get number of child in the rootControl layout"); - DALI_TEST_EQUALS( ( LayoutGroup::DownCast( DevelControl::GetLayout( rootControl ) ) ).GetChildCount(), 1 , TEST_LOCATION ); - - tet_infoline("SetLayout with empty Layout handle"); - - DevelControl::SetLayout( hbox, LayoutItem{} ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("Get number of children in the rootControl layout"); - DALI_TEST_EQUALS( ( LayoutGroup::DownCast( DevelControl::GetLayout( rootControl ) ) ).GetChildCount(), 1 , TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayoutingSettingAndRemoval_RemoveLayoutFromChild(void) -{ - ToolkitTestApplication application; - tet_infoline("UtcDaliLayoutingSettingAndRemoval_RemoveLayoutFromChild - Remove a layout from a child of another layout"); - - /* - - Hbox - | | | - control0 control1 control2 - (vbox) (leaf) (leaf) - - Test removes layout from control0 but does not remove the control. - - */ - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - SetupRootLayoutControl( rootControl ); - - auto hbox = Control::New(); - auto hboxLayout = LinearLayout::New(); - DevelControl::SetLayout( hbox, hboxLayout ); - hbox.SetName( "HBox"); - rootControl.Add( hbox ); - - // Add child controls - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 100, 100 ) ); // 0 - controls.push_back( CreateLeafControl( 100, 100 ) ); // 1 - controls.push_back( CreateLeafControl( 100, 100 ) ); // 2 - - for( auto&& iter : controls ) - { - hbox.Add( iter ); - } - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("Set LinearLayout to child control 0"); - - auto vboxLayout = LinearLayout::New(); - DevelControl::SetLayout( controls[0], vboxLayout ); - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("Get number of children in the hbox layout"); - DALI_TEST_EQUALS( ( LayoutGroup::DownCast( DevelControl::GetLayout( hbox ) ) ).GetChildCount(), 3 , TEST_LOCATION ); - - tet_infoline("SetLayout with empty Layout handle"); - - DevelControl::SetLayout( controls[0], LayoutItem{} ); - - // If vbox control has no children then should get a LayoutItem. - // but if still has children then should be a LayoutGroup/BinContainer. - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("Get number of child in the hbox layout"); - DALI_TEST_EQUALS( ( LayoutGroup::DownCast( DevelControl::GetLayout( hbox ) ) ).GetChildCount(), 3 , TEST_LOCATION ); - // Test should fail as the setting of an empty layout reduces the child count by 1 - - END_TEST; -} - -int UtcDaliLayoutingSettingAndRemoval_RemoveLayoutFromHbox(void) -{ - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayoutingSettingAndRemoval_RemoveLayoutFromHbox"); - - 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( "Container" ); - - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 40, 40 ) ); - controls.push_back( CreateLeafControl( 60, 40 ) ); - - for( auto&& iter : controls ) - { - hbox.Add( iter ); - } - hbox.SetParentOrigin( ParentOrigin::CENTER ); - hbox.SetAnchorPoint( AnchorPoint::CENTER ); - rootControl.Add( hbox ); - - tet_infoline("Layout as normal"); - application.SendNotification(); - application.Render(); - - tet_infoline("Set an empty layout on hbox container"); - LinearLayout emptyLayout; - DevelControl::SetLayout( hbox, emptyLayout ); - - tet_infoline("Run another layout"); - application.SendNotification(); - application.Render(); - - tet_infoline("Check leaf controls size and position"); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - tet_infoline("Child keeps position from last layout"); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - - END_TEST; -} - -int UtcDaliLayouting_SetLayoutAlreadyInUse(void) -{ - /* - 1 ControlA (LinearLayoutA) - 2 Add 3 children - - 3 ControlB (LinearLayoutA) - 4 Add 4 children - - Test number of children in each control/layout - - LinearLayoutA should now have 4 children - - ControlB should have 4 children too - ControlA should have 3 children. - - */ - - ToolkitTestApplication application; - tet_infoline(" UtcDaliLayouting_SetLayoutAlreadyInUse - Set layout belonging to controlA to controlB"); - - Stage stage = Stage::GetCurrent(); - - auto rootControl = Control::New(); - auto absoluteLayout = AbsoluteLayout::New(); - DevelControl::SetLayout( rootControl, absoluteLayout ); - rootControl.SetName( "AbsoluteLayout" ); - stage.Add( rootControl ); - - auto controlA = Control::New(); - auto hboxLayout = LinearLayout::New(); - controlA.SetName( "controlA"); - - rootControl.Add( controlA ); - - DevelControl::SetLayout( controlA, hboxLayout ); - - // Add child controls - std::vector< Control > controls; - controls.push_back( CreateLeafControl( 100, 100 ) ); // 0 - controls.push_back( CreateLeafControl( 100, 100 ) ); // 1 - controls.push_back( CreateLeafControl( 100, 100 ) ); // 2 - - for( auto&& iter : controls ) - { - controlA.Add( iter ); - } - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("SetLayout to another control"); - - auto controlB = Control::New(); - controlB.SetName( "controlB"); - - std::vector< Control > moreControls; - moreControls.push_back( CreateLeafControl( 100, 100 ) ); // 0 - moreControls.push_back( CreateLeafControl( 100, 100 ) ); // 1 - moreControls.push_back( CreateLeafControl( 100, 100 ) ); // 3 - moreControls.push_back( CreateLeafControl( 100, 100 ) ); // 4 - - for( auto&& iter : moreControls ) - { - controlB.Add( iter ); - } - - DevelControl::SetLayout( controlB, hboxLayout ); // Set hboxLayout used by ControlA to ControlB - - // Ensure layouting happens - application.SendNotification(); - application.Render(); - - tet_infoline("Get number of children in each control's layout"); - DALI_TEST_EQUALS( ( LayoutGroup::DownCast( DevelControl::GetLayout( controlA ) ) ).GetChildCount(), 3 , TEST_LOCATION ); - DALI_TEST_EQUALS( ( LayoutGroup::DownCast( DevelControl::GetLayout( controlB ) ) ).GetChildCount(), 4 , TEST_LOCATION ); - - END_TEST; -} diff --git a/dali-toolkit/devel-api/controls/control-devel.cpp b/dali-toolkit/devel-api/controls/control-devel.cpp index 01548d1..04b13d3 100755 --- a/dali-toolkit/devel-api/controls/control-devel.cpp +++ b/dali-toolkit/devel-api/controls/control-devel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -110,62 +110,6 @@ void SetInputMethodContext( Internal::Control& control, InputMethodContext& inpu Internal::Control::Impl::Get( control ).SetInputMethodContext( inputMethodContext ); } -Toolkit::LayoutItem GetLayout( Control control ) -{ - const Internal::Control& internalControl = Toolkit::Internal::GetImplementation( control ); - const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( internalControl ); - return Toolkit::LayoutItem( controlDataImpl.GetLayout().Get() ); -} - -Toolkit::LayoutItem GetLayout( Internal::Control& control ) -{ - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control ); - return Toolkit::LayoutItem( controlDataImpl.GetLayout().Get() ); -} - -void SetLayout( Internal::Control& control, Toolkit::LayoutItem layout ) -{ - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control ); - controlDataImpl.SetLayout( GetImplementation( layout ) ); -} - -void SetLayout( Control control, Toolkit::LayoutItem layout ) -{ - Internal::Control& internalControl = Toolkit::Internal::GetImplementation( control ); - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( internalControl ); - if( layout ) - { - controlDataImpl.SetLayout( GetImplementation( layout ) ); - } - else - { - controlDataImpl.RemoveLayout(); - } -} - -void RequestLayout( Internal::Control& control ) -{ - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( control ); - Toolkit::Internal::LayoutItemPtr layoutItem = controlDataImpl.GetLayout(); - if ( layoutItem ) - { - layoutItem->RequestLayout(); - } -} -void SetLayoutingRequired( Control control, bool layoutingRequired ) -{ - Internal::Control& internalControl = Toolkit::Internal::GetImplementation( control ); - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( internalControl ); - controlDataImpl.SetLayoutingRequired( layoutingRequired ); -} - -bool IsLayoutingRequired( Control control ) -{ - Internal::Control& internalControl = Toolkit::Internal::GetImplementation( control ); - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( internalControl ); - return controlDataImpl.IsLayoutingRequired(); -} - VisualEventSignalType& VisualEventSignal( Control control ) { Internal::Control& internalControl = Toolkit::Internal::GetImplementation( control ); diff --git a/dali-toolkit/devel-api/controls/control-devel.h b/dali-toolkit/devel-api/controls/control-devel.h index dad426f..ea19b13 100755 --- a/dali-toolkit/devel-api/controls/control-devel.h +++ b/dali-toolkit/devel-api/controls/control-devel.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_CONTROL_DEVEL_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -23,7 +23,6 @@ // INTERNAL INCLUDES #include #include -#include namespace Dali { @@ -271,64 +270,6 @@ DALI_TOOLKIT_API void DoAction( Control& control, Dali::Property::Index visualIn DALI_TOOLKIT_API void SetInputMethodContext( Internal::Control& control, InputMethodContext& inputMethodContext ); /** - * @brief Get the layout associated with this control, if any. - * - * @return A handle to the layout, or empty. - */ -DALI_TOOLKIT_API Toolkit::LayoutItem GetLayout( Internal::Control& control ); - -/** - * @brief Get the layout associated with a control, if any. - * - * @return A handle to the layout, or empty. - */ -DALI_TOOLKIT_API Toolkit::LayoutItem GetLayout( Control control ); - -/** - * @brief Set the layout on this control. - * - * @param[in] control The internal Control to set the layout on - * @param[in] layout Pointer to the layout - * @note Providing an empty layout will remove the current layout and - * replace it with a BinLayout. - * Setting a layout that has already been set will result in the - * original control becoming a BinLayout. Two Controls can not share - * the same layout. - */ -DALI_TOOLKIT_API void SetLayout( Internal::Control& control, Toolkit::LayoutItem layout ); - -/** - * @brief Set the layout on a control. - * - * @param[in] control The Control to set the layout on - * @param[in] layout Pointer to the layout - * @note Providing an empty layout will remove the current layout and - * replace it with a BinLayout. - */ -DALI_TOOLKIT_API void SetLayout( Control control, Toolkit::LayoutItem layout ); - -/** - * @brief Request the control layout. - * - * @param[in] control The internal Control to request the layout of - */ -DALI_TOOLKIT_API void RequestLayout( Internal::Control& control ); - -/** - * @brief Set whether the control should have a layout - * @param[in] control The Control to set the behaviour on - * @param[in] layoutingRequired true if the control should have a layout - */ -DALI_TOOLKIT_API void SetLayoutingRequired( Control control, bool layoutingRequired ); - -/** - * @brief Check if the control has been set to require layouting - * @param[in] control The Control to query - * @return true if the control needs layouting - */ -DALI_TOOLKIT_API bool IsLayoutingRequired( Control control ); - -/** * @brief Visual Event signal type */ using VisualEventSignalType = Signal< void ( Control, Dali::Property::Index, Dali::Property::Index ) >; diff --git a/dali-toolkit/devel-api/file.list b/dali-toolkit/devel-api/file.list index 25be5fa..7ae9e86 100755 --- a/dali-toolkit/devel-api/file.list +++ b/dali-toolkit/devel-api/file.list @@ -34,17 +34,6 @@ devel_api_src_files = \ $(devel_api_src_dir)/image-loader/atlas-upload-observer.cpp \ $(devel_api_src_dir)/image-loader/image-atlas.cpp \ $(devel_api_src_dir)/image-loader/texture-manager.cpp \ - $(devel_api_src_dir)/layouting/absolute-layout.cpp \ - $(devel_api_src_dir)/layouting/bin-layout.cpp \ - $(devel_api_src_dir)/layouting/flex-layout.cpp \ - $(devel_api_src_dir)/layouting/grid.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-group.cpp \ - $(devel_api_src_dir)/layouting/layout-group-impl.cpp \ - $(devel_api_src_dir)/layouting/linear-layout.cpp \ - $(devel_api_src_dir)/layouting/layout-transition-data.cpp \ $(devel_api_src_dir)/scripting/script.cpp \ $(devel_api_src_dir)/styling/style-manager-devel.cpp \ $(devel_api_src_dir)/text/bitmap-font.cpp \ @@ -90,25 +79,6 @@ devel_api_builder_header_files = \ 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/grid.h \ - $(devel_api_src_dir)/layouting/linear-layout.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/layout-transition-data.h \ - $(devel_api_src_dir)/layouting/measured-size.h \ - $(devel_api_src_dir)/layouting/measure-spec.h - devel_api_magnifier_header_files = \ $(devel_api_src_dir)/controls/magnifier/magnifier.h diff --git a/dali-toolkit/devel-api/layouting/absolute-layout.cpp b/dali-toolkit/devel-api/layouting/absolute-layout.cpp deleted file mode 100644 index 1323b30..0000000 --- a/dali-toolkit/devel-api/layouting/absolute-layout.cpp +++ /dev/null @@ -1,63 +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 - -//INTERNAL HEADERS -#include - -namespace Dali -{ -namespace Toolkit -{ - -AbsoluteLayout::AbsoluteLayout() -{ -} - -AbsoluteLayout AbsoluteLayout::New() -{ - Internal::AbsoluteLayoutPtr internal = Internal::AbsoluteLayout::New(); - return AbsoluteLayout( internal.Get() ); -} - -AbsoluteLayout AbsoluteLayout::DownCast( BaseHandle handle ) -{ - return AbsoluteLayout( dynamic_cast< Dali::Toolkit::Internal::AbsoluteLayout*>( handle.GetObjectPtr() ) ); -} - -AbsoluteLayout::AbsoluteLayout( const AbsoluteLayout& other ) -: LayoutGroup( other ) -{ -} - -AbsoluteLayout& AbsoluteLayout::operator=( const AbsoluteLayout& other ) -{ - if( &other != this ) - { - LayoutGroup::operator=( other ); - } - return *this; -} - -AbsoluteLayout::AbsoluteLayout( Dali::Toolkit::Internal::AbsoluteLayout* object ) -: LayoutGroup( object ) -{ -} - -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/devel-api/layouting/absolute-layout.h b/dali-toolkit/devel-api/layouting/absolute-layout.h deleted file mode 100644 index 5face16..0000000 --- a/dali-toolkit/devel-api/layouting/absolute-layout.h +++ /dev/null @@ -1,109 +0,0 @@ -#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 -#include -#include -#include -#include - -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 diff --git a/dali-toolkit/devel-api/layouting/bin-layout.cpp b/dali-toolkit/devel-api/layouting/bin-layout.cpp deleted file mode 100644 index 59d0b19..0000000 --- a/dali-toolkit/devel-api/layouting/bin-layout.cpp +++ /dev/null @@ -1,63 +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 - -//INTERNAL HEADERS -#include - -namespace Dali -{ -namespace Toolkit -{ - -BinLayout::BinLayout() -{ -} - -BinLayout BinLayout::New() -{ - Internal::BinLayoutPtr internal = Internal::BinLayout::New(); - return BinLayout( internal.Get() ); -} - -BinLayout BinLayout::DownCast( BaseHandle handle ) -{ - return BinLayout( dynamic_cast< Dali::Toolkit::Internal::BinLayout*>( handle.GetObjectPtr() ) ); -} - -BinLayout::BinLayout( const BinLayout& other ) -: LayoutGroup( other ) -{ -} - -BinLayout& BinLayout::operator=( const BinLayout& other ) -{ - if( &other != this ) - { - LayoutGroup::operator=( other ); - } - return *this; -} - -BinLayout::BinLayout( Dali::Toolkit::Internal::BinLayout* object ) -: LayoutGroup( object ) -{ -} - -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/devel-api/layouting/bin-layout.h b/dali-toolkit/devel-api/layouting/bin-layout.h deleted file mode 100644 index b61245c..0000000 --- a/dali-toolkit/devel-api/layouting/bin-layout.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef DALI_TOOLKIT_LAYOUTING_BIN_LAYOUT_H -#define DALI_TOOLKIT_LAYOUTING_BIN_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 -#include -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ - -namespace Internal DALI_INTERNAL -{ -class BinLayout; -} - -/** - * This class implements a bin layout, providing a simple layout to accept - * children and perform ResizePolicy mapping. - * - * Children will be positioned with their AnchorPoint and position if provided. - * If multiple children are added then they could overlap. - */ -class DALI_TOOLKIT_API BinLayout : public LayoutGroup -{ -public: - - /** - * @brief Creates an uninitialized BinLayout handle. - * - * Initialize it using BinLayout::New(). - * Calling member functions with an uninitialized handle is not allowed. - */ - BinLayout(); - - /** - * @brief Creates a BinLayout object. - */ - static BinLayout New(); - - /** - * @brief Downcasts a handle to a BinLayout handle. - * - * If handle points to a BinLayout, the downcast produces a valid handle. - * If not, the returned handle is left uninitialized. - - * @param[in] handle to an object - * @return Handle to a BinLayout or an uninitialized handle - */ - static BinLayout DownCast( BaseHandle handle ); - - /** - * @brief Copy constructor - */ - BinLayout( const BinLayout& other ); - - /** - * @brief Assignment operator - */ - BinLayout& operator=( const BinLayout& other ); - - /** - * @brief Default destructor. - * - * This is non-virtual, since derived Handle types must not contain data or virtual methods - */ - ~BinLayout()=default; - - -public: // Not intended for application developers - - /// @cond internal - /** - * @brief This constructor is used by BinLayout::New() methods. - * - * @param[in] actor A pointer to a newly allocated Dali resource - */ - explicit DALI_INTERNAL BinLayout( Internal::BinLayout* body ); - /// @endcond -}; - -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_LAYOUTING_BIN_LAYOUT_H diff --git a/dali-toolkit/devel-api/layouting/child-layout-data.h b/dali-toolkit/devel-api/layouting/child-layout-data.h deleted file mode 100644 index f3af733..0000000 --- a/dali-toolkit/devel-api/layouting/child-layout-data.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef DALI_TOOLKIT_LAYOUTING_CHILD_LAYOUT_DATA_H -#define DALI_TOOLKIT_LAYOUTING_CHILD_LAYOUT_DATA_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. - */ - - -namespace Dali -{ -namespace Toolkit -{ - -// used in property system - must be integer values. -namespace ChildLayoutData -{ -static const int MATCH_PARENT = -1; ///< Constant which indicates child size should match parent size -static const int WRAP_CONTENT = -2; ///< Constant which indicates parent should take the smallest size possible to wrap it's children with their desired size - -} // namespace ChildLayoutData - -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_LAYOUTING_CHILD_LAYOUT_DATA_H diff --git a/dali-toolkit/devel-api/layouting/flex-layout.cpp b/dali-toolkit/devel-api/layouting/flex-layout.cpp deleted file mode 100644 index 084182b..0000000 --- a/dali-toolkit/devel-api/layouting/flex-layout.cpp +++ /dev/null @@ -1,133 +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 "flex-layout.h" - -//INTERNAL INCLUDES -#include - -namespace Dali -{ -namespace Toolkit -{ - -FlexLayout::FlexLayout() -{ -} - -FlexLayout FlexLayout::New() -{ - Internal::FlexLayoutPtr internal = Internal::FlexLayout::New(); - return FlexLayout( internal.Get() ); -} - -FlexLayout FlexLayout::DownCast( BaseHandle handle ) -{ - return FlexLayout( dynamic_cast< Dali::Toolkit::Internal::FlexLayout*>( handle.GetObjectPtr() ) ); -} - -FlexLayout::FlexLayout( const FlexLayout& other ) -: LayoutGroup( other ) -{ -} - -FlexLayout& FlexLayout::operator=( const FlexLayout& other ) -{ - if( &other != this ) - { - LayoutGroup::operator=( other ); - } - return *this; -} - -void FlexLayout::SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection flexDirection ) -{ - if( GetImplementation(*this).GetFlexDirection() != flexDirection ) - { - GetImplementation(*this).SetFlexDirection( flexDirection ); - GetImplementation(*this).RequestLayout(); - } -} - -Dali::Toolkit::FlexLayout::FlexDirection FlexLayout::GetFlexDirection() const -{ - return GetImplementation(*this).GetFlexDirection(); -} - -void FlexLayout::SetFlexJustification( Dali::Toolkit::FlexLayout::Justification flexJustification ) -{ - if( GetImplementation(*this).GetFlexJustification() != flexJustification ) - { - GetImplementation(*this).SetFlexJustification( flexJustification ); - GetImplementation(*this).RequestLayout(); - } -} - -Dali::Toolkit::FlexLayout::Justification FlexLayout::GetFlexJustification() const -{ - return GetImplementation(*this).GetFlexJustification(); -} - -void FlexLayout::SetFlexWrap( Dali::Toolkit::FlexLayout::WrapType flexWrap ) -{ - if( GetImplementation(*this).GetFlexWrap() != flexWrap ) - { - GetImplementation(*this).SetFlexWrap( flexWrap ); - GetImplementation(*this).RequestLayout(); - } -} - -Dali::Toolkit::FlexLayout::WrapType FlexLayout::GetFlexWrap() const -{ - return GetImplementation(*this).GetFlexWrap(); -} - -void FlexLayout::SetFlexAlignment( Dali::Toolkit::FlexLayout::Alignment::Type flexAlignment ) -{ - if( GetImplementation(*this).GetFlexAlignment() != flexAlignment ) - { - GetImplementation(*this).SetFlexAlignment( flexAlignment ); - GetImplementation(*this).RequestLayout(); - } -} - -Dali::Toolkit::FlexLayout::Alignment::Type FlexLayout::GetFlexAlignment() const -{ - return GetImplementation(*this).GetFlexAlignment(); -} - -void FlexLayout::SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::Type flexAlignment ) -{ - if( GetImplementation(*this).GetFlexItemsAlignment() != flexAlignment ) - { - GetImplementation(*this).SetFlexItemsAlignment( flexAlignment ); - GetImplementation(*this).RequestLayout(); - } -} - -Dali::Toolkit::FlexLayout::Alignment::Type FlexLayout::GetFlexItemsAlignment() const -{ - return GetImplementation(*this).GetFlexItemsAlignment(); -} - -FlexLayout::FlexLayout( Dali::Toolkit::Internal::FlexLayout* object ) -: LayoutGroup( object ) -{ -} - -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/devel-api/layouting/flex-layout.h b/dali-toolkit/devel-api/layouting/flex-layout.h deleted file mode 100644 index 881478b..0000000 --- a/dali-toolkit/devel-api/layouting/flex-layout.h +++ /dev/null @@ -1,241 +0,0 @@ -#ifndef DALI_TOOLKIT_LAYOUTING_FLEX_LAYOUT_H -#define DALI_TOOLKIT_LAYOUTING_FLEX_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 -#include -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ - -namespace Internal DALI_INTERNAL -{ -class FlexLayout; -} - -/** - * This class implements a flex layout. - * - * The flex layout implementation is based on open source Facebook Yoga layout engine. - * For more information about the flex layout API and how to use it please refer to - * https://yogalayout.com/docs/ - * We implement the subset of the API in the class below. - */ -class DALI_TOOLKIT_API FlexLayout : public LayoutGroup -{ -public: - - enum PropertyRange - { - CHILD_PROPERTY_START_INDEX = FLEX_LAYOUT_CHILD_PROPERTY_START_INDEX, - CHILD_PROPERTY_END_INDEX = FLEX_LAYOUT_CHILD_PROPERTY_END_INDEX - }; - - /** - * @brief Enumeration for the direction of the main axis in the flex container. This determines - * the direction that flex items are laid out in the flex container. - */ - enum class FlexDirection - { - COLUMN, ///< The flexible items are displayed vertically as a column - COLUMN_REVERSE, ///< The flexible items are displayed vertically as a column, but in reverse order - ROW, ///< The flexible items are displayed horizontally as a row - ROW_REVERSE ///< The flexible items are displayed horizontally as a row, but in reverse order - }; - - /** - * @brief Enumeration for the alignment of the flex items when the items do not use all available - * space on the main-axis. - */ - enum class Justification - { - FLEX_START, ///< Items are positioned at the beginning of the container - CENTER, ///< Items are positioned at the center of the container - FLEX_END, ///< Items are positioned at the end of the container - SPACE_BETWEEN, ///< Items are positioned with equal space between the lines - SPACE_AROUND ///< Items are positioned with equal space before, between, and after the lines - }; - - /** - * @brief Enumeration for the alignment of the flex items or lines when the items or lines do not - * use all the available space on the cross-axis. - */ - struct Alignment - { - enum Type - { - AUTO, ///< Inherits the same alignment from the parent (only valid for "alignSelf" property) - FLEX_START, ///< At the beginning of the container - CENTER, ///< At the center of the container - FLEX_END, ///< At the end of the container - STRETCH ///< Stretch to fit the container - }; - }; - - /** - * @brief Enumeration for the wrap type of the flex container when there is no enough room for - * all the items on one flex line. - */ - enum class WrapType - { - NO_WRAP, ///< Flex items laid out in single line (shrunk to fit the flex container along the main axis) - WRAP ///< Flex items laid out in multiple lines if needed - }; - - struct ChildProperty - { - enum - { - FLEX = CHILD_PROPERTY_START_INDEX, ///< name "flex", The proportion of the free space in the container the flex item will receive. If all items in the container set this property, their sizes will be proportional to the specified flex factor, type FLOAT - ALIGN_SELF ///< name "alignSelf", The alignment of the flex item along the cross axis, which, if set, overrides the default alignment for all items in the container, type INTEGER - }; - }; - - /** - * @brief Creates an uninitialized FlexLayout handle. - * - * Initialize it using FlexLayout::New(). - * Calling member functions with an uninitialized handle is not allowed. - */ - FlexLayout(); - - /** - * @brief Creates a FlexLayout object. - */ - static FlexLayout New(); - - /** - * @brief Downcasts a handle to a FlexLayout handle. - * - * If handle points to a FlexLayout, the downcast produces a valid handle. - * If not, the returned handle is left uninitialized. - - * @param[in] handle to an object - * @return Handle to a FlexLayout or an uninitialized handle - */ - static FlexLayout DownCast( BaseHandle handle ); - - /** - * @brief Copy constructor - */ - FlexLayout( const FlexLayout& other ); - - /** - * @brief Assigment operator - */ - FlexLayout& operator=( const FlexLayout& other ); - - /** - * @brief Default destructor. - * - * This is non-virtual, since derived Handle types must not contain data or virtual methods - */ - ~FlexLayout()=default; - - /** - * @brief Set the flex direction in the layout. - * The direction of the main-axis which determines the direction that flex items are laid out. - * - * @param[in] flexDirection The flex direction. - */ - void SetFlexDirection( FlexDirection flexDirection ); - - /** - * @brief Get the flex direction in the layout. - * - * @return The flex direction. - */ - FlexDirection GetFlexDirection() const; - - /** - * @brief Set the justification in the layout. - * - * @param[in] flexJustification The flex justification. - */ - void SetFlexJustification( Justification flexJustification ); - - /** - * @brief Get the flex justification in the layout. - * - * @return The flex justification. - */ - Justification GetFlexJustification() const; - - /** - * @brief Set the wrap in the layout. - * - * @param[in] flexWrap The flex wrap. - */ - void SetFlexWrap( WrapType flexWrap ); - - /** - * @brief Get the flex wrap in the layout. - * - * @return The flex wrap. - */ - WrapType GetFlexWrap() const; - - /** - * @brief Set the alignment of the layout content. - * - * @param[in] flexAlignment The alignment of the content. - */ - void SetFlexAlignment( Alignment::Type flexAlignment ); - - /** - * @brief Get the alignment of the layout content. - * - * @return The flex content alignment. - */ - Alignment::Type GetFlexAlignment() const; - - /** - * @brief Set the alignment of the layout items. - * - * @param[in] flexAlignment The alignment of the items. - */ - void SetFlexItemsAlignment( Alignment::Type flexAlignment ); - - /** - * @brief Get the alignment of the layout items. - * - * @return The flex items alignment. - */ - Alignment::Type GetFlexItemsAlignment() const; - -public: // Not intended for application developers - - /// @cond internal - /** - * @brief This constructor is used by FlexLayout::New() methods. - * - * @param[in] actor A pointer to a newly allocated Dali resource - */ - explicit DALI_INTERNAL FlexLayout( Internal::FlexLayout* body ); - /// @endcond -}; - -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_LAYOUTING_FLEX_LAYOUT_H diff --git a/dali-toolkit/devel-api/layouting/grid.cpp b/dali-toolkit/devel-api/layouting/grid.cpp deleted file mode 100644 index 1d9958d..0000000 --- a/dali-toolkit/devel-api/layouting/grid.cpp +++ /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 - -//EXTERNAL HEADERS -//INTERNAL HEADERS -#include - -namespace Dali -{ -namespace Toolkit -{ - -Grid::Grid() -{ -} - -Grid Grid::New() -{ - Internal::GridPtr internal = Internal::Grid::New(); - return Grid( internal.Get() ); -} - -Grid Grid::DownCast( BaseHandle handle ) -{ - return Grid( dynamic_cast< Dali::Toolkit::Internal::Grid*>( handle.GetObjectPtr() ) ); -} - -Grid::Grid( const Grid& other ) -: LayoutGroup( other ) -{ -} - -Grid& Grid::operator=( const Grid& other ) -{ - if( &other != this ) - { - LayoutGroup::operator=( other ); - } - return *this; -} - -void Grid::SetNumberOfColumns( int columns ) -{ - GetImplementation(*this).SetNumberOfColumns( columns ); -} - -int Grid::GetNumberOfColumns() const -{ - return GetImplementation(*this).GetNumberOfColumns(); -} - -Grid::Grid( Dali::Toolkit::Internal::Grid* object ) -: LayoutGroup( object ) -{ -} - -} // namespace Toolkit -} // namespace Dali \ No newline at end of file diff --git a/dali-toolkit/devel-api/layouting/grid.h b/dali-toolkit/devel-api/layouting/grid.h deleted file mode 100644 index 16c6c34..0000000 --- a/dali-toolkit/devel-api/layouting/grid.h +++ /dev/null @@ -1,113 +0,0 @@ -#ifndef DALI_TOOLKIT_LAYOUTING_GRID_LAYOUT_H -#define DALI_TOOLKIT_LAYOUTING_GRID_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 -#include -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ - -namespace Internal DALI_INTERNAL -{ -class Grid; -} - -/** - * @brief - * This class implements a horizontal box layout, automatically handling - * right to left or left to right direction change. - */ -class DALI_TOOLKIT_API Grid : public LayoutGroup -{ -public: - - /** - * @brief Creates an uninitialized Grid handle. - * - * Initialize it using Grid::New(). - * Calling member functions with an uninitialized handle is not allowed. - */ - Grid(); - - /** - * @brief Creates a Grid object. - */ - static Grid New(); - - /** - * @brief Downcasts a handle to a Grid handle. - * - * If handle points to a Grid, the downcast produces a valid handle. - * If not, the returned handle is left uninitialized. - - * @param[in] handle to an object - * @return Handle to a Grid or an uninitialized handle - */ - static Grid DownCast( BaseHandle handle ); - - /** - * @brief Copy constructor - */ - Grid( const Grid& other ); - - /** - * @brief Assigment operator - */ - Grid& operator=( const Grid& other ); - - /** - * @brief Default destructor. - * - * This is non-virtual, since derived Handle types must not contain data or virtual methods - */ - ~Grid()=default; - - /** - * @brief Set the number of columns in the Grid. - * @param[in] columns number of columns, - */ - void SetNumberOfColumns( int columns ); - - /** - * @brief Get the number of columns in the grid. - * @return the number of columns. - */ - int GetNumberOfColumns() const; - -public: // Not intended for application developers - - /// @cond internal - /** - * @brief This constructor is used by Grid::New() methods. - * - * @param[in] actor A pointer to a newly allocated Dali resource - */ - explicit DALI_INTERNAL Grid( Internal::Grid* body ); - /// @endcond -}; - -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_LAYOUTING_GRID_LAYOUT_H diff --git a/dali-toolkit/devel-api/layouting/layout-child-impl.h b/dali-toolkit/devel-api/layouting/layout-child-impl.h deleted file mode 100644 index 79cea9c..0000000 --- a/dali-toolkit/devel-api/layouting/layout-child-impl.h +++ /dev/null @@ -1,61 +0,0 @@ -#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 - -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 diff --git a/dali-toolkit/devel-api/layouting/layout-controller.cpp b/dali-toolkit/devel-api/layouting/layout-controller.cpp deleted file mode 100644 index 95a2619..0000000 --- a/dali-toolkit/devel-api/layouting/layout-controller.cpp +++ /dev/null @@ -1,90 +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 - -// EXTERNAL INCLUDES -#include - -// INTERNAL INCLUDES -#include - - -namespace Dali -{ -namespace Toolkit -{ - -LayoutController::LayoutController() -{ -} - -LayoutController::~LayoutController() -{ -} - -LayoutController LayoutController::Get() -{ - LayoutController layoutController; - - SingletonService singletonService( SingletonService::Get() ); - if ( singletonService ) - { - Dali::BaseHandle handle = singletonService.GetSingleton( typeid(LayoutController) ); - if( handle ) - { - // If so, downcast the handle of singleton to layout controller - layoutController = LayoutController( dynamic_cast( handle.GetObjectPtr() ) ); - } - - if( !layoutController ) - { - // If not, create the layout controller and register it as a singleton - Internal::LayoutController* impl = new Internal::LayoutController(); - layoutController = LayoutController( impl ); - impl->Initialize(); - - // Registering the singleton will automatically register the processor with Core. - singletonService.Register( typeid(layoutController), layoutController ); - } - } - - return layoutController; -} - -void LayoutController::RequestLayout( LayoutItem layout ) -{ - GetImpl( *this ).RequestLayout( GetImplementation( layout ), -1, Actor(), Actor() ); -} - -void LayoutController::RequestLayout( LayoutItem layout, Dali::Toolkit::LayoutTransitionData::Type layoutTransitionType ) -{ - GetImpl( *this ).RequestLayout( GetImplementation( layout ), layoutTransitionType, Actor(), Actor() ); -} - -void LayoutController::RequestLayout( LayoutItem layout, Dali::Toolkit::LayoutTransitionData::Type layoutTransitionType, Actor gainedChild, Actor lostChild ) -{ - GetImpl( *this ).RequestLayout( GetImplementation( layout ), layoutTransitionType, gainedChild, lostChild ); -} - -LayoutController::LayoutController( Internal::LayoutController *impl ) -: BaseHandle( impl ) -{ -} - -} //namespace Toolkit -} //namespace Dali diff --git a/dali-toolkit/devel-api/layouting/layout-controller.h b/dali-toolkit/devel-api/layouting/layout-controller.h deleted file mode 100755 index 951a4fc..0000000 --- a/dali-toolkit/devel-api/layouting/layout-controller.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef DALI_TOOLKIT_DEVEL_LAYOUT_CONTROLLER_H -#define DALI_TOOLKIT_DEVEL_LAYOUT_CONTROLLER_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 -#include -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ - -namespace Internal -{ -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_TOOLKIT_API LayoutController : public BaseHandle -{ -public: - /** - * @brief Constructor - create an uninitialized handle. - * - * This can be initialized with LayoutController::Get(). - * Calling member functions with an uninitialized handle is not allowed. - */ - LayoutController(); - - /** - * @brief Destructor. - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~LayoutController(); - - /** - * @brief Gets the singleton of the LayoutController object. - * - * @return A handle to the LayoutController object. - */ - static LayoutController Get(); - - /** - * @brief Request for a particular layout (wrapping a control or a visual) to be measured and laid out. A specified layout transition - * will be triggered during the layout. - * @param[in] layout The layout to measure & relayout. - */ - void RequestLayout( LayoutItem layout ); - - /** - * @brief Request for a particular layout (wrapping a control or a visual) to be measured and laid out. A specified layout transition - * will be triggered during the layout. - * @param[in] layout The layout to measure & relayout. - * @param[in] layoutTransitionType The layout transition type. - */ - void RequestLayout( LayoutItem layout, Dali::Toolkit::LayoutTransitionData::Type layoutTransitionType ); - - /** - * @brief Request for a particular layout (wrapping a control or a visual) to be measured and laid out. A specified layout transition - * will be triggered during the layout. - * @param[in] layout The layout to measure & relayout. - * @param[in] layoutTransitionType The layout transition type. - * @param[in] gainedChild The gained layout owner's child. - * @param[in] lostChild The lost layout owner's child. - */ - void RequestLayout( LayoutItem layout, Dali::Toolkit::LayoutTransitionData::Type layoutTransitionType, Actor gainedChild, Actor lostChild ); - -public: - /// @cond internal - /** - * @brief This constructor is used by LayoutController::New() methods. - * - * @param[in] actor A pointer to a newly allocated Dali resource - */ - explicit DALI_INTERNAL LayoutController( Internal::LayoutController *impl ); - /// @endcond -}; - -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_DEVEL_LAYOUT_CONTROLLER_H diff --git a/dali-toolkit/devel-api/layouting/layout-group-impl.cpp b/dali-toolkit/devel-api/layouting/layout-group-impl.cpp deleted file mode 100644 index a27f060..0000000 --- a/dali-toolkit/devel-api/layouting/layout-group-impl.cpp +++ /dev/null @@ -1,831 +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 - -// EXTERNAL INCLUDES -#include -#include -#include -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include - -namespace -{ -#if defined(DEBUG_ENABLED) -Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" ); -#endif -} - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -LayoutGroup::LayoutGroup() -: mImpl( new LayoutGroup::Impl() ), - mSlotDelegate(this) -{ -} - -LayoutGroupPtr LayoutGroup::New( Handle& owner ) -{ - LayoutGroupPtr layoutPtr = new LayoutGroup(); - return layoutPtr; -} - -LayoutGroup::~LayoutGroup() -{ - // An object with a unique_ptr to an opaque structure must define it's destructor in the translation unit - // where the opaque structure is defined. It cannot use the default method in the header file. - RemoveAll(); -} - -Toolkit::LayoutGroup::LayoutId LayoutGroup::Add( LayoutItem& child ) -{ - LayoutParent* oldParent = child.GetParent(); - if( oldParent ) - { - LayoutGroupPtr parentGroup( dynamic_cast< LayoutGroup* >( oldParent ) ); - if( parentGroup ) - { - parentGroup->Remove( child ); - } - } - - Impl::ChildLayout childLayout; - childLayout.layoutId = mImpl->mNextLayoutId++; - 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 - if( ! DevelHandle::DoesCustomPropertyExist( owner, Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ) ) - { - // Set default properties for LayoutGroup and LayoutItem. - // Deriving classes can override OnChildAdd() to add their own default properties - GenerateDefaultChildPropertyValues( owner ); - } - - // Inform deriving classes that this child has been added - OnChildAdd( *childLayout.child.Get() ); - - // Now listen to future changes to the child properties. - DevelHandle::PropertySetSignal(owner).Connect( this, &LayoutGroup::OnSetChildProperties ); - - RequestLayout(); - - return childLayout.layoutId; -} - -void LayoutGroup::Remove( Toolkit::LayoutGroup::LayoutId childId ) -{ - for( auto iter = mImpl->mChildren.begin() ; iter != mImpl->mChildren.end() ; ++iter ) - { - if( iter->layoutId == childId ) - { - RemoveChild( *iter->child.Get() ); - mImpl->mChildren.erase(iter); - break; - } - } - RequestLayout(); -} - -void LayoutGroup::Remove( LayoutItem& child ) -{ - for( auto iter = mImpl->mChildren.begin() ; iter != mImpl->mChildren.end() ; ++iter ) - { - if( iter->child.Get() == &child ) - { - RemoveChild( *iter->child.Get() ); - mImpl->mChildren.erase(iter); - break; - } - } - RequestLayout(); -} - -Toolkit::LayoutGroup::LayoutId LayoutGroup::Insert( LayoutItem& target, LayoutItem& child ) -{ - LayoutParent* oldParent = child.GetParent(); - if( oldParent ) - { - LayoutGroupPtr parentGroup( dynamic_cast< LayoutGroup* >( oldParent ) ); - if( parentGroup ) - { - parentGroup->Remove( child ); - } - } - - // Find target position - std::vector< Impl::ChildLayout >::iterator position; - for( auto iter = mImpl->mChildren.begin(); iter != mImpl->mChildren.end(); ++iter ) - { - if( iter->child.Get() == &target ) - { - position = iter; - break; - } - } - - Impl::ChildLayout childLayout; - childLayout.layoutId = mImpl->mNextLayoutId++; - childLayout.child = &child; - mImpl->mChildren.insert( position, childLayout ); - - child.SetParent( this ); - - auto owner = child.GetOwner(); - - // Inform deriving classes that this child has been added - OnChildAdd( *childLayout.child.Get() ); - - // Now listen to future changes to the child properties. - DevelHandle::PropertySetSignal(owner).Connect( this, &LayoutGroup::OnSetChildProperties ); - - RequestLayout(); - - return childLayout.layoutId; -} - -void LayoutGroup::RemoveAll() -{ - for( auto iter = mImpl->mChildren.begin() ; iter != mImpl->mChildren.end() ; ) - { - RemoveChild( *iter->child.Get() ); - iter = mImpl->mChildren.erase(iter); - } -} - -unsigned int LayoutGroup::GetChildCount() const -{ - return mImpl->mChildren.size(); -} - -LayoutItemPtr LayoutGroup::GetChildAt( unsigned int index ) const -{ - DALI_ASSERT_ALWAYS( index < mImpl->mChildren.size() ); - return mImpl->mChildren[ index ].child; -} - -LayoutItemPtr LayoutGroup::GetChild( Toolkit::LayoutGroup::LayoutId childId ) const -{ - for( auto&& childLayout : mImpl->mChildren ) - { - if( childLayout.layoutId == childId ) - { - return childLayout.child; - } - } - return NULL; -} - -Toolkit::LayoutGroup::LayoutId LayoutGroup::GetChildId( LayoutItem& child ) const -{ - for( auto&& childLayout : mImpl->mChildren ) - { - if( childLayout.child.Get() == &child ) - { - return childLayout.layoutId; - } - } - return Toolkit::LayoutGroup::UNKNOWN_ID; -} - -void LayoutGroup::OnChildAdd( LayoutItem& child ) -{ -} - -void LayoutGroup::OnChildRemove( LayoutItem& child ) -{ -} - -void LayoutGroup::DoInitialize() -{ -} - -void LayoutGroup::DoRegisterChildProperties( const std::string& containerType ) -{ -} - -void LayoutGroup::OnSetChildProperties( Handle& handle, Property::Index index, Property::Value value ) -{ - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::OnSetChildProperties property(" << handle.GetPropertyName(index) << ")\n" ); - - if ( ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && - ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) ) - || - ( index == Toolkit::Control::Property::MARGIN || index == Toolkit::Control::Property::PADDING ) ) - { - // If any child properties are set, must perform relayout - for( auto&& child : mImpl->mChildren ) - { - if( child.child->GetOwner() == handle ) - { - child.child->RequestLayout(); - break; - } - } - } -} - -void LayoutGroup::GenerateDefaultChildPropertyValues( Handle child ) -{ - child.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, - Toolkit::ChildLayoutData::WRAP_CONTENT ); - child.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, - Toolkit::ChildLayoutData::WRAP_CONTENT ); -} - -void LayoutGroup::MeasureChildren( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec) -{ - for( auto&& child : mImpl->mChildren ) - { - //if( (child.mViewFlags & Impl::VISIBILITY_MASK) != Impl::GONE ) // Use owner visibility/enabled/ready - { - MeasureChild( child.child, widthMeasureSpec, heightMeasureSpec ); - } - } -} - -void LayoutGroup::MeasureChild( LayoutItemPtr child, - MeasureSpec parentWidthMeasureSpec, - MeasureSpec parentHeightMeasureSpec ) -{ - DALI_LOG_TRACE_METHOD( gLogFilter ); - - auto childOwner = child->GetOwner(); - - auto control = Toolkit::Control::DownCast( childOwner ); - -#if defined( DEBUG_ENABLED ) - if ( control ) - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChild(%s) natural size(%f, %f)\n", - control.GetName().c_str(), control.GetNaturalSize().width, control.GetNaturalSize().height ); - } -#endif - - - // Get last stored width and height specifications for the child - auto desiredWidth = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); - auto desiredHeight = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChild desiredWidth(%d) desiredHeight(%d)\n", desiredWidth, desiredHeight ); - - auto padding = GetPadding(); // Padding of this layout's owner, not of the child being measured. - - const MeasureSpec childWidthMeasureSpec = GetChildMeasureSpec( parentWidthMeasureSpec, - padding.start + padding.end, - desiredWidth); - const MeasureSpec childHeightMeasureSpec = GetChildMeasureSpec( parentHeightMeasureSpec, - padding.top + padding.bottom, - desiredHeight); - - child->Measure( childWidthMeasureSpec, childHeightMeasureSpec ); -} - -void LayoutGroup::MeasureChildWithMargins( LayoutItemPtr child, - MeasureSpec parentWidthMeasureSpec, LayoutLength widthUsed, - MeasureSpec parentHeightMeasureSpec, LayoutLength heightUsed) -{ - auto childOwner = child->GetOwner(); - auto desiredWidth = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); - auto desiredHeight = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ); - - auto padding = GetPadding(); // Padding of this layout's owner, not of the child being measured. - - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins desiredWidth(%d)\n", desiredWidth ); - - MeasureSpec childWidthMeasureSpec = GetChildMeasureSpec( parentWidthMeasureSpec, - LayoutLength( padding.start + padding.end ) + - widthUsed, desiredWidth ); - - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins desiredHeight(%d)\n", desiredHeight ); - - MeasureSpec childHeightMeasureSpec = GetChildMeasureSpec( parentHeightMeasureSpec, - LayoutLength( padding.top + padding.bottom )+ - heightUsed, desiredHeight ); - - child->Measure( childWidthMeasureSpec, childHeightMeasureSpec ); -} - - -MeasureSpec LayoutGroup::GetChildMeasureSpec( - MeasureSpec measureSpec, - LayoutLength padding, - LayoutLength childDimension ) -{ - auto specMode = measureSpec.GetMode(); - LayoutLength specSize = measureSpec.GetSize(); - - LayoutLength size = std::max( LayoutLength(0), specSize - padding ); // reduce available size by the owners padding - - LayoutLength resultSize = 0; - MeasureSpec::Mode resultMode = MeasureSpec::Mode::UNSPECIFIED; - - switch( specMode ) - { - // Parent has imposed an exact size on us - case MeasureSpec::Mode::EXACTLY: - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec MeasureSpec::Mode::EXACTLY\n"); - if (childDimension == Toolkit::ChildLayoutData::MATCH_PARENT) - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec childDimension MATCH_PARENT\n"); - - // Child wants to be our size. So be it. - resultSize = size; - resultMode = MeasureSpec::Mode::EXACTLY; - } - else if (childDimension == Toolkit::ChildLayoutData::WRAP_CONTENT) - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec childDimension WRAP_CONTENT\n"); - - // Child wants to determine its own size. It can't be - // bigger than us. - resultSize = size; - resultMode = MeasureSpec::Mode::AT_MOST; - } - else - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec childDimension UNSPECIFIED\n"); - resultSize = childDimension; - resultMode = MeasureSpec::Mode::EXACTLY; - } - - break; - } - - // Parent has imposed a maximum size on us - case MeasureSpec::Mode::AT_MOST: - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec MeasureSpec::Mode::AT_MOST\n"); - if (childDimension == Toolkit::ChildLayoutData::MATCH_PARENT) - { - // Child wants to be our size, but our size is not fixed. - // Constrain child to not be bigger than us. - resultSize = size; - resultMode = MeasureSpec::Mode::AT_MOST; - } - else if (childDimension == Toolkit::ChildLayoutData::WRAP_CONTENT) - { - // Child wants to determine its own size. It can't be - // bigger than us. - resultSize = size; - resultMode = MeasureSpec::Mode::AT_MOST; - } - else - { - // Child wants a specific size... so be it - resultSize = childDimension + padding; - resultMode = MeasureSpec::Mode::EXACTLY; - } - - break; - } - - // Parent asked to see how big we want to be - case MeasureSpec::Mode::UNSPECIFIED: - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec MeasureSpec::Mode::UNSPECIFIED\n"); - - if (childDimension == Toolkit::ChildLayoutData::MATCH_PARENT) - { - // Child wants to be our size... find out how big it should be - resultSize = LayoutItem::Impl::sUseZeroUnspecifiedMeasureSpec ? LayoutLength(0) : size; - resultMode = MeasureSpec::Mode::UNSPECIFIED; - } - else if (childDimension == Toolkit::ChildLayoutData::WRAP_CONTENT) - { - // Child wants to determine its own size.... find out how big - // it should be - resultSize = LayoutItem::Impl::sUseZeroUnspecifiedMeasureSpec ? LayoutLength(0) : size; - resultMode = MeasureSpec::Mode::UNSPECIFIED; - } - else - { - // Child wants a specific size... let him have it - resultSize = childDimension + padding; - resultMode = MeasureSpec::Mode::EXACTLY; - } - break; - } - } - - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec resultSize(" << resultSize << ")\n" ); - - //noinspection ResourceType - return MeasureSpec( resultSize, resultMode ); -} - - -void LayoutGroup::OnInitialize() -{ - auto control = Toolkit::Control::DownCast( GetOwner() ); - - if( control ) - { - // Take ownership of existing children - for( unsigned int childIndex = 0 ; childIndex < control.GetChildCount(); ++childIndex ) - { - ChildAddedToOwnerImpl( control.GetChildAt( childIndex ) ); - } - - 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 ); - - unsigned int count = parent.GetChildCount(); - unsigned int index = static_cast< unsigned int >( control.GetProperty< int >( DevelActor::Property::SIBLING_ORDER ) ); - - // Find insertion position - while( ++index < count ) - { - auto sibling = Toolkit::Control::DownCast( parent.GetChildAt( index ) ); - if( sibling ) - { - auto siblingLayout = DevelControl::GetLayout( sibling ); - if( siblingLayout ) - { - Internal::LayoutItem& siblingLayoutImpl = GetImplementation( siblingLayout ); - parentLayoutImpl.Insert( siblingLayoutImpl, *this ); - break; - } - } - } - - if( index >= count ) - { - parentLayoutImpl.Add( *this ); - } - } - } - } - - RequestLayout( Dali::Toolkit::LayoutTransitionData::Type::ON_OWNER_SET ); - } -} - -void LayoutGroup::OnRegisterChildProperties( const std::string& containerType ) -{ - DoRegisterChildProperties( containerType ); -} - -void LayoutGroup::OnUnparent() -{ - // Remove children - RemoveAll(); - - auto control = Toolkit::Control::DownCast( GetOwner() ); - if( control ) - { - DevelActor::ChildAddedSignal( control ).Disconnect( mSlotDelegate, &LayoutGroup::ChildAddedToOwner ); - DevelActor::ChildRemovedSignal( control ).Disconnect( mSlotDelegate, &LayoutGroup::ChildRemovedFromOwner ); - DevelHandle::PropertySetSignal( control ).Disconnect( mSlotDelegate, &LayoutGroup::OnOwnerPropertySet ); - } -} - -void LayoutGroup::RemoveChild( LayoutItem& item ) -{ - item.SetParent( nullptr ); - OnChildRemove( item ); -} - -void LayoutGroup::ChildAddedToOwner( Actor child ) -{ - ChildAddedToOwnerImpl( child ); - RequestLayout( Dali::Toolkit::LayoutTransitionData::Type::ON_CHILD_ADD, child, Actor() ); -} - -void LayoutGroup::ChildAddedToOwnerImpl( Actor child ) -{ - LayoutItemPtr childLayout; - Toolkit::Control control = Toolkit::Control::DownCast( child ); - -#if defined(DEBUG_ENABLED) - auto parent = Toolkit::Control::DownCast( GetOwner() ); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner child control(%s) owner control(%s)\n", - control?control.GetName().c_str():"Invalid", - parent?parent.GetName().c_str():"Invalid" ); -#endif - - if( control ) // Can only support adding Controls, not Actors to layout - { - Internal::Control& childControlImpl = GetImplementation( control ); - Internal::Control::Impl& childControlDataImpl = Internal::Control::Impl::Get( childControlImpl ); - childLayout = childControlDataImpl.GetLayout(); - - if( ! childLayout ) - { - // If the child doesn't already have a layout, then create a LayoutItem or LayoutGroup for it. - // If control behaviour flag set to Layout then set a LayoutGroup. - if( DevelControl::IsLayoutingRequired( control ) ) - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner Creating default LayoutGroup for control:%s\n", - control?control.GetName().c_str():"Invalid" ); - childLayout = LayoutGroup::New( control ); - } - else - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner Creating default LayoutItem for control:%s\n", - control?control.GetName().c_str():"Invalid" ); - childLayout = LayoutItem::New( control ); - childLayout->SetAnimateLayout( IsLayoutAnimated() ); // forces animation inheritance. - } - - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner child control:" << control.GetName() << - " desiredWidth: " << control.GetNaturalSize().width << - " desiredHeight:" << control.GetNaturalSize().height ); - - childControlDataImpl.SetLayout( *childLayout.Get() ); - - Vector3 size = child.GetTargetSize(); - // If the size of the control is set explicitly make sure that the control size - // stays the same after the layout except it is over written with match parent specs. - if ( size.x != 0 ) - { - childLayout->SetMinimumWidth( size.x ); - } - - if ( size.y != 0 ) - { - childLayout->SetMinimumHeight( size.y ); - } - // Default layout data will be generated by Add(). - } - else - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner child(%s) already has a Layout\n", control.GetName().c_str() ); - LayoutGroupPtr layoutGroup( dynamic_cast< LayoutGroup* >( childLayout.Get() ) ); - if( !layoutGroup ) - { - // Set only in case of leaf children - childLayout->SetAnimateLayout( IsLayoutAnimated() ); - } - } - - Add( *childLayout.Get() ); - } -} - -void LayoutGroup::ChildRemovedFromOwner( Actor child ) -{ - Toolkit::Control control = Toolkit::Control::DownCast( child ); - if( control ) - { - Internal::Control& childControlImpl = GetImplementation( control ); - Internal::Control::Impl& childControlDataImpl = Internal::Control::Impl::Get( childControlImpl ); - auto childLayout = childControlDataImpl.GetLayout(); - if( childLayout ) - { - Remove( *childLayout.Get() ); - RequestLayout( Dali::Toolkit::LayoutTransitionData::Type::ON_CHILD_REMOVE, Actor(), child ); - } - } -} - -void LayoutGroup::OnOwnerPropertySet( Handle& handle, Property::Index index, Property::Value value ) -{ - DALI_LOG_INFO( gLogFilter, Debug::Concise, "LayoutGroup::OnOwnerPropertySet\n"); - auto actor = Actor::DownCast( handle ); - if( actor && - ( - index == Actor::Property::LAYOUT_DIRECTION || - index == Toolkit::Control::Property::PADDING || - index == Toolkit::Control::Property::MARGIN - ) - ) - { - RequestLayout(); - } -} - -void LayoutGroup::OnAnimationStateChanged( bool animateLayout ) -{ - // Change children's animation state - for( auto&& child : mImpl->mChildren ) - { - LayoutGroupPtr parentGroup( dynamic_cast< LayoutGroup* >( child.child.Get() ) ); - if( ! parentGroup ) - { - // Change state only in case of leaf children - child.child->SetAnimateLayout( animateLayout ); - } - } -} - -void LayoutGroup::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) -{ - auto childCount = GetChildCount(); - - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, - "LayoutGroup::OnMeasure Actor Id:" << Actor::DownCast(GetOwner()).GetId() << - " Owner:" << Actor::DownCast(GetOwner()).GetName() << - " Child Count:" << childCount << - " MeasureSpecs( width:"< 0 ) - { - for( unsigned int i=0; iGetOwner()); - - // If child control has children check if a ResizePolicy is set on it. A LayoutItem could be a legacy container. - // A legacy container would need it's ResizePolicy to be applied as a MeasureSpec. - - // Check below will be true for legacy containers and controls with layout required set. - // Other layouts will have their own OnMeasure (a checked requirement) hence not execute LayoutGroup::OnMeasure. - // Controls which have set layout required will not be legacy controls hence should not have a ResizePolicy set. - // Only need to map the resize policy the first time as the Layouting system will then set it to FIXED. - if( childControl.GetChildCount() > 0 && ! mImpl->mResizePolicyMapped ) - { - // First pass, Static mappings that are not dependant on parent - SizeNegotiationMapper::SetLayoutParametersUsingResizePolicy( childControl, childLayout, Dimension::WIDTH ); - SizeNegotiationMapper::SetLayoutParametersUsingResizePolicy( childControl, childLayout, Dimension::HEIGHT ); - mImpl->mResizePolicyMapped = true; - } - - // Second pass, if any mappings were not possible due to parent size dependancies then calculate an exact desired size for child - if( true == childLayout->IsResizePolicyRequired() ) // No need to test child count as this flag would only be set if control had children. - { - // Get last stored width and height specifications for the child - LayoutLength desiredWidth = childControl.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); - LayoutLength desiredHeight = childControl.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ); - - DALI_LOG_INFO( gLogFilter, Debug::General, "LayoutGroup::MeasureChild Initial desired size pre ResizePolicy(%f,%f)\n", desiredWidth.AsInteger(), desiredHeight.AsInteger() ); - - childLayout->SetResizePolicyRequired( false ); // clear flag incase in case of changes before next Measure - SizeNegotiationMapper::GetSizeofChildForParentDependentResizePolicy( childControl, widthMeasureSpec, heightMeasureSpec, desiredWidth, desiredHeight ); - - // Parent dependant ResizePolicies become exact sizes so are now set on the child before it's measured. - childControl.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, desiredWidth.AsInteger() ); - childControl.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, desiredHeight.AsInteger() ); - - DALI_LOG_INFO( gLogFilter, Debug::General, " LayoutGroup::OnMeasure ResizePolicy Required resulting size(%f,%f)\n", desiredWidth.AsInteger(), desiredHeight.AsInteger() ); - } - - // Get size of child - MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec ); - LayoutLength childWidth = childLayout->GetMeasuredWidth(); - LayoutLength childHeight = childLayout->GetMeasuredHeight(); - - Extents childMargin = childLayout->GetMargin(); - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure child " << childControl.GetName().c_str() << " width[" << childWidth << "] height[" << childHeight << "]\n" ); - - layoutWidth = std::max( layoutWidth, childWidth + childMargin.start + childMargin.end ); - layoutHeight = std::max( layoutHeight, childHeight + childMargin.top + childMargin.bottom ); - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure calculated child width[" << layoutWidth << "] height[" << layoutHeight << "]\n" ); - } - else - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure Not a layout\n" ); - } - } - - Extents padding = GetPadding(); - layoutWidth += padding.start + padding.end; - layoutHeight += padding.top + padding.bottom; - } - else - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure Getting default size as a leaf\n" ); - // LayoutGroup does not contain any children so must be a leaf - layoutWidth = GetDefaultSize( GetSuggestedMinimumWidth(), widthMeasureSpec ); - layoutHeight = GetDefaultSize( GetSuggestedMinimumHeight(), heightMeasureSpec ); - } - - // Can't exceed specified width - if( widthMode == MeasureSpec::Mode::EXACTLY ) - { - exactWidth = true; - } - else if ( widthMode == MeasureSpec::Mode::AT_MOST ) - { - layoutWidth = std::min( layoutWidth, widthSpecSize ); - } - - // Can't exceed specified height - if( heightMode == MeasureSpec::Mode::EXACTLY ) - { - exactHeight = true; - } - else if ( heightMode == MeasureSpec::Mode::AT_MOST ) - { - layoutHeight = std::min( layoutHeight, heightSpecSize ); - } - - layoutWidth = std::max( layoutWidth, GetSuggestedMinimumWidth() ); - layoutHeight = std::max( layoutHeight, GetSuggestedMinimumHeight() ); - - if( exactWidth ) - { - layoutWidth = widthSpecSize; - } - - if( exactHeight ) - { - layoutHeight = heightSpecSize; - } - - DALI_LOG_STREAM( gLogFilter, Debug::General, "LayoutGroup::OnMeasure Measured size(" << layoutWidth << "," << layoutHeight << ") for : " << Actor::DownCast(GetOwner()).GetName() << " \n" ); - SetMeasuredDimensions( MeasuredSize( layoutWidth ), MeasuredSize( layoutHeight ) ); -} - -void LayoutGroup::OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ) -{ - auto count = GetChildCount(); - - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup OnLayout owner:" << ( ( Toolkit::Control::DownCast(GetOwner())) ? Toolkit::Control::DownCast(GetOwner()).GetName() : "invalid" ) << " childCount:" << count ); - - for( unsigned int childIndex = 0; childIndex < count; childIndex++) - { - LayoutItemPtr childLayout = GetChildAt( childIndex ); - if( childLayout != nullptr ) - { - - auto childOwner = childLayout->GetOwner(); - LayoutLength childWidth = childLayout->GetMeasuredWidth(); - LayoutLength childHeight = childLayout->GetMeasuredHeight(); - Extents childMargin = childLayout->GetMargin(); - auto control = Toolkit::Control::DownCast( childOwner ); - Extents padding = GetPadding(); - - auto childPosition = control.GetProperty< Vector3 >( Actor::Property::POSITION ); - auto anchorPoint = control.GetProperty< Vector3 >( Actor::Property::ANCHOR_POINT ); - - DALI_LOG_STREAM( gLogFilter, Debug::General, "LayoutGroup::OnLayout child[" << control.GetName() << - "] position(" << childPosition << ") child width[" << childWidth << "] height[" << childHeight << "]\n" ); - - // Margin and Padding only supported when child anchor point is TOP_LEFT. - int paddingAndMarginOffsetX = ( AnchorPoint::TOP_LEFT == anchorPoint ) ? ( padding.top + childMargin.top ) : 0; - int paddingAndMarginOffsetY = ( AnchorPoint::TOP_LEFT == anchorPoint ) ? ( padding.start + childMargin.start ) : 0; - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnLayout paddingMargin offset(%d,%d)\n", paddingAndMarginOffsetX, paddingAndMarginOffsetY ); - - LayoutLength childLeft = childPosition.x + paddingAndMarginOffsetX; - LayoutLength childTop = childPosition.y + paddingAndMarginOffsetY; - - childLayout->Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight ); - } - } -} - - -} // namespace Internal -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/devel-api/layouting/layout-group-impl.h b/dali-toolkit/devel-api/layouting/layout-group-impl.h deleted file mode 100644 index 5a2796b..0000000 --- a/dali-toolkit/devel-api/layouting/layout-group-impl.h +++ /dev/null @@ -1,338 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_GROUP_H -#define DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_GROUP_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 - -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -class LayoutGroup; -using LayoutGroupPtr = IntrusivePtr; - -/** - * LayoutGroup is an abstract class that provides child layout management and basic measuring and layouting. - * - * Deriving classes should override LayoutItem::DoInitialize for second stage initialization, - * LayoutGroup::DoRegisterChildProperties to register child property types with the owner, - * LayoutGroup::OnChildAdd to apply default child property values to the child. - * Deriving classes may override LayoutGroup::OnChildRemove. - * - * Deriving classes must also override OnMeasure and OnLayout as follows: - * - * OnMeasure should measure each child using LayoutGroup::MeasureChildWithMargins or LayoutGroup::MeasureChild. - * We recommend calling LayoutItem::ResolveSizeAndState() to resolve measure specs. - * If some children don't fit, then they can be measured again with different MeasureSpecs as required. - * - * After measurement, the derived class must also call SetMeasuredDimensions to set it's own requested size. - * - * 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_TOOLKIT_API LayoutGroup : public LayoutItem, - public LayoutParent, - public ConnectionTracker -{ -public: - /** - * Constructor. Returns an initialized object - */ - LayoutGroup(); - - /** - * @brief Construct - * - * @param[in] owner The owner (container view / child view / visual ) of this layout - * @return a new LayoutGroup object - */ - static LayoutGroupPtr New( Handle& owner ); - -protected: - /** - * Virtual destructor may only be called by Unreference() - */ - virtual ~LayoutGroup(); - -public: - LayoutGroup( const LayoutGroup& copy ) = delete; - LayoutGroup& operator=( const LayoutGroup& rhs ) = delete; - - /** - * @brief Add a layout child to this group. - * - * @param[in] layoutChild The child to add - * @return The layout id of this child. - */ - 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 ) override; - - /** - * @brief Remove a layout child from this group - * @param[in] child The layout child - */ - void Remove( LayoutItem& child ) override; - - /** - * @brief Insert a child to the parent - * @param[in] target The target item - * @param[in] child The item to insert to this layout parent - */ - Toolkit::LayoutGroup::LayoutId Insert( LayoutItem& target, LayoutItem& child ) override; - - /** - * @brief Remove all layout children. - * - * @note This will not unparent owner's children - */ - void RemoveAll(); - - - /** - * @brief Get the number of children contained by this layout group - * - * @return the number of children - */ - unsigned int GetChildCount() const; - - /** - * Get the child layout at the given index - */ - LayoutItemPtr GetChildAt( unsigned int childIndex ) const; - - /** - * Get the child layout id of the given child - */ - Toolkit::LayoutGroup::LayoutId GetChildId( LayoutItem& child ) const; - - /** - * @brief Get the layout child with the given layout id. - * @note child id's start at 1, and follow the insertion order - * @param[in] childId the layout id of the child within this group - * @return A pointer to the child layout - */ - LayoutItemPtr GetChild( Toolkit::LayoutGroup::LayoutId childId ) const; - - template - LayoutItemPtr GetChild( T childId ) = delete; // Prevent implicit casting of int/uint to LayoutId - - /** - * Callback when child is added to container. - * Derived classes can use this to set their own child properties on the child layout's owner. - */ - virtual void OnChildAdd( LayoutItem& child ); - - /** - * Callback when child is removed from container. - */ - virtual void OnChildRemove( LayoutItem& child ); - - /** - * @brief Calculate the right measure spec for this child. - * - * Does the hard part of MeasureChildren: figuring out the MeasureSpec to - * pass to a particular child. This method figures out the right MeasureSpec - * for one dimension (height or width) of one child view. - * - * The goal is to combine information from our MeasureSpec with the - * LayoutParams of the child to get the best possible results. For example, - * if the this view knows its size (because its MeasureSpec has a mode of - * EXACTLY), and the child has indicated in its LayoutParams that it wants - * to be the same size as the parent, the parent should ask the child to - * layout given an exact size. - * - * @param measureSpec The requirements for this view - * - * @param padding The padding of this view for the current dimension - * and margins, if applicable - * - * @param childDimension How big the child wants to be in the - * current dimension - * @return a MeasureSpec for the child - */ - static MeasureSpec GetChildMeasureSpec( MeasureSpec measureSpec, - LayoutLength padding, - LayoutLength childDimension ); - -protected: - /** - * @brief Second stage initialization method for deriving classes to override - */ - virtual void DoInitialize(); - - /** - * @brief Method for derived classes to implement in order to register child - * property types with the container. - * - * @param[in] containerType The fully qualified typename of the container - */ - virtual void DoRegisterChildProperties( const std::string& containerType ); - - /** - * Create default child property values suitable for this layout group or derived layouter - */ - virtual void GenerateDefaultChildPropertyValues( Handle child ); - - /** - * Ask all of the children of this view to measure themselves, taking into - * account both the MeasureSpec requirements for this view and its padding. - * The heavy lifting is done in GetChildMeasureSpec. - * - * @param widthMeasureSpec The width requirements for this view - * @param heightMeasureSpec The height requirements for this view - */ - virtual void MeasureChildren( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ); - - /** - * Ask one of the children of this view to measure itself, taking into - * account both the MeasureSpec requirements for this view and its padding. - * The heavy lifting is done in GetChildMeasureSpec. - * - * @param child The child to measure - * @param parentWidthMeasureSpec The width requirements for this view - * @param parentHeightMeasureSpec The height requirements for this view - */ - virtual void MeasureChild( LayoutItemPtr child, MeasureSpec parentWidthMeasureSpec, MeasureSpec parentHeightMeasureSpec ); - - /** - * Ask one of the children of this view to measure itself, taking into - * account both the MeasureSpec requirements for this view and its padding - * and margins. The child must have MarginLayoutParams The heavy lifting is - * done in GetChildMeasureSpec. - * - * @param child The child to measure - * @param parentWidthMeasureSpec The width requirements for this view - * @param widthUsed Extra space that has been used up by the parent - * horizontally (possibly by other children of the parent) - * @param parentHeightMeasureSpec The height requirements for this view - * @param heightUsed Extra space that has been used up by the parent - * vertically (possibly by other children of the parent) - */ - virtual void MeasureChildWithMargins( LayoutItemPtr child, - MeasureSpec parentWidthMeasureSpec, - LayoutLength widthUsed, - MeasureSpec parentHeightMeasureSpec, - LayoutLength heightUsed ); - /** - * @copydoc LayoutItem::OnMeasure - */ - virtual void OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) override; - - /** - * @copydoc LayoutItem::OnLayout - */ - virtual void OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ) override; - -private: - /** - * Second stage initialization for LayoutGroup only. - * This will call DoInitialize on most derived class. - */ - void OnInitialize() override final; - - /** - * @copydoc LayoutItem::OnRegisterChildProperties() - */ - void OnRegisterChildProperties( const std::string& containerType ) override final; - - /** - * @copydoc LayoutItem::OnUnparent - */ - 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 ); - - /** - * Implementation of ChildAddedToOwner - */ - void ChildAddedToOwnerImpl( Actor child ); - - /** - * Callback when child is removed from owner - */ - void ChildRemovedFromOwner( Actor child ); - - /** - * Callback when an owner property is set. Triggers a relayout if it's a child property - */ - void OnOwnerPropertySet( Handle& handle, Property::Index index, Property::Value value ); - - /** - * Callback when a child property is set on any given child - * @param[in] handle The handle to the child - * @param[in] index The index of the property that has been set - * @param[in] value The new value of the property - */ - void OnSetChildProperties( Handle& handle, Property::Index index, Property::Value value ); - - /** - * @brief Called when a layer animation state is changed. - */ - void OnAnimationStateChanged( bool animateLayout ) override final; - -public: - class Impl; // Class declaration is public so we can add devel API's in the future - -private: - std::unique_ptr mImpl; // The implementation data for this class. - SlotDelegate mSlotDelegate; ///< Slot delegate allows this class to connect safely to signals -}; - -} //namespace Internal - -inline Internal::LayoutGroup& GetImplementation( Dali::Toolkit::LayoutGroup& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "LayoutGroup handle is empty" ); - BaseObject& object = handle.GetBaseObject(); - return static_cast< Internal::LayoutGroup& >( object ); -} - -inline const Internal::LayoutGroup& GetImplementation( const Dali::Toolkit::LayoutGroup& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "LayoutGroup handle is empty" ); - const BaseObject& object = handle.GetBaseObject(); - return static_cast< const Internal::LayoutGroup& >( object ); -} - -}//namespace Toolkit -}//namespace Dali - -#endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_GROUP_H diff --git a/dali-toolkit/devel-api/layouting/layout-group.cpp b/dali-toolkit/devel-api/layouting/layout-group.cpp deleted file mode 100644 index 50ed913..0000000 --- a/dali-toolkit/devel-api/layouting/layout-group.cpp +++ /dev/null @@ -1,79 +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. - */ - -#include -#include - -namespace Dali -{ -namespace Toolkit -{ - -LayoutGroup::LayoutGroup() -: LayoutItem() -{ -} - -LayoutGroup LayoutGroup::New( Handle& handle ) -{ - Internal::LayoutGroupPtr layout = Internal::LayoutGroup::New( handle ); - return LayoutGroup( layout.Get() ); -} - -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) ); -} - -void LayoutGroup::Remove( LayoutGroup::LayoutId childId ) -{ - GetImplementation( *this ).Remove( childId ); -} - -void LayoutGroup::Remove( LayoutItem& child ) -{ - GetImplementation( *this ).Remove( GetImplementation(child) ); -} - -LayoutItem LayoutGroup::GetChild( LayoutGroup::LayoutId childId ) const -{ - Internal::LayoutItemPtr child = GetImplementation( *this ).GetChild( childId ); - return LayoutItem( child.Get() ); -} - -LayoutItem LayoutGroup::GetChildAt( unsigned int childId ) const -{ - Internal::LayoutItemPtr child = GetImplementation( *this ).GetChildAt( childId ); - return LayoutItem( child.Get() ); -} - -unsigned int LayoutGroup::GetChildCount() const -{ - return GetImplementation( *this ).GetChildCount(); -} - -LayoutGroup::LayoutGroup( Internal::LayoutGroup* layoutGroup ) -: LayoutItem( layoutGroup ) -{ -} - -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/devel-api/layouting/layout-group.h b/dali-toolkit/devel-api/layouting/layout-group.h deleted file mode 100755 index 45aec98..0000000 --- a/dali-toolkit/devel-api/layouting/layout-group.h +++ /dev/null @@ -1,166 +0,0 @@ -#ifndef DALI_TOOLKIT_LAYOUTING_LAYOUT_GROUP_H -#define DALI_TOOLKIT_LAYOUTING_LAYOUT_GROUP_H -/* - * Copyright (c) 2019 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 -#include -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ - -namespace Internal -{ -class LayoutGroup; -} - - -/** - * A layout that has layout children. Implements LayoutItem. - * It can both layout it's children, and be laid out by a parent container. - * - * A layout group automatically handles adding a Control container's children to itself, - * both on startup and on child add/remove. If this functionality is not desired, this needs - * splitting into two classes; one that manages just the layout part, and the other which - * handles Actor hierarchy. (@todo Consider doing this anyway...) - * - * This handle class allows the application to set up layout properties for the layout group; - * it doesn't access measure/layout directly. - * - * To write a new layout, inherit from both LayoutGroup handle and Internal::LayoutGroup body. - * - */ -class DALI_TOOLKIT_API LayoutGroup : public LayoutItem -{ -public: - using LayoutId = unsigned int; - static const unsigned int UNKNOWN_ID = 0; - - /** - * @brief Creates an uninitialized LayoutGroup handle. - * - * LayoutGroup is intended as a base class, and as such, does not have a New method. - * - * Calling member functions with an uninitialized handle is not allowed. - */ - LayoutGroup(); - - /** - * @brief Default Destructor. - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~LayoutGroup() = default; - - /** - * @brief Create an initialized LayoutGroup - * - * @param[in] handle A handle to the object that this layout for, e.g. a Control or a Visual::Base - */ - static LayoutGroup New( Handle& handle ); - - /** - * @brief Copy constructor - */ - LayoutGroup(const LayoutGroup& copy) = default; - - /** - * @brief Assigment operator - */ - LayoutGroup& operator=(const LayoutGroup& rhs) = default; - - /** - * @brief Downcasts a handle to a LayoutGroup handle. - * - * If handle points to a LayoutGroup, the downcast produces a valid handle. - * If not, the returned handle is left uninitialized. - - * @param[in] handle to an object - * @return Handle to a LayoutGroup or an uninitialized handle - */ - static LayoutGroup DownCast( BaseHandle handle ); - - /** - * @brief Add a child layout to the layout group - * - * @param[in] childLayout The layout to add. - * @return an Id of the child. - */ - LayoutId Add( LayoutItem& childLayout ); - - /** - * @brief Add a child layout to the layout group - * - * @param[in] childId the id of the child to remove - */ - void Remove( LayoutId childId ); - - /** - * @brief Remove a child layout from the layout group - * - * @param[in] childLayout The layout to remove. - */ - void Remove( LayoutItem& childLayout ); - - /** - * @brief Get the child at the given index. - * - * @param[in] index The index of the child. - */ - LayoutItem GetChildAt( unsigned int index ) const; - - /** - * @brief Get the count of the children of the layout - * - * @return the count of the children of the layout - */ - unsigned int GetChildCount() const ; - - /** - * @brief Get the child referenced by childId. - * - * @param[in] childId The id of the child to get - * @return A handle to the child layout, or empty if not found - */ - LayoutItem GetChild( LayoutId childId ) const ; - - /** - * Delete template method to remove implicit casting to integer types. - */ - template - LayoutItem GetChild( T childId ) = delete; - -public: - /// @cond internal - /** - * @brief This constructor is used by LayoutGroup::New() methods. - * - * @param[in] actor A pointer to a newly allocated Dali resource - */ - explicit LayoutGroup( Internal::LayoutGroup* layoutGroup ); - /// @endcond -}; - - -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_LAYOUTING_LAYOUT_GROUP_H diff --git a/dali-toolkit/devel-api/layouting/layout-item-impl.cpp b/dali-toolkit/devel-api/layouting/layout-item-impl.cpp deleted file mode 100644 index a41a13e..0000000 --- a/dali-toolkit/devel-api/layouting/layout-item-impl.cpp +++ /dev/null @@ -1,691 +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. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace -{ - -#if defined(DEBUG_ENABLED) -Debug::Filter* gLayoutFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" ); -#endif - -const char* WIDTH_SPECIFICATION_NAME( "widthSpecification" ); -const char* HEIGHT_SPECIFICATION_NAME( "heightSpecification" ); - -} - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -LayoutItem::LayoutItem() -: mImpl( new LayoutItem::Impl() ), - mSlotDelegate( this ) -{ -} - -LayoutItem::~LayoutItem() -{ - // An object with a unique_ptr to an opaque structure must define it's destructor in the translation unit - // where the opaque structure is defined. It cannot use the default method in the header file. -} - -LayoutItemPtr LayoutItem::New( Handle& owner ) -{ - LayoutItemPtr layoutPtr = new LayoutItem(); - return layoutPtr; -} - -void LayoutItem::Initialize( Handle& owner, const std::string& containerType ) -{ - mImpl->mOwner = owner; - RegisterChildProperties( containerType ); - OnInitialize(); // Ensure direct deriving class gets initialized -} - -Handle LayoutItem::GetOwner() const -{ - return mImpl->mOwner.GetHandle(); -} - -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.Reset(); -} - -LayoutTransitionDataPtr LayoutItem::GetDefaultTransition() -{ - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::GetDefaultTransition\n" ); - if ( !mImpl->mDefaultTransitionData.Get() ) - { - auto owner = GetOwner(); - auto actor = Actor::DownCast( owner ); - - mImpl->mDefaultTransitionData = LayoutTransitionData::New(); - { - Property::Map map; - map[ Dali::Toolkit::LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION; - map[ Dali::Toolkit::LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ Dali::Toolkit::LayoutTransitionData::AnimatorKey::ANIMATOR ] = std::string(); // default animator with default duration - // Capture calculated position after layout, apply default linear animation - mImpl->mDefaultTransitionData->AddPropertyAnimator( actor, map ); - } - { - Property::Map map; - map[ Dali::Toolkit::LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; - map[ Dali::Toolkit::LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update - map[ Dali::Toolkit::LayoutTransitionData::AnimatorKey::ANIMATOR ] = std::string(); // default animator with default duration - // Capture calculated size after layout, apply default linear animation - mImpl->mDefaultTransitionData->AddPropertyAnimator( actor, map ); - } - } - return mImpl->mDefaultTransitionData; -} - -void LayoutItem::SetAnimateLayout( bool animateLayout ) -{ - auto owner = GetOwner(); - auto actor = Actor::DownCast(owner); - - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetAnimateLayout animateLayout(%s) owner(%s)\n", (animateLayout)?"true":"false", - ( ( Actor::DownCast( owner) ) ? Actor::DownCast(owner).GetName().c_str() : "Invalid Actor" ) ); - - mImpl->mAnimated = animateLayout; - - OnAnimationStateChanged( animateLayout ); -} - -bool LayoutItem::IsLayoutAnimated() const -{ - return mImpl->mAnimated; -} - -void LayoutItem::SetTransitionData( int layoutTransitionType, Internal::LayoutTransitionDataPtr layoutTransitionDataPtr ) -{ - switch ( layoutTransitionType ) - { - case Dali::Toolkit::LayoutTransitionData::ON_CHILD_ADD: - mImpl->mOnChildAddTransitionData = layoutTransitionDataPtr; - break; - case Dali::Toolkit::LayoutTransitionData::ON_CHILD_REMOVE: - mImpl->mOnChildRemoveTransitionData = layoutTransitionDataPtr; - break; - case Dali::Toolkit::LayoutTransitionData::ON_CHILD_FOCUS: - mImpl->mOnChildFocusTransitionData = layoutTransitionDataPtr; - break; - case Dali::Toolkit::LayoutTransitionData::ON_OWNER_SET: - mImpl->mOnOwnerSetTransitionData = layoutTransitionDataPtr; - break; - case Dali::Toolkit::LayoutTransitionData::ON_LAYOUT_CHANGE: - mImpl->mOnLayoutChangeTransitionData = layoutTransitionDataPtr; - break; - default: - break; - } -} - -Internal::LayoutTransitionDataPtr LayoutItem::GetTransitionData( int layoutTransitionType ) const -{ - switch ( layoutTransitionType ) - { - case Dali::Toolkit::LayoutTransitionData::ON_CHILD_ADD: - return mImpl->mOnChildAddTransitionData.Get(); - case Dali::Toolkit::LayoutTransitionData::ON_CHILD_REMOVE: - return mImpl->mOnChildRemoveTransitionData.Get(); - case Dali::Toolkit::LayoutTransitionData::ON_CHILD_FOCUS: - return mImpl->mOnChildFocusTransitionData.Get(); - case Dali::Toolkit::LayoutTransitionData::ON_OWNER_SET: - return mImpl->mOnOwnerSetTransitionData.Get(); - case Dali::Toolkit::LayoutTransitionData::ON_LAYOUT_CHANGE: - return mImpl->mOnLayoutChangeTransitionData.Get(); - default: - return LayoutTransitionDataPtr(); - } -} - -void LayoutItem::RegisterChildProperties( const std::string& containerType ) -{ - // Call on derived types - auto typeInfo = TypeRegistry::Get().GetTypeInfo( containerType ); - if( typeInfo ) - { - Property::IndexContainer indices; - typeInfo.GetChildPropertyIndices( indices ); - - if( std::find( indices.Begin(), indices.End(), Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ) == - indices.End() ) - { - ChildPropertyRegistration( typeInfo.GetName(), WIDTH_SPECIFICATION_NAME, - Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, Property::INTEGER ); - - ChildPropertyRegistration( typeInfo.GetName(), HEIGHT_SPECIFICATION_NAME, - Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, Property::INTEGER ); - } - - OnRegisterChildProperties( containerType ); - } -} - -void LayoutItem::OnRegisterChildProperties( const std::string& containerType ) -{ -} - - -void LayoutItem::Measure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) -{ - DALI_LOG_TRACE_METHOD( gLayoutFilter ); - - const bool forceLayout = mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT ); - - const bool specChanged = - ( widthMeasureSpec != mImpl->mOldWidthMeasureSpec ) || - ( heightMeasureSpec != mImpl->mOldHeightMeasureSpec ); - - const bool isSpecExactly = - ( widthMeasureSpec.GetMode() == MeasureSpec::Mode::EXACTLY ) && - ( heightMeasureSpec.GetMode() == MeasureSpec::Mode::EXACTLY ); - - const bool matchesSpecSize = - ( GetMeasuredWidth() == widthMeasureSpec.GetSize() ) && - ( GetMeasuredHeight() == heightMeasureSpec.GetSize() ); - - const bool needsLayout = specChanged && ( !isSpecExactly || !matchesSpecSize ); - - DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::Measure("<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<ClearPrivateFlag( Impl::PRIVATE_FLAG_MEASURE_NEEDED_BEFORE_LAYOUT ); - - // flag not set, setMeasuredDimension() was not invoked, we raise an exception to warn the developer - DALI_ASSERT_ALWAYS( mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_MEASURED_DIMENSION_SET ) && - "Layout's OnMeasure() Measured dimension flag not set" ); - mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_LAYOUT_REQUIRED ); - } - - mImpl->mOldWidthMeasureSpec = widthMeasureSpec; - mImpl->mOldHeightMeasureSpec = heightMeasureSpec; -} - -void LayoutItem::Layout( LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b ) -{ - DALI_LOG_TRACE_METHOD( gLayoutFilter ); - - if( mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_MEASURE_NEEDED_BEFORE_LAYOUT ) ) - { - OnMeasure( mImpl->mOldWidthMeasureSpec, mImpl->mOldHeightMeasureSpec ); - mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_MEASURE_NEEDED_BEFORE_LAYOUT ); - } - - LayoutData& layoutData = *mImpl->sLayoutData; - size_t size = layoutData.childrenLayoutDataArray.size(); - - bool changed = SetFrame( l, t, r, b ); - - if( changed || mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_LAYOUT_REQUIRED ) ) - { - - OnLayout( changed, l, t, r, b ); - mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_LAYOUT_REQUIRED ); - } - - if ( size != layoutData.childrenLayoutDataArray.size() ) - { - layoutData.childrenLayoutDataArray.resize( size ); - } - - mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT ); - mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_IS_LAID_OUT ); -} - -LayoutLength LayoutItem::GetMinimumWidth() const -{ - return mImpl->mMinimumSize.GetWidth(); -} - -LayoutLength LayoutItem::GetMinimumHeight() const -{ - return mImpl->mMinimumSize.GetHeight(); -} - -void LayoutItem::SetMinimumWidth( LayoutLength minimumWidth ) -{ - mImpl->mMinimumSize.SetWidth( minimumWidth ); - RequestLayout(); -} - -void LayoutItem::SetMinimumHeight( LayoutLength minimumHeight ) -{ - mImpl->mMinimumSize.SetHeight( minimumHeight ); - RequestLayout(); -} - -Extents LayoutItem::GetPadding() const -{ - Toolkit::Control control = Toolkit::Control::DownCast( GetOwner() ); - if( control ) - { - Extents padding = control.GetProperty( Toolkit::Control::Property::PADDING ); - - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::Padding for %s : (%d,%d,%d,%d) \n", - control.GetName().c_str(), - padding.start, padding.end, padding.top, padding.bottom - ); - return padding; - } - else - { - return Extents(); - } -} - -Extents LayoutItem::GetMargin() const -{ - Toolkit::Control control = Toolkit::Control::DownCast( GetOwner() ); - if ( control ) - { - return control.GetProperty( Toolkit::Control::Property::MARGIN ); - } - else - { - return Extents(); - } -} - -LayoutLength LayoutItem::GetDefaultSize( LayoutLength size, MeasureSpec measureSpec ) -{ - LayoutLength result = size; - auto specMode = measureSpec.GetMode(); - auto specSize = measureSpec.GetSize(); - - DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::GetDefaultSize MeasureSpec("< LayoutLength( 0 ) ) - { - result = size; - } - else - { - result = specSize; - } - break; - } - case MeasureSpec::Mode::EXACTLY: - { - result = specSize; - break; - } - } - DALI_LOG_STREAM( gLayoutFilter, Debug::General, "LayoutItem::GetDefaultSize setting default size:" << result << "\n" ); - return result; -} - -void LayoutItem::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec) -{ - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::OnMeasure\n"); - - // GetDefaultSize will limit the MeasureSpec to the suggested minimumWidth and minimumHeight - SetMeasuredDimensions( GetDefaultSize( GetSuggestedMinimumWidth(), widthMeasureSpec ), - GetDefaultSize( GetSuggestedMinimumHeight(), heightMeasureSpec ) ); -} - -void LayoutItem::OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ) -{ -} - -void LayoutItem::SetParent( LayoutParent* parent ) -{ - mImpl->mLayoutParent = parent; - mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME ); -} - -LayoutParent* LayoutItem::GetParent() -{ - return mImpl->mLayoutParent; -} - -void LayoutItem::RequestLayout() -{ - Toolkit::Control control = Toolkit::Control::DownCast( GetOwner() ); - if( control ) - { - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::RequestLayout control(%s)\n", - control.GetName().c_str() ); - - // @todo Enforce failure if called in Measure/Layout passes. - mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT ); - Toolkit::LayoutController layoutController = Toolkit::LayoutController::Get(); - layoutController.RequestLayout( Toolkit::LayoutItem( this ) ); - } -} - -void LayoutItem::RequestLayout( Dali::Toolkit::LayoutTransitionData::Type layoutAnimationType ) -{ - Toolkit::Control control = Toolkit::Control::DownCast( GetOwner() ); - if ( control ) - { - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::RequestLayout control(%s) layoutTranstionType(%d)\n", - control.GetName().c_str(), (int)layoutAnimationType ); - - // @todo Enforce failure if called in Measure/Layout passes. - mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT ); - Toolkit::LayoutController layoutController = Toolkit::LayoutController::Get(); - layoutController.RequestLayout( Toolkit::LayoutItem(this), layoutAnimationType ); - } -} - -void LayoutItem::RequestLayout( Dali::Toolkit::LayoutTransitionData::Type layoutAnimationType, Actor gainedChild, Actor lostChild ) -{ - Toolkit::Control control = Toolkit::Control::DownCast( GetOwner() ); - if ( control ) - { - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::RequestLayout control(%s) layoutTranstionType(%d)\n", - control.GetName().c_str(), (int)layoutAnimationType ); - - // @todo Enforce failure if called in Measure/Layout passes. - mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT ); - Toolkit::LayoutController layoutController = Toolkit::LayoutController::Get(); - layoutController.RequestLayout( Toolkit::LayoutItem(this), layoutAnimationType, gainedChild, lostChild ); - } -} - -bool LayoutItem::IsLayoutRequested() const -{ - return mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT ); -} - -void LayoutItem::SetLayoutRequested() -{ - mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT ); -} - -bool LayoutItem::IsResizePolicyRequired() const -{ - return mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_USE_RESIZE_POLICY ); -} - -void LayoutItem::SetResizePolicyRequired( bool resizePolicyRequired ) -{ - if( resizePolicyRequired ) - { - mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_USE_RESIZE_POLICY ); - } - else - { - mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_USE_RESIZE_POLICY ); - } -} - -void LayoutItem::SetMeasuredDimensions( MeasuredSize measuredWidth, MeasuredSize measuredHeight ) -{ - - DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetMeasuredDimensions width(" << measuredWidth.GetSize() << ") height(" << measuredHeight.GetSize() << ") Control:" << - ( ( Actor::DownCast( GetOwner()) ) ? Actor::DownCast(GetOwner()).GetName().c_str() : "Invalid Actor" ) << "\n" ); - - mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_MEASURED_DIMENSION_SET ); - mImpl->mMeasuredWidth = measuredWidth; - mImpl->mMeasuredHeight = measuredHeight; -} - -LayoutLength LayoutItem::GetMeasuredWidth() const -{ - // Get the size portion of the measured width - return mImpl->mMeasuredWidth.GetSize(); -} - -LayoutLength LayoutItem::GetMeasuredHeight() const -{ - return mImpl->mMeasuredHeight.GetSize(); -} - -MeasuredSize LayoutItem::GetMeasuredWidthAndState() const -{ - return mImpl->mMeasuredWidth; -} - -MeasuredSize LayoutItem::GetMeasuredHeightAndState() const -{ - return mImpl->mMeasuredHeight; -} - -LayoutLength LayoutItem::GetSuggestedMinimumWidth() const -{ - auto owner = GetOwner(); - auto actor = Actor::DownCast( owner ); - auto naturalSize = actor ? actor.GetNaturalSize() : Vector3::ZERO; - - return std::max( mImpl->mMinimumSize.GetWidth(), LayoutLength( naturalSize.width ) ); -} - -LayoutLength LayoutItem::GetSuggestedMinimumHeight() const -{ - auto owner = GetOwner(); - auto actor = Actor::DownCast( owner ); - auto naturalSize = actor ? actor.GetNaturalSize() : Vector3::ZERO; - - return std::max( mImpl->mMinimumSize.GetHeight(), LayoutLength( naturalSize.height ) ); -} - -MeasuredSize LayoutItem::ResolveSizeAndState( LayoutLength size, MeasureSpec measureSpec, MeasuredSize::State childMeasuredState ) -{ - auto specMode = measureSpec.GetMode(); - LayoutLength specSize = measureSpec.GetSize(); - MeasuredSize result; - - switch( specMode ) - { - case MeasureSpec::Mode::AT_MOST: - { - if (specSize < size) - { - result = MeasuredSize( specSize, MeasuredSize::MEASURED_SIZE_TOO_SMALL ); - } - else - { - result.SetSize( size ); - } - break; - } - - case MeasureSpec::Mode::EXACTLY: - { - result.SetSize( specSize ); - break; - } - - case MeasureSpec::Mode::UNSPECIFIED: - default: - { - result.SetSize( size ); - break; - } - } - - result.SetState( childMeasuredState ); - return result; -} - - -bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ) -{ - bool changed = false; - - DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame enter(" << left << ", " << top << ", " << right << ", " << bottom << ")\n" ); - - if( mImpl->mLeft != left || mImpl->mRight != right || mImpl->mTop != top || mImpl->mBottom != bottom || mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME ) ) - { - changed = true; - mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME ); - } - - LayoutLength oldWidth = mImpl->mRight - mImpl->mLeft; - LayoutLength oldHeight = mImpl->mBottom - mImpl->mTop; - LayoutLength newWidth = right - left; - LayoutLength newHeight = bottom - top; - bool sizeChanged = ( newWidth != oldWidth ) || ( newHeight != oldHeight ); - - mImpl->mLeft = left; - mImpl->mTop = top; - mImpl->mRight = right; - mImpl->mBottom = bottom; - - // Reflect up to parent control - auto owner = GetOwner(); - auto actor = Actor::DownCast( owner ); - LayoutData& layoutData = *mImpl->sLayoutData; - - if( actor ) - { - if( changed || mImpl->mAnimated ) - { - layoutData.layoutPositionDataArray.push_back( - LayoutPositionData( actor, left.AsDecimal(), top.AsDecimal(), right.AsDecimal(), bottom.AsDecimal(), mImpl->mAnimated ) ); - } - - if( mImpl->mAnimated && !layoutData.speculativeLayout ) - { - if( layoutData.layoutTransition.layoutTransitionType != -1 ) - { - LayoutItem* transitionOwner = layoutData.layoutTransition.layoutItem.Get(); - LayoutTransitionDataPtr layoutTransitionDataPtr = GetTransitionData( layoutData.layoutTransition.layoutTransitionType ); - - // Found transition owner - if( transitionOwner == this && layoutTransitionDataPtr.Get() ) - { - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame apply transition to (%s), transition type (%d)\n", actor.GetName().c_str(), layoutData.layoutTransition.layoutTransitionType ); - layoutTransitionDataPtr->CollectLayoutDataElements( actor, layoutData ); - changed = true; - } - else - { - LayoutTransitionData::CollectChildrenLayoutDataElements( actor, layoutData ); - } - } - else - { - if( changed ) - { - LayoutTransitionDataPtr layoutTransitionDataPtr = GetTransitionData( Dali::Toolkit::LayoutTransitionData::ON_LAYOUT_CHANGE ); - if( layoutTransitionDataPtr ) // has custom default animation and normal update - { - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame apply custom default transition to (%s), transition type (%d)\n", actor.GetName().c_str(), Dali::Toolkit::LayoutTransitionData::ON_LAYOUT_CHANGE ); - layoutTransitionDataPtr->CollectLayoutDataElements( actor, layoutData ); - } - else - { - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame apply default transition to (%s), transition type (%d)\n", actor.GetName().c_str(), layoutData.layoutTransition.layoutTransitionType ); - GetDefaultTransition()->CollectLayoutDataElements( actor, layoutData ); - } - } - } - } - } - - // TODO: do we need it - if( sizeChanged ) - { - SizeChange( LayoutSize( newWidth, newHeight ), LayoutSize( oldWidth, oldHeight ) ); - } - - DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame exit(" << left << ", " << top << ", " << right << ", " << bottom << ")\n" ); - - return changed; -} - -void LayoutItem::OnLayoutAnimationFinished( Animation& animation ) -{ - auto owner = GetOwner(); - auto actor = Actor::DownCast(owner); - if( actor ) - { - actor.SetSize( Vector3( mImpl->mRight.AsInteger() - mImpl->mLeft.AsInteger(), mImpl->mBottom.AsInteger() - mImpl->mTop.AsInteger(), 0.0f ) ); - } -} - -void LayoutItem::SizeChange( LayoutSize newSize, LayoutSize oldSize) -{ - OnSizeChanged( newSize, oldSize ); -} - - -void LayoutItem::OnSizeChanged( LayoutSize newSize, LayoutSize oldSize ) -{ -} - -void LayoutItem::OnInitialize() -{ -} - - -} // namespace Internal -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/devel-api/layouting/layout-item-impl.h b/dali-toolkit/devel-api/layouting/layout-item-impl.h deleted file mode 100644 index 47d65cc..0000000 --- a/dali-toolkit/devel-api/layouting/layout-item-impl.h +++ /dev/null @@ -1,538 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_ITEM_H -#define DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_ITEM_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 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -struct LayoutData; - -class LayoutItem; -using LayoutItemPtr = IntrusivePtr; - -class LayoutTransitionData; -using LayoutTransitionDataPtr = IntrusivePtr; - -/** - * Base class for layouts. - */ -class DALI_TOOLKIT_API LayoutItem : public BaseObject, - public LayoutChild -{ -public: - /** - * Constructor. - */ - LayoutItem(); - -protected: - /** - * A reference counted object may only be deleted by calling Unreference() - */ - virtual ~LayoutItem(); - -public: - -/** - * @brief Construct - * - * @param[in] owner The owner (container view / child view / visual ) of this layout - * @return a new LayoutItem object - */ - static LayoutItemPtr New( Handle& owner ); - - /** - * @brief Remove the default copy constructor - */ - LayoutItem(const LayoutItem& copy)=delete; - - /** - * @brief Remove the default assignment operator - */ - LayoutItem& operator=(const LayoutItem& rhs)=delete; - - /** - * @brief Initialize the layout with it's owner and owner's type name - * @param[in] owner a handle to the owner container - * @param[in] containerType the type name of the owner container - */ - void Initialize( Handle& owner, const std::string& containerType ); - - /** - * @brief Get a handle to the owner of this layout - * - * @return a handle to the owner of this layout - */ - Handle GetOwner() const; - - /** - * @brief Unparent this layout from it's parent, remove it from it's owner - * and remove any layout children in derived types. - */ - void Unparent(); - - /** - * @brief Set whether this layout should be animated or not - * - * @param[in] animateLayout True if the layout should be animated when applied - */ - void SetAnimateLayout( bool animateLayout ); - - /** - * @brief Get whether this layout should be animated or not - * - * @return True if the layout should be animated when applied - */ - bool IsLayoutAnimated() const; - - /** - * @brief Get the default transition - * - * @return The default transition - */ - LayoutTransitionDataPtr GetDefaultTransition(); - - /** - * @brief Set the layout transition data - * @param[in] layoutTransitionType The type of the transition - * @param[in] layoutTransitionDataPtr The transition data pointer - */ - void SetTransitionData( int layoutTransitionType, LayoutTransitionDataPtr layoutTransitionDataPtr ); - - /** - * @brief Get the transition data - * @param[in] layoutTransitionType The type of the transition - * - * @return The transition - */ - LayoutTransitionDataPtr GetTransitionData( int layoutTransitionType ) const; - - /** - * @brief This is called to find out how big a layout should be. - * - * The parent supplies constraint information in the width and height parameters. - * - * The actual measurement work of a layout is performed in - * {@link #OnMeasure(MeasureSpec, MeasureSpec)}, called by this method. Therefore, only - * {@link #OnMeasure(MeasureSpec, MeasureSpec)} can and must be overridden by subclasses. - * - * @param[in] widthMeasureSpec Horizontal space requirements as imposed by the parent - * @param[in] heightMeasureSpec Vertical space requirements as imposed by the parent - * - * @see #OnMeasure(MeasureSpec, MeasureSpec) - */ - void Measure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ); - - /** - * @brief Assign a size and position to a layout and all of its descendants. - * - * This is the second phase of the layout mechanism. (The first is measuring). In this phase, each parent - * calls layout on all of its children to position them. This is typically done using the child - * measurements that were stored in the measure pass. - * - * Derived classes with children should override OnLayout. In that method, they should call Layout on each - * of their children. - * - * @param[in] left position, relative to parent - * @param[in] top position, relative to parent - * @param[in] right position, relative to parent - * @param[in] bottom position, relative to parent - */ - void Layout( LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ); - - /** - * @brief Utility to return a default size. - * - * Uses the supplied size if the MeasureSpec imposed no constraints. Will get larger if allowed by the - * MeasureSpec. - * - * @param[in] size Default size for this layout - * @param[in] measureSpec Constraints imposed by the parent - * @return The size this layout should be. - */ - static LayoutLength GetDefaultSize( LayoutLength size, MeasureSpec measureSpec ); - - /** - * @copydoc LayoutChild::SetParent - */ - void SetParent( LayoutParent* parent ) override; - - /** - * @copydoc LayoutChild::GetParent - */ - LayoutParent* GetParent() override; - - /** - * @brief Request that this layout is re-laid out. - * - * This will make this layout and all it's parent layouts dirty. - */ - void RequestLayout(); - - /** - * @brief Request that this layout is re-laid out with particular transition. - * @param[in] layoutTranstionType The transition type - * - * This will make this layout and all it's parent layouts dirty and set the transition queued. - */ - void RequestLayout( Dali::Toolkit::LayoutTransitionData::Type layoutTranstionType ); - - /** - * @brief Request that this layout is re-laid out with particular transition. - * @param[in] layoutTranstionType The transition type - * @param[in] gainedChild The gained owners's child due to add/remove or focus gained/lost - * @param[in] lostChild The lost owners's child due to add/remove or focus gained/lost - * - * This will make this layout and all it's parent layouts dirty and set the transition queued. - */ - void RequestLayout( Dali::Toolkit::LayoutTransitionData::Type layoutTranstionType, Actor gainedChild, Actor lostChild ); - - /** - * @brief Predicate to determine if this layout has been requested to re-layout - * - * @return True if a layout request has occured on this layout - */ - bool IsLayoutRequested() const; - - /** - * @brief Set layout requested flag (mark the layout dirty). - */ - void SetLayoutRequested(); - - /** - * @brief Checks if the Resize policy is being used for this LayoutItem - * @return true is ResizePolicy is used - */ - bool IsResizePolicyRequired() const; - - /** - * @brief Sets if the ResizePolicy is needed or not for this LayoutItem - * @param[in] resizeRequired true or false flag - */ - void SetResizePolicyRequired( bool resizeRequired ); - - /** - * @brief Get the measured width (without any measurement flags). - * - * This method should be used only during measurement and layout calculations. - * - * Use {@link Dali::Actor::GetTargetSize()} to see how wide a control is after layout - */ - LayoutLength GetMeasuredWidth() const; - - /** - * @brief Get the measured height (without any measurement flags). - * - * This method should be used only during measurement and layout calculations. - * - * Use {@link Dali::Actor::GetTargetSize()} to see how high a control is after layout - */ - LayoutLength GetMeasuredHeight() const; - - /** - * @brief Get the measured width and state. - * - * This method should be used only during measurement and layout calculations. - * - * Use {@link Dali::Actor::GetTargetSize()} to see how wide a view is after layout - */ - MeasuredSize GetMeasuredWidthAndState() const; - - /** - * @brief Get the measured height and state. - * - * This method should be used only during measurement and layout calculations. - * - * Use {@link Dali::Actor::GetTargetSize()} to see how high a view is after layout - */ - MeasuredSize GetMeasuredHeightAndState() const; - - /** - * @brief Returns the suggested minimum width that the layout should use. - * - * This returns the maximum of the layout's minimum width and the background's minimum width - * - * When being used in {@link #OnMeasure()}, the caller should still - * ensure the returned width is within the requirements of the parent. - * - * @return The suggested minimum width of the layout. - */ - LayoutLength GetSuggestedMinimumWidth() const; - - /** - * @brief Returns the suggested minimum height that the layout should use. - * - * This returns the maximum of the layout's minimum height and the background's minimum height - * - * When being used in {@link #OnMeasure()}, the caller should still - * ensure the returned height is within the requirements of the parent. - * - * @return The suggested minimum height of the layout. - */ - LayoutLength GetSuggestedMinimumHeight() const; - - /** - * @brief Sets the minimum width of the layout. - * - * It is not guaranteed the layout will be able to achieve this minimum width (for example, if its parent - * layout constrains it with less available width). - * - * @param[in] minWidth The minimum width the layout will try to be, in pixels - * - * @see #GetMinimumWidth() - */ - void SetMinimumWidth( LayoutLength minWidth ); - - /** - * @brief Sets the minimum height of the layout. - * - * It is not guaranteed the layout will be able to achieve this minimum height (for example, if its parent - * layout constrains it with less available height). - * - * @param[in] minHeight The minimum height the layout will try to be, in pixels - * - * @see #GetMinimumHeight() - */ - void SetMinimumHeight( LayoutLength minHeight ); - - /** - * @brief Returns the minimum width of the layout. - * - * @return the minimum width the layout will try to be, in pixels - * - * @see #SetMinimumWidth(LayoutLength) - */ - LayoutLength GetMinimumWidth() const; - - /** - * @brief Returns the minimum height of the layout. - * - * @return the minimum height the layout will try to be, in pixels - * - * @see #SetMinimumHeight(LayoutLength) - */ - LayoutLength GetMinimumHeight() const; - - /** - * Get the padding information. - * @return The padding information - */ - Extents GetPadding() const; - - /** - * Get the margin information. - * @return The margin information - */ - Extents GetMargin() const; - -protected: - /** - * @brief Allow directly deriving classes to remove layout children when unparented - */ - virtual void OnUnparent(){}; - - /** - * @brief Ensure direct derived types register their child properties with the owner - * - * @param[in] containerType The type name of the owner container - */ - virtual void OnRegisterChildProperties( const std::string& containerType ); - - /** - * @brief Measure the layout and its content to determine the measured width and the - * measured height. - * - * This method is invoked by {@link #Measure(MeasureSpec, MeasureSpec)} and - * should be overridden by subclasses to provide accurate and efficient - * measurement of their contents. - * - * CONTRACT: When overriding this method, you - * must call {@link #SetMeasuredDimensions(MeasuredSize,MeasuredSize)} to store the - * measured width and height of this layout. Failure to do so will trigger an - * IllegalStateException, thrown by - * {@link #Measure(MeasureSpec,MeasureSpec)}. Calling the superclass' - * {@link #OnMeasure(MeasureSpec,MeasureSpec)} is a valid use. - * - * The base class implementation of measure defaults to the background size, - * unless a larger size is allowed by the MeasureSpec. Subclasses should - * override {@link #OnMeasure(MeasureSpec,MeasureSpec)} to provide better measurements of - * their content. - * - * If this method is overridden, it is the subclass's responsibility to make - * sure the measured height and width are at least the layout's minimum height - * and width ({@link #GetSuggestedMinimumHeight()} and - * {@link #GetSuggestedMinimumWidth()}). - * - * @param[in] widthMeasureSpec horizontal space requirements as imposed by the parent. - * The requirements are encoded with - * {@link MeasureSpec}. - * @param[in] heightMeasureSpec vertical space requirements as imposed by the parent. - * The requirements are encoded with - * {@link MeasureSpec}. - * - * @see #GetMeasuredWidth() - * @see #GetMeasuredHeight() - * @see #GetSuggestedMinimumHeight() - * @see #GetSuggestedMinimumWidth() - * @see MeasureSpec#GetMode(int) - * @see MeasureSpec#GetSize(int) - */ - virtual void OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ); - - /** - * @brief Called from Layout() when this layout should assign a size and position to each of its children. - * - * Derived classes with children should override this method and call Layout() on each of their children. - * - * @param[in] changed This is a new size or position for this layout - * @param[in] left Left position, relative to parent - * @param[in] top Top position, relative to parent - * @param[in] right Right position, relative to parent - * @param[in] bottom Bottom position, relative to parent - */ - virtual void OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ); - - - /** - * @brief This method must be called by {@link #OnMeasure(MeasureSpec,MeasureSpec)} to store the - * measured width and measured height. - * - * Failing to do so will trigger an exception at measurement time. - * - * @param[in] measuredWidth The measured width of this layout. This may have a state of - * {@link MeasuredSize::MEASURED_SIZE_TOO_SMALL} - * - * @param[in] measuredHeight The measured height of this layout. This may have a state of - * {@link MeasuredSize::MEASURED_SIZE_TOO_SMALL} - */ - void SetMeasuredDimensions( MeasuredSize measuredWidth, MeasuredSize measuredHeight ); - - /** - * @brief Utility to reconcile a desired size and state, with constraints imposed by a MeasureSpec. - * - * @param[in] size How big the layout wants to be. - * @param[in] measureSpec Constraints imposed by the parent. - * @param[in] childMeasuredState Size information bit mask for the layout's children. - * - * @return A measured size, which may indicate that it is too small. - */ - static MeasuredSize ResolveSizeAndState( LayoutLength size, MeasureSpec measureSpec, - MeasuredSize::State childMeasuredState ); - - /** - * @brief Sets the frame (the size and position) of the layout onto it's owner. - * Collect all properties to animate after the layout update. - * - * @param[in] left The horizontal position of the left edge of this frame within the parent layout - * @param[in] top The vertical position of the top edge of this frame within the parent layout - * @param[in] right The horizontal position of the right edge of this frame within the parent layout - * @param[in] bottom The vertical position of the bottom edge of this frame within the parent layout - */ - bool SetFrame( LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ); - - /** - * Virtual method to inform derived classes when the layout size changed - * @param[in] newSize The new size of the layout - * @param[in] oldSize The old size of the layout - */ - virtual void OnSizeChanged( LayoutSize newSize, LayoutSize oldSize ); - - - /** - * @brief Initialization method for LayoutGroup to override - */ - virtual void OnInitialize(); - - /** - * @brief Called when a layer animation state is changed. - */ - virtual void OnAnimationStateChanged( bool animateLayout ) {} - -private: - /** - * @brief Called to change the size of the layout. - * - * @param[in] newSize The new size of the layout - * @param[in] oldSize The old size of the layout - */ - void SizeChange( LayoutSize newSize, LayoutSize oldSize ); - - /** - * @brief Triggered when a layout animation finished. - * - * @param[in] animation A handle to the layout animation - */ - void OnLayoutAnimationFinished( Animation& animation ); - - /** - * @brief Register child properties of layout with owner type. - * - * The Actor hierarchy uses these registered properties in the type - * system to ensure child custom properties are properly initialized. - * - * @param[in] containerType The type of the containing view (owner) - */ - void RegisterChildProperties( const std::string& containerType ); - -public: - class Impl; // Class declaration is public so we can add devel API's in the future - -private: - std::unique_ptr mImpl; ///< Implementation class holds all the data - SlotDelegate mSlotDelegate; -}; - -} //namespace Internal - -inline Internal::LayoutItem& GetImplementation( Dali::Toolkit::LayoutItem& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "LayoutItem handle is empty" ); - BaseObject& object = handle.GetBaseObject(); - return static_cast< Internal::LayoutItem& >( object ); -} - -inline const Internal::LayoutItem& GetImplementation( const Dali::Toolkit::LayoutItem& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "LayoutItem handle is empty" ); - const BaseObject& object = handle.GetBaseObject(); - return static_cast< const Internal::LayoutItem& >( object ); -} - -} //namespace Toolkit -} //namespace Dali - -#endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_ITEM_H diff --git a/dali-toolkit/devel-api/layouting/layout-item.cpp b/dali-toolkit/devel-api/layouting/layout-item.cpp deleted file mode 100644 index 315faa4..0000000 --- a/dali-toolkit/devel-api/layouting/layout-item.cpp +++ /dev/null @@ -1,75 +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. - */ - -#include -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ - -LayoutItem::LayoutItem() -: BaseHandle() -{ -} - -LayoutItem LayoutItem::New( Handle& handle ) -{ - Internal::LayoutItemPtr layout = Internal::LayoutItem::New( handle ); - return LayoutItem( layout.Get() ); -} - -LayoutItem::LayoutItem( Internal::LayoutItem* LayoutItem ) -: BaseHandle( LayoutItem ) -{ -} - -Handle LayoutItem::GetOwner() const -{ - return GetImplementation( *this ).GetOwner(); -} - -void LayoutItem::SetAnimateLayout( bool animateLayout ) -{ - GetImplementation( *this ).SetAnimateLayout( animateLayout ); -} - -bool LayoutItem::IsLayoutAnimated() const -{ - return GetImplementation( *this ).IsLayoutAnimated(); -} - -void LayoutItem::SetTransitionData( LayoutTransitionData::Type layoutTransitionType, LayoutTransitionData layoutTransitionData ) -{ - Toolkit::Internal::LayoutTransitionDataPtr layoutTransitionDataPtr = Toolkit::Internal::LayoutTransitionDataPtr(); - if ( layoutTransitionData ) - { - layoutTransitionDataPtr = Toolkit::Internal::LayoutTransitionDataPtr( &Toolkit::GetImplementation( layoutTransitionData ) ); - } - GetImplementation( *this ).SetTransitionData( layoutTransitionType, layoutTransitionDataPtr ); -} - -LayoutTransitionData LayoutItem::GetTransitionData( LayoutTransitionData::Type layoutTransitionType ) const -{ - return LayoutTransitionData( GetImplementation( *this ).GetTransitionData( layoutTransitionType ).Get() ); -} - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/devel-api/layouting/layout-item.h b/dali-toolkit/devel-api/layouting/layout-item.h deleted file mode 100755 index 3513182..0000000 --- a/dali-toolkit/devel-api/layouting/layout-item.h +++ /dev/null @@ -1,152 +0,0 @@ -#ifndef DALI_TOOLKIT_LAYOUTING_LAYOUT_ITEM_H -#define DALI_TOOLKIT_LAYOUTING_LAYOUT_ITEM_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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ - -namespace Internal -{ -class LayoutItem; -} - -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_TOOLKIT_API LayoutItem : public BaseHandle -{ -public: - - enum PropertyRange - { - CHILD_PROPERTY_START_INDEX = CHILD_PROPERTY_REGISTRATION_START_INDEX, ///< Start index is used by child properties - CHILD_PROPERTY_END_INDEX = CHILD_PROPERTY_REGISTRATION_START_INDEX+1000 ///< Reserving 1000 property indices - }; - - struct ChildProperty - { - enum - { - WIDTH_SPECIFICATION = ///< Child property to specify desired width (May use MATCH_PARENT/WRAP_CONTENT) - CHILD_PROPERTY_START_INDEX, - HEIGHT_SPECIFICATION ///< Child property to specify desired height (May use MATCH_PARENT/WRAP_CONTENT) - }; - }; - - /** - * @brief Default constructor which provides an uninitialized Dali::LayoutItem. - */ - LayoutItem(); - - /** - * @brief Default destructor - */ - ~LayoutItem()=default; - - /** - * @brief Create an initialized LayoutItem - * - * @param[in] handle A handle to the object that this layout for, e.g. a Control or a Visual::Base - * @warning This is an interim function, and will be deleted when all controls have layouts - * @todo Ensure that this warning is implemented - */ - static LayoutItem New( Handle& handle ); - - /** - * @brief Copy constructor - * @param[in] copy The LayoutItem to copy. - */ - LayoutItem(const LayoutItem& copy) = default; - - /** - * @brief Assignment operator - * @param[in] rhs The LayoutItem to copy - */ - LayoutItem& operator=( const LayoutItem& rhs ) = default; - - /** - * @brief Get a handle to the control or visual this layout represents. - * - * @return - */ - Handle GetOwner() const; - - /** - * @brief Set whether this layout should be animated or not - * - * @param[in] animateLayout True if the layout should be animated when applied - */ - void SetAnimateLayout( bool animateLayout ); - - /** - * @brief Predicate to determine whether this layout should be animated when applied - * - * @return True if the layout should be animated when applied - */ - bool IsLayoutAnimated() const; - - /** - * @brief Set the layout transition data - * - * @param[in] layoutTransitionType The type of the layout transition - * @param[in] layoutTransitionData The layout transition data - */ - void SetTransitionData( LayoutTransitionData::Type layoutTransitionType, LayoutTransitionData layoutTransitionData ); - - /** - * @brief Get the layout transition data - * - * @param[in] layoutTransitionType The type of the layout transition - * - * @return The layout transition data - */ - LayoutTransitionData GetTransitionData( LayoutTransitionData::Type layoutTransitionType ) const; - -public: - /// @cond internal - /** - * @brief This constructor is used by LayoutItem::New() methods. - * - * @param[in] actor A pointer to a newly allocated Dali resource - */ - explicit LayoutItem( Internal::LayoutItem* LayoutItem ); - /// @endcond -}; - - -}//namespace Toolkit -}//namespace Dali - -#endif // DALI_TOOLKIT_LAYOUTING_LAYOUT_ITEM_H diff --git a/dali-toolkit/devel-api/layouting/layout-length.h b/dali-toolkit/devel-api/layouting/layout-length.h deleted file mode 100644 index 6004b77..0000000 --- a/dali-toolkit/devel-api/layouting/layout-length.h +++ /dev/null @@ -1,323 +0,0 @@ -#ifndef DALI_TOOLKIT_DEVEL_LAYOUT_LENGTH_H -#define DALI_TOOLKIT_DEVEL_LAYOUT_LENGTH_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. - */ - -// EXTERNAL INCLUDES -#include -#include -#include - -namespace Dali -{ - -namespace Toolkit -{ - -/** - * @brief A type that represents a layout length. - * - * Currently, this implies pixels, but could be extended to handle device dependent sizes, etc. - */ -class LayoutLength -{ -public: - - /** - * @brief default constructor, initialises to 0 - */ - LayoutLength() - : mValue( 0 ) - { - } - - /** - * @brief constructor - * - * @param value the value to initialise with - */ - LayoutLength( int value ) - : mValue( value ) - { - } - - /** - * @brief constructor from float - * - * @param value the value to initialise with - */ - LayoutLength( float value ) - : mValue( value ) - { - } - - /** - * @brief constructor - * - * @param layoutLength the value to initialise with - */ - LayoutLength( const LayoutLength& layoutLength ) - : mValue( layoutLength.mValue ) - { - } - - /** - * @brief assignment operator - * - * @param rhs LayoutLength to assign - * @return reference to itself - */ - LayoutLength& operator=( const LayoutLength& rhs ) - { - if( this != &rhs ) - { - mValue = rhs.mValue; - } - return *this; - } - - /** - * @brief assignment operator from int - * - * @param value the value to assign - * @return reference to itself - */ - LayoutLength& operator=( int value ) - { - mValue = value; - return *this; - } - - /** - * @brief assignment operator from float - * - * @param value the value to assign - * @return reference to itself - */ - LayoutLength& operator=( float value ) - { - mValue = value; - return *this; - } - - /** - * @brief plus equals operator - * - * @param rhs to add to this - * @return reference to itself - */ - LayoutLength& operator+=( LayoutLength rhs ) - { - mValue += rhs.mValue; - return *this; - } - - /** - * @brief minus equals operator - * - * @param rhs to subtract from this - * @return reference to itself - */ - LayoutLength& operator-=( LayoutLength rhs ) - { - mValue -= rhs.mValue; - return *this; - } - - /** - * @brief return value as decimal value (full raw value) - * - * @return the LayoutLength as full decimal value - */ - float AsDecimal() const - { - return mValue; - } - - /** - * @brief return value as rounded integer value (whole number) - * - * @return the LayoutLength rounded to next integer value - */ - float AsInteger() const - { - return round( mValue ); - } - - /** - * @brief return value as truncated integral value (whole number) - * - * @return the LayoutLength rounded to next integral value - */ - float AsTruncated() const - { - return trunc( mValue ); - } - -private: - - float mValue; - -}; - -/** - * @brief equal to operator - * - * @param lhs value to compare - * @param rhs value to compare against - * @note Using value instead of reference to allow conversions from int and float - * @return true if identical, false otherwise - */ -inline bool operator==( LayoutLength lhs, LayoutLength rhs ) -{ - return lhs.AsDecimal() == rhs.AsDecimal(); -} - -/** - * @brief not equal to operator - * - * @param lhs value to compare - * @param rhs value to compare against - * @note Using value instead of reference to allow conversions from int and float - * @return true if value is not identical, false otherwise - */ -inline bool operator!=( LayoutLength lhs, LayoutLength rhs ) -{ - return !operator==( lhs, rhs ); -} - -/** - * @brief less than operator - * - * @param lhs value to compare - * @param rhs value to compare against - * @note Using value instead of reference to allow conversions from int and float - * @return true if lhs value is less, false otherwise - */ -inline bool operator<( LayoutLength lhs, LayoutLength rhs ) -{ - return lhs.AsDecimal() < rhs.AsDecimal(); -} - -/** - * @brief greater than operator - * - * @param lhs value to compare - * @param rhs value to compare against - * @note Using value instead of reference to allow conversions from int and float - * @return true if lhs value is greater, false otherwise - */ -inline bool operator>( LayoutLength lhs, LayoutLength rhs ) -{ - return rhs < lhs; -} - -/** - * @brief less than or equal to operator - * - * @param lhs value to compare - * @param rhs value to compare against - * @note Using value instead of reference to allow conversions from int and float - * @return true if lhs value is less than or equal to, false otherwise - */ -inline bool operator<=( LayoutLength lhs, LayoutLength rhs ) -{ - return !(lhs > rhs); -} - -/** - * @brief greater than or equal to operator - * - * @param lhs value to compare - * @param rhs value to compare against - * @note Using value instead of reference to allow conversions from int and float - * @return true if lhs value is greater than or equal to, false otherwise - */ -inline bool operator>=( LayoutLength lhs, LayoutLength rhs ) -{ - return !(lhs < rhs); -} - -/** - * @brief add two LayoutLengths - * - * @param lhs The LayoutLength to add - * @param rhs The LayoutLength to add - * @note Using value instead of reference to allow conversions from int and float - * @return the resulting LayoutLength - */ -inline LayoutLength operator+( LayoutLength lhs, LayoutLength rhs ) -{ - return lhs.AsDecimal() + rhs.AsDecimal(); -} - -/** - * @brief subtract two LayoutLengths - * - * @param lhs The LayoutLength to subtract from - * @param rhs The LayoutLength to subtract - * @note Using value instead of reference to allow conversions from int and float - * @return the resulting LayoutLength - */ -inline LayoutLength operator-( LayoutLength lhs, LayoutLength rhs ) -{ - return lhs.AsDecimal() - rhs.AsDecimal(); -} - -/** - * @brief multiply two LayoutLengths - * - * @param lhs The LayoutLength to multiply - * @param rhs The LayoutLength to multiply - * @note Using value instead of reference to allow conversions from int and float - * @return the resulting LayoutLength - */ -inline LayoutLength operator*( LayoutLength lhs, LayoutLength rhs ) -{ - return lhs.AsDecimal() * rhs.AsDecimal(); -} - -/** - * @brief divide LayoutLength by a LayoutLength - * - * @param lhs The LayoutLength to divide - * @param rhs The LayoutLength to divide by - * @note Using value instead of reference to allow conversions from int and float - * @return the resulting value as float - */ -inline LayoutLength operator/( LayoutLength lhs, LayoutLength rhs ) -{ - return lhs.AsDecimal() / rhs.AsDecimal(); -} - -/** - * @brief Prints a LayoutLength - * - * @param[in] o The output stream operator - * @param[in] layoutLength the layout length to print - * @return The output stream operator - */ -inline std::ostream& operator<<( std::ostream& o, const LayoutLength& layoutLength ) -{ - return o << layoutLength.AsDecimal(); -} - -} // namespace Toolkit - -} // namespace Dali - -#endif //DALI_TOOLKIT_DEVEL_LAYOUT_LENGTH_H diff --git a/dali-toolkit/devel-api/layouting/layout-parent-impl.h b/dali-toolkit/devel-api/layouting/layout-parent-impl.h deleted file mode 100644 index a55c7cb..0000000 --- a/dali-toolkit/devel-api/layouting/layout-parent-impl.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_PARENT_H -#define DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_PARENT_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 - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ -class LayoutItem; - -/** - * 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: - /** - * @brief Add a child to the parent - * @param[in] item The item to add to this layout parent - */ - virtual Toolkit::LayoutGroup::LayoutId Add( LayoutItem& item ) = 0; - - /** - * @brief Remove a layout child from this group. - * @param[in] childId The layout child id - */ - 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; - - /** - * @brief Insert a child to the parent - * @param[in] target The target item - * @param[in] item The item to insert to this layout parent - */ - virtual Toolkit::LayoutGroup::LayoutId Insert( LayoutItem& target, LayoutItem& item ) = 0; - - -protected: - virtual ~LayoutParent() - { - } -}; - - - -} // namespace Internal -} // namespace Toolkit -} // namespace Dali - -#endif //DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_PARENT_H diff --git a/dali-toolkit/devel-api/layouting/layout-size.h b/dali-toolkit/devel-api/layouting/layout-size.h deleted file mode 100644 index d025ea7..0000000 --- a/dali-toolkit/devel-api/layouting/layout-size.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef DALI_TOOLKIT_DEVEL_LAYOUT_SIZE_H -#define DALI_TOOLKIT_DEVEL_LAYOUT_SIZE_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 - -namespace Dali -{ -namespace Toolkit -{ - -/** - * This class represents a layout size (width and height) - */ -class LayoutSize -{ -public: - LayoutSize() - : x( 0 ), - y( 0 ) - { - } - - LayoutSize( LayoutLength anX, LayoutLength aY ) - : x( anX ), - y( aY ) - { - } - - LayoutSize( const LayoutSize& layoutSize ) - : x( layoutSize.x ), - y( layoutSize.y ) - { - } - - LayoutSize& operator=(const LayoutSize& rhs) - { - x = rhs.x; - y = rhs.y; - return *this; - } - - void SetWidth( LayoutLength value ) - { - width = value; - } - - LayoutLength GetWidth() - { - return width; - } - - void SetHeight( LayoutLength value ) - { - height = value; - } - - LayoutLength GetHeight() - { - return height; - } - - bool operator==( const LayoutSize& rhs ) - { - return x==rhs.x && y==rhs.y; - } - - bool operator!=( const LayoutSize& rhs ) - { - return !( *this==rhs ); - } - - union - { - LayoutLength x; - LayoutLength width; - }; - - union - { - LayoutLength y; - LayoutLength height; - }; -}; - -/** - * @brief Prints a LayoutSize - * - * @param[in] o The output stream operator - * @param[in] layoutSize the layout size to print - * @return The output stream operator - */ -inline std::ostream& operator<< (std::ostream& o, const LayoutSize& layoutSize) -{ - return o << "[" << layoutSize.x << ", " << layoutSize.y << "]"; -} - -} // namespace Toolkit - -} // namespace Dali - -#endif //DALI_TOOLKIT_DEVEL_LAYOUT_SIZE_H diff --git a/dali-toolkit/devel-api/layouting/layout-transition-data.cpp b/dali-toolkit/devel-api/layouting/layout-transition-data.cpp deleted file mode 100644 index ad36ca8..0000000 --- a/dali-toolkit/devel-api/layouting/layout-transition-data.cpp +++ /dev/null @@ -1,67 +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. - */ - -#include -#include - -namespace Dali -{ -namespace Toolkit -{ - -LayoutTransitionData::LayoutTransitionData() -: BaseHandle() -{ -} - -LayoutTransitionData::LayoutTransitionData( Internal::LayoutTransitionData* layoutAnimationData ) -: BaseHandle( layoutAnimationData ) -{ -} - -LayoutTransitionData LayoutTransitionData::New() -{ - Internal::LayoutTransitionDataPtr layoutAnimationData = Internal::LayoutTransitionData::New(); - return LayoutTransitionData( layoutAnimationData.Get() ); -} - -LayoutTransitionData LayoutTransitionData::DownCast( BaseHandle handle ) -{ - return LayoutTransitionData( dynamic_cast(handle.GetObjectPtr()) ); -} - -void LayoutTransitionData::AddPropertyAnimator( Actor actor, Property::Map map ) -{ - GetImplementation( *this ).AddPropertyAnimator( actor, map ); -} - -void LayoutTransitionData::AddPropertyAnimator( Actor actor, Property::Map map, KeyFrames keyFrames, Animation::Interpolation interpolation ) -{ - GetImplementation( *this ).AddPropertyAnimator( actor, map, keyFrames, interpolation ); -} - -void LayoutTransitionData::AddPropertyAnimator( Actor actor, Property::Map map, Path path, Vector3 forward ) -{ - GetImplementation( *this ).AddPropertyAnimator( actor, map, path, forward ); -} - -LayoutTransitionData::LayoutTransitionSignalType& LayoutTransitionData::FinishedSignal() -{ - return GetImplementation(*this ).FinishedSignal(); -} - -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/devel-api/layouting/layout-transition-data.h b/dali-toolkit/devel-api/layouting/layout-transition-data.h deleted file mode 100644 index 6b56301..0000000 --- a/dali-toolkit/devel-api/layouting/layout-transition-data.h +++ /dev/null @@ -1,186 +0,0 @@ -#ifndef DALI_TOOLKIT_LAYOUTING_LAYOUT_TRANSITION_DATA_H -#define DALI_TOOLKIT_LAYOUTING_LAYOUT_TRANSITION_DATA_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 -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ - -namespace Internal -{ -class LayoutTransitionData; -} - -/** - * @brief The LayoutTransitionData class to collect the actors properties animators for layout transitions. - */ -class DALI_TOOLKIT_API LayoutTransitionData final : public BaseHandle -{ -public: - - /** - * @brief Enumeration for property animator keys belonging to the LayoutTransitionData class. - */ - struct AnimatorKey - { - enum Type - { - CONDITION, ///< A condition triggering the transition animation (the actor is added/removed/focus gained/focus lost) - PROPERTY, ///< A property to animate - INITIAL_VALUE, ///< Initial value of an animated property - TARGET_VALUE, ///< Target value of an animated property - ANIMATOR, ///< Animator for an animated property - TYPE, ///< Type of an animator - NAME, ///< Name of an animator - TIME_PERIOD, ///< Time period of an property animation - DURATION, ///< Duration of an property animation - DELAY, ///< Delay of an property animation - ALPHA_FUNCTION, ///< Alpha function of a property animation - AFFECTS_SIBLINGS, ///< Might change the actor siblings positions etc by updating the actor measured size if the actor size is changed due to the animation. False by default. - }; - }; - - struct Animator - { - enum Type - { - ANIMATE_TO, ///< Animate to property target value - ANIMATE_BY, ///< Animate by property target value - ANIMATE_BETWEEN, ///< Animate between property initial and target values - ANIMATE_PATH ///< Animate using the animation path - }; - }; - - struct Condition - { - enum Type - { - NONE, ///< Default, no conditions to animate property. The property is animated for all relevant animations related to a control - ON_ADD, ///< A condition to animate property when a control is added to the container - ON_REMOVE, ///< A condition to animate property when a control is removed from the container - ON_FOCUS_GAINED, ///< A condition to animate property when a control focus is gained - ON_FOCUS_LOST, ///< A condition to animate property when a control focus is lost - }; - }; - - enum Type - { - // Children related transitions - ON_CHILD_ADD, ///< A transition is triggered when a control is added to the container - ON_CHILD_REMOVE, ///< A transition is triggered when a control is removed from the container - ON_CHILD_FOCUS, ///< A transition is triggered when a control focus is changed in the container - // Layout related transitions - ON_OWNER_SET, ///< A transition is triggered when a layout is set to a new container - ON_LAYOUT_CHANGE, ///< A transition is triggered when a layout geometry is changed - }; - - typedef Signal< void (LayoutTransitionData::Type, LayoutTransitionData&) > LayoutTransitionSignalType; ///< Transition finished signal - - /** - * Create an uninitialized handle - * - * @SINCE_1_2.12 - */ - LayoutTransitionData(); - - /** - * Destructor - non virtual - * - * @SINCE_1_2.12 - */ - ~LayoutTransitionData() = default; - - /** - * Create an initialized LayoutTransitionData - */ - static LayoutTransitionData New(); - - /** - * @brief Downcasts a handle to LayoutTransitionData handle. - * - * If handle points to an LayoutTransitionData object, the downcast produces valid handle. - * If not, the returned handle is left uninitialized. - * - * @param[in] handle Handle to an object - * @return Handle to an LayoutTransitionData object or an uninitialized handle - */ - static LayoutTransitionData DownCast( BaseHandle handle ); - - /** - * @brief Add a property animator for an actor - * - * @param[in] actor An owner of the animated property. - * If actor is empty then the property animator is generic and apply to all children excluding the parent if the condition is met. - * @param[in] map The animated property map including animator map - */ - void AddPropertyAnimator( Actor actor, Property::Map map ); - - /** - * @brief Add a property animator for an actor - * - * @param[in] actor An owner of the animated property - * If actor is empty then the property animator is generic and apply to all children excluding the parent if the condition is met. - * @param[in] map The properties map - * @param[in] keyFrames key frames - * @param[in] interpolation An interpolation - */ - void AddPropertyAnimator( Actor actor, Property::Map map, KeyFrames keyFrames, Animation::Interpolation interpolation ); - - /** - * @brief Add a property animator for an actor - * - * @param[in] actor An owner of the animated property - * If actor is empty then the property animator is generic and apply to all children excluding the parent if the condition is met. - * @param[in] map A properties map - * @param[in] path An animation path - * @param[in] forward A forward vector for the path - */ - void AddPropertyAnimator( Actor actor, Property::Map map, Path path, Vector3 forward ); - - /** - * @brief Connects to this signal to be notified when a transition animation have finished. - * - * @return A signal object to connect with - */ - LayoutTransitionSignalType& FinishedSignal(); - -public: - /// @cond internal - /** - * @brief This constructor is used by LayoutTransitionData::New() method. - * - * @param[in] layoutTransitonData A pointer to a newly allocated transition data resource - */ - DALI_INTERNAL explicit LayoutTransitionData( Internal::LayoutTransitionData* layoutTransitonData ); - /// @endcond -}; - -}//namespace Toolkit -}//namespace Dali - -#endif // DALI_TOOLKIT_LAYOUTING_LAYOUT_TRANSITION_DATA_H diff --git a/dali-toolkit/devel-api/layouting/linear-layout.cpp b/dali-toolkit/devel-api/layouting/linear-layout.cpp deleted file mode 100644 index 25e88ab..0000000 --- a/dali-toolkit/devel-api/layouting/linear-layout.cpp +++ /dev/null @@ -1,93 +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 "linear-layout.h" - -//INTERNAL INCLUDES -#include - -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 ); -} - -LayoutSize LinearLayout::GetCellPadding() const -{ - return GetImplementation(*this).GetCellPadding(); -} - -void LinearLayout::SetOrientation( LinearLayout::Orientation orientation ) -{ - GetImplementation(*this).SetOrientation( orientation ); -} - -LinearLayout::Orientation LinearLayout::GetOrientation() const -{ - return GetImplementation(*this).GetOrientation(); -} - -void LinearLayout::SetAlignment( unsigned int alignment ) -{ - GetImplementation(*this).SetAlignment( alignment ); -} - -unsigned int LinearLayout::GetAlignment() const -{ - return GetImplementation(*this).GetAlignment(); -} - -LinearLayout::LinearLayout( Dali::Toolkit::Internal::LinearLayout* object ) -: LayoutGroup( object ) -{ -} - -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/devel-api/layouting/linear-layout.h b/dali-toolkit/devel-api/layouting/linear-layout.h deleted file mode 100644 index b70303a..0000000 --- a/dali-toolkit/devel-api/layouting/linear-layout.h +++ /dev/null @@ -1,181 +0,0 @@ -#ifndef DALI_TOOLKIT_LAYOUTING_LINEAR_LAYOUT_H -#define DALI_TOOLKIT_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 -#include -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ - -namespace Internal DALI_INTERNAL -{ -class LinearLayout; -} - -/** - * This class implements a linear box layout, automatically handling - * right to left or left to right direction change. - */ -class DALI_TOOLKIT_API LinearLayout : public LayoutGroup -{ -public: - - enum PropertyRange - { - CHILD_PROPERTY_START_INDEX = LINEAR_LAYOUT_CHILD_PROPERTY_START_INDEX, - CHILD_PROPERTY_END_INDEX = LINEAR_LAYOUT_CHILD_PROPERTY_END_INDEX - }; - - /** - * @brief Enumeration for the direction in which the content is laid out - */ - enum class Orientation - { - HORIZONTAL, ///< Horizontal (row) - VERTICAL ///< Vertical (column) - }; - - /** - * @brief Enumeration for the alignment of the linear layout items. - */ - struct Alignment - { - enum Type - { - BEGIN = 0x1, ///< At the left/right edge of the container (maps to LTR/RTL direction for horizontal orientation) - END = 0x2, ///< At the right/left edge of the container (maps to LTR/RTL direction for horizontal orientation) - CENTER_HORIZONTAL = 0x4, ///< At the horizontal center of the container - TOP = 0x8, ///< At the top edge of the container - BOTTOM = 0x10, ///< At the bottom edge of the container - CENTER_VERTICAL = 0x20 ///< At the vertical center of the container - }; - }; - - struct ChildProperty - { - enum - { - WEIGHT = CHILD_PROPERTY_START_INDEX, ///< name "weight", The proportion of the free space in the container the linear item will receive after all other non weighted items measured and all items specification width & height added. Type FLOAT - }; - }; - - /** - * @brief Creates an uninitialized LinearLayout handle. - * - * Initialize it using LinearLayout::New(). - * Calling member functions with an uninitialized handle is not allowed. - */ - LinearLayout(); - - /** - * @brief Creates a LinearLayout object. - */ - static LinearLayout New(); - - /** - * @brief Downcasts a handle to a LinearLayout 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 LinearLayout or an uninitialized handle - */ - static LinearLayout DownCast( BaseHandle handle ); - - /** - * @brief Copy constructor - */ - LinearLayout( const LinearLayout& other ); - - /** - * @brief Assigment operator - */ - LinearLayout& operator=( const LinearLayout& other ); - - /** - * @brief Default destructor. - * - * This is non-virtual, since derived Handle types must not contain data or virtual methods - */ - ~LinearLayout()=default; - - /** - * @brief Set the padding between cells in the layout - * - * @param[in] size The padding between cells. - */ - void SetCellPadding( LayoutSize size ); - - /** - * @brief Get the padding between cells in the layout - * - * @return The padding between cells. - */ - LayoutSize GetCellPadding() const; - - /** - * @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() const; - - /** - * @brief Set the alignment in the layout - * - * @param[in] alignment The alignment. - */ - void SetAlignment( unsigned int alignment ); - - /** - * @brief Get the alignment in the layout - * - * @return The alignment. - */ - unsigned int GetAlignment() const; - -public: // Not intended for application developers - - /// @cond internal - /** - * @brief This constructor is used by LinearLayout::New() methods. - * - * @param[in] actor A pointer to a newly allocated Dali resource - */ - explicit DALI_INTERNAL LinearLayout( Internal::LinearLayout* body ); - /// @endcond -}; - -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_LAYOUTING_LINEAR_LAYOUT_H diff --git a/dali-toolkit/devel-api/layouting/measure-spec.h b/dali-toolkit/devel-api/layouting/measure-spec.h deleted file mode 100755 index ccc23ed..0000000 --- a/dali-toolkit/devel-api/layouting/measure-spec.h +++ /dev/null @@ -1,175 +0,0 @@ -#ifndef DALI_TOOLKIT_LAYOUTING_MEASURE_SPEC_H -#define DALI_TOOLKIT_LAYOUTING_MEASURE_SPEC_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. - */ - -// EXTERNAL INCLUDES -#include -#include -#include - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ -namespace Toolkit -{ - -/** - * A MeasureSpec is used during the Measure pass by a LayoutGroup to inform it's children - * 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_TOOLKIT_API MeasureSpec -{ -public: - - enum class Mode - { - UNSPECIFIED, ///< This is used by a parent to determine the desired dimension of a child layout. - EXACTLY, /** This is used by a parent to impose an exact size on the child. The child must use - this size, and guarantee that all of its descendants will fit within this size */ - AT_MOST /** This is used by the parent to impose a maximum size on the child. The child must guarantee - * that it and all of it's descendants will fit within this size. */ - }; - - MeasureSpec( LayoutLength measureSpec, MeasureSpec::Mode mode ) - : mSize( measureSpec ), - mMode( mode ) - { - } - - MeasureSpec( LayoutLength measureSpec ) - : mSize( measureSpec ), - mMode( Mode::UNSPECIFIED ) - { - } - - ~MeasureSpec() = default; - - MeasureSpec& operator=( const MeasureSpec& rhs ) - { - if( this != &rhs ) - { - this->mSize = rhs.mSize; - this->mMode = rhs.mMode; - } - return *this; - } - - bool operator==( MeasureSpec value ) - { - return mSize == value.mSize; - } - - bool operator!=( MeasureSpec value ) - { - return mSize != value.mSize; - } - - /** - * @brief Set the mode of the measure spec. - * - * @param mode The mode to set - */ - void SetMode( MeasureSpec::Mode mode ) - { - mMode = mode; - } - - /** - * @brief Get the mode of the measure spec. - * - * @return The mode of the measure spec - */ - MeasureSpec::Mode GetMode() const - { - return mMode; - } - - /** - * @brief Set the size of the measure spec - * - * @param size the size to set - */ - void SetSize( LayoutLength size ) - { - mSize = size; - } - - /** - * @brief Get the size of the measure spec - * - * @return the size of the measure spec - */ - LayoutLength GetSize() const - { - return mSize; - } - - /** - * @brief Adjust the measure size by the given delta. - * - * Used only for EXACT and AT_MOST modes. - * @param[in] measureSpec the measure spec to adjust - * @param[in] delta A positive or negative value to adjust the measure spec by. - * - * @note if the adjusted size is negative, it is zeroed. - * @return A new measure spec with the adjusted values. - */ - static MeasureSpec Adjust( MeasureSpec measureSpec, int delta ) - { - auto mode = measureSpec.GetMode(); - auto size = measureSpec.GetSize(); - - if( mode == MeasureSpec::Mode::UNSPECIFIED ) - { - return MeasureSpec( size, MeasureSpec::Mode::UNSPECIFIED ); - } - - if( delta < 0 && measureSpec.mSize < abs(delta) ) - { - size = 0; - } - else - { - size += delta; - } - return MeasureSpec( size, mode ); - } - -private: - - LayoutLength mSize; ///< The specified size - Mode mMode; ///< The measure mode - -}; - -inline std::ostream& operator<< (std::ostream& o, const MeasureSpec& measureSpec ) -{ - return o << ( (measureSpec.GetMode() == MeasureSpec::Mode::UNSPECIFIED ? "Unspecified" - : (measureSpec.GetMode() == MeasureSpec::Mode::EXACTLY ? "Exactly":"At most" ) ) ) - << " " << measureSpec.GetSize(); -} - -} //namespace Toolkit -} //namespace Dali - - -#endif // DALI_TOOLKIT_LAYOUTING_MEASURE_SPEC_H diff --git a/dali-toolkit/devel-api/layouting/measured-size.h b/dali-toolkit/devel-api/layouting/measured-size.h deleted file mode 100755 index 5be02ac..0000000 --- a/dali-toolkit/devel-api/layouting/measured-size.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef DALI_TOOLKIT_LAYOUTING_MEASURED_SIZE_H -#define DALI_TOOLKIT_LAYOUTING_MEASURED_SIZE_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 -#include -#include - -namespace Dali -{ -namespace Toolkit -{ - -/** - * Class that encodes a measurement and a measure state, which is set if the measured size is too small. - */ -class DALI_TOOLKIT_API MeasuredSize -{ -public: - - enum State - { - MEASURED_SIZE_OK, ///< The measured size is good - MEASURED_SIZE_TOO_SMALL ///< The measured size is too small - }; - - MeasuredSize() - : mMeasuredSize( 0 ), - mState ( MeasuredSize::State::MEASURED_SIZE_OK ) - { - } - - MeasuredSize( LayoutLength measuredSize ) - : mMeasuredSize( measuredSize ), - mState ( MeasuredSize::State::MEASURED_SIZE_OK ) - { - } - - MeasuredSize( LayoutLength measuredSize, MeasuredSize::State state ) - : mMeasuredSize( measuredSize ), - mState( state ) - { - } - - ~MeasuredSize() = default; - - MeasuredSize& operator=( const MeasuredSize& rhs ) - { - if( this != &rhs ) - { - this->mMeasuredSize = rhs.mMeasuredSize; - this->mState = rhs.mState; - } - return *this; - } - - MeasuredSize& operator=( LayoutLength rhs ) - { - this->mMeasuredSize = rhs; - this->mState = State::MEASURED_SIZE_OK; - return *this; - } - - inline bool operator==( MeasuredSize value ) - { - return mMeasuredSize == value.mMeasuredSize; - } - - inline bool operator!=( MeasuredSize value ) - { - return mMeasuredSize != value.mMeasuredSize; - } - - inline void SetState( MeasuredSize::State state ) - { - mState = state; - } - - inline MeasuredSize::State GetState() - { - return mState; - } - - inline void SetSize( LayoutLength size ) - { - mMeasuredSize = size; - } - inline LayoutLength GetSize() - { - return mMeasuredSize; - } - -private: - LayoutLength mMeasuredSize; ///< The measured size - State mState; ///< The measured state -}; - -} //namespace Toolkit -} //namespace Dali - - -#endif // DALI_TOOLKIT_LAYOUTING_MEASURED_SIZE_H diff --git a/dali-toolkit/devel-api/layouting/vbox-layout.cpp b/dali-toolkit/devel-api/layouting/vbox-layout.cpp deleted file mode 100644 index b82166b..0000000 --- a/dali-toolkit/devel-api/layouting/vbox-layout.cpp +++ /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 - -//EXTERNAL HEADERS -//INTERNAL HEADERS -#include - -namespace Dali -{ -namespace Toolkit -{ - -VboxLayout::VboxLayout() -{ -} - -VboxLayout VboxLayout::New() -{ - Internal::VboxLayoutPtr internal = Internal::VboxLayout::New(); - return VboxLayout( internal.Get() ); -} - -VboxLayout VboxLayout::DownCast( BaseHandle handle ) -{ - return VboxLayout( dynamic_cast< Dali::Toolkit::Internal::VboxLayout*>( handle.GetObjectPtr() ) ); -} - -VboxLayout::VboxLayout( const VboxLayout& other ) -: LayoutGroup( other ) -{ -} - -VboxLayout& VboxLayout::operator=( const VboxLayout& other ) -{ - if( &other != this ) - { - LayoutGroup::operator=( other ); - } - return *this; -} - -void VboxLayout::SetCellPadding( LayoutSize size ) -{ - GetImplementation(*this).SetCellPadding( size ); -} - -LayoutSize VboxLayout::GetCellPadding() -{ - return GetImplementation(*this).GetCellPadding(); -} - -VboxLayout::VboxLayout( Dali::Toolkit::Internal::VboxLayout* object ) -: LayoutGroup( object ) -{ -} - -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/devel-api/layouting/vbox-layout.h b/dali-toolkit/devel-api/layouting/vbox-layout.h deleted file mode 100644 index 220872e..0000000 --- a/dali-toolkit/devel-api/layouting/vbox-layout.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef DALI_TOOLKIT_LAYOUTING_VBOX_LAYOUT_H -#define DALI_TOOLKIT_LAYOUTING_VBOX_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 -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ - -namespace Internal DALI_INTERNAL -{ -class VboxLayout; -} - -/** - * This class implements a vertical box layout, automatically handling - * right to left or left to right direction change. - */ -class DALI_TOOLKIT_API VboxLayout : public LayoutGroup -{ -public: - - enum PropertyRange - { - CHILD_PROPERTY_START_INDEX = LINEAR_LAYOUT_CHILD_PROPERTY_START_INDEX, - CHILD_PROPERTY_END_INDEX = LINEAR_LAYOUT_CHILD_PROPERTY_END_INDEX - }; - - struct ChildProperty - { - enum - { - WEIGHT = CHILD_PROPERTY_START_INDEX, - }; - }; - - /** - * @brief Creates an uninitialized VboxLayout handle. - * - * Initialize it using VboxLayout::New(). - * Calling member functions with an uninitialized handle is not allowed. - */ - VboxLayout(); - - /** - * @brief Creates a VboxLayout object. - */ - static VboxLayout New(); - - /** - * @brief Downcasts a handle to a VboxLayout handle. - * - * If handle points to a VboxLayout, the downcast produces a valid handle. - * If not, the returned handle is left uninitialized. - - * @param[in] handle to an object - * @return Handle to a VboxLayout or an uninitialized handle - */ - static VboxLayout DownCast( BaseHandle handle ); - - /** - * @brief Copy constructor - */ - VboxLayout( const VboxLayout& other ); - - /** - * @brief Assigment operator - */ - VboxLayout& operator=( const VboxLayout& other ); - - /** - * @brief Default destructor. - * - * This is non-virtual, since derived Handle types must not contain data or virtual methods - */ - ~VboxLayout()=default; - - /** - * @brief Set the padding between cells in the layout - * - * @param[in] size The padding between cells. - */ - void SetCellPadding( LayoutSize size ); - - /** - * @brief Get the padding between cells in the layout - * - * @return The padding between cells. - */ - LayoutSize GetCellPadding(); - -public: // Not intended for application developers - - /// @cond internal - /** - * @brief This constructor is used by VboxLayout::New() methods. - * - * @param[in] actor A pointer to a newly allocated Dali resource - */ - explicit DALI_INTERNAL VboxLayout( Internal::VboxLayout* body ); - /// @endcond -}; - -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_LAYOUTING_VBOX_LAYOUT_H diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index 0367037..3f8c7d8 100755 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -36,8 +36,6 @@ #include #include #include -#include -#include #include #include @@ -69,7 +67,6 @@ namespace #if defined(DEBUG_ENABLED) Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_CONTROL_VISUALS"); -Debug::Filter* gLogFilterLayout = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT"); #endif @@ -320,7 +317,6 @@ Control::Impl::Impl( Control& controlImpl ) : mControlImpl( controlImpl ), mState( Toolkit::DevelControl::NORMAL ), mSubStateName(""), - mLayout( NULL ), mLeftFocusableActorId( -1 ), mRightFocusableActorId( -1 ), mUpFocusableActorId( -1 ), @@ -343,8 +339,7 @@ Control::Impl::Impl( Control& controlImpl ) mInputMethodContext(), mFlags( Control::ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ), mIsKeyboardNavigationSupported( false ), - mIsKeyboardFocusGroup( false ), - mIsLayoutingRequired( false ) + mIsKeyboardFocusGroup( false ) { } @@ -1443,67 +1438,6 @@ bool Control::Impl::FilterKeyEvent( const KeyEvent& event ) return consumed; } -Toolkit::Internal::LayoutItemPtr Control::Impl::GetLayout() const -{ - return mLayout; -} - -void Control::Impl::SetLayout( Toolkit::Internal::LayoutItem& layout ) -{ - DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::SetLayout control:%s replacing existing layout:%s\n", - mControlImpl.Self().GetName().c_str(), - mLayout?"true":"false" ); - // Check if layout already has an owner. - auto control = Toolkit::Control::DownCast( layout.GetOwner() ); - if ( control ) - { - // If the owner is not this control then the owning control can no longer own it. - Dali::Toolkit::Control handle( mControlImpl.GetOwner() ); - if( control != handle ) - { - DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::SetLayout Layout already in use, %s will now have a BinLayout\n", - control.GetName().c_str() ); - Toolkit::BinLayout binLayout = Toolkit::BinLayout::New(); - // Previous owner of the layout gets a BinLayout instead of the layout. - DevelControl::SetLayout( control, binLayout ) ; - } - else - { - return; // layout is already set to this control. - } - } - - if( mLayout ) - { - mLayout->Unparent(); - mLayout.Reset(); - } - - mLayout = &layout; - - auto controlHandle = Toolkit::Control::DownCast( mControlImpl.Self() ); // Get a handle of this control implementation without copying internals. - mLayout->Initialize( controlHandle, controlHandle.GetTypeName() ); // LayoutGroup takes ownership of existing children -} - -void Control::Impl::RemoveLayout() -{ - DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::Impl::RemoveLayout\n"); - - Toolkit::BinLayout binLayout = Toolkit::BinLayout::New(); - - mControlImpl.mImpl->SetLayout( GetImplementation( binLayout ) ) ; -} - -void Control::Impl::SetLayoutingRequired( bool layoutingRequired ) -{ - mControlImpl.mImpl->mIsLayoutingRequired = layoutingRequired; -} - -bool Control::Impl::IsLayoutingRequired() -{ - return mControlImpl.mImpl->mIsLayoutingRequired; -} - DevelControl::VisualEventSignalType& Control::Impl::VisualEventSignal() { return mVisualEventSignal; diff --git a/dali-toolkit/internal/controls/control/control-data-impl.h b/dali-toolkit/internal/controls/control/control-data-impl.h index 634e7f6..2223215 100755 --- a/dali-toolkit/internal/controls/control/control-data-impl.h +++ b/dali-toolkit/internal/controls/control/control-data-impl.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_CONTROL_DATA_IMPL_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -333,37 +332,6 @@ public: bool FilterKeyEvent( const KeyEvent& event ); /** - * @brief Get the layout associated with this control, if any. - * - * @return A pointer to the layout, or NULL. - */ - Toolkit::Internal::LayoutItemPtr GetLayout() const; - - /** - * @brief Set the layout on this control. - * @param[in] layout Pointer to the layout - */ - void SetLayout( Toolkit::Internal::LayoutItem& layout ); - - /** - * @brief Remove the layout from this control - * - * @note This does not remove any children from this control, nor does it strip - * layouts from them but it does remove them from the layout hierarchy. - */ - void RemoveLayout(); - - /** - * @copydoc DevelControl::SetLayoutingRequired - */ - void SetLayoutingRequired( bool layoutingRequired ); - - /** - * @copydoc DevelControl::IsLayoutingRequired() - */ - bool IsLayoutingRequired(); - - /** * @copydoc DevelControl::VisualEventSignal() */ DevelControl::VisualEventSignalType& VisualEventSignal(); @@ -413,9 +381,6 @@ public: DevelControl::State mState; std::string mSubStateName; - // Layout - Toolkit::Internal::LayoutItemPtr mLayout; - int mLeftFocusableActorId; ///< Actor ID of Left focusable control. int mRightFocusableActorId; ///< Actor ID of Right focusable control. int mUpFocusableActorId; ///< Actor ID of Up focusable control. @@ -447,7 +412,6 @@ public: ControlBehaviour mFlags : CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor. bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control. bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group. - bool mIsLayoutingRequired :1; ///< Stores whether the control needs to be Layout RegisteredVisualContainer mRemoveVisuals; ///< List of visuals that are being replaced by another visual once ready diff --git a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp index 96b1b78..b2814a4 100755 --- a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp +++ b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -120,14 +120,14 @@ void ImageView::SetImage( Image image ) } else { - // Unregister the exsiting visual + // Unregister the existing visual DevelControl::UnregisterVisual( *this, Toolkit::ImageView::Property::IMAGE ); // Trigger a size negotiation request that may be needed when unregistering a visual. RelayoutRequest(); } - Toolkit::DevelControl::RequestLayout( *this ); + // Signal that a Relayout may be needed } void ImageView::SetImage( const Property::Map& map ) @@ -163,7 +163,7 @@ void ImageView::SetImage( const Property::Map& map ) RelayoutRequest(); } - Toolkit::DevelControl::RequestLayout( *this ); + // Signal that a Relayout may be needed } void ImageView::SetImage( const std::string& url, ImageDimensions size ) @@ -200,7 +200,7 @@ void ImageView::SetImage( const std::string& url, ImageDimensions size ) RelayoutRequest(); } - Toolkit::DevelControl::RequestLayout( *this ); + // Signal that a Relayout may be needed } Image ImageView::GetImage() const @@ -344,7 +344,7 @@ void ImageView::OnResourceReady( Toolkit::Control control ) { // Visual ready so update visual attached to this ImageView, following call to RelayoutRequest will use this visual. mVisual = DevelControl::GetVisual( *this, Toolkit::ImageView::Property::IMAGE ); - Toolkit::DevelControl::RequestLayout( *this ); + // Signal that a Relayout may be needed } /////////////////////////////////////////////////////////// diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index a2d866e..91a3940 100755 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -930,7 +930,7 @@ void TextLabel::OnRelayout( const Vector2& size, RelayoutContainer& container ) void TextLabel::RequestTextRelayout() { RelayoutRequest(); - Toolkit::DevelControl::RequestLayout( *this ); + // Signal that a Relayout may be needed } void TextLabel::SetUpAutoScrolling() diff --git a/dali-toolkit/internal/file.list b/dali-toolkit/internal/file.list index be6c728..cec9d3f 100755 --- a/dali-toolkit/internal/file.list +++ b/dali-toolkit/internal/file.list @@ -11,18 +11,6 @@ toolkit_src_files = \ $(toolkit_src_dir)/builder/style.cpp \ $(toolkit_src_dir)/builder/tree-node-manipulator.cpp \ $(toolkit_src_dir)/builder/replacement.cpp \ - $(toolkit_src_dir)/layouting/absolute-layout-impl.cpp \ - $(toolkit_src_dir)/layouting/bin-layout-impl.cpp \ - $(toolkit_src_dir)/layouting/flex-layout-impl.cpp \ - $(toolkit_src_dir)/layouting/grid-locations.cpp \ - $(toolkit_src_dir)/layouting/grid-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-controller-impl.cpp \ - $(toolkit_src_dir)/layouting/linear-layout-impl.cpp \ - $(toolkit_src_dir)/layouting/layout-transition-data-impl.cpp \ - $(toolkit_src_dir)/layouting/size-negotiation-mapper.cpp \ $(toolkit_src_dir)/visuals/animated-image/animated-image-visual.cpp \ $(toolkit_src_dir)/visuals/animated-image/image-cache.cpp \ $(toolkit_src_dir)/visuals/animated-image/fixed-image-cache.cpp \ diff --git a/dali-toolkit/internal/layouting/absolute-layout-impl.cpp b/dali-toolkit/internal/layouting/absolute-layout-impl.cpp deleted file mode 100644 index 8a635af..0000000 --- a/dali-toolkit/internal/layouting/absolute-layout-impl.cpp +++ /dev/null @@ -1,176 +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 - -//INTERNAL HEADERS -#include -#include -#include -#include -#include -#include - -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 }; - - LayoutLength minPositionX( 0 ); - LayoutLength minPositionY( 0 ); - LayoutLength maxPositionX( 0 ); - LayoutLength maxPositionY( 0 ); - - // measure children - for( unsigned int i=0; iGetOwner(); - - // Get size of child - MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec ); - LayoutLength childWidth = childLayout->GetMeasuredWidth(); - LayoutLength 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 ); - LayoutLength childLeft = childPosition.x; - LayoutLength childTop = childPosition.y; - - minPositionX = std::min( minPositionX, childLeft ); - maxPositionX = std::max( maxPositionX, childLeft + childWidth ); - // Children could overlap so find the highest and lowest child. - minPositionY = std::min( minPositionY, childTop ); - maxPositionY = std::max( maxPositionY, childTop + childHeight ); - - // Store current width and height needed to contain all children. - totalWidth = maxPositionX - minPositionX; - totalHeight = maxPositionY - minPositionY; - DALI_LOG_INFO( gLogFilter, Debug::Concise, "AbsoluteLayout::OnMeasure child width(%f) height(%f) \n", totalWidth.AsDecimal(), totalHeight.AsDecimal() ); - - 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(); - DALI_LOG_INFO( gLogFilter, Debug::Concise, "AbsoluteLayout::OnLayout child count(%d)\n", count ); - - for( unsigned int i = 0; i < count; i++) - { - LayoutItemPtr childLayout = GetChildAt( i ); - if( childLayout != nullptr ) - { - auto childOwner = childLayout->GetOwner(); - LayoutLength childWidth = childLayout->GetMeasuredWidth(); - LayoutLength childHeight = childLayout->GetMeasuredHeight(); - - auto childPosition = childOwner.GetProperty< Vector3 >( Actor::Property::POSITION ); - - LayoutLength childTop = childPosition.y; - LayoutLength childLeft = childPosition.x; - - DALI_LOG_STREAM( gLogFilter, Debug::General, - "AbsoluteLayout::OnLayout child[" << Toolkit::Control::DownCast( childOwner ).GetName().c_str() << - "] position(" << childPosition << ") child width[" << childWidth << "] height[" << childHeight << "]\n" ); - - childLayout->Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight ); - } - } -} - -} // namespace Internal -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/internal/layouting/absolute-layout-impl.h b/dali-toolkit/internal/layouting/absolute-layout-impl.h deleted file mode 100644 index 7b2d62b..0000000 --- a/dali-toolkit/internal/layouting/absolute-layout-impl.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_ABSOLUTE_LAYOUT_H -#define DALI_TOOLKIT_INTERNAL_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 -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -class AbsoluteLayout; -using AbsoluteLayoutPtr = IntrusivePtr; - -class AbsoluteLayout final : public LayoutGroup -{ -public: - static AbsoluteLayoutPtr New(); - -protected: - - /** - * Constructor - */ - AbsoluteLayout(); - - /** - * Destructor - */ - virtual ~AbsoluteLayout(); - - /** - * @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: - AbsoluteLayout( const AbsoluteLayout& other ) = delete; - AbsoluteLayout& operator=( const AbsoluteLayout& other ) = delete; - -}; - -} // namespace Internal - -inline Internal::AbsoluteLayout& GetImplementation( Dali::Toolkit::AbsoluteLayout& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "AbsoluteLayout handle is empty" ); - BaseObject& object = handle.GetBaseObject(); - return static_cast( object ); -} - -inline const Internal::AbsoluteLayout& GetImplementation( const Dali::Toolkit::AbsoluteLayout& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "AbsoluteLayout handle is empty" ); - const BaseObject& object = handle.GetBaseObject(); - return static_cast( object ); -} - -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_INTERNAL_ABSOLUTE_LAYOUT_H diff --git a/dali-toolkit/internal/layouting/bin-layout-impl.cpp b/dali-toolkit/internal/layouting/bin-layout-impl.cpp deleted file mode 100644 index 567fc39..0000000 --- a/dali-toolkit/internal/layouting/bin-layout-impl.cpp +++ /dev/null @@ -1,249 +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 - -//INTERNAL HEADERS -#include -#include -#include -#include -#include -#include -#include - -namespace -{ -#if defined(DEBUG_ENABLED) -static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" ); -#endif -} - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -BinLayoutPtr BinLayout::New() -{ - BinLayoutPtr layout( new BinLayout() ); - return layout; -} - -BinLayout::BinLayout() -: LayoutGroup() -{ -} - -BinLayout::~BinLayout() -{ -} - -void BinLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) -{ -#if defined(DEBUG_ENABLED) - auto actor = Actor::DownCast(GetOwner()); - - std::ostringstream oss; - oss << "BinLayout::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 - - auto childCount = GetChildCount(); - - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, - "BinLayout::OnMeasure Actor Id:" << Actor::DownCast(GetOwner()).GetId() << - " Owner:" << Actor::DownCast(GetOwner()).GetName() << - " Child Count:" << childCount << - " MeasureSpecs( width:"< 0 ) - { - for( unsigned int i=0; iGetOwner()); - - // If child control has children check if a ResizePolicy is set on it. A LayoutItem could be a legacy container. - // A legacy container would need it's ResizePolicy to be applied as a MeasureSpec. - - // Check below will be true for legacy containers and for controls with the layout flag required set. - // Other layouts will have their own OnMeasure (a requirement) hence not execute BinLayout::OnMeasure. - // Controls which have set the layout required flag will not be legacy controls hence should not have a ResizePolicy set. - if( childControl.GetChildCount() > 0 ) - { - // First pass, Static mappings that are not dependant on parent - SizeNegotiationMapper::SetLayoutParametersUsingResizePolicy( childControl, childLayout, Dimension::WIDTH ); - SizeNegotiationMapper::SetLayoutParametersUsingResizePolicy( childControl, childLayout, Dimension::HEIGHT ); - } - - // Second pass, if any mappings were not possible due to parent size dependencies then calculate an exact desired size for child - if( true == childLayout->IsResizePolicyRequired() ) // No need to test child count as this flag would only be set if control had children. - { - // Get last stored width and height specifications for the child - LayoutLength desiredWidth = childControl.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); - LayoutLength desiredHeight = childControl.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ); - - DALI_LOG_INFO( gLogFilter, Debug::General, "BinLayout::MeasureChild Initial desired size pre ResizePolicy(%f,%f)\n", desiredWidth.AsInteger(), desiredHeight.AsInteger() ); - - childLayout->SetResizePolicyRequired( false ); // clear flag incase in case of changes before next Measure - SizeNegotiationMapper::GetSizeofChildForParentDependentResizePolicy( childControl, widthMeasureSpec, heightMeasureSpec, desiredWidth, desiredHeight ); - - // Parent dependant ResizePolicies become exact sizes so are now set on the child before it's measured. - childControl.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, desiredWidth.AsInteger() ); - childControl.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, desiredHeight.AsInteger() ); - - DALI_LOG_INFO( gLogFilter, Debug::General, " BinLayout::OnMeasure ResizePolicy Required resulting size(%f,%f)\n", desiredWidth.AsInteger(), desiredHeight.AsInteger() ); - } - - // Get size of child - MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec ); - LayoutLength childWidth = childLayout->GetMeasuredWidth(); - LayoutLength childHeight = childLayout->GetMeasuredHeight(); - - Extents childMargin = childLayout->GetMargin(); - - // BinLayout width is that of it's widest child and it's height of the tallest child. - // MeasureSpec::Mode::UNSPECIFIED will use these sizes - layoutWidth = std::max( layoutWidth, childWidth + childMargin.start + childMargin.end ); - layoutHeight = std::max( layoutHeight, childHeight + childMargin.top + childMargin.bottom ); - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "BinLayout::OnMeasure calculated current BinLayout width[" << layoutWidth << "] height[" << layoutHeight << "]\n" ); - } - else - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "BinLayout::OnMeasure Not a layout\n" ); - } - } - - Extents padding = GetPadding(); - layoutWidth += padding.start + padding.end; - layoutHeight += padding.top + padding.bottom; - } - else - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "BinLayout::OnMeasure Getting default size as a leaf\n" ); - // BinLayout does not contain any children so must be a leaf - layoutWidth = GetDefaultSize( GetSuggestedMinimumWidth(), widthMeasureSpec ); - layoutHeight = GetDefaultSize( GetSuggestedMinimumHeight(), heightMeasureSpec ); - } - - // Can't exceed specified width - if( widthMode == MeasureSpec::Mode::EXACTLY ) - { - exactWidth = true; - } - else if ( widthMode == MeasureSpec::Mode::AT_MOST ) - { - layoutWidth = std::min( layoutWidth, widthSpecSize ); - } - - // Can't exceed specified height - if( heightMode == MeasureSpec::Mode::EXACTLY ) - { - exactHeight = true; - } - else if ( heightMode == MeasureSpec::Mode::AT_MOST ) - { - layoutHeight = std::min( layoutHeight, heightSpecSize ); - } - - layoutWidth = std::max( layoutWidth, GetSuggestedMinimumWidth() ); - layoutHeight = std::max( layoutHeight, GetSuggestedMinimumHeight() ); - - if( exactWidth ) - { - layoutWidth = widthSpecSize; - } - - if( exactHeight ) - { - layoutHeight = heightSpecSize; - } - - DALI_LOG_STREAM( gLogFilter, Debug::General, "BinLayout::OnMeasure Measured size(" << layoutWidth << "," << layoutHeight << ") for : " << Actor::DownCast(GetOwner()).GetName() << " \n" ); - SetMeasuredDimensions( MeasuredSize( layoutWidth ), MeasuredSize( layoutHeight ) ); - -} - -void BinLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ) -{ - auto count = GetChildCount(); - - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "BinLayout OnLayout owner:" << ( ( Toolkit::Control::DownCast(GetOwner())) ? Toolkit::Control::DownCast(GetOwner()).GetName() : "invalid" ) << " childCount:" << count ); - - for( unsigned int childIndex = 0; childIndex < count; childIndex++) - { - LayoutItemPtr childLayout = GetChildAt( childIndex ); - if( childLayout != nullptr ) - { - - auto childOwner = childLayout->GetOwner(); - LayoutLength childWidth = childLayout->GetMeasuredWidth(); - LayoutLength childHeight = childLayout->GetMeasuredHeight(); - Extents childMargin = childLayout->GetMargin(); - auto control = Toolkit::Control::DownCast( childOwner ); - Extents padding = GetPadding(); - - auto childPosition = control.GetProperty< Vector3 >( Actor::Property::POSITION ); - auto anchorPoint = control.GetProperty< Vector3 >( Actor::Property::ANCHOR_POINT ); - - DALI_LOG_STREAM( gLogFilter, Debug::General, "BinLayout::OnLayout child[" << control.GetName() << - "] position(" << childPosition << ") child width[" << childWidth << "] height[" << childHeight << "]\n" ); - - // Margin and Padding only supported when child anchor point is TOP_LEFT. - int paddingAndMarginOffsetX = ( AnchorPoint::TOP_LEFT == anchorPoint ) ? ( padding.top + childMargin.top ) : 0; - int paddingAndMarginOffsetY = ( AnchorPoint::TOP_LEFT == anchorPoint ) ? ( padding.start + childMargin.start ) : 0; - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "BinLayout::OnLayout paddingMargin offset(%d,%d)\n", paddingAndMarginOffsetX, paddingAndMarginOffsetY ); - - LayoutLength childLeft = childPosition.x + paddingAndMarginOffsetX; - LayoutLength childTop = childPosition.y + paddingAndMarginOffsetY; - - childLayout->Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight ); - } - } -} - -} // namespace Internal -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/internal/layouting/bin-layout-impl.h b/dali-toolkit/internal/layouting/bin-layout-impl.h deleted file mode 100644 index d20ea64..0000000 --- a/dali-toolkit/internal/layouting/bin-layout-impl.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_BIN_LAYOUT_H -#define DALI_TOOLKIT_INTERNAL_BIN_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 -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -class BinLayout; -using BinLayoutPtr = IntrusivePtr; - -class BinLayout final : public LayoutGroup -{ -public: - static BinLayoutPtr New(); - -protected: - - /** - * Constructor - */ - BinLayout(); - - /** - * Destructor - */ - virtual ~BinLayout(); - - /** - * @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: - BinLayout( const BinLayout& other ) = delete; - BinLayout& operator=( const BinLayout& other ) = delete; - -}; - -} // namespace Internal - -inline Internal::BinLayout& GetImplementation( Dali::Toolkit::BinLayout& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "BinLayout handle is empty" ); - BaseObject& object = handle.GetBaseObject(); - return static_cast( object ); -} - -inline const Internal::BinLayout& GetImplementation( const Dali::Toolkit::BinLayout& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "BinLayout handle is empty" ); - const BaseObject& object = handle.GetBaseObject(); - return static_cast( object ); -} - -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_INTERNAL_BIN_LAYOUT_H diff --git a/dali-toolkit/internal/layouting/flex-layout-impl.cpp b/dali-toolkit/internal/layouting/flex-layout-impl.cpp deleted file mode 100755 index 0090ec8..0000000 --- a/dali-toolkit/internal/layouting/flex-layout-impl.cpp +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright (c) 2019 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 "flex-layout-impl.h" - -//EXTERNAL INCLUDES -#include -#include -#include -#include - -//INTERNAL INCLUDES -#include -#include -#include -#include - -#if defined(DEBUG_ENABLED) -static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" ); -#endif - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -FlexLayoutPtr FlexLayout::New() -{ - FlexLayoutPtr layout( new FlexLayout() ); - return layout; -} - -void FlexLayout::SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection flexDirection ) -{ - YGNodeStyleSetFlexDirection( mRoot, static_cast(flexDirection) ); -} - -Dali::Toolkit::FlexLayout::FlexDirection FlexLayout::GetFlexDirection() const -{ - return static_cast(YGNodeStyleGetFlexDirection( mRoot )); -} - -void FlexLayout::SetFlexJustification( Dali::Toolkit::FlexLayout::Justification flexJustification ) -{ - YGNodeStyleSetJustifyContent( mRoot, static_cast(flexJustification) ); -} - -Dali::Toolkit::FlexLayout::Justification FlexLayout::GetFlexJustification() const -{ - return static_cast(YGNodeStyleGetJustifyContent( mRoot )); -} - -void FlexLayout::SetFlexWrap( Dali::Toolkit::FlexLayout::WrapType wrapType ) -{ - YGNodeStyleSetFlexWrap( mRoot, static_cast(wrapType) ); -} - -Dali::Toolkit::FlexLayout::WrapType FlexLayout::GetFlexWrap() const -{ - return static_cast(YGNodeStyleGetFlexWrap( mRoot )); -} - -void FlexLayout::SetFlexAlignment( Dali::Toolkit::FlexLayout::Alignment::Type flexAlignment ) -{ - YGNodeStyleSetAlignContent( mRoot, static_cast(flexAlignment) ); -} - -Dali::Toolkit::FlexLayout::Alignment::Type FlexLayout::GetFlexAlignment() const -{ - return static_cast(YGNodeStyleGetAlignContent( mRoot )); -} - -void FlexLayout::SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::Type flexAlignment ) -{ - YGNodeStyleSetAlignItems( mRoot, static_cast(flexAlignment) ); -} - -Dali::Toolkit::FlexLayout::Alignment::Type FlexLayout::GetFlexItemsAlignment() const -{ - return static_cast(YGNodeStyleGetAlignItems( mRoot )); -} - -FlexLayout::FlexLayout() -: LayoutGroup(), - mRoot( nullptr ) -{ - mRoot = YGNodeNew(); - YGNodeSetContext( mRoot, this ); - - // Set default style - YGNodeStyleSetFlexDirection( mRoot, YGFlexDirectionColumn ); - YGNodeStyleSetFlexWrap( mRoot, YGWrapNoWrap ); - YGNodeStyleSetJustifyContent( mRoot, YGJustifyFlexStart ); - YGNodeStyleSetAlignContent( mRoot, YGAlignFlexStart ); - YGNodeStyleSetAlignItems( mRoot, YGAlignFlexStart ); -} - -FlexLayout::~FlexLayout() -{ - if( mRoot ) - { - YGNodeFreeRecursive( mRoot ); - } -} - -void FlexLayout::DoInitialize() -{ -} - -void FlexLayout::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::FlexLayout::ChildProperty::FLEX ) == - indices.End() ) - { - ChildPropertyRegistration( typeInfo.GetName(), "flex", Toolkit::FlexLayout::ChildProperty::FLEX, Property::FLOAT ); - } - - if( std::find( indices.Begin(), indices.End(), Toolkit::FlexLayout::ChildProperty::ALIGN_SELF ) == - indices.End() ) - { - ChildPropertyRegistration( typeInfo.GetName(), "alignSelf", Toolkit::FlexLayout::ChildProperty::ALIGN_SELF, Property::INTEGER ); - } - } -} - -void FlexLayout::OnChildAdd( LayoutItem& child ) -{ - auto owner = child.GetOwner(); - if(!DevelHandle::DoesCustomPropertyExist(owner, Toolkit::FlexLayout::ChildProperty::FLEX )) - { - owner.SetProperty( Toolkit::FlexLayout::ChildProperty::FLEX, 0 ); - } - if(!DevelHandle::DoesCustomPropertyExist(owner, Toolkit::FlexLayout::ChildProperty::ALIGN_SELF )) - { - owner.SetProperty( Toolkit::FlexLayout::ChildProperty::ALIGN_SELF, YGAlignAuto ); - } - - YGNodeRef node = YGNodeNew(); - YGNodeSetContext( node, &child ); - YGNodeSetMeasureFunc( node, OnChildMeasure ); - YGNodeMarkDirty( node ); - YGNodeInsertChild( mRoot, node, GetChildCount()-1 ); -} - -void FlexLayout::OnChildRemove( LayoutItem& child ) -{ - auto count = GetChildCount(); - for( unsigned int childIndex = 0; childIndex < count; childIndex++) - { - LayoutItemPtr childLayout = GetChildAt( childIndex ); - if( &child == childLayout.Get() ) - { - YGNodeRef node = YGNodeGetChild( mRoot, childIndex ); - YGNodeRemoveChild( mRoot, node ); - break; - } - } -} - -void FlexLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) -{ - auto actor = Actor::DownCast(GetOwner()); - bool isLayoutRtl = actor ? actor.GetProperty( Actor::Property::LAYOUT_DIRECTION ) == LayoutDirection::RIGHT_TO_LEFT: false; - Extents padding = GetPadding(); - Extents margin = GetMargin(); - -#if defined(DEBUG_ENABLED) - std::ostringstream oss; - oss << "FlexLayout::OnMeasure "; - if( actor ) - { - oss << "Actor Id:" << actor.GetId() << " Name:" << actor.GetName() << " Layout direction:" << actor.GetProperty( Actor::Property::LAYOUT_DIRECTION ).Get() << " "; - } - oss << "widthMeasureSpec:" << widthMeasureSpec << " heightMeasureSpec:" << heightMeasureSpec << std::endl; - DALI_LOG_INFO( gLogFilter, Debug::Concise, oss.str().c_str() ); -#endif - - YGNodeStyleSetMargin( mRoot, YGEdgeLeft, margin.start ); - YGNodeStyleSetMargin( mRoot, YGEdgeTop, margin.top ); - YGNodeStyleSetMargin( mRoot, YGEdgeRight, margin.end ); - YGNodeStyleSetMargin( mRoot, YGEdgeBottom, margin.bottom ); - YGNodeStyleSetPadding( mRoot, YGEdgeLeft, padding.start ); - YGNodeStyleSetPadding( mRoot, YGEdgeTop, padding.top ); - YGNodeStyleSetPadding( mRoot, YGEdgeRight, padding.end ); - YGNodeStyleSetPadding( mRoot, YGEdgeBottom, padding.bottom ); - - float width = YGUndefined; - float height = YGUndefined; - - YGNodeStyleSetWidth( mRoot, YGUndefined ); - YGNodeStyleSetHeight( mRoot, YGUndefined ); - YGNodeStyleSetMinWidth( mRoot, YGUndefined ); - YGNodeStyleSetMinHeight( mRoot, YGUndefined ); - YGNodeStyleSetMaxWidth( mRoot, YGUndefined ); - YGNodeStyleSetMaxHeight( mRoot, YGUndefined ); - - if( widthMeasureSpec.GetMode() == MeasureSpec::Mode::EXACTLY ) - { - width = widthMeasureSpec.GetSize().AsDecimal(); - YGNodeStyleSetWidth( mRoot, width ); - } - else if( widthMeasureSpec.GetMode() == MeasureSpec::Mode::AT_MOST ) - { - width = widthMeasureSpec.GetSize().AsDecimal(); - YGNodeStyleSetMaxWidth( mRoot, width ); - } - - if ( heightMeasureSpec.GetMode() == MeasureSpec::Mode::EXACTLY ) - { - height = heightMeasureSpec.GetSize().AsDecimal(); - YGNodeStyleSetHeight( mRoot, height ); - } - else if ( heightMeasureSpec.GetMode() == MeasureSpec::Mode::AT_MOST ) - { - height = heightMeasureSpec.GetSize().AsDecimal(); - YGNodeStyleSetMaxHeight( mRoot, height ); - } - - SetChildrenStyle(); - YGNodeCalculateLayout( mRoot, width, height, isLayoutRtl ? YGDirectionRTL : YGDirectionLTR ); - SetMeasuredDimensions( GetDefaultSize( YGNodeLayoutGetWidth(mRoot), widthMeasureSpec ), - GetDefaultSize( YGNodeLayoutGetHeight(mRoot), heightMeasureSpec ) ); -} - -void FlexLayout::OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ) -{ - auto owner = GetOwner(); - auto actor = Actor::DownCast(owner); - bool isLayoutRtl = actor ? actor.GetProperty( Actor::Property::LAYOUT_DIRECTION ).Get() == LayoutDirection::RIGHT_TO_LEFT: false; - LayoutLength width = right - left; - LayoutLength height = bottom - top; - -#if defined(DEBUG_ENABLED) - std::ostringstream oss; - oss << "FlexLayout::OnLayout "; - if( actor ) - { - oss << "Actor Id:" << actor.GetId() << " Name:" << actor.GetName() << " Layout direction:" << actor.GetProperty( Actor::Property::LAYOUT_DIRECTION ).Get() << " "; - } - oss << "changed:" << (int)changed << " left:" << left << " top:" << top << " right:" << right << " bottom:" << bottom << " isLayoutRtl:" << (int)isLayoutRtl << std::endl; - DALI_LOG_INFO( gLogFilter, Debug::Concise, oss.str().c_str() ); -#endif - - YGNodeCalculateLayout( mRoot, width.AsDecimal(), height.AsDecimal(), isLayoutRtl ? YGDirectionRTL : YGDirectionLTR ); - - auto count = GetChildCount(); - for( unsigned int childIndex = 0; childIndex < count; childIndex++) - { - LayoutItemPtr childLayout = GetChildAt( childIndex ); - if( childLayout != nullptr ) - { - YGNodeRef node = YGNodeGetChild(mRoot, childIndex); - LayoutLength childLeft = LayoutLength( YGNodeLayoutGetLeft( node ) )+ left; - LayoutLength childTop = LayoutLength( YGNodeLayoutGetTop( node ) ) + top; - LayoutLength childWidth = LayoutLength( YGNodeLayoutGetWidth( node ) ); - LayoutLength childHeight = LayoutLength( YGNodeLayoutGetHeight( node ) ); - childLayout->Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight ); - } - } -} - -YGSize FlexLayout::OnChildMeasure( YGNodeRef node, - float innerWidth, - YGMeasureMode widthMode, - float innerHeight, - YGMeasureMode heightMode ) { - LayoutItem* childLayout = static_cast(node->getContext()); - auto childOwner = childLayout->GetOwner(); - auto desiredWidth = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); - auto desiredHeight = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ); - MeasureSpec parentWidthMeasureSpec( 0 ); - if ( innerWidth != YGUndefined ) - { - parentWidthMeasureSpec = MeasureSpec( innerWidth, static_cast(widthMode) ); - } - auto parentHeightMeasureSpec = MeasureSpec( 0 ); - if ( innerHeight != YGUndefined ) - { - parentHeightMeasureSpec = MeasureSpec( innerHeight, static_cast(heightMode) ); - } - auto childWidthMeasureSpec = LayoutGroup::GetChildMeasureSpec( parentWidthMeasureSpec, 0, desiredWidth); - auto childHeightMeasureSpec = LayoutGroup::GetChildMeasureSpec( parentHeightMeasureSpec, 0, desiredHeight); - - // Force to fill parent if a child wants to match parent even if GetChildMeasureSpec sets otherwise - if( desiredWidth == Toolkit::ChildLayoutData::MATCH_PARENT && innerWidth != YGUndefined ) - { - childWidthMeasureSpec = MeasureSpec( innerWidth, MeasureSpec::Mode::EXACTLY ); - } - if( desiredHeight == Toolkit::ChildLayoutData::MATCH_PARENT && innerHeight != YGUndefined ) - { - childHeightMeasureSpec = MeasureSpec( innerHeight, MeasureSpec::Mode::EXACTLY ); - } - -#if defined(DEBUG_ENABLED) - auto actor = Actor::DownCast(childOwner); - std::ostringstream oss; - oss << "FlexLayout::OnChildMeasure "; - if( actor ) - { - oss << "Actor Id:" << actor.GetId() << " Name:" << actor.GetName() << " "; - } - oss << "innerWidth:" << ( ( innerWidth == YGUndefined ) ? "YGUndefined " : "" ) << innerWidth << - " innerHeight:" << ( ( innerHeight == YGUndefined ) ? "YGUndefined " : "" ) << innerHeight << - " desiredWidth:" << desiredWidth << " desiredHeight:" << desiredHeight << - " childWidthMeasureSpec:" << childWidthMeasureSpec << " childHeightMeasureSpec:" << childHeightMeasureSpec << std::endl; - DALI_LOG_INFO( gLogFilter, Debug::Concise, oss.str().c_str() ); -#endif - - childLayout->Measure( childWidthMeasureSpec, childHeightMeasureSpec ); - - // Remove padding here since Yoga doesn't consider it as a part of the node size - Extents padding = childLayout->GetPadding(); - LayoutLength measuredWidth = childLayout->GetMeasuredWidth() - padding.end - padding.start; - LayoutLength measuredHeight = childLayout->GetMeasuredHeight() - padding.bottom - padding.top; - - // Create struct instance first and manually set params to support all compiler versions - YGSize ygSize; - ygSize.width = measuredWidth.AsDecimal(); - ygSize.height = measuredHeight.AsDecimal(); - return ygSize; -} - -void FlexLayout::SetChildrenStyle() -{ - if( mRoot ) - { - auto count = GetChildCount(); - for( unsigned int childIndex = 0; childIndex < count; childIndex++) - { - LayoutItemPtr childLayout = GetChildAt( childIndex ); - if( childLayout != nullptr ) - { - Extents padding = childLayout->GetPadding(); - Extents margin = childLayout->GetMargin(); - auto childOwner = childLayout->GetOwner(); - auto childActor = Actor::DownCast(childOwner); - auto flex = childOwner.GetProperty( Toolkit::FlexLayout::ChildProperty::FLEX ); - auto alignSelf = static_cast( childOwner.GetProperty( Toolkit::FlexLayout::ChildProperty::ALIGN_SELF )); - - YGNodeRef childNode = YGNodeGetChild( mRoot, childIndex ); - // Initialise the style of the child. - YGNodeStyleSetMargin( childNode, YGEdgeLeft, margin.start ); - YGNodeStyleSetMargin( childNode, YGEdgeTop, margin.top ); - YGNodeStyleSetMargin( childNode, YGEdgeRight, margin.end ); - YGNodeStyleSetMargin( childNode, YGEdgeBottom, margin.bottom ); - - YGNodeStyleSetPadding( childNode, YGEdgeLeft, padding.start ); - YGNodeStyleSetPadding( childNode, YGEdgeTop, padding.top ); - YGNodeStyleSetPadding( childNode, YGEdgeRight, padding.end ); - YGNodeStyleSetPadding( childNode, YGEdgeBottom, padding.bottom ); - - YGNodeStyleSetWidth( childNode, YGUndefined ); - YGNodeStyleSetHeight( childNode, YGUndefined ); - // TODO: check if we are supposed to use actor properties here, max/min is needed for stretch - YGNodeStyleSetMinWidth( childNode, childActor.GetMinimumSize().x ); - YGNodeStyleSetMinHeight( childNode, childActor.GetMinimumSize().y ); - if( childActor.GetMaximumSize().x == FLT_MAX ) - { - YGNodeStyleSetMaxWidth( childNode, YGUndefined ); - } - else - { - YGNodeStyleSetMaxWidth( childNode, childActor.GetMaximumSize().x ); - } - if( childActor.GetMaximumSize().y == FLT_MAX ) - { - YGNodeStyleSetMaxHeight( childNode, YGUndefined ); - } - else - { - YGNodeStyleSetMaxHeight( childNode, childActor.GetMaximumSize().y ); - } - - YGNodeStyleSetFlex( childNode, flex ); - YGNodeStyleSetAlignSelf( childNode, alignSelf ); - - // Have to do manually for nodes with custom measure function - // TODO: check the style is changed before marking the node - YGNodeMarkDirty( childNode ); - } - } - } -} - -} // namespace Internal -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/internal/layouting/flex-layout-impl.h b/dali-toolkit/internal/layouting/flex-layout-impl.h deleted file mode 100644 index b2bd236..0000000 --- a/dali-toolkit/internal/layouting/flex-layout-impl.h +++ /dev/null @@ -1,165 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_FLEX_LAYOUT_H -#define DALI_TOOLKIT_INTERNAL_LAYOUTING_FLEX_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. - */ - -//EXTERNAL INCLUDES -#include -#include - -//INTERNAL INCLUDES -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -class FlexLayout; -using FlexLayoutPtr = IntrusivePtr; - -class FlexLayout final : public LayoutGroup -{ -public: - static FlexLayoutPtr New(); - -public: - /** - * @copydoc FlexLayout::SetFlexDirection - */ - void SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection flexDirection ); - - /** - * @copydoc FlexLayout::GetFlexDirection - */ - Dali::Toolkit::FlexLayout::FlexDirection GetFlexDirection() const; - - /** - * @copydoc FlexLayout::SetFlexJustification - */ - void SetFlexJustification( Dali::Toolkit::FlexLayout::Justification flexJustification ); - - /** - * @copydoc FlexLayout::GetFlexJustification - */ - Dali::Toolkit::FlexLayout::Justification GetFlexJustification() const; - - /** - * @copydoc FlexLayout::SetFlexWrap - */ - void SetFlexWrap( Dali::Toolkit::FlexLayout::WrapType wrap ); - - /** - * @copydoc FlexLayout::GetFlexWrap - */ - Dali::Toolkit::FlexLayout::WrapType GetFlexWrap() const; - - /** - * @copydoc FlexLayout::SetFlexAlignment - */ - void SetFlexAlignment( Dali::Toolkit::FlexLayout::Alignment::Type flexAlignment ); - /** - * @copydoc FlexLayout::GetFlexAlignment - */ - Dali::Toolkit::FlexLayout::Alignment::Type GetFlexAlignment() const; - - /** - * @copydoc FlexLayout::SetFlexItemsAlignment - */ - void SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::Type flexAlignment ); - - /** - * @copydoc FlexLayout::GetFlexItemsAlignment - */ - Dali::Toolkit::FlexLayout::Alignment::Type GetFlexItemsAlignment() const; - -protected: - /** - * Constructor - */ - FlexLayout(); - - /** - * Virtual destructor - */ - virtual ~FlexLayout(); - - /** - * @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::OnChildRemove - */ - virtual void OnChildRemove( 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: - FlexLayout( const FlexLayout& other ) = delete; - FlexLayout& operator=( const FlexLayout& other ) = delete; - - static YGSize OnChildMeasure( YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode ); - void SetChildrenStyle(); - -private: - YGNodeRef mRoot; -}; - -} // namespace Internal - -inline Internal::FlexLayout& GetImplementation( Dali::Toolkit::FlexLayout& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "FboxLayout handle is empty" ); - BaseObject& object = handle.GetBaseObject(); - return static_cast( object ); -} - -inline const Internal::FlexLayout& GetImplementation( const Dali::Toolkit::FlexLayout& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "FboxLayout handle is empty" ); - const BaseObject& object = handle.GetBaseObject(); - return static_cast( object ); -} - -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_FLEX_LAYOUT_H diff --git a/dali-toolkit/internal/layouting/grid-impl.cpp b/dali-toolkit/internal/layouting/grid-impl.cpp deleted file mode 100644 index b633523..0000000 --- a/dali-toolkit/internal/layouting/grid-impl.cpp +++ /dev/null @@ -1,267 +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 - -//EXTERNAL HEADERS -#include -#include -#include - -//INTERNAL HEADERS -#include -#include -#include -#include -#include - -#if defined(DEBUG_ENABLED) -static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_LAYOUT" ); -#endif - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -GridPtr Grid::New() -{ - GridPtr layout( new Grid() ); - return layout; -} - -Grid::Grid() -: LayoutGroup(), - mTotalHeight( 0 ), - mTotalWidth( 0 ), - mNumColumns( 1 ), - mNumRows( 1 ), - mRequestedColumnWidth( 0 ), - mRequestedNumColumns( AUTO_FIT ) -{ - mLocations = GridLocations::New(); -} - -Grid::~Grid(){} - -void Grid::SetNumberOfColumns( int columns ) -{ - mRequestedNumColumns = columns; - // Store value and Relayout if changed. - if( columns != mNumColumns ) - { - mNumColumns = std::max( 1, columns ); - RequestLayout(); - } -} - -int Grid::GetNumberOfColumns() const -{ - return mNumColumns; -} - -void Grid::DetermineNumberOfColumns( LayoutLength availableSpace ) -{ - if( mRequestedNumColumns == AUTO_FIT ) - { - if( availableSpace > 0 ) - { - // Can only calculate number of columns if a column width has been set - mNumColumns = ( mRequestedColumnWidth > 0 ) ? ( availableSpace.AsInteger() / mRequestedColumnWidth ) : 1; - } - } -} - -void Grid::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) -{ - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, - "Grid::OnMeasure Actor Id:" << Actor::DownCast(GetOwner()).GetId() << - " Owner:" << Actor::DownCast(GetOwner()).GetName() << - " MeasureSpecs( width:"< 0 ) - { - auto childLayoutItem = GetChildAt( 0 ); - if( childLayoutItem ) - { - auto childOwner = childLayoutItem->GetOwner(); - - MeasureChild( childLayoutItem, widthMeasureSpec, heightMeasureSpec ); - desiredChildHeight = childLayoutItem->GetMeasuredHeight(); - desiredChildWidth = childLayoutItem->GetMeasuredWidth(); - - // If child has a margin then add it to desired size - Extents childMargin = childOwner.GetProperty( Toolkit::Control::Property::MARGIN ); - desiredChildHeight += childMargin.top + childMargin.bottom; - desiredChildWidth += childMargin.start + childMargin.end; - - mTotalWidth = desiredChildWidth * mNumColumns; - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "Grid::OnMeasure TotalDesiredWidth(" << mTotalWidth << ") \n" ); - } // Child is LayoutItem - } // Child exists - - // Include padding for max and min checks - mTotalWidth += gridLayoutPadding.start + gridLayoutPadding.end; - - // Ensure width does not exceed specified atmost width or less than mininum width - mTotalWidth = std::max( mTotalWidth, GetSuggestedMinimumWidth() ); - - // widthMode EXACTLY so grid must be the given width - if( gridWidthMode == MeasureSpec::Mode::EXACTLY || gridWidthMode == MeasureSpec::Mode::AT_MOST ) - { - // In the case of AT_MOST, widthSize is the max limit. - mTotalWidth = std::min( mTotalWidth, widthSize ); - } - - availableContentWidth = mTotalWidth - gridLayoutPadding.start - gridLayoutPadding.end; - widthSize = mTotalWidth; - - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "Grid::OnMeasure availableContentWidth" << availableContentWidth << " mTotalWidth(" << mTotalWidth << ") \n" ); - // HEIGHT SPECIFICATIONS - - // heightMode EXACTLY so grid must be the given height - if( gridHeightMode == MeasureSpec::Mode::EXACTLY || gridHeightMode == MeasureSpec::Mode::AT_MOST ) - { - if( childCount > 0 ) - { - mTotalHeight = gridLayoutPadding.top + gridLayoutPadding.bottom; - - for( auto i = 0u; i < childCount; i += mNumColumns ) - { - mTotalHeight += desiredChildHeight; - } - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "Grid::OnMeasure TotalDesiredHeight(" << mTotalHeight << ") \n" ); - - // Ensure ourHeight does not exceed specified atmost height - mTotalHeight = std::min( mTotalHeight, heightSize ); - mTotalHeight = std::max( mTotalHeight, GetSuggestedMinimumHeight() ); - - heightSize = mTotalHeight; - } // Child exists - - // In the case of AT_MOST, availableContentHeigth is the max limit. - availableContentHeight = heightSize - gridLayoutPadding.top - gridLayoutPadding.bottom; - } - else - { - // Grid expands to fit content - - // If number of columns AUTO_FIT then set to 1 column. - mNumColumns = ( mNumColumns > 0 ) ? mNumColumns : 1; - // Calculate numbers of rows, round down result as later check for remainder. - mNumRows = childCount / mNumColumns; - // If number of cells not cleanly dividable by colums, add another row to house remainder cells. - mNumRows += ( childCount % mNumColumns ) ? 1 : 0; - - availableContentHeight = desiredChildHeight * mNumRows; - } - - // If number of columns not defined - DetermineNumberOfColumns( availableContentWidth ); - - // Locations define the start, end,top and bottom of each cell. - mLocations->CalculateLocations( mNumColumns, availableContentWidth.AsInteger(), availableContentHeight.AsInteger(), childCount ); - - - SetMeasuredDimensions( ResolveSizeAndState( widthSize, widthMeasureSpec, MeasuredSize::State::MEASURED_SIZE_OK ), - ResolveSizeAndState( heightSize, heightMeasureSpec, MeasuredSize::State::MEASURED_SIZE_OK ) ); -} - -void Grid::OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ) -{ - auto owner = GetOwner(); - auto actor = Actor::DownCast(owner); - auto count = GetChildCount(); - - GridLocations::LocationVector locations = mLocations->GetLocations(); - - Extents gridLayoutPadding = GetPadding(); - Extents childMargins; - - // Margin for all children dependant on if set on first child - if( count ) - { - LayoutItemPtr childLayout = GetChildAt( 0 ); - if( childLayout ) - { - auto childOwner = childLayout->GetOwner(); - if( childOwner ) - { - childMargins = childOwner.GetProperty( Toolkit::Control::Property::MARGIN ); - } - } - } - - for( unsigned int i = 0; i < count; i++) - { - // for each child - int childIndex = i; - LayoutItemPtr childLayout = GetChildAt( childIndex ); - if( childLayout != nullptr ) - { - // Get start and end position of child x1,x2 - auto x1 = locations[ i ].xStart; - auto x2 = locations[ i ].xEnd; - - // Get top and bottom position of child y1,y2 - auto y1 = locations[ i ].yTop; - auto y2 = locations[ i ].yBottom; - - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Grid::OnLayout cellSize(%d,%d) \n", x2 - x1, y2 - y1); - - // Offset children by the grids padding if present - x1 += gridLayoutPadding.start; - x2 += gridLayoutPadding.start; - y1 += gridLayoutPadding.top; - y2 += gridLayoutPadding.top; - - // Offset children by the margin of the first child ( if required ). - x1 += childMargins.start; - x2 -= childMargins.end; - y1 += childMargins.top; - y2 -= childMargins.bottom; - - childLayout->Layout( x1, y1, x2, y2 ); - } - } -} - -} // namespace Internal -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/internal/layouting/grid-impl.h b/dali-toolkit/internal/layouting/grid-impl.h deleted file mode 100644 index 264f11d..0000000 --- a/dali-toolkit/internal/layouting/grid-impl.h +++ /dev/null @@ -1,133 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_GRID_IMPL_H -#define DALI_TOOLKIT_INTERNAL_LAYOUTING_GRID_IMPL_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. - */ - -// EXTERNAL_HEADERS -#include -#include - -// INTERNAL_HEADERS -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -class Grid; -using GridPtr = IntrusivePtr; - -class Grid final : public LayoutGroup -{ -public: - - /** - * Creates a pointer to an Internal Grid - */ - static GridPtr New(); - - /** - * Set grid's the number of columns - * @param[in] columns number of columns - */ - void SetNumberOfColumns( int columns ); - - /** - * Get number of columns, -1 would indicate AUTO_FIT - * which means the number has not been set but will be calculated. - * @return the number of columns set - */ - int GetNumberOfColumns() const; - - // Movable but not copyable - Grid( const Grid& other ) = delete; - Grid& operator=( const Grid& other ) = delete; - Grid( Grid && ) = default; - Grid& operator=( Grid && ) = default; - -protected: - - /** - * Default Constructor - */ - Grid(); - - /** - * Destructor - */ - ~Grid(); - - /** - * @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: - - /** - * @brief - * For the given availableSpace, calculate or retreive the number of required columns. - * @param[in] availableSpace the space available for a child in each column. - */ - void DetermineNumberOfColumns( LayoutLength availableSpace ); - -private: - - GridLocationsPtr mLocations; - - LayoutLength mTotalHeight; - LayoutLength mTotalWidth; - - const int AUTO_FIT = -1; - - int mNumColumns; - int mNumRows; - - int mRequestedColumnWidth; - int mRequestedNumColumns; -}; - -} // namespace Internal - -inline Internal::Grid& GetImplementation( Dali::Toolkit::Grid& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "Grid handle is empty" ); - BaseObject& object = handle.GetBaseObject(); - return static_cast( object ); -} - -inline const Internal::Grid& GetImplementation( const Dali::Toolkit::Grid& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "Grid handle is empty" ); - const BaseObject& object = handle.GetBaseObject(); - return static_cast( object ); -} - -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_INTERNAL_LAYOUTINGInner diff --git a/dali-toolkit/internal/layouting/grid-locations.cpp b/dali-toolkit/internal/layouting/grid-locations.cpp deleted file mode 100644 index 847bcc1..0000000 --- a/dali-toolkit/internal/layouting/grid-locations.cpp +++ /dev/null @@ -1,139 +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 - -// EXTERNAL HEADERS -#include - -// INTERNAL HEADERS -#include - -namespace -{ - -#if defined(DEBUG_ENABLED) -static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::Concise, false, "LOG_AXIS" ); -#endif - -} - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -GridLocationsPtr GridLocations::New() -{ - GridLocationsPtr gridAxis( new GridLocations() ); - return gridAxis; -} - -GridLocations::GridLocations() -: mLocations() -{ -} - -GridLocations::~GridLocations(){} - -void GridLocations::CalculateLocations( int numberOfColumns, - unsigned int availableWidth, - unsigned int availableHeight, - unsigned int numberOfCells ) -{ - DALI_ASSERT_DEBUG( numberOfColumns > 0 && "number of columns should be greater than 0" ); - numberOfColumns = std::max ( numberOfColumns, 1 ); - mLocations.clear(); - - // Calculate width and height of columns and rows. - - // Calculate numbers of rows, round down result as later check for remainder. - unsigned int numberOfRows = numberOfCells/numberOfColumns; - // If number of cells not cleanly dividable by colums, add another row to house remainder cells. - numberOfRows += (numberOfCells%numberOfColumns)?1:0; - - // Safe as numberOfColumns is guaranteed to be > 0 - unsigned int columnWidth = availableWidth / numberOfColumns; - - unsigned int rowHeight = availableHeight; - - if( numberOfRows > 0 ) - { - rowHeight = availableHeight / numberOfRows; - } - - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ColumWidth[%d] RowHeight[%d] NumberOfRows[%d] NumberOfColumns[%d]\n", - columnWidth, rowHeight, numberOfRows, numberOfColumns ); - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Remainder[%d]\n", numberOfCells%numberOfColumns ); - - int y1 = 0; - int y2 = y1 + rowHeight; - - // Calculate start, end, top and bottom coordinate of each cell. - - // Iterate rows - for( auto i = 0u; i < numberOfRows; i++ ) - { - int x1 = 0; - int x2 = x1 + columnWidth; - - // Iterate columns - for( auto j = 0; j < numberOfColumns; j++ ) - { - GridLocations::Cell cell( x1, x2, y1, y2 ); - mLocations.push_back( cell ); - // Calculate starting x and ending x position of each column - x1 = x2; - x2 = x2 + columnWidth; - } - - // Calculate top y and bottom y position of each row. - y1 = y2; - y2 = y2 + rowHeight; - } - -#if defined(DEBUG_ENABLED) - std::ostringstream oss; - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "GridLocations::CalculateLocations (%d)\n", numberOfCells ); - for( auto i = 0u; i < numberOfCells; i++ ) - { - DALI_LOG_STREAM( gLogFilter, Debug::Verbose,"x1:"< -#include -#include -#include - -// INTERNAL HEADERS -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -class GridLocations; -using GridLocationsPtr = IntrusivePtr; - -/* @brief This internal class houses the algorithm for computing the locations and size of cells. - * - * A Grid layout uses two instances of this class - * distinguished by the "horizontal" flag which is true for the horizontal axis and false - * for the vertical one. - */ - -class GridLocations : public RefObject -{ - -public: - - static const int UNDEFINED = INT_MIN; - - static const unsigned int HORIZONTAL = 0; - static const unsigned int VERTICAL = 1; - - struct Cell - { - int xStart; - int xEnd; - int yTop; - int yBottom; - - Cell( int x1, int x2, int y1, int y2): xStart(x1), xEnd(x2), yTop(y1), yBottom(y2){}; - }; - - typedef std::vector< Cell > LocationVector; - -public: - - static GridLocationsPtr New(); - - /* - * Uses the given parameters to calculate the x,y coordinates of each cell and cell size. - */ - void CalculateLocations( int numberOfColumns, unsigned int availableWidth, - unsigned int availableHeight, unsigned int numberOfCells ); - - LocationVector GetLocations(); - -private: - - GridLocations(); - ~GridLocations(); - GridLocations( const GridLocations& other ) = delete; - GridLocations& operator=( const GridLocations& other ) = delete; - -private: - - LocationVector mLocations; - -}; - -} // namespace Internal -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_GRID_LOCATIONS_H diff --git a/dali-toolkit/internal/layouting/layout-controller-debug.cpp b/dali-toolkit/internal/layouting/layout-controller-debug.cpp deleted file mode 100644 index 4b8f63e..0000000 --- a/dali-toolkit/internal/layouting/layout-controller-debug.cpp +++ /dev/null @@ -1,193 +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. - */ - -#include -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -#if defined( DEBUG_ENABLED ) -Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT_TREE" ); - - -void GetLayoutMeasureStateString( std::ostringstream& oss, LayoutItemPtr layout ) -{ - if( layout ) - { - auto widthSizeAndState = layout->GetMeasuredWidthAndState(); - auto heightSizeAndState = layout->GetMeasuredHeightAndState(); - - oss << "LayoutMeasureState:" << - " w:" << widthSizeAndState.GetSize() << (widthSizeAndState.GetState()==MeasuredSize::MEASURED_SIZE_TOO_SMALL?"/TooSmall":"") << - " h:" << heightSizeAndState.GetSize() << (heightSizeAndState.GetState()==MeasuredSize::MEASURED_SIZE_TOO_SMALL?"/TooSmall":""); - } -} - -void LayoutDebugMeasureStateRecurseLayout( LayoutItemPtr layout, int depth ); - -void LayoutDebugMeasureStateRecurseActor( Actor root, int depth ) -{ - std::ostringstream oss; - for(int i=0;i( layout.Get() ) ); - if( layoutGroup ) - { - for( unsigned int i=0; iGetChildCount(); ++i ) - { - auto layoutChild = layoutGroup->GetChildAt( i ); - LayoutDebugMeasureStateRecurseLayout( layoutChild, depth+1 ); - } - } - descendActor = false; - } - } - - if( descendActor == true ) - { - oss << std::endl; - DALI_LOG_INFO( gLogFilter, Debug::Verbose, oss.str().c_str() ); - - // Depth first descent through actor children - for( unsigned int i = 0, count = root.GetChildCount(); i < count; ++i ) - { - Actor child = root.GetChildAt( i ); - LayoutDebugMeasureStateRecurseActor( child, depth+1 ); - } - } -} - -void LayoutDebugMeasureStateRecurseLayout( LayoutItemPtr layout, int depth ) -{ - std::ostringstream oss; - for(int i=0;iGetOwner() ); - if( actor ) - { - oss << "Actor " << actor.GetId() << ":" << actor.GetName() << " "; - } - else - { - oss << "Owner: " << layout->GetOwner().GetObjectPtr() << " "; - } - - GetLayoutMeasureStateString( oss, layout ); - oss << std::endl; - DALI_LOG_INFO( gLogFilter, Debug::Verbose, oss.str().c_str() ); - - auto layoutGroup = LayoutGroupPtr( dynamic_cast< LayoutGroup* >( layout.Get() ) ); - if( layoutGroup ) - { - for( unsigned int i=0; iGetChildCount(); ++i ) - { - auto layoutChild = layoutGroup->GetChildAt( i ); - LayoutDebugMeasureStateRecurseLayout( layoutChild, depth+1 ); - } - } - else if( actor ) - { - for( unsigned int i = 0, count = actor.GetChildCount(); i < count; ++i ) - { - LayoutDebugMeasureStateRecurseActor( actor.GetChildAt( i ), depth + 1 ); - } - } -} - - -void LayoutDebugMeasureState( Actor root ) -{ - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Layout tree after measure:\n\n" ); - LayoutDebugMeasureStateRecurseActor( root, 0 ); -} - - -void LayoutDebugAfterLayoutRecurse( Actor root, int depth ) -{ - std::ostringstream oss; - for(int i=0;iGetOwner(); - auto widthMeasureSpec = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); - auto heightMeasureSpec = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ); - - oss << "LayoutData:" << "( " << widthMeasureSpec << ", " << heightMeasureSpec << ") "; - - auto actorPos = root.GetProperty( Actor::Property::POSITION ); - auto actorSize = root.GetProperty( Actor::Property::SIZE ); - oss << " ActorPos: (" << actorPos.x << ", " << actorPos.y << ")"; - oss << " ActorSize: (" << actorSize.width << ", " << actorSize.height << ")"; - } - else - { - // Try getting layout data from parent control - } - } - oss << std::endl; - - DALI_LOG_INFO( gLogFilter, Debug::Verbose, oss.str().c_str() ); - - // Depth first descent through actor children - for( unsigned int i = 0, count = root.GetChildCount(); i < count; ++i ) - { - Actor child = root.GetChildAt( i ); - LayoutDebugAfterLayoutRecurse( child, depth+1 ); - } -} - -void LayoutDebugAfterLayout( Actor root ) -{ - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Layout tree after layout:\n\n" ); - LayoutDebugAfterLayoutRecurse( root, 0 ); -} - - -#endif - -} // namespace Internal -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/internal/layouting/layout-controller-debug.h b/dali-toolkit/internal/layouting/layout-controller-debug.h deleted file mode 100644 index 9a2323f..0000000 --- a/dali-toolkit/internal/layouting/layout-controller-debug.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_DEBUG_H -#define DALI_TOOLKIT_INTERNAL_LAYOUTING_DEBUG_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 -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -#if defined(DEBUG_ENABLED) - -extern void LayoutDebugMeasureState( Actor root ); -extern void LayoutDebugAfterLayout( Actor root ); - - -#define LAYOUT_DEBUG_MEASURE_STATES( root ) \ - LayoutDebugMeasureState( root ) - -#define LAYOUT_DEBUG_AFTER_LAYOUT( root ) \ - LayoutDebugAfterLayout( root ) - -#else - - -#define LAYOUT_DEBUG_MEASURE_STATES( root ) -#define LAYOUT_DEBUG_AFTER_LAYOUT( root ) - -#endif - -} // namespace Internal -} // namespace Toolkit -} // namespace Dali - -#endif //DALI_TOOLKIT_INTERNAL_LAYOUTING_DEBUG_H diff --git a/dali-toolkit/internal/layouting/layout-controller-impl.cpp b/dali-toolkit/internal/layouting/layout-controller-impl.cpp deleted file mode 100644 index b0637b3..0000000 --- a/dali-toolkit/internal/layouting/layout-controller-impl.cpp +++ /dev/null @@ -1,506 +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. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace Dali; - -namespace -{ - -#if defined(DEBUG_ENABLED) -static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" ); -#endif - -} - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -LayoutController::LayoutController() -: mLayoutRequested( false ), - mFocusChangedFunctor( *this ), - mSlotDelegate( this ) -{ -} - -LayoutController::~LayoutController() -{ -} - -void LayoutController::Initialize() -{ - mAnimation = Animation::New( 0.0f ); - - Dali::Toolkit::KeyInputFocusManager manager = Dali::Toolkit::KeyInputFocusManager::Get(); - manager.KeyInputFocusChangedSignal().Connect( mSlotDelegate.GetConnectionTracker(), mFocusChangedFunctor ); -} - -void LayoutController::FocusChangedFunctor::operator() ( Dali::Toolkit::Control gainingControl, Dali::Toolkit::Control lostControl ) -{ - Toolkit::LayoutItem layoutItem = Toolkit::DevelControl::GetLayout( gainingControl ); - if( layoutItem ) - { - Toolkit::Internal::LayoutItem& layoutItemImpl = GetImplementation( layoutItem ); - LayoutParent* layoutParent = layoutItemImpl.GetParent(); - if( layoutParent ) - { - LayoutGroup* layoutGroup = static_cast< LayoutGroup* >( layoutParent ); - layoutController.RequestLayout( dynamic_cast< Toolkit::Internal::LayoutItem& >( *layoutGroup ), Dali::Toolkit::LayoutTransitionData::ON_CHILD_FOCUS, gainingControl, lostControl ); - } - } -} - -void LayoutController::RequestLayout( LayoutItem& layoutItem, int layoutTransitionType, Actor gainedChild, Actor lostChild ) -{ - auto actor = Actor::DownCast( layoutItem.GetOwner() ); - if ( actor ) - { - DALI_LOG_INFO( gLogFilter, Debug::Concise, "LayoutController::RequestLayout owner[%s] layoutItem[%p] layoutTransitionType(%d) gainedChild[%s] lostChild[%s]\n", - actor.GetName().c_str(), &layoutItem, layoutTransitionType, - gainedChild ? gainedChild.GetName().c_str() : "", - lostChild ? lostChild.GetName().c_str() : ""); - } - else - { - DALI_LOG_INFO( gLogFilter, Debug::Concise, "LayoutController::RequestLayout layoutItem[%p] layoutAnimationType(%d)\n", &layoutItem, layoutTransitionType ); - } - - mLayoutRequested = true; - if( layoutTransitionType != -1 ) - { - LayoutTransition layoutTransition = LayoutTransition( layoutItem, layoutTransitionType, gainedChild, lostChild ); - if( std::find( mLayoutTransitions.begin(), mLayoutTransitions.end(), layoutTransition ) == mLayoutTransitions.end() && layoutItem.GetTransitionData( layoutTransitionType ).Get() ) - { - DALI_LOG_INFO( gLogFilter, Debug::Concise, "LayoutController::RequestLayout Add transition layoutTransitionType(%d)\n", layoutTransitionType ); - mLayoutTransitions.push_back( layoutTransition ); - } - } - - // Go up the tree and mark all parents to relayout - LayoutParent* layoutParent = layoutItem.GetParent(); - if( layoutParent ) - { - LayoutGroup& layoutGroup = static_cast< LayoutGroup& >( *layoutParent ); - if( ! layoutGroup.IsLayoutRequested() ) - { - layoutGroup.RequestLayout(); - } - } -} - -void LayoutController::Process() -{ - // Perform the full process. - DALI_LOG_INFO( gLogFilter, Debug::Concise, "LayoutController::Process\n" ); - - if( mLayoutRequested ) - { - // If window size has changed, expect stage to have already been updated - Stage stage = Stage::GetCurrent(); - auto stageWidth = stage.GetSize().width; - auto stageHeight = stage.GetSize().height; - - MeasureSpec widthSpec( stageWidth, MeasureSpec::Mode::EXACTLY ); - MeasureSpec heightSpec( stageHeight, MeasureSpec::Mode::EXACTLY ); - - LayoutTransition layoutTransition; - LayoutPositionDataArray layoutPositionDataArray; - LayoutAnimatorArray layoutAnimatorArray; - LayoutDataArray layoutDataArray; - LayoutDataArray childrenLayoutDataArray; - - if ( mLayoutTransitions.size() ) - { - layoutTransition = mLayoutTransitions.front(); - mLayoutTransitions.pop_front(); - mLayoutRequested = ( mLayoutTransitions.size() != 0 ); - } - else - { - mLayoutRequested = false; - } - - LayoutData layoutData( layoutTransition, layoutPositionDataArray, layoutAnimatorArray, layoutDataArray, childrenLayoutDataArray ); - LayoutItem::Impl::sLayoutData = &layoutData; - - if( layoutTransition.layoutTransitionType != -1 ) - { - UpdateMeasureHierarchyForAnimation( layoutData ); - } - - // Test how to perform a measure on each control. - MeasureHierarchy( stage.GetRootLayer(), widthSpec, heightSpec ); - - LAYOUT_DEBUG_MEASURE_STATES( stage.GetRootLayer() ); - - if( layoutTransition.layoutTransitionType != -1 ) - { - RestoreActorsSpecs(); - } - - layoutAnimatorArray.clear(); - layoutDataArray.clear(); - childrenLayoutDataArray.clear(); - - PerformLayout( stage.GetRootLayer(), 0, 0, stageWidth, stageHeight ); - - PerformLayoutPositioning( layoutPositionDataArray, false ); - - PerformLayoutAnimation( layoutTransition, layoutPositionDataArray, layoutDataArray, layoutAnimatorArray ); - LayoutItem::Impl::sLayoutData = nullptr; - - LAYOUT_DEBUG_AFTER_LAYOUT( stage.GetRootLayer() ); - } -} - -void LayoutController::MeasureHierarchy( Actor root, MeasureSpec widthSpec, MeasureSpec heightSpec ) -{ - // Does this actor have a layout? - // Yes - measure the layout. It will call this method again for each of it's children. - // No - recurse through actor children. - // - // If in a leaf actor with no layout, it's natural size is bubbled back up. - // - // What happens if nothing in the tree has a layout? - - Toolkit::Control control = Toolkit::Control::DownCast( root ); - if( control ) - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::Measuring control:%s\n", control.GetName().c_str() ); - Internal::Control& controlImpl = GetImplementation( control ); - - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); - LayoutItemPtr layout = controlDataImpl.GetLayout(); - - if( layout ) - { - layout->Measure( widthSpec, heightSpec ); - } - } - else - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::Measuring (%u) children\n", root.GetChildCount() ); - // Depth first descent through actor children - for( unsigned int i = 0, count = root.GetChildCount(); i < count; ++i ) - { - Actor child = root.GetChildAt( i ); - MeasureHierarchy( child, widthSpec, heightSpec ); - } - } -} - -void LayoutController::UpdateMeasureHierarchyForAnimation( LayoutData& layoutData ) -{ - LayoutTransition& layoutTransition = layoutData.layoutTransition; - Actor transitionOwner = Actor::DownCast( layoutTransition.layoutItem.Get()->GetOwner() ); - LayoutTransitionDataPtr layoutTransitionDataPtr = layoutTransition.layoutItem->GetTransitionData( layoutTransition.layoutTransitionType ); - - if( !layoutTransitionDataPtr->HasUpdateMeasuredSize() ) - { - return; - } - - layoutData.updateMeasuredSize = true; - layoutTransitionDataPtr->CollectLayoutDataElements( transitionOwner, layoutData ); - - UpdateMeasureHierarchyForAnimation( transitionOwner, layoutData ); - - for( auto layoutDataElement : layoutData.layoutDataArray ) - { - if( !layoutDataElement.updateMeasuredSize ) - { - continue; - } - - Actor actor = layoutDataElement.handle.GetHandle(); - if( actor ) - { - LayoutDataAnimator animator = layoutData.layoutAnimatorArray[ layoutDataElement.animatorIndex ]; - float width = actor.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); - float height = actor.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ); - - if( layoutDataElement.AdjustMeasuredSize( width, height, animator.animatorType ) ) - { - mActorSizeSpecs.push_back( ActorSizeSpec( actor ) ); - actor.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, static_cast( width ) ); - actor.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, static_cast( height ) ); - } - } - } - - layoutData.updateMeasuredSize = false; -} - -void LayoutController::UpdateMeasureHierarchyForAnimation( Actor root, LayoutData& layoutData ) -{ - Toolkit::Control control = Toolkit::Control::DownCast( root ); - if( control ) - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::UpdateMeasureHierarchyForAnimation control:%s\n", control.GetName().c_str() ); - Internal::Control& controlImpl = GetImplementation( control ); - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); - LayoutItemPtr layout = controlDataImpl.GetLayout(); - - if( layout ) - { - auto layoutGroup = Toolkit::LayoutGroup::DownCast( layout.Get() ); - if( layoutGroup ) - { - unsigned int childCount = layoutGroup.GetChildCount(); - for( unsigned int i=0; iLayout( left, top, right, bottom ); - } - } - else - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::PerformLayout (%u) children\n", root.GetChildCount() ); - // Depth first descent through actor children - for( unsigned int i = 0, count = root.GetChildCount(); i < count; ++i ) - { - Actor child = root.GetChildAt( i ); - PerformLayout( child, left, top, right, bottom ); - } - } -} - -void LayoutController::PerformLayoutPositioning( LayoutPositionDataArray& layoutPositionDataArray, bool all ) const -{ - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::PerformLayoutPositioning %d\n", (int)all ); - - for( auto layoutPositionData : layoutPositionDataArray ) - { - Actor actor = layoutPositionData.handle.GetHandle(); - if( actor && ( !layoutPositionData.animated || all ) ) - { - if( !layoutPositionData.animated ) - { - actor.SetX( layoutPositionData.left ); - actor.SetY( layoutPositionData.top ); - - actor.SetProperty( Actor::Property::SIZE_WIDTH, layoutPositionData.right - layoutPositionData.left ); - actor.SetProperty( Actor::Property::SIZE_HEIGHT, layoutPositionData.bottom - layoutPositionData.top ); - } - else - { - actor.SetX( actor.GetCurrentPosition().x ); - actor.SetY( actor.GetCurrentPosition().y ); - - actor.SetProperty( Actor::Property::SIZE_WIDTH, actor.GetCurrentSize().x ); - actor.SetProperty( Actor::Property::SIZE_HEIGHT, actor.GetCurrentSize().y ); - } - } - } -} - -void LayoutController::PerformLayoutAnimation( LayoutTransition& layoutTransition, LayoutPositionDataArray& layoutPositionDataArray, LayoutDataArray& layoutDataArray, LayoutAnimatorArray& layoutAnimatorArray ) -{ - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::PerformLayoutAnimation\n" ); - Animation animation = Animation::New( 0 ); - bool isAnimatorAdded = false; - - if( layoutAnimatorArray.size() == 0 ) - { - layoutAnimatorArray.push_back( LayoutDataAnimator() ); - } - - for( auto layoutDataElement : layoutDataArray ) - { - if( layoutDataElement.animatorIndex >= 0 ) - { - Actor actor = layoutDataElement.handle.GetHandle(); - if ( actor ) - { - LayoutDataAnimator animator = layoutAnimatorArray[ layoutDataElement.animatorIndex ]; - TimePeriod timePeriod = TimePeriod( 0, animation.GetDuration() ); - if( animator.timePeriod.durationSeconds >= 0 ) - { - timePeriod = animator.timePeriod; - } - - Property::Value value = layoutDataElement.targetValue; - // Capture calculated position and size values after layout if target values are not set. - // Other values are set to current actor ones. - if( value.GetType() == Property::NONE ) - { - if( layoutDataElement.positionDataIndex < 0) - { - auto result = std::find_if( layoutPositionDataArray.begin(), layoutPositionDataArray.end(), [&actor](const LayoutPositionData& iter) - { return iter.handle == actor; } ); - if( result == layoutPositionDataArray.end() ) - { - continue; - } - layoutDataElement.positionDataIndex = std::distance( layoutPositionDataArray.begin(), result ); - } - - LayoutPositionData& positionData = layoutPositionDataArray[ layoutDataElement.positionDataIndex ]; - // with updated measured size scale animation the measured size includes scale, so we need to fit in the centre of the measured rectangle - // the real size child so that the all scale related animations placed correctly - if( positionData.updateWithCurrentSize ) - { - Vector3 size = actor.GetCurrentSize(); - float dX = ( ( positionData.right - positionData.left ) - size.width ) / 2; - float dY = ( ( positionData.bottom - positionData.top ) - size.height ) / 2; - positionData.left += dX; - positionData.top += dY; - positionData.right -= dX; - positionData.bottom -= dY; - positionData.updateWithCurrentSize = false; - } - - switch ( layoutDataElement.propertyIndex ) - { - case Actor::Property::POSITION: - value = Vector3( positionData.left, positionData.top, 0.0f ); - break; - case Actor::Property::POSITION_X: - value = positionData.left; - break; - case Actor::Property::POSITION_Y: - value = positionData.top; - break; - case Actor::Property::SIZE: - value = Vector3( positionData.right - positionData.left, positionData.bottom - positionData.top, 0.0f ); - break; - case Actor::Property::SIZE_WIDTH: - value = positionData.right - positionData.left; - break; - case Actor::Property::SIZE_HEIGHT: - value = positionData.bottom - positionData.top; - break; - default: - value = actor.GetProperty( layoutDataElement.propertyIndex ); - } - } - - // Failed to get target value, just move to the next one - if( value.GetType() == Property::NONE ) - { - continue; - } - - // Set initial value - Property::Value initialValue = layoutDataElement.initialValue; - if( initialValue.GetType() != Property::NONE ) - { - actor.SetProperty( layoutDataElement.propertyIndex, initialValue ); - } - - // Create an animator for the property - switch( animator.animatorType ) - { - case Toolkit::LayoutTransitionData::Animator::ANIMATE_TO: - { - animation.AnimateTo( Property( actor, layoutDataElement.propertyIndex ), value, animator.alphaFunction, timePeriod ); - break; - } - case Toolkit::LayoutTransitionData::Animator::ANIMATE_BY: - { - animation.AnimateBy( Property( actor, layoutDataElement.propertyIndex ), value, animator.alphaFunction, timePeriod ); - break; - } - case Toolkit::LayoutTransitionData::Animator::ANIMATE_BETWEEN: - { - animation.AnimateBetween( Property( actor, layoutDataElement.propertyIndex ), animator.keyFrames, animator.alphaFunction, animator.interpolation ); - break; - } - case Toolkit::LayoutTransitionData::Animator::ANIMATE_PATH: - { - animation.Animate( actor, animator.path, animator.forward, animator.alphaFunction, timePeriod ); - break; - } - } - isAnimatorAdded = true; - } - } - } - - if( isAnimatorAdded ) - { - if( mAnimation.GetState() == Animation::PLAYING ) - { - mAnimation.SetCurrentProgress( 1.0f ); - } - mAnimation = animation; - mAnimationFinishedFunctors.push_back( AnimationFinishedFunctor( *this, layoutTransition, layoutPositionDataArray ) ); - mAnimation.FinishedSignal().Connect( mSlotDelegate.GetConnectionTracker(), mAnimationFinishedFunctors.back() ); - mAnimation.Play(); - } -} - -} // namespace Internal -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/internal/layouting/layout-controller-impl.h b/dali-toolkit/internal/layouting/layout-controller-impl.h deleted file mode 100644 index 3606dd6..0000000 --- a/dali-toolkit/internal/layouting/layout-controller-impl.h +++ /dev/null @@ -1,183 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_LAYOUT_CONTROLLER_H -#define DALI_TOOLKIT_INTERNAL_LAYOUT_CONTROLLER_H - -/* - * Copyright (c) 2019 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 -#include -#include -#include -#include -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -/** - * @brief Layout controller handles measurement and layout of all - * controls that utilize Layouts. - */ -class LayoutController : public Dali::BaseObject, public Integration::Processor -{ -public: - /** - * Constructor - */ - LayoutController(); - - /** - * Destructor - */ - ~LayoutController(); - - /** - * Second stage initialization - */ - void Initialize(); - - /** - * This marks the given layout and all its parents as dirty and triggers a transition if set. - */ - void RequestLayout( LayoutItem& layout, int layoutTransitionType, Actor gainedChild, Actor lostChild ); - - /** - * Measures next level of layouts in the actor hierarchy. - */ - void MeasureHierarchy( Actor root, MeasureSpec widthSpec, MeasureSpec heightSpec ); - - /** - * Perform layout of the hierarchy - */ - void PerformLayout( Actor root, int left, int top, int right, int bottom ); - - /** - * Perform positioning of actors after layout update - */ - void PerformLayoutPositioning( LayoutPositionDataArray& layoutPositionDataArray, bool all ) const; - - /** - * Perform animation of actors properties after layout update - */ - void PerformLayoutAnimation( LayoutTransition& layoutTransition, LayoutPositionDataArray& layoutPositionDataArray, LayoutDataArray& layoutDataArray, LayoutAnimatorArray& layoutAnimatorArray ); - - /** - * Focus change callback. - */ - void KeyInputFocusChangedCallback( Control gainingActor, Control lostActor ); - -protected: // Implementation of Processor - - /** - * @copydoc Dali::Integration::Processor::Process() - */ - virtual void Process(); - -private: - struct ActorSizeSpec - { - ActorSizeSpec(Actor actor) - : actor( actor ) - , widthSpec( actor.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ) ) - , heightSpec( actor.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ) ) - { - } - - WeakHandle actor; - int widthSpec; - int heightSpec; - }; - std::vector mActorSizeSpecs; - - void UpdateMeasureHierarchyForAnimation( LayoutData& layoutData ); - - void UpdateMeasureHierarchyForAnimation( Actor root, LayoutData& layoutData ); - - void RestoreActorsSpecs(); - - std::list< LayoutTransition > mLayoutTransitions; - struct AnimationFinishedFunctor - { - AnimationFinishedFunctor( LayoutController& layoutController, LayoutTransition& layoutTransition, LayoutPositionDataArray& array ) - : layoutController( layoutController ), - layoutDataPositionArray(), - layoutItem( layoutTransition.layoutItem ), - layoutTransitionType( layoutTransition.layoutTransitionType ) - { - layoutDataPositionArray.swap( array ); - } - - void operator()( Animation& animation ) - { - layoutController.PerformLayoutPositioning( layoutDataPositionArray, true ); - layoutController.mAnimationFinishedFunctors.pop_front(); - if( layoutTransitionType != -1 ) - { - LayoutTransitionDataPtr layoutTransitionDataPtr = layoutItem->GetTransitionData( layoutTransitionType ); - layoutTransitionDataPtr->EmitSignalFinish( layoutTransitionType ); - } - } - - LayoutController& layoutController; - LayoutPositionDataArray layoutDataPositionArray; - LayoutItemPtr layoutItem; - int layoutTransitionType; - }; - - bool mLayoutRequested; - Animation mAnimation; - std::list< AnimationFinishedFunctor > mAnimationFinishedFunctors; - - struct FocusChangedFunctor - { - FocusChangedFunctor( LayoutController& layoutController ) - : layoutController( layoutController ) - { - } - - void operator() ( Dali::Toolkit::Control gainingControl, Dali::Toolkit::Control lostActor ); - LayoutController& layoutController; - }; - FocusChangedFunctor mFocusChangedFunctor; - - SlotDelegate mSlotDelegate; -}; - -} // namespace Internal - -inline Internal::LayoutController& GetImpl( Dali::Toolkit::LayoutController& handle ) -{ - DALI_ASSERT_ALWAYS(handle); - Dali::BaseObject& object = handle.GetBaseObject(); - return static_cast(object); -} - -inline const Internal::LayoutController& GetImpl( const Dali::Toolkit::LayoutController& handle ) -{ - DALI_ASSERT_ALWAYS(handle); - const Dali::BaseObject& object = handle.GetBaseObject(); - return static_cast(object); -} - -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_INTERNAL_LAYOUT_CONTROLLER_H diff --git a/dali-toolkit/internal/layouting/layout-group-data-impl.cpp b/dali-toolkit/internal/layouting/layout-group-data-impl.cpp deleted file mode 100644 index 56e92a3..0000000 --- a/dali-toolkit/internal/layouting/layout-group-data-impl.cpp +++ /dev/null @@ -1,38 +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. - */ - -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -LayoutGroup::Impl::Impl() -: mChildren(), - mNextLayoutId(1), - mResizePolicyMapped( false ) -{ -} - -} // namespace Internal - -} // namespace Toolkit - -} // namespace Dali diff --git a/dali-toolkit/internal/layouting/layout-group-data-impl.h b/dali-toolkit/internal/layouting/layout-group-data-impl.h deleted file mode 100644 index 02a4716..0000000 --- a/dali-toolkit/internal/layouting/layout-group-data-impl.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_LAYOUT_GROUP_DATA_IMPL_H_H -#define DALI_TOOLKIT_INTERNAL_LAYOUT_GROUP_DATA_IMPL_H_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 - -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -class LayoutGroup::Impl -{ -public: - Impl(); - -public: - struct ChildLayout - { - LayoutItemPtr child; - Toolkit::LayoutGroup::LayoutId layoutId; - }; - - std::vector mChildren; - Toolkit::LayoutGroup::LayoutId mNextLayoutId; - bool mResizePolicyMapped; -}; - - -} // namespace Internal -} // namespace Toolkit -} // namespace Dali - -#endif //DALI_TOOLKIT_INTERNAL_LAYOUT_GROUP_DATA_IMPL_H_H diff --git a/dali-toolkit/internal/layouting/layout-item-data-impl.cpp b/dali-toolkit/internal/layouting/layout-item-data-impl.cpp deleted file mode 100644 index e6e41b6..0000000 --- a/dali-toolkit/internal/layouting/layout-item-data-impl.cpp +++ /dev/null @@ -1,52 +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. - */ - -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -class LayoutData; - -bool LayoutItem::Impl::sUseZeroUnspecifiedMeasureSpec = false; -LayoutData* LayoutItem::Impl::sLayoutData = nullptr; - -LayoutItem::Impl::Impl() -: mOwner(), - mLayoutParent( nullptr ), - mOldWidthMeasureSpec( 0 ), - mOldHeightMeasureSpec( 0 ), - mMinimumSize(), - mMeasuredWidth(0), - mMeasuredHeight(0), - mLeft( 0 ), - mRight( 0 ), - mTop( 0 ), - mBottom( 0 ), - mViewFlags( 0 ), - mPrivateFlags( 0 ), - mAnimated( false ) -{ -} - -} // namespace Internal -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/internal/layouting/layout-item-data-impl.h b/dali-toolkit/internal/layouting/layout-item-data-impl.h deleted file mode 100644 index e7b2819..0000000 --- a/dali-toolkit/internal/layouting/layout-item-data-impl.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_BASE_DATA_IMPL_H_H -#define DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_BASE_DATA_IMPL_H_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 -#include -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -class LayoutItem::Impl -{ -public: - Impl(); - -public: - WeakHandle mOwner; ///< Control or Visual that owns this layout. Weak pointer to prevent cyclic references - LayoutParent* mLayoutParent; ///< The containing layout parent. - - MeasureSpec mOldWidthMeasureSpec; - MeasureSpec mOldHeightMeasureSpec; - LayoutSize mMinimumSize; - - MeasuredSize mMeasuredWidth; - MeasuredSize mMeasuredHeight; - - LayoutLength mLeft; - LayoutLength mRight; - LayoutLength mTop; - LayoutLength mBottom; - - static const int PRIVATE_FLAG_MEASURED_DIMENSION_SET = 0x00000001; - static const int PRIVATE_FLAG_FORCE_LAYOUT = 0x00000002; - static const int PRIVATE_FLAG_LAYOUT_REQUIRED = 0x00000004; - static const int PRIVATE_FLAG_IS_LAID_OUT = 0x00000008; - static const int PRIVATE_FLAG_MEASURE_NEEDED_BEFORE_LAYOUT = 0x00000010; ///< Flag indicating that a call to measure() was skipped and should be done instead when layout() is invoked. - static const int PRIVATE_FLAG_FORCE_SET_FRAME = 0x00000020; - static const int PRIVATE_FLAG_USE_RESIZE_POLICY = 0x00000040; - - int mViewFlags; - int mPrivateFlags; - - bool mAnimated; - - inline void ClearPrivateFlag( int flag ) - { - mPrivateFlags &= ~flag; - } - - inline void SetPrivateFlag( int flag ) - { - mPrivateFlags |= flag; - } - - inline bool GetPrivateFlag( int flag ) - { - return ( mPrivateFlags & flag ) != 0; - } - - static bool sUseZeroUnspecifiedMeasureSpec; - - // Custom transitions - LayoutTransitionDataPtr mOnChildAddTransitionData; - LayoutTransitionDataPtr mOnChildRemoveTransitionData; - LayoutTransitionDataPtr mOnChildFocusTransitionData; - LayoutTransitionDataPtr mOnOwnerSetTransitionData; - LayoutTransitionDataPtr mOnLayoutChangeTransitionData; - // Default transition - LayoutTransitionDataPtr mDefaultTransitionData; - - // To pass layout data during perform layout - static LayoutData* sLayoutData; -}; - -} // namespace Internal -} // namespace Toolkit -} // namespace Dali - -#endif //DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_BASE_DATA_IMPL_H_H diff --git a/dali-toolkit/internal/layouting/layout-transition-data-impl.cpp b/dali-toolkit/internal/layouting/layout-transition-data-impl.cpp deleted file mode 100644 index 07a32ca..0000000 --- a/dali-toolkit/internal/layouting/layout-transition-data-impl.cpp +++ /dev/null @@ -1,762 +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. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace -{ -#if defined(DEBUG_ENABLED) -Debug::Filter* gLayoutFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" ); -#endif - -// Key tokens -const char* TOKEN_CONDITION("condition"); -const char* TOKEN_AFFECTS_SIBLINGS("affectsSiblings"); -const char* TOKEN_PROPERTY("property"); -const char* TOKEN_INITIAL_VALUE("initialValue"); -const char* TOKEN_TARGET_VALUE("targetValue"); -const char* TOKEN_ANIMATOR("animator"); -const char* TOKEN_TYPE("type"); -const char* TOKEN_NAME("name"); -const char* TOKEN_TIME_PERIOD("timePeriod"); -const char* TOKEN_DURATION("duration"); -const char* TOKEN_DELAY("delay"); -const char* TOKEN_ALPHA_FUNCTION("alphaFunction"); - -DALI_ENUM_TO_STRING_TABLE_BEGIN( ANIMATOR_TYPE ) -DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::LayoutTransitionData::Animator::Type, ANIMATE_TO ) -DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::LayoutTransitionData::Animator::Type, ANIMATE_BY ) -DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::LayoutTransitionData::Animator::Type, ANIMATE_BETWEEN ) -DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::Toolkit::LayoutTransitionData::Animator::Type, ANIMATE_PATH ) -DALI_ENUM_TO_STRING_TABLE_END( ANIMATOR_TYPE ) - -DALI_ENUM_TO_STRING_TABLE_BEGIN( ALPHA_FUNCTION_BUILTIN ) -DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::AlphaFunction, LINEAR) -DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::AlphaFunction, REVERSE) -DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::AlphaFunction, EASE_IN) -DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::AlphaFunction, EASE_OUT) -DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::AlphaFunction, EASE_IN_OUT) -DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::AlphaFunction, EASE_IN_SQUARE) -DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::AlphaFunction, EASE_OUT_SQUARE) -DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::AlphaFunction, EASE_IN_SINE) -DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::AlphaFunction, EASE_OUT_SINE) -DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::AlphaFunction, EASE_IN_OUT_SINE) -DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::AlphaFunction, EASE_OUT_BACK) -DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::AlphaFunction, BOUNCE) -DALI_ENUM_TO_STRING_WITH_SCOPE(Dali::AlphaFunction, SIN) -DALI_ENUM_TO_STRING_TABLE_END( ALPHA_FUNCTION_BUILTIN ) - -} - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -bool LayoutDataElement::AdjustMeasuredSize( float& width, float& height, Toolkit::LayoutTransitionData::Animator::Type animatorType ) -{ - bool adjusted = true; - if( targetValue.GetType() == Property::NONE ) - { - return false; - } - - Actor actor = handle.GetHandle(); - float animateByMultiplier = ( animatorType == Toolkit::LayoutTransitionData::Animator::Type::ANIMATE_BY ) ? 1.0f : 0.0f; - Vector3 size = actor.GetCurrentSize(); - - switch ( targetValue.GetType() ) - { - case Property::Type::VECTOR3: - { - Vector3 value = targetValue.Get(); - switch( propertyIndex ) - { - case Actor::Property::SCALE: - { - width = size.x * ( animateByMultiplier + value.x ); - height = size.y * ( animateByMultiplier + value.y ); - break; - } - case Actor::Property::SIZE: - { - width = value.x + ( animateByMultiplier * size.x ); - height = value.y + ( animateByMultiplier * size.y ); - break; - } - default: - { - adjusted = false; - break; - } - } - break; - } - case Property::Type::FLOAT: - { - float value = targetValue.Get(); - switch( propertyIndex ) - { - case Actor::Property::SCALE_X: - { - width = size.x * ( animateByMultiplier + value ); - break; - } - case Actor::Property::SCALE_Y: - { - height = size.y * ( animateByMultiplier + value ); - break; - } - case Actor::Property::SIZE_WIDTH: - { - width = value + ( animateByMultiplier * size.x ); - break; - } - case Actor::Property::SIZE_HEIGHT: - { - height = value + ( animateByMultiplier * size.y ); - break; - } - default: - { - adjusted = true; - break; - } - } - break; - } - default: - { - adjusted = false; - break; - } - } - - return adjusted; -} - -void LayoutDataElement::UpdatePropertyIndex() -{ - if( propertyIndex == -1 && !propertyName.empty() ) - { - Actor actor = handle.GetHandle(); - if( actor ) - { - propertyIndex = DevelHandle::GetPropertyIndex( actor, Property::Key( propertyName ) ); - } - } -} - -void LayoutDataElement::UpdateAnimatorIndex( const LayoutAnimatorArray& animators ) -{ - if( animatorIndex == -1 ) - { - if( animatorName.empty() ) - { - animatorIndex = 0; - return; - } - - std::string animatorName = this->animatorName; - auto animator = std::find_if( animators.begin(), animators.end(), [ &animatorName ](const LayoutDataAnimator& iter) { - return ( iter.name == animatorName ); } ); - if( animator != animators.end() ) - { - animatorIndex = std::distance( animators.begin(), animator ); - } - } -} - -void LayoutDataElement::UpdatePositionDataIndex( LayoutData& layoutData ) -{ - positionDataIndex = layoutData.layoutPositionDataArray.size() - 1; - switch( propertyIndex ) - { - case Actor::Property::SCALE: - case Actor::Property::SCALE_X: - case Actor::Property::SCALE_Y: - if( positionDataIndex != -1 && updateMeasuredSize ) - { - layoutData.layoutPositionDataArray[ positionDataIndex ].updateWithCurrentSize = true; - } - break; - } -} - -LayoutTransitionData::LayoutTransitionData() : - mUpdateMeasuredSize( false ) -{ -} - -LayoutTransitionData::~LayoutTransitionData() -{ -} - -LayoutTransitionDataPtr LayoutTransitionData::New() -{ - LayoutTransitionDataPtr layoutAnimationData( new LayoutTransitionData() ); - return layoutAnimationData; -} - -LayoutTransitionData::PropertyAnimator::PropertyAnimator( ) - : handle() - , map() - , interpolation( Animation::Linear ) -{ -} - -LayoutTransitionData::PropertyAnimator::PropertyAnimator( Actor actor, Property::Map map ) - : handle( actor ) - , map( map ) - , interpolation( Animation::Linear ) -{ -} - -LayoutTransitionData::PropertyAnimator::PropertyAnimator( Actor actor, Property::Map map, Path path, Vector3 forward ) - : handle( actor ) - , map( map ) - , interpolation( Animation::Linear ) - , path( path ) - , forward( forward ) -{ -} - -LayoutTransitionData::PropertyAnimator::PropertyAnimator( Actor actor, Property::Map map, KeyFrames keyFrames, Animation::Interpolation interpolation ) - : handle( actor ) - , map( map ) - , keyFrames( keyFrames ) - , interpolation( interpolation ) -{ -} - -void LayoutTransitionData::AddPropertyAnimator( Actor actor, Property::Map map ) -{ - LayoutDataElement layoutDataElement; - if( ConvertToLayoutDataElement( PropertyAnimator( actor, map ), layoutDataElement ) ) - { - mLayoutDataElements.push_back( layoutDataElement ); - } - - UpdateAnimatorsIndices(); -} - -void LayoutTransitionData::AddPropertyAnimator( Actor actor, Property::Map map, KeyFrames keyFrames, Animation::Interpolation interpolation ) -{ - LayoutDataElement layoutDataElement; - if( ConvertToLayoutDataElement( PropertyAnimator( actor, map, keyFrames, interpolation ), layoutDataElement ) ) - { - mLayoutDataElements.push_back( layoutDataElement ); - } - - UpdateAnimatorsIndices(); -} - -void LayoutTransitionData::AddPropertyAnimator( Actor actor, Property::Map map, Path path, Vector3 forward ) -{ - LayoutDataElement layoutDataElement; - if( ConvertToLayoutDataElement( PropertyAnimator( actor, map, path, forward ), layoutDataElement ) ) - { - mLayoutDataElements.push_back( layoutDataElement ); - } - - UpdateAnimatorsIndices(); -} - -bool LayoutTransitionData::ConvertToLayoutAnimator( const Property::Map& animatorMap, const PropertyAnimator& propertyAnimator, LayoutDataAnimator& layoutDataAnimator ) -{ - bool valid = true; - - for ( size_t animatorMapIdx = 0; animatorMapIdx < animatorMap.Count(); ++animatorMapIdx ) - { - const KeyValuePair pair( animatorMap.GetKeyValue( animatorMapIdx ) ); - - Property::Index indexKey = Property::INVALID_INDEX; - if ( pair.first.type == Property::Key::STRING ) - { - const std::string& key(pair.first.stringKey); - if( key == TOKEN_TYPE ) - { - indexKey = Dali::Toolkit::LayoutTransitionData::AnimatorKey::TYPE; - } - else if( key == TOKEN_NAME ) - { - indexKey = Dali::Toolkit::LayoutTransitionData::AnimatorKey::NAME; - } - else if( key == TOKEN_TIME_PERIOD ) - { - indexKey = Dali::Toolkit::LayoutTransitionData::AnimatorKey::TIME_PERIOD; - } - else if( key == TOKEN_ALPHA_FUNCTION ) - { - indexKey = Dali::Toolkit::LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION; - } - } - else - { - indexKey = pair.first.indexKey; - } - - const Property::Value& value( pair.second ); - - if ( indexKey == Dali::Toolkit::LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION ) - { - if ( value.GetType() == Property::ARRAY ) - { - valid = true; - Vector4 controlPoints; - Property::Array *array = value.GetArray(); - if ( array && array->Count() >= 4 ) - { - for ( size_t vecIdx = 0; vecIdx < 4; ++vecIdx ) - { - Property::Value& v = array->GetElementAt( vecIdx ); - if ( v.GetType() == Property::FLOAT ) - { - controlPoints[vecIdx] = v.Get(); - } - else - { - valid = false; - break; - } - } - } - else - { - valid = false; - } - - if ( valid ) - { - Vector2 controlPoint1( controlPoints.x, controlPoints.y ); - Vector2 controlPoint2( controlPoints.z, controlPoints.w ); - layoutDataAnimator.alphaFunction = AlphaFunction( controlPoint1, controlPoint2 ); - } - else - { - valid = false; - } - } - else if ( value.GetType() == Property::VECTOR4 ) - { - Vector4 controlPoints = value.Get(); - Vector2 controlPoint1( controlPoints.x, controlPoints.y ); - Vector2 controlPoint2( controlPoints.z, controlPoints.w ); - layoutDataAnimator.alphaFunction = AlphaFunction( controlPoint1, controlPoint2 ); - } - else if ( value.GetType() == Property::INTEGER ) - { - layoutDataAnimator.alphaFunction = AlphaFunction( static_cast( value.Get() ) ); - } - else if ( value.GetType() == Property::STRING ) - { - std::string alphaFunctionValue = value.Get(); - - if ( alphaFunctionValue == "LINEAR" ) - { - layoutDataAnimator.alphaFunction = AlphaFunction( AlphaFunction::LINEAR ); - } - else if ( !alphaFunctionValue.compare( 0, 5, "EASE_" ) ) - { - if ( alphaFunctionValue == "EASE_IN" ) - { - layoutDataAnimator.alphaFunction = AlphaFunction( AlphaFunction::EASE_IN ); - } - else if ( alphaFunctionValue == "EASE_OUT" ) - { - layoutDataAnimator.alphaFunction = AlphaFunction( AlphaFunction::EASE_OUT ); - } - else if ( !alphaFunctionValue.compare( 5, 3, "IN_" ) ) - { - if ( !alphaFunctionValue.compare( 8, -1, "SQUARE" ) ) - { - layoutDataAnimator.alphaFunction = AlphaFunction( AlphaFunction::EASE_IN_SQUARE ); - } - else if ( !alphaFunctionValue.compare( 8, -1, "OUT" ) ) - { - layoutDataAnimator.alphaFunction = AlphaFunction( AlphaFunction::EASE_IN_OUT ); - } - else if ( !alphaFunctionValue.compare( 8, -1, "OUT_SINE" ) ) - { - layoutDataAnimator.alphaFunction = AlphaFunction( AlphaFunction::EASE_IN_OUT_SINE ); - } - else if ( !alphaFunctionValue.compare( 8, -1, "SINE" ) ) - { - layoutDataAnimator.alphaFunction = AlphaFunction( AlphaFunction::EASE_IN_SINE ); - } - } - else if ( !alphaFunctionValue.compare( 5, 4, "OUT_" ) ) - { - if ( !alphaFunctionValue.compare( 9, -1, "SQUARE" ) ) - { - layoutDataAnimator.alphaFunction = AlphaFunction( AlphaFunction::EASE_OUT_SQUARE ); - } - else if ( !alphaFunctionValue.compare( 9, -1, "SINE" ) ) - { - layoutDataAnimator.alphaFunction = AlphaFunction( AlphaFunction::EASE_OUT_SINE ); - } - else if ( !alphaFunctionValue.compare( 9, -1, "BACK" ) ) - { - layoutDataAnimator.alphaFunction = AlphaFunction( AlphaFunction::EASE_OUT_BACK ); - } - } - } - else if ( alphaFunctionValue == "REVERSE" ) - { - layoutDataAnimator.alphaFunction = AlphaFunction( AlphaFunction::REVERSE ); - } - else if ( alphaFunctionValue == "BOUNCE" ) - { - layoutDataAnimator.alphaFunction = AlphaFunction( AlphaFunction::BOUNCE ); - } - else if ( alphaFunctionValue == "SIN" ) - { - layoutDataAnimator.alphaFunction = AlphaFunction( AlphaFunction::SIN ); - } - else - { - valid = false; - } - } - else - { - valid = false; - } - } - else if ( indexKey == Dali::Toolkit::LayoutTransitionData::AnimatorKey::NAME ) - { - if( value.GetType() == Property::STRING ) - { - layoutDataAnimator.name = value.Get(); - } - } - else if ( indexKey == Dali::Toolkit::LayoutTransitionData::AnimatorKey::TYPE ) - { - if( value.GetType() == Property::STRING ) - { - std::string animatorType = value.Get(); - if( animatorType == ANIMATOR_TYPE_TABLE[ Toolkit::LayoutTransitionData::Animator::Type::ANIMATE_TO ].string ) - { - layoutDataAnimator.animatorType = Toolkit::LayoutTransitionData::Animator::Type::ANIMATE_TO; - } - else if( animatorType == ANIMATOR_TYPE_TABLE[ Toolkit::LayoutTransitionData::Animator::Type::ANIMATE_BY ].string ) - { - layoutDataAnimator.animatorType = Toolkit::LayoutTransitionData::Animator::Type::ANIMATE_BY; - } - else if( animatorType == ANIMATOR_TYPE_TABLE[ Toolkit::LayoutTransitionData::Animator::Type::ANIMATE_BETWEEN ].string ) - { - layoutDataAnimator.animatorType = Toolkit::LayoutTransitionData::Animator::Type::ANIMATE_BETWEEN; - layoutDataAnimator.keyFrames = propertyAnimator.keyFrames; - } - else if( animatorType == ANIMATOR_TYPE_TABLE[ Toolkit::LayoutTransitionData::Animator::Type::ANIMATE_PATH ].string ) - { - layoutDataAnimator.animatorType = Toolkit::LayoutTransitionData::Animator::Type::ANIMATE_PATH; - layoutDataAnimator.path = propertyAnimator.path; - layoutDataAnimator.forward = propertyAnimator.forward; - } - } - else if ( value.GetType() == Property::INTEGER ) - { - layoutDataAnimator.animatorType = static_cast( pair.second.Get() ); - } - } - else if ( indexKey == Dali::Toolkit::LayoutTransitionData::AnimatorKey::TIME_PERIOD ) - { - Property::Map timeMap = value.Get(); - for ( size_t timeMapIdx = 0; timeMapIdx < timeMap.Count(); ++timeMapIdx ) - { - const KeyValuePair pair( timeMap.GetKeyValue( timeMapIdx ) ); - indexKey = Property::INVALID_INDEX; - - if ( pair.first.type == Property::Key::STRING) - { - const std::string& key( pair.first.stringKey ); - if( key == TOKEN_DURATION ) - { - indexKey = Dali::Toolkit::LayoutTransitionData::AnimatorKey::DURATION; - } - else if( key == TOKEN_DELAY ) - { - indexKey = Dali::Toolkit::LayoutTransitionData::AnimatorKey::DELAY; - } - } - else - { - indexKey = pair.first.indexKey; - } - - if ( indexKey == Dali::Toolkit::LayoutTransitionData::AnimatorKey::DELAY ) - { - layoutDataAnimator.timePeriod.delaySeconds = pair.second.Get(); - } - else if ( indexKey == Dali::Toolkit::LayoutTransitionData::AnimatorKey::DURATION ) - { - layoutDataAnimator.timePeriod.durationSeconds = pair.second.Get(); - } - } - } - } - - return valid; -} - -bool LayoutTransitionData::ConvertToLayoutDataElement( - const PropertyAnimator& propertyAnimator, LayoutDataElement& layoutDataElement ) -{ - const Property::Map& map = propertyAnimator.map; - bool propertyFound = false; - - if( mLayoutAnimators.size() == 0 ) - { - mLayoutAnimators.push_back( LayoutDataAnimator() ); - } - - layoutDataElement.handle = propertyAnimator.handle; - - for( unsigned int mapIdx = 0; mapIdx < map.Count(); ++mapIdx ) - { - const KeyValuePair pair( map.GetKeyValue( mapIdx ) ); - const Property::Value& value( pair.second ); - Property::Index indexKey = Property::INVALID_INDEX; - - if ( pair.first.type == Property::Key::STRING ) - { - const std::string& key( pair.first.stringKey ); - if ( key == TOKEN_CONDITION ) - { - indexKey = Dali::Toolkit::LayoutTransitionData::AnimatorKey::CONDITION; - } - if ( key == TOKEN_PROPERTY ) - { - indexKey = Dali::Toolkit::LayoutTransitionData::AnimatorKey::PROPERTY; - } - else if( key == TOKEN_INITIAL_VALUE ) - { - indexKey = Dali::Toolkit::LayoutTransitionData::AnimatorKey::INITIAL_VALUE; - } - else if( key == TOKEN_TARGET_VALUE ) - { - indexKey = Dali::Toolkit::LayoutTransitionData::AnimatorKey::TARGET_VALUE; - } - else if( key == TOKEN_ANIMATOR ) - { - indexKey = Dali::Toolkit::LayoutTransitionData::AnimatorKey::ANIMATOR; - } - else if( key == TOKEN_AFFECTS_SIBLINGS ) - { - indexKey = Dali::Toolkit::LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS; - } - } - else - { - indexKey = pair.first.indexKey; - } - - if( indexKey == Dali::Toolkit::LayoutTransitionData::AnimatorKey::CONDITION ) - { - layoutDataElement.condition = value.Get(); - } - else if ( indexKey == Dali::Toolkit::LayoutTransitionData::AnimatorKey::AFFECTS_SIBLINGS ) - { - layoutDataElement.updateMeasuredSize = value.Get(); - if( layoutDataElement.updateMeasuredSize ) - { - mUpdateMeasuredSize = true; - } - } - else if( indexKey == Dali::Toolkit::LayoutTransitionData::AnimatorKey::PROPERTY ) - { - if( value.GetType() == Property::STRING ) - { - layoutDataElement.propertyName = value.Get(); - layoutDataElement.UpdatePropertyIndex(); - } - else - { - layoutDataElement.propertyIndex = value.Get(); - } - propertyFound = true; - } - else if( indexKey == Dali::Toolkit::LayoutTransitionData::AnimatorKey::INITIAL_VALUE ) - { - layoutDataElement.initialValue = value; - } - else if( indexKey == Dali::Toolkit::LayoutTransitionData::AnimatorKey::TARGET_VALUE ) - { - layoutDataElement.targetValue = value; - } - else if( indexKey == Dali::Toolkit::LayoutTransitionData::AnimatorKey::ANIMATOR ) - { - if( value.GetType() == Property::STRING ) - { - layoutDataElement.animatorName = value.Get(); - layoutDataElement.UpdateAnimatorIndex( mLayoutAnimators ); - } - else if ( value.GetType() == Property::MAP ) - { - Property::Map animatorMap = value.Get< Property::Map >(); - LayoutDataAnimator layoutDataAnimator; - if( ConvertToLayoutAnimator( animatorMap, propertyAnimator, layoutDataAnimator ) ) - { - mLayoutAnimators.push_back( layoutDataAnimator ); - layoutDataElement.animatorIndex = mLayoutAnimators.size() - 1; - } - } - } - } - - return propertyFound; -} - -void LayoutTransitionData::CollectChildrenLayoutDataElements( Actor child, LayoutData& layoutData ) -{ - LayoutDataArray& layoutDataArray = layoutData.layoutDataArray; - // Add the children animators - for( const LayoutDataElement& iter : layoutData.childrenLayoutDataArray ) - { - Actor actor = iter.handle.GetHandle(); - if( actor && actor != child ) - { - continue; - } - - LayoutDataElement layoutDataElement = iter; - Actor gainedChild = layoutData.layoutTransition.gainedChild.GetHandle(); - Actor lostChild = layoutData.layoutTransition.lostChild.GetHandle(); - switch ( layoutDataElement.condition ) - { - case Dali::Toolkit::LayoutTransitionData::Condition::ON_ADD: - if ( layoutData.layoutTransition.layoutTransitionType != Dali::Toolkit::LayoutTransitionData::ON_CHILD_ADD - || gainedChild != child ) - { - continue; - } - break; - case Dali::Toolkit::LayoutTransitionData::Condition::ON_REMOVE: - if( layoutData.layoutTransition.layoutTransitionType != Dali::Toolkit::LayoutTransitionData::ON_CHILD_REMOVE - || lostChild != child ) - { - continue; - } - break; - case Dali::Toolkit::LayoutTransitionData::Condition::ON_FOCUS_GAINED: - if( layoutData.layoutTransition.layoutTransitionType != Dali::Toolkit::LayoutTransitionData::ON_CHILD_FOCUS - || gainedChild != child ) - { - continue; - } - break; - case Dali::Toolkit::LayoutTransitionData::Condition::ON_FOCUS_LOST: - if( layoutData.layoutTransition.layoutTransitionType != Dali::Toolkit::LayoutTransitionData::ON_CHILD_FOCUS - || lostChild != child ) - { - continue; - } - break; - default: - break; - } - - if( layoutData.updateMeasuredSize && !layoutDataElement.updateMeasuredSize ) - { - continue; - } - - layoutDataElement.handle = child; - layoutDataElement.UpdatePropertyIndex(); - layoutDataElement.UpdatePositionDataIndex( layoutData ); - layoutDataArray.push_back( layoutDataElement ); - } -} - -void LayoutTransitionData::UpdateAnimatorsIndices() -{ - for( LayoutDataElement& iter: mLayoutDataElements ) - { - iter.UpdateAnimatorIndex( mLayoutAnimators ); - } -} - -void LayoutTransitionData::CollectLayoutDataElements( Actor owner, LayoutData& layoutData ) -{ - LayoutAnimatorArray& layoutAnimatorArray = layoutData.layoutAnimatorArray; - LayoutAnimatorArray::iterator it = mLayoutAnimators.begin(); - if (layoutAnimatorArray.size() != 0) - { - // skip default animator - ++it; - } - std::copy( it, mLayoutAnimators.end(), std::back_inserter( layoutAnimatorArray ) ); - - LayoutDataArray& layoutDataArray = layoutData.layoutDataArray; - // Collect the transition animators - for( const LayoutDataElement& iter : mLayoutDataElements ) - { - Actor actor = iter.handle.GetHandle(); - if( !actor || actor != owner ) - { - layoutData.childrenLayoutDataArray.push_back( iter ); - continue; - } - - LayoutDataElement layoutDataElement = iter; - if( layoutData.updateMeasuredSize && !layoutDataElement.updateMeasuredSize ) - { - continue; - } - - layoutDataElement.UpdatePropertyIndex(); - layoutDataElement.UpdatePositionDataIndex( layoutData ); - layoutDataArray.push_back( layoutDataElement ); - } -} - -Dali::Toolkit::LayoutTransitionData::LayoutTransitionSignalType& LayoutTransitionData::FinishedSignal() -{ - return mFinishedSignal; -} - -void LayoutTransitionData::EmitSignalFinish( int layoutTransitionType ) -{ - if ( !mFinishedSignal.Empty() ) - { - Dali::Toolkit::LayoutTransitionData handle( this ); - mFinishedSignal.Emit( static_cast(layoutTransitionType), handle ); - } -} - -bool LayoutTransitionData::HasUpdateMeasuredSize() -{ - return mUpdateMeasuredSize; -} - -} // namespace Internal -} // namespace Toolkit -} // namespace Dali diff --git a/dali-toolkit/internal/layouting/layout-transition-data-impl.h b/dali-toolkit/internal/layouting/layout-transition-data-impl.h deleted file mode 100644 index 354a1bd..0000000 --- a/dali-toolkit/internal/layouting/layout-transition-data-impl.h +++ /dev/null @@ -1,327 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_TRANSITION_DATA_IMPL_H -#define DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_TRANSITION_DATA_IMPL_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 - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -struct LayoutTransition -{ - LayoutTransition( LayoutItem& layoutItem, int layoutTransitionType, Actor gainedChild, Actor lostChild ) - : layoutItem( &layoutItem ) - , layoutTransitionType( layoutTransitionType ) - , gainedChild( gainedChild ) - , lostChild( lostChild ) - { - } - - LayoutTransition() - : layoutTransitionType( -1 ) - { - } - - bool operator==( const LayoutTransition& rhs ) - { - return ( layoutItem.Get() == rhs.layoutItem.Get() - && layoutTransitionType == rhs.layoutTransitionType - && gainedChild == rhs.gainedChild - && lostChild == rhs.lostChild ); - } - - LayoutItemPtr layoutItem; - int layoutTransitionType; - WeakHandle gainedChild; - WeakHandle lostChild; -}; - -const float DEFAULT_TRANSITION_DURATION( 0.5f ); - -struct LayoutDataAnimator -{ - LayoutDataAnimator() - : animatorType( Toolkit::LayoutTransitionData::Animator::ANIMATE_TO ), - alphaFunction( AlphaFunction::LINEAR ), - timePeriod( 0.0f, DEFAULT_TRANSITION_DURATION ), - interpolation( Animation::Linear ) - { - } - - std::string name; - Toolkit::LayoutTransitionData::Animator::Type animatorType; - AlphaFunction alphaFunction; - TimePeriod timePeriod; - - KeyFrames keyFrames; - Animation::Interpolation interpolation; - - Path path; - Vector3 forward; -}; - -using LayoutAnimatorArray = std::vector< LayoutDataAnimator >; - -struct LayoutPositionData -{ - LayoutPositionData( Actor handle, float left, float top, float right, float bottom, bool animated ) : - handle( handle ), left( left ), top( top ), right( right ), bottom( bottom ), animated( animated ), updateWithCurrentSize(false) - { - }; - - WeakHandle handle; - float left; - float top; - float right; - float bottom; - bool animated; - bool updateWithCurrentSize; -}; - -using LayoutPositionDataArray = std::vector< LayoutPositionData >; - -struct LayoutDataElement -{ - LayoutDataElement() - : propertyIndex( Property::INVALID_KEY ), - animatorIndex( -1 ), - positionDataIndex(-1 ), - condition( Dali::Toolkit::LayoutTransitionData::Condition::NONE ), - updateMeasuredSize( false ) - { - }; - - bool AdjustMeasuredSize( float& width, float& height, Toolkit::LayoutTransitionData::Animator::Type animatorType ); - void UpdatePropertyIndex(); - void UpdateAnimatorIndex( const LayoutAnimatorArray& animators ); - void UpdatePositionDataIndex( LayoutData& layoutData ); - - WeakHandle handle; - std::string propertyName; - Property::Index propertyIndex; - Property::Value initialValue; - Property::Value targetValue; - std::string animatorName; - int animatorIndex; - int positionDataIndex; - int condition; - bool updateMeasuredSize; -}; - -using LayoutDataArray = std::vector< LayoutDataElement >; - -class LayoutTransitionData; -using LayoutTransitionDataPtr = IntrusivePtr; - -/** - * LayoutTransitionData implementation class. - */ -class DALI_TOOLKIT_API LayoutTransitionData : public BaseObject -{ -public: - struct PropertyAnimator - { - PropertyAnimator(); - PropertyAnimator( Actor actor, Property::Map map ); - PropertyAnimator( Actor actor, Property::Map map, Path path, Vector3 forward ); - PropertyAnimator( Actor actor, Property::Map map, KeyFrames keyFrames, Animation::Interpolation interpolation ); - - WeakHandle handle; - - Property::Map map; - - KeyFrames keyFrames; - Animation::Interpolation interpolation; - - Path path; - Vector3 forward; - }; - using PropertyAnimatorArray = std::vector< PropertyAnimator >; - - static LayoutTransitionDataPtr New(); - - LayoutTransitionData( const LayoutTransitionData& ) = delete; - LayoutTransitionData& operator=( const LayoutTransitionData& ) = delete; - - /** - * @brief Add a property animator for an actor in the transition - * @param[in] actor The actor - * @param[in] map The map containing the transition animator keys - * - * This will parse the property animator map and add the layout data element to the array of layout data elements related to this transition - */ - void AddPropertyAnimator( Actor actor, Property::Map map ); - - /** - * @brief Add a property animator for an actor in the transition - * @param[in] actor The actor - * @param[in] map The map containing the transition animator keys - * @param[in] keyFrames The key frames used by the property animator - * @param[in] interpolation The interpolation used by the property animator - * - * This will parse the property animator map and add the layout data element to the array of layout data elements related to this transition - */ - void AddPropertyAnimator( Actor actor, Property::Map map, KeyFrames keyFrames, Animation::Interpolation interpolation ); - - /** - * @brief Add a property animator for an actor in the transition - * @param[in] actor The actor - * @param[in] map The map containing the transition animator keys - * @param[in] path The path for the property animator - * @param[in] forward The forward vector for the property animator - * - * This will parse the property animator map and add the layout data element to the array of layout data elements related to this transition - */ - void AddPropertyAnimator( Actor actor, Property::Map map, Path path, Vector3 forward ); - - /** - * @brief Collect the transition layout data elements - * @param[in] actor The actor the transition property animators are applied to - * @param[in] layoutData The layout data containing layout data elements array for the layout update - * - * This will copy the transition layout data elements to the layout data elements array - */ - void CollectLayoutDataElements( Actor, LayoutData& layoutData ); - - /** - * @brief Collect the transition children layout data elements - * @param[in] actor The actor the transition property animators are applied to - * @param[in] layoutData The layout data containing layout data elements array for the layout update - * - * This will copy the children transition layout data elements to the layout data elements array - */ - static void CollectChildrenLayoutDataElements( Actor, LayoutData& layoutData ); - - /** - * @copydoc Dali::Toolkit::LayoutTransitionData::FinishedSignal() - */ - Dali::Toolkit::LayoutTransitionData::LayoutTransitionSignalType& FinishedSignal(); - - /** - * @brief Emit the transition finish signal - * @param[in] layoutTransitionType The transition type - */ - void EmitSignalFinish( int layoutTransitionType ); - - /** - * @brief Check if one of the layout data elements has updateMeasuredSize flag set - */ - bool HasUpdateMeasuredSize(); - -private: - /** - * @brief Convert the property animator data to the layout data animator - * @param[in] animatorData The animator data map - * @param[in] propertyAnimator The property animator - * @param[in] layoutAnimator The layout animator - * - * This will parse the property animator map and add the layout data element animator to the layout animators array - */ - bool ConvertToLayoutAnimator( const Property::Map& animatorData, const PropertyAnimator& propertyAnimator, LayoutDataAnimator& layoutAnimator ); - - /** - * @brief Convert the property animator to the layout data element - * @param[in] propertyAnimator The property animator - * @param[in] layoutDataElement The layout data element - * @param[in] layoutDataElement The layout data - * - * This will parse the property animator map and add the layout data element to the layout data elements array - */ - bool ConvertToLayoutDataElement( const PropertyAnimator& propertyAnimator, LayoutDataElement& layoutDataElement ); - - void UpdateAnimatorsIndices(); - - bool mUpdateMeasuredSize; - LayoutAnimatorArray mLayoutAnimators; - LayoutDataArray mLayoutDataElements; - - /** - * Ref counted object - Only allow construction via New(). - */ - LayoutTransitionData(); - -protected: - /** - * A ref counted object may only be deleted by calling Unreference - */ - virtual ~LayoutTransitionData(); - - Dali::Toolkit::LayoutTransitionData::LayoutTransitionSignalType mFinishedSignal; -}; - -using PropertyAnimatorArray = std::vector< LayoutTransitionData::PropertyAnimator >; -using LayoutTransitionDataArray = std::vector< LayoutTransitionDataPtr >; -using LayoutDataArray = std::vector< LayoutDataElement >; - -struct LayoutData -{ - LayoutData( LayoutTransition& layoutTransition, LayoutPositionDataArray& layoutPositionDataArray, LayoutAnimatorArray& layoutAnimatorArray, - LayoutDataArray& layoutDataArray, LayoutDataArray& childrenLayoutDataArray ) - : speculativeLayout( false ), - updateMeasuredSize( false ), - layoutTransition( layoutTransition ), - layoutPositionDataArray( layoutPositionDataArray ), - layoutAnimatorArray( layoutAnimatorArray ), - layoutDataArray( layoutDataArray), - childrenLayoutDataArray( childrenLayoutDataArray ) - { - }; - - bool speculativeLayout; - bool updateMeasuredSize; - LayoutTransition& layoutTransition; - LayoutPositionDataArray& layoutPositionDataArray; - LayoutAnimatorArray& layoutAnimatorArray; - LayoutDataArray& layoutDataArray; - LayoutDataArray& childrenLayoutDataArray; -}; - -} //namespace Internal - -inline Internal::LayoutTransitionData& GetImplementation( Dali::Toolkit::LayoutTransitionData& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "LayoutTransitionData handle is empty" ); - BaseObject& object = handle.GetBaseObject(); - return static_cast< Internal::LayoutTransitionData& >( object ); -} - -inline const Internal::LayoutTransitionData& GetImplementation( const Dali::Toolkit::LayoutTransitionData& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "LayoutTransitionData handle is empty" ); - const BaseObject& object = handle.GetBaseObject(); - return static_cast< const Internal::LayoutTransitionData& >( object ); -} - -} //namespace Toolkit -} //namespace Dali - -#endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_LAYOUT_TRANSITION_DATA_IMPL_H diff --git a/dali-toolkit/internal/layouting/linear-layout-impl.cpp b/dali-toolkit/internal/layouting/linear-layout-impl.cpp deleted file mode 100644 index b077f54..0000000 --- a/dali-toolkit/internal/layouting/linear-layout-impl.cpp +++ /dev/null @@ -1,875 +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 "linear-layout-impl.h" - -//PUBLIC INCLUDES -#include -#include -#include -#include - -//INTERNAL INCLUDES -#include -#include -#include - -namespace -{ -#if defined(DEBUG_ENABLED) -static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" ); -#endif -} - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -const int HORIZONTAL_ALIGNMENT_MASK = ( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL | Dali::Toolkit::LinearLayout::Alignment::END ); -const int VERTICAL_ALIGNMENT_MASK = ( Dali::Toolkit::LinearLayout::Alignment::TOP | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL | Dali::Toolkit::LinearLayout::Alignment::BOTTOM ); - -LinearLayoutPtr LinearLayout::New() -{ - LinearLayoutPtr layout( new LinearLayout() ); - return layout; -} - -LinearLayout::LinearLayout() -: LayoutGroup(), - mCellPadding( 0, 0 ), - mOrientation( Dali::Toolkit::LinearLayout::Orientation::HORIZONTAL ), - mAlignment( Dali::Toolkit::LinearLayout::Alignment::BEGIN | Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL ), - mTotalLength( 0 ) -{ -} - -LinearLayout::~LinearLayout() -{ -} - -void LinearLayout::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::LinearLayout::ChildProperty::WEIGHT ) == - indices.End() ) - { - ChildPropertyRegistration( typeInfo.GetName(), "weight", Toolkit::LinearLayout::ChildProperty::WEIGHT, Property::FLOAT ); - } - } -} - -void LinearLayout::OnChildAdd( LayoutItem& child ) -{ - auto owner = child.GetOwner(); - if( !DevelHandle::DoesCustomPropertyExist( owner, Toolkit::LinearLayout::ChildProperty::WEIGHT ) ) - { - owner.SetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT, 0.0f ); - } -} - -void LinearLayout::SetCellPadding( LayoutSize size ) -{ - if ( mCellPadding != size ) - { - mCellPadding = size; - RequestLayout(); - } -} - -LayoutSize LinearLayout::GetCellPadding() const -{ - return mCellPadding; -} - -void LinearLayout::SetOrientation( Dali::Toolkit::LinearLayout::Orientation orientation ) -{ - if ( mOrientation != orientation ) - { - mOrientation = orientation; - RequestLayout(); - } -} - -Dali::Toolkit::LinearLayout::Orientation LinearLayout::GetOrientation() const -{ - return mOrientation; -} - -void LinearLayout::SetAlignment( unsigned int alignment ) -{ - if ( mAlignment != alignment ) - { - mAlignment = alignment; - RequestLayout(); - } -} - -unsigned int LinearLayout::GetAlignment() const -{ - return mAlignment; -} - -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; - LayoutLength weightedMaxHeight = 0; - float totalWeight = 0; - LayoutLength usedExcessSpace = 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 - - // 1st phase: - // We cycle through all children and measure children with weight 0 (non weighted children) according to their specs - // to accumulate total used space in mTotalLength based on measured sizes and margins. - // Weighted children are not measured at this phase. - // Available space for weighted children will be calculated in the phase 2 based on mTotalLength value. - for( unsigned int i = 0; i < GetChildCount(); ++i ) - { - auto childLayout = GetChildAt( i ); - if( childLayout ) - { - auto childOwner = childLayout->GetOwner(); - LayoutLength desiredHeight = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ); - LayoutLength desiredWidth = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); - float childWeight = childOwner.GetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT ); - Extents childMargin = childLayout->GetMargin(); - - totalWeight += childWeight; - - const bool useExcessSpace = desiredWidth == 0 && childWeight > 0; - if( isExactly && useExcessSpace ) - { - mTotalLength += childMargin.start + childMargin.end; - } - else - { - LayoutLength childWidth = 0; - if( useExcessSpace ) - { - // The widthMode is either UNSPECIFIED or AT_MOST, and - // this child is only laid out using excess space. Measure - // using WRAP_CONTENT so that we can find out the view's - // optimal width. - Extents padding = GetPadding(); - const MeasureSpec childWidthMeasureSpec = GetChildMeasureSpec( widthMeasureSpec, padding.start + padding.end, Toolkit::ChildLayoutData::WRAP_CONTENT ); - const MeasureSpec childHeightMeasureSpec = GetChildMeasureSpec( heightMeasureSpec, padding.top + padding.bottom, desiredHeight ); - childLayout->Measure( childWidthMeasureSpec, childHeightMeasureSpec ); - childWidth = childLayout->GetMeasuredWidth(); - usedExcessSpace += childWidth; - } - else - { - MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec ); - childWidth = childLayout->GetMeasuredWidth(); - } - - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LinearLayout::OnMeasure childWidth(" << childWidth << ")\n" ); - LayoutLength length = childWidth + childMargin.start + childMargin.end; - LayoutLength cellPadding = i < GetChildCount() - 1 ? mCellPadding.width : 0; - if( isExactly ) - { - mTotalLength += length; - } - else - { - LayoutLength 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; - } - - LayoutLength marginHeight = childMargin.top + childMargin.bottom; - LayoutLength 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 ); - if( childWeight > 0 ) - { - /* - * Heights of weighted Views are bogus if we end up - * remeasuring, so keep them separate. - */ - weightedMaxHeight = std::max( weightedMaxHeight, matchHeightLocally ? marginHeight : childHeight ); - } - else - { - alternativeMaxHeight = std::max( alternativeMaxHeight, matchHeightLocally ? marginHeight : childHeight ); - } - } - } - - Extents padding = GetPadding(); - mTotalLength += padding.start + padding.end; - LayoutLength widthSize = mTotalLength; - widthSize = std::max( widthSize, GetSuggestedMinimumWidth() ); - MeasuredSize widthSizeAndState = ResolveSizeAndState( widthSize, widthMeasureSpec, MeasuredSize::State::MEASURED_SIZE_OK); - widthSize = widthSizeAndState.GetSize(); - - // Expand children with weight to take up available space - // 2nd phase: - // We cycle through weighted children now (children with weight > 0). - // The children are measured with exact size equal to their share of the available space based on their weights. - // mTotalLength is updated to include weighted children measured sizes. - LayoutLength remainingExcess = widthSize - mTotalLength + usedExcessSpace; - if( remainingExcess != 0 && totalWeight > 0 ) - { - float remainingWeightSum = totalWeight; - maxHeight = 0; - mTotalLength = 0; - - for( unsigned int i = 0; i < GetChildCount(); ++i ) - { - auto childLayout = GetChildAt( i ); - auto childOwner = childLayout->GetOwner(); - LayoutLength desiredWidth = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); - LayoutLength desiredHeight = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ); - float childWeight = childOwner.GetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT ); - Extents childMargin = childLayout->GetMargin(); - - LayoutLength childWidth = 0; - if( childWeight > 0 ) - { - LayoutLength share = ( childWeight * remainingExcess ) / remainingWeightSum; - remainingExcess -= share; - remainingWeightSum -= childWeight; - - // Always lay out weighted elements with intrinsic size regardless of the parent spec. - // for consistency between specs. - if( desiredWidth == 0 ) - { - // This child needs to be laid out from scratch using - // only its share of excess space. - childWidth = share; - } - else - { - // This child had some intrinsic width to which we - // need to add its share of excess space. - childWidth = childLayout->GetMeasuredWidth() + share; - } - - const MeasureSpec childWidthMeasureSpec = MeasureSpec( childWidth, MeasureSpec::Mode::EXACTLY ); - const MeasureSpec childHeightMeasureSpec = GetChildMeasureSpec( heightMeasureSpec, padding.top + padding.bottom, desiredHeight ); - childLayout->Measure( childWidthMeasureSpec, childHeightMeasureSpec ); - - // Child may now not fit in horizontal dimension. - if( childLayout->GetMeasuredWidthAndState().GetState() == MeasuredSize::State::MEASURED_SIZE_TOO_SMALL ) - { - childState.widthState = MeasuredSize::State::MEASURED_SIZE_TOO_SMALL; - } - } - - LayoutLength length = childLayout->GetMeasuredWidth() + LayoutLength( childMargin.start + childMargin.end ); - LayoutLength cellPadding = i < GetChildCount() - 1 ? mCellPadding.width : 0; - if( isExactly ) - { - mTotalLength += length; - } - else - { - LayoutLength totalLength = mTotalLength; - mTotalLength = std::max( totalLength, totalLength + length + cellPadding ); - } - - bool matchHeightLocally = heightMode != MeasureSpec::Mode::EXACTLY && desiredHeight == Toolkit::ChildLayoutData::MATCH_PARENT; - LayoutLength marginHeight = childMargin.top + childMargin.bottom; - LayoutLength childHeight = childLayout->GetMeasuredHeight() + marginHeight; - - maxHeight = std::max( maxHeight, childHeight ); - alternativeMaxHeight = std::max( alternativeMaxHeight, matchHeightLocally ? marginHeight : childHeight ); - allFillParent = (allFillParent && desiredHeight == Toolkit::ChildLayoutData::MATCH_PARENT); - - mTotalLength += padding.start + padding.end; - } - } - else - { - alternativeMaxHeight = std::max( alternativeMaxHeight, weightedMaxHeight ); - } - - 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 - MeasureSpec uniformMeasureSpec( GetMeasuredHeight(), MeasureSpec::Mode::EXACTLY ); - for (int i = 0; i < count; ++i) - { - LayoutItemPtr childLayout = GetChildAt(i); - if( childLayout != nullptr ) - { - auto childOwner = childLayout->GetOwner(); - LayoutLength desiredWidth = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); - LayoutLength desiredHeight = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ); - - if( desiredHeight == Toolkit::ChildLayoutData::MATCH_PARENT ) - { - // Temporarily force children to reuse their old measured width - LayoutLength oldWidth = desiredWidth; - childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, childLayout->GetMeasuredWidth().AsInteger() ); - - // Remeasure with new dimensions - MeasureChildWithMargins( childLayout, widthMeasureSpec, 0, uniformMeasureSpec, 0 ); - - childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, oldWidth.AsInteger() ); - } - } - } -} - -void LinearLayout::LayoutHorizontal( LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ) -{ - auto owner = GetOwner(); - auto actor = Actor::DownCast(owner); - bool isLayoutRtl = actor ? actor.GetProperty( Actor::Property::LAYOUT_DIRECTION ) : false; - - Extents padding = GetPadding(); - - LayoutLength childTop( padding.top ); - LayoutLength childLeft( padding.start ); - - // Where bottom of child should go - LayoutLength height = bottom - top; - - // Space available for child - LayoutLength childSpace = height - padding.top - padding.bottom; - - auto count = GetChildCount(); - - switch ( mAlignment & HORIZONTAL_ALIGNMENT_MASK ) - { - case Dali::Toolkit::LinearLayout::Alignment::BEGIN: - default: - { - // mTotalLength contains the padding already - // In case of RTL map BEGIN alignment to the right edge - if ( isLayoutRtl ) - { - childLeft = LayoutLength( padding.start ) + right - left - mTotalLength; - } - else - { - childLeft = LayoutLength( padding.start ); - } - break; - } - case Dali::Toolkit::LinearLayout::Alignment::END: - { - // mTotalLength contains the padding already - // In case of RTL map END alignment to the left edge - if ( isLayoutRtl ) - { - childLeft = LayoutLength( padding.start ); - } - else - { - childLeft = LayoutLength( padding.start ) + right - left - mTotalLength; - } - break; - } - case Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL: - { - // mTotalLength contains the padding already - childLeft = padding.start + ( right - left - mTotalLength ) / 2.0f; - break; - } - } - - int start = 0; - int dir = 1; - - // In case of RTL, start drawing from the last child. - 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 ) - { - LayoutLength childWidth = childLayout->GetMeasuredWidth(); - LayoutLength childHeight = childLayout->GetMeasuredHeight(); - Extents childMargin = childLayout->GetMargin(); - - switch ( mAlignment & VERTICAL_ALIGNMENT_MASK ) - { - case Dali::Toolkit::LinearLayout::Alignment::TOP: - { - childTop = LayoutLength( padding.top ) + childMargin.top; - break; - } - case Dali::Toolkit::LinearLayout::Alignment::BOTTOM: - { - childTop = height - padding.bottom - childHeight - childMargin.bottom; - break; - } - case Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL: // FALLTHROUGH - default: - { - childTop = padding.top + ( ( childSpace - childHeight ) / 2.0f ) + childMargin.top - childMargin.bottom; - break; - } - } - 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(); - auto heightMode = heightMeasureSpec.GetMode(); - bool isExactly = ( heightMode == MeasureSpec::Mode::EXACTLY ); - - bool matchWidth = false; - bool allFillParent = true; - LayoutLength maxWidth = 0; - LayoutLength alternativeMaxWidth = 0; - LayoutLength weightedMaxWidth = 0; - float totalWeight = 0; - LayoutLength usedExcessSpace = 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 - - // 1st phase: - // We cycle through all children and measure children with weight 0 (non weighted children) according to their specs - // to accumulate total used space in mTotalLength based on measured sizes and margins. - // Weighted children are not measured at this phase. - // Available space for weighted children will be calculated in the phase 2 based on mTotalLength value. - for( unsigned int i = 0; i < GetChildCount(); ++i ) - { - auto childLayout = GetChildAt( i ); - if( childLayout ) - { - auto childOwner = childLayout->GetOwner(); - LayoutLength desiredWidth = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); - LayoutLength desiredHeight = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ); - float childWeight = childOwner.GetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT ); - Extents childMargin = childLayout->GetMargin(); - - totalWeight += childWeight; - - bool useExcessSpace = desiredHeight == 0 && childWeight > 0; - - if( isExactly && useExcessSpace ) - { - LayoutLength totalLength = mTotalLength; - mTotalLength = std::max( totalLength, totalLength + childMargin.top + childMargin.bottom ); - } - else - { - LayoutLength childHeight = 0; - if( useExcessSpace ) - { - // The heightMode is either UNSPECIFIED or AT_MOST, and - // this child is only laid out using excess space. Measure - // using WRAP_CONTENT so that we can find out the view's - // optimal height. We'll restore the original height of 0 - // after measurement. - Extents padding = GetPadding(); - const MeasureSpec childWidthMeasureSpec = GetChildMeasureSpec( widthMeasureSpec, padding.start + padding.end, desiredWidth ); - const MeasureSpec childHeightMeasureSpec = GetChildMeasureSpec( heightMeasureSpec, padding.top + padding.bottom, Toolkit::ChildLayoutData::WRAP_CONTENT ); - childLayout->Measure( childWidthMeasureSpec, childHeightMeasureSpec ); - childHeight = childLayout->GetMeasuredHeight(); - usedExcessSpace += childHeight; - } - else - { - MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec ); - childHeight = childLayout->GetMeasuredHeight(); - } - - DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LinearLayout::MeasureVertical childHeight(" << childHeight << ")\n" ); - - LayoutLength length = childHeight + childMargin.top + childMargin.bottom; - LayoutLength cellPadding = i < GetChildCount() - 1 ? mCellPadding.height : 0; - LayoutLength 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; - } - - LayoutLength marginWidth = childMargin.start + childMargin.end; - LayoutLength 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 ); - if( childWeight > 0 ) - { - /* - * Widths of weighted Views are bogus if we end up - * remeasuring, so keep them separate. - */ - weightedMaxWidth = std::max( weightedMaxWidth, matchWidthLocally ? marginWidth : childWidth ); - } - else - { - alternativeMaxWidth = std::max( alternativeMaxWidth, matchWidthLocally ? marginWidth : childWidth ); - } - } - } - - Extents padding = GetPadding(); - mTotalLength += padding.top + padding.bottom; - LayoutLength heightSize = mTotalLength; - heightSize = std::max( heightSize, GetSuggestedMinimumHeight() ); - MeasuredSize heightSizeAndState = ResolveSizeAndState( heightSize, heightMeasureSpec, MeasuredSize::State::MEASURED_SIZE_OK); - heightSize = heightSizeAndState.GetSize(); - - // Either expand children with weight to take up available space or - // shrink them if they extend beyond our current bounds. If we skipped - // measurement on any children, we need to measure them now. - - // 2nd phase: - // We cycle through weighted children now (children with weight > 0). - // The children are measured with exact size equal to their share of the available space based on their weights. - // mTotalLength is updated to include weighted children measured sizes. - LayoutLength remainingExcess = heightSize - mTotalLength + usedExcessSpace; - if( remainingExcess != 0 && totalWeight > 0.0f ) - { - float remainingWeightSum = totalWeight; - - mTotalLength = 0; - - for( unsigned int i = 0; i < GetChildCount(); ++i ) - { - auto childLayout = GetChildAt( i ); - auto childOwner = childLayout->GetOwner(); - LayoutLength desiredWidth = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); - LayoutLength desiredHeight = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ); - float childWeight = childOwner.GetProperty( Toolkit::LinearLayout::ChildProperty::WEIGHT ); - Extents childMargin = childLayout->GetMargin(); - - LayoutLength childHeight = 0; - if( childWeight > 0 ) - { - LayoutLength share = ( childWeight * remainingExcess ) / remainingWeightSum; - remainingExcess -= share; - remainingWeightSum -= childWeight; - - // Always lay out weighted elements with intrinsic size regardless of the parent spec - // for consistency between specs. - if( desiredHeight == 0 ) - { - // This child needs to be laid out from scratch using - // only its share of excess space. - childHeight = share; - } - else - { - // This child had some intrinsic width to which we - // need to add its share of excess space. - childHeight = childLayout->GetMeasuredHeight() + share; - } - - const MeasureSpec childWidthMeasureSpec = GetChildMeasureSpec( widthMeasureSpec, padding.start + padding.end, desiredWidth ); - const MeasureSpec childHeightMeasureSpec = MeasureSpec( childHeight, MeasureSpec::Mode::EXACTLY ); - childLayout->Measure( childWidthMeasureSpec, childHeightMeasureSpec ); - - // Child may now not fit in vertical dimension. - if( childLayout->GetMeasuredHeightAndState().GetState() == MeasuredSize::State::MEASURED_SIZE_TOO_SMALL ) - { - childState.heightState = MeasuredSize::State::MEASURED_SIZE_TOO_SMALL; - } - } - - 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; - } - - LayoutLength marginWidth = childMargin.start + childMargin.end; - LayoutLength childWidth = childLayout->GetMeasuredWidth() + marginWidth; - maxWidth = std::max( maxWidth, childWidth ); - allFillParent = allFillParent && desiredWidth == Toolkit::ChildLayoutData::MATCH_PARENT; - alternativeMaxWidth = std::max( alternativeMaxWidth, matchWidthLocally ? marginWidth : childWidth ); - - childHeight = childLayout->GetMeasuredHeight(); - LayoutLength length = childHeight + childMargin.top + childMargin.bottom; - LayoutLength cellPadding = i < GetChildCount() - 1 ? mCellPadding.height : 0; - LayoutLength totalLength = mTotalLength; - mTotalLength = std::max( totalLength, totalLength + length + cellPadding ); - } - - // Add in our padding - mTotalLength += padding.top + padding.bottom; - } - else - { - alternativeMaxWidth = std::max( alternativeMaxWidth, weightedMaxWidth ); - } - - 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. - MeasureSpec uniformMeasureSpec( GetMeasuredWidth(), MeasureSpec::Mode::EXACTLY ); - for (int i = 0; i < count; ++i) - { - LayoutItemPtr childLayout = GetChildAt(i); - if( childLayout != nullptr ) - { - auto childOwner = childLayout->GetOwner(); - LayoutLength desiredWidth = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); - LayoutLength desiredHeight = childOwner.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ); - - if( desiredWidth == Toolkit::ChildLayoutData::MATCH_PARENT ) - { - // Temporarily force children to reuse their old measured height - LayoutLength oldHeight = desiredHeight; - childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, childLayout->GetMeasuredHeight().AsInteger() ); - - // Remeasure with new dimensions - MeasureChildWithMargins( childLayout, uniformMeasureSpec, 0, heightMeasureSpec, 0 ); - - childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, oldHeight.AsInteger() ); - } - } - } -} - -void LinearLayout::LayoutVertical( LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ) -{ - Extents padding = GetPadding(); - - LayoutLength childTop( padding.top ); - LayoutLength childLeft( padding.start ); - - // Where end of child should go - LayoutLength width = right - left; - - // Space available for child - LayoutLength childSpace = width - padding.start - padding.end; - auto count = GetChildCount(); - - switch ( mAlignment & VERTICAL_ALIGNMENT_MASK ) - { - case Dali::Toolkit::LinearLayout::Alignment::TOP: - { - // mTotalLength contains the padding already - childTop = LayoutLength( padding.top ); - break; - } - case Dali::Toolkit::LinearLayout::Alignment::BOTTOM: - { - // mTotalLength contains the padding already - childTop = LayoutLength( padding.top ) + bottom - top - mTotalLength; - break; - } - case Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL: - default: - { - // mTotalLength contains the padding already - childTop = padding.top + ( bottom - top - mTotalLength ) / 2.0f; - break; - } - } - - for( unsigned int childIndex = 0; childIndex < count; childIndex++) - { - LayoutItemPtr childLayout = GetChildAt( childIndex ); - if( childLayout != nullptr ) - { - LayoutLength childWidth = childLayout->GetMeasuredWidth(); - LayoutLength childHeight = childLayout->GetMeasuredHeight(); - Extents childMargin = childLayout->GetMargin(); - - childTop += childMargin.top; - switch ( mAlignment & HORIZONTAL_ALIGNMENT_MASK ) - { - case Dali::Toolkit::LinearLayout::Alignment::BEGIN: - default: - { - childLeft = LayoutLength( padding.start ) + childMargin.start; - break; - } - case Dali::Toolkit::LinearLayout::Alignment::END: - { - childLeft = width - padding.end - childWidth - childMargin.end; - break; - } - case Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL: - { - childLeft = padding.start + ( childSpace - childWidth ) / 2.0f + childMargin.start - childMargin.end; - break; - } - } - 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 deleted file mode 100644 index 5f39ad2..0000000 --- a/dali-toolkit/internal/layouting/linear-layout-impl.h +++ /dev/null @@ -1,177 +0,0 @@ -#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 -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -class LinearLayout; -using LinearLayoutPtr = IntrusivePtr; - -class LinearLayout final : public LayoutGroup -{ -public: - /** - * Creates a pointer to a LinearLayout implementation. - */ - static LinearLayoutPtr New(); - -public: - /** - * @brief Set the padding between cells in the layout - * - * @param[in] size The padding between cells. - */ - void SetCellPadding( LayoutSize size ); - - /** - * @brief Get the padding between cells in the layout - * - * @return The padding between cells. - */ - LayoutSize GetCellPadding() const; - - /** - * @brief Set the orientation in the layout - * - * @param[in] orientation The orientation. - */ - void SetOrientation( Dali::Toolkit::LinearLayout::Orientation orientation ); - - /** - * @brief Get the orientation in the layout - * - * @return The orientation. - */ - Dali::Toolkit::LinearLayout::Orientation GetOrientation() const; - - /** - * @brief Set the alignment in the layout - * - * @param[in] alignment The alignment. - */ - void SetAlignment( unsigned int alignment ); - - /** - * @brief Get the alignment in the layout - * - * @return The alignment. - */ - unsigned int GetAlignment() const; - -protected: - /** - * Default Constructor - */ - LinearLayout(); - - /** - * Destructor - */ - virtual ~LinearLayout(); - - /** - * @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: - 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; - unsigned int mAlignment; - 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( 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( object ); -} - -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_LINEAR_LAYOUT_H diff --git a/dali-toolkit/internal/layouting/size-negotiation-mapper.cpp b/dali-toolkit/internal/layouting/size-negotiation-mapper.cpp deleted file mode 100644 index 2a1c7a3..0000000 --- a/dali-toolkit/internal/layouting/size-negotiation-mapper.cpp +++ /dev/null @@ -1,210 +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 - -// EXTERNAL HEADER -#include - -// INTERNAL HEADER -#include -#include -#include - -namespace -{ -#if defined(DEBUG_ENABLED) -Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" ); -#endif - -/** - * Set the width specification with the given layout params - */ -void SetWidthLayoutParams( Dali::Toolkit::Control control, int layoutParams ) -{ - DALI_LOG_INFO( gLogFilter, Debug::General, "SizeNegotiationMapper::SetLayoutParamsUsingResizePolicy Setting WIDTH LayoutParam(%d) for %s\n", - layoutParams, - control.GetName().c_str() ); - control.SetProperty( Dali::Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, layoutParams ); -} - -/** - * Set the height specification with the given layout params - */ -void SetHeightLayoutParams( Dali::Toolkit::Control control, int layoutParams ) -{ - DALI_LOG_INFO( gLogFilter, Debug::General, "SizeNegotiationMapper::SetLayoutParamsUsingResizePolicy Setting HEIGHT LayoutParam(%d) for %s\n", - layoutParams, - control.GetName().c_str() ); - control.SetProperty( Dali::Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, layoutParams ); -} - -/** - * Call SetResizePolicyRequired true on the layout belonging to the provided control - */ -void SetResizePolicyRequiredFlag( Dali::Toolkit::Internal::LayoutItemPtr layout ) -{ - layout->SetResizePolicyRequired( true ); -} - -} // namspace - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -void SizeNegotiationMapper::SetLayoutParametersUsingResizePolicy( Toolkit::Control control, Toolkit::Internal::LayoutItemPtr layout, Dimension::Type dimension ) -{ - // Get control's current width specification - int matchedLayoutParamWidth = control.GetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); - int matchedLayoutParamHeight = control.GetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ); - - // Get control's Resize Policy that should be mapped to a width specification - const ResizePolicy::Type resizePolicy = control.GetResizePolicy( dimension ); - - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SizeNegotiationMapper::SetLayoutParamsUsingResizePolicy ResizePolicy for control:%s resizePolicy %d for dimension %d\n", - control?control.GetName().c_str():"Invalid", - resizePolicy, - dimension ); - - bool matchFound( false ); - - // Use the control's ResizePolicy to determine the new specification - switch( resizePolicy ) - { - case ResizePolicy::USE_ASSIGNED_SIZE : - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SizeNegotiationMapper::SetLayoutParamsUsingResizePolicy USE_ASSIGNED_SIZE\n"); - // Set by legacy controls on their children. Will not be exposed to a Layout. - break; - } - - case ResizePolicy::FIXED : - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SizeNegotiationMapper::SetLayoutParamsUsingResizePolicy FIXED\n"); - Vector3 controlSize = control.GetTargetSize(); - matchedLayoutParamWidth = controlSize.width; - matchedLayoutParamHeight = controlSize.height; - matchFound = true; - break; - }; - case ResizePolicy::USE_NATURAL_SIZE : - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SizeNegotiationMapper::SetLayoutParamsUsingResizePolicy USE_NATURAL_SIZE\n"); - // Default ResizePolicy for controls. - // LayoutGroups are containers, containers will not have a natural size. - break; - }; - case ResizePolicy::FILL_TO_PARENT : - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SizeNegotiationMapper::SetLayoutParamsUsingResizePolicy FILL_TO_PARENT\n"); - matchedLayoutParamWidth = ChildLayoutData::MATCH_PARENT; - matchedLayoutParamHeight = ChildLayoutData::MATCH_PARENT; - matchFound = true; - break; - }; - case ResizePolicy::SIZE_RELATIVE_TO_PARENT : - { - SetResizePolicyRequiredFlag( layout ); // Defer setting the exact size until the parent size is known. - break; - }; - case ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT : - { - SetResizePolicyRequiredFlag( layout ); // Defer setting the exact size until the parent size is known. - break; - }; - case ResizePolicy::FIT_TO_CHILDREN : - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SizeNegotiationMapper::SetLayoutParamsUsingResizePolicy FIT_TO_CHILDREN\n"); - matchedLayoutParamWidth = ChildLayoutData::WRAP_CONTENT; - matchedLayoutParamHeight = ChildLayoutData::WRAP_CONTENT; - matchFound = true; - break; - }; - case ResizePolicy::DIMENSION_DEPENDENCY : - { - // Not supported - break; - }; - } - - // Use the resize policy for the required dimensions only. - // Possible that only one dimension was set hence either the matchedLayoutParamWidth or - // matchedLayoutParamHeight should not be used. - if( matchFound ) - { - if( dimension & Dimension::WIDTH ) - { - SetWidthLayoutParams( control, matchedLayoutParamWidth ); - } - - if( dimension & Dimension::HEIGHT ) - { - SetHeightLayoutParams( control, matchedLayoutParamHeight ); - } - } -}; - -void SizeNegotiationMapper::GetSizeofChildForParentDependentResizePolicy( Toolkit::Control control, const MeasureSpec parentWidthSpecification, const MeasureSpec parentHeightSpecification, LayoutLength& childWidth, LayoutLength& childHeight) -{ - DALI_LOG_INFO( gLogFilter, Debug::General, "SizeNegotiationMapper::SetLayoutParamsForParentDependantResizePolicy ResizePolicy required for %s\n", control.GetName().c_str() ); - ResizePolicy::Type widthResizePolicy = control.GetResizePolicy( Dimension::WIDTH ); - ResizePolicy::Type heightResizePolicy = control.GetResizePolicy( Dimension::HEIGHT ); - Vector3 sizeModeFactor = control.GetSizeModeFactor(); - - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SizeNegotiationMapper::MeasureChild SetLayoutParamsForParentDependantResizePolicy for control:%s resizePolicy w:%d h:%d modeFactor(%f,%f,%f)\n", - control?control.GetName().c_str():"Invalid", - widthResizePolicy, heightResizePolicy, - sizeModeFactor.x, - sizeModeFactor.y, - sizeModeFactor.z ); - - if( widthResizePolicy == ResizePolicy::SIZE_RELATIVE_TO_PARENT ) - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SizeNegotiationMapper::SetLayoutParamsForParentDependantResizePolicy width SIZE_RELATIVE_TO_PARENT\n"); - childWidth = parentWidthSpecification.GetSize().AsDecimal() * sizeModeFactor.x; - } - else if( widthResizePolicy == ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT ) - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SizeNegotiationMapper::SetLayoutParamsForParentDependantResizePolicy width SIZE_FIXED_OFFSET_FROM_PARENT\n"); - childWidth = parentWidthSpecification.GetSize().AsDecimal() + sizeModeFactor.x; - } - - if( heightResizePolicy == ResizePolicy::SIZE_RELATIVE_TO_PARENT ) - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SizeNegotiationMapper::SetLayoutParamsForParentDependantResizePolicy height SIZE_RELATIVE_TO_PARENT\n"); - childHeight = parentHeightSpecification.GetSize().AsDecimal() * sizeModeFactor.y; - } - else if( heightResizePolicy == ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT ) - { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SizeNegotiationMapper::SetLayoutParamsForParentDependantResizePolicy height SIZE_FIXED_OFFSET_FROM_PARENT\n"); - childHeight = parentHeightSpecification.GetSize().AsDecimal() + sizeModeFactor.y; - } - - // DIMENSION_DEPENDENCY not supported - - DALI_LOG_INFO( gLogFilter, Debug::General, "SizeNegotiationMapper::SetLayoutParamsForParentDependantResizePolicy child size(%f,%f)\n", childWidth.AsInteger(), childHeight.AsInteger() ); -} - -} // namespace Internal - -} // namespace Toolkit - -} // namespace Dali \ No newline at end of file diff --git a/dali-toolkit/internal/layouting/size-negotiation-mapper.h b/dali-toolkit/internal/layouting/size-negotiation-mapper.h deleted file mode 100644 index 082da33..0000000 --- a/dali-toolkit/internal/layouting/size-negotiation-mapper.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_SIZE_NEGOTIATION_MAPPER_IMPL_H -#define DALI_TOOLKIT_INTERNAL_LAYOUTING_SIZE_NEGOTIATION_MAPPER_IMPL_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. - */ - -// EXTERNAL HEADERS -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ -using LayoutItemPtr = IntrusivePtr; -/** - * @brief Maps ResizePolicies used in SizeNegotiation to the Layout system - * - */ -namespace SizeNegotiationMapper -{ -/** - * @brief Sets the child layout parameters on the control by mapping it's ResizePolicy to a MeasureSpecification - * @param[out] control the control to set the layout params on - * @param[out] layout the layout for the given control - * @param[in] dimension the dimension or dimensions the resize policy applies to. - * @note If Dimension::ALL_DIMENSIONS is provided as the dimension parameter then Dimension::WIDTH is used for - * both height and width mapping. - */ -void SetLayoutParametersUsingResizePolicy( Toolkit::Control control, Toolkit::Internal::LayoutItemPtr layout, const Dimension::Type dimension ); - -/** - * @brief Sets the child layout parameters on the control using the a ResizePolicy that is dependant on it's parent - * @param[out] control the control to set the layout params on - * @param[in] parentWidthSpecification the parent's width measure specification - * @param[in] parentHeightSpecification the parent's height measure specification - * @param[out] childWidth the resulting child width - * @param[out] childHeight the resulting child height - * @note This method should be used after a child has been parented and a parent measure spec is available. - */ -void GetSizeofChildForParentDependentResizePolicy( Toolkit::Control control, const MeasureSpec parentWidthSpecification, const MeasureSpec parentHeightSpecification, LayoutLength& childWidth, LayoutLength& childHeight ); - -} // namespace SizeNegotiationMapper - -} // namespace Internal - -} // namespace Toolkit - -} // namespace Dali - - -#endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_SIZE_NEGOTIATION_MAPPER_IMPL_H \ No newline at end of file diff --git a/dali-toolkit/internal/layouting/vbox-layout-impl.cpp b/dali-toolkit/internal/layouting/vbox-layout-impl.cpp deleted file mode 100644 index 22fba16..0000000 --- a/dali-toolkit/internal/layouting/vbox-layout-impl.cpp +++ /dev/null @@ -1,261 +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 - -//INTERNAL HEADERS -#include -#include -#include -#include -#include -#include -#include - -namespace -{ -#if defined(DEBUG_ENABLED) -static Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" ); -#endif -} - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -VboxLayoutPtr VboxLayout::New() -{ - VboxLayoutPtr layout( new VboxLayout() ); - return layout; -} - -VboxLayout::VboxLayout() -: LayoutGroup(), - mCellPadding( 0, 0 ), - mTotalLength( 0 ) -{ -} - -VboxLayout::~VboxLayout() -{ -} - -void VboxLayout::DoInitialize() -{ -} - -void VboxLayout::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::VboxLayout::ChildProperty::WEIGHT ) == - indices.End() ) - { - ChildPropertyRegistration( typeInfo.GetName(), "weight", Toolkit::VboxLayout::ChildProperty::WEIGHT, Property::FLOAT ); - } - } -} - -void VboxLayout::OnChildAdd( LayoutItem& child ) -{ - auto owner = child.GetOwner(); - owner.SetProperty( Toolkit::VboxLayout::ChildProperty::WEIGHT, 1.0f ); -} - -void VboxLayout::SetCellPadding( LayoutSize size ) -{ - mCellPadding = size; -} - -LayoutSize VboxLayout::GetCellPadding() -{ - return mCellPadding; -} - - -void VboxLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) -{ -#if defined(DEBUG_ENABLED) - auto actor = Actor::DownCast(GetOwner()); - - std::ostringstream oss; - oss << "VboxLayout::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 - - 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; iGetOwner(); - auto desiredWidth = childOwner.GetProperty( 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 = iGetMeasuredWidth() + 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 VboxLayout::ForceUniformWidth( int count, MeasureSpec heightMeasureSpec ) -{ - // 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( 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( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ); - auto desiredHeight = childOwner.GetProperty( 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 VboxLayout::OnLayout( bool changed, 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 childOwner = childLayout->GetOwner(); - 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/vbox-layout-impl.h b/dali-toolkit/internal/layouting/vbox-layout-impl.h deleted file mode 100644 index fb88095..0000000 --- a/dali-toolkit/internal/layouting/vbox-layout-impl.h +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_VBOX_LAYOUT_H -#define DALI_TOOLKIT_INTERNAL_LAYOUTING_VBOX_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 -#include -#include -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ - -class VboxLayout; -using VboxLayoutPtr = IntrusivePtr; - -class VboxLayout final : public LayoutGroup -{ -public: - static VboxLayoutPtr New(); - -public: - - /** - * Set the inter-cell padding - * @param[in] size The size of the inter-cell padding - */ - void SetCellPadding( LayoutSize size ); - - /** - * Get the inter-cell padding - * @return The size of the inter-cell padding - */ - LayoutSize GetCellPadding(); - -protected: - /** - * Constructor - */ - VboxLayout(); - - /** - * Virtual destructor - */ - virtual ~VboxLayout(); - - /** - * @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: - VboxLayout( const VboxLayout& other ) = delete; - VboxLayout& operator=( const VboxLayout& other ) = delete; - - /** - * Apply a uniform width to the children - */ - void ForceUniformWidth( int count, MeasureSpec heightMeasureSpec ); - -private: - LayoutSize mCellPadding; - LayoutLength mTotalLength; -}; - -} // namespace Internal - -inline Internal::VboxLayout& GetImplementation( Dali::Toolkit::VboxLayout& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "VboxLayout handle is empty" ); - BaseObject& object = handle.GetBaseObject(); - return static_cast( object ); -} - -inline const Internal::VboxLayout& GetImplementation( const Dali::Toolkit::VboxLayout& handle ) -{ - DALI_ASSERT_ALWAYS( handle && "VboxLayout handle is empty" ); - const BaseObject& object = handle.GetBaseObject(); - return static_cast( object ); -} - -} // namespace Toolkit -} // namespace Dali - -#endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_VBOX_LAYOUT_H diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index d8cd9f8..066fb3b 100755 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -575,9 +575,10 @@ void Control::OnStageConnection( int depth ) CreateClippingRenderer( *this ); // Request to be laid out when the control is connected to the Stage. - Toolkit::DevelControl::RequestLayout( *this ); + // Signal that a Relayout may be needed } + void Control::OnStageDisconnection() { mImpl->OnStageDisconnection();