DALi signals refactor to remove V2 naming
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / buttons / push-button-impl.cpp
index d007c03..d4381fb 100644 (file)
@@ -1,29 +1,30 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 // CLASS HEADER
-
 #include "push-button-impl.h"
 
 // EXTERNAL INCLUDES
-
 #include <algorithm>
+#include <dali/public-api/actors/image-actor.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/scripting/scripting.h>
 
 // INTERNAL INCLUDES
-
 #include "push-button-default-painter-impl.h"
 
 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
@@ -58,9 +59,8 @@ BaseHandle Create()
 
 TypeRegistration typeRegistration( typeid(Toolkit::PushButton), typeid(Toolkit::Button), Create );
 
-SignalConnectorType signalConnector1( typeRegistration, Toolkit::PushButton::SIGNAL_TOGGLED , &PushButton::DoConnectSignal );
-SignalConnectorType signalConnector2( typeRegistration, Toolkit::PushButton::SIGNAL_PRESSED , &PushButton::DoConnectSignal );
-SignalConnectorType signalConnector3( typeRegistration, Toolkit::PushButton::SIGNAL_RELEASED, &PushButton::DoConnectSignal );
+SignalConnectorType signalConnector1( typeRegistration, Toolkit::PushButton::SIGNAL_PRESSED , &PushButton::DoConnectSignal );
+SignalConnectorType signalConnector2( typeRegistration, Toolkit::PushButton::SIGNAL_RELEASED, &PushButton::DoConnectSignal );
 
 TypeAction action1( typeRegistration, Toolkit::PushButton::ACTION_PUSH_BUTTON_CLICK, &PushButton::DoAction );
 
@@ -208,7 +208,7 @@ void PushButton::SetToggled( bool toggle )
     GetPushButtonPainter( mPainter )->Toggled( handle );
 
     // Emit signal.
-    mToggledSignalV2.Emit( handle, mToggled );
+    mToggledSignal.Emit( handle, mToggled );
   }
 }
 
@@ -355,19 +355,14 @@ Actor& PushButton::GetFadeOutButtonImage()
   return mFadeOutButtonImage;
 }
 
-Toolkit::PushButton::ToggledSignalV2& PushButton::ToggledSignal()
-{
-  return mToggledSignalV2;
-}
-
-Toolkit::PushButton::PressedSignalV2& PushButton::PressedSignal()
+Toolkit::PushButton::PressedSignalType& PushButton::PressedSignal()
 {
-  return mPressedSignalV2;
+  return mPressedSignal;
 }
 
-Toolkit::PushButton::ReleasedSignalV2& PushButton::ReleasedSignal()
+Toolkit::PushButton::ReleasedSignalType& PushButton::ReleasedSignal()
 {
-  return mReleasedSignalV2;
+  return mReleasedSignal;
 }
 
 bool PushButton::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
@@ -566,7 +561,7 @@ void PushButton::OnButtonDown()
     }
 
     //Emit signal.
-    mPressedSignalV2.Emit( handle );
+    mPressedSignal.Emit( handle );
   }
 }
 
@@ -583,8 +578,8 @@ void PushButton::OnButtonUp()
       // Notifies the painter the button has been toggled.
       GetPushButtonPainter( mPainter )->Toggled( handle );
 
-      //Emit signal.
-      mToggledSignalV2.Emit( handle, mToggled );
+      // Emit signal.
+      mToggledSignal.Emit( handle, mToggled );
     }
     else
     {
@@ -600,8 +595,8 @@ void PushButton::OnButtonUp()
       }
 
       //Emit signal.
-      mReleasedSignalV2.Emit( handle );
-      mClickedSignalV2.Emit( handle );
+      mReleasedSignal.Emit( handle );
+      mClickedSignal.Emit( handle );
     }
   }
 }
@@ -623,7 +618,7 @@ void PushButton::OnTouchPointLeave()
       }
 
       //Emit signal.
-      mReleasedSignalV2.Emit( handle );
+      mReleasedSignal.Emit( handle );
     }
   }
 }
@@ -643,6 +638,25 @@ float PushButton::OnAnimationTimeRequested() const
   return GetPushButtonPainter( mPainter )->GetAnimationTime();
 }
 
+void PushButton::OnButtonStageDisconnection()
+{
+  if( ButtonDown == mState )
+  {
+    if( !mToggleButton )
+    {
+      Toolkit::PushButton handle( GetOwner() );
+
+      // Notifies the painter the button has been released.
+      GetPushButtonPainter( mPainter )->Released( handle );
+
+      if( mAutoRepeating )
+      {
+        mAutoRepeatingTimer.Reset();
+      }
+    }
+  }
+}
+
 PushButton::PushButton()
 : Button(),
   mAutoRepeating( false ),
@@ -688,9 +702,9 @@ bool PushButton::AutoRepeatingSlot()
     GetPushButtonPainter( mPainter )->Pressed( handle );
 
     //Emit signal.
-    consumed = mReleasedSignalV2.Emit( handle );
-    consumed |= mClickedSignalV2.Emit( handle );
-    consumed |= mPressedSignalV2.Emit( handle );
+    consumed = mReleasedSignal.Emit( handle );
+    consumed |= mClickedSignal.Emit( handle );
+    consumed |= mPressedSignal.Emit( handle );
  }
 
   return consumed;
@@ -699,13 +713,13 @@ bool PushButton::AutoRepeatingSlot()
 void PushButton::OnActivated()
 {
   // When the button is activated, it performs the click action
-  std::vector<Property::Value> attributes;
+  PropertyValueContainer attributes;
   DoClickAction(attributes);
 }
 
 Vector3 PushButton::GetNaturalSize()
 {
-  Vector3 size = ControlImpl::GetNaturalSize();
+  Vector3 size = Control::GetNaturalSize();
 
   const bool widthIsZero = EqualsZero( size.width );
   const bool heightIsZero = EqualsZero( size.height );
@@ -780,7 +794,7 @@ void PushButton::DoClickAction(const PropertyValueContainer& attributes)
   }
 }
 
-bool PushButton::DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes)
+bool PushButton::DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes)
 {
   bool ret = false;