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