X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fpush-button-impl.cpp;h=4e96f14551499d6d3ccc83cf0e87c5fd44eaa3ef;hp=450b03858d6637977c100234c54213351676b6df;hb=abbf60ed35112186269d2fe93b949eb8abd4283d;hpb=57869973578f6a0b0f836d396c7232ddb8302c6b diff --git a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp index 450b038..4e96f14 100644 --- a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp @@ -19,16 +19,21 @@ #include "push-button-impl.h" // EXTERNAL INCLUDES -#include -#include #include -#include +#include +#include +#include +#include // INTERNAL INCLUDES -#include "push-button-default-painter-impl.h" +#include +#include +#include +#include -#include -#include +#if defined(DEBUG_ENABLED) + extern Debug::Filter* gLogButtonFilter; +#endif namespace Dali { @@ -47,50 +52,32 @@ BaseHandle Create() return Toolkit::PushButton::New(); } -TypeRegistration typeRegistration( typeid(Toolkit::PushButton), typeid(Toolkit::Button), Create ); +// Properties -SignalConnectorType signalConnector1( typeRegistration, Toolkit::PushButton::SIGNAL_PRESSED , &PushButton::DoConnectSignal ); -SignalConnectorType signalConnector2( 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 ) -} // unnamed namespace - -namespace -{ - -const unsigned int INITIAL_AUTOREPEATING_DELAY( 0.15f ); -const unsigned int NEXT_AUTOREPEATING_DELAY( 0.05f ); +DALI_TYPE_REGISTRATION_END() -const float TEXT_PADDING = 12.0f; - -// Helper function used to cast a ButtonPainter to PushButtonDefaultPainter -PushButtonDefaultPainterPtr GetPushButtonPainter( Dali::Toolkit::Internal::ButtonPainterPtr painter ) -{ - return static_cast( painter.Get() ); -} - -/** - * Find the first image actor in the actor hierarchy +/* + * Table to define Text-to-enum conversions for IconAlignment. */ -ImageActor FindImageActor( Actor root ) -{ - ImageActor imageActor = ImageActor::DownCast( root ); - if( !imageActor && root ) - { - for( unsigned int i = 0, numChildren = root.GetChildCount(); i < numChildren; ++i ) - { - ImageActor childImageActor = FindImageActor( root.GetChildAt( i ) ); - if( childImageActor ) - { - return childImageActor; - } - } - } +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] ); - return imageActor; -} +} // unnamed namespace +namespace +{ } // unnamed namespace @@ -109,648 +96,150 @@ 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( !mDisabled && 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. - mStateChangedSignal.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::SetSelectedImage( Image image ) -{ - SetSelectedImage( ImageActor::New( image ) ); -} - -void PushButton::SetSelectedImage( Actor image ) -{ - Toolkit::PushButton handle( GetOwner() ); - GetPushButtonPainter( mPainter )->SetSelectedImage( handle, image ); -} - -Actor& PushButton::GetSelectedImage() -{ - return mSelectedImage; -} - -Actor PushButton::GetSelectedImage() const -{ - return mSelectedImage; -} - -void PushButton::SetDisabledBackgroundImage( Image image ) -{ - SetDisabledBackgroundImage( ImageActor::New( image ) ); -} - -void PushButton::SetDisabledBackgroundImage( Actor image ) -{ - Toolkit::PushButton handle( GetOwner() ); - GetPushButtonPainter( mPainter )->SetDisabledBackgroundImage( handle, image ); -} - -Actor& PushButton::GetDisabledBackgroundImage() -{ - return mDisabledBackgroundImage; -} - -Actor PushButton::GetDisabledBackgroundImage() const -{ - return mDisabledBackgroundImage; -} - -void PushButton::SetDisabledImage( Image image ) -{ - SetDisabledImage( ImageActor::New( image ) ); -} - -void PushButton::SetDisabledImage( Actor image ) -{ - Toolkit::PushButton handle( GetOwner() ); - GetPushButtonPainter( mPainter )->SetDisabledImage( handle, image ); -} - -Actor& PushButton::GetDisabledImage() -{ - return mDisabledImage; -} - -Actor PushButton::GetDisabledImage() const -{ - return mDisabledImage; -} - -void PushButton::SetLabel( const std::string& label ) -{ - Toolkit::TextView textView ( Toolkit::TextView::New( label ) ); - textView.SetWidthExceedPolicy( Toolkit::TextView::ShrinkToFit ); // Make sure our text always fits inside the button - SetLabel( textView ); -} - -void PushButton::SetLabel( Actor label ) -{ - Toolkit::PushButton handle( GetOwner() ); - GetPushButtonPainter( mPainter )->SetLabel( handle, label ); -} - -Actor PushButton::GetLabel() const -{ - return mLabel; -} - -Actor& PushButton::GetLabel() -{ - return mLabel; -} - -Actor& PushButton::GetFadeOutBackgroundImage() -{ - return mFadeOutBackgroundImage; -} - -Actor& PushButton::GetFadeOutButtonImage() -{ - return mFadeOutButtonImage; -} - -Toolkit::PushButton::PressedSignalType& PushButton::PressedSignal() -{ - return mPressedSignal; -} - -Toolkit::PushButton::ReleasedSignalType& PushButton::ReleasedSignal() -{ - return mReleasedSignal; -} - -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_STATE_CHANGED == signalName ) + case TOP: { - button.StateChangedSignal().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 ); } -void PushButton::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value ) +const PushButton::IconAlignment PushButton::GetIconAlignment() const { - Toolkit::PushButton pushButton = Toolkit::PushButton::DownCast( Dali::BaseHandle( object ) ); - - if ( pushButton ) - { - PushButton& pushButtonImpl( GetImplementation( pushButton ) ); - - if ( propertyIndex == Toolkit::Button::PROPERTY_AUTO_REPEATING ) - { - pushButtonImpl.SetAutoRepeating( value.Get< bool >() ); - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY ) - { - pushButtonImpl.SetInitialAutoRepeatingDelay( value.Get< float >() ); - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY ) - { - pushButtonImpl.SetNextAutoRepeatingDelay( value.Get< float >() ); - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLABLE ) - { - pushButtonImpl.SetToggleButton( value.Get< bool >() ); - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLED ) - { - pushButtonImpl.SetToggled( value.Get< bool >() ); - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR ) - { - pushButtonImpl.SetButtonImage( Scripting::NewActor( value.Get< Property::Map >() ) ); - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR ) - { - pushButtonImpl.SetSelectedImage( Scripting::NewActor( value.Get< Property::Map >() ) ); - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR ) - { - pushButtonImpl.SetDisabledImage( Scripting::NewActor( value.Get< Property::Map >() ) ); - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_LABEL_ACTOR ) - { - pushButtonImpl.SetLabel( Scripting::NewActor( value.Get< Property::Map >() ) ); - } - } + return mIconAlignment; } -Property::Value PushButton::GetProperty( BaseObject* object, Property::Index propertyIndex ) +void PushButton::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value ) { - Property::Value value; - Toolkit::PushButton pushButton = Toolkit::PushButton::DownCast( Dali::BaseHandle( object ) ); if ( pushButton ) { PushButton& pushButtonImpl( GetImplementation( pushButton ) ); - if ( propertyIndex == Toolkit::Button::PROPERTY_AUTO_REPEATING ) - { - value = pushButtonImpl.mAutoRepeating; - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY ) - { - value = pushButtonImpl.mInitialAutoRepeatingDelay; - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY ) - { - value = pushButtonImpl.mNextAutoRepeatingDelay; - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLABLE ) - { - value = pushButtonImpl.mToggleButton; - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLED ) - { - value = pushButtonImpl.mToggled; - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR ) - { - Property::Map map; - Scripting::CreatePropertyMap( pushButtonImpl.mButtonImage, map ); - value = map; - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR ) - { - Property::Map map; - Scripting::CreatePropertyMap( pushButtonImpl.mSelectedImage, map ); - value = map; - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR ) - { - Property::Map map; - Scripting::CreatePropertyMap( pushButtonImpl.mDisabledImage, map ); - value = map; - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_LABEL_ACTOR ) - { - Property::Map map; - Scripting::CreatePropertyMap( pushButtonImpl.mLabel, map ); - value = map; - } - } + // Properties remain here for Tizen 3.0 legacy requirements. Are now in Button base class - return value; -} - -void PushButton::OnButtonInitialize() -{ - // Push button requires the Leave event. - Actor root = Self(); - root.SetLeaveRequired( true ); -} - -void PushButton::OnButtonDown() -{ - if( !mToggleButton ) - { - Toolkit::PushButton handle( GetOwner() ); - - // Notifies the painter the button has been pressed. - GetPushButtonPainter( mPainter )->Pressed( handle ); - - if( mAutoRepeating ) - { - SetUpTimer( mInitialAutoRepeatingDelay ); - } - - //Emit signal. - mPressedSignal.Emit( handle ); - } -} - -void PushButton::OnButtonUp() -{ - if( ButtonDown == mState ) - { - if( mToggleButton ) + switch ( propertyIndex ) { - mToggled = !mToggled; - - Toolkit::PushButton handle( GetOwner() ); - - // Notifies the painter the button has been toggled. - GetPushButtonPainter( mPainter )->Toggled( handle ); - - // Emit signal. - mStateChangedSignal.Emit( handle, mToggled ); - } - else - { - Toolkit::PushButton handle( GetOwner() ); - - // Notifies the painter the button has been clicked. - GetPushButtonPainter( mPainter )->Released( handle ); - GetPushButtonPainter( mPainter )->Clicked( handle ); - - if( mAutoRepeating ) + case Toolkit::PushButton::Property::UNSELECTED_ICON: { - mAutoRepeatingTimer.Reset(); + pushButtonImpl.CreateVisualsForComponent( Toolkit::Button::Property::UNSELECTED_VISUAL, value, DepthIndex::CONTENT ); + break; } - - //Emit signal. - mReleasedSignal.Emit( handle ); - mClickedSignal.Emit( handle ); - } - } -} - -void PushButton::OnTouchPointLeave() -{ - if( ButtonDown == mState ) - { - if( !mToggleButton ) - { - Toolkit::PushButton handle( GetOwner() ); - - // Notifies the painter the button has been released. - GetPushButtonPainter( mPainter )->Released( handle ); - - if( mAutoRepeating ) + case Toolkit::PushButton::Property::SELECTED_ICON: { - mAutoRepeatingTimer.Reset(); + pushButtonImpl.CreateVisualsForComponent( Toolkit::Button::Property::SELECTED_VISUAL, value, DepthIndex::CONTENT ); + break; } - - //Emit signal. - mReleasedSignal.Emit( handle ); - } - } -} - -void PushButton::OnTouchPointInterrupted() -{ - OnTouchPointLeave(); -} - -void PushButton::OnAnimationTimeSet( float animationTime ) -{ - GetPushButtonPainter( mPainter )->SetAnimationTime( animationTime ); -} - -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 ) + case Toolkit::PushButton::Property::ICON_ALIGNMENT: + { + IconAlignment iconAlignment; + if( Scripting::GetEnumeration< IconAlignment >( value.Get< std::string >().c_str(), IconAlignmentTable, IconAlignmentTableCount, iconAlignment ) ) + { + pushButtonImpl.SetIconAlignment( iconAlignment ); + } + break; + } + case Toolkit::PushButton::Property::LABEL_PADDING: + { + Vector4 padding ( value.Get< Vector4 >() ); + pushButtonImpl.Button::SetLabelPadding( Padding( padding.x, padding.y, padding.z, padding.w ) ); + break; + } + case Toolkit::PushButton::Property::ICON_PADDING: { - mAutoRepeatingTimer.Reset(); + Vector4 padding ( value.Get< Vector4 >() ); + pushButtonImpl.Button::SetForegroundPadding( Padding( padding.x, padding.y, padding.z, padding.w ) ); + break; } } } } -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() +Property::Value PushButton::GetProperty( BaseObject* object, Property::Index propertyIndex ) { - if( mAutoRepeatingTimer ) - { - mAutoRepeatingTimer.Reset(); - } - - mPainter = NULL; -} + Property::Value value; -void PushButton::SetUpTimer( float delay ) -{ - mAutoRepeatingTimer = Dali::Timer::New( static_cast( 1000.f * delay ) ); - mAutoRepeatingTimer.TickSignal().Connect( this, &PushButton::AutoRepeatingSlot ); - mAutoRepeatingTimer.Start(); -} + Toolkit::PushButton pushButton = Toolkit::PushButton::DownCast( Dali::BaseHandle( object ) ); -bool PushButton::AutoRepeatingSlot() -{ - bool consumed = false; - if( !mDisabled ) + if ( pushButton ) { - // 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 = mReleasedSignal.Emit( handle ); - consumed |= mClickedSignal.Emit( handle ); - consumed |= mPressedSignal.Emit( handle ); - } - - return consumed; -} - -void PushButton::OnActivated() -{ - // When the button is activated, it performs the click action - PropertyValueContainer attributes; - DoClickAction(attributes); -} - -Vector3 PushButton::GetNaturalSize() -{ - Vector3 size = Control::GetNaturalSize(); - - const bool widthIsZero = EqualsZero( size.width ); - const bool heightIsZero = EqualsZero( size.height ); + PushButton& pushButtonImpl( GetImplementation( pushButton ) ); - if( widthIsZero || heightIsZero ) - { - // If background and background not scale9 try get size from that - ImageActor imageActor = FindImageActor( mButtonImage ); - if( imageActor && imageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH ) + switch ( propertyIndex ) { - Vector3 imageSize = RelayoutHelper::GetNaturalSize( imageActor ); - - if( widthIsZero ) + case Toolkit::PushButton::Property::UNSELECTED_ICON: { - size.width = imageSize.width; + //value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION ); + break; } - - if( heightIsZero ) + case Toolkit::PushButton::Property::SELECTED_ICON: { - size.height = imageSize.height; + //value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION ); + break; } - } - - ImageActor backgroundImageActor = FindImageActor( mBackgroundImage ); - if( backgroundImageActor && backgroundImageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH ) - { - Vector3 imageSize = RelayoutHelper::GetNaturalSize( backgroundImageActor ); - - if( widthIsZero ) + case Toolkit::PushButton::Property::ICON_ALIGNMENT: { - size.width = std::max( size.width, imageSize.width ); + value = Scripting::GetLinearEnumerationName< IconAlignment >( pushButtonImpl.GetIconAlignment(), IconAlignmentTable, IconAlignmentTableCount ); + break; } - - if( heightIsZero ) + case Toolkit::PushButton::Property::LABEL_PADDING: { - size.height = std::max( size.height, imageSize.height ); + Padding padding = pushButtonImpl.Button::GetLabelPadding(); + value = Vector4( padding.x, padding.y, padding.top, padding.bottom); + break; } - } - - // If label, test against it's size - Toolkit::TextView textView = Toolkit::TextView::DownCast( mLabel ); - if( textView ) - { - Vector3 textViewSize = textView.GetNaturalSize(); - - if( widthIsZero ) + case Toolkit::PushButton::Property::ICON_PADDING: { - 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 ); + Padding padding = pushButtonImpl.Button::GetForegroundPadding(); + value = Vector4( padding.x, padding.y, padding.top, padding.bottom); + break; } } } - return size; -} - -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; - } -} - -bool PushButton::DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes) -{ - bool ret = false; - - Dali::BaseHandle handle(object); - - Toolkit::PushButton button = Toolkit::PushButton::DownCast(handle); - - DALI_ASSERT_ALWAYS(button); - - if(Toolkit::PushButton::ACTION_PUSH_BUTTON_CLICK == actionName) - { - GetImplementation(button).DoClickAction(attributes); - ret = true; - } - - return ret; + return value; } } // namespace Internal