Merge "Make radio buttons work with size negotiation, bug fixes." into tizen
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / buttons / button-impl.cpp
index 9c1c340..90a741a 100644 (file)
@@ -1,18 +1,19 @@
-//
-// 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
 
@@ -46,13 +47,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 )
@@ -105,6 +107,11 @@ Toolkit::Button::ClickedSignalV2& Button::ClickedSignal()
   return mClickedSignalV2;
 }
 
+Toolkit::Button::ToggledSignalV2& Button::ToggledSignal()
+{
+  return mToggledSignalV2;
+}
+
 bool Button::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
 {
   Dali::BaseHandle handle( object );
@@ -116,6 +123,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
@@ -223,13 +234,10 @@ void Button::OnTap(Actor actor, 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 )