Commit 442117389177d86f35e87a81f54596baddb13dc8
1 parent
2d811050
Update resize behaviour in TextLabel demo
Change-Id: Iebd7a2a501dc280c77e797b6545ce524879f3b59
Showing
1 changed file
with
30 additions
and
2 deletions
examples/text-label/text-label-example.cpp
| ... | ... | @@ -22,6 +22,7 @@ |
| 22 | 22 | |
| 23 | 23 | // EXTERNAL INCLUDES |
| 24 | 24 | #include <dali/devel-api/object/handle-devel.h> |
| 25 | +#include <dali/devel-api/actors/actor-devel.h> | |
| 25 | 26 | #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h> |
| 26 | 27 | #include <dali-toolkit/dali-toolkit.h> |
| 27 | 28 | #include <iostream> |
| ... | ... | @@ -114,6 +115,7 @@ public: |
| 114 | 115 | mLabel(), |
| 115 | 116 | mContainer(), |
| 116 | 117 | mGrabCorner(), |
| 118 | + mBorder(), | |
| 117 | 119 | mPanGestureDetector(), |
| 118 | 120 | mLayoutSize(), |
| 119 | 121 | mLanguageId( 0u ), |
| ... | ... | @@ -164,8 +166,7 @@ public: |
| 164 | 166 | |
| 165 | 167 | mLabel.SetName( "TextLabel" ); |
| 166 | 168 | mLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 167 | - mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | |
| 168 | - mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); | |
| 169 | + mLabel.SetSize(mLayoutSize); | |
| 169 | 170 | mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true ); |
| 170 | 171 | mLabel.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::GREEN ); |
| 171 | 172 | mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) ); |
| ... | ... | @@ -173,6 +174,22 @@ public: |
| 173 | 174 | mLabel.SetBackgroundColor( Color::WHITE ); |
| 174 | 175 | mContainer.Add( mLabel ); |
| 175 | 176 | |
| 177 | + // Add a border for the container so you can see the container is being resized while grabbing the handle. | |
| 178 | + mBorder = Control::New(); | |
| 179 | + mBorder.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | |
| 180 | + mBorder.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | |
| 181 | + mBorder.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); | |
| 182 | + | |
| 183 | + Dali::Property::Map border; | |
| 184 | + border.Insert( Visual::Property::TYPE, Visual::BORDER ); | |
| 185 | + border.Insert( BorderVisual::Property::COLOR, Color::WHITE ); | |
| 186 | + border.Insert( BorderVisual::Property::SIZE, 2.f ); | |
| 187 | + mBorder.SetProperty( Control::Property::BACKGROUND, border ); | |
| 188 | + mContainer.Add( mBorder ); | |
| 189 | + mBorder.SetVisible(false); | |
| 190 | + | |
| 191 | + DevelActor::RaiseToTop(mGrabCorner); | |
| 192 | + | |
| 176 | 193 | mHueAngleIndex = mLabel.RegisterProperty( "hue", 0.0f ); |
| 177 | 194 | Renderer bgRenderer = mLabel.GetRendererAt(0); |
| 178 | 195 | mOverrideMixColorIndex = DevelHandle::GetPropertyIndex( bgRenderer, ColorVisual::Property::MIX_COLOR ); |
| ... | ... | @@ -212,6 +229,9 @@ public: |
| 212 | 229 | { |
| 213 | 230 | mLayoutSize.y = 2.0f; |
| 214 | 231 | } |
| 232 | + | |
| 233 | + // Only show the border during the panning | |
| 234 | + mBorder.SetVisible(true); | |
| 215 | 235 | } |
| 216 | 236 | |
| 217 | 237 | mLayoutSize.x += gesture.displacement.x * 2.0f; |
| ... | ... | @@ -226,6 +246,13 @@ public: |
| 226 | 246 | |
| 227 | 247 | mContainer.SetSize( clampedSize ); |
| 228 | 248 | } |
| 249 | + | |
| 250 | + if( gesture.state == Gesture::Cancelled || gesture.state == Gesture::Finished ) | |
| 251 | + { | |
| 252 | + // Resize the text label to match the container size when panning is finished | |
| 253 | + mLabel.SetSize(mLayoutSize); | |
| 254 | + mBorder.SetVisible(false); | |
| 255 | + } | |
| 229 | 256 | } |
| 230 | 257 | |
| 231 | 258 | /** |
| ... | ... | @@ -350,6 +377,7 @@ private: |
| 350 | 377 | |
| 351 | 378 | Control mContainer; |
| 352 | 379 | Control mGrabCorner; |
| 380 | + Control mBorder; | |
| 353 | 381 | |
| 354 | 382 | PanGestureDetector mPanGestureDetector; |
| 355 | 383 | ... | ... |