Commit ea8d5e7931fcbcf33c4dc03de26f8c169402b217

Authored by Victor Cebollada
2 parents db0f431e 87d45c11

[dali_1.2.53] Merge branch 'devel/master'

Change-Id: I537bf589dad3e8df8f86a478ac7c348bd2fc8a29
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>
... ... @@ -43,6 +44,7 @@ const unsigned int KEY_ONE = 11;
43 44 const unsigned int KEY_A = 38;
44 45 const unsigned int KEY_F = 41;
45 46 const unsigned int KEY_H = 43;
  47 +const unsigned int KEY_U = 30;
46 48 const unsigned int KEY_V = 55;
47 49 const unsigned int KEY_M = 58;
48 50 const unsigned int KEY_L = 46;
... ... @@ -113,6 +115,7 @@ public:
113 115 mLabel(),
114 116 mContainer(),
115 117 mGrabCorner(),
  118 + mBorder(),
116 119 mPanGestureDetector(),
117 120 mLayoutSize(),
118 121 mLanguageId( 0u ),
... ... @@ -160,17 +163,33 @@ public:
160 163 mPanGestureDetector.DetectedSignal().Connect( this, &TextLabelExample::OnPan );
161 164  
162 165 mLabel = TextLabel::New( "A Quick Brown Fox Jumps Over The Lazy Dog" );
  166 +
163 167 mLabel.SetName( "TextLabel" );
164 168 mLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT );
165   - mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
166   - mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
  169 + mLabel.SetSize(mLayoutSize);
167 170 mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true );
168   - mLabel.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::BLUE );
  171 + mLabel.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::GREEN );
169 172 mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
170 173 mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK );
171 174 mLabel.SetBackgroundColor( Color::WHITE );
172 175 mContainer.Add( mLabel );
173 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 +
174 193 mHueAngleIndex = mLabel.RegisterProperty( "hue", 0.0f );
175 194 Renderer bgRenderer = mLabel.GetRendererAt(0);
176 195 mOverrideMixColorIndex = DevelHandle::GetPropertyIndex( bgRenderer, ColorVisual::Property::MIX_COLOR );
... ... @@ -187,7 +206,7 @@ public:
187 206  
188 207 // Animate the text color 3 times from source color to RED
189 208 Animation animation = Animation::New( 2.f );
190   - animation.AnimateTo( Property( mLabel, DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE ), Color::RED, AlphaFunction::SIN );
  209 + animation.AnimateTo( Property( mLabel, DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE ), Color::YELLOW, AlphaFunction::SIN );
191 210 animation.SetLoopCount( 3 );
192 211 animation.Play();
193 212  
... ... @@ -210,6 +229,9 @@ public:
210 229 {
211 230 mLayoutSize.y = 2.0f;
212 231 }
  232 +
  233 + // Only show the border during the panning
  234 + mBorder.SetVisible(true);
213 235 }
214 236  
215 237 mLayoutSize.x += gesture.displacement.x * 2.0f;
... ... @@ -224,6 +246,13 @@ public:
224 246  
225 247 mContainer.SetSize( clampedSize );
226 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 + }
227 256 }
228 257  
229 258 /**
... ... @@ -252,7 +281,7 @@ public:
252 281 {
253 282 Animation animation = Animation::New( 2.f );
254 283 animation.AnimateTo( Property( mLabel, DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE ), Color::RED, AlphaFunction::SIN );
255   - animation.SetLooping( true );
  284 + animation.SetLoopCount( 3 );
256 285 animation.Play();
257 286 break;
258 287 }
... ... @@ -318,6 +347,12 @@ public:
318 347 }
319 348 break;
320 349 }
  350 + case KEY_U: // Markup
  351 + {
  352 + mLabel.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
  353 + mLabel.SetProperty( TextLabel::Property::TEXT, "<font family='DejaVuSerif' size='18'>H<color value='blue'>ello</color> <font weight='bold'>world</font> demo</font>" );
  354 + break;
  355 + }
321 356 case KEY_PLUS: // Increase shadow offset
322 357 {
323 358 mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ) + Vector2( 1.0f, 1.0f ) );
... ... @@ -342,6 +377,7 @@ private:
342 377  
343 378 Control mContainer;
344 379 Control mGrabCorner;
  380 + Control mBorder;
345 381  
346 382 PanGestureDetector mPanGestureDetector;
347 383  
... ...
packaging/com.samsung.dali-demo.spec
... ... @@ -2,7 +2,7 @@
2 2  
3 3 Name: com.samsung.dali-demo
4 4 Summary: The OpenGLES Canvas Core Demo
5   -Version: 1.2.52
  5 +Version: 1.2.53
6 6 Release: 1
7 7 Group: System/Libraries
8 8 License: Apache-2.0
... ...