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,6 +22,7 @@ | ||
| 22 | 22 | ||
| 23 | // EXTERNAL INCLUDES | 23 | // EXTERNAL INCLUDES |
| 24 | #include <dali/devel-api/object/handle-devel.h> | 24 | #include <dali/devel-api/object/handle-devel.h> |
| 25 | +#include <dali/devel-api/actors/actor-devel.h> | ||
| 25 | #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h> | 26 | #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h> |
| 26 | #include <dali-toolkit/dali-toolkit.h> | 27 | #include <dali-toolkit/dali-toolkit.h> |
| 27 | #include <iostream> | 28 | #include <iostream> |
| @@ -114,6 +115,7 @@ public: | @@ -114,6 +115,7 @@ public: | ||
| 114 | mLabel(), | 115 | mLabel(), |
| 115 | mContainer(), | 116 | mContainer(), |
| 116 | mGrabCorner(), | 117 | mGrabCorner(), |
| 118 | + mBorder(), | ||
| 117 | mPanGestureDetector(), | 119 | mPanGestureDetector(), |
| 118 | mLayoutSize(), | 120 | mLayoutSize(), |
| 119 | mLanguageId( 0u ), | 121 | mLanguageId( 0u ), |
| @@ -164,8 +166,7 @@ public: | @@ -164,8 +166,7 @@ public: | ||
| 164 | 166 | ||
| 165 | mLabel.SetName( "TextLabel" ); | 167 | mLabel.SetName( "TextLabel" ); |
| 166 | mLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | 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 | mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true ); | 170 | mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true ); |
| 170 | mLabel.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::GREEN ); | 171 | mLabel.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::GREEN ); |
| 171 | mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) ); | 172 | mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) ); |
| @@ -173,6 +174,22 @@ public: | @@ -173,6 +174,22 @@ public: | ||
| 173 | mLabel.SetBackgroundColor( Color::WHITE ); | 174 | mLabel.SetBackgroundColor( Color::WHITE ); |
| 174 | mContainer.Add( mLabel ); | 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 | mHueAngleIndex = mLabel.RegisterProperty( "hue", 0.0f ); | 193 | mHueAngleIndex = mLabel.RegisterProperty( "hue", 0.0f ); |
| 177 | Renderer bgRenderer = mLabel.GetRendererAt(0); | 194 | Renderer bgRenderer = mLabel.GetRendererAt(0); |
| 178 | mOverrideMixColorIndex = DevelHandle::GetPropertyIndex( bgRenderer, ColorVisual::Property::MIX_COLOR ); | 195 | mOverrideMixColorIndex = DevelHandle::GetPropertyIndex( bgRenderer, ColorVisual::Property::MIX_COLOR ); |
| @@ -212,6 +229,9 @@ public: | @@ -212,6 +229,9 @@ public: | ||
| 212 | { | 229 | { |
| 213 | mLayoutSize.y = 2.0f; | 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 | mLayoutSize.x += gesture.displacement.x * 2.0f; | 237 | mLayoutSize.x += gesture.displacement.x * 2.0f; |
| @@ -226,6 +246,13 @@ public: | @@ -226,6 +246,13 @@ public: | ||
| 226 | 246 | ||
| 227 | mContainer.SetSize( clampedSize ); | 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,6 +377,7 @@ private: | ||
| 350 | 377 | ||
| 351 | Control mContainer; | 378 | Control mContainer; |
| 352 | Control mGrabCorner; | 379 | Control mGrabCorner; |
| 380 | + Control mBorder; | ||
| 353 | 381 | ||
| 354 | PanGestureDetector mPanGestureDetector; | 382 | PanGestureDetector mPanGestureDetector; |
| 355 | 383 |