Commit 7cc14ca9e296a20174f2971f0a10f5689f5ccf2e

Authored by György Straub
2 parents abfe3367 f75cc82b

[dali_1.3.36] Merge branch 'devel/master'

Change-Id: I304ec82bd26456c8594387ab1bf704bb658b1e65
examples/layouting/absolute-example.cpp
@@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
17 17
18 #include <string> 18 #include <string>
19 #include "absolute-example.h" 19 #include "absolute-example.h"
  20 +#include "layout-utilities.h"
20 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h> 21 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
21 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h> 22 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
22 #include <dali-toolkit/devel-api/controls/control-devel.h> 23 #include <dali-toolkit/devel-api/controls/control-devel.h>
@@ -28,6 +29,7 @@ using namespace Dali::Toolkit; @@ -28,6 +29,7 @@ using namespace Dali::Toolkit;
28 29
29 namespace 30 namespace
30 { 31 {
  32 +const char* const TITLE = "Absolute Example";
31 33
32 struct ImageDetails 34 struct ImageDetails
33 { 35 {
@@ -67,7 +69,8 @@ namespace Demo @@ -67,7 +69,8 @@ namespace Demo
67 { 69 {
68 70
69 AbsoluteExample::AbsoluteExample() 71 AbsoluteExample::AbsoluteExample()
70 -: mRootLayoutControl(), 72 +: Example( TITLE ),
  73 + mRootLayoutControl(),
71 mAbsoluteLayoutContainer(), 74 mAbsoluteLayoutContainer(),
72 mLayoutSizeToggleStatus( true ), 75 mLayoutSizeToggleStatus( true ),
73 mToggleButton() 76 mToggleButton()
@@ -77,16 +80,9 @@ AbsoluteExample::AbsoluteExample() @@ -77,16 +80,9 @@ AbsoluteExample::AbsoluteExample()
77 80
78 void AbsoluteExample::Create() 81 void AbsoluteExample::Create()
79 { 82 {
80 - // Create a root layout, ideally Dali would have a default layout in the root layer.  
81 - // Without this root layer the mAbsoluteLayout (or any other layout) will not  
82 - // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.  
83 - // It uses the default stage size and ideally should have a layout added to it.  
84 auto stage = Stage::GetCurrent(); 83 auto stage = Stage::GetCurrent();
85 - mRootLayoutControl = Control::New();  
86 - auto rootLayout = AbsoluteLayout::New();  
87 - DevelControl::SetLayout( mRootLayoutControl, rootLayout );  
88 - mRootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );  
89 - mRootLayoutControl.SetParentOrigin( ParentOrigin::CENTER ); 84 + // This layout will be the size of the stage but allows subsequent layouts to be any size.
  85 + mRootLayoutControl = LayoutUtilities::CreateRootContainer();
90 stage.Add( mRootLayoutControl ); 86 stage.Add( mRootLayoutControl );
91 87
92 // Create an Absolute Layout to show ImageViews at explictly provided positions. 88 // Create an Absolute Layout to show ImageViews at explictly provided positions.
examples/layouting/absolute-example.h
@@ -34,11 +34,12 @@ namespace Demo @@ -34,11 +34,12 @@ namespace Demo
34 * @brief Example of a Linear Layout with padding applied, enables updating of padding values for 34 * @brief Example of a Linear Layout with padding applied, enables updating of padding values for
35 * one of the children. 35 * one of the children.
36 */ 36 */
37 -class AbsoluteExample: public ConnectionTracker, public Example 37 +class AbsoluteExample final: public ConnectionTracker, public Example
38 { 38 {
39 public: 39 public:
40 static const unsigned int NUMBER_OF_IMAGE_VIEWS = 4; 40 static const unsigned int NUMBER_OF_IMAGE_VIEWS = 4;
41 41
  42 + // Constructor
42 AbsoluteExample(); 43 AbsoluteExample();
43 44
44 // Creates a Absolute Layout Example and displays it. 45 // Creates a Absolute Layout Example and displays it.
@@ -49,7 +50,6 @@ public: @@ -49,7 +50,6 @@ public:
49 50
50 private: 51 private:
51 52
52 -  
53 // Callback when change size button is pressed 53 // Callback when change size button is pressed
54 bool ChangeSizeClicked( Toolkit::Button button ); 54 bool ChangeSizeClicked( Toolkit::Button button );
55 55
examples/layouting/example.h
@@ -18,6 +18,9 @@ @@ -18,6 +18,9 @@
18 * 18 *
19 */ 19 */
20 20
  21 +// EXTERNAL INCLUDES
  22 +#include <string>
  23 +
21 namespace Demo 24 namespace Demo
22 { 25 {
23 26
@@ -35,6 +38,28 @@ public: @@ -35,6 +38,28 @@ public:
35 38
36 /// Virtual destructor 39 /// Virtual destructor
37 virtual ~Example() = default; 40 virtual ~Example() = default;
  41 +
  42 + /**
  43 + * Gets the title set for this example
  44 + * @return title
  45 + */
  46 + const std::string& GetExampleTitle() const
  47 + {
  48 + return mTitle;
  49 + }
  50 +
  51 +protected:
  52 + /**
  53 + * Constructor for Example
  54 + * @param[in] title Title to be used for the example
  55 + */
  56 + Example( const std::string& title )
  57 + : mTitle( title )
  58 + {
  59 + }
  60 +
  61 +private:
  62 + const std::string mTitle;
38 }; 63 };
39 64
40 } // namespace Demo 65 } // namespace Demo
examples/layouting/flex-example.cpp
@@ -26,6 +26,7 @@ using namespace Dali::Toolkit; @@ -26,6 +26,7 @@ using namespace Dali::Toolkit;
26 26
27 namespace 27 namespace
28 { 28 {
  29 +const char* const TITLE = "Flex Example";
29 30
30 // Button file names 31 // Button file names
31 const char* LTR_IMAGE( DEMO_IMAGE_DIR "icon-play.png" ); 32 const char* LTR_IMAGE( DEMO_IMAGE_DIR "icon-play.png" );
@@ -81,7 +82,8 @@ namespace Demo @@ -81,7 +82,8 @@ namespace Demo
81 { 82 {
82 83
83 FlexExample::FlexExample() 84 FlexExample::FlexExample()
84 -: mLTRDirection(true) 85 +: Example( TITLE ),
  86 + mLTRDirection(true)
85 { 87 {
86 88
87 } 89 }
examples/layouting/flex-example.h
@@ -37,6 +37,8 @@ namespace Demo @@ -37,6 +37,8 @@ namespace Demo
37 class FlexExample final: public ConnectionTracker, public Example 37 class FlexExample final: public ConnectionTracker, public Example
38 { 38 {
39 public: 39 public:
  40 +
  41 + // Constructor
40 FlexExample(); 42 FlexExample();
41 43
42 // Creates a Flex Layout Example and displays it. 44 // Creates a Flex Layout Example and displays it.
examples/layouting/grid-example.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2018 Samsung Electronics Co., Ltd.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + *
  16 + */
  17 +
  18 +#include <string>
  19 +#include "grid-example.h"
  20 +#include "layout-utilities.h"
  21 +#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
  22 +#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
  23 +#include <dali-toolkit/devel-api/controls/control-devel.h>
  24 +#include <dali-toolkit/devel-api/layouting/absolute-layout.h>
  25 +#include <dali-toolkit/devel-api/layouting/grid.h>
  26 +
  27 +using namespace Dali;
  28 +using namespace Dali::Toolkit;
  29 +
  30 +namespace
  31 +{
  32 +const char* const TITLE = "Grid Example";
  33 +
  34 +// Helper function to create ImageViews with given filename and size.
  35 +void CreateChildImageView( ImageView& imageView, const char* filename, Size size )
  36 +{
  37 + imageView = ImageView::New();
  38 + Property::Map imagePropertyMap;
  39 + imagePropertyMap[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::IMAGE;
  40 + imagePropertyMap[ Toolkit::ImageVisual::Property::URL ] = filename;
  41 + imagePropertyMap[ ImageVisual::Property::DESIRED_WIDTH ] = size.width;
  42 + imagePropertyMap[ ImageVisual::Property::DESIRED_HEIGHT ] = size.height;
  43 + imageView.SetProperty(Toolkit::ImageView::Property::IMAGE , imagePropertyMap );
  44 + imageView.SetName("ImageView");
  45 + imageView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  46 + imageView.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS );
  47 +}
  48 +
  49 +enum CurrentExample
  50 +{
  51 + GRID_EXACT_WIDTH = 0,
  52 + ITEMS_WITH_MARGINS,
  53 + GRID_MATCH_PARENT,
  54 + GRID_WRAP_CONTENT,
  55 + ADD_ITEMS,
  56 + CHANGE_TO_3_COLUMNS
  57 +};
  58 +
  59 +}
  60 +
  61 +namespace Demo
  62 +{
  63 +
  64 +GridExample::GridExample()
  65 +: Example( TITLE )
  66 +{
  67 +}
  68 +
  69 +void GridExample::Create()
  70 +{
  71 + // The Init signal is received once (only) during the Application lifetime
  72 + mToggleStatus = 0;
  73 + auto stage = Stage::GetCurrent();
  74 +
  75 + // This layout will be the size of the stage but allow the Grid layout to be any size.
  76 + mRootLayoutControl = LayoutUtilities::CreateRootContainer();
  77 + stage.Add( mRootLayoutControl );
  78 +
  79 + // Create a table view to show a pair of buttons above each image.
  80 + mGridContainer = Control::New();
  81 +
  82 + // Create LinearLayout for this control.
  83 + auto gridLayout = Grid::New();
  84 + gridLayout.SetAnimateLayout(true);
  85 + gridLayout.SetNumberOfColumns( 2 );
  86 + DevelControl::SetLayout( mGridContainer, gridLayout );
  87 + mGridContainer.SetName("GridContainer");
  88 + mGridContainer.SetBackgroundColor( Color::WHITE );
  89 + mGridContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
  90 + mGridContainer.SetProperty( LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
  91 + mGridContainer.SetProperty( Toolkit::Control::Property::PADDING, Extents( 20,20,20,20 ) );
  92 + mGridContainer.SetParentOrigin( ParentOrigin::CENTER );
  93 +
  94 + mRootLayoutControl.Add( mGridContainer );
  95 +
  96 + for( unsigned int x = 0; x < INITIAL_NUMBER_OF_IMAGE_VIEWS; x++ )
  97 + {
  98 + ImageView imageView;
  99 + CreateChildImageView( imageView, DEMO_IMAGE_DIR "gallery-small-23.jpg" , Size(100.0f, 100.0f) );
  100 + mImageViews.push_back( imageView );
  101 + mGridContainer.Add( mImageViews[x] );
  102 + }
  103 +
  104 + // Button toggles the size of the layout
  105 + mToggleButton = PushButton::New();
  106 + mToggleButton.SetProperty( Toolkit::Button::Property::LABEL, "Set Width 300" );
  107 + mToggleButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
  108 + mToggleButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
  109 + mToggleButton.ClickedSignal().Connect( this, &Demo::GridExample::ToggleButtonClicked );
  110 + mToggleButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
  111 + mToggleButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
  112 +
  113 + stage.Add( mToggleButton );
  114 +}
  115 +
  116 +void GridExample::Remove()
  117 +{
  118 + mImageViews.clear();
  119 + UnparentAndReset( mGridContainer );
  120 + UnparentAndReset( mRootLayoutControl );
  121 + UnparentAndReset( mToggleButton );
  122 +}
  123 +
  124 +void GridExample::ChangeTo3Columns()
  125 +{
  126 + Grid gridLayout = Grid::DownCast( DevelControl::GetLayout(mGridContainer) );
  127 + if ( gridLayout )
  128 + {
  129 + gridLayout.SetNumberOfColumns( 3 );
  130 + }
  131 +}
  132 +
  133 +void GridExample::AddItemsInteractively()
  134 +{
  135 + if( mImageViews.size() < MAX_NUMBER_OF_IMAGE_VIEWS )
  136 + {
  137 + ImageView imageView;
  138 + CreateChildImageView( imageView, DEMO_IMAGE_DIR "gallery-small-23.jpg" , Size(100.0f, 100.0f) );
  139 + mImageViews.push_back( imageView );
  140 + mGridContainer.Add( imageView);
  141 +
  142 + // Add item button shows how many items left to add.
  143 + unsigned int numberOfAdditonalImageViews = MAX_NUMBER_OF_IMAGE_VIEWS-INITIAL_NUMBER_OF_IMAGE_VIEWS;
  144 + unsigned int remainingImageViews = numberOfAdditonalImageViews - ( ( mImageViews.size() - INITIAL_NUMBER_OF_IMAGE_VIEWS) );
  145 + std::string buttonLabel( "Add item["+ std::to_string( numberOfAdditonalImageViews-remainingImageViews ) +"/"+
  146 + std::to_string( numberOfAdditonalImageViews)+"]" );
  147 + mToggleButton.SetProperty( Toolkit::Button::Property::LABEL, buttonLabel );
  148 + }
  149 +}
  150 +
  151 +void GridExample::AddMarginToItems()
  152 +{
  153 + for( unsigned int x = 0; x < INITIAL_NUMBER_OF_IMAGE_VIEWS; x++ )
  154 + {
  155 + mImageViews[x].SetProperty(Toolkit::Control::Property::MARGIN, Extents( 20,20,20,10));
  156 + }
  157 +}
  158 +
  159 +void GridExample::RemoveMarginsFromItems()
  160 +{
  161 + for( unsigned int x = 0; x < INITIAL_NUMBER_OF_IMAGE_VIEWS; x++ )
  162 + {
  163 + mImageViews[x].SetProperty(Toolkit::Control::Property::MARGIN, Extents());
  164 + }
  165 +}
  166 +
  167 +void GridExample::MatchParentOnWidth()
  168 +{
  169 + mGridContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION,ChildLayoutData::MATCH_PARENT );
  170 +}
  171 +
  172 +void GridExample::WrapContentOnWidth()
  173 +{
  174 + mGridContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, ChildLayoutData::WRAP_CONTENT );
  175 +}
  176 +
  177 +void GridExample::SetExactWidth()
  178 +{
  179 + mGridContainer.SetProperty( LayoutItem::ChildProperty::WIDTH_SPECIFICATION, 300 );
  180 +}
  181 +
  182 +bool GridExample::ToggleButtonClicked( Toolkit::Button button )
  183 +{
  184 + switch( mToggleStatus )
  185 + {
  186 + case GRID_EXACT_WIDTH :
  187 + {
  188 + SetExactWidth();
  189 + mToggleButton.SetProperty( Toolkit::Button::Property::LABEL, "Set Child Margin" );
  190 + mToggleStatus = ITEMS_WITH_MARGINS;
  191 + break;
  192 + }
  193 + case ITEMS_WITH_MARGINS :
  194 + {
  195 + AddMarginToItems();
  196 + mToggleStatus = GRID_MATCH_PARENT;
  197 + mToggleButton.SetProperty( Toolkit::Button::Property::LABEL, "Set width MATCH_PARENT" );
  198 + break;
  199 + }
  200 + case GRID_MATCH_PARENT :
  201 + {
  202 + RemoveMarginsFromItems();
  203 + MatchParentOnWidth();
  204 + mToggleButton.SetProperty( Toolkit::Button::Property::LABEL, "Set width WRAP_CONTENT" );
  205 + mToggleStatus = GRID_WRAP_CONTENT;
  206 + break;
  207 + }
  208 + case GRID_WRAP_CONTENT :
  209 + {
  210 + WrapContentOnWidth();
  211 + mToggleButton.SetProperty( Toolkit::Button::Property::LABEL, "Add item" );
  212 + mToggleStatus = ADD_ITEMS;
  213 + break;
  214 + }
  215 + case ADD_ITEMS :
  216 + {
  217 + if( mGridContainer.GetChildCount() < MAX_NUMBER_OF_IMAGE_VIEWS )
  218 + {
  219 + AddItemsInteractively();
  220 + }
  221 +
  222 + if( mGridContainer.GetChildCount() == MAX_NUMBER_OF_IMAGE_VIEWS )
  223 + {
  224 + // Remove button when no more items to add
  225 + mToggleStatus= CHANGE_TO_3_COLUMNS;
  226 + mToggleButton.SetProperty( Toolkit::Button::Property::LABEL, "Change Columns" );
  227 + }
  228 + break;
  229 + }
  230 + case CHANGE_TO_3_COLUMNS :
  231 + {
  232 + ChangeTo3Columns();
  233 + mToggleStatus = GRID_EXACT_WIDTH;
  234 + UnparentAndReset( mToggleButton );
  235 + break;
  236 + }
  237 + default :
  238 + {
  239 + mToggleStatus = GRID_EXACT_WIDTH;
  240 + }
  241 + }
  242 + return true;
  243 +}
  244 +
  245 +} // namespace Demo
examples/layouting/grid-example.h 0 → 100644
  1 +#ifndef DALI_DEMO_GRID_EXAMPLE_H
  2 +#define DALI_DEMO_GRID_EXAMPLE_H
  3 +
  4 +/*
  5 + * Copyright (c) 2018 Samsung Electronics Co., Ltd.
  6 + *
  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
  10 + *
  11 + * http://www.apache.org/licenses/LICENSE-2.0
  12 + *
  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.
  18 + *
  19 + */
  20 +
  21 +#include <string>
  22 +#include <dali/dali.h>
  23 +#include <dali-toolkit/dali-toolkit.h>
  24 +
  25 +#include "example.h"
  26 +
  27 +using namespace Dali;
  28 +using namespace Dali::Toolkit;
  29 +
  30 +namespace Demo
  31 +{
  32 +
  33 +/**
  34 + * @file grid-example.hcpp
  35 + * @brief Example of a Grid Layout
  36 + */
  37 +class GridExample final: public ConnectionTracker, public Example
  38 +{
  39 +public:
  40 +
  41 + // Constructor
  42 + GridExample();
  43 +
  44 + static const unsigned int MAX_NUMBER_OF_IMAGE_VIEWS = 9;
  45 + static const unsigned int INITIAL_NUMBER_OF_IMAGE_VIEWS = 5;
  46 +
  47 + // Create a Grid layout of ImagesViews
  48 + void Create() override;
  49 +
  50 + // Remove created Layout
  51 + void Remove() override;
  52 +
  53 +private:
  54 +
  55 + // Callback for button pressed
  56 + bool ToggleButtonClicked( Toolkit::Button button );
  57 +
  58 + // Actions to perform in this example
  59 + void ChangeTo3Columns();
  60 + void AddItemsInteractively();
  61 + void AddMarginToItems();
  62 + void RemoveMarginsFromItems();
  63 + void MatchParentOnWidth();
  64 + void WrapContentOnWidth();
  65 + void SetExactWidth();
  66 +
  67 +private:
  68 +
  69 + Toolkit::Control mRootLayoutControl;
  70 + Toolkit::Control mGridContainer;
  71 + std::vector<Toolkit::ImageView> mImageViews;
  72 + Toolkit::PushButton mToggleButton;
  73 + unsigned int mToggleStatus;
  74 +};
  75 +
  76 +} // namespace Demo
  77 +
  78 +#endif // DALI_DEMO_GRID_EXAMPLE_H
examples/layouting/layout-utilities.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2018 Samsung Electronics Co., Ltd.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + *
  16 + */
  17 +
  18 +#include <dali-toolkit/devel-api/controls/control-devel.h>
  19 +#include <dali-toolkit/devel-api/layouting/absolute-layout.h>
  20 +
  21 +using namespace Dali;
  22 +using namespace Dali::Toolkit;
  23 +
  24 +namespace LayoutUtilities
  25 +{
  26 +Toolkit::Control CreateRootContainer()
  27 +{
  28 + Control rootLayoutControl = Control::New();
  29 + rootLayoutControl.SetName( "AbsoluteLayout");
  30 + auto rootLayout = AbsoluteLayout::New();
  31 + DevelControl::SetLayout( rootLayoutControl, rootLayout );
  32 + rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );
  33 + rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER );
  34 +
  35 + return rootLayoutControl;
  36 +}
  37 +
  38 +} // namespace LayoutUtilities
0 \ No newline at end of file 39 \ No newline at end of file
examples/layouting/layout-utilities.h 0 → 100644
  1 +/*
  2 + * Copyright (c) 2018 Samsung Electronics Co., Ltd.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + *
  16 + */
  17 +
  18 +#ifndef DALI_DEMO_LAYOUT_UTILITIES_H
  19 +#define DALI_DEMO_LAYOUT_UTILITIES_H
  20 +
  21 +#include <dali-toolkit/public-api/controls/control.h>
  22 +
  23 +namespace LayoutUtilities
  24 +{
  25 +/**
  26 + * @brief
  27 + * Create a root layout, ideally Dali would have a default layout in the root layer.
  28 + * Without this root layer the mAbsoluteLayout (or any other layout) will not
  29 + * honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.
  30 + * It uses the default stage size and ideally should have a layout added to it.
  31 + * @return resulting root layout
  32 + */
  33 +Dali::Toolkit::Control CreateRootContainer();
  34 +} // namespace LayoutUtilities
  35 +
  36 +#endif // DALI_DEMO_LAYOUT_UTILITIES_H
0 \ No newline at end of file 37 \ No newline at end of file
examples/layouting/layouting-examples.cpp
@@ -27,6 +27,7 @@ @@ -27,6 +27,7 @@
27 #include "linear-example.h" 27 #include "linear-example.h"
28 #include "padding-example.h" 28 #include "padding-example.h"
29 #include "flex-example.h" 29 #include "flex-example.h"
  30 +#include "grid-example.h"
30 #include "example.h" 31 #include "example.h"
31 #include "absolute-example.h" 32 #include "absolute-example.h"
32 33
@@ -39,18 +40,18 @@ namespace @@ -39,18 +40,18 @@ namespace
39 const char* BACKGROUND_IMAGE( DEMO_IMAGE_DIR "lake_front.jpg" ); 40 const char* BACKGROUND_IMAGE( DEMO_IMAGE_DIR "lake_front.jpg" );
40 const char* TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" ); 41 const char* TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" );
41 42
42 -const char* APPLICATION_TITLE( "Layout Tester" );  
43 -  
44 typedef std::unique_ptr< Demo::Example > ExamplePointer; 43 typedef std::unique_ptr< Demo::Example > ExamplePointer;
  44 +
45 typedef std::vector< ExamplePointer > ExampleContainer; 45 typedef std::vector< ExamplePointer > ExampleContainer;
46 46
47 /// All layouting examples to be shown should be added to this method 47 /// All layouting examples to be shown should be added to this method
48 void CreateExamples( ExampleContainer& container ) 48 void CreateExamples( ExampleContainer& container )
49 { 49 {
50 - container.push_back( ExamplePointer( new Demo::LinearExample ) );  
51 - container.push_back( ExamplePointer( new Demo::PaddingExample ) );  
52 - container.push_back( ExamplePointer( new Demo::AbsoluteExample ) );  
53 - container.push_back( ExamplePointer( new Demo::FlexExample ) ); 50 + container.push_back( ExamplePointer(new Demo::LinearExample) );
  51 + container.push_back( ExamplePointer(new Demo::PaddingExample) );
  52 + container.push_back( ExamplePointer(new Demo::AbsoluteExample) );
  53 + container.push_back( ExamplePointer(new Demo::FlexExample) ) ;
  54 + container.push_back( ExamplePointer(new Demo::GridExample) ) ;
54 } 55 }
55 56
56 } // anonymous namespace 57 } // anonymous namespace
@@ -86,12 +87,12 @@ private: @@ -86,12 +87,12 @@ private:
86 87
87 stage.Add( toolbar ); 88 stage.Add( toolbar );
88 89
89 - auto title = TextLabel::New( APPLICATION_TITLE );  
90 - title.SetParentOrigin( ParentOrigin::CENTER );  
91 - title.SetAnchorPoint( AnchorPoint::CENTER );  
92 - title.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );  
93 - title.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::LEFT );  
94 - toolbar.Add( title ); 90 + mToolbarTitle = TextLabel::New( "");
  91 + mToolbarTitle.SetParentOrigin( ParentOrigin::CENTER );
  92 + mToolbarTitle.SetAnchorPoint( AnchorPoint::CENTER );
  93 + mToolbarTitle.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
  94 + mToolbarTitle.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::LEFT );
  95 + toolbar.Add( mToolbarTitle );
95 96
96 mNextLayout = PushButton::New(); 97 mNextLayout = PushButton::New();
97 mNextLayout.SetProperty( Toolkit::Button::Property::LABEL, "change layout"); 98 mNextLayout.SetProperty( Toolkit::Button::Property::LABEL, "change layout");
@@ -105,6 +106,7 @@ private: @@ -105,6 +106,7 @@ private:
105 if( ! mLayoutingExamples.empty() ) 106 if( ! mLayoutingExamples.empty() )
106 { 107 {
107 mLayoutingExamples[ mLayoutIndex ]->Create(); 108 mLayoutingExamples[ mLayoutIndex ]->Create();
  109 + mToolbarTitle.SetProperty(Toolkit::TextLabel::Property::TEXT, mLayoutingExamples[ mLayoutIndex ]->GetExampleTitle() );
108 } 110 }
109 } 111 }
110 112
@@ -115,6 +117,7 @@ private: @@ -115,6 +117,7 @@ private:
115 mLayoutingExamples[ mLayoutIndex ]->Remove(); 117 mLayoutingExamples[ mLayoutIndex ]->Remove();
116 mLayoutIndex = ( mLayoutIndex + 1 ) % mLayoutingExamples.size(); 118 mLayoutIndex = ( mLayoutIndex + 1 ) % mLayoutingExamples.size();
117 mLayoutingExamples[ mLayoutIndex ]->Create(); 119 mLayoutingExamples[ mLayoutIndex ]->Create();
  120 + mToolbarTitle.SetProperty(Toolkit::TextLabel::Property::TEXT, mLayoutingExamples[ mLayoutIndex ]->Example::GetExampleTitle() );
118 } 121 }
119 return true; 122 return true;
120 } 123 }
@@ -139,6 +142,7 @@ private: @@ -139,6 +142,7 @@ private:
139 ExampleContainer mLayoutingExamples; 142 ExampleContainer mLayoutingExamples;
140 PushButton mNextLayout; 143 PushButton mNextLayout;
141 unsigned int mLayoutIndex; 144 unsigned int mLayoutIndex;
  145 + TextLabel mToolbarTitle;
142 }; 146 };
143 147
144 int DALI_EXPORT_API main( int argc, char **argv ) 148 int DALI_EXPORT_API main( int argc, char **argv )
examples/layouting/linear-example.cpp
@@ -27,6 +27,7 @@ using namespace Dali::Toolkit; @@ -27,6 +27,7 @@ using namespace Dali::Toolkit;
27 27
28 namespace 28 namespace
29 { 29 {
  30 +const char* const TITLE = "Linear Example";
30 31
31 // Button file names 32 // Button file names
32 const char* LTR_IMAGE( DEMO_IMAGE_DIR "icon-play.png" ); 33 const char* LTR_IMAGE( DEMO_IMAGE_DIR "icon-play.png" );
@@ -69,7 +70,8 @@ namespace Demo @@ -69,7 +70,8 @@ namespace Demo
69 { 70 {
70 71
71 LinearExample::LinearExample() 72 LinearExample::LinearExample()
72 -: mLTRDirection(true) 73 +: Example( TITLE ),
  74 + mLTRDirection(true)
73 { 75 {
74 } 76 }
75 77
examples/layouting/padding-example.cpp
@@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
17 17
18 #include <string> 18 #include <string>
19 #include "padding-example.h" 19 #include "padding-example.h"
  20 +#include "layout-utilities.h"
20 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h> 21 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
21 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h> 22 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
22 #include <dali-toolkit/devel-api/controls/control-devel.h> 23 #include <dali-toolkit/devel-api/controls/control-devel.h>
@@ -29,6 +30,7 @@ using namespace Dali::Toolkit; @@ -29,6 +30,7 @@ using namespace Dali::Toolkit;
29 30
30 namespace 31 namespace
31 { 32 {
  33 +const char* const TITLE = "Padding Example";
32 34
33 // Helper function to create ImageViews with given filename and size. 35 // Helper function to create ImageViews with given filename and size.
34 void CreateChildImageView( ImageView& imageView, const char* filename, Size size ) 36 void CreateChildImageView( ImageView& imageView, const char* filename, Size size )
@@ -50,21 +52,17 @@ void CreateChildImageView( ImageView&amp; imageView, const char* filename, Size size @@ -50,21 +52,17 @@ void CreateChildImageView( ImageView&amp; imageView, const char* filename, Size size
50 namespace Demo 52 namespace Demo
51 { 53 {
52 54
  55 +PaddingExample::PaddingExample()
  56 +: Example( TITLE )
  57 +{}
  58 +
53 void PaddingExample::Create() 59 void PaddingExample::Create()
54 { 60 {
55 // The Init signal is received once (only) during the Application lifetime 61 // The Init signal is received once (only) during the Application lifetime
56 62
57 - // Create a root layout, ideally Dali would have a default layout in the root layer.  
58 - // Without this root layer the mAbsoluteLayout (or any other layout) will not  
59 - // honour WIDTH_SPECIFICATION or HEIGHT_SPECIFICATION settings.  
60 - // It uses the default stage size and ideally should have a layout added to it.  
61 auto stage = Stage::GetCurrent(); 63 auto stage = Stage::GetCurrent();
62 - auto rootLayoutControl = Control::New();  
63 - rootLayoutControl.SetName( "AbsoluteLayout");  
64 - auto rootLayout = AbsoluteLayout::New();  
65 - DevelControl::SetLayout( rootLayoutControl, rootLayout );  
66 - rootLayoutControl.SetAnchorPoint( AnchorPoint::CENTER );  
67 - rootLayoutControl.SetParentOrigin( ParentOrigin::CENTER ); 64 +
  65 + Control rootLayoutControl = LayoutUtilities::CreateRootContainer();
68 stage.Add( rootLayoutControl ); 66 stage.Add( rootLayoutControl );
69 67
70 // Create a table view to show a pair of buttons above each image. 68 // Create a table view to show a pair of buttons above each image.
examples/layouting/padding-example.h
@@ -41,6 +41,9 @@ public: @@ -41,6 +41,9 @@ public:
41 41
42 static const unsigned int NUMBER_OF_IMAGE_VIEWS = 3; 42 static const unsigned int NUMBER_OF_IMAGE_VIEWS = 3;
43 43
  44 + // Constructor
  45 + PaddingExample();
  46 +
44 // Create a Linear layout of ImagesViews, one with a Margin, One with padding. 47 // Create a Linear layout of ImagesViews, one with a Margin, One with padding.
45 void Create() override; 48 void Create() override;
46 49
packaging/com.samsung.dali-demo.spec
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 Name: com.samsung.dali-demo 3 Name: com.samsung.dali-demo
4 Summary: The OpenGLES Canvas Core Demo 4 Summary: The OpenGLES Canvas Core Demo
5 -Version: 1.3.35 5 +Version: 1.3.36
6 Release: 1 6 Release: 1
7 Group: System/Libraries 7 Group: System/Libraries
8 License: Apache-2.0 8 License: Apache-2.0