Update demo to use LinearLayout. 56/181556/5
authorAnton Obzhirov <a.obzhirov@samsung.com>
Thu, 14 Jun 2018 16:38:22 +0000 (17:38 +0100)
committerAnton Obzhirov <a.obzhirov@samsung.com>
Mon, 18 Jun 2018 11:03:01 +0000 (12:03 +0100)
Change-Id: I0ccaae96503906e221ea24ad232a68896e12c5ba

examples/layouting/linear-example.cpp
examples/layouting/linear-example.h
examples/layouting/padding-example.cpp
examples/simple-layout/simple-layout-example.cpp

index a499005..9f56222 100644 (file)
@@ -20,8 +20,7 @@
 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
-#include <dali-toolkit/devel-api/layouting/hbox-layout.h>
-#include <dali-toolkit/devel-api/layouting/vbox-layout.h>
+#include <dali-toolkit/devel-api/layouting/linear-layout.h>
 
 using namespace Dali;
 using namespace Dali::Toolkit;
@@ -69,6 +68,11 @@ void CreateChildImageView( ImageView& imageView, const char* filename, Size size
 namespace Demo
 {
 
+LinearExample::LinearExample()
+: mLTRDirection(true)
+{
+}
+
 void LinearExample::Create()
 {
   auto stage = Stage::GetCurrent();
@@ -93,10 +97,9 @@ void LinearExample::Create()
 
   // Create a linear layout
   mLinearContainer = Control::New();
-  mIsHorizontal = false;
-
-  auto layout = VboxLayout::New();
+  auto layout = LinearLayout::New();
   layout.SetAnimateLayout(true);
+  layout.SetOrientation( LinearLayout::Orientation::VERTICAL );
   DevelControl::SetLayout( mLinearContainer, layout );
 
   mLinearContainer.SetParentOrigin( ParentOrigin::CENTER );
@@ -129,7 +132,7 @@ void LinearExample::Remove()
 // Mirror items in layout
 bool LinearExample::OnDirectionClicked( Button button )
 {
-  if( mDirection )
+  if( !mLTRDirection )
   {
     mDirectionButton.SetProperty( PushButton::Property::UNSELECTED_ICON, LTR_IMAGE );
     mDirectionButton.SetProperty( PushButton::Property::SELECTED_ICON, LTR_SELECTED_IMAGE );
@@ -141,27 +144,23 @@ bool LinearExample::OnDirectionClicked( Button button )
     mDirectionButton.SetProperty( PushButton::Property::SELECTED_ICON, RTL_SELECTED_IMAGE );
     mLinearContainer.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
   }
-  mDirection = !mDirection;
+  mLTRDirection = !mLTRDirection;
   return true;
 }
 
 // Rotate layout by changing layout
 bool LinearExample::OnRotateClicked( Button button )
 {
-  mIsHorizontal = !mIsHorizontal;
-  if( mIsHorizontal )
+  auto layout = LinearLayout::DownCast( DevelControl::GetLayout( mLinearContainer ) );
+  if( layout.GetOrientation() == LinearLayout::Orientation::VERTICAL )
   {
-    auto hboxLayout = HboxLayout::New();
-    hboxLayout.SetAnimateLayout(true);
-    DevelControl::SetLayout( mLinearContainer, hboxLayout );
+    layout.SetOrientation( LinearLayout::Orientation::HORIZONTAL );
   }
   else
   {
-    auto vboxLayout = VboxLayout::New();
-    vboxLayout.SetAnimateLayout(true);
-    DevelControl::SetLayout( mLinearContainer, vboxLayout );
+    layout.SetOrientation( LinearLayout::Orientation::VERTICAL );
   }
   return true;
 }
 
-} // namespace Demo
\ No newline at end of file
+} // namespace Demo
index a1496bb..c170e0f 100644 (file)
@@ -32,11 +32,12 @@ namespace Demo
 /**
  * @file linear-example.hcpp
  * @brief Example of a Linear Layout with mirror feature and
- * tranisition from horizontal to vertical.
+ * transition from horizontal to vertical.
  */
 class LinearExample final: public ConnectionTracker, public Example
 {
 public:
+  LinearExample();
 
   // Creates a Linear Layout Example and displays it.
   virtual void Create() override;
@@ -56,8 +57,7 @@ private:
   PushButton mDirectionButton;
   PushButton mRotateButton;
   Control mLinearContainer;
-  bool mDirection = false;
-  bool mIsHorizontal = true;
+  bool mLTRDirection;
 }; // class LinearContainer
 
 } // namespace Demo
index fc8ba41..70457dc 100644 (file)
@@ -20,8 +20,8 @@
 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
-#include <dali-toolkit/devel-api/layouting/hbox-layout.h>
 #include <dali-toolkit/devel-api/layouting/absolute-layout.h>
+#include <dali-toolkit/devel-api/layouting/linear-layout.h>
 
 using namespace Dali;
 using namespace Dali::Toolkit;
@@ -70,8 +70,8 @@ void PaddingExample::Create()
   // Create a table view to show a pair of buttons above each image.
   mHorizontalBox = Control::New();
 
-  // Create HBoxLayout for this control.
-  auto hboxLayout = HboxLayout::New();
+  // Create LinearLayout for this control.
+  auto hboxLayout = LinearLayout::New();
   DevelControl::SetLayout( mHorizontalBox, hboxLayout );
   mHorizontalBox.SetName("HBox");
   mHorizontalBox.SetBackgroundColor( Color::WHITE );
index efa5351..ac24ea1 100644 (file)
@@ -18,7 +18,6 @@
 #include <dali-toolkit/dali-toolkit.h>
 
 #include <dali-toolkit/devel-api/controls/control-devel.h>
-#include <dali-toolkit/devel-api/layouting/hbox-layout.h>
 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
 
 #include "custom-layout.h"