Merge "Make radio buttons work with size negotiation, bug fixes." into tizen
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 25 Sep 2014 14:19:01 +0000 (07:19 -0700)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 25 Sep 2014 14:19:01 +0000 (07:19 -0700)
16 files changed:
automated-tests/src/dali-toolkit-unmanaged/CMakeLists.txt
automated-tests/src/dali-toolkit-unmanaged/utc-Dali-RadioButton.cpp [new file with mode: 0644]
base/dali-toolkit/images/radio-button-active.png
base/dali-toolkit/images/radio-button-inactive.png
base/dali-toolkit/internal/controls/buttons/button-impl.cpp
base/dali-toolkit/internal/controls/buttons/button-impl.h
base/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp
base/dali-toolkit/internal/controls/buttons/push-button-impl.cpp
base/dali-toolkit/internal/controls/buttons/push-button-impl.h
base/dali-toolkit/internal/controls/buttons/radio-button-impl.cpp
base/dali-toolkit/internal/controls/buttons/radio-button-impl.h
base/dali-toolkit/public-api/controls/buttons/button.cpp
base/dali-toolkit/public-api/controls/buttons/button.h
base/dali-toolkit/public-api/controls/buttons/push-button.cpp
base/dali-toolkit/public-api/controls/buttons/push-button.h
base/dali-toolkit/public-api/controls/buttons/radio-button.h

index a4ad16f..c58d7f2 100644 (file)
@@ -50,6 +50,7 @@ SET(TC_SOURCES
  utc-Dali-ScrollViewEffect.cpp
  utc-Dali-TextInput.cpp
  utc-Dali-StyleManager.cpp
+ utc-Dali-RadioButton.cpp
 )
 
 # Append list of test harness files (Won't get parsed for test cases)
diff --git a/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-RadioButton.cpp b/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-RadioButton.cpp
new file mode 100644 (file)
index 0000000..f39ce42
--- /dev/null
@@ -0,0 +1,272 @@
+/*
+ * 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.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+void dali_radio_button_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void dali_radio_button_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+namespace
+{
+
+static bool gObjectCreatedCallBackCalled;
+
+static void TestCallback(BaseHandle handle)
+{
+  gObjectCreatedCallBackCalled = true;
+}
+
+}
+
+int UtcDaliRadioButtonNew(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliRadioButtonNew");
+
+  // Create the Slider actor
+  RadioButton radioButton;
+
+  DALI_TEST_CHECK( !radioButton );
+
+  radioButton = RadioButton::New();
+
+  DALI_TEST_CHECK( radioButton );
+
+  RadioButton radioButton2(radioButton);
+
+  DALI_TEST_CHECK( radioButton2 == radioButton );
+
+  //Additional check to ensure object is created by checking if it's registered
+  ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
+  DALI_TEST_CHECK( registry );
+
+  gObjectCreatedCallBackCalled = false;
+  registry.ObjectCreatedSignal().Connect( &TestCallback );
+  {
+    RadioButton radioButton = RadioButton::New();
+  }
+  DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
+  END_TEST;
+}
+
+int UtcDaliRadioButtonDestructor(void)
+{
+  ToolkitTestApplication application;
+
+  RadioButton* radioButton = new RadioButton();
+  delete radioButton;
+
+  DALI_TEST_CHECK( true );
+  END_TEST;
+}
+
+int UtcDaliRadioButtonDownCast(void)
+{
+  ToolkitTestApplication application;
+
+  Handle handle = RadioButton::New();
+
+  RadioButton radioButton = RadioButton::DownCast( handle );
+
+  DALI_TEST_CHECK( radioButton == handle );
+  END_TEST;
+}
+
+int UtcDaliRadioButtonLabelActor(void)
+{
+  ToolkitTestApplication application;
+
+  TextView actor1 = TextView::New( "test actor 1" );
+
+  RadioButton radioButton = RadioButton::New( actor1 );
+  DALI_TEST_CHECK( actor1 == radioButton.GetLabel() );
+
+  TextView actor2 = TextView::New( "test actor 2" );
+  radioButton.SetLabel( actor2 );
+  DALI_TEST_CHECK( actor2 == radioButton.GetLabel() );
+
+  END_TEST;
+}
+
+int UtcDaliRadioButtonActive(void)
+{
+  ToolkitTestApplication application;
+
+  RadioButton radioButton = RadioButton::New();
+
+  // Default active
+  DALI_TEST_CHECK( radioButton.IsActive() == false );
+
+  // False to true
+  radioButton.ToggleState();
+  DALI_TEST_CHECK( radioButton.IsActive() == true );
+
+  // True to false
+  radioButton.ToggleState();
+  DALI_TEST_CHECK( radioButton.IsActive() == false );
+
+  // False
+  radioButton.SetActive( false );
+  DALI_TEST_CHECK( radioButton.IsActive() == false );
+
+  // True
+  radioButton.SetActive( true );
+  DALI_TEST_CHECK( radioButton.IsActive() == true );
+
+  // False
+  radioButton.SetActive( false );
+  DALI_TEST_CHECK( radioButton.IsActive() == false );
+
+  END_TEST;
+}
+
+int UtcDaliRadioButtonActiveProperty(void)
+{
+  ToolkitTestApplication application;  // Exceptions require ToolkitTestApplication
+  tet_infoline(" UtcDaliRadioButtonActiveProperty");
+
+  // Create the RadioButton actor
+  RadioButton radioButton = RadioButton::New();
+  Stage::GetCurrent().Add( radioButton );
+  radioButton.SetParentOrigin(ParentOrigin::TOP_LEFT);
+  radioButton.SetAnchorPoint(ParentOrigin::TOP_LEFT);
+  radioButton.SetPosition( 0.0f, 0.0f );
+
+  // Default active
+  DALI_TEST_CHECK( radioButton.GetProperty<bool>( RadioButton::PROPERTY_ACTIVE ) == false );
+
+  // Setting false active
+  radioButton.SetProperty( RadioButton::PROPERTY_ACTIVE, false );
+  DALI_TEST_CHECK( radioButton.GetProperty<bool>( RadioButton::PROPERTY_ACTIVE ) == false );
+
+  // Setting true active
+  radioButton.SetProperty( RadioButton::PROPERTY_ACTIVE, true );
+  DALI_TEST_CHECK( radioButton.GetProperty<bool>( RadioButton::PROPERTY_ACTIVE ) == true );
+
+  // Setting false again
+  radioButton.SetProperty( RadioButton::PROPERTY_ACTIVE, false );
+  DALI_TEST_CHECK( radioButton.GetProperty<bool>( RadioButton::PROPERTY_ACTIVE ) == false );
+
+  // Test selecting radio buttons
+  RadioButton radioButton2 = RadioButton::New( "label" );
+  radioButton2.SetParentOrigin(ParentOrigin::TOP_LEFT);
+  radioButton2.SetAnchorPoint(ParentOrigin::TOP_LEFT);
+  radioButton2.SetPosition( 0.0f, 0.0f );
+
+  RadioButton radioButton3 = RadioButton::New( "label" );
+  radioButton3.SetParentOrigin(ParentOrigin::TOP_LEFT);
+  radioButton3.SetAnchorPoint(ParentOrigin::TOP_LEFT);
+  radioButton3.SetPosition( 0.0f, 40.0f );
+
+  Actor radioGroup = Actor::New();
+  Stage::GetCurrent().Add( radioGroup );
+  radioGroup.SetParentOrigin(ParentOrigin::TOP_LEFT);
+  radioGroup.SetAnchorPoint(ParentOrigin::TOP_LEFT);
+  radioGroup.SetPosition( 0.0f, 0.0f );
+  radioGroup.SetSize( 400.0f, 400.0 );
+
+  radioGroup.Add( radioButton2 );
+  radioGroup.Add( radioButton3 );
+
+  application.SendNotification();
+  application.Render();
+
+  // Simulate touch events
+  DALI_TEST_CHECK( radioButton2.GetProperty<bool>( RadioButton::PROPERTY_ACTIVE ) == false );
+  DALI_TEST_CHECK( radioButton3.GetProperty<bool>( RadioButton::PROPERTY_ACTIVE ) == false );
+
+  // Select first radio
+  {
+    Dali::Integration::TouchEvent event = Dali::Integration::TouchEvent();
+
+    const Dali::TouchPoint pointUp( 0, TouchPoint::Up, 10.0f, 10.0f );
+    event.AddPoint( pointUp );
+
+    application.ProcessEvent( event );
+
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( RadioButton::PROPERTY_ACTIVE ) == true );
+    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( RadioButton::PROPERTY_ACTIVE ) == false );
+  }
+
+  // Select an already selected radio
+  {
+    Dali::Integration::TouchEvent event = Dali::Integration::TouchEvent();
+
+    const Dali::TouchPoint pointDown( 0, TouchPoint::Up, 10.0f, 10.0f );
+    event.AddPoint( pointDown );
+
+    application.ProcessEvent( event );
+
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( RadioButton::PROPERTY_ACTIVE ) == true );
+    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( RadioButton::PROPERTY_ACTIVE ) == false );
+  }
+
+  // Select second radio
+  {
+    Dali::Integration::TouchEvent event = Dali::Integration::TouchEvent();
+
+    const Dali::TouchPoint pointDown( 0, TouchPoint::Up, 10.0f, 50.0f );
+    event.AddPoint( pointDown );
+
+    application.ProcessEvent( event );
+
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( RadioButton::PROPERTY_ACTIVE ) == false );
+    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( RadioButton::PROPERTY_ACTIVE ) == true );
+  }
+
+  // Select outside radio group
+  {
+    Dali::Integration::TouchEvent event = Dali::Integration::TouchEvent();
+
+    const Dali::TouchPoint pointDown( 0, TouchPoint::Up, 10.0f, 500.0f );
+    event.AddPoint( pointDown );
+
+    application.ProcessEvent( event );
+
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_CHECK( radioButton2.GetProperty<bool>( RadioButton::PROPERTY_ACTIVE ) == false );
+    DALI_TEST_CHECK( radioButton3.GetProperty<bool>( RadioButton::PROPERTY_ACTIVE ) == true );
+  }
+
+  END_TEST;
+}
index a59c438..d49cbb5 100644 (file)
Binary files a/base/dali-toolkit/images/radio-button-active.png and b/base/dali-toolkit/images/radio-button-active.png differ
index 04b05da..6f647e8 100644 (file)
Binary files a/base/dali-toolkit/images/radio-button-inactive.png and b/base/dali-toolkit/images/radio-button-inactive.png differ
index ec78cba..90a741a 100644 (file)
@@ -47,6 +47,7 @@ BaseHandle Create()
 TypeRegistration typeRegistration( typeid(Toolkit::Button), typeid(Toolkit::Control), Create );
 
 SignalConnectorType signalConnector1( typeRegistration, Toolkit::Button::SIGNAL_CLICKED, &Button::DoConnectSignal );
+SignalConnectorType signalConnector2( typeRegistration, Toolkit::Button::SIGNAL_TOGGLED, &Button::DoConnectSignal );
 
 PropertyRegistration property1( typeRegistration, "dimmed", Toolkit::Button::PROPERTY_DIMMED, Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
 
@@ -106,6 +107,11 @@ Toolkit::Button::ClickedSignalV2& Button::ClickedSignal()
   return mClickedSignalV2;
 }
 
+Toolkit::Button::ToggledSignalV2& Button::ToggledSignal()
+{
+  return mToggledSignalV2;
+}
+
 bool Button::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
 {
   Dali::BaseHandle handle( object );
@@ -117,6 +123,10 @@ bool Button::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tr
   {
     button.ClickedSignal().Connect( tracker, functor );
   }
+  else if( Dali::Toolkit::Button::SIGNAL_TOGGLED == signalName )
+  {
+    button.ToggledSignal().Connect( tracker, functor );
+  }
   else
   {
     // signalName does not match any signal
index e3763e4..2c45d7f 100644 (file)
@@ -144,6 +144,11 @@ public:
   Toolkit::Button::ClickedSignalV2& ClickedSignal();
 
   /**
+   * @copydoc Dali::Toolkit::Button::ToggledSignal()
+   */
+  Toolkit::Button::ToggledSignalV2& ToggledSignal();
+
+  /**
    * Connects a callback function with the object's signals.
    * @param[in] object The object providing the signal.
    * @param[in] tracker Used to disconnect the signal.
@@ -232,6 +237,7 @@ protected: // Signals
   ButtonPainterPtr mPainter;              ///< Pointer to a ButtonPainter base class.
 
   Toolkit::Button::ClickedSignalV2 mClickedSignalV2; ///< Signal emitted when the button is clicked.
+  Toolkit::Button::ToggledSignalV2 mToggledSignalV2; ///< Signal emitted when the button is toggled.
 
   TapGestureDetector mTapDetector;
 };
index ea4909d..e252ea5 100644 (file)
@@ -86,8 +86,8 @@ void CheckBoxButton::SetChecked( bool checked )
     // Notifies the painter the checkbox has been checked.
     GetCheckBoxButtonPainter( mPainter )->Checked( handle );
 
-    // Emit signal.
-    mClickedSignalV2.Emit( handle );
+    // Raise toggled signal
+    mToggledSignalV2.Emit( handle, mChecked );
   }
 }
 
index 9d758b0..34245c2 100644 (file)
@@ -59,9 +59,8 @@ BaseHandle Create()
 
 TypeRegistration typeRegistration( typeid(Toolkit::PushButton), typeid(Toolkit::Button), Create );
 
-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 );
+SignalConnectorType signalConnector1( typeRegistration, Toolkit::PushButton::SIGNAL_PRESSED , &PushButton::DoConnectSignal );
+SignalConnectorType signalConnector2( typeRegistration, Toolkit::PushButton::SIGNAL_RELEASED, &PushButton::DoConnectSignal );
 
 TypeAction action1( typeRegistration, Toolkit::PushButton::ACTION_PUSH_BUTTON_CLICK, &PushButton::DoAction );
 
@@ -356,11 +355,6 @@ Actor& PushButton::GetFadeOutButtonImage()
   return mFadeOutButtonImage;
 }
 
-Toolkit::PushButton::ToggledSignalV2& PushButton::ToggledSignal()
-{
-  return mToggledSignalV2;
-}
-
 Toolkit::PushButton::PressedSignalV2& PushButton::PressedSignal()
 {
   return mPressedSignalV2;
@@ -584,7 +578,7 @@ void PushButton::OnButtonUp()
       // Notifies the painter the button has been toggled.
       GetPushButtonPainter( mPainter )->Toggled( handle );
 
-      //Emit signal.
+      // Emit signal.
       mToggledSignalV2.Emit( handle, mToggled );
     }
     else
index b4acfaf..a021683 100644 (file)
@@ -242,11 +242,6 @@ public:
   // Signals
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::ToggledSignal()
-   */
-  Toolkit::PushButton::ToggledSignalV2& ToggledSignal();
-
-  /**
    * @copydoc Dali::Toolkit::PushButton::PressedSignal()
    */
   Toolkit::PushButton::PressedSignalV2& PressedSignal();
@@ -399,7 +394,6 @@ private:
   bool  mToggled;                   ///< Stores the toggle state.
 
   // Signals
-  Toolkit::PushButton::ToggledSignalV2 mToggledSignalV2;   ///< Signal emitted when the button is toggled.
   Toolkit::PushButton::PressedSignalV2 mPressedSignalV2;   ///< Signal emitted when the button is pressed.
   Toolkit::PushButton::ReleasedSignalV2 mReleasedSignalV2; ///< Signal emitted when the button is released.
 
index 669394a..41e4a6f 100644 (file)
@@ -40,18 +40,15 @@ BaseHandle Create()
   return Toolkit::RadioButton::New();
 }
 
-TypeRegistration typeRegistration(typeid (Toolkit::RadioButton ), typeid (Toolkit::Button ), Create);
+TypeRegistration typeRegistration( typeid( Toolkit::RadioButton ), typeid( Toolkit::Button ), Create);
 
 PropertyRegistration property1(typeRegistration, "active", Toolkit::RadioButton::PROPERTY_ACTIVE, Property::BOOLEAN, &RadioButton::SetProperty, &RadioButton::GetProperty);
 PropertyRegistration property2(typeRegistration, "label-actor", Toolkit::RadioButton::PROPERTY_LABEL_ACTOR, Property::MAP, &RadioButton::SetProperty, &RadioButton::GetProperty);
-}
 
-namespace
-{
 const char* const INACTIVE_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-inactive.png";
 const char* const ACTIVE_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-active.png";
-const Vector3 IMAGE_WIDTH(16.f, 0.f, 0.f);
-const Vector3 DISTANCE_BETWEEN_IMAGE_AND_LABEL(5.f, 0.f, 0.f);
+
+const Vector3 DISTANCE_BETWEEN_IMAGE_AND_LABEL(5.0f, 0.0f, 0.0f);
 }
 
 Dali::Toolkit::RadioButton RadioButton::New()
@@ -70,14 +67,12 @@ Dali::Toolkit::RadioButton RadioButton::New()
 }
 
 RadioButton::RadioButton()
-  : Button(),
-  mActive(false)
+  : mActive(false)
 {
-  mInactiveImage = Dali::Image::New(INACTIVE_BUTTON_IMAGE_DIR);
-  mActiveImage = Dali::Image::New(ACTIVE_BUTTON_IMAGE_DIR);
+  mInactiveImage = Dali::Image::New( INACTIVE_BUTTON_IMAGE_DIR );
+  mActiveImage = Dali::Image::New( ACTIVE_BUTTON_IMAGE_DIR );
 
-  mImageActor = Dali::ImageActor::New(mInactiveImage);
-  mLabel = Actor::New();
+  mRadioIcon = Dali::ImageActor::New( mInactiveImage );
 }
 
 RadioButton::~RadioButton()
@@ -86,23 +81,40 @@ RadioButton::~RadioButton()
 
 void RadioButton::SetLabel(const std::string& label)
 {
-  mLabel.Reset();
-  mLabel = Actor::New();
-
-  Toolkit::TextView textView = Toolkit::TextView::New(label);
-  textView.SetWidthExceedPolicy(Toolkit::TextView::ShrinkToFit); // Make sure our text always fits inside the button
-  textView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+  TextActor textActor = TextActor::DownCast( mLabel );
+  if( textActor )
+  {
+    textActor.SetText( label );
+  }
+  else
+  {
+    Toolkit::TextView newTextView = Toolkit::TextView::New( label );
+    SetLabel( newTextView );
+  }
 
-  mLabel.Add(textView);
+  RelayoutRequest();
 }
 
 void RadioButton::SetLabel(Actor label)
 {
   if( mLabel != label )
   {
-    Self().Remove(mLabel);
+    if( mLabel )
+    {
+      mRadioIcon.Remove( mLabel );
+    }
+
+    if( label )
+    {
+      label.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
+      label.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
+      label.MoveBy( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
+      mRadioIcon.Add( label );
+    }
+
     mLabel = label;
-    Self().Add(mLabel);
+
+    RelayoutRequest();
   }
 }
 
@@ -118,7 +130,6 @@ void RadioButton::SetActive(bool active)
     if( active )
     {
       Actor parent = Self().GetParent();
-
       if( parent )
       {
         for( unsigned int i = 0; i < parent.GetChildCount(); ++i )
@@ -131,14 +142,21 @@ void RadioButton::SetActive(bool active)
           }
         }
       }
+
       mActive = true;
-      mImageActor.SetImage(mActiveImage);
+      mRadioIcon.SetImage(mActiveImage);
     }
     else
     {
       mActive = false;
-      mImageActor.SetImage(mInactiveImage);
+      mRadioIcon.SetImage(mInactiveImage);
     }
+
+    // Raise toggled signal
+    Toolkit::RadioButton handle( GetOwner() );
+    mToggledSignalV2.Emit( handle, mActive );
+
+    RelayoutRequest();
   }
 }
 
@@ -152,39 +170,63 @@ void RadioButton::ToggleState()
   SetActive(!mActive);
 }
 
+void RadioButton::OnRelaidOut( Vector2 /*size*/, ActorSizeContainer& container )
+{
+  Vector3 newSize( mRadioIcon.GetNaturalSize() );
+
+  if( mLabel )
+  {
+    // 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 actorSize( mLabel.GetSize() );
+    newSize.width += actorSize.width;
+    newSize.height = std::max( newSize.height, actorSize.height );
+  }
+
+  Self().SetSize( newSize );
+}
+
 void RadioButton::OnInitialize()
 {
-  mImageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Self().Add(mImageActor);
+  mRadioIcon.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
+  mRadioIcon.SetParentOrigin( ParentOrigin::CENTER_LEFT );
+  Self().Add( mRadioIcon );
 
-  mLabel.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  mLabel.MoveBy(IMAGE_WIDTH + DISTANCE_BETWEEN_IMAGE_AND_LABEL);
-  Self().Add(mLabel);
+  RelayoutRequest();
 }
 
 void RadioButton::OnButtonUp()
 {
-  ToggleState();
+  // Don't allow selection on an already active radio button
+  if( !mActive )
+  {
+    ToggleState();
+  }
 }
 
 void RadioButton::SetProperty(BaseObject* object, Property::Index propertyIndex, const Property::Value& value)
 {
-  Toolkit::RadioButton radioButton = Toolkit::RadioButton::DownCast(Dali::BaseHandle(object));
+  Toolkit::RadioButton radioButton = Toolkit::RadioButton::DownCast( Dali::BaseHandle( object ) );
 
   if( radioButton )
   {
-    RadioButton & radioButtonImpl(GetImplementation(radioButton));
+    RadioButton& radioButtonImpl( GetImplementation( radioButton ) );
 
     switch ( propertyIndex )
     {
       case Toolkit::RadioButton::PROPERTY_ACTIVE:
       {
-        radioButtonImpl.SetActive(value.Get< bool >( ));
+        radioButtonImpl.SetActive( value.Get< bool >( ) );
         break;
       }
       case Toolkit::RadioButton::PROPERTY_LABEL_ACTOR:
       {
-        radioButtonImpl.SetLabel(Scripting::NewActor(value.Get< Property::Map >( )));
+        radioButtonImpl.SetLabel( Scripting::NewActor( value.Get< Property::Map >( ) ) );
         break;
       }
     }
@@ -195,11 +237,11 @@ Property::Value RadioButton::GetProperty(BaseObject* object, Property::Index pro
 {
   Property::Value value;
 
-  Toolkit::RadioButton radioButton = Toolkit::RadioButton::DownCast(Dali::BaseHandle(object));
+  Toolkit::RadioButton radioButton = Toolkit::RadioButton::DownCast( Dali::BaseHandle(object) );
 
   if( radioButton )
   {
-    RadioButton & radioButtonImpl(GetImplementation(radioButton));
+    RadioButton& radioButtonImpl( GetImplementation( radioButton ) );
 
     switch ( propertyIndex )
     {
@@ -211,7 +253,7 @@ Property::Value RadioButton::GetProperty(BaseObject* object, Property::Index pro
       case Toolkit::RadioButton::PROPERTY_LABEL_ACTOR:
       {
         Property::Map map;
-        Scripting::CreatePropertyMap(radioButtonImpl.mLabel, map);
+        Scripting::CreatePropertyMap( radioButtonImpl.mLabel, map );
         value = map;
         break;
       }
@@ -219,4 +261,4 @@ Property::Value RadioButton::GetProperty(BaseObject* object, Property::Index pro
   }
 
   return value;
-}
\ No newline at end of file
+}
index 1ee813f..5afa145 100644 (file)
@@ -102,6 +102,11 @@ class RadioButton: public Button
    */
   void ToggleState();
 
+  /**
+   * @copydoc Dali::Toolkit::Control::OnRelaidOut(Vector2 size, ActorSizeContainer& container)
+   */
+  virtual void OnRelaidOut( Vector2 size, ActorSizeContainer& container );
+
  public:
   // Properties
 
@@ -138,7 +143,7 @@ class RadioButton: public Button
 
   Image mInactiveImage;     ///< Stores the inactive image
   Image mActiveImage;       ///< Stores the active image
-  ImageActor mImageActor;   ///< Stores the current image
+  ImageActor mRadioIcon;   ///< Stores the current image
   Actor mLabel;             ///< Stores the button label
   bool mActive;             ///< Stores the active state
 } ;
@@ -168,4 +173,4 @@ inline const Toolkit::Internal::RadioButton& GetImplementation(const Toolkit::Ra
 } // namespace Toolkit
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_INTERNAL_RADIO_BUTTON_H__
\ No newline at end of file
+#endif // __DALI_TOOLKIT_INTERNAL_RADIO_BUTTON_H__
index 55764a2..cd0bf52 100644 (file)
@@ -30,6 +30,7 @@ namespace Toolkit
 {
 
 const char* const Button::SIGNAL_CLICKED = "clicked";
+const char* const Button::SIGNAL_TOGGLED = "toggled";
 
 Button::Button()
 {}
@@ -82,6 +83,11 @@ Button::ClickedSignalV2& Button::ClickedSignal()
   return Dali::Toolkit::GetImplementation( *this ).ClickedSignal();
 }
 
+Button::ToggledSignalV2& Button::ToggledSignal()
+{
+  return Dali::Toolkit::GetImplementation( *this ).ToggledSignal();
+}
+
 Button::Button( Internal::Button& implementation )
 : Control( implementation )
 {
index 8d95226..980ddbd 100644 (file)
@@ -53,6 +53,7 @@ public:
 
   // Signal Names
   static const char* const SIGNAL_CLICKED; ///< name "clicked"
+  static const char* const SIGNAL_TOGGLED; ///< name "toggled"
 
   // Properties
   static const Property::Index PROPERTY_DIMMED; ///< name "dimmed", @see SetDimmed(), type BOOLEAN
@@ -131,10 +132,20 @@ public: //Signals
   typedef SignalV2< bool ( Button ) > ClickedSignalV2;
 
   /**
+   * @brief Button toggled signal type
+   */
+  typedef SignalV2< bool ( Button, bool ) > ToggledSignalV2;
+
+  /**
    * @brief Signal emitted when the button is touched and the touch point doesn't leave the boundary of the button.
    */
   ClickedSignalV2& ClickedSignal();
 
+  /**
+   * @brief Signal emitted when the button's state is toggled.
+   */
+  ToggledSignalV2& ToggledSignal();
+
 public: // Not intended for application developers
 
   /**
index 24da5ee..f6e2775 100644 (file)
@@ -29,7 +29,6 @@ namespace Dali
 namespace Toolkit
 {
 
-const char* const PushButton::SIGNAL_TOGGLED = "toggled";
 const char* const PushButton::SIGNAL_PRESSED = "pressed";
 const char* const PushButton::SIGNAL_RELEASED = "released";
 
@@ -219,11 +218,6 @@ Actor PushButton::GetLabelText() const
   return Dali::Toolkit::GetImplementation( *this ).GetLabelText();
 }
 
-PushButton::ToggledSignalV2& PushButton::ToggledSignal()
-{
-  return Dali::Toolkit::GetImplementation( *this ).ToggledSignal();
-}
-
 PushButton::PressedSignalV2& PushButton::PressedSignal()
 {
   return Dali::Toolkit::GetImplementation( *this ).PressedSignal();
index 5bebddd..658dbae 100644 (file)
@@ -80,7 +80,6 @@ class PushButton : public Button
 public:
 
   //Signal Names
-  static const char* const SIGNAL_TOGGLED; ///< name "toggled"
   static const char* const SIGNAL_PRESSED; ///< name "pressed"
   static const char* const SIGNAL_RELEASED; ///< name "released"
 
@@ -333,9 +332,6 @@ public:
 
 public: //Signals
 
-  /// @brief PushButton Toggled signal type.
-  typedef SignalV2< bool ( Button, bool ) > ToggledSignalV2;
-
   /// @brief PushButton Pressed signal type.
   typedef SignalV2< bool ( Button ) > PressedSignalV2;
 
@@ -343,11 +339,6 @@ public: //Signals
   typedef SignalV2< bool ( Button ) > ReleasedSignalV2;
 
   /**
-   * @brief Signal emitted when the \e toggle property is set and the button is touched.
-   */
-  ToggledSignalV2& ToggledSignal();
-
-  /**
    * @brief Signal emitted when the button is touched.
    */
   PressedSignalV2& PressedSignal();
index 37f3860..23c370b 100644 (file)
@@ -41,7 +41,7 @@ class RadioButton;
  *
  * Radio buttons are designed to select one of many option at the same time.
  *
- * Every button have its own \e label and \e state, which can be modified by RadioButton::SetLabel and RadioBUtton::SetActive.
+ * Every button have its own \e label and \e state, which can be modified by RadioButton::SetLabel and RadioButton::SetActive.
  *
  * RadioButton can change its current state using RadioButton::ToggleState.
  *
@@ -177,7 +177,8 @@ class RadioButton: public Button
    * @param[in]  internal  A pointer to the internal CustomActor.
    */
   RadioButton(Dali::Internal::CustomActor* internal);
-} ;
+
+};
 
 } // namespace Toolkit