-//
-// 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/object/type-registry.h>
+#include <dali/public-api/object/type-registry-helper.h>
+#include <dali/public-api/images/resource-image.h>
+#include <dali/devel-api/scripting/scripting.h>
+#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
+#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
-#include "push-button-default-painter-impl.h"
-
-#include <dali-toolkit/public-api/controls/text-view/text-view.h>
+#if defined(DEBUG_ENABLED)
+ extern Debug::Filter* gLogButtonFilter;
+#endif
namespace Dali
{
namespace Toolkit
{
-const Property::Index PushButton::PROPERTY_AUTO_REPEATING = Internal::Button::BUTTON_PROPERTY_END_INDEX + 1;
-const Property::Index PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY = Internal::Button::BUTTON_PROPERTY_END_INDEX + 2;
-const Property::Index PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY = Internal::Button::BUTTON_PROPERTY_END_INDEX + 3;
-const Property::Index PushButton::PROPERTY_TOGGLABLE = Internal::Button::BUTTON_PROPERTY_END_INDEX + 4;
-const Property::Index PushButton::PROPERTY_TOGGLE = Internal::Button::BUTTON_PROPERTY_END_INDEX + 5;
-const Property::Index PushButton::PROPERTY_BUTTON_IMAGE = Internal::Button::BUTTON_PROPERTY_END_INDEX + 6;
-const Property::Index PushButton::PROPERTY_PRESSED_IMAGE = Internal::Button::BUTTON_PROPERTY_END_INDEX + 8;
-const Property::Index PushButton::PROPERTY_DIMMED_IMAGE = Internal::Button::BUTTON_PROPERTY_END_INDEX + 9;
-const Property::Index PushButton::PROPERTY_LABEL_TEXT = Internal::Button::BUTTON_PROPERTY_END_INDEX + 11;
-
namespace Internal
{
return Toolkit::PushButton::New();
}
-TypeRegistration typeRegistration( typeid(Toolkit::PushButton), typeid(Toolkit::Button), Create );
+// Properties
-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 );
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::PushButton, Toolkit::Button, Create )
-TypeAction action1( typeRegistration, Toolkit::PushButton::ACTION_PUSH_BUTTON_CLICK, &PushButton::DoAction );
+DALI_PROPERTY_REGISTRATION( Toolkit, PushButton, "unselectedIcon", STRING, UNSELECTED_ICON )
+DALI_PROPERTY_REGISTRATION( Toolkit, PushButton, "selectedIcon", STRING, SELECTED_ICON )
+DALI_PROPERTY_REGISTRATION( Toolkit, PushButton, "iconAlignment", STRING, ICON_ALIGNMENT )
+DALI_PROPERTY_REGISTRATION( Toolkit, PushButton, "labelPadding", STRING, LABEL_PADDING )
+DALI_PROPERTY_REGISTRATION( Toolkit, PushButton, "iconPadding", STRING, ICON_PADDING )
-PropertyRegistration property1( typeRegistration, "auto-repeating", Toolkit::PushButton::PROPERTY_AUTO_REPEATING, Property::BOOLEAN, &PushButton::SetProperty, &PushButton::GetProperty );
-PropertyRegistration property2( typeRegistration, "initial-auto-repeating-delay", Toolkit::PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY, Property::FLOAT, &PushButton::SetProperty, &PushButton::GetProperty );
-PropertyRegistration property3( typeRegistration, "next-auto-repeating-delay", Toolkit::PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY, Property::FLOAT, &PushButton::SetProperty, &PushButton::GetProperty );
-PropertyRegistration property4( typeRegistration, "togglable", Toolkit::PushButton::PROPERTY_TOGGLABLE, Property::BOOLEAN, &PushButton::SetProperty, &PushButton::GetProperty );
-PropertyRegistration property5( typeRegistration, "toggle", Toolkit::PushButton::PROPERTY_TOGGLE, Property::BOOLEAN, &PushButton::SetProperty, &PushButton::GetProperty );
-PropertyRegistration property6( typeRegistration, "button-image", Toolkit::PushButton::PROPERTY_BUTTON_IMAGE, Property::STRING, &PushButton::SetProperty, &PushButton::GetProperty );
-PropertyRegistration property7( typeRegistration, "pressed-image", Toolkit::PushButton::PROPERTY_PRESSED_IMAGE, Property::STRING, &PushButton::SetProperty, &PushButton::GetProperty );
-PropertyRegistration property8( typeRegistration, "dimmed-image", Toolkit::PushButton::PROPERTY_DIMMED_IMAGE, Property::STRING, &PushButton::SetProperty, &PushButton::GetProperty );
-PropertyRegistration property9( typeRegistration, "label-text", Toolkit::PushButton::PROPERTY_LABEL_TEXT, Property::STRING, &PushButton::SetProperty, &PushButton::GetProperty );
+DALI_TYPE_REGISTRATION_END()
+
+/*
+ * Table to define Text-to-enum conversions for IconAlignment.
+ */
+const Dali::Scripting::StringEnum IconAlignmentTable[] = {
+ { "LEFT", Toolkit::Internal::PushButton::LEFT },
+ { "RIGHT", Toolkit::Internal::PushButton::RIGHT },
+ { "TOP", Toolkit::Internal::PushButton::TOP },
+ { "BOTTOM", Toolkit::Internal::PushButton::BOTTOM },
+}; const unsigned int IconAlignmentTableCount = sizeof( IconAlignmentTable ) / sizeof( IconAlignmentTable[0] );
} // unnamed namespace
namespace
{
-const unsigned int INITIAL_AUTOREPEATING_DELAY( 0.15f );
-const unsigned int NEXT_AUTOREPEATING_DELAY( 0.05f );
-
-// Helper function used to cast a ButtonPainter to PushButtonDefaultPainter
-PushButtonDefaultPainterPtr GetPushButtonPainter( Dali::Toolkit::Internal::ButtonPainterPtr painter )
-{
- return static_cast<PushButtonDefaultPainter*>( painter.Get() );
-}
-
-/**
- * Helper function to checks if the specified actor is an ImageActor and if it has an Image with a path.
- *
- * @param[in] actor Actor handle to check.
- * @param[out] path The image path will be applied to this parameter, if available.
- * If not available then this will be an empty string.
- */
-void GetImageActorFilename( Actor& actor, std::string& path )
-{
- path = ""; // Just return an empty string if not using ImageActor with an image
-
- if ( actor )
- {
- ImageActor imageActor = ImageActor::DownCast( actor );
- if ( imageActor )
- {
- Image image = imageActor.GetImage();
- if ( image )
- {
- path = image.GetFilename();
- }
- }
- }
-}
-
} // unnamed namespace
Dali::Toolkit::PushButton PushButton::New()
return pushButton;
}
-void PushButton::SetAutoRepeating( bool autoRepeating )
-{
- mAutoRepeating = autoRepeating;
-
- // An autorepeating button can't be a toggle button.
- if( autoRepeating )
- {
- mToggleButton = false;
- if( mToggled )
- {
- // Emit a signal is not wanted, only change the appearance.
- Toolkit::PushButton handle( GetOwner() );
- GetPushButtonPainter( mPainter )->Toggled( handle );
- mToggled = false;
- }
- }
-
- // Notifies the painter.
- GetPushButtonPainter( mPainter )->SetAutoRepeating( mAutoRepeating );
-}
-
-bool PushButton::IsAutoRepeating() const
-{
- return mAutoRepeating;
-}
-
-void PushButton::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
+PushButton::PushButton()
+: Button(),
+ mIconAlignment( RIGHT )
{
- DALI_ASSERT_ALWAYS( initialAutoRepeatingDelay > 0.f );
- mInitialAutoRepeatingDelay = initialAutoRepeatingDelay;
}
-float PushButton::GetInitialAutoRepeatingDelay() const
+PushButton::~PushButton()
{
- return mInitialAutoRepeatingDelay;
}
-void PushButton::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
+void PushButton::OnInitialize()
{
- DALI_ASSERT_ALWAYS( nextAutoRepeatingDelay > 0.f );
- mNextAutoRepeatingDelay = nextAutoRepeatingDelay;
-}
+ Button::OnInitialize();
-float PushButton::GetNextAutoRepeatingDelay() const
-{
- return mNextAutoRepeatingDelay;
+ // Push button requires the Leave event.
+ Actor self = Self();
+ self.SetLeaveRequired( true );
}
-void PushButton::SetToggleButton( bool toggle )
+void PushButton::SetIconAlignment( const PushButton::IconAlignment iconAlignment )
{
- mToggleButton = toggle;
-
- // A toggle button can't be an autorepeating button.
- if( toggle )
+ mIconAlignment = iconAlignment;
+ Button::Align labelAlignment;
+ switch ( iconAlignment )
{
- mAutoRepeating = false;
-
- // Notifies the painter.
- GetPushButtonPainter( mPainter )->SetAutoRepeating( mAutoRepeating );
- }
-}
-
-bool PushButton::IsToggleButton() const
-{
- return mToggleButton;
-}
-
-void PushButton::SetToggled( bool toggle )
-{
- if( !mDimmed && mToggleButton && ( toggle != mToggled ) )
+ case RIGHT:
{
- mToggled = toggle;
-
- Toolkit::PushButton handle( GetOwner() );
-
- // Notifies the painter the button has been toggled.
- GetPushButtonPainter( mPainter )->Toggled( handle );
-
- // Emit signal.
- mToggledSignalV2.Emit( handle, mToggled );
+ labelAlignment = Button::BEGIN;
+ break;
}
-}
-
-bool PushButton::IsToggled() const
-{
- return mToggleButton && mToggled;
-}
-
-void PushButton::SetButtonImage( Image image )
-{
- SetButtonImage( ImageActor::New( image ) );
-}
-
-void PushButton::SetButtonImage( Actor image )
-{
- Toolkit::PushButton handle( GetOwner() );
- GetPushButtonPainter( mPainter )->SetButtonImage( handle, image );
-}
-
-Actor& PushButton::GetButtonImage()
-{
- return mButtonImage;
-}
-
-Actor PushButton::GetButtonImage() const
-{
- return mButtonImage;
-}
-
-void PushButton::SetBackgroundImage( Image image )
-{
- SetBackgroundImage( ImageActor::New( image ) );
-}
-
-void PushButton::SetBackgroundImage( Actor image )
-{
- Toolkit::PushButton handle( GetOwner() );
- GetPushButtonPainter( mPainter )->SetBackgroundImage( handle, image );
-}
-
-Actor& PushButton::GetBackgroundImage()
-{
- return mBackgroundImage;
-}
-
-Actor PushButton::GetBackgroundImage() const
-{
- return mBackgroundImage;
-}
-
-void PushButton::SetPressedImage( Image image )
-{
- SetPressedImage( ImageActor::New( image ) );
-}
-
-void PushButton::SetPressedImage( Actor image )
-{
- Toolkit::PushButton handle( GetOwner() );
- GetPushButtonPainter( mPainter )->SetPressedImage( handle, image );
-}
-
-Actor& PushButton::GetPressedImage()
-{
- return mPressedImage;
-}
-
-Actor PushButton::GetPressedImage() const
-{
- return mPressedImage;
-}
-
-void PushButton::SetDimmedBackgroundImage( Image image )
-{
- SetDimmedBackgroundImage( ImageActor::New( image ) );
-}
-
-void PushButton::SetDimmedBackgroundImage( Actor image )
-{
- Toolkit::PushButton handle( GetOwner() );
- GetPushButtonPainter( mPainter )->SetDimmedBackgroundImage( handle, image );
-}
-
-Actor& PushButton::GetDimmedBackgroundImage()
-{
- return mDimmedBackgroundImage;
-}
-
-Actor PushButton::GetDimmedBackgroundImage() const
-{
- return mDimmedBackgroundImage;
-}
-
-void PushButton::SetDimmedImage( Image image )
-{
- SetDimmedImage( ImageActor::New( image ) );
-}
-
-void PushButton::SetDimmedImage( Actor image )
-{
- Toolkit::PushButton handle( GetOwner() );
- GetPushButtonPainter( mPainter )->SetDimmedImage( handle, image );
-}
-
-Actor& PushButton::GetDimmedImage()
-{
- return mDimmedImage;
-}
-
-Actor PushButton::GetDimmedImage() const
-{
- return mDimmedImage;
-}
-
-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 );
-}
-
-void PushButton::SetLabelText( Actor text )
-{
- Toolkit::PushButton handle( GetOwner() );
- GetPushButtonPainter( mPainter )->SetLabelText( handle, text );
-}
-
-Actor& PushButton::GetLabel()
-{
- return mLabel;
-}
-
-Actor PushButton::GetLabelText() const
-{
- return mLabel;
-}
-
-Actor& PushButton::GetFadeOutBackgroundImage()
-{
- return mFadeOutBackgroundImage;
-}
-
-Actor& PushButton::GetFadeOutButtonImage()
-{
- return mFadeOutButtonImage;
-}
-
-Toolkit::PushButton::ToggledSignalV2& PushButton::ToggledSignal()
-{
- return mToggledSignalV2;
-}
-
-Toolkit::PushButton::PressedSignalV2& PushButton::PressedSignal()
-{
- return mPressedSignalV2;
-}
-
-Toolkit::PushButton::ReleasedSignalV2& PushButton::ReleasedSignal()
-{
- return mReleasedSignalV2;
-}
-
-bool PushButton::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
-{
- Dali::BaseHandle handle( object );
-
- bool connected( true );
- Toolkit::PushButton button = Toolkit::PushButton::DownCast(handle);
-
- if( Toolkit::PushButton::SIGNAL_TOGGLED == signalName )
+ case TOP:
{
- button.ToggledSignal().Connect( tracker, functor );
+ labelAlignment = Button::BOTTOM;
+ break;
}
- else if( Toolkit::PushButton::SIGNAL_PRESSED == signalName )
+ case BOTTOM:
{
- button.PressedSignal().Connect( tracker, functor );
+ labelAlignment = Button::TOP;
+ break;
}
- else if( Toolkit::PushButton::SIGNAL_RELEASED == signalName )
- {
- button.ReleasedSignal().Connect( tracker, functor );
- }
- else
- {
- // signalName does not match any signal
- connected = false;
+ case LEFT:
+ default:
+ labelAlignment = Button::END;
+ break;
}
- return connected;
+ Button::SetLabelAlignment( labelAlignment );
+}
+
+const PushButton::IconAlignment PushButton::GetIconAlignment() const
+{
+ return mIconAlignment;
}
void PushButton::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
{
PushButton& pushButtonImpl( GetImplementation( pushButton ) );
+ // Properties remain here for Tizen 3.0 legacy requirements. Are now in Button base class
+
switch ( propertyIndex )
{
- case Toolkit::PushButton::PROPERTY_AUTO_REPEATING:
+ case Toolkit::PushButton::Property::UNSELECTED_ICON:
{
- pushButtonImpl.SetAutoRepeating( value.Get< bool >() );
+ pushButtonImpl.CreateVisualsForComponent( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, value, DepthIndex::CONTENT );
break;
}
-
- case Toolkit::PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY:
- {
- pushButtonImpl.SetInitialAutoRepeatingDelay( value.Get< float >() );
- break;
- }
-
- case Toolkit::PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY:
+ case Toolkit::PushButton::Property::SELECTED_ICON:
{
- pushButtonImpl.SetNextAutoRepeatingDelay( value.Get< float >() );
+ pushButtonImpl.CreateVisualsForComponent( Toolkit::DevelButton::Property::SELECTED_VISUAL, value, DepthIndex::CONTENT );
break;
}
-
- case Toolkit::PushButton::PROPERTY_TOGGLABLE:
+ case Toolkit::PushButton::Property::ICON_ALIGNMENT:
{
- pushButtonImpl.SetToggleButton( value.Get< bool >() );
- break;
- }
-
- case Toolkit::PushButton::PROPERTY_TOGGLE:
- {
- pushButtonImpl.SetToggled( value.Get< bool >() );
- break;
- }
-
- case Toolkit::PushButton::PROPERTY_BUTTON_IMAGE:
- {
- Image image = Image::New( value.Get<std::string>() );
- pushButtonImpl.SetButtonImage( image );
- break;
- }
-
- case Toolkit::PushButton::PROPERTY_PRESSED_IMAGE:
- {
- Image image = Image::New( value.Get<std::string>() );
- pushButtonImpl.SetPressedImage( image );
+ IconAlignment iconAlignment;
+ if( Scripting::GetEnumeration< IconAlignment >( value.Get< std::string >().c_str(), IconAlignmentTable, IconAlignmentTableCount, iconAlignment ) )
+ {
+ pushButtonImpl.SetIconAlignment( iconAlignment );
+ }
break;
}
-
- case Toolkit::PushButton::PROPERTY_DIMMED_IMAGE:
+ case Toolkit::PushButton::Property::LABEL_PADDING:
{
- Image image = Image::New( value.Get<std::string>() );
- pushButtonImpl.SetDimmedImage( image );
+ Vector4 padding ( value.Get< Vector4 >() );
+ pushButtonImpl.Button::SetLabelPadding( Padding( padding.x, padding.y, padding.z, padding.w ) );
break;
}
-
- case Toolkit::PushButton::PROPERTY_LABEL_TEXT:
+ case Toolkit::PushButton::Property::ICON_PADDING:
{
- pushButtonImpl.SetLabelText( value.Get< std::string >() );
+ Vector4 padding ( value.Get< Vector4 >() );
+ pushButtonImpl.Button::SetForegroundPadding( Padding( padding.x, padding.y, padding.z, padding.w ) );
break;
}
}
switch ( propertyIndex )
{
- case Toolkit::PushButton::PROPERTY_AUTO_REPEATING:
+ case Toolkit::PushButton::Property::UNSELECTED_ICON:
{
- value = pushButtonImpl.mAutoRepeating;
+ //value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION );
break;
}
-
- case Toolkit::PushButton::PROPERTY_INITIAL_AUTO_REPEATING_DELAY:
+ case Toolkit::PushButton::Property::SELECTED_ICON:
{
- value = pushButtonImpl.mInitialAutoRepeatingDelay;
+ //value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION );
break;
}
-
- case Toolkit::PushButton::PROPERTY_NEXT_AUTO_REPEATING_DELAY:
+ case Toolkit::PushButton::Property::ICON_ALIGNMENT:
{
- value = pushButtonImpl.mNextAutoRepeatingDelay;
+ value = Scripting::GetLinearEnumerationName< IconAlignment >( pushButtonImpl.GetIconAlignment(), IconAlignmentTable, IconAlignmentTableCount );
break;
}
-
- case Toolkit::PushButton::PROPERTY_TOGGLABLE:
- {
- value = pushButtonImpl.mToggleButton;
- break;
- }
-
- case Toolkit::PushButton::PROPERTY_TOGGLE:
- {
- value = pushButtonImpl.mToggled;
- break;
- }
-
- case Toolkit::PushButton::PROPERTY_BUTTON_IMAGE:
- {
- std::string path;
- GetImageActorFilename( pushButtonImpl.mButtonImage, path );
- value = path;
- break;
- }
-
- case Toolkit::PushButton::PROPERTY_PRESSED_IMAGE:
- {
- std::string path;
- GetImageActorFilename( pushButtonImpl.mPressedImage, path );
- value = path;
- break;
- }
-
- case Toolkit::PushButton::PROPERTY_DIMMED_IMAGE:
+ case Toolkit::PushButton::Property::LABEL_PADDING:
{
- std::string path;
- GetImageActorFilename( pushButtonImpl.mDimmedImage, path );
- value = path;
+ Padding padding = pushButtonImpl.Button::GetLabelPadding();
+ value = Vector4( padding.x, padding.y, padding.top, padding.bottom);
break;
}
-
- case Toolkit::PushButton::PROPERTY_LABEL_TEXT:
+ case Toolkit::PushButton::Property::ICON_PADDING:
{
- value = ""; // Just return an empty string if not using a TextView
-
- if ( pushButtonImpl.mLabel )
- {
- Toolkit::TextView textView = Toolkit::TextView::DownCast( pushButtonImpl.mLabel );
- if ( textView )
- {
- value = textView.GetText();
- }
- }
+ Padding padding = pushButtonImpl.Button::GetForegroundPadding();
+ value = Vector4( padding.x, padding.y, padding.top, padding.bottom);
break;
}
}
return value;
}
-void PushButton::OnButtonInitialize()
-{
- // Push button requires the Leave event.
- Actor root = Self();
- root.SetLeaveRequired( true );
-}
+// Deprecated API using Actor to set images
-void PushButton::OnButtonDown()
+void PushButton::SetButtonImage( Actor image )
{
- if( !mToggleButton )
- {
- Toolkit::PushButton handle( GetOwner() );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetButtonImage() is deprecated and will be removed from next release. Use Button.SetProperty UNSELECTED_STATE_IMAGE or Styling file instead.\n" );
- // Notifies the painter the button has been pressed.
- GetPushButtonPainter( mPainter )->Pressed( handle );
+ Image retreivedButtonImage = Toolkit::ImageView::DownCast( image ).GetImage();
+ if ( retreivedButtonImage )
+ {
+ ResourceImage resourceImage = ResourceImage::DownCast( retreivedButtonImage );
- if( mAutoRepeating )
+ if ( resourceImage )
{
- SetUpTimer( mInitialAutoRepeatingDelay );
- }
+ Self().SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, resourceImage.GetUrl() );
- //Emit signal.
- mPressedSignalV2.Emit( handle );
+ }
}
}
-void PushButton::OnButtonUp()
+void PushButton::SetBackgroundImage( Actor image )
{
- if( ButtonDown == mState )
- {
- if( mToggleButton )
- {
- mToggled = !mToggled;
-
- Toolkit::PushButton handle( GetOwner() );
-
- // Notifies the painter the button has been toggled.
- GetPushButtonPainter( mPainter )->Toggled( handle );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetBackgroundImage() is deprecated and will be removed from next release.\n" );
- //Emit signal.
- mToggledSignalV2.Emit( handle, mToggled );
- }
- else
- {
- Toolkit::PushButton handle( GetOwner() );
-
- // Notifies the painter the button has been clicked.
- GetPushButtonPainter( mPainter )->Released( handle );
- GetPushButtonPainter( mPainter )->Clicked( handle );
+ SetButtonImage( image );
- if( mAutoRepeating )
- {
- mAutoRepeatingTimer.Reset();
- }
-
- //Emit signal.
- mReleasedSignalV2.Emit( handle );
- mClickedSignalV2.Emit( handle );
- }
- }
}
-void PushButton::OnTouchPointLeave()
+void PushButton::SetSelectedImage( Actor image )
{
- if( ButtonDown == mState )
- {
- if( !mToggleButton )
- {
- Toolkit::PushButton handle( GetOwner() );
-
- // Notifies the painter the button has been released.
- GetPushButtonPainter( mPainter )->Released( handle );
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedImage() is deprecated and will be removed from next release. Use Button.SetProperty SELECTED_STATE_IMAGE or Styling file instead.\n" );
- if( mAutoRepeating )
- {
- mAutoRepeatingTimer.Reset();
- }
+ Image retreivedButtonImage = Toolkit::ImageView::DownCast( image ).GetImage();
+ if ( retreivedButtonImage )
+ {
+ ResourceImage resourceImage = ResourceImage::DownCast( retreivedButtonImage );
- //Emit signal.
- mReleasedSignalV2.Emit( handle );
+ if ( resourceImage )
+ {
+ Self().SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, resourceImage.GetUrl() );
}
}
}
-void PushButton::OnTouchPointInterrupted()
+void PushButton::SetSelectedBackgroundImage( Actor image )
{
- OnTouchPointLeave();
-}
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedBackgroundImage() is deprecated and will be removed from next release.\n" );
-void PushButton::OnAnimationTimeSet( float animationTime )
-{
- GetPushButtonPainter( mPainter )->SetAnimationTime( animationTime );
+ SetSelectedImage( image );
}
-float PushButton::OnAnimationTimeRequested() const
+void PushButton::SetDisabledBackgroundImage( Actor image )
{
- return GetPushButtonPainter( mPainter )->GetAnimationTime();
-}
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledBackgroundImage() is deprecated and will be removed from next release.\n" );
-PushButton::PushButton()
-: Button(),
- mAutoRepeating( false ),
- mInitialAutoRepeatingDelay( INITIAL_AUTOREPEATING_DELAY ),
- mNextAutoRepeatingDelay( NEXT_AUTOREPEATING_DELAY ),
- mToggleButton( false ),
- mAutoRepeatingTimer(),
- mToggled( false ),
- mClickActionPerforming(false)
-{
- // Creates specific painter.
- mPainter = PushButtonDefaultPainterPtr( new PushButtonDefaultPainter() );
-}
-
-PushButton::~PushButton()
-{
- if( mAutoRepeatingTimer )
+ Image retreivedButtonImage = Toolkit::ImageView::DownCast( image ).GetImage();
+ if ( retreivedButtonImage )
{
- mAutoRepeatingTimer.Reset();
- }
+ ResourceImage resourceImage = ResourceImage::DownCast( retreivedButtonImage );
- mPainter = NULL;
+ if ( resourceImage )
+ {
+ Self().SetProperty( Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL, resourceImage.GetUrl() );
+ }
+ }
}
-void PushButton::SetUpTimer( float delay )
+void PushButton::SetDisabledImage( Actor image )
{
- mAutoRepeatingTimer = Dali::Timer::New( static_cast<unsigned int>( 1000.f * delay ) );
- mAutoRepeatingTimer.TickSignal().Connect( this, &PushButton::AutoRepeatingSlot );
- mAutoRepeatingTimer.Start();
-}
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledImage() is deprecated and will be removed from next release. Use Button.SetProperty DISABLED_STATE_IMAGE or Styling file instead.\n" );
-bool PushButton::AutoRepeatingSlot()
-{
- bool consumed = false;
- if( !mDimmed )
+ Image retreivedButtonImage = Toolkit::ImageView::DownCast( image ).GetImage();
+ if ( retreivedButtonImage )
{
- // Restart the autorepeat timer.
- SetUpTimer( mNextAutoRepeatingDelay );
-
- Toolkit::PushButton handle( GetOwner() );
-
- // Notifies the painter the button has been pressed.
- GetPushButtonPainter( mPainter )->Pressed( handle );
-
- //Emit signal.
- consumed = mReleasedSignalV2.Emit( handle );
- consumed |= mClickedSignalV2.Emit( handle );
- consumed |= mPressedSignalV2.Emit( handle );
- }
+ ResourceImage resourceImage = ResourceImage::DownCast( retreivedButtonImage );
- return consumed;
-}
-
-void PushButton::OnActivated()
-{
- // When the button is activated, it performs the click action
- std::vector<Property::Value> attributes;
- DoClickAction(attributes);
-}
-
-void PushButton::DoClickAction(const PropertyValueContainer& attributes)
-{
- // Prevents the button signals from doing a recursive loop by sending an action
- // and re-emitting the signals.
- if(!mClickActionPerforming)
- {
- mClickActionPerforming = true;
- OnButtonDown();
- mState = ButtonDown;
- OnButtonUp();
- mClickActionPerforming = false;
+ if ( resourceImage )
+ {
+ Self().SetProperty( Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL, resourceImage.GetUrl() );
+ }
}
}
-bool PushButton::DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes)
+void PushButton::SetDisabledSelectedImage( Actor image )
{
- bool ret = false;
-
- Dali::BaseHandle handle(object);
-
- Toolkit::PushButton button = Toolkit::PushButton::DownCast(handle);
-
- DALI_ASSERT_ALWAYS(button);
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledSelectedImage() is deprecated and will be removed from next release.\n" );
- if(Toolkit::PushButton::ACTION_PUSH_BUTTON_CLICK == actionName)
+ Image retreivedButtonImage = Toolkit::ImageView::DownCast( image ).GetImage();
+ if ( retreivedButtonImage )
{
- GetImplementation(button).DoClickAction(attributes);
- ret = true;
- }
+ ResourceImage resourceImage = ResourceImage::DownCast( retreivedButtonImage );
- return ret;
+ if ( resourceImage )
+ {
+ Self().SetProperty( Toolkit::DevelButton::Property::DISABLED_SELECTED_BACKGROUND_VISUAL, resourceImage.GetUrl() );
+ }
+ }
}
} // namespace Internal