- Actor& label = GetLabel();
-
- if( label )
- {
- label.SetParentOrigin( ParentOrigin::CENTER_LEFT );
- label.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
-
- // Radio button width is FIT_TO_CHILDREN, so the label must have a sensible policy to fill out the space
- if( label.GetResizePolicy( Dimension::WIDTH ) == ResizePolicy::FILL_TO_PARENT )
- {
- label.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::WIDTH );
- }
-
- if( IsSelected() )
- {
- label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- else
- {
- label.SetX( GetButtonImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- }
-}
-
-bool RadioButton::OnSelected()
-{
- Actor& buttonImage = GetButtonImage();
- Actor& selectedImage = GetSelectedImage();
- Actor& label = GetLabel();
-
- PaintState paintState = GetPaintState();
-
- switch( paintState )
- {
- case UnselectedState:
- {
- Actor parent = Self().GetParent();
- if( parent )
- {
- for( unsigned int i = 0; i < parent.GetChildCount(); ++i )
- {
- Dali::Toolkit::RadioButton radioButtonChild = Dali::Toolkit::RadioButton::DownCast( parent.GetChildAt( i ) );
- if( radioButtonChild && radioButtonChild != Self() )
- {
- radioButtonChild.SetSelected( false );
- }
- }
- }
-
- RemoveChild( buttonImage );
-
- if( label )
- {
- label.SetX( selectedImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- break;
- }
- case SelectedState:
- {
- RemoveChild( selectedImage );
-
- if( label )
- {
- label.SetX( buttonImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
- }
- break;
- }
- default:
- {
- break;
- }
- }
-
- // there is no animation
- return false;
+ // Radio button can be part of a group, if a button in the group is selected then all others should be unselected
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "RadioButton::OnStateChange state(%d)\n", newState );
+
+ switch( newState )
+ {
+ case SELECTED_STATE:
+ {
+ Actor parent = Self().GetParent();
+ if( parent )
+ {
+ for( unsigned int i = 0; i < parent.GetChildCount(); ++i )
+ {
+ Dali::Toolkit::RadioButton radioButtonChild = Dali::Toolkit::RadioButton::DownCast( parent.GetChildAt( i ) );
+ if( radioButtonChild && radioButtonChild != Self() )
+ {
+ radioButtonChild.SetSelected( false );
+ }
+ }
+ }
+ }
+
+ default:
+ {
+ break;
+ }
+ }