X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fradio-button-impl.cpp;h=08d10bf6b0aeeff5f5f8a3d4d5cedf4b773c8454;hb=3b16ae16f01bd50a26e6c44e6e20ebb8499b4f91;hp=2bcb9014bf350695c01179beee11178452a68e50;hpb=f4d559ea999cbbc44b1ecd489c4ca3711d37feca;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp b/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp index 2bcb901..08d10bf 100644 --- a/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp @@ -20,9 +20,7 @@ #include "radio-button-impl.h" // EXTERNAL INCLUDES -#include #include -#include using namespace Dali; using namespace Dali::Toolkit::Internal; @@ -59,35 +57,21 @@ Dali::Toolkit::RadioButton RadioButton::New() } RadioButton::RadioButton() - : mSelected(false) { mUnselectedImage = Dali::Image::New( UNSELECTED_BUTTON_IMAGE_DIR ); mSelectedImage = Dali::Image::New( SELECTED_BUTTON_IMAGE_DIR ); mRadioIcon = Dali::ImageActor::New( mUnselectedImage ); + +// SetTogglableButton(true); + mTogglableButton = true; // TODO: Use SetTogglableButton() after refactoring painter } RadioButton::~RadioButton() { } -void RadioButton::SetLabel(const std::string& label) -{ - TextActor textActor = TextActor::DownCast( mLabel ); - if( textActor ) - { - textActor.SetText( label ); - } - else - { - Toolkit::TextView newTextView = Toolkit::TextView::New( label ); - SetLabel( newTextView ); - } - - RelayoutRequest(); -} - -void RadioButton::SetLabel(Actor label) +void RadioButton::SetLabel( Actor label ) { if( mLabel != label ) { @@ -110,14 +94,9 @@ void RadioButton::SetLabel(Actor label) } } -Actor RadioButton::GetLabel() const +void RadioButton::SetSelected( bool selected ) { - return mLabel; -} - -void RadioButton::SetSelected(bool selected) -{ - if( mSelected != selected ) + if( IsSelected() != selected ) { if( selected ) { @@ -146,36 +125,28 @@ void RadioButton::SetSelected(bool selected) // Raise state changed signal Toolkit::RadioButton handle( GetOwner() ); - mStateChangedSignal.Emit( handle, mSelected ); + StateChangedSignal().Emit( handle ); RelayoutRequest(); } } -bool RadioButton::IsSelected()const -{ - return mSelected; -} - -void RadioButton::ToggleState() -{ - SetSelected(!mSelected); -} - void RadioButton::OnRelayout( const Vector2& /*size*/, ActorSizeContainer& container ) { Vector3 newSize( mRadioIcon.GetNaturalSize() ); - if( mLabel ) + Actor& label = GetLabel(); + + if( label ) { // Offset the label from the radio button image newSize.width += DISTANCE_BETWEEN_IMAGE_AND_LABEL.width; // Find the size of the control using size negotiation - Vector3 actorNaturalSize( mLabel.GetNaturalSize() ); - Control::Relayout( mLabel, Vector2( actorNaturalSize.width, actorNaturalSize.height ), container ); + Vector3 actorNaturalSize( label.GetNaturalSize() ); + Control::Relayout( label, Vector2( actorNaturalSize.width, actorNaturalSize.height ), container ); - Vector3 actorSize( mLabel.GetSize() ); + Vector3 actorSize( label.GetSize() ); newSize.width += actorSize.width; newSize.height = std::max( newSize.height, actorSize.height ); } @@ -194,53 +165,12 @@ void RadioButton::OnInitialize() void RadioButton::OnButtonUp() { - // Don't allow selection on an already selected radio button - if( !mSelected ) - { - ToggleState(); - } -} - -void RadioButton::SetProperty(BaseObject* object, Property::Index propertyIndex, const Property::Value& value) -{ - Toolkit::RadioButton radioButton = Toolkit::RadioButton::DownCast( Dali::BaseHandle( object ) ); - - if( radioButton ) + if( ButtonDown == GetState() ) { - RadioButton& radioButtonImpl( GetImplementation( radioButton ) ); - - if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLED ) + // Don't allow selection on an already selected radio button + if( !IsSelected() ) { - radioButtonImpl.SetSelected( value.Get< bool >( ) ); - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_LABEL_ACTOR ) - { - radioButtonImpl.SetLabel( Scripting::NewActor( value.Get< Property::Map >( ) ) ); + SetSelected(!IsSelected()); } } } - -Property::Value RadioButton::GetProperty(BaseObject* object, Property::Index propertyIndex) -{ - Property::Value value; - - Toolkit::RadioButton radioButton = Toolkit::RadioButton::DownCast( Dali::BaseHandle(object) ); - - if( radioButton ) - { - RadioButton& radioButtonImpl( GetImplementation( radioButton ) ); - - if ( propertyIndex == Toolkit::Button::PROPERTY_TOGGLED ) - { - value = radioButtonImpl.mSelected; - } - else if ( propertyIndex == Toolkit::Button::PROPERTY_LABEL_ACTOR ) - { - Property::Map map; - Scripting::CreatePropertyMap( radioButtonImpl.mLabel, map ); - value = map; - } - } - - return value; -}