From 1c22cc2b91aaac24f5d39a2b7d36ba53e3386487 Mon Sep 17 00:00:00 2001 From: Anton Obzhirov Date: Thu, 14 Jun 2018 17:38:22 +0100 Subject: [PATCH] [Tizen] Update demo to use LinearLayout. Change-Id: I0ccaae96503906e221ea24ad232a68896e12c5ba --- examples/layouting/linear-example.cpp | 31 ++++++++++++------------ examples/layouting/linear-example.h | 6 ++--- examples/layouting/padding-example.cpp | 6 ++--- examples/simple-layout/simple-layout-example.cpp | 1 - 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/examples/layouting/linear-example.cpp b/examples/layouting/linear-example.cpp index a499005..9f56222 100644 --- a/examples/layouting/linear-example.cpp +++ b/examples/layouting/linear-example.cpp @@ -20,8 +20,7 @@ #include #include #include -#include -#include +#include 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 diff --git a/examples/layouting/linear-example.h b/examples/layouting/linear-example.h index a1496bb..c170e0f 100644 --- a/examples/layouting/linear-example.h +++ b/examples/layouting/linear-example.h @@ -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 diff --git a/examples/layouting/padding-example.cpp b/examples/layouting/padding-example.cpp index fc8ba41..70457dc 100644 --- a/examples/layouting/padding-example.cpp +++ b/examples/layouting/padding-example.cpp @@ -20,8 +20,8 @@ #include #include #include -#include #include +#include 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 ); diff --git a/examples/simple-layout/simple-layout-example.cpp b/examples/simple-layout/simple-layout-example.cpp index efa5351..ac24ea1 100644 --- a/examples/simple-layout/simple-layout-example.cpp +++ b/examples/simple-layout/simple-layout-example.cpp @@ -18,7 +18,6 @@ #include #include -#include #include #include "custom-layout.h" -- 2.7.4