Initial removal of Text features
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / buttons / push-button-impl.cpp
index d007c03..ee89ab9 100644 (file)
@@ -1,32 +1,32 @@
-//
-// 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>
 #include <dali-toolkit/internal/controls/relayout-helper.h>
 
 namespace Dali
@@ -58,9 +58,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 );
 
@@ -324,9 +323,7 @@ Actor PushButton::GetDimmedImage() const
 
 void PushButton::SetLabelText( const std::string& text )
 {
-  Toolkit::TextView textView ( Toolkit::TextView::New( text ) );
-  textView.SetWidthExceedPolicy( Toolkit::TextView::ShrinkToFit ); // Make sure our text always fits inside the button
-  SetLabelText( textView );
+  // TODO
 }
 
 void PushButton::SetLabelText( Actor text )
@@ -355,11 +352,6 @@ Actor& PushButton::GetFadeOutButtonImage()
   return mFadeOutButtonImage;
 }
 
-Toolkit::PushButton::ToggledSignalV2& PushButton::ToggledSignal()
-{
-  return mToggledSignalV2;
-}
-
 Toolkit::PushButton::PressedSignalV2& PushButton::PressedSignal()
 {
   return mPressedSignalV2;
@@ -583,7 +575,7 @@ void PushButton::OnButtonUp()
       // Notifies the painter the button has been toggled.
       GetPushButtonPainter( mPainter )->Toggled( handle );
 
-      //Emit signal.
+      // Emit signal.
       mToggledSignalV2.Emit( handle, mToggled );
     }
     else
@@ -643,6 +635,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 ),
@@ -699,13 +710,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 );
@@ -744,23 +755,6 @@ Vector3 PushButton::GetNaturalSize()
         size.height = std::max( size.height, imageSize.height );
       }
     }
-
-    // If label, test against it's size
-    Toolkit::TextView textView = Toolkit::TextView::DownCast( mLabel );
-    if( textView )
-    {
-      Vector3 textViewSize = textView.GetNaturalSize();
-
-      if( widthIsZero )
-      {
-        size.width = std::max( size.width, textViewSize.width + TEXT_PADDING * 2.0f );
-      }
-
-      if( heightIsZero )
-      {
-        size.height = std::max( size.height, textViewSize.height + TEXT_PADDING * 2.0f );
-      }
-    }
   }
 
   return size;
@@ -780,7 +774,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;