diff --git a/examples/text-label/text-label-example.cpp b/examples/text-label/text-label-example.cpp index d7c7315..5952d59 100644 --- a/examples/text-label/text-label-example.cpp +++ b/examples/text-label/text-label-example.cpp @@ -22,6 +22,7 @@ // EXTERNAL INCLUDES #include +#include #include #include #include @@ -43,6 +44,7 @@ const unsigned int KEY_ONE = 11; const unsigned int KEY_A = 38; const unsigned int KEY_F = 41; const unsigned int KEY_H = 43; +const unsigned int KEY_U = 30; const unsigned int KEY_V = 55; const unsigned int KEY_M = 58; const unsigned int KEY_L = 46; @@ -113,6 +115,7 @@ public: mLabel(), mContainer(), mGrabCorner(), + mBorder(), mPanGestureDetector(), mLayoutSize(), mLanguageId( 0u ), @@ -160,17 +163,33 @@ public: mPanGestureDetector.DetectedSignal().Connect( this, &TextLabelExample::OnPan ); mLabel = TextLabel::New( "A Quick Brown Fox Jumps Over The Lazy Dog" ); + mLabel.SetName( "TextLabel" ); mLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); - mLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); + mLabel.SetSize(mLayoutSize); mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true ); - mLabel.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::BLUE ); + mLabel.SetProperty( DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE, Color::GREEN ); mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) ); mLabel.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLACK ); mLabel.SetBackgroundColor( Color::WHITE ); mContainer.Add( mLabel ); + // Add a border for the container so you can see the container is being resized while grabbing the handle. + mBorder = Control::New(); + mBorder.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mBorder.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + mBorder.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); + + Dali::Property::Map border; + border.Insert( Visual::Property::TYPE, Visual::BORDER ); + border.Insert( BorderVisual::Property::COLOR, Color::WHITE ); + border.Insert( BorderVisual::Property::SIZE, 2.f ); + mBorder.SetProperty( Control::Property::BACKGROUND, border ); + mContainer.Add( mBorder ); + mBorder.SetVisible(false); + + DevelActor::RaiseToTop(mGrabCorner); + mHueAngleIndex = mLabel.RegisterProperty( "hue", 0.0f ); Renderer bgRenderer = mLabel.GetRendererAt(0); mOverrideMixColorIndex = DevelHandle::GetPropertyIndex( bgRenderer, ColorVisual::Property::MIX_COLOR ); @@ -187,7 +206,7 @@ public: // Animate the text color 3 times from source color to RED Animation animation = Animation::New( 2.f ); - animation.AnimateTo( Property( mLabel, DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE ), Color::RED, AlphaFunction::SIN ); + animation.AnimateTo( Property( mLabel, DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE ), Color::YELLOW, AlphaFunction::SIN ); animation.SetLoopCount( 3 ); animation.Play(); @@ -210,6 +229,9 @@ public: { mLayoutSize.y = 2.0f; } + + // Only show the border during the panning + mBorder.SetVisible(true); } mLayoutSize.x += gesture.displacement.x * 2.0f; @@ -224,6 +246,13 @@ public: mContainer.SetSize( clampedSize ); } + + if( gesture.state == Gesture::Cancelled || gesture.state == Gesture::Finished ) + { + // Resize the text label to match the container size when panning is finished + mLabel.SetSize(mLayoutSize); + mBorder.SetVisible(false); + } } /** @@ -252,7 +281,7 @@ public: { Animation animation = Animation::New( 2.f ); animation.AnimateTo( Property( mLabel, DevelTextLabel::Property::TEXT_COLOR_ANIMATABLE ), Color::RED, AlphaFunction::SIN ); - animation.SetLooping( true ); + animation.SetLoopCount( 3 ); animation.Play(); break; } @@ -318,6 +347,12 @@ public: } break; } + case KEY_U: // Markup + { + mLabel.SetProperty( TextLabel::Property::ENABLE_MARKUP, true ); + mLabel.SetProperty( TextLabel::Property::TEXT, "Hello world demo" ); + break; + } case KEY_PLUS: // Increase shadow offset { mLabel.SetProperty( TextLabel::Property::SHADOW_OFFSET, mLabel.GetProperty( TextLabel::Property::SHADOW_OFFSET ) + Vector2( 1.0f, 1.0f ) ); @@ -342,6 +377,7 @@ private: Control mContainer; Control mGrabCorner; + Control mBorder; PanGestureDetector mPanGestureDetector; diff --git a/packaging/com.samsung.dali-demo.spec b/packaging/com.samsung.dali-demo.spec index 2f7e85e..608d0a7 100755 --- a/packaging/com.samsung.dali-demo.spec +++ b/packaging/com.samsung.dali-demo.spec @@ -2,7 +2,7 @@ Name: com.samsung.dali-demo Summary: The OpenGLES Canvas Core Demo -Version: 1.2.52 +Version: 1.2.53 Release: 1 Group: System/Libraries License: Apache-2.0