Removed OnButton virtual functions and simplified RadioButton logic
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / check-box-button-impl.cpp
index 4eb7831..9554ccb 100644 (file)
@@ -1,30 +1,37 @@
-//
-// 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) 2016 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 "check-box-button-impl.h"
 
 // EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/images/resource-image.h>
 
-#include <algorithm>
-
-// INTERNAL INCLUDES
+//INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/image-view/image-view-impl.h>
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
+#include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
 
-#include "check-box-button-default-painter-impl.h"
+#if defined(DEBUG_ENABLED)
+  extern Debug::Filter* gLogButtonFilter;
+#endif
 
 namespace Dali
 {
@@ -45,18 +52,9 @@ BaseHandle Create()
 
 TypeRegistration mType( typeid(Toolkit::CheckBoxButton), typeid(Toolkit::Button), Create );
 
-TypeAction a1(mType, Toolkit::CheckBoxButton::ACTION_CHECK_BOX_BUTTON_CLICK, &CheckBoxButton::DoAction);
 
-}
 
-namespace
-{
-  // Helper function used to cast a ButtonPainterPtr to CheckBoxButtonDefaultPainterPtr
-  CheckBoxButtonDefaultPainterPtr GetCheckBoxButtonPainter( ButtonPainterPtr painter )
-  {
-    return static_cast<CheckBoxButtonDefaultPainter*>( painter.Get() );
-  }
-} // namespace
+}
 
 Dali::Toolkit::CheckBoxButton CheckBoxButton::New()
 {
@@ -73,196 +71,21 @@ Dali::Toolkit::CheckBoxButton CheckBoxButton::New()
   return checkBoxButton;
 }
 
-void CheckBoxButton::SetChecked( bool checked )
-{
-  if( !mDimmed && ( checked != mChecked ) )
-  {
-    // Stores the state.
-    mChecked = checked;
-
-    Toolkit::CheckBoxButton handle( GetOwner() );
-
-    // Notifies the painter the checkbox has been checked.
-    GetCheckBoxButtonPainter( mPainter )->Checked( handle );
-
-    // Emit signal.
-    mClickedSignalV2.Emit( handle );
-  }
-}
-
-bool CheckBoxButton::IsChecked() const
-{
-  return mChecked;
-}
-
-void CheckBoxButton::SetBackgroundImage( Image image )
-{
-  SetBackgroundImage( ImageActor::New( image ) );
-}
-
-void CheckBoxButton::SetBackgroundImage( Actor image )
-{
-  Toolkit::CheckBoxButton handle( GetOwner() );
-  GetCheckBoxButtonPainter( mPainter )->SetBackgroundImage( handle, image );
-}
-
-Actor& CheckBoxButton::GetBackgroundImage()
-{
-  return mBackgroundImage;
-}
-
-Actor CheckBoxButton::GetBackgroundImage() const
-{
-  return mBackgroundImage;
-}
-
-void CheckBoxButton::SetCheckedImage( Image image )
-{
-  SetCheckedImage( ImageActor::New( image ) );
-}
-
-void CheckBoxButton::SetCheckedImage( Actor image )
-{
-  Toolkit::CheckBoxButton handle( GetOwner() );
-  GetCheckBoxButtonPainter( mPainter )->SetCheckedImage( handle, image );
-}
-
-Actor& CheckBoxButton::GetCheckedImage()
-{
-  return mCheckedImage;
-}
-
-Actor CheckBoxButton::GetCheckedImage() const
-{
-  return mCheckedImage;
-}
-
-void CheckBoxButton::SetDimmedBackgroundImage( Image image )
-{
-  SetDimmedBackgroundImage( ImageActor::New( image ) );
-}
-
-void CheckBoxButton::SetDimmedBackgroundImage( Actor image )
-{
-  Toolkit::CheckBoxButton handle( GetOwner() );
-  GetCheckBoxButtonPainter( mPainter )->SetDimmedBackgroundImage( handle, image );
-}
-
-Actor& CheckBoxButton::GetDimmedBackgroundImage()
-{
-  return mDimmedBackgroundImage;
-}
-
-Actor CheckBoxButton::GetDimmedBackgroundImage() const
-{
-  return mDimmedBackgroundImage;
-}
-
-void CheckBoxButton::SetDimmedCheckedImage( Image image )
-{
-  SetDimmedCheckedImage( ImageActor::New( image ) );
-}
-
-void CheckBoxButton::SetDimmedCheckedImage( Actor image )
-{
-  Toolkit::CheckBoxButton handle( GetOwner() );
-  GetCheckBoxButtonPainter( mPainter )->SetDimmedCheckedImage( handle, image );
-}
-
-Actor& CheckBoxButton::GetDimmedCheckedImage()
-{
-  return mDimmedCheckedImage;
-}
-
-Actor CheckBoxButton::GetDimmedCheckedImage() const
-{
-  return mDimmedCheckedImage;
-}
-
-Actor& CheckBoxButton::GetFadeOutBackgroundImage()
-{
-  return mFadeOutBackgroundImage;
-}
-
-Actor& CheckBoxButton::GetFadeOutCheckedImage()
-{
-  return mFadeOutCheckedImage;
-}
-
-void CheckBoxButton::OnButtonInitialize()
-{
-  mUseFadeAnimationProperty = Self().RegisterProperty( Toolkit::CheckBoxButton::USE_FADE_ANIMATION_PROPERTY_NAME, false );
-  mUseCheckAnimationProperty = Self().RegisterProperty( Toolkit::CheckBoxButton::USE_CHECK_ANIMATION_PROPERTY_NAME, true );
-}
-
-void CheckBoxButton::OnButtonUp()
-{
-  if( ButtonDown == mState )
-  {
-    // Stores the state, notifies the painter and emits a signal.
-    SetChecked( !mChecked );
-  }
-}
-
-void CheckBoxButton::OnAnimationTimeSet( float animationTime )
-{
-  GetCheckBoxButtonPainter( mPainter )->SetAnimationTime( animationTime );
-}
-
-float CheckBoxButton::OnAnimationTimeRequested() const
-{
-  return GetCheckBoxButtonPainter( mPainter )->GetAnimationTime();
-}
-
-void CheckBoxButton::OnActivated()
-{
-  // When the button is activated, it performs the click action
-  std::vector<Property::Value> attributes;
-  DoClickAction(attributes);
-}
-
-void CheckBoxButton::DoClickAction(const PropertyValueContainer& attributes)
+CheckBoxButton::CheckBoxButton()
+: Button()
 {
-  // Prevents the button signals from doing a recursive loop by sending an action
-  // and re-emitting the signals.
-  if(!mClickActionPerforming)
-  {
-    mClickActionPerforming = true;
-    SetChecked( !mChecked );
-    mClickActionPerforming = false;
-  }
+  SetTogglableButton( true );
 }
 
-bool CheckBoxButton::DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes)
+CheckBoxButton::~CheckBoxButton()
 {
-  bool ret = false;
-
-  Dali::BaseHandle handle(object);
-
-  Toolkit::CheckBoxButton button = Toolkit::CheckBoxButton::DownCast(handle);
-
-  if(Toolkit::CheckBoxButton::ACTION_CHECK_BOX_BUTTON_CLICK == actionName)
-  {
-    GetImplementation(button).DoClickAction(attributes);
-    ret = true;
-  }
-
-  return ret;
 }
 
-CheckBoxButton::CheckBoxButton()
-: Button(),
-  mChecked( false ),
-  mClickActionPerforming(false)
+void CheckBoxButton::OnInitialize()
 {
-  // Creates specific painter.
-  mPainter = new CheckBoxButtonDefaultPainter();
+  Button::OnInitialize();
 }
 
-CheckBoxButton::~CheckBoxButton()
-{
-  mPainter = NULL;
-}
 
 } // namespace Internal