+ mStageSize = stage.GetSize();
+ mButtonSize = Size( mStageSize.height * 0.1, mStageSize.height * 0.1 ); // Button size 1/10 of stage height
+
+ mContainer = Control::New();
+ mContainer.SetName( "Container" );
+ mContainer.SetParentOrigin( ParentOrigin::CENTER );
+ mLayoutSize = Vector2(mStageSize.width*0.6f, mStageSize.width*0.6f);
+ mContainer.SetSize( mLayoutSize );
+ stage.Add( mContainer );
+
+ // Resize the center layout when the corner is grabbed
+ mGrabCorner = ImageView::New( BACKGROUND_IMAGE );
+ mGrabCorner.SetName( "GrabCorner" );
+ mGrabCorner.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ mGrabCorner.SetParentOrigin( ParentOrigin::BOTTOM_RIGHT );
+ mGrabCorner.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+ mContainer.Add( mGrabCorner );
+
+ mPanGestureDetector = PanGestureDetector::New();
+ mPanGestureDetector.Attach( mGrabCorner );
+ mPanGestureDetector.DetectedSignal().Connect( this, &TextLabelExample::OnPan );
+
+ mLabel = TextLabel::New( "\xF0\x9F\x98\x89 A Quick Brown Fox Jumps Over The Lazy Dog" );
+
+ mLabel.SetName( "TextLabel" );
+ mLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mLabel.SetSize(mLayoutSize);
+ mLabel.SetProperty( TextLabel::Property::MULTI_LINE, true );
+ mLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
+ mLabel.SetBackgroundColor( Color::WHITE );
+ mContainer.Add( mLabel );
+
+ // Clicking ExpandingButton shows the Registered Style buttons, clicking again hides them.
+ Vector2 expandingButtonPosition( mButtonSize.width, mStageSize.height * STYLE_BUTTON_POSTION_RELATIVE_TO_STAGE );
+ SetUpExpandingStyleButtons( expandingButtonPosition );
+ stage.Add( mExpandingButtons );
+
+ // 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( Toolkit::Visual::Property::TYPE, Visual::BORDER );
+ border.Insert( BorderVisual::Property::COLOR, Color::WHITE );
+ border.Insert( BorderVisual::Property::SIZE, 3.f );
+ mBorder.SetProperty( Control::Property::BACKGROUND, border );
+ mContainer.Add( mBorder );
+ mBorder.SetVisible(false);
+ mGrabCorner.RaiseToTop();
+
+ mHueAngleIndex = mLabel.RegisterProperty( "hue", 0.0f );
+ Renderer bgRenderer = mLabel.GetRendererAt(0);
+ mOverrideMixColorIndex = DevelHandle::GetPropertyIndex( bgRenderer, ColorVisual::Property::MIX_COLOR );
+
+ Constraint constraint = Constraint::New<Vector3>( bgRenderer, mOverrideMixColorIndex, HSVColorConstraint(0.0f, 0.5f, 0.8f));
+ constraint.AddSource( Source( mLabel, mHueAngleIndex ) );
+ constraint.SetRemoveAction( Constraint::Discard );
+ constraint.Apply();
+
+ Animation anim = Animation::New(50.0f);
+ anim.AnimateTo(Property(mLabel, mHueAngleIndex), 6.28318f);
+ anim.SetLooping(true);
+ anim.Play();
+
+ mContainer.RaiseToTop();
+ mGrabCorner.RaiseToTop();
+
+ Property::Value labelText = mLabel.GetProperty( TextLabel::Property::TEXT );
+ std::cout << "Displaying text: \"" << labelText.Get< std::string >() << "\"" << std::endl;
+ }
+
+ // If the styling buttons should colapse (hide) then the color buttons should also hide.
+ bool OnExpandingButtonCollapsing( Demo::ExpandingButtons button )
+ {
+ mCollapseColorsAndStyles = true;
+ HideColorButtons();
+ return true;
+ }
+
+ // Get the style type from the given button
+ StyleType GetStyleTypeFromButton( Toolkit::Button button )
+ {
+ StyleType style = StyleType::TEXT_COLOR;
+
+ if( button == mStyleButtons[ StyleType::OUTLINE ] )
+ {
+ style = StyleType::OUTLINE;
+ }
+ else if( button == mStyleButtons[ StyleType::SHADOW ] )
+ {
+ style = StyleType::SHADOW;
+ }
+ else if( button == mStyleButtons[ StyleType::BACKGROUND ] )
+ {
+ style = StyleType::BACKGROUND;
+ }
+ return style;
+ }
+
+ // Style selected, show color buttons
+ bool OnStyleButtonClicked( Toolkit::Button button )
+ {
+ StyleType selectedStyle = GetStyleTypeFromButton( button );
+ if ( mStyleActivatedForColor == selectedStyle )
+ {
+ HideColorButtons();
+ }
+ else
+ {
+ ResetColorButtons( mColorButtons, NUMBER_OF_COLORS );
+ ShowColorButtons( selectedStyle);
+ }
+ return true;
+ }
+
+ // Set style to selected color
+ bool OnColorSelected( Toolkit::Button button )
+ {
+ for( unsigned int index = 0; index < NUMBER_OF_COLORS; index++)
+ {
+ if ( mColorButtons[index] == button )
+ {
+ mSelectedColor = AVAILABLE_COLORS[ index ];
+ }
+ }
+
+ switch ( mStyleActivatedForColor )
+ {
+ case TEXT_COLOR :
+ {
+ Animation animation = Animation::New( 1.f );
+ animation.AnimateTo( Property( mLabel, TextLabel::Property::TEXT_COLOR ), mSelectedColor, AlphaFunction::LINEAR );
+ mCurrentStyleColor[ TEXT_COLOR ] = mSelectedColor;
+ animation.Play();
+ break;
+ }
+ case OUTLINE :
+ {
+ Property::Map outlineMap;
+ float outlineWidth = OUTLINE_WIDTH;
+
+ if( mStyleActiveState[ OUTLINE ] )
+ {
+ outlineWidth = ( Color::WHITE == mSelectedColor ) ? 0.0f : OUTLINE_WIDTH ; // toggles outline on/off
+ }
+ mStyleActiveState[ OUTLINE ] = ( outlineWidth > 0.0f ) ? true : false;
+
+ outlineMap["color"] = mSelectedColor;
+ outlineMap["width"] = outlineWidth;
+ mCurrentStyleColor[ OUTLINE ] = mSelectedColor;
+ mLabel.SetProperty( TextLabel::Property::OUTLINE, outlineMap );
+ break;
+ }
+ case SHADOW :
+ {
+ Vector2 shadowOffset( SHADOW_OFFSET ); // Will be set to zeros if color already set
+ Property::Value value = mLabel.GetProperty( TextLabel::Property::SHADOW_COLOR );
+ Vector4 currentShadowColor;
+ value.Get( currentShadowColor );
+
+ if ( mStyleActiveState[ SHADOW ] )
+ {
+ // toggle shadow off ( zero offset ) if color is already set
+ shadowOffset = ( Color::WHITE == mSelectedColor ) ? Vector2::ZERO : Vector2( SHADOW_OFFSET );
+ }
+
+ mStyleActiveState[ SHADOW ] = ( shadowOffset == Vector2::ZERO ) ? false : true;
+ mCurrentStyleColor[ SHADOW ] = mSelectedColor;
+
+ Property::Map shadowMap;
+ shadowMap.Insert( "offset", shadowOffset );
+ shadowMap.Insert( "color", mSelectedColor );
+ mLabel.SetProperty( TextLabel::Property::SHADOW, shadowMap );
+
+ break;
+ }
+ case BACKGROUND :
+ {
+ Property::Map backgroundMap;
+ auto backgroundEnabled(true);
+
+ if( mStyleActiveState[ BACKGROUND ] )
+ {
+ backgroundEnabled = ( Color::WHITE != mSelectedColor ); // toggles background on/off
+ }
+ mStyleActiveState[ BACKGROUND ] = backgroundEnabled;
+
+ backgroundMap["color"] = mSelectedColor;
+ backgroundMap["enable"] = backgroundEnabled;
+ mCurrentStyleColor[ BACKGROUND ] = mSelectedColor;
+ mLabel.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMap );
+
+ break;
+ }
+ default :
+ break;
+ }