Merge "Updated control transitions to work with visual transform" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / button-impl.cpp
index 51dd6ef..0c7005b 100644 (file)
@@ -547,13 +547,13 @@ void Button::ButtonDown()
 
 void Button::ButtonUp()
 {
+  bool emitSignalsForPressAndReleaseAction = false;
+
   if( DEPRESSED == mButtonPressedState )
   {
-    bool validButtonAction = false;
-
     if( mTogglableButton ) // Button up will change state
     {
-      validButtonAction = OnToggleReleased(); // Derived toggle buttons can override this to provide custom behaviour
+      emitSignalsForPressAndReleaseAction = OnToggleReleased(); // Derived toggle buttons can override this to provide custom behaviour
     }
     else
     {
@@ -562,16 +562,20 @@ void Button::ButtonUp()
       {
         mAutoRepeatingTimer.Reset();
       }
-      validButtonAction = true;
+      emitSignalsForPressAndReleaseAction = true;
     }
+  }
+  else if ( TOGGLE_DEPRESSED == mButtonPressedState )
+  {
+    emitSignalsForPressAndReleaseAction = true; // toggle released after being pressed, a click
+  }
 
-    if ( validButtonAction )
-    {
-      // The clicked and released signals should be emitted regardless of toggle mode.
-      Toolkit::Button handle( GetOwner() );
-      mReleasedSignal.Emit( handle );
-      mClickedSignal.Emit( handle );
-    }
+  if ( emitSignalsForPressAndReleaseAction )
+  {
+    // The clicked and released signals should be emitted regardless of toggle mode.
+    Toolkit::Button handle( GetOwner() );
+    mReleasedSignal.Emit( handle );
+    mClickedSignal.Emit( handle );
   }
 }
 
@@ -1012,10 +1016,15 @@ void Button::OnRelayout( const Vector2& size, RelayoutContainer& container )
         labelPosition.y = labelVisualPadding.height;
       }
 
+      Vector2 preSize = Vector2( static_cast< int >( remainingSpaceForText.x ), static_cast< int >( remainingSpaceForText.y ));
+
       DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout text Size(%f,%f) text Position(%f,%f) \n", remainingSpaceForText.width, remainingSpaceForText.height, labelPosition.x, labelPosition.y);
 
+      DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout text Size -- (%f,%f) text Position(%f,%f) \n", preSize.width, preSize.height, labelPosition.x, labelPosition.y);
+
+
       Property::Map textVisualTransform;
-      textVisualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, remainingSpaceForText)
+      textVisualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, preSize )
                          .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, labelPosition )
                          .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 1.0f, 1.0f, 1.0f,1.0f ) ) // Use absolute size
                          .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
@@ -1025,6 +1034,8 @@ void Button::OnRelayout( const Vector2& size, RelayoutContainer& container )
     }
   }
 
+  DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout selected (%s) \n", IsSelected()?"yes":"no" );
+
   DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout << \n");
 }