Commit 5b1bbe7168563d2068308d2f8b22ce7b1dfdf36b

Authored by Anton Obzhirov
1 parent df6b2d6f

Update demo to use LinearLayout.

Change-Id: I0ccaae96503906e221ea24ad232a68896e12c5ba
examples/layouting/linear-example.cpp
@@ -20,8 +20,7 @@ @@ -20,8 +20,7 @@
20 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h> 20 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
21 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h> 21 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
22 #include <dali-toolkit/devel-api/controls/control-devel.h> 22 #include <dali-toolkit/devel-api/controls/control-devel.h>
23 -#include <dali-toolkit/devel-api/layouting/hbox-layout.h>  
24 -#include <dali-toolkit/devel-api/layouting/vbox-layout.h> 23 +#include <dali-toolkit/devel-api/layouting/linear-layout.h>
25 24
26 using namespace Dali; 25 using namespace Dali;
27 using namespace Dali::Toolkit; 26 using namespace Dali::Toolkit;
@@ -69,6 +68,11 @@ void CreateChildImageView( ImageView&amp; imageView, const char* filename, Size size @@ -69,6 +68,11 @@ void CreateChildImageView( ImageView&amp; imageView, const char* filename, Size size
69 namespace Demo 68 namespace Demo
70 { 69 {
71 70
  71 +LinearExample::LinearExample()
  72 +: mLTRDirection(true)
  73 +{
  74 +}
  75 +
72 void LinearExample::Create() 76 void LinearExample::Create()
73 { 77 {
74 auto stage = Stage::GetCurrent(); 78 auto stage = Stage::GetCurrent();
@@ -93,10 +97,9 @@ void LinearExample::Create() @@ -93,10 +97,9 @@ void LinearExample::Create()
93 97
94 // Create a linear layout 98 // Create a linear layout
95 mLinearContainer = Control::New(); 99 mLinearContainer = Control::New();
96 - mIsHorizontal = false;  
97 -  
98 - auto layout = VboxLayout::New(); 100 + auto layout = LinearLayout::New();
99 layout.SetAnimateLayout(true); 101 layout.SetAnimateLayout(true);
  102 + layout.SetOrientation( LinearLayout::Orientation::VERTICAL );
100 DevelControl::SetLayout( mLinearContainer, layout ); 103 DevelControl::SetLayout( mLinearContainer, layout );
101 104
102 mLinearContainer.SetParentOrigin( ParentOrigin::CENTER ); 105 mLinearContainer.SetParentOrigin( ParentOrigin::CENTER );
@@ -129,7 +132,7 @@ void LinearExample::Remove() @@ -129,7 +132,7 @@ void LinearExample::Remove()
129 // Mirror items in layout 132 // Mirror items in layout
130 bool LinearExample::OnDirectionClicked( Button button ) 133 bool LinearExample::OnDirectionClicked( Button button )
131 { 134 {
132 - if( mDirection ) 135 + if( !mLTRDirection )
133 { 136 {
134 mDirectionButton.SetProperty( PushButton::Property::UNSELECTED_ICON, LTR_IMAGE ); 137 mDirectionButton.SetProperty( PushButton::Property::UNSELECTED_ICON, LTR_IMAGE );
135 mDirectionButton.SetProperty( PushButton::Property::SELECTED_ICON, LTR_SELECTED_IMAGE ); 138 mDirectionButton.SetProperty( PushButton::Property::SELECTED_ICON, LTR_SELECTED_IMAGE );
@@ -141,27 +144,23 @@ bool LinearExample::OnDirectionClicked( Button button ) @@ -141,27 +144,23 @@ bool LinearExample::OnDirectionClicked( Button button )
141 mDirectionButton.SetProperty( PushButton::Property::SELECTED_ICON, RTL_SELECTED_IMAGE ); 144 mDirectionButton.SetProperty( PushButton::Property::SELECTED_ICON, RTL_SELECTED_IMAGE );
142 mLinearContainer.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT ); 145 mLinearContainer.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
143 } 146 }
144 - mDirection = !mDirection; 147 + mLTRDirection = !mLTRDirection;
145 return true; 148 return true;
146 } 149 }
147 150
148 // Rotate layout by changing layout 151 // Rotate layout by changing layout
149 bool LinearExample::OnRotateClicked( Button button ) 152 bool LinearExample::OnRotateClicked( Button button )
150 { 153 {
151 - mIsHorizontal = !mIsHorizontal;  
152 - if( mIsHorizontal ) 154 + auto layout = LinearLayout::DownCast( DevelControl::GetLayout( mLinearContainer ) );
  155 + if( layout.GetOrientation() == LinearLayout::Orientation::VERTICAL )
153 { 156 {
154 - auto hboxLayout = HboxLayout::New();  
155 - hboxLayout.SetAnimateLayout(true);  
156 - DevelControl::SetLayout( mLinearContainer, hboxLayout ); 157 + layout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
157 } 158 }
158 else 159 else
159 { 160 {
160 - auto vboxLayout = VboxLayout::New();  
161 - vboxLayout.SetAnimateLayout(true);  
162 - DevelControl::SetLayout( mLinearContainer, vboxLayout ); 161 + layout.SetOrientation( LinearLayout::Orientation::VERTICAL );
163 } 162 }
164 return true; 163 return true;
165 } 164 }
166 165
167 -} // namespace Demo  
168 \ No newline at end of file 166 \ No newline at end of file
  167 +} // namespace Demo
examples/layouting/linear-example.h
@@ -32,11 +32,12 @@ namespace Demo @@ -32,11 +32,12 @@ namespace Demo
32 /** 32 /**
33 * @file linear-example.hcpp 33 * @file linear-example.hcpp
34 * @brief Example of a Linear Layout with mirror feature and 34 * @brief Example of a Linear Layout with mirror feature and
35 - * tranisition from horizontal to vertical. 35 + * transition from horizontal to vertical.
36 */ 36 */
37 class LinearExample final: public ConnectionTracker, public Example 37 class LinearExample final: public ConnectionTracker, public Example
38 { 38 {
39 public: 39 public:
  40 + LinearExample();
40 41
41 // Creates a Linear Layout Example and displays it. 42 // Creates a Linear Layout Example and displays it.
42 virtual void Create() override; 43 virtual void Create() override;
@@ -56,8 +57,7 @@ private: @@ -56,8 +57,7 @@ private:
56 PushButton mDirectionButton; 57 PushButton mDirectionButton;
57 PushButton mRotateButton; 58 PushButton mRotateButton;
58 Control mLinearContainer; 59 Control mLinearContainer;
59 - bool mDirection = false;  
60 - bool mIsHorizontal = true; 60 + bool mLTRDirection;
61 }; // class LinearContainer 61 }; // class LinearContainer
62 62
63 } // namespace Demo 63 } // namespace Demo
examples/layouting/padding-example.cpp
@@ -20,8 +20,8 @@ @@ -20,8 +20,8 @@
20 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h> 20 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
21 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h> 21 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
22 #include <dali-toolkit/devel-api/controls/control-devel.h> 22 #include <dali-toolkit/devel-api/controls/control-devel.h>
23 -#include <dali-toolkit/devel-api/layouting/hbox-layout.h>  
24 #include <dali-toolkit/devel-api/layouting/absolute-layout.h> 23 #include <dali-toolkit/devel-api/layouting/absolute-layout.h>
  24 +#include <dali-toolkit/devel-api/layouting/linear-layout.h>
25 25
26 using namespace Dali; 26 using namespace Dali;
27 using namespace Dali::Toolkit; 27 using namespace Dali::Toolkit;
@@ -70,8 +70,8 @@ void PaddingExample::Create() @@ -70,8 +70,8 @@ void PaddingExample::Create()
70 // Create a table view to show a pair of buttons above each image. 70 // Create a table view to show a pair of buttons above each image.
71 mHorizontalBox = Control::New(); 71 mHorizontalBox = Control::New();
72 72
73 - // Create HBoxLayout for this control.  
74 - auto hboxLayout = HboxLayout::New(); 73 + // Create LinearLayout for this control.
  74 + auto hboxLayout = LinearLayout::New();
75 DevelControl::SetLayout( mHorizontalBox, hboxLayout ); 75 DevelControl::SetLayout( mHorizontalBox, hboxLayout );
76 mHorizontalBox.SetName("HBox"); 76 mHorizontalBox.SetName("HBox");
77 mHorizontalBox.SetBackgroundColor( Color::WHITE ); 77 mHorizontalBox.SetBackgroundColor( Color::WHITE );
examples/simple-layout/simple-layout-example.cpp
@@ -18,7 +18,6 @@ @@ -18,7 +18,6 @@
18 #include <dali-toolkit/dali-toolkit.h> 18 #include <dali-toolkit/dali-toolkit.h>
19 19
20 #include <dali-toolkit/devel-api/controls/control-devel.h> 20 #include <dali-toolkit/devel-api/controls/control-devel.h>
21 -#include <dali-toolkit/devel-api/layouting/hbox-layout.h>  
22 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h> 21 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
23 22
24 #include "custom-layout.h" 23 #include "custom-layout.h"