1 #ifndef TEST_INTERNAL_CUSTOM_LAYOUT_H
2 #define TEST_INTERNAL_CUSTOM_LAYOUT_H
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 #include <dali/public-api/common/intrusive-ptr.h>
22 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
25 #include "custom-layout.h"
33 using Dali::Toolkit::MeasureSpec;
34 using Dali::Toolkit::LayoutLength;
37 using CustomLayoutPtr = Dali::IntrusivePtr< CustomLayout >;
40 * @brief The implementation of our custom layout.
42 * Here we will override the methods that we require to mimic a very simple horizontal layout.
44 class CustomLayout final : public Dali::Toolkit::Internal::LayoutGroup
49 * @brief Create a new CustomLayout object.
50 * @return An intrusive pointer to the created CustomLayout object
52 static CustomLayoutPtr New();
54 // Movable but not copyable
55 CustomLayout( const CustomLayout& other ) = delete;
56 CustomLayout& operator=( const CustomLayout& ) = delete;
57 CustomLayout( CustomLayout&& other ) = default;
58 CustomLayout& operator=( CustomLayout&& other ) = default;
63 * @brief Default Constructor
65 CustomLayout() = default;
70 virtual ~CustomLayout() = default;
73 * @copydoc LayoutItem::OnMeasure
75 * Overriding this method so that we can calculate the size we require using our children's sizes
77 virtual void OnMeasure( MeasureSpec widthMeasureSpec, Dali::Toolkit::MeasureSpec heightMeasureSpec ) override;
80 * @copydoc LayoutItem::OnLayout
82 * Overriding this method so that we can layout our children as required.
84 virtual void OnLayout( bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom ) override;
88 } // namespace Internal
90 inline Internal::CustomLayout& GetImplementation( Test::CustomLayout& handle )
92 DALI_ASSERT_ALWAYS( handle && "CustomLayout handle is empty" );
93 Dali::BaseObject& object = handle.GetBaseObject();
94 return static_cast<Internal::CustomLayout&>( object );
97 inline const Internal::CustomLayout& GetImplementation( const Test::CustomLayout& handle )
99 DALI_ASSERT_ALWAYS( handle && "CustomLayout handle is empty" );
100 const Dali::BaseObject& object = handle.GetBaseObject();
101 return static_cast<const Internal::CustomLayout&>( object );
106 #endif // TEST_INTERNAL_CUSTOM_LAYOUT_H