DALi signals refactor to remove V2 naming
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / buttons / button-impl.cpp
index 9c1c340..8300ad9 100644 (file)
@@ -1,23 +1,27 @@
-//
-// 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 "button-impl.h"
 
+// EXTERNAL INCLUDES
+#include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/object/type-registry.h>
+
 namespace
 {
 const char* const PROPERTY_DIMMED = "dimmed";
@@ -46,13 +50,14 @@ BaseHandle Create()
 TypeRegistration typeRegistration( typeid(Toolkit::Button), typeid(Toolkit::Control), Create );
 
 SignalConnectorType signalConnector1( typeRegistration, Toolkit::Button::SIGNAL_CLICKED, &Button::DoConnectSignal );
+SignalConnectorType signalConnector2( typeRegistration, Toolkit::Button::SIGNAL_TOGGLED, &Button::DoConnectSignal );
 
 PropertyRegistration property1( typeRegistration, "dimmed", Toolkit::Button::PROPERTY_DIMMED, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
 
 } // unnamed namespace
 
 Button::Button()
-: ControlImpl( true ),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
   mState( ButtonUp ),
   mDimmed( false ),
   mPainter( NULL )
@@ -100,9 +105,14 @@ float Button::OnAnimationTimeRequested() const
   return 0.f;
 }
 
-Toolkit::Button::ClickedSignalV2& Button::ClickedSignal()
+Toolkit::Button::ClickedSignalType& Button::ClickedSignal()
+{
+  return mClickedSignal;
+}
+
+Toolkit::Button::ToggledSignalType& Button::ToggledSignal()
 {
-  return mClickedSignalV2;
+  return mToggledSignal;
 }
 
 bool Button::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
@@ -116,6 +126,10 @@ bool Button::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tr
   {
     button.ClickedSignal().Connect( tracker, functor );
   }
+  else if( Dali::Toolkit::Button::SIGNAL_TOGGLED == signalName )
+  {
+    button.ToggledSignal().Connect( tracker, functor );
+  }
   else
   {
     // signalName does not match any signal
@@ -218,18 +232,15 @@ void Button::OnControlSizeSet(const Vector3& targetSize)
   }
 }
 
-void Button::OnTap(Actor actor, TapGesture tap)
+void Button::OnTap(Actor actor, const TapGesture& tap)
 {
   // Do nothing.
 }
 
-void Button::OnStageDisconnection()
+void Button::OnControlStageDisconnection()
 {
-  if( ButtonUp != mState )
-  {
-    OnTouchPointLeave(); // Notification for derived classes.
-    mState = ButtonUp;
-  }
+  OnButtonStageDisconnection(); // Notification for derived classes.
+  mState = ButtonUp;
 }
 
 void Button::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )