Merge "Fix SWIG C# Build" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 14 Dec 2016 15:56:31 +0000 (07:56 -0800)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Wed, 14 Dec 2016 15:56:32 +0000 (07:56 -0800)
32 files changed:
automated-tests/src/dali-toolkit-internal/CMakeLists.txt
automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp [deleted file]
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-application.h
automated-tests/src/dali-toolkit/utc-Dali-Button.cpp
automated-tests/src/dali-toolkit/utc-Dali-CheckBoxButton.cpp
automated-tests/src/dali-toolkit/utc-Dali-PushButton.cpp
automated-tests/src/dali-toolkit/utc-Dali-RadioButton.cpp
build/tizen/dali-toolkit/Makefile.am
dali-toolkit/devel-api/controls/buttons/button-devel.h [new file with mode: 0644]
dali-toolkit/devel-api/file.list
dali-toolkit/internal/builder/builder-impl.cpp
dali-toolkit/internal/controls/buttons/button-impl.cpp
dali-toolkit/internal/controls/buttons/button-impl.h
dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp
dali-toolkit/internal/controls/buttons/check-box-button-impl.h
dali-toolkit/internal/controls/buttons/push-button-impl.cpp
dali-toolkit/internal/controls/buttons/push-button-impl.h
dali-toolkit/internal/controls/buttons/radio-button-impl.cpp
dali-toolkit/internal/controls/buttons/radio-button-impl.h
dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp
dali-toolkit/internal/visuals/text/text-visual.cpp
dali-toolkit/internal/visuals/visual-factory-impl.cpp
dali-toolkit/public-api/controls/buttons/button.cpp
dali-toolkit/public-api/controls/buttons/button.h
dali-toolkit/public-api/controls/buttons/push-button.cpp
dali-toolkit/public-api/controls/buttons/push-button.h
dali-toolkit/public-api/controls/control-impl.cpp
dali-toolkit/styles/1920x1080/dali-toolkit-default-theme.json
dali-toolkit/styles/480x800/dali-toolkit-default-theme.json
dali-toolkit/styles/720x1280/dali-toolkit-default-theme.json
dali-toolkit/styles/images-common/checkbox-selected-disabled.png [moved from dali-toolkit/styles/images-common/checkbox-selected-diabled.png with 100% similarity]

index a4a8ae7..20d76c0 100644 (file)
@@ -7,7 +7,6 @@ SET(CAPI_LIB "dali-toolkit-internal")
 
 # List of test case sources (Only these get parsed for test cases)
 SET(TC_SOURCES
- utc-Dali-PushButton.cpp
  utc-Dali-Text-CharacterSetConversion.cpp
  utc-Dali-Text-Cursor.cpp
  utc-Dali-Text-Segmentation.cpp
diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp
deleted file mode 100644 (file)
index edaf7fd..0000000
+++ /dev/null
@@ -1,718 +0,0 @@
-/*
- * 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/internal/controls/buttons/push-button-impl.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 Toolkit;
-
-namespace
-{
-
-static bool gPushButtonSelectedState = false;
-bool PushButtonSelected( Button button, bool selected )
-{
-  gPushButtonSelectedState = selected && ( selected == static_cast<PushButton&>( button ).IsSelected() );
-  return true;
-}
-
-
-Dali::Integration::Point GetPointDownInside()
-{
-  Dali::Integration::Point point;
-  point.SetState( PointState::DOWN );
-  point.SetScreenPosition( Vector2( 240, 400 ) );
-  return point;
-}
-
-Dali::Integration::Point GetPointUpInside()
-{
-  Dali::Integration::Point point;
-  point.SetState( PointState::UP );
-  point.SetScreenPosition( Vector2( 240, 400 ) );
-  return point;
-}
-
-Dali::Integration::Point GetPointMotionOut()
-{
-  Dali::Integration::Point point;
-  point.SetState( PointState::MOTION );
-  point.SetScreenPosition( Vector2( 10, 10 ) );
-  return point;
-}
-
-Dali::Integration::Point GetPointUpOutside()
-{
-  Dali::Integration::Point point;
-  point.SetState( PointState::UP );
-  point.SetScreenPosition( Vector2( 10, 10 ) );
-  return point;
-}
-
-} // namespace
-
-
-//////////////////////////////////////////////////////////
-
-namespace
-{
-static bool gOnTouchPointInterrupted = false;
-} //namespace
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-class TETButton;
-}
-
-/**
- * Creates a PushButton to test if interrupt events are handled correctly.
- */
-class TETButton : public PushButton
-{
-public:
-  // PushButton Pressed
-  typedef Signal< bool ( PushButton ) > ButtonSignalType;
-
-  ButtonSignalType& PressedSignal();
-
-  /**
-   * Default constructor.
-   */
-  TETButton();
-
-  /**
-   * Copy constructor.
-   */
-  TETButton( const PushButton& button );
-
-  /**
-   * Assignment operator.
-   */
-  TETButton& operator=( const TETButton& button );
-
-  /**
-   * Creates and initializes a new button.
-   */
-  static TETButton New();
-
-  /**
-   * Down cast to TETButton.
-   */
-  static TETButton DownCast( BaseHandle handle );
-
-  /**
-   * Creates a handle using the Toolkit::Internal implementation.
-   * @param[in]  implementation  The Control implementation.
-   */
-  TETButton( Internal::TETButton& implementation );
-
-  /**
-   * Allows the creation of this Control from an Internal::CustomActor pointer.
-   * @param[in]  internal  A pointer to the internal CustomActor.
-   */
-  TETButton( Dali::Internal::CustomActor* internal );
-};
-
-namespace Internal
-{
-
-/**
- * Internal implementation
- */
-class TETButton : public PushButton
-{
-public:
-  /**
-   * Construct a new Button.
-   */
-  TETButton();
-
-  /**
-   * A reference counted object may only be deleted by calling Unreference()
-   */
-  virtual ~TETButton();
-
-  /**
-   * Creates an internal button.
-   */
-  static Toolkit::TETButton New();
-
-  /**
-   * @return the pressed signal.
-   */
-  Toolkit::TETButton::ButtonSignalType& PressedSignal();
-
-  /**
-   * Callback called when an interrupt events is received.
-   */
-  void OnTouchPointInterrupted();
-
-  /**
-   * Callback received when a down event is received.
-   */
-  void OnButtonDown();
-
-  Toolkit::TETButton::ButtonSignalType mPressedSignal;   ///< Signal emitted when the button is pressed.
-};
-
-} // namespace Internal
-
-TETButton::TETButton()
-{
-}
-
-TETButton::TETButton( const PushButton& button )
-: PushButton( button )
-{
-}
-
-TETButton& TETButton::operator=( const TETButton& button )
-{
-  if( &button != this )
-  {
-    PushButton::operator=( button );
-  }
-  return *this;
-}
-
-TETButton TETButton::New()
-{
-  return Internal::TETButton::New();
-}
-
-TETButton TETButton::DownCast( BaseHandle handle )
-{
-  return Control::DownCast<TETButton, Internal::TETButton>(handle);
-}
-
-TETButton::ButtonSignalType& TETButton::PressedSignal()
-{
-  TETButton button( *this );
-  DALI_ASSERT_ALWAYS( button );
-
-  Dali::RefObject& handle = button.GetImplementation();
-
-  return static_cast<Toolkit::Internal::TETButton&>( handle ).PressedSignal();
-}
-
-TETButton::TETButton( Internal::TETButton& implementation )
-: PushButton( implementation )
-{}
-
-TETButton::TETButton( Dali::Internal::CustomActor* internal )
-: PushButton( internal )
-{
-  VerifyCustomActorPointer<Internal::TETButton>(internal);
-}
-
-namespace Internal
-{
-
-TETButton::TETButton()
-: PushButton(),
-  mPressedSignal()
-{
-}
-
-TETButton::~TETButton()
-{
-}
-
-Toolkit::TETButton TETButton::New()
-{
-  // Create the implementation, temporarily owned on stack
-  IntrusivePtr< TETButton > internalTETButton = new TETButton();
-
-  // Pass ownership to CustomActor
-  Dali::Toolkit::TETButton tetButton( *internalTETButton );
-
-  // Second-phase init of the implementation
-  // This can only be done after the CustomActor connection has been made...
-  internalTETButton->Initialize();
-
-  return tetButton;
-}
-
-Toolkit::TETButton::ButtonSignalType& TETButton::PressedSignal()
-{
-  return mPressedSignal;
-}
-
-void TETButton::OnButtonDown()
-{
-  Toolkit::TETButton handle( GetOwner() );
-
-  //Emit signal.
-  mPressedSignal.Emit( handle );
-}
-
-void TETButton::OnTouchPointInterrupted()
-{
-  gOnTouchPointInterrupted = true;
-}
-
-} // namespace Internal
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-namespace
-{
-
-class TETButtonPressed : public Dali::ConnectionTracker
-{
-public:
-  enum Test
-  {
-    SENSITIVENESS,
-    VISIBILITY
-  };
-
-  TETButtonPressed( Actor actor, Test test )
-  : mActor( actor ),
-    mTest( test )
-  {
-  }
-
-  bool Callback( PushButton button )
-  {
-    switch( mTest )
-    {
-      case SENSITIVENESS:
-      {
-        mActor.SetSensitive( false );
-        break;
-      }
-      case VISIBILITY:
-      {
-        std::cout <<"VISIBILITY false" << std::endl;
-        mActor.SetVisible( false );
-        break;
-      }
-      default:
-      {
-        break;
-      }
-    }
-    return true;
-  }
-
-  Actor mActor;
-  Test mTest;
-};
-
-static bool TestCallback(Actor actor, const TouchData& event)
-{
-  return true;
-}
-
-} // namespace
-
-//////////////////////////////////////////////////////////
-
-int UtcDaliPushButtonDownCast(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliPushButtonDownCast");
-
-  TETButton tetButton= Toolkit::TETButton::New();
-
-  BaseHandle object(tetButton);
-
-  TETButton tetButton2 = TETButton::DownCast( object );
-  DALI_TEST_CHECK(tetButton2);
-
-  TETButton tetButton3 = DownCast< TETButton >(object);
-  DALI_TEST_CHECK(tetButton3);
-  END_TEST;
-}
-
-int UtcDaliPushButtonInterruptEventWhenInsensitive(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliPushButtonInterruptEventWhenInsensitive");
-
-  // * Creates an actor which contains a button.
-  // * The size of the actor is bigger than the button.
-  // * The button's boundary is contained in the actor's one.
-  Actor actor = Actor::New();
-  TETButton tetButton= Toolkit::TETButton::New();
-
-  actor.SetName( "Actor" );
-  tetButton.SetName( "TETButton" );
-
-  actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  actor.SetPosition( 0, 0 );
-  actor.SetSize( 400, 800 );
-
-  tetButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  tetButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  tetButton.SetPosition( 240, 400 );
-  tetButton.SetSize( 100, 100 );
-
-  actor.Add( tetButton );
-  Stage::GetCurrent().Add( actor );
-
-  // * Actor's touch event is connected to a callback function
-  //   and this callback function consumes the event.
-  actor.TouchSignal().Connect( &TestCallback );
-
-  // * Button's pressed signal is connected to a callback function
-  //   which also consumes the event.
-  // * Changes the sensitiveness of the button to false.
-  TETButtonPressed tetButtonPressed( actor, TETButtonPressed::SENSITIVENESS );
-  tetButton.PressedSignal().Connect( &tetButtonPressed, &TETButtonPressed::Callback );
-
-  // Initializes TET state.
-  gOnTouchPointInterrupted = false;
-  tetButton.SetSensitive( true );
-
-  Dali::Integration::TouchEvent event;
-
-  // TET starts.
-
-  // Test a down point inside the button which is also consumed by the actor, and an up point
-  // consumed only by the actor.  gOnTouchPointInterrupted should be true (Button receives an
-  // interrupt event.
-
-  application.SendNotification();
-  application.Render();
-
-  // A down event is sent inside the button's boundary.
-
-  event = Dali::Integration::TouchEvent();
-  event.AddPoint( GetPointDownInside() );
-
-  // flush the queue and render once
-  application.SendNotification();
-  application.Render();
-  application.ProcessEvent( event );
-
-  // An up event is sent outside the button's boundary but inside the actor's one.
-
-  event = Dali::Integration::TouchEvent();
-  event.AddPoint( GetPointUpOutside() );
-
-  // flush the queue and render once
-  application.SendNotification();
-  application.Render();
-  application.ProcessEvent( event );
-
-  DALI_TEST_CHECK( gOnTouchPointInterrupted );
-
-  // Test a down point inside the button which is also consumed by the actor, and a motion point
-  // consumed only by the actor.  gOnTouchPointInterrupted should be true (Button receives an
-  // interrupt event.
-
-  // Initializes TET state.
-  gOnTouchPointInterrupted = false;
-  actor.SetSensitive( true );
-  tetButton.SetSensitive( true );
-
-  application.SendNotification();
-  application.Render();
-
-  // A down event is sent inside the button's boundary.
-
-  event = Dali::Integration::TouchEvent();
-  event.AddPoint( GetPointDownInside() );
-
-  // flush the queue and render once
-  application.SendNotification();
-  application.Render();
-  application.ProcessEvent( event );
-
-  // A motion event is sent outside the button's boundary but inside the actor's one.
-
-  event = Dali::Integration::TouchEvent();
-  event.AddPoint( GetPointMotionOut() );
-
-  // flush the queue and render once
-  application.SendNotification();
-  application.Render();
-  application.ProcessEvent( event );
-
-  DALI_TEST_CHECK( gOnTouchPointInterrupted );
-
-  // Test a down point inside the button which is also consumed by the actor, and an up point
-  // also inside the button and consumed by the actor.  gOnTouchPointInterrupted should be false.
-
-  // Initializes TET state.
-  gOnTouchPointInterrupted = false;
-  actor.SetSensitive( true );
-  tetButton.SetSensitive( true );
-
-  // A down event is sent inside the button's boundary.
-
-  event = Dali::Integration::TouchEvent();
-  event.AddPoint( GetPointDownInside() );
-
-  // flush the queue and render once
-  application.SendNotification();
-  application.Render();
-  application.ProcessEvent( event );
-
-  actor.SetSensitive( true );
-  // An up event is sent inside the button's boundary.
-
-  event = Dali::Integration::TouchEvent();
-  event.AddPoint( GetPointUpInside() );
-
-  // flush the queue and render once
-  application.SendNotification();
-  application.Render();
-  application.ProcessEvent( event );
-
-  DALI_TEST_CHECK( !gOnTouchPointInterrupted );
-  END_TEST;
-}
-
-int UtcDaliPushButtonInterruptEventWhenNonVisible(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline(" UtcDaliPushButtonInterruptEventWhenNonVisible");
-
-  // Does same test as above but changing the visibility instead the sensitiveness.
-
-  // * Creates an actor which contains a button.
-  // * The size of the actor is bigger than the button.
-  // * The button's boundary is contained in the actor's one.
-  Actor actor = Actor::New();
-  TETButton tetButton = Toolkit::TETButton::New();
-
-  actor.SetName( "Actor" );
-  tetButton.SetName( "TETButton" );
-
-  actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  actor.SetPosition( 0, 0 );
-  actor.SetSize( 400, 800 );
-
-  tetButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  tetButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
-  tetButton.SetPosition( 240, 400 );
-  tetButton.SetSize( 100, 100 );
-
-  actor.Add( tetButton );
-  Stage::GetCurrent().Add( actor );
-
-  // * Actor's touch event is connected to a callback function
-  //   and this callback function consumes the event.
-  actor.TouchSignal().Connect( &TestCallback );
-
-  // * Button's pressed signal is connected to a callback function
-  //   which also consumes the event.
-  // * Changes the visibility of the button to false.
-  TETButtonPressed tetButtonPressed( tetButton, TETButtonPressed::VISIBILITY );
-  tetButton.PressedSignal().Connect( &tetButtonPressed, &TETButtonPressed::Callback );
-
-  // Initializes TET state.
-  gOnTouchPointInterrupted = false;
-  tetButton.SetVisible( true );
-
-  Dali::Integration::TouchEvent event;
-
-  // TET starts.
-
-  // Test a down point inside the button which is also consumed by the actor, and an up point
-  // consumed only by the actor.  gOnTouchPointInterrupted should be true (Button receives an
-  // interrupt event.
-
-  application.SendNotification();
-  application.Render();
-
-  // A down event is sent inside the button's boundary.
-
-  event = Dali::Integration::TouchEvent();
-  event.AddPoint( GetPointDownInside() );
-
-  // flush the queue and render once
-  application.SendNotification();
-  application.Render();
-  application.ProcessEvent( event );
-
-  // More renders are needed in order to allow the node of the actor to become invisible.
-  application.SendNotification();
-  application.Render();
-  application.SendNotification();
-  application.Render();
-  application.SendNotification();
-  application.Render();
-
-  // An up event is sent outside the button's boundary but inside the actor's one.
-
-  event = Dali::Integration::TouchEvent();
-  event.AddPoint( GetPointUpOutside() );
-
-  // flush the queue and render once
-  application.SendNotification();
-  application.Render();
-  application.ProcessEvent( event );
-
-  DALI_TEST_CHECK( gOnTouchPointInterrupted );
-
-  // Test a down point inside the button which is also consumed by the actor, and a motion point
-  // consumed only by the actor.  gOnTouchPointInterrupted should be true (Button receives an
-  // interrupt event.
-
-  // Initializes TET state.
-  gOnTouchPointInterrupted = false;
-  tetButton.SetVisible( true );
-
-  application.SendNotification();
-  application.Render();
-  application.SendNotification();
-  application.Render();
-  application.SendNotification();
-  application.Render();
-
-  // A down event is sent inside the button's boundary.
-
-  event = Dali::Integration::TouchEvent();
-  event.AddPoint( GetPointDownInside() );
-
-  // flush the queue and render once
-  application.SendNotification();
-  application.Render();
-  application.ProcessEvent( event );
-
-  // More renders are needed in order to allow the node of the actor to become invisible.
-  application.SendNotification();
-  application.Render();
-  application.SendNotification();
-  application.Render();
-  application.SendNotification();
-  application.Render();
-
-  // A motion event is sent outside the button's boundary but inside the actor's one.
-
-  event = Dali::Integration::TouchEvent();
-  event.AddPoint( GetPointMotionOut() );
-
-  // flush the queue and render once
-  application.SendNotification();
-  application.Render();
-  application.ProcessEvent( event );
-
-  DALI_TEST_CHECK( gOnTouchPointInterrupted );
-
-  // Test a down point inside the button which is also consumed by the actor, and an up point
-  // also inside the button and consumed by the actor.  gOnTouchPointInterrupted should be false.
-
-  // Initializes TET state.
-  gOnTouchPointInterrupted = false;
-  tetButton.SetVisible( true );
-
-  application.SendNotification();
-  application.Render();
-  application.SendNotification();
-  application.Render();
-  application.SendNotification();
-  application.Render();
-
-  // A down event is sent inside the button's boundary.
-
-  event = Dali::Integration::TouchEvent();
-  event.AddPoint( GetPointDownInside() );
-
-  // flush the queue and render once
-  application.SendNotification();
-  application.Render();
-  application.ProcessEvent( event );
-
-  tetButton.SetVisible( true );
-
-  application.SendNotification();
-  application.Render();
-  application.SendNotification();
-  application.Render();
-  application.SendNotification();
-  application.Render();
-
-  // An up event is sent inside the button's boundary.
-
-  event = Dali::Integration::TouchEvent();
-  event.AddPoint( GetPointUpInside() );
-
-  // flush the queue and render once
-  application.SendNotification();
-  application.Render();
-  application.ProcessEvent( event );
-
-  DALI_TEST_CHECK( !gOnTouchPointInterrupted );
-  END_TEST;
-}
-
-int UtcDaliPushButtonProperties(void)
-{
-  ToolkitTestApplication application;
-
-  PushButton button = PushButton::New();
-  Stage::GetCurrent().Add( button );
-
-  // Button::PROPERTY_AUTO_REPEATING
-  button.SetAutoRepeating( false );
-  DALI_TEST_CHECK( ! button.GetProperty< bool >( Button::Property::AUTO_REPEATING ) );
-  button.SetProperty( Button::Property::AUTO_REPEATING, true );
-  DALI_TEST_CHECK( button.IsAutoRepeating() ) ;
-  DALI_TEST_CHECK( button.GetProperty< bool >( Button::Property::AUTO_REPEATING ) );
-
-  // Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY
-  button.SetInitialAutoRepeatingDelay( 10.0f );
-  DALI_TEST_EQUALS( 10.0f, button.GetProperty< float >( Button::Property::INITIAL_AUTO_REPEATING_DELAY ), TEST_LOCATION );
-  button.SetProperty( Button::Property::INITIAL_AUTO_REPEATING_DELAY, 25.0f );
-  DALI_TEST_EQUALS( 25.0f, button.GetInitialAutoRepeatingDelay(), TEST_LOCATION );
-  DALI_TEST_EQUALS( 25.0f, button.GetProperty< float >( Button::Property::INITIAL_AUTO_REPEATING_DELAY ), TEST_LOCATION );
-
-  //  Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY
-  button.SetNextAutoRepeatingDelay( 3.0f );
-  DALI_TEST_EQUALS( 3.0f, button.GetProperty< float >( Button::Property::NEXT_AUTO_REPEATING_DELAY ), TEST_LOCATION );
-  button.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, 4.0f );
-  DALI_TEST_EQUALS( 4.0f, button.GetNextAutoRepeatingDelay(), TEST_LOCATION );
-  DALI_TEST_EQUALS( 4.0f, button.GetProperty< float >( Button::Property::NEXT_AUTO_REPEATING_DELAY ), TEST_LOCATION );
-
-  //  Button::PROPERTY_TOGGLABLE
-  button.SetTogglableButton( false );
-  DALI_TEST_CHECK( ! button.GetProperty< bool >( Button::Property::TOGGLABLE ) );
-  button.SetProperty( Button::Property::TOGGLABLE, true );
-  DALI_TEST_CHECK( button.IsTogglableButton() ) ;
-  DALI_TEST_CHECK( button.GetProperty< bool >( Button::Property::TOGGLABLE ) );
-
-  //  Button::PROPERTY_SELECTED
-  button.SetSelected( false );
-  DALI_TEST_CHECK( ! button.GetProperty< bool >( Button::Property::SELECTED ) );
-  button.SetProperty( Button::Property::SELECTED, true );
-  DALI_TEST_CHECK( button.IsSelected() ) ;
-  DALI_TEST_CHECK( button.GetProperty< bool >( Button::Property::SELECTED ) );
-
-  END_TEST;
-}
index e8d9be4..d89d4d2 100644 (file)
@@ -221,5 +221,17 @@ void TestApplication::ResetContext()
   mCore->ContextCreated();
 }
 
+unsigned int TestApplication::Wait( unsigned int durationToWait )
+{
+  int time = 0;
+
+  for(unsigned int i = 0; i <= ( durationToWait / RENDER_FRAME_INTERVAL); i++)
+  {
+    SendNotification();
+    Render(RENDER_FRAME_INTERVAL);
+    time += RENDER_FRAME_INTERVAL;
+  }
+  return time;
+}
 
 } // Namespace dali
index 49a7f51..c5ecc4f 100644 (file)
@@ -48,6 +48,8 @@ public:
 
   static const unsigned int DEFAULT_RENDER_INTERVAL = 1;
 
+  static const unsigned int RENDER_FRAME_INTERVAL = 16;
+
   TestApplication( size_t surfaceWidth  = DEFAULT_SURFACE_WIDTH,
                    size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
                    float  horizontalDpi = DEFAULT_HORIZONTAL_DPI,
@@ -80,6 +82,7 @@ public:
   bool RenderOnly( );
   void ResetContext();
   bool GetRenderNeedsUpdate();
+  unsigned int Wait( unsigned int durationToWait );
 
 private:
   void DoUpdate( unsigned int intervalMilliseconds, const char* location=NULL );
index ead898d..a2bf49d 100644 (file)
 // Need to override adaptor classes for toolkit test harness, so include
 // test harness headers before dali headers.
 #include <dali-toolkit-test-suite-utils.h>
+#include "dali-toolkit-test-utils/toolkit-timer.h"
 
 #include <dali.h>
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali/integration-api/events/touch-event-integ.h>
 
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
+
 using namespace Dali;
 using namespace Toolkit;
 
@@ -42,8 +47,12 @@ void utc_dali_toolkit_button_cleanup(void)
 
 namespace
 {
+static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
+
 static bool gIsCalledButtonCallback = false;
 
+const int RENDER_FRAME_INTERVAL = 16;
+
 static bool ButtonCallback( Button button )
 {
   gIsCalledButtonCallback = true;
@@ -112,8 +121,8 @@ Dali::Integration::Point GetPointUpOutside()
   return point;
 }
 
-
 static float ANIMATION_TIME( 0.5f );
+
 } // namespace
 
 int UtcDaliButtonConstructorP(void)
@@ -205,6 +214,70 @@ int UtcDaliButtonSetDisabledP(void)
   END_TEST;
 }
 
+int UtcDaliButtonSetDisabledWithDifferentStates01P(void)
+{
+  ToolkitTestApplication application;
+
+  tet_infoline("UtcDaliButtonSetDisabledWithDifferentStates01P\n");
+
+  Button button = PushButton::New();
+
+  bool SELECTED = true;
+
+  button.SetProperty( Button::Property::TOGGLABLE, true);
+  button.SetProperty( Button::Property::SELECTED, SELECTED );
+
+  button.SetProperty( Button::Property::DISABLED, true);
+
+  tet_infoline("Set button to SELECTED = false whilst disabled, should not change to false\n");
+  button.SetProperty( Button::Property::SELECTED, !SELECTED );
+
+  bool isSelected = button.GetProperty<bool>( Button::Property::SELECTED ) ;
+
+  DALI_TEST_EQUALS( isSelected, SELECTED , TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliButtonSetDisabledWithDifferentStates02P(void)
+{
+  ToolkitTestApplication application;
+
+  tet_infoline("UtcDaliButtonSetDisabledWithDifferentStates02\n");
+
+  Button button = PushButton::New();
+
+  bool SELECTED = true;
+
+  button.SetProperty( Button::Property::TOGGLABLE, true );
+  button.SetProperty( Button::Property::SELECTED, SELECTED );
+  button.SetProperty( Button::Property::DISABLED, true );
+
+  bool isSelected =  button.GetProperty<bool>( Button::Property::SELECTED );
+  DALI_TEST_EQUALS( isSelected, SELECTED , TEST_LOCATION );
+  tet_infoline("Set button to DISABLED = false whilst disabled and then set to unselected\n");
+
+  button.SetProperty( Button::Property::DISABLED, false );
+  button.SetProperty( Button::Property::SELECTED, !SELECTED );
+
+  isSelected = button.GetProperty<bool>( Button::Property::SELECTED );
+  DALI_TEST_EQUALS( isSelected, !SELECTED , TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliButtonPropertyGetLabelAlignment(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliPushButtonPropertyGetLabelAlignment\n");
+
+  Button button = PushButton::New();
+  button.SetProperty( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT, "END"  );
+  DALI_TEST_EQUALS( button.GetProperty<std::string>( Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT ), "END", TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliButtonIsDisabledP(void)
 {
   ToolkitTestApplication application;
@@ -261,6 +334,66 @@ int UtcDaliButtonIsAutoRepeatingP(void)
   END_TEST;
 }
 
+int UtcDaliButtonAutoRepeatingP(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliButtonPressedSignalP  Setup Autorepeating and check multiple clicked signals received\n");
+
+  const float AUTO_REPEATING_DELAY = 0.15f;
+
+  Button button = PushButton::New();
+  button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  button.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  button.SetPosition( 240, 400 );
+  button.SetSize( 100, 100 );
+  Stage::GetCurrent().Add( button );
+
+  application.SendNotification();
+  application.Render();
+
+  button.SetProperty( Toolkit::Button::Property::AUTO_REPEATING, true  );
+  button.SetProperty( Toolkit::Button::Property::INITIAL_AUTO_REPEATING_DELAY, AUTO_REPEATING_DELAY );
+  // connect to its touch signal
+  ConnectionTracker* testTracker = new ConnectionTracker();
+  button.PressedSignal().Connect( &ButtonCallback );
+  button.ClickedSignal().Connect( &ButtonCallback );
+  bool clickedSignal = false;
+  bool pressedSignal = false;
+  button.ConnectSignal( testTracker, "pressed", CallbackFunctor(&pressedSignal) );
+  button.ConnectSignal( testTracker, "clicked", CallbackFunctor(&clickedSignal) );
+
+  Dali::Integration::TouchEvent event;
+
+  // Touch point down and up inside the button.
+
+  gIsCalledButtonCallback = false;
+  event = Dali::Integration::TouchEvent();
+  event.AddPoint( GetPointDownInside() );
+  application.ProcessEvent( event );
+
+  DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
+  DALI_TEST_EQUALS( pressedSignal, true, TEST_LOCATION );
+  tet_infoline("Consume first clicked signal then wait\n");
+
+  gIsCalledButtonCallback = false;
+  Dali::Timer timer = Timer::New( AUTO_REPEATING_DELAY );
+  timer.MockEmitSignal();
+  application.Wait( AUTO_REPEATING_DELAY*2 );
+  DALI_TEST_EQUALS( clickedSignal, true, TEST_LOCATION );
+  tet_infoline("Check gIsCalledButtonCallback was called again after last consumption of it.\n");
+
+  DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
+
+  gIsCalledButtonCallback = false;
+  event = Dali::Integration::TouchEvent();
+  event.AddPoint( GetPointUpInside() );
+  application.ProcessEvent( event );
+
+  DALI_TEST_EQUALS( gIsCalledButtonCallback, true, TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliButtonSetInitialAutoRepeatingDelayP(void)
 {
   ToolkitTestApplication application;
@@ -287,7 +420,7 @@ int UtcDaliButtonSetNextAutoRepeatingDelayP(void)
 
   DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.5f, TEST_LOCATION );
 
-  button.SetNextAutoRepeatingDelay( 0.2f );
+  button.SetProperty( Button::Property::NEXT_AUTO_REPEATING_DELAY, 0.2f );
 
   DALI_TEST_EQUALS( button.GetNextAutoRepeatingDelay(), 0.2f, TEST_LOCATION );
   END_TEST;
@@ -344,6 +477,10 @@ int UtcDaliButtonSetLabelStringP(void)
   ToolkitTestApplication application;
 
   Button button = PushButton::New();
+  button.SetProperty( Toolkit::Button::Property::LABEL,
+                      Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+                                     .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+                     );
 
   button.SetLabelText( "Button Label" );
 
@@ -351,15 +488,37 @@ int UtcDaliButtonSetLabelStringP(void)
   END_TEST;
 }
 
-int UtcDaliButtonSetLabelActorP(void)
+int UtcDaliButtonSetLabelPropertyP(void)
 {
   ToolkitTestApplication application;
 
+  const std::string TEST_LABEL1 = "test label one";
+  const std::string TEST_LABEL2 = "test label two";
+
   Button button = PushButton::New();
 
-  button.SetLabelText( "Button Label" );
+  button.SetProperty( Toolkit::Button::Property::LABEL,
+                        Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+                                       .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+                     );
+
+  button.SetProperty( Button::Property::LABEL_TEXT, TEST_LABEL1 );
+
+  std::string labelText = button.GetProperty<std::string>( Button::Property::LABEL_TEXT );
+
+  DALI_TEST_EQUALS( labelText, TEST_LABEL1,  TEST_LOCATION );
+
+  Property::Map propertyMap;
+  propertyMap.Insert( Toolkit::Visual::Property::TYPE,  Toolkit::DevelVisual::TEXT );
+  propertyMap.Insert( Toolkit::TextVisual::Property::TEXT,  TEST_LABEL2 );
+  propertyMap.Insert( Toolkit::TextVisual::Property::TEXT_COLOR, Color::BLUE );
+  propertyMap.Insert( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
+  button.SetProperty( Button::Property::LABEL, propertyMap );
+
+  labelText = button.GetProperty<std::string>( Button::Property::LABEL_TEXT );
+
+  DALI_TEST_EQUALS( labelText, TEST_LABEL2,  TEST_LOCATION );
 
-  DALI_TEST_EQUALS( button.GetLabelText(), "Button Label", TEST_LOCATION );
   END_TEST;
 }
 
@@ -374,16 +533,12 @@ int UtcDaliButtonSetUnselectedImageP(void)
   application.SendNotification();
   application.Render();
 
-  pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
   pushButton.SetUnselectedImage( "Image.jpg" );
 
   application.SendNotification();
   application.Render();
 
-  Vector3 size = pushButton.GetCurrentSize();
-
-  DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION );
-  DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION );
+  DALI_TEST_CHECK( pushButton );
 
   END_TEST;
 }
@@ -399,16 +554,12 @@ int UtcDaliButtonSetSelectedImageP(void)
   application.SendNotification();
   application.Render();
 
-  pushButton.SetSize( Vector2( 20.0f, 20.0f ) );
   pushButton.SetSelectedImage( "Image.jpg" );
 
   application.SendNotification();
   application.Render();
 
-  Vector3 size = pushButton.GetCurrentSize();
-
-  DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION );
-  DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION );
+  DALI_TEST_CHECK( pushButton );
 
   END_TEST;
 }
@@ -803,7 +954,7 @@ int UtcDaliButtonSetDisabledSelectedImageN(void)
   END_TEST;
 }
 
-int UtcDaliButtonSetLabelP(void)
+int UtcDaliButtonSetLabeActorlP(void)
 {
   ToolkitTestApplication application;
 
@@ -851,14 +1002,26 @@ int UtcDaliButtonSetButtonImageP(void)
 
   try
   {
-    button.SetButtonImage( CreateBufferImage( 10, 10, Color::WHITE ) );
-    DALI_TEST_CHECK( ImageView::DownCast( button.GetButtonImage() ) );
+    ResourceImage image1 = ResourceImage::New( TEST_IMAGE_ONE );
+    button.SetButtonImage( image1 );
+
+    Property::Value value = button.GetProperty(Button::Property::UNSELECTED_STATE_IMAGE );
+    DALI_TEST_CHECK( value.Get<std::string>() == TEST_IMAGE_ONE );
   }
   catch(...)
   {
     DALI_TEST_CHECK( false );
   }
 
+  std::string imageUrl;
+
+  Dali::Actor actor = button.GetButtonImage();
+
+  Toolkit::ImageView imageView = Toolkit::ImageView ::DownCast( actor );
+
+  tet_infoline(" UtcDaliButtonSetButtonImageP Ensure an ImageView is returned\n");
+  DALI_TEST_CHECK ( imageView )
+
   END_TEST;
 }
 
@@ -870,7 +1033,9 @@ int UtcDaliButtonSetButtonImageN(void)
 
   try
   {
-    button.SetButtonImage( CreateBufferImage( 10, 10, Color::WHITE ) );
+    ResourceImage image1 = ResourceImage::New( TEST_IMAGE_ONE );
+    button.SetButtonImage( image1 );
+
     DALI_TEST_CHECK( false );
   }
   catch(...)
@@ -887,17 +1052,27 @@ int UtcDaliButtonSetSelectedImageWithImageP(void)
 
   PushButton button = PushButton::New();
   Stage::GetCurrent().Add( button );
+  ResourceImage image1 = ResourceImage::New( TEST_IMAGE_ONE );
 
   try
   {
-    button.SetSelectedImage( CreateBufferImage( 10, 10, Color::WHITE ) );
-    DALI_TEST_CHECK( ImageView::DownCast( button.GetSelectedImage() ) );
+    button.SetSelectedImage( image1 );
+    Property::Value value = button.GetProperty( Button::Property::SELECTED_STATE_IMAGE );
+    DALI_TEST_CHECK( value.Get<std::string>() == TEST_IMAGE_ONE );
   }
   catch(...)
   {
     DALI_TEST_CHECK( false );
   }
 
+  std::string imageUrl;
+
+  Dali::Actor actor = button.GetSelectedImage();
+
+  Toolkit::ImageView imageView = Toolkit::ImageView::DownCast( actor );
+
+  tet_infoline(" UtcDaliButtonSetSelectedImageWithImageP Ensure an ImageView is returned\n");
+
   END_TEST;
 }
 
@@ -1007,3 +1182,59 @@ int UtcDaliButtonResetSelectedColorP(void)
 
   END_TEST;
 }
+
+int UtcDaliButtonSetImagesWithDeprecatedProperties(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliButtonSetImagesWithDeprecatedProperties");
+
+  PushButton pushButton = PushButton::New();
+
+  Stage::GetCurrent().Add( pushButton );
+
+  Property::Map propertyMap;
+  propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
+  propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
+
+  DALI_TEST_EQUALS( pushButton.GetRendererCount(), 0, TEST_LOCATION );
+
+  pushButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, propertyMap );
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1, TEST_LOCATION );
+
+  tet_infoline(" Set state to selected and provide SELECTED visual");
+  pushButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, propertyMap );
+  pushButton.SetProperty( Toolkit::Button::Property::SELECTED, true );
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1, TEST_LOCATION );
+
+  tet_infoline(" Set state to selected, disabled and provide DISABLED_STATE_IMAGE visual");
+  pushButton.SetProperty( Toolkit::Button::Property::SELECTED, false );
+  pushButton.SetProperty( Toolkit::Button::Property::DISABLED, true );
+  pushButton.SetProperty( Toolkit::Button::Property::DISABLED_STATE_IMAGE, propertyMap );
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1, TEST_LOCATION );
+
+END_TEST;
+}
+
+int UtcDaliButtonSetGetDepreciatedPropertiesWithURL(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" UtcDaliButtonSetGetDepreciatedPropertiesWithURL");
+
+  PushButton button = PushButton::New();
+  Stage::GetCurrent().Add( button );
+
+  tet_infoline(" Set state to selected, disabled and provide DISABLED_STATE_IMAGE visual");
+  button.SetProperty( Toolkit::Button::Property::DISABLED, true );
+  button.SetProperty( Toolkit::Button::Property::DISABLED_STATE_IMAGE, TEST_IMAGE_ONE );
+
+  Property::Value value = button.GetProperty(Button::Property::DISABLED_STATE_IMAGE );
+  DALI_TEST_EQUALS( value.Get<std::string>(),  TEST_IMAGE_ONE, TEST_LOCATION );
+
+END_TEST;
+}
index 07b810f..c67b2ae 100644 (file)
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
 
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
+
+
 using namespace Dali;
 using namespace Toolkit;
 
@@ -33,6 +38,10 @@ bool CheckBoxButtonClicked( Button button )
   return true;
 }
 
+static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
+const Vector2 TEST_IMAGE_SIZE = Vector2( 66.0f, 66.0f );
+
+
 } // namespace
 
 void checkbox_button_startup(void)
@@ -155,11 +164,14 @@ int UtcDaliCheckBoxSetLabelP(void)
   CheckBoxButton checkBox = CheckBoxButton::New();
 
   Property::Map propertyMap;
-  propertyMap.Insert("text",  "activate");
+
+  propertyMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+             .Add( Toolkit::TextVisual::Property::TEXT, "activate" )
+             .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
+
   checkBox.SetProperty( checkBox.GetPropertyIndex("label"), propertyMap );
 
   DALI_TEST_EQUALS( checkBox.GetLabelText(), "activate", TEST_LOCATION ); // Change to use GerProperty once that code is implemented
-
   END_TEST;
 }
 
@@ -177,13 +189,16 @@ int UtcDaliCheckBoxSetLabelDisabledP(void)
   application.Render();
 
   Property::Map propertyMap;
-  propertyMap.Insert("text",  "activate");
-  checkBox.SetProperty(checkBox.GetPropertyIndex("disabled"), true);
 
+  propertyMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+             .Add( Toolkit::TextVisual::Property::TEXT, "activate" )
+             .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
+
+  checkBox.SetProperty(checkBox.GetPropertyIndex("disabled"), true);
   checkBox.SetProperty( checkBox.GetPropertyIndex("label"), propertyMap );
 
   DALI_TEST_CHECK(  checkBox.GetProperty<bool>(checkBox.GetPropertyIndex("disabled")) );
-  DALI_TEST_EQUALS( checkBox.GetLabelText(), "activate", TEST_LOCATION ); // Change to use GerProperty once that code is implemented
+  DALI_TEST_EQUALS( checkBox.GetLabelText(), "activate", TEST_LOCATION ); // Change to use GetProperty once that code is implemented
 
   END_TEST;
 }
@@ -203,3 +218,100 @@ int UtcDaliCheckBoxSettingDisabled(void)
 
   END_TEST;
 }
+
+int UtcDaliCheckBoxSetLabelPadding(void)
+{
+  tet_infoline("UtcDaliCheckBoxSetLabelPadding\n");
+
+  ToolkitTestApplication application;
+
+  CheckBoxButton checkBox = CheckBoxButton::New();
+
+  Property::Map propertyMap;
+
+  propertyMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+             .Add( Toolkit::TextVisual::Property::TEXT, "activate" )
+             .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
+
+  checkBox.SetProperty( Toolkit::DevelButton::Property::LABEL, propertyMap );
+
+  application.SendNotification();
+  application.Render();
+
+  Vector3 orginalSize = checkBox.GetNaturalSize();
+
+  checkBox.SetProperty( Toolkit::DevelButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
+
+  application.SendNotification();
+  application.Render();
+
+  Vector3 paddingAddedSize = checkBox.GetNaturalSize();
+
+  DALI_TEST_EQUALS( checkBox.GetProperty<Vector4>( Toolkit::DevelButton::Property::LABEL_PADDING ), Vector4( 10.0f, 10.0f, 10.0f, 10.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  tet_infoline("Comparing original size of button with just text and button size with text and padding\n");
+
+  DALI_TEST_EQUALS( orginalSize.width +10.0f + 10.0f , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  DALI_TEST_EQUALS( orginalSize.height +10.0f + 10.0f , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliCheckBoxSetForegroundPadding(void)
+{
+  tet_infoline("UtcDaliCheckBoxSetForegroundPadding\n");
+
+  ToolkitTestApplication application;
+
+  CheckBoxButton checkBox = CheckBoxButton::New();
+
+  Property::Map propertyMap;
+
+  propertyMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+             .Add( Toolkit::TextVisual::Property::TEXT, "activate" )
+             .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
+
+  checkBox.SetProperty( Toolkit::DevelButton::Property::LABEL, propertyMap );
+  checkBox.SetProperty( Toolkit::DevelButton::Property::LABEL_PADDING, Vector4( 5.0f, 5.0f, 5.0f, 5.0f ) );
+
+  application.SendNotification();
+  application.Render();
+
+  tet_printf( "Button RelayoutSize with text(%f,%f)\n", checkBox.GetNaturalSize().width, checkBox.GetNaturalSize().height );
+
+  TestPlatformAbstraction& platform = application.GetPlatform();
+  platform.SetClosestImageSize( TEST_IMAGE_SIZE );
+
+  checkBox.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, TEST_IMAGE_ONE );
+  checkBox.SetProperty( Toolkit::DevelButton::Property::SELECTED_VISUAL, TEST_IMAGE_ONE );
+
+
+  application.SendNotification();
+  application.Render();
+
+  Vector3 preVisualPaddingSize = checkBox.GetNaturalSize();
+
+  tet_printf( "Button RelayoutSize with text and icon (%f,%f)\n", checkBox.GetNaturalSize().width, checkBox.GetNaturalSize().height );
+
+  checkBox.SetProperty( Toolkit::DevelButton::Property::VISUAL_PADDING, Vector4( 25.0f, 25.0f, 25.0f, 25.0f ) );
+
+  application.SendNotification();
+  application.Render();
+
+  Vector3 paddingAddedSize = checkBox.GetNaturalSize();
+
+  tet_printf( "Button RelayoutSize with text, icon and padding (%f,%f)\n", checkBox.GetNaturalSize().width, checkBox.GetNaturalSize().height );
+
+  DALI_TEST_EQUALS( checkBox.GetProperty<Vector4>( Toolkit::DevelButton::Property::VISUAL_PADDING ), Vector4( 25.0f, 25.0f, 25.0f, 25.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  tet_infoline("Comparing original size of button before adding padding to visual foreground\n");
+
+  DALI_TEST_GREATER( paddingAddedSize.width, preVisualPaddingSize.width , TEST_LOCATION );
+
+  tet_infoline("Text and Visual are side by side, visual height and padding must be greater than text height and padding for this test\n");
+
+  DALI_TEST_GREATER( paddingAddedSize.height, preVisualPaddingSize.height , TEST_LOCATION );
+
+  END_TEST;
+}
index a191f43..5ae6ee7 100644 (file)
 #include <dali/integration-api/events/touch-event-integ.h>
 #include <dali-toolkit/dali-toolkit.h>
 
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
+
 using namespace Dali;
 using namespace Toolkit;
 
@@ -41,6 +45,7 @@ void utc_dali_toolkit_pushbutton_cleanup(void)
 
 namespace
 {
+static const char* TEST_IMAGE_ONE = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
 
 static bool gPushButtonSelectedState = false;
 bool PushButtonSelected( Button button )
@@ -211,6 +216,29 @@ int UtcDaliPushButtonSetGetAutoRepeating(void)
   END_TEST;
 }
 
+int UtcDaliPushButtonSetAutoRepeating(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliPushButtonSetAutoRepeating\n");
+  tet_infoline("Ensure setting AutoRepeating on a SELECTED Toggle button switches off Toggle\n");
+  PushButton pushButton = PushButton::New();
+
+  const bool INITIAL_TOGGLE_VALUE = true;
+  const bool INITIAL_SELECTED_VALUE = true;
+
+  pushButton.SetProperty( Button::Property::TOGGLABLE, INITIAL_TOGGLE_VALUE);
+  pushButton.SetProperty( Button::Property::SELECTED, INITIAL_SELECTED_VALUE );
+
+  DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE  ), INITIAL_TOGGLE_VALUE , TEST_LOCATION );
+  DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::SELECTED  ), INITIAL_SELECTED_VALUE , TEST_LOCATION );
+
+  pushButton.SetProperty( Button::Property::AUTO_REPEATING, true );
+
+  DALI_TEST_EQUALS( pushButton.GetProperty<bool>( Button::Property::TOGGLABLE ), !INITIAL_TOGGLE_VALUE , TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliPushButtonSetGetTogglableButton(void)
 {
   ToolkitTestApplication application;
@@ -373,6 +401,11 @@ int UtcDaliPushButtonSetLabelText(void)
 
   PushButton pushButton = PushButton::New();
 
+  pushButton.SetProperty( Toolkit::Button::Property::LABEL,
+                          Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+                                         .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+                        );
+
   application.SendNotification();
   application.Render();
 
@@ -572,7 +605,7 @@ int UtcDaliPushButtonSelected(void)
   DALI_TEST_CHECK( !gPushButtonSelectedState );
 
   // Test4. Touch point down inside and up outside the button.
-
+  //        State changes on Button down
   gPushButtonSelectedState = false;
   event = Dali::Integration::TouchEvent();
   event.AddPoint( GetPointDownInside() );
@@ -586,9 +619,12 @@ int UtcDaliPushButtonSelected(void)
   event.AddPoint( GetPointUpOutside() );
   application.ProcessEvent( event );
 
-  DALI_TEST_CHECK( !gPushButtonSelectedState );
+  DALI_TEST_CHECK( gPushButtonSelectedState );
 
   // Test5. Touch point down outside and up inside the button.
+  // Start in unselected state
+  pushButton.SetProperty( Button::Property::SELECTED, false );
+  DALI_TEST_CHECK( !pushButton.IsSelected());
 
   gPushButtonSelectedState = false;
   event = Dali::Integration::TouchEvent();
@@ -661,8 +697,9 @@ int UtcDaliPushButtonPaddingLayout(void)
   // The icon and label are each enabled and disabled to confirm the correct padding is used.
   PushButton pushButton = PushButton::New();
 
-  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
-  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 20.0f, 20.0f, 20.0f, 20.0f ) );
+  const Vector4 TEST_ICON_PADDING( 20.0f, 20.0f, 20.0f, 20.0f );
+  const Vector4 TEST_LABEL_PADDING( 10.0f, 10.0f, 10.0f ,10.0f );
+  const Vector2 TEST_IMAGE_SIZE = Vector2( 5.0f, 5.0f);
 
   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
@@ -679,29 +716,40 @@ int UtcDaliPushButtonPaddingLayout(void)
   Vector2 size( Vector2::ZERO );
   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+  tet_printf( "Button Natural Size(%f,%f)\n", pushButton.GetNaturalSize().width, pushButton.GetNaturalSize().height );
 
   DALI_TEST_EQUALS( size, Vector2::ZERO, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
 
-  // Check label only padding.
+  // Check label only padding
   pushButton.SetLabelText( "Label" );
 
   application.SendNotification();
   application.Render();
 
-  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
-  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+  Vector2 sizeWithLabelWithoutPadding( Vector2::ZERO );
+  sizeWithLabelWithoutPadding.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  sizeWithLabelWithoutPadding.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+
+  tet_printf( "Button RelayoutSize label without padding (%f,%f)\n", sizeWithLabelWithoutPadding.width, sizeWithLabelWithoutPadding.height );
 
-  // We should not test against the exact label size, we just make sure it is larger than our label padding so we know the padding has been applied.
-  DALI_TEST_GREATER( size.width, 20.0f, TEST_LOCATION );
-  DALI_TEST_GREATER( size.height, 20.0f, TEST_LOCATION );
+  // Add label padding to label
+  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
+  application.SendNotification();
+  application.Render();
+
+  Vector2 sizeLabelAndPadding( Vector2::ZERO );
+  sizeLabelAndPadding.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  sizeLabelAndPadding.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+  tet_printf( "Button RelayoutSize after label padding(%f,%f)\n", sizeLabelAndPadding.width, sizeLabelAndPadding.height );
+
+  // If control size has increased beyond size of just label then padding has been applied
+  DALI_TEST_GREATER( sizeLabelAndPadding.width, sizeWithLabelWithoutPadding.width+TEST_LABEL_PADDING.x, TEST_LOCATION );
+  DALI_TEST_GREATER( sizeLabelAndPadding.height, sizeWithLabelWithoutPadding.height+TEST_LABEL_PADDING.w, TEST_LOCATION );
 
   // Re-initialise the button so we can setup icon-only padding.
   pushButton.Unparent();
   pushButton = PushButton::New();
 
-  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 10.0f, 10.0f, 10.0f, 10.0f ) );
-  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 20.0f, 20.0f, 20.0f, 20.0f ) );
-
   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
   pushButton.SetPosition( 0.0f, 0.0f );
@@ -709,32 +757,53 @@ int UtcDaliPushButtonPaddingLayout(void)
 
   Stage::GetCurrent().Add( pushButton );
 
-  const char* INVALID_IMAGE_FILE_NAME = "invalid-image.jpg";
+  TestPlatformAbstraction& platform = application.GetPlatform();
+  platform.SetClosestImageSize( TEST_IMAGE_SIZE );
+
   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "RIGHT" );
-  pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, INVALID_IMAGE_FILE_NAME );
-  pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, INVALID_IMAGE_FILE_NAME );
+  pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, TEST_IMAGE_ONE );
+  pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, TEST_IMAGE_ONE );
 
   application.SendNotification();
   application.Render();
 
+  // Size of button with just icon
   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+  tet_printf( "Button RelayoutSize with icon(%f,%f)\n", size.width, size.height );
+
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, TEST_ICON_PADDING );
+
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( size, TEST_IMAGE_SIZE, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
 
-  DALI_TEST_EQUALS( size, Vector2( 40.0f, 40.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+  tet_printf( "Button RelayoutSize after icon padding(%f,%f)\n", size.width, size.height );
+  const Vector2 expectedIconAndPaddingSize( TEST_ICON_PADDING.x+TEST_ICON_PADDING.y+TEST_IMAGE_SIZE.width, TEST_ICON_PADDING.w+TEST_ICON_PADDING.z +TEST_IMAGE_SIZE.height );
+  DALI_TEST_EQUALS( size, expectedIconAndPaddingSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
 
   // Now test padding for both label and icon simultaneously.
   pushButton.SetLabelText( "Label" );
+  application.SendNotification();
+  application.Render();
+
+  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+  tet_printf( "Button RelayoutSize after label added(%f,%f)\n", size.width, size.height );
+
+  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
 
   application.SendNotification();
   application.Render();
 
   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+  tet_printf( "Button RelayoutSize after icon and label padding(%f,%f)\n", size.width, size.height );
 
-  // We should not test against the exact label size, we just make sure it is larger than our label padding so we know the padding has been applied.
-  // Note we only test the width as we are horizontally aligned and the label my be less high than the icon.
-  // Full directional alignment tests are done in UtcDaliPushButtonAlignmentLayout.
-  DALI_TEST_GREATER( size.width, 60.0f, TEST_LOCATION );
+  DALI_TEST_EQUALS( size.width, sizeLabelAndPadding.width + expectedIconAndPaddingSize.width, TEST_LOCATION );
+  DALI_TEST_GREATER( size.height, expectedIconAndPaddingSize.width, TEST_LOCATION ); // Test height of control is greater than icon and padding. As Text set to larger values.
 
   END_TEST;
 }
@@ -769,10 +838,12 @@ int UtcDaliPushButtonAlignmentLayout(void)
    * |         |   v     +------------+   -
    * +---------+   -
    */
-  PushButton pushButton = PushButton::New();
 
-  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 30.0f, 30.0f, 30.0f, 30.0f ) );
-  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, Vector4( 75.0f, 75.0f, 75.0f, 75.0f ) );
+  const Vector4 TEST_ICON_PADDING( 70.0f, 70.0f, 70.0f, 70.0f );
+  const Vector4 TEST_LABEL_PADDING( 30.0f, 30.0f, 30.0f, 30.0f );
+  const Vector2 TEST_IMAGE_SIZE = Vector2( 10.0f, 10.0f);
+
+  PushButton pushButton = PushButton::New();
 
   pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
   pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
@@ -781,23 +852,43 @@ int UtcDaliPushButtonAlignmentLayout(void)
 
   Stage::GetCurrent().Add( pushButton );
 
-  const char* INVALID_IMAGE_FILE_NAME = "invalid-image.jpg";
-  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "RIGHT" );
-  pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, INVALID_IMAGE_FILE_NAME );
-  pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, INVALID_IMAGE_FILE_NAME );
+  // Add a label and get size of control
+  pushButton.SetLabelText( "Label" );
+  application.SendNotification();
+  application.Render();
 
+  // First get the size of control with just label
+  Vector2 justLabelSize( Vector2::ZERO );
+  justLabelSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  justLabelSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+  tet_printf( "Button RelayoutSize with just label and no padding(%f,%f)\n", justLabelSize.width, justLabelSize.height );
+
+  pushButton.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, TEST_LABEL_PADDING );
   application.SendNotification();
   application.Render();
 
-  // First get the base size (without label).
-  Vector2 baseSize( Vector2::ZERO );
-  baseSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
-  baseSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+  // Size of Label and Padding
+  Vector2 expectedLabelAndPaddingSize( Vector2::ZERO );
+  expectedLabelAndPaddingSize.width = justLabelSize.width + TEST_LABEL_PADDING.x + TEST_LABEL_PADDING.y;
+  expectedLabelAndPaddingSize.height = justLabelSize.height + TEST_LABEL_PADDING.w + TEST_LABEL_PADDING.z;
 
-  DALI_TEST_EQUALS( baseSize, Vector2( 150.0f, 150.0f ), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+  Vector2 labelAndPaddingSize( Vector2::ZERO );
+  labelAndPaddingSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  labelAndPaddingSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
 
-  // Add a label to cause size to be modified in the direction of alignment.
-  pushButton.SetLabelText( "Label" );
+  DALI_TEST_EQUALS( labelAndPaddingSize, expectedLabelAndPaddingSize , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+
+  const Vector2 testImageWithPaddingSize = Vector2 ( ( TEST_IMAGE_SIZE.width + TEST_ICON_PADDING.x + TEST_ICON_PADDING.y ),
+                                                     ( TEST_IMAGE_SIZE.height + TEST_ICON_PADDING.w + TEST_ICON_PADDING.z ) );
+
+  TestPlatformAbstraction& platform = application.GetPlatform();
+  platform.SetClosestImageSize( TEST_IMAGE_SIZE );
+
+  // Add Icon and set its alignment
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "RIGHT" );
+  pushButton.SetProperty( Toolkit::PushButton::Property::UNSELECTED_ICON, TEST_IMAGE_ONE );
+  pushButton.SetProperty( Toolkit::PushButton::Property::SELECTED_ICON, TEST_IMAGE_ONE );
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_PADDING, TEST_ICON_PADDING );
 
   application.SendNotification();
   application.Render();
@@ -806,7 +897,6 @@ int UtcDaliPushButtonAlignmentLayout(void)
   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
 
-
   /*
    * Test Icon right alignment.
    * Height grows to largest of Icon or Label (+ padding).
@@ -820,8 +910,8 @@ int UtcDaliPushButtonAlignmentLayout(void)
    *  |............+         |
    *  +------------+---------+
    */
-  DALI_TEST_GREATER( size.width, 150.0f + 60.0f, TEST_LOCATION );
-  DALI_TEST_EQUALS( size.height, 150.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+  DALI_TEST_EQUALS( size.width, ( testImageWithPaddingSize.width + labelAndPaddingSize.width ) , TEST_LOCATION );
+  DALI_TEST_EQUALS( size.height, ( std::max( testImageWithPaddingSize.height, labelAndPaddingSize.height) ) , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
 
   // Now test left alignment matches right for size.
   pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "LEFT" );
@@ -829,9 +919,8 @@ int UtcDaliPushButtonAlignmentLayout(void)
   application.SendNotification();
   application.Render();
 
-  Vector2 compareSize( Vector2::ZERO );
-  compareSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
-  compareSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
 
   /*
    * Test Icon left alignment.
@@ -846,20 +935,11 @@ int UtcDaliPushButtonAlignmentLayout(void)
    *  |         +............|
    *  +---------+------------+
    */
-  DALI_TEST_EQUALS( size, compareSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-
-  // Test top alignment.
-  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "TOP" );
-
-  application.SendNotification();
-  application.Render();
-
-  compareSize.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
-  compareSize.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+  DALI_TEST_EQUALS( size.width, ( testImageWithPaddingSize.width + labelAndPaddingSize.width ) , TEST_LOCATION );
+  DALI_TEST_EQUALS( size.height, ( std::max( testImageWithPaddingSize.height, labelAndPaddingSize.height) ) , Math::MACHINE_EPSILON_1000, TEST_LOCATION );
 
+  tet_infoline(" Test Icon TOP alignment - Width grows to largest of Icon or label (plus padding)");
   /*
-   * Test Icon top alignment.
-   * Width grows to largest of Icon or Label (+ padding).
    *
    *  +---------+
    *  |         |
@@ -873,13 +953,10 @@ int UtcDaliPushButtonAlignmentLayout(void)
    *  |         |
    *  +---------+
    *
-   *  Note: We subtract a small number as we want to do a >= test.
    */
-  DALI_TEST_GREATER( size.width, 150.0f - Math::MACHINE_EPSILON_1000, TEST_LOCATION );
-  DALI_TEST_GREATER( compareSize.height, 150.0f + 60.0f, TEST_LOCATION );
 
-  // Test bottom alignment.
-  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "BOTTOM" );
+  tet_infoline("SetProperty on ICON_ALIGNMENT should relayout the Button");
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "TOP" );
 
   application.SendNotification();
   application.Render();
@@ -887,6 +964,16 @@ int UtcDaliPushButtonAlignmentLayout(void)
   size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
   size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
 
+  tet_printf("Natural width (%f)\n",pushButton.GetNaturalSize().width);
+  tet_printf("Natural height (%f)\n",pushButton.GetNaturalSize().height);
+
+  tet_printf(" UtcDaliPushButtonAlignmentLayout Top layout - Image and Padding size (%f,%f)\n", testImageWithPaddingSize.width, testImageWithPaddingSize.height );
+  tet_printf(" UtcDaliPushButtonAlignmentLayout Top layout - Text and Padding size (%f,%f)\n", labelAndPaddingSize.width, labelAndPaddingSize.height );
+
+  DALI_TEST_EQUALS( size.width, ( std::max( testImageWithPaddingSize.width, labelAndPaddingSize.width ) ) , TEST_LOCATION );
+
+  DALI_TEST_EQUALS( size.height,( testImageWithPaddingSize.height + labelAndPaddingSize.height ) , TEST_LOCATION );
+
   /*
    * Test Icon bottom alignment.
    * Width grows to largest of Icon or Label (+ padding).
@@ -903,90 +990,118 @@ int UtcDaliPushButtonAlignmentLayout(void)
    *  |         |
    *  +---------+
    */
-  DALI_TEST_EQUALS( size, compareSize, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+  tet_infoline(" Test Icon BOTTOM alignment - Width grows to largest of Icon or label (plus padding)");
+  pushButton.SetProperty( Toolkit::PushButton::Property::ICON_ALIGNMENT, "BOTTOM" );
+
+  application.SendNotification();
+  application.Render();
+
+  size.width = pushButton.GetRelayoutSize( Dimension::WIDTH );
+  size.height = pushButton.GetRelayoutSize( Dimension::HEIGHT );
+
+  DALI_TEST_EQUALS( size.width, ( std::max(testImageWithPaddingSize.width, labelAndPaddingSize.width )) , TEST_LOCATION );
+  DALI_TEST_EQUALS( size.height,( testImageWithPaddingSize.height + labelAndPaddingSize.height ) , TEST_LOCATION );
 
   END_TEST;
 }
 
-int UtcDaliPushButtonSetButtonImageP(void)
+int UtcDaliPushButtonSetUnSelectedVisual01P(void)
 {
+  tet_infoline(" Test adding a visual for the UNSELECTED_VISUAL property, removing Button from stage and counting renderers\n");
   ToolkitTestApplication application;
 
-  PushButton button = PushButton::New();
-  Stage::GetCurrent().Add( button );
+  PushButton pushButton = PushButton::New();
+  pushButton.SetSize(100.0f, 100.0f);
 
-  try
-  {
-    button.SetButtonImage( ImageView::New() );
-    DALI_TEST_CHECK( true );
-  }
-  catch(...)
-  {
-    DALI_TEST_CHECK( false );
-  }
+  Stage::GetCurrent().Add( pushButton );
 
-  END_TEST;
-}
+  Property::Map propertyMap;
+  propertyMap.Insert(Visual::Property::TYPE,  Visual::COLOR);
+  propertyMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLUE);
 
-int UtcDaliPushButtonSetButtonImageN(void)
-{
-  ToolkitTestApplication application;
+  pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, propertyMap );
 
-  PushButton button;
+  tet_infoline(" UNSELECTED_VISUAL Added to button\n");
 
-  try
-  {
-    button.SetSelectedImage( ImageView::New() );
-    DALI_TEST_CHECK( false );
-  }
-  catch(...)
-  {
-    DALI_TEST_CHECK( true );
-  }
+  application.SendNotification();
+  application.Render(0);
 
-  END_TEST;
-}
+  unsigned int rendererCount = pushButton.GetRendererCount();
+  tet_printf("After adding UNSELECTED_BACKGROUND_VISUAL the renderer count is(%d)\n", rendererCount );
 
-int UtcDaliPushButtonSetBackgroundImageP(void)
-{
-  ToolkitTestApplication application;
+  DALI_TEST_EQUALS( pushButton.GetRendererCount(), 1 , TEST_LOCATION );
 
-  PushButton button = PushButton::New();
-  Stage::GetCurrent().Add( button );
+  tet_printf("Remove button from stage\n" );
 
-  try
-  {
-    button.SetBackgroundImage( ImageView::New() );
-    DALI_TEST_CHECK( true );
-  }
-  catch(...)
-  {
-    DALI_TEST_CHECK( false );
-  }
+  Stage::GetCurrent().Remove( pushButton );
+
+  rendererCount = pushButton.GetRendererCount();
+  tet_printf("After removing pushbutton from stage the renderer count is(%d)\n ", rendererCount );
+
+  DALI_TEST_EQUALS( pushButton.GetRendererCount(), 0, TEST_LOCATION );
+
+  tet_printf("After removing pushbutton from stage the renderer count is(%d)\n ", rendererCount );
+
+  Property::Map propertyMap2;
+  propertyMap2.Insert(Visual::Property::TYPE,  Visual::COLOR);
+  propertyMap2.Insert(ColorVisual::Property::MIX_COLOR, Color::RED);
+  pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, propertyMap2 );
+
+  tet_printf("Added UNSELECTED_VISUAL and add button back to Stage\n");
+
+  Stage::GetCurrent().Add( pushButton );
+
+  tet_printf("With UNSELECTED_BACKGROUND_VISUAL and UNSELECTED_ICON the renderer count is(%d)\n", pushButton.GetRendererCount() );
+
+  DALI_TEST_EQUALS( pushButton.GetRendererCount(), 2, TEST_LOCATION );
 
   END_TEST;
 }
 
-int UtcDaliPushButtonSetBackgroundImageN(void)
+int UtcDaliPushButtonSetSelectedVisualN(void)
 {
+  tet_infoline(" Test adding a broken visual for the UNSELECTED_VISUAL property");
+
   ToolkitTestApplication application;
 
-  PushButton button;
+  PushButton pushButton = PushButton::New();
 
-  try
-  {
-    button.SetBackgroundImage( ImageView::New() );
-    DALI_TEST_CHECK( false );
-  }
-  catch(...)
-  {
-    DALI_TEST_CHECK( true );
-  }
+  pushButton.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+  pushButton.SetParentOrigin( ParentOrigin::TOP_LEFT );
+  pushButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+
+  Stage::GetCurrent().Add( pushButton );
+  application.SendNotification();
+  application.Render(0);
+
+  unsigned int preRendererCount = pushButton.GetRendererCount();
+  tet_printf("RendererCount prior to adding visual(%d)\n",preRendererCount);
+  DALI_TEST_EQUALS( preRendererCount, 0, TEST_LOCATION );
+
+  Stage::GetCurrent().Remove( pushButton );
+  application.SendNotification();
+  application.Render(0);
+
+  Property::Map colorMap;
+  const int BROKEN_VISUAL_TYPE = 999999999;
+
+  colorMap.Insert(Visual::Property::TYPE,  BROKEN_VISUAL_TYPE);
+  colorMap.Insert(BorderVisual::Property::COLOR,  Color::BLUE);
+  colorMap.Insert(BorderVisual::Property::SIZE,  5.f);
+  pushButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, colorMap );
+
+  Stage::GetCurrent().Add( pushButton );
+  application.SendNotification();
+  application.Render(0);
+
+  unsigned int postRendererCount  = pushButton.GetRendererCount();
+  tet_printf("RendererCount post broken visual (%d)\n", postRendererCount);
+  DALI_TEST_EQUALS( postRendererCount, 0, TEST_LOCATION );
 
   END_TEST;
 }
 
-int UtcDaliPushButtonSetSelectedImageP(void)
+int UtcDaliPushButtonSetButtonImageP(void)
 {
   ToolkitTestApplication application;
 
@@ -995,7 +1110,7 @@ int UtcDaliPushButtonSetSelectedImageP(void)
 
   try
   {
-    button.SetSelectedImage( ImageView::New() );
+    button.SetButtonImage( ImageView::New() );
     DALI_TEST_CHECK( true );
   }
   catch(...)
@@ -1006,26 +1121,27 @@ int UtcDaliPushButtonSetSelectedImageP(void)
   END_TEST;
 }
 
-int UtcDaliPushButtonSetSelectedImageN(void)
+int UtcDaliPushButtonSetBackgroundImageP(void)
 {
   ToolkitTestApplication application;
 
-  PushButton button;
+  PushButton button = PushButton::New();
+  Stage::GetCurrent().Add( button );
 
   try
   {
-    button.SetSelectedImage( ImageView::New() );
-    DALI_TEST_CHECK( false );
+    button.SetBackgroundImage( ImageView::New() );
+    DALI_TEST_CHECK( true );
   }
   catch(...)
   {
-    DALI_TEST_CHECK( true );
+    DALI_TEST_CHECK( false );
   }
 
   END_TEST;
 }
 
-int UtcDaliPushButtonSetSelectedBackgroundImageP(void)
+int UtcDaliPushButtonSetSelectedImageP(void)
 {
   ToolkitTestApplication application;
 
@@ -1034,7 +1150,7 @@ int UtcDaliPushButtonSetSelectedBackgroundImageP(void)
 
   try
   {
-    button.SetSelectedBackgroundImage( ImageView::New() );
+    button.SetSelectedImage( ImageView::New() );
     DALI_TEST_CHECK( true );
   }
   catch(...)
@@ -1045,20 +1161,21 @@ int UtcDaliPushButtonSetSelectedBackgroundImageP(void)
   END_TEST;
 }
 
-int UtcDaliPushButtonSetSelectedBackgroundImageN(void)
+int UtcDaliPushButtonSetSelectedBackgroundImageP(void)
 {
   ToolkitTestApplication application;
 
-  PushButton button;
+  PushButton button = PushButton::New();
+  Stage::GetCurrent().Add( button );
 
   try
   {
     button.SetSelectedBackgroundImage( ImageView::New() );
-    DALI_TEST_CHECK( false );
+    DALI_TEST_CHECK( true );
   }
   catch(...)
   {
-    DALI_TEST_CHECK( true );
+    DALI_TEST_CHECK( false );
   }
 
   END_TEST;
@@ -1084,24 +1201,6 @@ int UtcDaliPushButtonSetDisabledBackgroundImageP(void)
   END_TEST;
 }
 
-int UtcDaliPushButtonSetDisabledBackgroundImageN(void)
-{
-  ToolkitTestApplication application;
-
-  PushButton button;
-
-  try
-  {
-    button.SetDisabledBackgroundImage( ImageView::New() );
-    DALI_TEST_CHECK( false );
-  }
-  catch(...)
-  {
-    DALI_TEST_CHECK( true );
-  }
-
-  END_TEST;
-}
 
 int UtcDaliPushButtonSetDisabledImageP(void)
 {
@@ -1123,25 +1222,6 @@ int UtcDaliPushButtonSetDisabledImageP(void)
   END_TEST;
 }
 
-int UtcDaliPushButtonSetDisabledImageN(void)
-{
-  ToolkitTestApplication application;
-
-  PushButton button;
-
-  try
-  {
-    button.SetDisabledImage( ImageView::New() );
-    DALI_TEST_CHECK( false );
-  }
-  catch(...)
-  {
-    DALI_TEST_CHECK( true );
-  }
-
-  END_TEST;
-}
-
 int UtcDaliPushButtonSetDisabledSelectedImageP(void)
 {
   ToolkitTestApplication application;
@@ -1161,22 +1241,3 @@ int UtcDaliPushButtonSetDisabledSelectedImageP(void)
 
   END_TEST;
 }
-
-int UtcDaliPushButtonSetDisabledSelectedImageN(void)
-{
-  ToolkitTestApplication application;
-
-  PushButton button;
-
-  try
-  {
-    button.SetDisabledSelectedImage( ImageView::New() );
-    DALI_TEST_CHECK( false );
-  }
-  catch(...)
-  {
-    DALI_TEST_CHECK( true );
-  }
-
-  END_TEST;
-}
index 07f275e..24b4964 100644 (file)
@@ -21,6 +21,8 @@
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali/integration-api/events/touch-event-integ.h>
 
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
 
 using namespace Dali;
 using namespace Dali::Toolkit;
@@ -142,7 +144,15 @@ int UtcDaliRadioButtonLabelActor(void)
 
   std::string labelText = "test actor 1";
 
-  RadioButton radioButton = RadioButton::New( labelText );
+  RadioButton radioButton = RadioButton::New();
+
+  radioButton.SetProperty( Toolkit::Button::Property::LABEL,
+                          Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+                                         .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+                        );
+
+  radioButton.SetLabelText( labelText );
+
   DALI_TEST_EQUALS( radioButton.GetLabelText(), labelText, TEST_LOCATION );
 
   std::string labelText2 = "test actor 2";
index 38f4c89..4ba3e04 100644 (file)
@@ -101,6 +101,7 @@ develapibuilderdir =            $(develapidir)/builder
 develapicontrolsdir =           $(develapidir)/controls
 develapibloomviewdir =          $(develapicontrolsdir)/bloom-view
 develapibubbleemitterdir =      $(develapicontrolsdir)/bubble-effect
+develapibuttonsdir =            $(develapicontrolsdir)/buttons
 develapieffectsviewdir =        $(develapicontrolsdir)/effects-view
 develapigaussianblurviewdir =   $(develapicontrolsdir)/gaussian-blur-view
 develapimagnifierdir =          $(develapicontrolsdir)/magnifier
@@ -125,6 +126,7 @@ develapi_HEADERS =                  $(devel_api_header_files)
 develapicontrols_HEADERS =          $(devel_api_controls_header_files)
 develapibloomview_HEADERS =         $(devel_api_bloom_view_header_files)
 develapibubbleemitter_HEADERS =     $(devel_api_bubble_emitter_header_files)
+develapibuttons_HEADERS =           $(devel_api_buttons_header_files)
 develapibuilder_HEADERS =           $(devel_api_builder_header_files)
 develapieffectsview_HEADERS =       $(devel_api_effects_view_header_files)
 develapifocusmanager_HEADERS =      $(devel_api_focus_manager_header_files)
diff --git a/dali-toolkit/devel-api/controls/buttons/button-devel.h b/dali-toolkit/devel-api/controls/buttons/button-devel.h
new file mode 100644 (file)
index 0000000..769c8eb
--- /dev/null
@@ -0,0 +1,151 @@
+#ifndef __DALI_TOOLKIT_BUTTON_DEVEL_H__
+#define __DALI_TOOLKIT_BUTTON_DEVEL_H__
+
+/*
+ * Copyright (c) 2016 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/buttons/button.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace DevelButton
+{
+/**
+ *
+ * @section ButtonProperties Properties
+ * |%Property enum                                         |String name                             |Type          |Writable|Animatable|
+ * |-------------------------------------------------------|----------------------------------------|--------------|--------|----------|
+ * | Property::DISABLED                                    | disabled                               |  BOOLEAN     | Y      | N        |
+ * | Property::AUTO_REPEATING                              | autoRepeating                          |  BOOLEAN     | Y      | N        |
+ * | Property::INITIAL_AUTO_REPEATING_DELAY                | initialAutoRepeatingDelay              |  FLOAT       | Y      | N        |
+ * | Property::NEXT_AUTO_REPEATING_DELAY                   | nextAutoRepeatingDelay                 |  FLOAT       | Y      | N        |
+ * | Property::TOGGLABLE                                   | togglable                              |  BOOLEAN     | Y      | N        |
+ * | Property::SELECTED                                    | selected                               |  BOOLEAN     | Y      | N        |
+ * | Property::LABEL                                       | label                                  |  MAP         | Y      | N        |
+ * | Property::UNSELECTED_STATE_VISUAL                     | unselectedVisual                       |  MAP         | Y      | N        |
+ * | Property::SELECTED_VISUAL                             | selectedVisual                         |  MAP         | Y      | N        |
+ * | Property::DISABLED_SELECTED_VISUAL                    | disabledSelectedVisual                 |  MAP         | Y      | N        |
+ * | Property::DISABLED_UNSELECTED_VISUAL                  | disabledUnselectedVisual               |  MAP         | Y      | N        |
+ * | Property::UNSELECTED_BACKGROUND_VISUAL                | unselectedBackgroundVisual             |  MAP         | Y      | N        |
+ * | Property::SELECTED_BACKGROUND_VISUAL                  | selectedBackgroundVisual               |  MAP         | Y      | N        |
+ * | Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL       | disabledUnselectedBackgroundVisual     |  MAP         | Y      | N        |
+ * | Property::DISABLED_SELECTED_BACKGROUND_VISUAL         | disabledSelectedBackgroundVisual       |  MAP         | Y      | N        |
+ * | Property::LABEL_RELATIVE_ALIGNMENT                    | labelRelativeAlignment                 |  STRING      | Y      | N        |
+ * -------------------------------------------------------------------------------------------------------------------------------------
+ *
+ *
+ */
+
+  namespace Property
+  {
+    enum Type
+    {
+      DISABLED = Dali::Toolkit::Button::Property::DISABLED,
+      AUTO_REPEATING = Dali::Toolkit::Button::Property::AUTO_REPEATING,
+      INITIAL_AUTO_REPEATING_DELAY = Dali::Toolkit::Button::Property::INITIAL_AUTO_REPEATING_DELAY,
+      NEXT_AUTO_REPEATING_DELAY = Dali::Toolkit::Button::Property:: NEXT_AUTO_REPEATING_DELAY,
+      TOGGLABLE = Dali::Toolkit::Button::Property::TOGGLABLE,
+      SELECTED = Dali::Toolkit::Button::Property::SELECTED,
+      UNSELECTED_STATE_IMAGE = Dali::Toolkit::Button::Property::UNSELECTED_STATE_IMAGE,
+      SELECTED_STATE_IMAGE = Dali::Toolkit::Button::Property::SELECTED_STATE_IMAGE,
+      DISABLED_STATE_IMAGE = Dali::Toolkit::Button::Property::DISABLED_STATE_IMAGE,
+      UNSELECTED_COLOR = Dali::Toolkit::Button::Property::UNSELECTED_COLOR,
+      SELECTED_COLOR = Dali::Toolkit::Button::Property::SELECTED_COLOR,
+      LABEL = Dali::Toolkit::Button::Property::LABEL,
+      LABEL_TEXT = Dali::Toolkit::Button::Property::LABEL_TEXT,
+
+      /**
+       * @brief name "unselectedVisual", type string if it is a url, map otherwise
+       * @details Sets the unselected button foreground/icon visual
+       */
+      UNSELECTED_VISUAL = LABEL_TEXT + 1,
+
+      /**
+       * @brief name "selectedImage", type string if it is a url, map otherwise
+       * @details Sets the selected button foreground/icon visual
+       * @SINCE_1_2.18
+       */
+      SELECTED_VISUAL,
+
+      /**
+       * @brief name "disabledSelectedVisual", type string if it is a url, map otherwise
+       * @details Sets the disabled selected state foreground/icon button visual
+       */
+      DISABLED_SELECTED_VISUAL,
+
+      /**
+       * @brief name "disabledUnSelectedVisual", type string if it is a url, map otherwise
+       * @details Sets the disabled unselected state foreground/icon visual
+       */
+      DISABLED_UNSELECTED_VISUAL,
+
+      /**
+       * @brief name "unselectedBackgroundVisual", type string if it is a url, map otherwise
+       * @details Sets the disabled in the unselected state background, button visual
+       */
+      UNSELECTED_BACKGROUND_VISUAL,
+
+      /**
+       * @brief name "selectedBackgroundVisual", type string if it is a url, map otherwise
+       * @details Sets the selected background button visual
+       */
+      SELECTED_BACKGROUND_VISUAL,
+
+      /**
+       * @brief name "disabledUnselectedBackgroundVisual", type string if it is a url, map otherwise
+       * @details Sets the disabled while unselected background button visual
+       */
+      DISABLED_UNSELECTED_BACKGROUND_VISUAL,
+
+      /**
+       * @brief name "disabledSelectedBackgroundVisual", type string if it is a url, map otherwise
+       * @details Sets the disabled while selected background button visual
+       */
+      DISABLED_SELECTED_BACKGROUND_VISUAL,
+
+      /**
+       * @brief name "labelRelativeAlignment", type STRING
+       * @details Sets the position of the the label in relation to the foreground/icon if both present
+       */
+      LABEL_RELATIVE_ALIGNMENT,
+
+      /**
+       * @brief name "labelPadding", type Vector4
+       * @details Sets the padding around the text
+       */
+      LABEL_PADDING,
+
+      /**
+       * @brief name "visualPadding", type Vector4
+       * @details Sets the padding around the foreground visual
+       */
+      VISUAL_PADDING
+    };
+  } // namespace Property
+
+} // namespace DevelButton
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_BUTTON_DEVEL_H__
index 6afe30c..566949b 100644 (file)
@@ -51,6 +51,9 @@ devel_api_bloom_view_header_files = \
 devel_api_bubble_emitter_header_files = \
   $(devel_api_src_dir)/controls/bubble-effect/bubble-emitter.h
 
+devel_api_buttons_header_files = \
+  $(devel_api_src_dir)/controls/buttons/button-devel.h
+
 devel_api_builder_header_files = \
   $(devel_api_src_dir)/builder/builder.h \
   $(devel_api_src_dir)/builder/json-parser.h \
index de3fbe1..a7fabdf 100644 (file)
@@ -193,7 +193,7 @@ void Builder::SetProperties( const TreeNode& node, Handle& handle, const Replace
       }
       else
       {
-        DALI_SCRIPT_VERBOSE("SetProperty INVALID '%s' Index=:%d\n", key.c_str(), index);
+        DALI_LOG_ERROR("Key '%s' not found.\n", key.c_str());
       }
 
       // Add custom properties
index 925daf1..3bcdde3 100644 (file)
 
 // EXTERNAL INCLUDES
 #include <cstring> // for strcmp
+#include <dali/devel-api/scripting/enum-helper.h>
+#include <dali/integration-api/debug.h>
 #include <dali/public-api/events/touch-data.h>
 #include <dali/public-api/images/resource-image.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
+#include <dali/public-api/size-negotiation/relayout-container.h>
+#include <dali/devel-api/object/property-helper-devel.h>
 #include <dali/devel-api/scripting/scripting.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
 #include <dali-toolkit/public-api/visuals/color-visual-properties.h>
-#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
+#include <dali-toolkit/devel-api/align-enums.h>
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 
-
-/**
- * Button states and contents
- *                                         (3) mSelectedContent
- *  (2) mUnselectedContent                 (2) mSelectedBackgroundContent
- *  (1) mBackgroundContent                 (1) mBackgroundContent
- * < unselected > ----------------------- < selected >
- *       |                OnSelect()            |
- *       | OnDisabled()                         | OnDisabled()
- *       |                                      |
- * < disabled >                           < disabled-selected >
- *  (2) mDisabledContent                   (2) mDisabledSelectedContent
- *  (1) mDisabledBackgroundContent         (1) mDisabledBackgroundContent
- *
- * The drawing order of child actors is as follows.
- *
- *  Top      mLabel
- *   |       mUnselectedContent / mSelectedContent / mDisabledContent / mDisabledSelectedContent
- *   |       mSelectedBackgroundContent
- * Bottom    mBackgroundContent / mDisabledBackgroundContent
- *
- * Some of contents may be missed.
- * And 2 images - fade-in image and fade-out image - in the same layer can be shown during the transition animation. Fade-in image should be above fade-out image.
- */
+#if defined(DEBUG_ENABLED)
+    Debug::Filter* gLogButtonFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_BUTTON_CONTROL");
+#endif
 
 namespace Dali
 {
@@ -77,23 +65,32 @@ BaseHandle Create()
 }
 
 // Setup properties, signals and actions using the type-registry.
-DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Button, Toolkit::Control, Create );
-
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "disabled",                     BOOLEAN, DISABLED                     )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "autoRepeating",                BOOLEAN, AUTO_REPEATING               )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "initialAutoRepeatingDelay",    FLOAT,   INITIAL_AUTO_REPEATING_DELAY )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "nextAutoRepeatingDelay",       FLOAT,   NEXT_AUTO_REPEATING_DELAY    )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "togglable",                    BOOLEAN, TOGGLABLE                    )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selected",                     BOOLEAN, SELECTED                     )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "unselectedStateImage",         STRING,  UNSELECTED_STATE_IMAGE       )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selectedStateImage",           STRING,  SELECTED_STATE_IMAGE         )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "disabledStateImage",           STRING,  DISABLED_STATE_IMAGE         )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "unselectedColor",              VECTOR4, UNSELECTED_COLOR             )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selectedColor",                VECTOR4, SELECTED_COLOR               )
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "label",                        MAP,     LABEL                        )
-
-// Deprecated properties:
-DALI_PROPERTY_REGISTRATION( Toolkit, Button, "labelText",                    STRING,  LABEL_TEXT                   )
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Button, Toolkit::Control, Create )
+
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "disabled",                           BOOLEAN, DISABLED                              )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "autoRepeating",                      BOOLEAN, AUTO_REPEATING                        )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "initialAutoRepeatingDelay",          FLOAT,   INITIAL_AUTO_REPEATING_DELAY          )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "nextAutoRepeatingDelay",             FLOAT,   NEXT_AUTO_REPEATING_DELAY             )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "togglable",                          BOOLEAN, TOGGLABLE                             )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selected",                           BOOLEAN, SELECTED                              )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "unselectedStateImage",               MAP,     UNSELECTED_STATE_IMAGE                ) // Deprecated property
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selectedStateImage",                 MAP,     SELECTED_STATE_IMAGE                  ) // Deprecated property
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "disabledStateImage",                 MAP,     DISABLED_STATE_IMAGE                  ) // Deprecated property
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "unselectedColor",                    VECTOR4, UNSELECTED_COLOR                      ) // Deprecated property
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selectedColor",                      VECTOR4, SELECTED_COLOR                        ) // Deprecated property
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "label",                              MAP,     LABEL                                 )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "labelText",                          STRING,  LABEL_TEXT                            ) // Deprecated property
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "unselectedVisual",                   MAP,     UNSELECTED_VISUAL                     )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "selectedVisual",                     MAP,     SELECTED_VISUAL                       )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "disabledSelectedVisual",             MAP,     DISABLED_SELECTED_VISUAL              )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "disabledUnselectedVisual",           MAP,     DISABLED_UNSELECTED_VISUAL            )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "unselectedBackgroundVisual",         MAP,     UNSELECTED_BACKGROUND_VISUAL          )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "selectedBackgroundVisual",           MAP,     SELECTED_BACKGROUND_VISUAL            )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "disabledUnselectedBackgroundVisual", MAP,     DISABLED_UNSELECTED_BACKGROUND_VISUAL )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "disabledSelectedBackgroundVisual",   MAP,     DISABLED_SELECTED_BACKGROUND_VISUAL   )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "labelRelativeAlignment",             STRING,  LABEL_RELATIVE_ALIGNMENT              )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "labelPadding",                       VECTOR4, LABEL_PADDING                         )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, Button, "visualPadding",                      VECTOR4, VISUAL_PADDING                        )
 
 // Signals:
 DALI_SIGNAL_REGISTRATION(   Toolkit, Button, "pressed",                               SIGNAL_PRESSED               )
@@ -106,180 +103,85 @@ DALI_ACTION_REGISTRATION(   Toolkit, Button, "buttonClick",
 
 DALI_TYPE_REGISTRATION_END()
 
-const unsigned int INITIAL_AUTOREPEATING_DELAY( 0.15f );
-const unsigned int NEXT_AUTOREPEATING_DELAY( 0.05f );
+DALI_ENUM_TO_STRING_TABLE_BEGIN( ALIGNMENT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Internal::Button, BEGIN )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Internal::Button, END )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Internal::Button, TOP )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Internal::Button, BOTTOM )
+DALI_ENUM_TO_STRING_TABLE_END( ALIGNMENT )
 
-} // unnamed namespace
-
-Button::Button()
-: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
-  mAutoRepeatingTimer(),
-  mUnselectedColor( Color::WHITE ), // The natural colors of the specified images will be used by default.
-  mSelectedColor( Color::WHITE ),
-  mDisabled( false ),
-  mAutoRepeating( false ),
-  mTogglableButton( false ),
-  mSelected( false ),
-  mInitialAutoRepeatingDelay( INITIAL_AUTOREPEATING_DELAY ),
-  mNextAutoRepeatingDelay( NEXT_AUTOREPEATING_DELAY ),
-  mAnimationTime( 0.0f ),
-  mClickActionPerforming( false ),
-  mState( ButtonUp ),
-  mPaintState( UnselectedState )
+const Scripting::StringEnum ALIGNMENT_STRING_TABLE[] =
 {
-}
+  { "BEGIN",  Button::BEGIN   },
+  { "END",    Button::END     },
+  { "TOP",    Button::TOP     },
+  { "BOTTOM", Button::BOTTOM  },
+};
 
-Button::~Button()
-{
-}
+const unsigned int ALIGNMENT_STRING_TABLE_COUNT = sizeof( ALIGNMENT_STRING_TABLE ) / sizeof( ALIGNMENT_STRING_TABLE[0] );
 
-void Button::SetDisabled( bool disabled )
+const Property::Index GET_VISUAL_INDEX_FOR_STATE[][Button::STATE_COUNT] =
 {
-  if( disabled == mDisabled )
-  {
-    return;
-  }
+  { Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, Toolkit::DevelButton::Property::UNSELECTED_VISUAL },
+  { Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, Toolkit::DevelButton::Property::SELECTED_VISUAL  },
+  { Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL, Toolkit::DevelButton::Property::DISABLED_UNSELECTED_VISUAL },
+  { Toolkit::DevelButton::Property::DISABLED_SELECTED_BACKGROUND_VISUAL, Toolkit::DevelButton::Property::DISABLED_SELECTED_VISUAL }
+};
 
-  StopTransitionAnimation();
-
-  mDisabled = disabled;
-
-  // Notifies the derived class the button has been disabled.
-  OnDisabled();
-
-  switch( mPaintState )
+/**
+ * Checks if given map contains a text string
+ */
+bool MapContainsTextString( Property::Map& map )
+{
+  bool result = false;
+  Property::Value* value = map.Find( Toolkit::TextVisual::Property::TEXT );
+  if ( value )
   {
-    case UnselectedState:
-    {
-      //Layer Order
-      //(3) mDisabledContent (Inserted)
-      //(4) mUnselectedContent
-      //(2) mDisabledBackgroundContent (Inserted)
-      //(1) mBackgroundContent
-
-      AddButtonImage( mBackgroundContent );
-      TransitionButtonImage( mDisabledBackgroundContent );
-      AddButtonImage( mUnselectedContent );
-      TransitionButtonImage( mDisabledContent );
-
-      AddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
-      ReAddLabel();
-
-      TransitionOut( mDecoration[ SELECTED_DECORATION ] );
-      TransitionOut( mUnselectedContent );
-      TransitionOut( mSelectedContent );
-      TransitionOut( mBackgroundContent );
-      TransitionOut( mSelectedBackgroundContent );
-      TransitionOut( mDisabledSelectedContent );
-
-      mPaintState = DisabledUnselectedState;
-      break;
-    }
-    case SelectedState:
-    {
-      //Layer Order
-      //(5) mDisabledSelectedContent (Inserted)
-      //(4) mSelectedContent
-      //(3) mDisabledBackgroundContent (Inserted)
-      //(2) mSelectedBackgroundContent
-      //(1) mBackgroundContent
-
-      AddButtonImage( mBackgroundContent );
-      AddButtonImage( mSelectedBackgroundContent );
-      TransitionButtonImage( mDisabledBackgroundContent );
-      AddButtonImage( mSelectedContent );
-      TransitionButtonImage( mDisabledSelectedContent );
-
-      AddButtonImage( mDecoration[ SELECTED_DECORATION ] );
-      ReAddLabel();
-
-      TransitionOut( mDecoration[ UNSELECTED_DECORATION ] );
-      TransitionOut( mUnselectedContent );
-      TransitionOut( mSelectedContent );
-      TransitionOut( mBackgroundContent );
-      TransitionOut( mSelectedBackgroundContent );
-      TransitionOut( mDisabledContent );
-
-      mPaintState = DisabledSelectedState;
-      break;
-    }
-    case DisabledUnselectedState:
+    std::string textString;
+    value->Get( textString );
+    if ( !textString.empty() )
     {
-      //Layer Order
-      //(3) mUnselectedContent (Inserted)
-      //(4) mDisabledContent
-      //(2) mBackgroundContent (Inserted)
-      //(1) mDisabledBackgroundContent
-
-      AddButtonImage( mDisabledBackgroundContent );
-      TransitionButtonImage( mBackgroundContent );
-      AddButtonImage( mDisabledContent );
-      TransitionButtonImage( mUnselectedContent );
-
-      AddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
-      ReAddLabel();
-
-      TransitionOut( mDecoration[ SELECTED_DECORATION ] );
-      TransitionOut( mSelectedContent );
-      TransitionOut( mSelectedBackgroundContent );
-      TransitionOut( mDisabledContent );
-      TransitionOut( mDisabledSelectedContent );
-      TransitionOut( mDisabledBackgroundContent );
-
-      mPaintState = UnselectedState;
-      break;
-    }
-    case DisabledSelectedState:
-    {
-      //Layer Order
-      //(4) mSelectedContent (Inserted)
-      //(5) mDisabledSelectedContent
-      //(3) mSelectedBackgroundContent (Inserted)
-      //(2) mBackgroundContent (Inserted)
-      //(1) mDisabledBackgroundContent
-
-      AddButtonImage( mDisabledBackgroundContent );
-      TransitionButtonImage( mBackgroundContent );
-      TransitionButtonImage( mSelectedBackgroundContent );
-      AddButtonImage( mDisabledSelectedContent );
-      TransitionButtonImage( mSelectedContent );
-
-      AddButtonImage( mDecoration[ SELECTED_DECORATION ] );
-      ReAddLabel();
-
-      TransitionOut( mDecoration[ UNSELECTED_DECORATION ] );
-      TransitionOut( mUnselectedContent );
-      TransitionOut( mDisabledContent );
-      TransitionOut( mDisabledSelectedContent );
-      TransitionOut( mDisabledBackgroundContent );
-
-      mPaintState = SelectedState;
-      break;
+      result = true;
     }
   }
+  return result;
+}
+
+} // unnamed namespace
 
-  StartTransitionAnimation();
+Button::Button()
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
+  mAutoRepeatingTimer(),
+  mTextLabelAlignment( END ),
+  mAutoRepeating( false ),
+  mTogglableButton( false ),
+  mTextStringSetFlag( false ),
+  mInitialAutoRepeatingDelay( 0.0f ),
+  mNextAutoRepeatingDelay( 0.0f ),
+  mAnimationTime( 0.0f ),
+  mButtonPressedState( UNPRESSED ),
+  mButtonState( UNSELECTED_STATE ),
+  mPreviousButtonState( mButtonState ),
+  mClickActionPerforming( false )
+{
 }
 
-bool Button::IsDisabled() const
+Button::~Button()
 {
-  return mDisabled;
 }
 
 void Button::SetAutoRepeating( bool autoRepeating )
 {
   mAutoRepeating = autoRepeating;
 
-  // An autorepeating button can't be a togglable button.
+  // An autorepeating button can't be a toggle button.
   if( autoRepeating )
   {
-    mTogglableButton = false;
-
-    if( mSelected )
+    if( IsSelected() )
     {
-      // Emit a signal is not wanted, only change the appearance.
-      SetSelected( false, false );
+      SetSelected( false ); // UnSelect before switching off Toggle feature.
     }
+    mTogglableButton = false;
   }
 }
 
@@ -290,7 +192,7 @@ bool Button::IsAutoRepeating() const
 
 void Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
 {
-  DALI_ASSERT_ALWAYS( initialAutoRepeatingDelay > 0.f );
+  DALI_ASSERT_DEBUG( initialAutoRepeatingDelay > 0.f );
   mInitialAutoRepeatingDelay = initialAutoRepeatingDelay;
 }
 
@@ -301,7 +203,7 @@ float Button::GetInitialAutoRepeatingDelay() const
 
 void Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
 {
-  DALI_ASSERT_ALWAYS( nextAutoRepeatingDelay > 0.f );
+  DALI_ASSERT_DEBUG( nextAutoRepeatingDelay > 0.f );
   mNextAutoRepeatingDelay = nextAutoRepeatingDelay;
 }
 
@@ -314,7 +216,7 @@ void Button::SetTogglableButton( bool togglable )
 {
   mTogglableButton = togglable;
 
-  // A togglable button can't be an autorepeating button.
+  // A toggle button can't be an autorepeating button.
   if( togglable )
   {
     mAutoRepeating = false;
@@ -328,425 +230,251 @@ bool Button::IsTogglableButton() const
 
 void Button::SetSelected( bool selected )
 {
-  if( !mDisabled && mTogglableButton && ( selected != mSelected ) )
+  if( mTogglableButton )
   {
-    SetSelected( selected, true );
+    DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::SetSelected (%s)\n", (selected?"true":"false") );
+
+    if ( selected && ( mButtonState != SELECTED_STATE ) )
+    {
+      ChangeState( SELECTED_STATE );
+    }
+    else if ( !selected && ( mButtonState != UNSELECTED_STATE ) )
+    {
+      ChangeState( UNSELECTED_STATE );
+    }
   }
 }
 
-void Button::SetSelected( bool selected, bool emitSignal )
+void Button::SetDisabled( bool disabled )
 {
-  StopTransitionAnimation();
-
-  mSelected = selected;
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::SetDisabled(%s) state(%d)\n", (disabled)?"disabled":"active", mButtonState );
 
-  // Notifies the derived class the button has been selected.
-  OnSelected();
-
-  switch( mPaintState )
+  if ( disabled )
   {
-    case UnselectedState:
-    {
-      //Layer Order
-      //(3) mSelectedContent (Inserted)
-      //(4) mUnselectedContent
-      //(2) mSelectedBackgroundContent (Inserted)
-      //(1) mBackgroundContent
-
-      AddButtonImage( mBackgroundContent );
-      TransitionButtonImage( mSelectedBackgroundContent );
-      AddButtonImage( mUnselectedContent );
-      TransitionButtonImage( mSelectedContent );
-
-      AddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
-      TransitionButtonImage( mDecoration[ SELECTED_DECORATION ] );
-      ReAddLabel();
-
-      TransitionOut( mDecoration[ UNSELECTED_DECORATION ] );
-      TransitionOut( mUnselectedContent );
-      TransitionOut( mDisabledContent );
-      TransitionOut( mDisabledSelectedContent );
-      TransitionOut( mDisabledBackgroundContent );
-
-      mPaintState = SelectedState;
-      break;
-    }
-    case SelectedState:
+    if ( mButtonState == SELECTED_STATE )
     {
-      //Layer Order
-      //(3) mUnselectedContent (Inserted)
-      //(2) mSelectedContent
-      //(1) mBackgroundContent
-
-      AddButtonImage( mBackgroundContent );
-      AddButtonImage( mSelectedContent );
-      TransitionButtonImage( mUnselectedContent );
-
-      AddButtonImage( mDecoration[ SELECTED_DECORATION ] );
-      TransitionButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
-      ReAddLabel();
-
-      TransitionOut( mDecoration[ SELECTED_DECORATION ] );
-      TransitionOut( mSelectedContent );
-      TransitionOut( mSelectedBackgroundContent );
-      TransitionOut( mDisabledContent );
-      TransitionOut( mDisabledSelectedContent );
-      TransitionOut( mDisabledBackgroundContent );
-
-      mPaintState = UnselectedState;
-      break;
+      ChangeState( DISABLED_SELECTED_STATE );
     }
-    case DisabledUnselectedState:
-    case DisabledSelectedState:
+    else if ( mButtonState == UNSELECTED_STATE )
     {
-      DALI_ASSERT_DEBUG( 0 && "Shouldn't be able to change paint state if the button is disabled." );
-      break;
+      ChangeState( DISABLED_UNSELECTED_STATE );
     }
   }
-
-  StartTransitionAnimation();
-
-  if( emitSignal )
+  else
   {
-    Toolkit::Button handle( GetOwner() );
-
-    // Emit signal.
-    mStateChangedSignal.Emit( handle );
+    if ( mButtonState == DISABLED_SELECTED_STATE )
+    {
+      ChangeState( SELECTED_STATE );
+    }
+    else if ( mButtonState == DISABLED_UNSELECTED_STATE )
+    {
+      ChangeState( UNSELECTED_STATE );
+    }
   }
-
-  RelayoutRequest();
-}
-
-bool Button::IsSelected() const
-{
-  return mTogglableButton && mSelected;
 }
 
-void Button::SetAnimationTime( float animationTime )
+bool Button::IsDisabled() const
 {
-  mAnimationTime = animationTime;
+  return ( mButtonState == DISABLED_SELECTED_STATE || mButtonState == DISABLED_UNSELECTED_STATE ) ;
 }
 
-float Button::GetAnimationTime() const
+bool Button::ValidateState( State requestedState )
 {
-  return mAnimationTime;
-}
+  /*  Below tables shows allowed state transitions
+   *  Match rows in first column to following columns, if true then transition allowed.
+   *  eg UNSELECTED_STATE to DISABLED_UNSELECTED_STATE is true so state transition allowed.
+   *
+                                                             to| UNSELECTED_STATE | SELECTED_STATE | DISABLED_UNSELECTED_STATE | DISABLED_SELECTED_STATE |*/
+                                 /* from*/
+  bool transitionTable[4][4] = { /* UNSELECTED_STATE*/         {      false,            true,               true,                   false         },
+                                 /* SELECTED_STATE*/           {      true,             false,              false,                  true          },
+                                 /* DISABLED_UNSELECTED_STATE*/{      true,             true,               false,                  false         },
+                                 /* DISABLED_SELECTED_STATE*/  {      false,            true,               false,                  false         }
+                               };
 
-void Button::SetLabelText( const std::string& label )
-{
-  Property::Map labelProperty;
-  labelProperty.Insert( "text", label );
-  ModifyLabel( labelProperty );
-}
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::ValidateState ReuestedState:%d, CurrentState:%d, result:%s\n",
+                 requestedState, mButtonState, (transitionTable[mButtonState][requestedState])?"change-accepted":"change-denied");
 
-std::string Button::GetLabelText() const
-{
-  Toolkit::TextLabel label = Dali::Toolkit::TextLabel::DownCast( mLabel );
-  if( label )
-  {
-    return label.GetProperty<std::string>( Dali::Toolkit::TextLabel::Property::TEXT );
-  }
-  return std::string();
+  return transitionTable[mButtonState][requestedState];
 }
 
-void Button::ModifyLabel( const Property::Map& properties )
+void Button::PerformFunctionOnVisualsInState( void(Button::*functionPtr)( Property::Index visualIndex), State state )
 {
-  // If we don't have a label yet, create one.
-  if( !mLabel )
-  {
-    // If we don't have a label, create one and set it up.
-    // Note: The label text is set from the passed in property map after creation.
-    mLabel = Toolkit::TextLabel::New();
-    mLabel.SetPosition( 0.0f, 0.0f );
-    // label should be the top of the button
-    Self().Add( mLabel );
-  }
-
-  // Set any properties specified for the label by iterating through all property key-value pairs.
-  for( unsigned int i = 0, mapCount = properties.Count(); i < mapCount; ++i )
-  {
-    const StringValuePair& propertyPair( properties.GetPair( i ) );
-
-    // Convert the property string to a property index.
-    Property::Index setPropertyIndex = mLabel.GetPropertyIndex( propertyPair.first );
-    if( setPropertyIndex != Property::INVALID_INDEX )
-    {
-      // If the conversion worked, we have a valid property index,
-      // Set the property to the new value.
-      mLabel.SetProperty( setPropertyIndex, propertyPair.second );
-    }
-  }
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::PerformFunctionOnVisualsInState BACKROUND visual(%d) for state (%d)\n",
+                 GET_VISUAL_INDEX_FOR_STATE[state][BACKGROUND], state );
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::PerformFunctionOnVisualsInState FOREGROUND visuals(%d)  for state (%d)\n",
+                 GET_VISUAL_INDEX_FOR_STATE[state][FOREGROUND], state );
 
-  // Notify derived button classes of the change.
-  OnLabelSet( false );
+  (this->*functionPtr)( GET_VISUAL_INDEX_FOR_STATE[state][BACKGROUND] );
+  (this->*functionPtr)( GET_VISUAL_INDEX_FOR_STATE[state][FOREGROUND] );
 
   RelayoutRequest();
 }
 
-Actor& Button::GetLabelActor()
+void Button::ChangeState( State requestedState )
 {
-  return mLabel;
-}
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::ChangeState ReuestedState(%d)\n", requestedState );
 
-void Button::SetDecoration( DecorationState state, Actor actor )
-{
-  if( mDecoration[ state ] && mDecoration[ state ].GetParent() )
+  // Validate State before changing
+  if ( !ValidateState( requestedState ))
   {
-    mDecoration[ state ].Unparent();
+    DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::ChangeState ReuestedState(%d) not validated\n", requestedState );
+    return;
   }
 
-  mDecoration[ state ] = actor;
-  mDecoration[ state ].SetColorMode( USE_OWN_COLOR );
-
-  ResetImageLayers();
-  RelayoutRequest();
-}
-
-Actor& Button::GetDecoration( DecorationState state )
-{
-  return mDecoration[ state ];
-}
+  // If not on stage the button could have still been set to selected so update state
+  mPreviousButtonState = mButtonState; // Store previous state for visual removal (used when animations ended)
+  mButtonState = requestedState; // Update current state
 
-void Button::SetupContent( Actor& actorToModify, Actor newActor )
-{
-  if( newActor )
+  if ( Self().OnStage() )
   {
-    StopTransitionAnimation();
-
-    if( actorToModify && actorToModify.GetParent() )
-    {
-      actorToModify.Unparent();
-    }
-
-    actorToModify = newActor;
-
-    if( actorToModify )
-    {
-      actorToModify.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-      actorToModify.SetParentOrigin( ParentOrigin::TOP_LEFT );
-      actorToModify.SetPosition( 0.f, 0.f );
-    }
-
-    ResetImageLayers();
+    OnStateChange( mButtonState ); // Notify derived buttons
+    PerformFunctionOnVisualsInState( &Button::SelectRequiredVisual, mButtonState );
+    // If animation supported then visual removal should be performed after any transition animation has completed.
+    // If Required Visual is not loaded before current visual is removed then a flickering will be evident.
+    PerformFunctionOnVisualsInState( &Button::OnButtonVisualRemoval, mPreviousButtonState ); // Derived button can override OnButtonVisualRemoval
   }
-}
 
-const Vector4 Button::GetUnselectedColor() const
-{
-  return mUnselectedColor;
+  Toolkit::Button handle( GetOwner() );
+  // Emit signal.
+  mStateChangedSignal.Emit( handle );
 }
 
-void Button::SetColor( const Vector4& color, Button::PaintState selectedState )
+bool Button::IsSelected() const
 {
-  Actor* contentActor = NULL; // Using a pointer as SetupContent assigns the new Actor to this.
-  bool imageFileExists = false;
-  Property::Index visualIndex = Toolkit::Button::Property::SELECTED_STATE_IMAGE;
-
-  if ( selectedState == SelectedState || selectedState == DisabledSelectedState )
-  {
-    mSelectedColor = color;
-    contentActor = &mSelectedContent;
-    imageFileExists = !GetSelectedImageFilename().empty();
-  }
-  else
-  {
-    mUnselectedColor = color;
-    contentActor = &mUnselectedContent;
-    imageFileExists = !GetUnselectedImageFilename().empty();
-    visualIndex = Toolkit::Button::Property::UNSELECTED_STATE_IMAGE;
-  }
-
-  if ( contentActor )
-  {
-    if( imageFileExists )
-    {
-      // If there is existing unselected content, change the color on it directly.
-      contentActor->SetColor( color );
-    }
-    else
-    {
-      // If there is no existing content, create a new actor to use for flat color.
-      Actor placementActor = Actor::New();
-      Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
-      Toolkit::Visual::Base visual;
-
-      Property::Map map;
-      map[ Toolkit::DevelVisual::Property::TYPE ] = Toolkit::Visual::COLOR;
-      map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
-
-      visual = visualFactory.CreateVisual( map );
-
-      RegisterVisual( visualIndex, visual );
-
-      SetupContent( *contentActor, placementActor ); //
-      contentActor->SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
-    }
-  }
+  bool selected = ( mButtonState == SELECTED_STATE ) || ( mButtonState == DISABLED_SELECTED_STATE );
+  return mTogglableButton && selected;
 }
 
-const Vector4 Button::GetSelectedColor() const
+void Button::SetLabelText( const std::string& label )
 {
-  return mSelectedColor;
+  Property::Map labelProperty;
+  labelProperty.Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT)
+               .Add( Toolkit::TextVisual::Property::TEXT, label );
+
+  Self().SetProperty( Toolkit::Button::Property::LABEL, labelProperty );
 }
 
-void Button::SetUnselectedImage( const std::string& filename )
+std::string Button::GetLabelText() const
 {
-  Toolkit::ImageView newContent;
-  if( !filename.empty() )
-  {
-    newContent = Toolkit::ImageView::New( filename );
-  }
-  else
-  {
-    newContent = Toolkit::ImageView::New();
-  }
+  Property::Value value = Self().GetProperty( Toolkit::Button::Property::LABEL );
 
-  if( newContent )
-  {
-    SetupContent( mUnselectedContent, newContent );
+  Property::Map *labelProperty = value.GetMap();
 
-    mUnselectedContent.SetColor( mUnselectedColor );
+  std::string textLabel;
 
-    OnUnselectedImageSet();
-    RelayoutRequest();
+  if ( labelProperty )
+  {
+    Property::Value* value = labelProperty->Find( Toolkit::TextVisual::Property::TEXT );
+    value->Get( textLabel );
   }
-}
 
-Actor& Button::GetUnselectedImage()
-{
-  return mUnselectedContent;
+  return textLabel;
 }
 
-void Button::SetSelectedImage( const std::string& filename )
+void Button::MergeLabelProperties( const Property::Map& inMap, Property::Map& outMap )
 {
-  Toolkit::ImageView newContent;
-  if( !filename.empty() )
-  {
-   newContent = Toolkit::ImageView::New( filename );
-  }
-  else
-  {
-    newContent = Toolkit::ImageView::New();
-  }
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "MergeLabelProperties with %d properties\n", inMap.Count() );
 
-  if( newContent )
+  /**
+   * Properties for the Label visual could be from a style sheet but after being set the "TEXT" property could be set.
+   * Hence would need to create the Text Visual with the complete merged set of properties.
+   *
+   * 1) Find Label Visual
+   * 2) Retrieve current properties ( settings )
+   * 3) Merge with new properties ( settings )
+   * 4) Return new merged map
+   */
+  Toolkit::Visual::Base visual = GetVisual( Toolkit::Button::Property::LABEL );
+  if ( visual )
   {
-    SetupContent( mSelectedContent, newContent );
-
-    mSelectedContent.SetColor( mSelectedColor );
-
-    OnSelectedImageSet();
-    RelayoutRequest();
+    DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "MergeLabelProperties Visual already exists, retrieving existing map\n");
+    visual.CreatePropertyMap( outMap );
+    DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "MergeLabelProperties retrieved %d properties\n", outMap.Count() );
   }
-}
-
-Actor& Button::GetSelectedImage()
-{
-  return mSelectedContent;
-}
-
-void Button::SetBackgroundImage( const std::string& filename )
-{
-  SetupContent( mBackgroundContent, Toolkit::ImageView::New( filename ) );
-
-  OnBackgroundImageSet();
-  RelayoutRequest();
-}
-
-Actor& Button::GetBackgroundImage()
-{
-  return mBackgroundContent;
-}
-
-void Button::SetSelectedBackgroundImage( const std::string& filename )
-{
-  SetupContent( mSelectedBackgroundContent, Toolkit::ImageView::New( filename ) );
-
-  OnSelectedBackgroundImageSet();
-  RelayoutRequest();
-}
 
-Actor& Button::GetSelectedBackgroundImage()
-{
-  return mSelectedBackgroundContent;
-}
+  outMap.Merge( inMap );
 
-void Button::SetDisabledImage( const std::string& filename )
-{
-  SetupContent( mDisabledContent, Toolkit::ImageView::New( filename ) );
+  // Store if a text string has been supplied.
 
-  OnDisabledImageSet();
-  RelayoutRequest();
-}
+  mTextStringSetFlag = MapContainsTextString( outMap );
 
-Actor& Button::GetDisabledImage()
-{
-  return mDisabledContent;
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "MergeLabelProperties now has %d properties\n", outMap.Count() );
 }
 
-void Button::SetDisabledSelectedImage( const std::string& filename )
+void Button::SetLabelAlignment( Button::Align labelAlignment)
 {
-  SetupContent( mDisabledSelectedContent, Toolkit::ImageView::New( filename ) );
-
-  OnDisabledSelectedImageSet();
+  mTextLabelAlignment = labelAlignment;
   RelayoutRequest();
 }
 
-Actor& Button::GetDisabledSelectedImage()
+Button::Align Button::GetLabelAlignment()
 {
-  return mDisabledSelectedContent;
+  return mTextLabelAlignment;
 }
 
-void Button::SetDisabledBackgroundImage( const std::string& filename )
-{
-  SetupContent( mDisabledBackgroundContent, Toolkit::ImageView::New( filename ) );
-
-  OnDisabledBackgroundImageSet();
-  RelayoutRequest();
-}
+/**
+ * Create Visual for given index from a property map or url.
+ * 1) Check if value passed in is a url and create visual
+ * 2) Create visual from map if step (1) is false
+ * 3) Register visual with control with false for enable flag. Button will later enable visual when needed ( Button::SelectRequiredVisual )
+ * 4) Unregister visual if empty map was provided. This is the method to remove a visual
+ */
 
-Actor& Button::GetDisabledBackgroundImage()
+void Button::CreateVisualsForComponent( Property::Index index, const Property::Value& value, const float visualDepth )
 {
-  return mDisabledBackgroundContent;
-}
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "CreateVisualsForComponent index(%d)\n", index );
+  Toolkit::VisualFactory visualFactory = Toolkit::VisualFactory::Get();
+  Toolkit::Visual::Base buttonVisual;
 
-std::string Button::GetUnselectedImageFilename() const
-{
-  if( mUnselectedContent )
+  std::string imageUrl;
+  if( value.Get( imageUrl ) )
   {
-    ResourceImage image = ResourceImage::DownCast( mUnselectedContent );
-    if( image )
+    DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "CreateVisualsForComponent Using image URL(%d)\n", index );
+    if ( !imageUrl.empty() )
     {
-      return image.GetUrl();
+      DALI_ASSERT_DEBUG( index != Toolkit::Button::Property::LABEL && "Creating a Image Visual instead of Text Visual " );
+      buttonVisual = visualFactory.CreateVisual(  imageUrl, ImageDimensions()  );
     }
   }
-  return std::string();
-}
-
-std::string Button::GetSelectedImageFilename() const
-{
-  if( mSelectedContent )
+  else
   {
-    ResourceImage image = ResourceImage::DownCast( mSelectedContent );
-    if( image )
+    // if its not a string then get a Property::Map from the property if possible.
+    Property::Map *map = value.GetMap();
+    if( map && !map->Empty()  ) // Empty map results in current visual removal.
     {
-      return image.GetUrl();
+      DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "CreateVisualsForComponent Using Map(%d)\n", index );
+      buttonVisual = visualFactory.CreateVisual( *map );
     }
   }
-  return std::string();
+
+  if ( buttonVisual )
+  {
+    DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "CreateVisualsForComponent RegisterVisual index(%d) enabled(%s)\n",
+                   index, IsVisualEnabled( index )?"true":"false" );
+    buttonVisual.SetDepthIndex( visualDepth );
+    RegisterVisual( index, buttonVisual, IsVisualEnabled( index ) );
+  }
+  else
+  {
+    UnregisterVisual( index );
+    DALI_LOG_INFO( gLogButtonFilter, Debug::General, "CreateVisualsForComponent Visual not created or empty map (clearing visual).(%d)\n", index);
+  }
+  PerformFunctionOnVisualsInState( &Button::SelectRequiredVisual, mButtonState );
 }
 
-std::string Button::GetDisabledImageFilename() const
+bool Button::GetPropertyMapForVisual( Property::Index visualIndex, Property::Map& retreivedMap ) const
 {
-  if( mDisabledContent )
+  DALI_LOG_INFO( gLogButtonFilter, Debug::General, "GetPropertyMapForVisual visual(%d)\n", visualIndex);
+  bool success = false;
+  Toolkit::Visual::Base visual = GetVisual( visualIndex );
+  if ( visual )
   {
-    ResourceImage image = ResourceImage::DownCast( mDisabledContent );
-    if( image )
-    {
-      return image.GetUrl();
-    }
+    visual.CreatePropertyMap( retreivedMap );
+    success = true;
   }
-  return std::string();
+  DALI_LOG_INFO( gLogButtonFilter, Debug::General, "GetPropertyMapForVisual %s\n", success?"Success":"Failure");
+  return success;
 }
 
 bool Button::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
@@ -757,7 +485,7 @@ bool Button::DoAction( BaseObject* object, const std::string& actionName, const
 
   Toolkit::Button button = Toolkit::Button::DownCast( handle );
 
-  DALI_ASSERT_ALWAYS( button );
+  DALI_ASSERT_DEBUG( button );
 
   if( 0 == strcmp( actionName.c_str(), ACTION_BUTTON_CLICK ) )
   {
@@ -774,9 +502,12 @@ bool Button::DoClickAction( const Property::Map& attributes )
   if( !mClickActionPerforming )
   {
     mClickActionPerforming = true;
-    OnButtonDown();
-    mState = ButtonDown;
-    OnButtonUp();
+    ButtonDown();
+    if ( !mTogglableButton )
+    {
+      mButtonPressedState = DEPRESSED;
+    }
+    ButtonUp();
     mClickActionPerforming = false;
 
     return true;
@@ -785,15 +516,27 @@ bool Button::DoClickAction( const Property::Map& attributes )
   return false;
 }
 
-void Button::OnButtonDown()
+void Button::ButtonDown()
 {
-  if( !mTogglableButton )
+  if( mTogglableButton )
+  {
+    if ( mButtonState != SELECTED_STATE )
+    {
+      SetSelected( true );
+      mButtonPressedState = TOGGLE_DEPRESSED;
+    }
+    else
+    {
+      mButtonPressedState = DEPRESSED;
+    }
+  }
+  else
   {
     Pressed();
-
+    mButtonPressedState = DEPRESSED;
     if( mAutoRepeating )
     {
-      SetUpTimer( mInitialAutoRepeatingDelay );
+       SetUpTimer( mInitialAutoRepeatingDelay );
     }
   }
 
@@ -802,34 +545,47 @@ void Button::OnButtonDown()
   mPressedSignal.Emit( handle );
 }
 
-void Button::OnButtonUp()
+void Button::ButtonUp()
 {
-  if( ButtonDown == mState )
+  if( DEPRESSED == mButtonPressedState )
   {
-    if( mTogglableButton )
+    bool validButtonAction = false;
+
+    if( mTogglableButton ) // Button up will change state
     {
-      SetSelected( !mSelected );
+      validButtonAction = OnToggleReleased(); // Derived toggle buttons can override this to provide custom behaviour
     }
     else
     {
-      Released();
-
+      Released(); // Button up will result in unselected state
       if( mAutoRepeating )
       {
         mAutoRepeatingTimer.Reset();
       }
+      validButtonAction = true;
     }
 
-    // The clicked and released signals should be emitted regardless of toggle mode.
-    Toolkit::Button handle( GetOwner() );
-    mReleasedSignal.Emit( handle );
-    mClickedSignal.Emit( handle );
+    if ( validButtonAction )
+    {
+      // The clicked and released signals should be emitted regardless of toggle mode.
+      Toolkit::Button handle( GetOwner() );
+      mReleasedSignal.Emit( handle );
+      mClickedSignal.Emit( handle );
+    }
   }
 }
 
+bool Button::OnToggleReleased()
+{
+  SetSelected( !IsSelected() );
+  mButtonPressedState = UNPRESSED;
+  return true;
+}
+
+
 void Button::OnTouchPointLeave()
 {
-  if( ButtonDown == mState )
+  if( DEPRESSED == mButtonPressedState )
   {
     if( !mTogglableButton )
     {
@@ -841,6 +597,8 @@ void Button::OnTouchPointLeave()
       }
     }
 
+    mButtonPressedState = UNPRESSED;
+
     // The released signal should be emitted regardless of toggle mode.
     Toolkit::Button handle( GetOwner() );
     mReleasedSignal.Emit( handle );
@@ -906,6 +664,8 @@ bool Button::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tr
 
 void Button::OnInitialize()
 {
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::OnInitialize\n" );
+
   Actor self = Self();
 
   mTapDetector = TapGestureDetector::New();
@@ -922,73 +682,34 @@ bool Button::OnAccessibilityActivated()
   return OnKeyboardEnter();
 }
 
-bool Button::OnKeyboardEnter()
+bool Button::OnTouch( Actor actor, const TouchData& touch )
 {
-  // When the enter key is pressed, or button is activated, the click action is performed.
-  Property::Map attributes;
-  bool ret = DoClickAction( attributes );
-
-  return ret;
-}
 
-void Button::OnStageDisconnection()
-{
-  if( ButtonDown == mState )
-  {
-    if( !mTogglableButton )
-    {
-      Released();
-
-      if( mAutoRepeating )
-      {
-        mAutoRepeatingTimer.Reset();
-      }
-    }
-  }
-
-  mState = ButtonUp;
-
-  Control::OnStageDisconnection();
-}
-
-bool Button::OnTouch( Actor actor, const TouchData& touch )
-{
   // Only events are processed when the button is not disabled and the touch event has only
   // one touch point.
-  if( ( !mDisabled ) && ( 1 == touch.GetPointCount() ) )
+
+  if( !IsDisabled() && ( 1 == touch.GetPointCount() ) )
   {
     switch( touch.GetState( 0 ) )
     {
       case PointState::DOWN:
       {
-        OnButtonDown(); // Notification for derived classes.
-
-        // Sets the button state to ButtonDown.
-        mState = ButtonDown;
+        ButtonDown();
         break;
       }
       case PointState::UP:
       {
-        OnButtonUp(); // Notification for derived classes.
-
-        // Sets the button state to ButtonUp.
-        mState = ButtonUp;
+        ButtonUp();
         break;
       }
       case PointState::INTERRUPTED:
       {
-        OnTouchPointInterrupted(); // Notification for derived classes.
-
-        // Sets the button state to the default (ButtonUp).
-        mState = ButtonUp;
+        OnTouchPointInterrupted();
         break;
       }
       case PointState::LEAVE:
       {
-        OnTouchPointLeave(); // Notification for derived classes.
-
-        // Sets the button state to the default (ButtonUp).
-        mState = ButtonUp;
+        OnTouchPointLeave();
         break;
       }
       case PointState::MOTION:
@@ -1003,343 +724,404 @@ bool Button::OnTouch( Actor actor, const TouchData& touch )
   {
     OnTouchPointLeave(); // Notification for derived classes.
 
-    // Sets the button state to the default (ButtonUp).
-    mState = ButtonUp;
+    // Sets the button state to the default
+    mButtonPressedState = UNPRESSED;
   }
 
   return false;
 }
 
-void Button::OnTap(Actor actor, const TapGesture& tap)
+bool Button::OnKeyboardEnter()
 {
-  // Do nothing.
-}
+  // When the enter key is pressed, or button is activated, the click action is performed.
+  Property::Map attributes;
+  bool ret = DoClickAction( attributes );
 
-void Button::SetUpTimer( float delay )
-{
-  mAutoRepeatingTimer = Dali::Timer::New( static_cast<unsigned int>( 1000.f * delay ) );
-  mAutoRepeatingTimer.TickSignal().Connect( this, &Button::AutoRepeatingSlot );
-  mAutoRepeatingTimer.Start();
+  return ret;
 }
 
-bool Button::AutoRepeatingSlot()
+void Button::OnStageDisconnection()
 {
-  bool consumed = false;
-  if( !mDisabled )
+  if( DEPRESSED == mButtonPressedState )
   {
-    // Restart the autorepeat timer.
-    SetUpTimer( mNextAutoRepeatingDelay );
-
-    Pressed();
+    if( !mTogglableButton )
+    {
+      Released();
 
-    Toolkit::Button handle( GetOwner() );
+      if( mAutoRepeating )
+      {
+        mAutoRepeatingTimer.Reset();
+      }
+    }
+  }
 
-    //Emit signal.
-    consumed = mReleasedSignal.Emit( handle );
-    consumed |= mClickedSignal.Emit( handle );
-    consumed |= mPressedSignal.Emit( handle );
- }
+  mButtonPressedState = UNPRESSED;
 
-  return consumed;
+  Control::OnStageDisconnection(); // Visuals will be set off stage
 }
 
-void Button::Pressed()
+void Button::OnStageConnection( int depth )
 {
-  if( mPaintState == UnselectedState )
-  {
-    StopTransitionAnimation();
-
-    // Notifies the derived class the button has been pressed.
-    OnPressed();
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::OnStageConnection ptr(%p) \n", this );
+  PerformFunctionOnVisualsInState( &Button::OnButtonVisualRemoval, mPreviousButtonState );
+  SelectRequiredVisual( Toolkit::Button::Property::LABEL );
+  PerformFunctionOnVisualsInState( &Button::SelectRequiredVisual, mButtonState );
+  Control::OnStageConnection( depth ); // Enabled visuals will be put on stage
+}
 
-    //Layer Order
-    //(4) mSelectedContent (Inserted)
-    //(3) mUnselectedContent
-    //(2) mSelectedBackgroundContent (Inserted)
-    //(1) mBackgroundContent
+Vector3 Button::GetNaturalSize()
+{
+  Vector3 size = Vector3::ZERO;
 
-    AddButtonImage( mBackgroundContent );
-    TransitionButtonImage( mSelectedBackgroundContent );
-    AddButtonImage( mUnselectedContent );
-    TransitionButtonImage( mSelectedContent );
+  bool horizontalAlignment = mTextLabelAlignment == BEGIN || mTextLabelAlignment == END; // label and visual side by side
 
-    AddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
-    TransitionButtonImage( mDecoration[ SELECTED_DECORATION ] );
-    ReAddLabel();
+  // Get natural size of foreground ( largest of the possible visuals )
+  Size largestProvidedVisual;
+  Size labelSize = Size::ZERO;
 
-    TransitionOut( mDecoration[ UNSELECTED_DECORATION ] );
-    TransitionOut( mUnselectedContent );
-    TransitionOut( mDisabledContent );
-    TransitionOut( mDisabledSelectedContent );
-    TransitionOut( mDisabledBackgroundContent );
+  bool foreGroundVisualUsed = false;
 
-    mPaintState = SelectedState;
+  for ( int state = Button::UNSELECTED_STATE; state < Button::STATE_COUNT; state++ )
+  {
+    Toolkit::Visual::Base visual = GetVisual( GET_VISUAL_INDEX_FOR_STATE[state][FOREGROUND] );
+    Size visualSize;
+    if ( visual )
+    {
+      visual.GetNaturalSize( visualSize );
+      largestProvidedVisual.width = std::max(largestProvidedVisual.width, visualSize.width );
+      largestProvidedVisual.height = std::max(largestProvidedVisual.height, visualSize.height );
+      foreGroundVisualUsed = true;
+    }
+  }
 
-    StartTransitionAnimation();
+  if ( !foreGroundVisualUsed ) // If foreground visual not supplied then use the background visual to calculate Natural size
+  {
+    for ( int state = Button::UNSELECTED_STATE; state < Button::STATE_COUNT; state++ )
+    {
+      Toolkit::Visual::Base visual = GetVisual( GET_VISUAL_INDEX_FOR_STATE[state][BACKGROUND] );
+      Size visualSize;
+      if ( visual )
+      {
+        visual.GetNaturalSize( visualSize );
+        largestProvidedVisual.width = std::max(largestProvidedVisual.width, visualSize.width );
+        largestProvidedVisual.height = std::max(largestProvidedVisual.height, visualSize.height );
+      }
+    }
   }
-}
 
-void Button::Released()
-{
-  if( mPaintState == SelectedState )
+  // Get horizontal padding total
+  if ( largestProvidedVisual.width > 0 )  // if visual exists
   {
-    StopTransitionAnimation();
+    size.width += largestProvidedVisual.width + mForegroundPadding.left + mForegroundPadding.right;
+  }
+  // Get vertical padding total
+  if ( largestProvidedVisual.height > 0 )
+  {
+    size.height += largestProvidedVisual.height + mForegroundPadding.top + mForegroundPadding.bottom;
+  }
 
-    // Notifies the derived class the button has been released.
-    OnReleased();
+  DALI_LOG_INFO( gLogButtonFilter, Debug::General, "GetNaturalSize visual Size(%f,%f)\n",
+                 largestProvidedVisual.width, largestProvidedVisual.height );
 
-    //Layer Order
-    //(3) mUnselectedContent (Inserted)
-    //(2) mSelectedContent
-    //(1) mBackgroundContent
+  // Get natural size of label if text has been set
+  if ( mTextStringSetFlag )
+  {
+    Toolkit::Visual::Base visual = GetVisual( Toolkit::Button::Property::LABEL );
 
-    AddButtonImage( mBackgroundContent );
-    AddButtonImage( mSelectedContent );
-    TransitionButtonImage( mUnselectedContent );
+    if ( visual )
+    {
+      visual.GetNaturalSize( labelSize );
 
-    AddButtonImage( mDecoration[ SELECTED_DECORATION ] );
-    TransitionButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
-    ReAddLabel();
+      DALI_LOG_INFO( gLogButtonFilter, Debug::General, "GetNaturalSize labelSize(%f,%f) padding(%f,%f)\n",
+                     labelSize.width, labelSize.height, mLabelPadding.left + mLabelPadding.right, mLabelPadding.top + mLabelPadding.bottom);
 
-    TransitionOut( mDecoration[ SELECTED_DECORATION ] );
-    TransitionOut( mSelectedContent );
-    TransitionOut( mSelectedBackgroundContent );
-    TransitionOut( mDisabledContent );
-    TransitionOut( mDisabledSelectedContent );
-    TransitionOut( mDisabledBackgroundContent );
+      labelSize.width += mLabelPadding.left + mLabelPadding.right;
+      labelSize.height += mLabelPadding.top + mLabelPadding.bottom;
 
-    mPaintState = UnselectedState;
+      // Add label size to height or width depending on alignment position
+      if ( horizontalAlignment )
+      {
+        size.width += labelSize.width;
+        size.height = std::max(size.height, labelSize.height );
+      }
+      else
+      {
+        size.height += labelSize.height;
+        size.width = std::max(size.width, labelSize.width );
+      }
+    }
+  }
 
-    StartTransitionAnimation();
+  if( size.width < 1 && size.height < 1 )
+  {
+    // if no image or label then use Control's natural size
+    DALI_LOG_INFO( gLogButtonFilter, Debug::General, "GetNaturalSize Using control natural size\n");
+    size = Control::GetNaturalSize();
   }
-}
 
-Button::ButtonState Button::GetState()
-{
-  return mState;
-}
+  DALI_LOG_INFO( gLogButtonFilter, Debug::General, "Button GetNaturalSize (%f,%f)\n", size.width, size.height );
 
-Button::PaintState Button::GetPaintState()
-{
-  return mPaintState;
+  return size;
 }
 
-void Button::PrepareAddButtonImage( Actor& actor )
+void Button::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
 {
-  if( actor )
-  {
-    Self().Add( actor );
-    PrepareForTranstionOut( actor );
-  }
+  DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnSetResizePolicy\n");
+  RelayoutRequest();
 }
 
-void Button::TransitionButtonImage( Actor& actor )
+/**
+ * Visuals are sized and positioned in this function.
+ * Whilst the control has it's size negotiated it has to size it's visuals explicitly here.
+ */
+
+void Button::OnRelayout( const Vector2& size, RelayoutContainer& container )
 {
-  if( actor )
-  {
-    if( !actor.GetParent() )
-    {
-      Self().Add( actor );
-    }
+  DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout targetSize(%f,%f) ptr(%p) state[%d]\n", size.width, size.height, this, mButtonState );
 
-    OnTransitionIn( actor );
-  }
-}
+  Toolkit::Visual::Base currentVisual = GetVisual( GET_VISUAL_INDEX_FOR_STATE[mButtonState][FOREGROUND] );
 
-void Button::AddButtonImage( Actor& actor )
-{
-  if( actor )
-  {
-    Self().Add( actor );
-  }
-}
+  Toolkit::Visual::Base currentBackGroundVisual = GetVisual( GET_VISUAL_INDEX_FOR_STATE[mButtonState][BACKGROUND] );
 
-void Button::ReAddLabel()
-{
-  if( mLabel )
+  // Sizes and padding set to zero, if not present then values will no effect calculations.
+  Vector2 visualPosition = Vector2::ZERO;
+  Vector2 labelPosition = Vector2::ZERO;
+  Size visualSize = Size::ZERO;
+  Padding foregroundVisualPadding = Padding(0.0f, 0.0f, 0.0f, 0.0f );
+  Padding labelVisualPadding = Padding(0.0f, 0.0f, 0.0f, 0.0f );
+
+  if ( mTextStringSetFlag )
   {
-    mLabel.Unparent();
-    Self().Add( mLabel );
+    DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout Label padding setting padding:%f,%f,%f,%f\n", mLabelPadding.y, mLabelPadding.x, mLabelPadding.width,mLabelPadding.height );
+    labelVisualPadding = mLabelPadding;
   }
-}
 
-void Button::RemoveButtonImage( Actor& actor )
-{
-  if( actor )
+  if ( currentVisual )
   {
-    if( actor.GetParent() )
-    {
-      Self().Remove( actor );
-    }
-    PrepareForTranstionIn( actor );
+    DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout Foreground Visual setting padding:%f,%f,%f,%f\n", mForegroundPadding.y, mForegroundPadding.x, mForegroundPadding.width,mForegroundPadding.height );
+    currentVisual.GetNaturalSize( visualSize );
+    foregroundVisualPadding = mForegroundPadding;
   }
-}
 
-unsigned int Button::FindChildIndex( Actor& actor )
-{
-  Actor self = Self();
-  unsigned int childrenNum = self.GetChildCount();
+  Toolkit::Align::Type visualAnchorPoint = Toolkit::Align::TOP_BEGIN;
+
+  Vector2 visualAndPaddingSize = Vector2( ( foregroundVisualPadding.x + visualSize.width + foregroundVisualPadding.y ),
+                                          ( foregroundVisualPadding.width + visualSize.height + foregroundVisualPadding.height ));
+
+  DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout visualAndPaddingSize(%f,%f)\n", visualAndPaddingSize.width, visualAndPaddingSize.height);
+
+  // Text Visual should take all space available after foreground visual size and all padding is considered.
+  // Remaining Space priority, Foreground padding, foreground visual, Text padding then Text visual.
+  Size remainingSpaceForText = Size::ZERO;
 
-  for( unsigned int i = 0; i < childrenNum; i++ )
+  switch ( mTextLabelAlignment )
   {
-    Actor child = self.GetChildAt( i );
-    if( child == actor )
+    case BEGIN :
     {
-      return i;
-    }
-  }
+      visualAnchorPoint = Toolkit::Align::TOP_END;
+      visualPosition.x = foregroundVisualPadding.right;
+      visualPosition.y = foregroundVisualPadding.top;
 
-  return childrenNum;
-}
+      labelPosition.x = labelVisualPadding.x;
+      labelPosition.y = labelVisualPadding.top;
 
-void Button::TransitionOut( Actor actor )
-{
-  OnTransitionOut( actor );
-}
+      remainingSpaceForText.width = size.width - visualAndPaddingSize.width - labelVisualPadding.x - labelVisualPadding.y;
+      remainingSpaceForText.height = size.height - labelVisualPadding.top - labelVisualPadding.bottom;
+      break;
+    }
+    case END :
+    {
+      visualAnchorPoint = Toolkit::Align::TOP_BEGIN;
+      visualPosition.x = foregroundVisualPadding.left;
+      visualPosition.y = foregroundVisualPadding.top;
 
-void Button::ResetImageLayers()
-{
-  // Ensure that all layers are in the correct order and state according to the paint state
+      labelPosition.x = visualAndPaddingSize.width + labelVisualPadding.x;
+      labelPosition.y = labelVisualPadding.top;
 
-  switch( mPaintState )
-  {
-    case UnselectedState:
-    {
-      //Layer Order
-      //(2) mUnselectedContent
-      //(1) mBackgroundContent
-
-      RemoveButtonImage( mDecoration[ SELECTED_DECORATION ] );
-      RemoveButtonImage( mSelectedContent );
-      RemoveButtonImage( mSelectedBackgroundContent );
-      RemoveButtonImage( mDisabledContent );
-      RemoveButtonImage( mDisabledSelectedContent );
-      RemoveButtonImage( mDisabledBackgroundContent );
-
-      PrepareAddButtonImage( mBackgroundContent );
-      PrepareAddButtonImage( mUnselectedContent );
-
-      PrepareAddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
-      ReAddLabel();
+      remainingSpaceForText.width = size.width - visualAndPaddingSize.width - labelVisualPadding.x - labelVisualPadding.y;
+      remainingSpaceForText.height = size.height - labelVisualPadding.top - labelVisualPadding.bottom;
       break;
     }
-    case SelectedState:
+    case TOP :
     {
-      //Layer Order
-      //(3) mSelectedContent
-      //(2) mSelectedBackgroundContent
-      //(1) mBackgroundContent
-
-      RemoveButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
-      RemoveButtonImage( mUnselectedContent );
-      RemoveButtonImage( mDisabledContent );
-      RemoveButtonImage( mDisabledSelectedContent );
-      RemoveButtonImage( mDisabledBackgroundContent );
-
-      PrepareAddButtonImage( mBackgroundContent );
-      PrepareAddButtonImage( mSelectedBackgroundContent );
-      PrepareAddButtonImage( mSelectedContent );
-
-      PrepareAddButtonImage( mDecoration[ SELECTED_DECORATION ] );
-      ReAddLabel();
+      visualAnchorPoint = Toolkit::Align::BOTTOM_END;
+      visualPosition.x = foregroundVisualPadding.left;
+      visualPosition.y = foregroundVisualPadding.bottom;
+
+      labelPosition.x = labelVisualPadding.left;
+      labelPosition.y = labelVisualPadding.top;
+
+      remainingSpaceForText.width = size.width - labelVisualPadding.x - labelVisualPadding.y;
+      remainingSpaceForText.height = size.height - visualAndPaddingSize.height - labelVisualPadding.top - labelVisualPadding.bottom;
+
       break;
     }
-    case DisabledUnselectedState:
+    case BOTTOM :
     {
-      //Layer Order
-      //(2) mDisabledContent
-      //(1) mDisabledBackgroundContent
-
-      RemoveButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
-      RemoveButtonImage( mUnselectedContent );
-      RemoveButtonImage( mBackgroundContent );
-      RemoveButtonImage( mDecoration[ SELECTED_DECORATION ] );
-      RemoveButtonImage( mSelectedContent );
-      RemoveButtonImage( mDisabledSelectedContent );
-      RemoveButtonImage( mSelectedBackgroundContent );
-
-      PrepareAddButtonImage( mDisabledBackgroundContent ? mDisabledBackgroundContent : mBackgroundContent );
-      PrepareAddButtonImage( mDisabledContent ? mDisabledContent : mUnselectedContent );
-
-      PrepareAddButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
-      ReAddLabel();
+      visualAnchorPoint = Toolkit::Align::TOP_END;
+      visualPosition.x = foregroundVisualPadding.left;
+      visualPosition.y = foregroundVisualPadding.top;
+
+      labelPosition.x = labelVisualPadding.left;
+      labelPosition.y = visualAndPaddingSize.height + labelVisualPadding.top;
+
+      remainingSpaceForText.width = size.width - labelVisualPadding.x - labelVisualPadding.y;
+      remainingSpaceForText.height = size.height - visualAndPaddingSize.height - labelVisualPadding.top - labelVisualPadding.bottom;
+
       break;
     }
-    case DisabledSelectedState:
+  }
+
+  if ( currentBackGroundVisual )
+  {
+    DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout Setting visual background size to(%f,%f)\n", size.width, size.height);
+
+    Property::Map visualTransform;
+
+    visualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, size )
+                   .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 0.0f, 0.0f, 1.0f, 1.0f) );  // Use relative size
+
+    currentBackGroundVisual.SetTransformAndSize( visualTransform, size );
+  }
+
+  if ( currentVisual )
+  {
+    DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout Setting visual size to(%f,%f)\n", visualSize.width, visualSize.height);
+
+    Property::Map visualTransform;
+
+    visualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, visualSize )
+                   .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, visualPosition )
+                   .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 1.0f, 1.0f, 1.0f, 1.0f) )  // Use absolute size
+                   .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
+                   .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, visualAnchorPoint );
+
+    currentVisual.SetTransformAndSize( visualTransform, size );
+  }
+
+  if ( mTextStringSetFlag )
+  {
+    Toolkit::Visual::Base textVisual = GetVisual( Toolkit::Button::Property::LABEL ); // No need to search for Label visual if no text set.
+
+    if ( textVisual )
     {
-      //Layer Order
-      // (2) mDisabledSelectedContent
-      // (1) mDisabledBackgroundContent
-
-      RemoveButtonImage( mDecoration[ UNSELECTED_DECORATION ] );
-      RemoveButtonImage( mUnselectedContent );
-      RemoveButtonImage( mDecoration[ SELECTED_DECORATION ] );
-      RemoveButtonImage( mSelectedContent );
-      RemoveButtonImage( mBackgroundContent );
-      RemoveButtonImage( mSelectedBackgroundContent );
-      RemoveButtonImage( mDisabledContent );
-
-      if( mDisabledBackgroundContent )
-      {
-        PrepareAddButtonImage( mDisabledBackgroundContent );
-      }
-      else
+      if ( !currentVisual )
       {
-        PrepareAddButtonImage( mBackgroundContent );
-        PrepareAddButtonImage( mSelectedBackgroundContent );
+        DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout Only Text\n");
+        labelPosition.x = labelVisualPadding.left;
+        labelPosition.y = labelVisualPadding.height;
       }
 
-      PrepareAddButtonImage( mDisabledSelectedContent ? mDisabledSelectedContent : mSelectedContent );
+      Vector2 preSize = Vector2( static_cast< int >( remainingSpaceForText.x ), static_cast< int >( remainingSpaceForText.y ));
 
-      PrepareAddButtonImage( mDecoration[ SELECTED_DECORATION ] );
-      ReAddLabel();
-      break;
+      DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout text Size(%f,%f) text Position(%f,%f) \n", remainingSpaceForText.width, remainingSpaceForText.height, labelPosition.x, labelPosition.y);
+
+      DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout text Size -- (%f,%f) text Position(%f,%f) \n", preSize.width, preSize.height, labelPosition.x, labelPosition.y);
+
+
+      Property::Map textVisualTransform;
+      textVisualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, preSize )
+                         .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, labelPosition )
+                         .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 1.0f, 1.0f, 1.0f,1.0f ) ) // Use absolute size
+                         .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN )
+                         .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, visualAnchorPoint );
+
+      textVisual.SetTransformAndSize( textVisualTransform, size );
     }
   }
+
+  DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout << \n");
+}
+
+void Button::OnTap(Actor actor, const TapGesture& tap)
+{
+  // Prevents Parent getting a tap event
+}
+
+void Button::SetUpTimer( float delay )
+{
+  mAutoRepeatingTimer = Dali::Timer::New( static_cast<unsigned int>( 1000.f * delay ) );
+  mAutoRepeatingTimer.TickSignal().Connect( this, &Button::AutoRepeatingSlot );
+  mAutoRepeatingTimer.Start();
 }
 
-void Button::StartTransitionAnimation()
+bool Button::AutoRepeatingSlot()
 {
-  if( mTransitionAnimation )
+  bool consumed = false;
+  if( !IsDisabled() )
   {
-    mTransitionAnimation.Play();
-  }
-  else
+    // Restart the autorepeat timer.
+    SetUpTimer( mNextAutoRepeatingDelay );
+
+    Pressed();
+
+    Toolkit::Button handle( GetOwner() );
+
+    //Emit signal.
+    consumed = mReleasedSignal.Emit( handle );
+    consumed = mClickedSignal.Emit( handle );
+    consumed |= mPressedSignal.Emit( handle );
+ }
+
+  return consumed;
+}
+
+void Button::Pressed()
+{
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::Pressed\n" );
+
+  if( mButtonState == UNSELECTED_STATE )
   {
-    ResetImageLayers();
+    ChangeState( SELECTED_STATE );
+    OnPressed();  // Notifies the derived class the button has been pressed.
   }
 }
 
-void Button::StopTransitionAnimation()
+void Button::Released()
 {
-  if( mTransitionAnimation )
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::Released\n" );
+
+  if( mButtonState == SELECTED_STATE && !mTogglableButton )
   {
-    mTransitionAnimation.Clear();
-    mTransitionAnimation.Reset();
+    ChangeState( UNSELECTED_STATE );
+    OnReleased(); //    // Notifies the derived class the button has been released.
   }
+  mButtonPressedState = UNPRESSED;
 }
 
-Dali::Animation Button::GetTransitionAnimation()
+void Button::SelectRequiredVisual( Property::Index visualIndex )
 {
-  if( !mTransitionAnimation )
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::SelectRequiredVisual index(%d) state(%d)\n", visualIndex, mButtonState );
+
+  EnableVisual( visualIndex, true );
+}
+
+void Button::RemoveVisual( Property::Index visualIndex )
+{
+  // Use OnButtonVisualRemoval if want button developer to have the option to override removal.
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::RemoveVisual index(%d) state(%d)\n", visualIndex, mButtonState );
+
+  Toolkit::Visual::Base visual = GetVisual( visualIndex );
+
+  if( visual )
   {
-    mTransitionAnimation = Dali::Animation::New( GetAnimationTime() );
-    mTransitionAnimation.FinishedSignal().Connect( this, &Button::TransitionAnimationFinished );
+    EnableVisual( visualIndex, false );
   }
-
-  return mTransitionAnimation;
 }
 
-void Button::TransitionAnimationFinished( Dali::Animation& source )
+void Button::OnButtonVisualRemoval( Property::Index visualIndex )
 {
-  StopTransitionAnimation();
-  ResetImageLayers();
+  // Derived Buttons can over ride this to prevent default removal.
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::OnButtonVisualRemoval index(%d)\n", visualIndex );
+  RemoveVisual( visualIndex );
 }
 
 void Button::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
 {
   Toolkit::Button button = Toolkit::Button::DownCast( Dali::BaseHandle( object ) );
 
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::SetProperty index[%d]\n", index );
+
   if ( button )
   {
     switch ( index )
@@ -1380,52 +1162,100 @@ void Button::SetProperty( BaseObject* object, Property::Index index, const Prope
         break;
       }
 
-      case Toolkit::Button::Property::UNSELECTED_STATE_IMAGE:
+      case Toolkit::Button::Property::UNSELECTED_STATE_IMAGE: // Legacy Tizen 3.0
       {
-        GetImplementation( button ).SetUnselectedImage( value.Get< std::string >() );
+        GetImplementation( button ).CreateVisualsForComponent( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, value, DepthIndex::BACKGROUND );
         break;
       }
-
-      case Toolkit::Button::Property::SELECTED_STATE_IMAGE:
+      case Toolkit::Button::Property::DISABLED_STATE_IMAGE:  // Legacy Tizen 3.0
+      {
+        GetImplementation( button ).CreateVisualsForComponent( Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL, value, DepthIndex::BACKGROUND );
+        break;
+      }
+      case Toolkit::Button::Property::SELECTED_STATE_IMAGE:  // Legacy Tizen 3.0
       {
-        GetImplementation( button ).SetSelectedImage( value.Get< std::string >() );
+        GetImplementation( button ).CreateVisualsForComponent( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, value, DepthIndex::BACKGROUND );
+        break;
+      }
+      case Toolkit::DevelButton::Property::UNSELECTED_VISUAL:
+      case Toolkit::DevelButton::Property::SELECTED_VISUAL:
+      case Toolkit::DevelButton::Property::DISABLED_SELECTED_VISUAL:
+      case Toolkit::DevelButton::Property::DISABLED_UNSELECTED_VISUAL:
+      {
+        GetImplementation( button ).CreateVisualsForComponent( index, value, DepthIndex::CONTENT );
         break;
       }
 
-      case Toolkit::Button::Property::DISABLED_STATE_IMAGE:
+      case Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL:
+      case Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL:
+      case Toolkit::DevelButton::Property::DISABLED_SELECTED_BACKGROUND_VISUAL:
+      case Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL:
       {
-        GetImplementation( button ).SetDisabledImage( value.Get< std::string >() );
+        GetImplementation( button ).CreateVisualsForComponent( index , value, DepthIndex::BACKGROUND);
         break;
       }
 
       case Toolkit::Button::Property::UNSELECTED_COLOR:
       {
-        GetImplementation( button ).SetColor( value.Get< Vector4 >(), UnselectedState );
+        DALI_LOG_WARNING("[%s] Using deprecated Property Button::Property::UNSELECTED_COLOR instead use Button::Property::UNSELECTED_BACKGROUND_VISUAL\n", __FUNCTION__);
+        GetImplementation( button ).SetColor( value.Get< Vector4 >(), Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL );
         break;
       }
 
       case Toolkit::Button::Property::SELECTED_COLOR:
       {
-        GetImplementation( button ).SetColor( value.Get< Vector4 >(), SelectedState );
+        DALI_LOG_WARNING("[%s] Using deprecated Property Button::Property::SELECTED_COLOR instead use Button::Property::SELECTED_BACKGROUND_VISUAL\n", __FUNCTION__);
+        GetImplementation( button ).SetColor( value.Get< Vector4 >(), Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL );
         break;
       }
 
       case Toolkit::Button::Property::LABEL_TEXT:
       {
-        GetImplementation( button ).SetLabelText( value.Get< std::string >() );
+        DALI_LOG_WARNING("[%s] Using deprecated Property Button::Property::LABEL_TEXT instead use Button::Property::LABEL\n", __FUNCTION__);
+        GetImplementation( button ).SetLabelText(value.Get< std::string >() );
         break;
       }
 
       case Toolkit::Button::Property::LABEL:
       {
         // Get a Property::Map from the property if possible.
-        Property::Map setPropertyMap;
-        if( value.Get( setPropertyMap ) )
+        Property::Map* setPropertyMap = value.GetMap();
+        if( setPropertyMap )
         {
-          GetImplementation( button ).ModifyLabel( setPropertyMap );
+          Property::Map textVisualProperties;
+          GetImplementation( button ).MergeLabelProperties( *setPropertyMap, textVisualProperties );
+          GetImplementation( button ).CreateVisualsForComponent( index, textVisualProperties, DepthIndex::CONTENT );
+          GetImplementation( button ).RelayoutRequest();
         }
+        break;
+      }
+
+      case Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT:
+      {
+        Button::Align labelAlignment(END);
+        Scripting::GetEnumeration< Button::Align> ( value.Get< std::string >().c_str(),
+                                                    ALIGNMENT_TABLE, ALIGNMENT_TABLE_COUNT,
+                                                    labelAlignment );
+
+        GetImplementation( button ).SetLabelAlignment( labelAlignment );
+        GetImplementation( button ).RelayoutRequest();
+        break;
+      }
+
+      case Toolkit::DevelButton::Property::LABEL_PADDING:
+      {
+        Vector4 padding ( value.Get< Vector4 >() );
+        GetImplementation( button ).SetLabelPadding( Padding( padding.x, padding.y, padding.z, padding.w ) );
+        break;
+      }
+
+      case Toolkit::DevelButton::Property::VISUAL_PADDING:
+      {
+        Vector4 padding ( value.Get< Vector4 >() );
+        GetImplementation( button ).SetForegroundPadding( Padding( padding.x, padding.y, padding.z, padding.w ) );
+        GetImplementation( button ).RelayoutRequest();
+        break;
       }
-      break;
     }
   }
 }
@@ -1442,7 +1272,7 @@ Property::Value Button::GetProperty( BaseObject* object, Property::Index propert
     {
       case Toolkit::Button::Property::DISABLED:
       {
-        value = GetImplementation( button ).mDisabled;
+        value = GetImplementation( button ).IsDisabled();
         break;
       }
 
@@ -1472,25 +1302,43 @@ Property::Value Button::GetProperty( BaseObject* object, Property::Index propert
 
       case Toolkit::Button::Property::SELECTED:
       {
-        value = GetImplementation( button ).mSelected;
+        value = GetImplementation( button ).IsSelected();
         break;
       }
 
       case Toolkit::Button::Property::UNSELECTED_STATE_IMAGE:
       {
-        value = GetImplementation( button ).GetUnselectedImageFilename();
+        value = GetImplementation( button ).GetUrlForImageVisual( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL );
         break;
       }
 
       case Toolkit::Button::Property::SELECTED_STATE_IMAGE:
       {
-        value = GetImplementation( button ).GetSelectedImageFilename();
+        value = GetImplementation( button ).GetUrlForImageVisual( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL );
         break;
       }
 
       case Toolkit::Button::Property::DISABLED_STATE_IMAGE:
       {
-        value = GetImplementation( button ).GetDisabledImageFilename();
+        value = GetImplementation( button ).GetUrlForImageVisual( Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL );
+        break;
+      }
+
+      case Toolkit::DevelButton::Property::UNSELECTED_VISUAL:
+      case Toolkit::DevelButton::Property::SELECTED_VISUAL:
+      case Toolkit::DevelButton::Property::DISABLED_SELECTED_VISUAL:
+      case Toolkit::DevelButton::Property::DISABLED_UNSELECTED_VISUAL:
+      case Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL:
+      case Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL:
+      case Toolkit::DevelButton::Property::DISABLED_SELECTED_BACKGROUND_VISUAL:
+      case Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL:
+      case Toolkit::Button::Property::LABEL:
+      {
+        Property::Map visualProperty;
+        if ( GetImplementation( button ).GetPropertyMapForVisual( propertyIndex, visualProperty ) )
+        {
+          value = visualProperty;
+        }
         break;
       }
 
@@ -1512,143 +1360,241 @@ Property::Value Button::GetProperty( BaseObject* object, Property::Index propert
         break;
       }
 
-      case Toolkit::Button::Property::LABEL:
+      case Toolkit::DevelButton::Property::LABEL_RELATIVE_ALIGNMENT:
       {
-        Property::Map emptyMap;
-        value = emptyMap;
+        const char* alignment = Scripting::GetEnumerationName< Button::Align >( GetImplementation( button ).GetLabelAlignment(),
+                                                                                ALIGNMENT_STRING_TABLE,
+                                                                                ALIGNMENT_STRING_TABLE_COUNT );
+        if( alignment )
+        {
+          value = std::string( alignment );
+        }
+
         break;
       }
+
+      case Toolkit::DevelButton::Property::LABEL_PADDING:
+      {
+        Padding padding = GetImplementation( button ).GetLabelPadding();
+        value = Vector4( padding.x, padding.y, padding.top, padding.bottom);
+        break;
+      }
+
+      case Toolkit::DevelButton::Property::VISUAL_PADDING:
+      {
+        Padding padding = GetImplementation( button ).GetForegroundPadding();
+        value = Vector4( padding.x, padding.y, padding.top, padding.bottom);
+      }
     }
   }
 
   return value;
 }
 
-// Deprecated API
+void Button::SetLabelPadding( const Padding& padding)
+{
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::SetLabelPadding padding(%f,%f,%f,%f)\n", padding.left, padding.right, padding.bottom, padding.top );
+  mLabelPadding = Padding( padding.left, padding.right, padding.bottom, padding.top );
+  RelayoutRequest();
+}
 
-void Button::SetLabel( Actor label )
+Padding Button::GetLabelPadding()
 {
-  if( mLabel != label )
-  {
-    if( mLabel && mLabel.GetParent() )
-    {
-      mLabel.GetParent().Remove( mLabel );
-    }
+  return mLabelPadding;
+}
 
-    mLabel = label;
-    mLabel.SetPosition( 0.0f, 0.0f );
+void Button::SetForegroundPadding( const Padding& padding)
+{
+  DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::SetForegroundPadding padding(%f,%f,%f,%f)\n", padding.left, padding.right, padding.bottom, padding.top );
+  mForegroundPadding = Padding( padding.left, padding.right, padding.bottom, padding.top );
+  RelayoutRequest();
+}
 
-    // label should be the top of the button
-    Self().Add( mLabel );
+Padding Button::GetForegroundPadding()
+{
+  return mForegroundPadding;
+}
 
-    ResetImageLayers();
-    OnLabelSet( true );
+////////////////////////////////////////////////////////////////////////
+// Legacy functions from Tizen 2.4 and 3.0
 
-    RelayoutRequest();
+// Legacy code needed whilst Color can be set by direct Property setting ( deprecated ) instead of setting a Visual
+void Button::SetColor( const Vector4& color, Property::Index visualIndex )
+{
+  if ( visualIndex == Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL )
+  {
+    mSelectedColor = color;
   }
+  else
+  {
+    mUnselectedColor = color;
+  }
+
+  Property::Map map;
+  map[ Toolkit::Visual::Property::TYPE ] = Toolkit::Visual::COLOR;
+  map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
+
+  CreateVisualsForComponent( visualIndex, map, DepthIndex::BACKGROUND );
 }
 
-void Button::SetButtonImage( Actor image )
+const Vector4 Button::GetUnselectedColor() const
 {
-  if( image )
-  {
-    StopTransitionAnimation();
+  return mUnselectedColor;
+}
 
-    SetupContent( mUnselectedContent, image );
+const Vector4 Button::GetSelectedColor() const
+{
+  return mSelectedColor;
+}
 
-    OnUnselectedImageSet();
-    RelayoutRequest();
-  }
+void Button::SetAnimationTime( float animationTime )
+{
+  // Used by deprecated API
+  mAnimationTime = animationTime;
 }
 
-void Button::SetSelectedImage( Actor image )
+float Button::GetAnimationTime() const
 {
-  if( image )
-  {
-    StopTransitionAnimation();
+  // Used by deprecated API
+  return mAnimationTime;
+}
 
-    SetupContent( mSelectedContent, image );
+void Button::SetLabel( Actor label )
+{
+  if ( label )
+  {
+    Property::Value value ="";
+    value = label.GetProperty(Toolkit::TextLabel::Property::TEXT);
 
-    OnSelectedImageSet();
-    RelayoutRequest();
+    SetLabelText( value.Get<std::string>() );
   }
 }
 
-void Button::SetBackgroundImage( Actor image )
+void Button::SetUnselectedImage( const std::string& filename )
 {
-  if( image )
+  SetBackgroundImage( filename );
+}
+
+void Button::SetBackgroundImage( const std::string& filename )
+{
+  if( !filename.empty() )
+  {
+    CreateVisualsForComponent( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, filename, DepthIndex::BACKGROUND );
+  }
+  else
   {
-    StopTransitionAnimation();
+    UnregisterVisual( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL );
+  }
+}
 
-    SetupContent( mBackgroundContent, image );
+void Button::SetSelectedImage( const std::string& filename )
+{
+    SetSelectedBackgroundImage( filename );
+}
 
-    OnBackgroundImageSet();
-    RelayoutRequest();
+void Button::SetSelectedBackgroundImage( const std::string& filename )
+{
+  if( !filename.empty() )
+  {
+    CreateVisualsForComponent( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, filename, DepthIndex::BACKGROUND );
+  }
+  else
+  {
+    UnregisterVisual( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL );
   }
 }
 
-void Button::SetSelectedBackgroundImage( Actor image )
+void Button::SetDisabledBackgroundImage( const std::string& filename )
 {
-  if( image )
+  if( !filename.empty() )
   {
-    StopTransitionAnimation();
-
-    SetupContent( mSelectedBackgroundContent, image );
-
-    OnSelectedBackgroundImageSet();
-    RelayoutRequest();
+    CreateVisualsForComponent( Toolkit::DevelButton::Property::DISABLED_UNSELECTED_BACKGROUND_VISUAL, filename, DepthIndex::BACKGROUND );
   }
 }
 
-void Button::SetDisabledImage( Actor image )
+void Button::SetDisabledImage( const std::string& filename )
 {
-  if( image )
+  if( !filename.empty() )
   {
-    StopTransitionAnimation();
-
-    SetupContent( mDisabledContent, image );
-
-    OnDisabledImageSet();
-    RelayoutRequest();
+    CreateVisualsForComponent( Toolkit::DevelButton::Property::DISABLED_UNSELECTED_VISUAL, filename, DepthIndex::CONTENT );
   }
 }
 
-void Button::SetDisabledSelectedImage( Actor image )
+void Button::SetDisabledSelectedImage( const std::string& filename )
 {
-  if( image )
+  if( !filename.empty() )
   {
-    StopTransitionAnimation();
+    CreateVisualsForComponent( Toolkit::DevelButton::Property::DISABLED_SELECTED_VISUAL, filename, DepthIndex::CONTENT );
+  }
+}
 
-    SetupContent( mDisabledSelectedContent, image );
+// Used by Deprecated Properties which don't use the Visual Property maps for setting and getting
+std::string Button::GetUrlForImageVisual( const Property::Index index ) const
+{
+  Toolkit::Visual::Base visual = GetVisual( index );
+  std::string result;
 
-    OnDisabledSelectedImageSet();
-    RelayoutRequest();
+  if ( visual )
+  {
+    Dali::Property::Map retreivedMap;
+    visual.CreatePropertyMap( retreivedMap );
+    Property::Value* value = retreivedMap.Find(  Toolkit::ImageVisual::Property::URL,  Property::STRING );
+    if ( value )
+    {
+      result = value->Get<std::string>();
+    }
   }
+
+  return result;
 }
 
-void Button::SetDisabledBackgroundImage( Actor image )
+// Below functions DEPRECATED_1_0.50 - Return empty Actors
+
+namespace
 {
-  if( image )
-  {
-    StopTransitionAnimation();
+std::string GetUrlFromImage( Image& image )
+{
+  ResourceImage resourceImage = ResourceImage::DownCast( image );
 
-    SetupContent( mDisabledBackgroundContent, image );
+  std::string imageUrl;
 
-    OnDisabledBackgroundImageSet();
-    RelayoutRequest();
+  if ( resourceImage )
+  {
+    imageUrl = resourceImage.GetUrl();
   }
+  return imageUrl;
+}
+
+} // namespace
+
+
+void Button::SetButtonImage( Image image )
+{
+  DALI_LOG_WARNING("Button::SetButtonImage @DEPRECATED_1_0.50\n");
+  SetUnselectedImage( GetUrlFromImage( image ) );
+}
+
+void Button::SetSelectedImage( Image image )
+{
+  DALI_LOG_WARNING("Button::SetSelectedImage @DEPRECATED_1_0.50\n");
+  SetSelectedImage( GetUrlFromImage( image ) );
 }
 
 Actor Button::GetButtonImage() const
 {
-  return mUnselectedContent;
+  DALI_LOG_WARNING("Button::GetButtonImage @DEPRECATED_1_0.50\n");
+  Actor imageView = Toolkit::ImageView::New( GetUrlForImageVisual( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL ) );
+
+  return imageView;
 }
 
 Actor Button::GetSelectedImage() const
 {
-  return mSelectedContent;
-}
+  DALI_LOG_WARNING("Button::GetSelectedImage @DEPRECATED_1_0.50\n");
+  Actor imageView = Toolkit::ImageView::New( GetUrlForImageVisual( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL ) );
 
+  return imageView;
+}
 
 } // namespace Internal
 
index da2557f..a079cd5 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_BUTTON_H__
-#define __DALI_TOOLKIT_INTERNAL_BUTTON_H__
+#ifndef DALI_TOOLKIT_INTERNAL_BUTTON_H
+#define DALI_TOOLKIT_INTERNAL_BUTTON_H
 
 /*
  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
@@ -23,7 +23,8 @@
 #include <dali/public-api/animation/animation.h>
 
 // INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/buttons/button.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
+#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
 
 namespace Dali
@@ -38,7 +39,16 @@ namespace Internal
 {
 
 /**
+ * @copydoc Toolkit::Button
+ *
  * Button is the base class implementation for all buttons.
+ *
+ * @note
+ *
+ * All Foreground/Icon visuals expected to be the same size.
+ * Background visuals will take the size of the control.
+ * Padding and struts take size precedence over visuals when available space is limited.
+ * Icon/Foreground visuals take size precedence over Labels when available space is limited.
  */
 class Button : public Control
 {
@@ -46,6 +56,19 @@ class Button : public Control
 public:
 
   /**
+   * Enum describing the position the text label can be in relation to the control (and foreground/icon)
+   */
+  enum Align
+  {
+    BEGIN,  // At the start of the control before the foreground/icon
+    END,    // At the end of the control after the foreground/icon
+    TOP,    // At the top of the control above the foreground/icon
+    BOTTOM  // At the bottom of the control below the foreground/icon
+  };
+
+public:
+
+  /**
    * @copydoc Dali::Toolkit::Button::SetDisabled
    */
   void SetDisabled( bool disabled );
@@ -126,82 +149,13 @@ public:
   std::string GetLabelText() const;
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetUnselectedImage
-   */
-  void SetUnselectedImage( const std::string& filename );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetSelectedImage
-   */
-  void SetSelectedImage( const std::string& filename );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage
-   */
-  void SetBackgroundImage( const std::string& filename );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetSelectedBackgroundImage
-   */
-  void SetSelectedBackgroundImage( const std::string& filename );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledImage
-   */
-  void SetDisabledImage( const std::string& filename );
-
-  /**
-   * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage
-   */
-  void SetDisabledSelectedImage( const std::string& filename );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage
-   */
-  void SetDisabledBackgroundImage( const std::string& filename );
-
-  /**
-   * @return The filename used for the button image.
-   */
-  std::string GetUnselectedImageFilename() const;
-
-  /**
-   * @return The filename used for the selected image.
-   */
-  std::string GetSelectedImageFilename() const;
-
-  /**
-   * @return The filename used for the background image.
-   */
-  std::string GetBackgroundImageFilename() const;
-
-  /**
-   * @return The filename used for the selected background image.
-   */
-  std::string GetSelectedBackgroundImageFilename() const;
-
-  /**
-   * @return The filename used for the disabled button image.
-   */
-  std::string GetDisabledImageFilename() const;
-
-  /**
-   * @return The filename used for the disabled selected image.
-   */
-  std::string GetDisabledSelectedImageFilename() const;
-
-  /**
-   * @return The filename used for the disabled background image.
-   */
-  std::string GetDisabledBackgroundImageFilename() const;
-
-  /**
-   * @brief Sets the specified properties on the button label.
+   * @brief Produces a Property::Map of Text properties to create a Text Visual
    * If the label does not exist yet, it is created.
    * The derived buttons are notified if any properties are changed.
    * @param[in] properties A Property::Map of key-value pairs of properties to set.
+   * @param[out] properties A Property::Map of text visual  properties to set.
    */
-  void ModifyLabel( const Property::Map& properties );
+  void MergeLabelProperties( const Property::Map& inMap, Property::Map& outMap );
 
   /**
    * Performs actions as requested using the action name.
@@ -220,46 +174,65 @@ public: // Deprecated API
   void SetLabel( Actor label );
 
   /**
-   * @deprecated Sets the unselected image with an Actor.
+   * @deprecated Sets the unselected image with an url.
    * @param[in] image The Actor to use.
    */
-  void SetButtonImage( Actor image );
+  void SetUnselectedImage( const std::string& filename );
 
   /**
-   * @deprecated Sets the selected image with an Actor.
-   * @param[in] image The Actor to use.
+   * @deprecated Sets the selected image with an url.
+   * @param[in] filename The url of the image to use to use.
    */
-  void SetSelectedImage( Actor image );
+  void SetSelectedImage( const std::string& filename );
 
   /**
-   * @deprecated Sets the background image with an Actor.
-   * @param[in] image The Actor to use.
+   * @deprecated Sets the selected background image with an url.
+   * @param[in] filename The url of the image to use to use.
    */
-  void SetBackgroundImage( Actor image );
+  void SetSelectedBackgroundImage( const std::string& filename );
 
   /**
-   * @deprecated Sets the selected background image with an Actor.
-   * @param[in] image The Actor to use.
+   * @deprecated Sets the background image with an url.
+   * @param[in] filename The url of the image to use to use.
    */
-  void SetSelectedBackgroundImage( Actor image );
+  void SetBackgroundImage( const std::string& filename );
 
   /**
-   * @deprecated Sets the disabled image with an Actor.
-   * @param[in] image The Actor to use.
+   * @deprecated Sets the disabled unselected background image with an url.
+   * @param[in] filename The url of the image to use to use.
    */
-  void SetDisabledImage( Actor image );
+  void SetDisabledBackgroundImage( const std::string& filename );
 
   /**
-   * @deprecated Sets the disabled selected image with an Actor.
-   * @param[in] image The Actor to use.
+   * @deprecated Sets the disabled unselected image with an url.
+   * @param[in] filename The url of the image to use to use.
    */
-  void SetDisabledSelectedImage( Actor image );
+  void SetDisabledImage( const std::string& filename );
 
   /**
-   * @deprecated Sets the disabled background image with an Actor.
-   * @param[in] image The Actor to use.
+   * @deprecated Sets the disabled selected image with an url.
+   * @param[in] filename The url of the image to use to use.
    */
-  void SetDisabledBackgroundImage( Actor image );
+  void SetDisabledSelectedImage( const std::string& filename );
+
+  /**
+   * @deprecated Sets the unselected image with an Actor.
+   * @param[in] image The Image to use.
+   */
+  void SetButtonImage( Image image );
+
+  /**
+   * @deprecated Sets the selected image with an Actor.
+   * @param[in] image The Image to use.
+   */
+  void SetSelectedImage( Image image );
+
+  /**
+   * @Gets url of a image visual, used by GetProperty but for deprecated Properties
+   * @param[in] index Visual index of url required
+   * @return filename for the corresponding visual
+   */
+  std::string GetUrlForImageVisual( const Property::Index index ) const;
 
   /**
    * @copydoc Dali::Toolkit::Button::GetButtonImage
@@ -271,33 +244,57 @@ public: // Deprecated API
    */
   Actor GetSelectedImage() const;
 
-protected:
+public:
+
+  /**
+   * Button's state
+   */
+  enum State
+  {
+    UNSELECTED_STATE,              ///< The button is unselected.
+    SELECTED_STATE,                ///< The button is selected.
+    DISABLED_UNSELECTED_STATE,     ///< The button is disabled and unselected.
+    DISABLED_SELECTED_STATE,       ///< The button is disabled and selected.
+    STATE_COUNT,                   ///< Number of States
+  };
 
-  enum ButtonState
+  /**
+   * Enum to distinguish the different style-able components of the button
+   */
+  enum Visuals
   {
-    ButtonUp,                                  ///< The button is up.
-    ButtonDown,                                ///< The button is down.
+    UNSELECTED_FOREGROUND = 0,
+    SELECTED_FOREGROUND,
+    DISABLED_SELECTED_FOREGROUND,
+    DISABLED_UNSELECTED_FOREGROUND,
+    UNSELECTED_BACKGROUND,
+    SELECTED_BACKGROUND,
+    DISABLED_UNSELECTED_BACKGROUND,
+    DISABLED_SELECTED_BACKGROUND,
+    VISUALS_COUNT
   };
 
   /**
-   * Button paint states.
+   * Enum to list types of visual a state can have.
    */
-  enum PaintState
+  enum VisualState
   {
-    UnselectedState,              ///< The button is unselected.
-    SelectedState,                ///< The button is selected.
-    DisabledUnselectedState,      ///< The button is disabled and unselected.
-    DisabledSelectedState,        ///< The button is disabled and selected.
+    BACKGROUND = 0,
+    FOREGROUND,
+    VISUAL_STATE_COUNT
   };
 
+protected:
+
   /**
-   * Enum to specify which decoration when getting and setting decorations.
+   * Button press state which is not the same as the actual button's state.
+   * For example An UNSELECTED button can be DEPRESSED, but until released, the actual button state doesn't change to SELECTED
    */
-  enum DecorationState
+  enum PressState
   {
-    UNSELECTED_DECORATION = 0,
-    SELECTED_DECORATION,
-    DECORATION_STATES
+    DEPRESSED,                           ///< The button is up.
+    UNPRESSED,                           ///< The button is down.
+    TOGGLE_DEPRESSED,                    ///< The button has been pressed down and will stay depressed when released.
   };
 
   /**
@@ -317,37 +314,12 @@ protected:
   /**
    * @return A reference to the unselected button image.
    */
-  Actor& GetUnselectedImage();
+  Actor GetUnselectedImage();
 
   /**
    * @return A reference to the selected image.
    */
-  Actor& GetSelectedImage();
-
-  /**
-   * @return A reference to the background image.
-   */
-  Actor& GetBackgroundImage();
-
-  /**
-   * @return A reference to the selected background image.
-   */
-  Actor& GetSelectedBackgroundImage();
-
-  /**
-   * @return A reference to the disabled button image.
-   */
-  Actor& GetDisabledImage();
-
-  /**
-   * @return A reference to the disabled selected image.
-   */
-  Actor& GetDisabledSelectedImage();
-
-  /**
-   * @return A reference to the disabled background image.
-   */
-  Actor& GetDisabledBackgroundImage();
+  Actor GetSelectedImage();
 
 private:
 
@@ -359,57 +331,11 @@ private:
   bool DoClickAction( const Property::Map& attributes );
 
   /**
-   * This method is called when the label is set.
-   * @param[in] noPadding Used to bypass padding if the label is to be treated generically.
-   */
-  virtual void OnLabelSet( bool noPadding ) {}
-
-  /**
-   * This method is called when the unselected button image is set
-   */
-  virtual void OnUnselectedImageSet() {}
-
-  /**
-   * This method is called when the selected image is set
-   */
-  virtual void OnSelectedImageSet() {}
-
-  /**
-   * This method is called when the background image is set
-   */
-  virtual void OnBackgroundImageSet() {}
-
-  /**
-   * This method is called when the selected background image is set
-   */
-  virtual void OnSelectedBackgroundImageSet() {}
-
-  /**
-   * This method is called when the disabled button image is set
-   */
-  virtual void OnDisabledImageSet() {}
-
-  /**
-   * This method is called when the disabled selected image is set
-   */
-  virtual void OnDisabledSelectedImageSet() {}
-
-  /**
-   * This method is called when the disabled background image is set
-   */
-  virtual void OnDisabledBackgroundImageSet() {}
-
-  /**
-   * This method is called the button is down.
-   * Could be reimplemented in subclasses to provide specific behaviour.
-   */
-  virtual void OnButtonDown();
-
-  /**
-   * This method is called when the button is up.
+   * This method is called when the button is a Toggle button and released
    * Could be reimplemented in subclasses to provide specific behaviour.
+   * @return bool returns true if state changed.
    */
-  virtual void OnButtonUp();
+  virtual bool OnToggleReleased();
 
   /**
    * This method is called when touch leaves the boundary of the button or several touch points are received.
@@ -426,7 +352,7 @@ private:
   /**
    * This method is called when the \e selected property is changed.
    */
-  virtual void OnSelected() {}
+  virtual void OnStateChange( State newState ){}
 
   /**
    * This method is called when the \e disabled property is changed.
@@ -516,8 +442,27 @@ protected: // From Control
    * @copydoc Toolkit::Control::OnStageDisconnection()
    * @note If overridden by deriving button classes, then an up-call to Button::OnStageDisconnection MUST be made at the end.
    */
-  void OnStageDisconnection();
+  virtual void OnStageDisconnection();
 
+  /**
+   * @copydoc Toolkit::Control::OnStageConnnection()
+   */
+  virtual void OnStageConnection( int depth );
+
+  /**
+   * @copydoc Toolkit::Control::GetNaturalSize
+   */
+  virtual Vector3 GetNaturalSize();
+
+  /**
+   * @copydoc Toolkit::Control::OnSetResizePolicy
+   */
+  virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension );
+
+  /**
+   * @copydoc Toolkit::Control::OnRelayout
+   */
+  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
 
 private:
 
@@ -546,160 +491,152 @@ private:
   void SetUpTimer( float delay );
 
   /**
-   * Slot called when Dali::Timer::SignalTick signal. Resets the autorepeating timer.
+   * Button has been pressed
    */
-  bool AutoRepeatingSlot();
+  void Pressed();
 
   /**
-   * Sets the button as selected or unselected.
-   * @param[in] selected \e selected property value.
-   * @param[in] emitSignal Emit a signal if this value is \e true.
+   * This method is called the button is down.
    */
-  void SetSelected( bool selected, bool emitSignal );
+  void ButtonDown();
 
   /**
-   * This method is called when the button is pressed.
+   * This method is called when the button is up.
    */
-  void Pressed();
+  void ButtonUp();
 
   /**
-   * This method is called when the button is released.
+   * Slot called when Dali::Timer::SignalTick signal. Resets the autorepeating timer.
    */
-  void Released();
+  bool AutoRepeatingSlot();
 
   /**
-   * Used to perform common setup applied to images within button.
-   * This will replace the current image with the specifed one.
-   * @param[in]  actorToModify The image to replace.
-   * @param[out] newActor The new image to use.
+   *  Check the requested state is an allowed transition.
+   *  Some states can not be transitioned to from certain states.
+   *  @param[in] requestedState check if can transition to this state
+   *  @return bool true if state change valid
    */
-  void SetupContent( Actor& actorToModify, Actor newActor );
+  bool ValidateState( State requestedState );
 
   /**
-   * Gets the unselected content color.
-   * @return     The currently used unselected color.
+   * Perform the given function on the visuals in the given state. Can be used to add and remove visuals.
+   * @param[in] functionPtr pointer to the function to perform an action on a visual
+   * @param[in] state Visuals in this state will be the target
    */
-  const Vector4 GetUnselectedColor() const;
+  void PerformFunctionOnVisualsInState( void(Button::*functionPtr)( Property::Index visualIndex), State state  );
 
   /**
-   * Sets the color of button in selected or unselected state, if image also supplied this color will be appplied to it.
-   * If no visual exists, it is created.
-   * @param[in]  color The color to use.
-   * @param[in]  selectedState The state to apply the color to, SelectedState or DisabledUnselectedState.
+   * Changes the button state when an action occurs on it
+   * @param[in] requestedState the state to change to
    */
-  void SetColor( const Vector4& color, PaintState selectedState );
+  void ChangeState( State requestedState );
 
   /**
-   * Gets the selected content color.
-   * @return     The currently used selected color.
+   * @brief Get unselected button color
+   * @return color as vector4
    */
-  const Vector4 GetSelectedColor() const;
-
-protected:
-
-  ButtonState GetState();
-  PaintState GetPaintState();
-  void SetDecoration( DecorationState state, Actor actor );
-  Actor& GetDecoration( DecorationState state );
-
+  const Vector4 GetUnselectedColor() const;
 
   /**
-   * Returns the animation to be used for transitioning creating the animation if needed.
-   * @return The initialised transition animation.
+   * @brief Get selected button color
+   * @return color as vector4
    */
-  Dali::Animation GetTransitionAnimation();
+  const Vector4 GetSelectedColor() const;
 
   /**
-   * Prepares the actor to be transitioned in.
-   * @param[in]  actor  The actor that will be transitioned in.
+   * Sets the color of button in selected or unselected state, if image also supplied this color will be appplied to it.
+   * If no visual exists, it is created.
+   * @param[in]  color The color to use.
+   * @param[in]  visualIndex The Visual to apply the color
    */
-  virtual void PrepareForTranstionIn( Actor actor ) {}
+  void SetColor( const Vector4& color, Property::Index visualIndex );
 
   /**
-   * Prepares the actor to be transitioned in.
-   * @param[in]  actor  The actor that will be transitioned out.
+   * This method is called when the button is released.
    */
-  virtual void PrepareForTranstionOut( Actor actor ) {}
+  void Released();
 
-  /**
-   * Transitions the actor in, allowing derived classes to configure
-   * the GetTransitionAnimation() animation ready.
-   * Button is in charge of calling Dali::Animation::Play and so derived classes
-   * only need to add the animation.
-   */
-  virtual void OnTransitionIn( Actor actor ) {}
+protected:
 
   /**
-   * Transitions the actor out, allowing derived classes to configure
-   * the GetTransitionAnimation() animation ready.
-   * Button is in charge of calling Dali::Animation::Play and so derived classes
-   * only need to add the animation.
+   * Set Text Label Padding
+   * @param[in] padding BEGIN END BOTTOM TOP
    */
-  virtual void OnTransitionOut( Actor actor ) {}
-
-private:
+  void SetLabelPadding( const Padding& padding );
 
   /**
-   * Starts the transition animation.
-   * Button::TransitionFinished is called when the animation finishes.
+   * Get Text Label padding
+   * @return Padding
    */
-  void StartTransitionAnimation();
+  Padding GetLabelPadding();
 
   /**
-   * This method stops all transition animations
+   * Set Foreground/icon Padding
+   * @param[in] padding BEGIN END BOTTOM TOP
    */
-  void StopTransitionAnimation();
+  void SetForegroundPadding( const Padding& padding);
 
   /**
-   * Called when the transition animation finishes.
+   * Get Foreground padding
+   * @ return Padding
    */
-  void TransitionAnimationFinished( Dali::Animation& source );
+  Padding GetForegroundPadding();
 
   /**
-   * Resets the Button to the base state for the current paint state.
-   * Any additionally inserted images needed for transitions that are
-   * no longer needed and the removed.
+   * @brief Setup the button components for example foregrounds and background
+   * @param[in] index the index of the visual to set
+   * @param[in] value the value to set on the component
+   * @param[in] visualDepth the depth of the visual if overlapping another
    */
-  void ResetImageLayers();
+  void CreateVisualsForComponent( Property::Index index ,const Property::Value& value, const float visualDepth );
 
   /**
-   * Transitions out the actor
+   * @brief Get the Property map for the given Visual
+   * @param[in] visualIndex visual index of the required visual
+   * @param[out] retreivedMap the property map used to construct the required visual
+   * @return bool success flag, true if visual found
    */
-  void TransitionOut( Actor actor );
-
+  bool GetPropertyMapForVisual( Property::Index visualIndex, Property::Map& retreivedMap ) const;
   /**
-   * Removes the actor from the button and prepares it to be transitioned out
+   * Returns the animation to be used for transition, creating the animation if needed.
+   * @return The initialised transition animation.
    */
-  void RemoveButtonImage( Actor& actor );
+  Dali::Animation GetTransitionAnimation();
 
   /**
-   * Finds the index of the actor.
-   * If the actor doesn't exist, return the last index + 1.
+   * @brief Set the position of the label relative to foreground/icon, if both present
+   * @param[in] labelAlignment given alignment setting
    */
-  unsigned int FindChildIndex( Actor& actor );
+  void SetLabelAlignment( Align labelAlignment);
 
   /**
-   * Adds an actor to the hierarchy and prepares it to be transitioned.
-   * @param[in] actor The actor to add
+   * @brief Get set alignment of label in relation to foreground/icon
+   * @return Set alignment value
    */
-  void PrepareAddButtonImage( Actor& actor );
+  Align GetLabelAlignment();
 
   /**
-   * Adds an actor to the hierarchy and marks it to be transitioned.
-   * @param[in] actor The actor to add
+   * Removes the visual from the button (un-staged)
+   * If the derived button does not want the visual removed then use this virtual function to
+   * define the required behaviour.
+   * Can decide to only remove specified visuals via index
    */
-  void TransitionButtonImage( Actor& actor );
+  virtual void OnButtonVisualRemoval( Property::Index visualIndex );
+
+
+private:
 
   /**
-   * Adds an actor to the hierarchy.
-   * @param[in] actor The actor to add
+   * Removes the visual from the button and prepares it to be transitioned out
+   * @param[in] visualIndex the visual to remove
    */
-  void AddButtonImage( Actor& actor );
+  void RemoveVisual( Property::Index visualIndex );
 
   /**
-   * (Re)Adds the label (if exists) to the hierarchy (so it is always on top).
+   * Adds the required visual to the button.
+   * @param[in] visualIndex The Property index of the visual required
    */
-  void ReAddLabel();
+  void SelectRequiredVisual( Property::Index visualIndex );
 
   // Undefined
   Button( const Button& );
@@ -715,41 +652,34 @@ private:
   Toolkit::Button::ButtonSignalType mClickedSignal;           ///< Signal emitted when the button is clicked.
   Toolkit::Button::ButtonSignalType mStateChangedSignal;      ///< Signal emitted when the button's state is changed.
 
-  Timer mAutoRepeatingTimer;                   ///< Timer used to implement the autorepeating property.
+  Timer            mAutoRepeatingTimer;
 
-  Actor mLabel;                                ///< Stores the button label.
+  Actor            mLabel;                      ///< Stores the button text label.
+  Padding          mLabelPadding;               ///< The padding around the label (if present).
+  Padding          mForegroundPadding;          ///< The padding around the foreground/icon visual (if present).
 
-  Actor mDecoration[ DECORATION_STATES ];      ///< Stores the decorations for both selected and unselected states.
+  Align            mTextLabelAlignment;           ///< Position of text label in relation to foreground/icon when both are present.
 
-  Actor mUnselectedContent;                    ///< Stores the unselected content.
-  Actor mSelectedContent;                      ///< Stores the selected content.
-  Actor mBackgroundContent;                    ///< Stores the background content.
-  Actor mSelectedBackgroundContent;            ///< Stores the selected background content.
-  Actor mDisabledContent;                      ///< Stores the disabled content.
-  Actor mDisabledSelectedContent;              ///< Stores the disabled selected content.
-  Actor mDisabledBackgroundContent;            ///< Stores the disabled background content.
+  TapGestureDetector mTapDetector;
 
-  Animation        mTransitionAnimation;       ///< Animation used in the state transitions.
+  Vector4          mUnselectedColor;
+  Vector4          mSelectedColor;
 
-  TapGestureDetector mTapDetector;
+  bool             mAutoRepeating;              ///< Stores the autorepeating property.
+  bool             mTogglableButton;            ///< Stores the togglable property as a flag.
+  bool             mTextStringSetFlag;          ///< Stores if text has been set. Required in relayout but don't want to calculate there.
 
-  Vector4          mUnselectedColor;           ///< Color to use for unselected content.
-  Vector4          mSelectedColor;             ///< Color to use for selected content.
+  float            mInitialAutoRepeatingDelay;  ///< Stores the initial autorepeating delay in seconds.
+  float            mNextAutoRepeatingDelay;     ///< Stores the next autorepeating delay in seconds.
 
-  bool             mDisabled;                  ///< Stores the disabled property.
-  bool             mAutoRepeating;             ///< Stores the autorepeating property.
-  bool             mTogglableButton;           ///< Stores the togglable property.
-  bool             mSelected;                  ///< Stores the selected state.
-  float            mInitialAutoRepeatingDelay; ///< Stores the initial autorepeating delay in seconds.
-  float            mNextAutoRepeatingDelay;    ///< Stores the next autorepeating delay in seconds.
+  float            mAnimationTime;
 
-  float            mAnimationTime;             ///< The animation time.
+  PressState       mButtonPressedState;         ///< In relation to the button being pressed/released
+  State            mButtonState;
+  State            mPreviousButtonState;        ///< During a transition between two states, this stores the previous state so Visuals can be removed.
 
   // Actions
-  bool             mClickActionPerforming;
-
-  ButtonState      mState;                     ///< Stores the button state.
-  PaintState       mPaintState;                ///< Stores the paint state.
+  bool             mClickActionPerforming;      ///< Used to manage signal emissions during action
 };
 
 } // namespace Internal
@@ -778,4 +708,4 @@ inline const Toolkit::Internal::Button& GetImplementation( const Toolkit::Button
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_INTERNAL_BUTTON_H__
+#endif // DALI_TOOLKIT_INTERNAL_BUTTON_H
index 5bf5344..9554ccb 100644 (file)
@@ -19,6 +19,7 @@
 #include "check-box-button-impl.h"
 
 // EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/images/resource-image.h>
 
 #include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
 #include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
 
+#if defined(DEBUG_ENABLED)
+  extern Debug::Filter* gLogButtonFilter;
+#endif
+
 namespace Dali
 {
 
@@ -40,9 +45,6 @@ namespace Internal
 namespace
 {
 
-const float DISTANCE_BETWEEN_IMAGE_AND_LABEL( 5.0f );
-const float ANIMATION_TIME( 0.26f );  // EFL checkbox tick time
-
 BaseHandle Create()
 {
   return Toolkit::CheckBoxButton::New();
@@ -50,10 +52,8 @@ BaseHandle Create()
 
 TypeRegistration mType( typeid(Toolkit::CheckBoxButton), typeid(Toolkit::Button), Create );
 
-const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-unselected.png";
-const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-selected.png";
-const char* const DISABLED_UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-unselected-disabled.png";
-const char* const DISABLED_SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "checkbox-selected-diabled.png";
+
+
 }
 
 Dali::Toolkit::CheckBoxButton CheckBoxButton::New()
@@ -75,168 +75,17 @@ CheckBoxButton::CheckBoxButton()
 : Button()
 {
   SetTogglableButton( true );
-
-  SetAnimationTime( ANIMATION_TIME );
 }
 
 CheckBoxButton::~CheckBoxButton()
 {
 }
 
-void CheckBoxButton::SetTickUVEffect()
-{
-  Toolkit::ImageView imageView = Toolkit::ImageView::DownCast( mSelectedImage );
-  if( imageView )
-  {
-    imageView.RegisterProperty( "uTextureRect", Vector4(0.f, 0.f, 1.f, 1.f ) );
-    imageView.RegisterProperty( "uTopLeft", Vector2::ZERO );
-
-    Property::Map shaderMap = CreateImageRegionEffect();
-    imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, shaderMap );
-
-    GetImpl( imageView ).SetDepthIndex( DepthIndex::DECORATION );
-  }
-}
-
 void CheckBoxButton::OnInitialize()
 {
   Button::OnInitialize();
-
-  // Wrap around all children
-  Self().SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
-
-  SetUnselectedImage( UNSELECTED_BUTTON_IMAGE_DIR );
-  SetSelectedImage( SELECTED_BUTTON_IMAGE_DIR );
-  SetDisabledImage( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR );
-  SetDisabledSelectedImage( DISABLED_SELECTED_BUTTON_IMAGE_DIR );
-
-  mSelectedImage = GetSelectedImage();
-  SetTickUVEffect();
 }
 
-void CheckBoxButton::OnLabelSet( bool noPadding )
-{
-  Actor& label = GetLabelActor();
-
-  if( label )
-  {
-    label.SetParentOrigin( ParentOrigin::CENTER_LEFT );
-    label.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
-
-    if( IsDisabled() && GetDisabledBackgroundImage() )
-    {
-      label.SetX( GetDisabledBackgroundImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
-    }
-    else if ( GetBackgroundImage() )
-    {
-      label.SetX( GetBackgroundImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
-    }
-    else if( IsSelected() && GetSelectedImage())
-    {
-      label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
-    }
-    else if( GetUnselectedImage() )
-    {
-      label.SetX( GetUnselectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
-    }
-    else
-    {
-      label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
-    }
-  }
-}
-
-void CheckBoxButton::OnDisabled()
-{
-  Actor& backgroundImage = GetBackgroundImage();
-  Actor& disabledBackgroundImage = GetDisabledBackgroundImage();
-
-  Actor& label = GetLabelActor();
-  if( label )
-  {
-    if( IsDisabled() && disabledBackgroundImage )
-    {
-      label.SetX( disabledBackgroundImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
-    }
-    else if( backgroundImage )
-    {
-      label.SetX( backgroundImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
-    }
-    else if( IsSelected() && GetSelectedImage())
-    {
-      label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
-    }
-    else if( GetUnselectedImage() )
-    {
-      label.SetX( GetUnselectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
-    }
-    else
-    {
-      label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
-    }
-  }
-}
-
-void CheckBoxButton::PrepareForTranstionIn( Actor actor )
-{
-  Actor& selectedImage = GetSelectedImage();
-  if( actor == selectedImage )
-  {
-    actor.SetScale( Vector3( 0.0f, 1.0f, 1.0f ) );
-    actor.RegisterProperty( "uBottomRight", Vector2( 0.0f, 1.0f ) );
-
-    if( mSelectedImage != selectedImage )
-    {
-      mSelectedImage = selectedImage;
-      SetTickUVEffect();
-    }
-  }
-}
-
-void CheckBoxButton::PrepareForTranstionOut( Actor actor )
-{
-  Actor& selectedImage = GetSelectedImage();
-  if( actor == selectedImage )
-  {
-    actor.SetScale( Vector3::ONE );
-    actor.RegisterProperty( "uBottomRight", Vector2::ONE );
-
-    if( mSelectedImage != selectedImage )
-    {
-      mSelectedImage = selectedImage;
-      SetTickUVEffect();
-    }
-  }
-}
-
-void CheckBoxButton::OnTransitionIn( Actor actor )
-{
-  Actor& selectedImage = GetSelectedImage();
-  if( actor && actor == selectedImage )
-  {
-    if( GetPaintState() == UnselectedState )
-    {
-      Dali::Animation transitionAnimation = GetTransitionAnimation();
-      if( transitionAnimation )
-      {
-        // UV anim
-        transitionAnimation.AnimateTo( Property( actor, "uBottomRight" ), Vector2::ONE );
-
-        // Actor size anim
-        transitionAnimation.AnimateTo( Property( actor, Actor::Property::SCALE_X ), 1.0f );
-      }
-    }
-    else
-    {
-      //explicitly end the swipe animation
-      actor.SetScale( Vector3::ONE );
-      if( mSelectedImage == selectedImage  )
-      {
-        actor.RegisterProperty( "uBottomRight", Vector2::ONE );
-      }
-    }
-  }
-}
 
 } // namespace Internal
 
index e3d6a46..daee597 100644 (file)
@@ -62,11 +62,6 @@ private:
    */
   virtual ~CheckBoxButton();
 
-  /**
-   * Setup the ticking effect to the selected image.
-   */
-  void SetTickUVEffect();
-
 private: // From Button
 
 
@@ -75,31 +70,6 @@ private: // From Button
    */
   virtual void OnInitialize();
 
-  /**
-   * @copydoc Toolkit::Internal::Button::OnLabelSet
-   */
-  virtual void OnLabelSet( bool noPadding );
-
-  /**
-   * @copydoc Toolkit::Internal::Button::OnDisabled
-   */
-  virtual void OnDisabled();
-
-  /**
-   * @copydoc Toolkit::Internal::Button::PrepareForTranstionIn( Actor actor )
-   */
-  virtual void PrepareForTranstionIn( Actor actor );
-
-  /**
-   * @copydoc Toolkit::Internal::Button::PrepareForTranstionOut( Actor actor )
-   */
-  virtual void PrepareForTranstionOut( Actor actor );
-
-  /**
-   * @copydoc Toolkit::Internal::Button::OnTransitionInImage( Actor actor )
-   */
-  virtual void OnTransitionIn( Actor actor );
-
 private:
 
   // Undefined
@@ -108,8 +78,6 @@ private:
   // Undefined
   CheckBoxButton& operator=( const CheckBoxButton& );
 
-private:
-  Actor         mSelectedImage;
 };
 
 } // namespace Internal
index 2190016..3391bae 100644 (file)
 #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>
+
+#if defined(DEBUG_ENABLED)
+  extern Debug::Filter* gLogButtonFilter;
+#endif
 
 namespace Dali
 {
@@ -40,10 +48,6 @@ namespace Internal
 namespace
 {
 
-const float   ANIMATION_TIME( 0.2f );
-const Padding DEFAULT_LABEL_PADDING( 12.0f, 12.0f, 12.0f, 12.0f );
-const Padding DEFAULT_ICON_PADDING( 12.0f, 12.0f, 12.0f, 12.0f );
-
 BaseHandle Create()
 {
   return Toolkit::PushButton::New();
@@ -71,31 +75,11 @@ const Dali::Scripting::StringEnum IconAlignmentTable[] = {
   { "BOTTOM", Toolkit::Internal::PushButton::BOTTOM },
 }; const unsigned int IconAlignmentTableCount = sizeof( IconAlignmentTable ) / sizeof( IconAlignmentTable[0] );
 
-const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-up.9.png";
-const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-down.9.png";
-const char* const DISABLED_UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-disabled.9.png";
-const char* const DISABLED_SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "button-down-disabled.9.png";
-
 } // unnamed namespace
 
 namespace
 {
 
-/**
- * Get size of Actor if larger than given size
- * @param[in] root the actor to get the size of
- * @param[out] size the greater of the given size or the size of the Actor
- */
-void SizeOfActorIfLarger( Actor root, Vector3& size )
-{
-  if ( root )
-  {
-    // RelayoutSize retreived for Actor to use any padding set to it.
-    size.width = std::max( root.GetRelayoutSize( Dimension::WIDTH ), size.width );
-    size.height = std::max( root.GetRelayoutSize( Dimension::HEIGHT ), size.height );
-  }
-}
-
 } // unnamed namespace
 
 Dali::Toolkit::PushButton PushButton::New()
@@ -115,12 +99,8 @@ Dali::Toolkit::PushButton PushButton::New()
 
 PushButton::PushButton()
 : Button(),
-  mLabelPadding( DEFAULT_LABEL_PADDING ),
-  mIconPadding( DEFAULT_ICON_PADDING ),
-  mIconAlignment( RIGHT ),
-  mSize()
+  mIconAlignment( RIGHT )
 {
-  SetAnimationTime( ANIMATION_TIME );
 }
 
 PushButton::~PushButton()
@@ -134,32 +114,36 @@ void PushButton::OnInitialize()
   // Push button requires the Leave event.
   Actor self = Self();
   self.SetLeaveRequired( true );
-
-  // Set resize policy to natural size so that buttons will resize to background images
-  self.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-
-  SetUnselectedImage( UNSELECTED_BUTTON_IMAGE_DIR );
-  SetSelectedImage( SELECTED_BUTTON_IMAGE_DIR );
-  SetDisabledImage( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR );
-  SetDisabledSelectedImage( DISABLED_SELECTED_BUTTON_IMAGE_DIR );
-}
-
-void PushButton::SetIcon( DecorationState state, const std::string iconFilename )
-{
-  mIconName[ state ] = iconFilename;
-  SetDecoration( state, Toolkit::ImageView::New( iconFilename  ) );
-  ConfigureSizeNegotiation();
-}
-
-std::string& PushButton::GetIcon( DecorationState state )
-{
-  return mIconName[ state ];
 }
 
 void PushButton::SetIconAlignment( const PushButton::IconAlignment iconAlignment )
 {
   mIconAlignment = iconAlignment;
-  ConfigureSizeNegotiation();
+  Button::Align labelAlignment;
+  switch ( iconAlignment )
+  {
+  case RIGHT:
+  {
+    labelAlignment = Button::BEGIN;
+    break;
+  }
+  case TOP:
+  {
+    labelAlignment = Button::BOTTOM;
+    break;
+  }
+  case BOTTOM:
+  {
+    labelAlignment = Button::TOP;
+    break;
+  }
+  case LEFT:
+  default:
+    labelAlignment = Button::END;
+    break;
+  }
+
+  Button::SetLabelAlignment( labelAlignment );
 }
 
 const PushButton::IconAlignment PushButton::GetIconAlignment() const
@@ -167,28 +151,6 @@ const PushButton::IconAlignment PushButton::GetIconAlignment() const
   return mIconAlignment;
 }
 
-void PushButton::SetLabelPadding( const Vector4& padding )
-{
-  mLabelPadding = Padding( padding.x, padding.y, padding.z, padding.w );
-  ConfigureSizeNegotiation();
-}
-
-Vector4 PushButton::GetLabelPadding()
-{
-  return Vector4( mLabelPadding.left, mLabelPadding.right, mLabelPadding.top, mLabelPadding.bottom );
-}
-
-void PushButton::SetIconPadding( const Vector4& padding )
-{
-  mIconPadding = Padding( padding.x, padding.y, padding.z, padding.w );
-  ConfigureSizeNegotiation();
-}
-
-Vector4 PushButton::GetIconPadding()
-{
-  return Vector4( mIconPadding.left, mIconPadding.right, mIconPadding.top, mIconPadding.bottom );
-}
-
 void PushButton::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
 {
   Toolkit::PushButton pushButton = Toolkit::PushButton::DownCast( Dali::BaseHandle( object ) );
@@ -197,16 +159,18 @@ void PushButton::SetProperty( BaseObject* object, Property::Index propertyIndex,
   {
     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::UNSELECTED_ICON:
       {
-        pushButtonImpl.SetIcon( UNSELECTED_DECORATION, value.Get< std::string >() );
+        pushButtonImpl.CreateVisualsForComponent( Toolkit::DevelButton::Property::UNSELECTED_VISUAL, value, DepthIndex::CONTENT );
         break;
       }
       case Toolkit::PushButton::Property::SELECTED_ICON:
       {
-        pushButtonImpl.SetIcon( SELECTED_DECORATION, value.Get< std::string >() );
+        pushButtonImpl.CreateVisualsForComponent( Toolkit::DevelButton::Property::SELECTED_VISUAL, value, DepthIndex::CONTENT );
         break;
       }
       case Toolkit::PushButton::Property::ICON_ALIGNMENT:
@@ -220,12 +184,14 @@ void PushButton::SetProperty( BaseObject* object, Property::Index propertyIndex,
       }
       case Toolkit::PushButton::Property::LABEL_PADDING:
       {
-        pushButtonImpl.SetLabelPadding( value.Get< Vector4 >() );
+        Vector4 padding ( value.Get< Vector4 >() );
+        pushButtonImpl.Button::SetLabelPadding( Padding( padding.x, padding.y, padding.z, padding.w ) );
         break;
       }
       case Toolkit::PushButton::Property::ICON_PADDING:
       {
-        pushButtonImpl.SetIconPadding( value.Get< Vector4 >() );
+        Vector4 padding ( value.Get< Vector4 >() );
+        pushButtonImpl.Button::SetForegroundPadding( Padding( padding.x, padding.y, padding.z, padding.w ) );
         break;
       }
     }
@@ -246,12 +212,12 @@ Property::Value PushButton::GetProperty( BaseObject* object, Property::Index pro
     {
       case Toolkit::PushButton::Property::UNSELECTED_ICON:
       {
-        value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION );
+        //value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION );
         break;
       }
       case Toolkit::PushButton::Property::SELECTED_ICON:
       {
-        value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION );
+        //value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION );
         break;
       }
       case Toolkit::PushButton::Property::ICON_ALIGNMENT:
@@ -261,12 +227,14 @@ Property::Value PushButton::GetProperty( BaseObject* object, Property::Index pro
       }
       case Toolkit::PushButton::Property::LABEL_PADDING:
       {
-        value = pushButtonImpl.GetLabelPadding();
+        Padding padding = pushButtonImpl.Button::GetLabelPadding();
+        value = Vector4( padding.x, padding.y, padding.top, padding.bottom);
         break;
       }
       case Toolkit::PushButton::Property::ICON_PADDING:
       {
-        value = pushButtonImpl.GetIconPadding();
+        Padding padding = pushButtonImpl.Button::GetForegroundPadding();
+        value = Vector4( padding.x, padding.y, padding.top, padding.bottom);
         break;
       }
     }
@@ -275,331 +243,6 @@ Property::Value PushButton::GetProperty( BaseObject* object, Property::Index pro
   return value;
 }
 
-void PushButton::OnLabelSet( bool noPadding )
-{
-  Actor& label = GetLabelActor();
-
-  if( label )
-  {
-    if( noPadding )
-    {
-      mLabelPadding = Padding( 0.0f, 0.0f, 0.0f, 0.0f );
-    }
-
-    Toolkit::TextLabel textLabel = Toolkit::TextLabel::DownCast( label );
-    if( textLabel )
-    {
-      textLabel.SetProperty( Toolkit::TextLabel::Property::MULTI_LINE, false );
-    }
-  }
-  ConfigureSizeNegotiation();
-}
-
-void PushButton::OnButtonImageSet()
-{
-  ConfigureSizeNegotiation();
-}
-
-void PushButton::OnSelectedImageSet()
-{
-  ConfigureSizeNegotiation();
-}
-
-void PushButton::OnBackgroundImageSet()
-{
-  ConfigureSizeNegotiation();
-}
-
-void PushButton::OnSelectedBackgroundImageSet()
-{
-  ConfigureSizeNegotiation();
-}
-
-void PushButton::OnDisabledImageSet()
-{
-  ConfigureSizeNegotiation();
-}
-
-void PushButton::OnDisabledSelectedImageSet()
-{
-  ConfigureSizeNegotiation();
-}
-
-void PushButton::OnDisabledBackgroundImageSet()
-{
-  ConfigureSizeNegotiation();
-}
-
-void PushButton::OnSizeSet( const Vector3& targetSize )
-{
-  if( targetSize != mSize )
-  {
-    mSize = targetSize;
-
-    Actor& label = GetLabelActor();
-
-    if( label )
-    {
-      label.SetSize( mSize );
-    }
-  }
-}
-
-void PushButton::PrepareForTranstionIn( Actor actor )
-{
-  actor.SetOpacity( 0.0f );
-}
-
-void PushButton::PrepareForTranstionOut( Actor actor )
-{
-  actor.SetOpacity( 1.0f );
-}
-
-void PushButton::OnTransitionIn( Actor actor )
-{
-  FadeImageTo( actor, 1.f );
-}
-
-void PushButton::OnTransitionOut( Actor actor )
-{
-  FadeImageTo( actor, 0.0f );
-}
-
-void PushButton::FadeImageTo( Actor actor, float opacity )
-{
-  if( actor )
-  {
-    Dali::Animation transitionAnimation = GetTransitionAnimation();
-    DALI_ASSERT_DEBUG( transitionAnimation );
-
-    if( transitionAnimation )
-    {
-      transitionAnimation.AnimateTo( Property( actor, Actor::Property::COLOR_ALPHA ), opacity );
-    }
-  }
-}
-
-Vector3 PushButton::GetNaturalSize()
-{
-  Vector3 size;
-
-  // If label, test against it's size
-  Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( GetLabelActor() );
-
-  Actor icon = GetDecoration( UNSELECTED_DECORATION );
-  if( label || icon )
-  {
-    Vector3 labelSize( Vector3::ZERO );
-    Vector3 iconSize( Vector3::ZERO );
-
-    if( label )
-    {
-      Vector3 labelNaturalSize = label.GetNaturalSize();
-      labelSize.width = labelNaturalSize.width + mLabelPadding.left + mLabelPadding.right;
-      labelSize.height = labelNaturalSize.height + mLabelPadding.top + mLabelPadding.bottom;
-    }
-
-    if( icon )
-    {
-      Vector3 iconNaturalSize = icon.GetNaturalSize();
-      iconSize.width = iconNaturalSize.width + mIconPadding.left + mIconPadding.right;
-      iconSize.height = iconNaturalSize.height + mIconPadding.top + mIconPadding.bottom;
-
-      switch( mIconAlignment )
-      {
-        case LEFT:
-        case RIGHT:
-        {
-          size.width = labelSize.width + iconSize.width;
-          size.height = std::max( labelSize.height, iconSize.height );
-          break;
-        }
-        case TOP:
-        case BOTTOM:
-        {
-          size.width = std::max( labelSize.width, iconSize.width );
-          size.height = labelSize.height + iconSize.height;
-          break;
-        }
-      }
-    }
-    else
-    {
-      // No icon, so size is the same as label size.
-      // (If there is no label this is zero).
-      size = labelSize;
-    }
-  }
-  else
-  {
-    // Check Image and Background image and use the largest size as the control's Natural size.
-    SizeOfActorIfLarger( GetUnselectedImage(), size );
-    SizeOfActorIfLarger( GetBackgroundImage(), size );
-  }
-
-  return size;
-}
-
-void PushButton::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
-{
-  ConfigureSizeNegotiation();
-}
-
-void PushButton::ConfigureSizeNegotiation()
-{
-  std::vector< Actor > images;
-  images.reserve( 7 );
-
-  images.push_back( GetUnselectedImage() );
-  images.push_back( GetSelectedImage() );
-  images.push_back( GetSelectedBackgroundImage() );
-  images.push_back( GetBackgroundImage() );
-  images.push_back( GetDisabledImage() );
-  images.push_back( GetDisabledSelectedImage() );
-  images.push_back( GetDisabledBackgroundImage() );
-
-  Actor label = GetLabelActor();
-
-  for( unsigned int i = 0; i < Dimension::DIMENSION_COUNT; ++i )
-  {
-    ConfigureSizeNegotiationDimension( static_cast< Dimension::Type >( 1 << i ), images, label );
-  }
-
-  // Add any vertical padding directly to the actors.
-  Actor icon = GetDecoration( UNSELECTED_DECORATION );
-  Actor selectedIcon = GetDecoration( SELECTED_DECORATION );
-  bool iconExists = icon || selectedIcon;
-
-  if( label )
-  {
-    label.SetPadding( mLabelPadding );
-  }
-  if( icon )
-  {
-    icon.SetPadding( mIconPadding );
-  }
-  if( selectedIcon )
-  {
-    selectedIcon.SetPadding( mIconPadding );
-  }
-
-  // Calculate and apply horizontal alignments and offsets
-  // to text and icon (depending on existence).
-  Vector3 iconPosition( Vector3::ZERO );
-  Vector3 labelPosition( Vector3::ZERO );
-  Vector3 iconAnchoring( AnchorPoint::CENTER );
-  Vector3 labelAnchoring( AnchorPoint::CENTER );
-  std::string horizontalLabelAlignment = "CENTER";
-  std::string verticalLabelAlignment = "CENTER";
-
-  if( iconExists && label )
-  {
-    // There is an icon and a label to lay out.
-    switch( mIconAlignment )
-    {
-      case LEFT:
-      {
-        iconPosition.x = mIconPadding.left;
-        labelPosition.x = -mLabelPadding.right;
-        iconAnchoring = AnchorPoint::CENTER_LEFT;
-        labelAnchoring = AnchorPoint::CENTER_RIGHT;
-        horizontalLabelAlignment = "END";
-        break;
-      }
-      case RIGHT:
-      {
-        iconPosition.x = -mIconPadding.right;
-        labelPosition.x = mLabelPadding.left;
-        iconAnchoring = AnchorPoint::CENTER_RIGHT;
-        labelAnchoring = AnchorPoint::CENTER_LEFT;
-        horizontalLabelAlignment = "BEGIN";
-        break;
-      }
-      case TOP:
-      {
-        iconPosition.y = mIconPadding.top;
-        labelPosition.y = -mLabelPadding.bottom;
-        iconAnchoring = AnchorPoint::TOP_CENTER;
-        labelAnchoring = AnchorPoint::BOTTOM_CENTER;
-        verticalLabelAlignment = "BOTTOM";
-        break;
-      }
-      case BOTTOM:
-      {
-        iconPosition.y = -mIconPadding.bottom;
-        labelPosition.y = mLabelPadding.top;
-        iconAnchoring = AnchorPoint::BOTTOM_CENTER;
-        labelAnchoring = AnchorPoint::TOP_CENTER;
-        verticalLabelAlignment = "TOP";
-        break;
-      }
-    }
-  }
-
-  // Note: If there is only an icon, or only a label, the default values are now correct.
-  // Setup the icon(s) with the precalculated values.
-  if( icon )
-  {
-    icon.SetPosition( iconPosition );
-    icon.SetParentOrigin( iconAnchoring );
-    icon.SetAnchorPoint( iconAnchoring );
-  }
-  if( selectedIcon )
-  {
-    selectedIcon.SetPosition( iconPosition );
-    selectedIcon.SetParentOrigin( iconAnchoring );
-    selectedIcon.SetAnchorPoint( iconAnchoring );
-  }
-
-  // Setup the label.
-  if( label )
-  {
-    label.SetPosition( labelPosition );
-    label.SetParentOrigin( labelAnchoring );
-    label.SetAnchorPoint( labelAnchoring );
-    label.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, horizontalLabelAlignment );
-    label.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, verticalLabelAlignment );
-  }
-
-  RelayoutRequest();
-}
-
-
-void PushButton::ConfigureSizeNegotiationDimension( Dimension::Type dimension, const std::vector< Actor >& images, Actor& label )
-{
-  ResizePolicy::Type imageResizePolicy = ResizePolicy::FILL_TO_PARENT;
-  ResizePolicy::Type labelResizePolicy = ResizePolicy::FILL_TO_PARENT;
-
-  ResizePolicy::Type resizePolicy = Self().GetResizePolicy( dimension );
-
-  if( resizePolicy == ResizePolicy::FIT_TO_CHILDREN || resizePolicy == ResizePolicy::USE_NATURAL_SIZE )
-  {
-    if( label )
-    {
-      labelResizePolicy = ResizePolicy::USE_NATURAL_SIZE;
-    }
-    else
-    {
-      imageResizePolicy = ResizePolicy::USE_NATURAL_SIZE;
-    }
-  }
-
-  if( label )
-  {
-    label.SetResizePolicy( labelResizePolicy, dimension );
-  }
-
-  for( std::vector< Actor >::const_iterator it = images.begin(), itEnd = images.end(); it != itEnd; ++it )
-  {
-    Actor actor = *it;
-    if( actor )
-    {
-      actor.SetResizePolicy( imageResizePolicy, dimension );
-    }
-  }
-}
-
-
 } // namespace Internal
 
 } // namespace Toolkit
index a003e6d..ecc7ac7 100644 (file)
@@ -100,123 +100,9 @@ private: // From Button
    */
   virtual void OnInitialize();
 
-  /**
-   * @copydoc Toolkit::Internal::Button::OnLabelSet
-   */
-  virtual void OnLabelSet( bool noPadding );
-
-  /**
-   * @copydoc Toolkit::Internal::Button::OnButtonImageSet
-   */
-  virtual void OnButtonImageSet();
-
-  /**
-   * @copydoc Toolkit::Internal::Button::OnSelectedImageSet
-   */
-  virtual void OnSelectedImageSet();
-
-  /**
-   * @copydoc Toolkit::Internal::Button::OnBackgroundImage
-   */
-  virtual void OnBackgroundImageSet();
-
-  /**
-   * @copydoc Toolkit::Internal::Button::OnSelectedBackgroundImageSet
-   */
-  virtual void OnSelectedBackgroundImageSet();
-
-  /**
-   * @copydoc Toolkit::Internal::Button::OnDisabledImageSet
-   */
-  virtual void OnDisabledImageSet();
-
-  /**
-   * @copydoc Toolkit::Internal::Button::OnDisabledSelectedImageSet
-   */
-  virtual void OnDisabledSelectedImageSet();
-
-  /**
-   * @copydoc Toolkit::Internal::Button::OnDisabledBackgroundImageSet
-   */
-  virtual void OnDisabledBackgroundImageSet();
-
-  /**
-   * @copydoc Toolkit::Internal::Button::PrepareForTranstionIn( Actor actor )
-   */
-  virtual void PrepareForTranstionIn( Actor actor );
-
-  /**
-   * @copydoc Toolkit::Internal::Button::PrepareForTranstionOut( Actor actor )
-   */
-  virtual void PrepareForTranstionOut( Actor actor );
-
-  /**
-   * @copydoc Toolkit::Internal::Button::OnTransitionIn( Actor actor )
-   */
-  virtual void OnTransitionIn( Actor actor );
-
-  /**
-   * @copydoc Toolkit::Internal::Button::OnTransitionOut( Actor actor )
-   */
-  virtual void OnTransitionOut( Actor actor );
-
-private: // From Control
-
-  /**
-   * @copydoc CustomActorImpl::OnSizeSet( const Vector3& targetSize )
-   */
-  virtual void OnSizeSet( const Vector3& targetSize );
-
-  /**
-   * @copydoc Toolkit::Control::GetNaturalSize
-   */
-  virtual Vector3 GetNaturalSize();
-
-  /**
-   * @copydoc Toolkit::Control::OnSetResizePolicy
-   */
-  virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension );
-
 private:
 
   /**
-   * It adds the actor to the root actor and to the fade in animation.
-   * @param[inout] actor The actor.
-   * @param[in] opacity The opacity to fade to
-   */
-  void FadeImageTo( Actor actor, float opacity );
-
-  /**
-   * @brief Custom configuration for size negotiation
-   */
-  void ConfigureSizeNegotiation();
-
-  /**
-   * @brief Configure size negotiation for a given dimension
-   *
-   * @param[in] dimension The dimension to configure
-   * @param[in] images The list of images to configure
-   * @param[in] label The text label to configure
-   */
-  void ConfigureSizeNegotiationDimension( Dimension::Type dimension, const std::vector< Actor >& images, Actor& label );
-
-  /**
-   * @brief Sets either the selected or unselected icon.
-   *
-   * @param[in] state The icon state to set
-   * @param[in] iconFilename The filename of the icon
-   */
-  void SetIcon( DecorationState state, const std::string iconFilename );
-
-  /**
-   * @brief Gets either the selected or unselected icon.
-   *
-   * @param[in] state The icon state to get
-   * @return    The filename of the icon
-   */
-  std::string& GetIcon( DecorationState state );
-
-  /**
    * @brief Sets the alignment mode to use to align the icon to the label.
    *
    * @param[in] iconAlignment The alignment mode to use
@@ -230,34 +116,6 @@ private:
    */
   const PushButton::IconAlignment GetIconAlignment() const;
 
-  /**
-   * @brief Sets the padding for the label.
-   *
-   * @param[in] padding The padding to set
-   */
-  void SetLabelPadding( const Vector4& padding );
-
-  /**
-   * @brief Gets the padding for the label.
-   *
-   * @return The label padding
-   */
-  Vector4 GetLabelPadding();
-
-  /**
-   * @brief Sets the padding for the icon.
-   *
-   * @param[in] padding The padding to set
-   */
-  void SetIconPadding( const Vector4& padding );
-
-  /**
-   * @brief Gets the padding for the icon.
-   *
-   * @return The icon padding
-   */
-  Vector4 GetIconPadding();
-
 private:
 
   // Undefined
@@ -268,11 +126,7 @@ private:
 
 private:
 
-  std::string    mIconName[ DECORATION_STATES ]; ///< The original filenames for the icons.
-  Padding        mLabelPadding;                  ///< The padding around the label (if present).
-  Padding        mIconPadding;                   ///< The padding around the icon (if present).
   IconAlignment  mIconAlignment;                 ///< The alignment of the icon against the label.
-  Vector3        mSize;                          ///< The button's size.
 };
 
 } // namespace Internal
index 142dba1..9dd7570 100644 (file)
 #include "radio-button-impl.h"
 
 // EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/images/resource-image.h>
 
+#if defined(DEBUG_ENABLED)
+  extern Debug::Filter* gLogButtonFilter;
+#endif
+
 namespace Dali
 {
 
@@ -42,12 +47,6 @@ BaseHandle Create()
 
 TypeRegistration typeRegistration( typeid( Toolkit::RadioButton ), typeid( Toolkit::Button ), Create);
 
-const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-unselected.png";
-const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-selected.png";
-const char* const DISABLED_UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-unselected-disabled.png";
-const char* const DISABLED_SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-selected-disabled.png";
-
-const float DISTANCE_BETWEEN_IMAGE_AND_LABEL( 5.0f );
 }
 
 Dali::Toolkit::RadioButton RadioButton::New()
@@ -77,105 +76,48 @@ RadioButton::~RadioButton()
 void RadioButton::OnInitialize()
 {
   Button::OnInitialize();
-
-  Actor self = Self();
-
-  // Wrap size of radio button around all its children
-  self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
-
-  SetUnselectedImage( UNSELECTED_BUTTON_IMAGE_DIR );
-  SetSelectedImage( SELECTED_BUTTON_IMAGE_DIR );
-  SetDisabledImage( DISABLED_UNSELECTED_BUTTON_IMAGE_DIR );
-  SetDisabledSelectedImage( DISABLED_SELECTED_BUTTON_IMAGE_DIR );
-
-  RelayoutRequest();
 }
 
-void RadioButton::OnButtonUp()
+bool RadioButton::OnToggleReleased()
 {
-  if( ButtonDown == GetState() )
+  // Radio button overrides toggle release (button up) as doesn't allow un-selection to be performed on it directly.
+  bool stateChanged = false;
+  if( !IsSelected() )
   {
-    // Don't allow selection on an already selected radio button
-    if( !IsSelected() )
-    {
-      SetSelected( !IsSelected() );
-    }
+    Button::SetSelected( true ); // Set button to selected as previously unselected
+    stateChanged = true;
   }
+  return stateChanged;
 }
 
-void RadioButton::OnLabelSet( bool noPadding )
+void RadioButton::OnStateChange( State newState )
 {
-  Actor& label = GetLabelActor();
-
-  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() && GetSelectedImage() )
-    {
-      label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
-    }
-    else if( GetUnselectedImage() )
-    {
-      label.SetX( GetUnselectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
-    }
-    else
-    {
-      label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
-    }
-  }
-}
-
-void RadioButton::OnSelected()
-{
-  Actor& label = GetLabelActor();
-
-  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 );
-          }
-        }
-      }
-
-      Actor& selectedImage = GetSelectedImage();
-      if( label && selectedImage )
-      {
-        label.SetX( selectedImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
-      }
-      break;
-    }
-    case SelectedState:
-    {
-      Actor& buttonImage = GetUnselectedImage();
-      if( label && buttonImage )
-      {
-        label.SetX( buttonImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
-      }
-      break;
-    }
-    default:
-    {
-      break;
-    }
-  }
+  // 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;
+     }
+   }
 }
 
 } // namespace Internal
index 630e1a3..1012196 100644 (file)
@@ -69,19 +69,14 @@ private: // From Button
   virtual void OnInitialize();
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnButtonUp
+   * @copydoc Toolkit::Internal::Button::OnStateChange
    */
-  virtual void OnButtonUp();
+  virtual void OnStateChange( State newState );
 
   /**
-   * @copydoc Toolkit::Internal::Button::OnSelected
+   * @copydoc Toolkit::Internal::Button::OnToggleReleased
    */
-  virtual void OnSelected();
-
-  /**
-   * @copydoc Toolkit::Internal::Button::OnLabelSet
-   */
-  virtual void OnLabelSet( bool noPadding );
+  virtual bool OnToggleReleased();
 
 private:
 
index e82d82d..c91f71d 100644 (file)
@@ -34,6 +34,8 @@
 #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/controls/text-controls/text-selection-popup-callback-interface.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 
 namespace Dali
 {
@@ -709,7 +711,7 @@ std::string TextSelectionPopup::GetPressedImage() const
 
      // Label properties.
      Property::Map buttonLabelProperties;
-     buttonLabelProperties.Insert( "text", button.caption );
+     buttonLabelProperties.Insert( Toolkit::TextVisual::Property::TEXT, button.caption );
      option.SetProperty( Toolkit::Button::Property::LABEL, buttonLabelProperties );
    }
    if( showIcons )
index 7a8ad7a..2e7fa6d 100644 (file)
@@ -94,9 +94,13 @@ const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
   uniform mediump mat4 uMvpMatrix;\n
   uniform mediump vec3 uSize;\n
   uniform mediump vec4 pixelArea;
+
+  uniform mediump mat4 uModelMatrix;\n
+  uniform mediump mat4 uViewMatrix;\n
+  uniform mediump mat4 uProjection;\n
+
   varying mediump vec2 vTexCoord;\n
   \n
-
   //Visual size and offset
   uniform mediump vec2 offset;\n
   uniform mediump vec2 size;\n
@@ -113,7 +117,10 @@ const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
 
   void main()\n
   {\n
-    mediump vec4 vertexPosition = uMvpMatrix *ComputeVertexPosition();\n
+    mediump vec4 nonAlignedVertex = uViewMatrix*uModelMatrix*ComputeVertexPosition();\n
+    mediump vec4 pixelAlignedVertex = vec4 ( floor(nonAlignedVertex.xyz), 1.0 );\n
+    mediump vec4 vertexPosition = uProjection*pixelAlignedVertex;\n
+
     vTexCoord = pixelArea.xy+pixelArea.zw*(aPosition + vec2(0.5) );\n
     gl_Position = vertexPosition;\n
   }\n
@@ -268,12 +275,9 @@ void TextVisual::DoSetOnStage( Actor& actor )
     mFactoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY , geometry );
   }
 
-  Shader shader = mFactoryCache.GetShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP );
-  if( !shader )
-  {
-    shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_CLAMP );
-    mFactoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP, shader );
-  }
+  Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_ATLAS_CLAMP );
+  mFactoryCache.SaveShader( VisualFactoryCache::IMAGE_SHADER_ATLAS_DEFAULT_WRAP, shader );
+
   shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
 
   mImpl->mRenderer = Renderer::New( geometry, shader );
@@ -432,29 +436,23 @@ void TextVisual::UpdateRenderer()
       PixelData data = mTypesetter->Render( relayoutSize );
 
       Vector4 atlasRect = FULL_TEXTURE_RECT;
-      TextureSet textureSet = mFactoryCache.GetAtlasManager()->Add( atlasRect, data );
 
-      if( textureSet )
-      {
-        mImpl->mFlags |= Impl::IS_ATLASING_APPLIED;
-      }
-      else
-      {
-        // It may happen the image atlas can't handle a pixel data it exceeds the maximum size.
-        // In that case, create a texture. TODO: should tile the text.
+      // Texture set not retrieved from Atlas Manager whilst pixel offset visible.
 
-        Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D,
-                                        data.GetPixelFormat(),
-                                        data.GetWidth(),
-                                        data.GetHeight() );
+      // It may happen the image atlas can't handle a pixel data it exceeds the maximum size.
+      // In that case, create a texture. TODO: should tile the text.
 
-        texture.Upload( data );
+      Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D,
+                                      data.GetPixelFormat(),
+                                      data.GetWidth(),
+                                      data.GetHeight() );
 
-        textureSet = TextureSet::New();
-        textureSet.SetTexture( 0u, texture );
+      texture.Upload( data );
 
-        mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
-      }
+      TextureSet textureSet = TextureSet::New();
+      textureSet.SetTexture( 0u, texture );
+
+      mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
 
       mImpl->mRenderer.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, atlasRect );
 
index c9e1852..92cc53c 100644 (file)
@@ -28,6 +28,7 @@
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/visuals/image-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
 #include <dali-toolkit/internal/visuals/border/border-visual.h>
 #include <dali-toolkit/internal/visuals/color/color-visual.h>
@@ -63,6 +64,7 @@ DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, GRADIENT )
 DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, IMAGE )
 DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, MESH )
 DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, PRIMITIVE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::DevelVisual, TEXT )
 DALI_ENUM_TO_STRING_WITH_SCOPE( Toolkit::Visual, WIREFRAME )
 DALI_ENUM_TO_STRING_TABLE_END( VISUAL_TYPE )
 
index 783e1e6..2dd17c3 100644 (file)
 
 // EXTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
+#include <dali/public-api/object/property-map.h>
+#include <dali/public-api/images/resource-image.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/controls/buttons/button-impl.h>
 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
+#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
 
 namespace Dali
 {
@@ -251,18 +254,14 @@ void Button::SetButtonImage( Image image )
 {
   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetButtonImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
 
-  Actor imageView = Toolkit::ImageView::New( image );
-  imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-  Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageView );
+  Dali::Toolkit::GetImplementation( *this ).SetButtonImage( image );
 }
 
 void Button::SetSelectedImage( Image image )
 {
   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedImage() is deprecated and will be removed from next release. Use Styling file instead.\n" );
 
-  Actor imageView = Toolkit::ImageView::New( image );
-  imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
-  Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageView );
+  Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( image );
 }
 
 Actor Button::GetButtonImage() const
@@ -279,7 +278,6 @@ Actor Button::GetSelectedImage() const
   return Dali::Toolkit::GetImplementation( *this ).GetSelectedImage();
 }
 
-
 Button::Button( Internal::Button& implementation )
 : Control( implementation )
 {
index dbb0618..3ccf2d4 100644 (file)
@@ -37,7 +37,7 @@ class Button;
  */
 
 /**
- * @brief Button is a base class for different kind of buttons.
+ * @brief Button is a base class for different kinds of buttons.
  *
  * This class provides the disabled property and the clicked signal.
  *
@@ -59,14 +59,17 @@ class Button;
  *       When \e togglable is set to \e true, a Button::StateChangedSignal() signal is emitted, with the selected state.
  * </ul>
  *
- * The button's appearance can be modified by setting properties for the various image filenames.
+ * 'Visual' describes not just traditional images like png, bmp but refers to whatever is used to show the button, it could be a color, gradient or some other kind of renderer.
  *
- * The \e background is always shown and doesn't change if the button is pressed or released. The \e button image is shown over the \e background image when the
- * button is not pressed and is replaced by the \e selected image when the button is pressed. The text label is placed always on the top of all images.
+ * The button's appearance can be modified by setting properties for the various visuals/images.
  *
- * When the button is disabled, \e background, \e button and \e selected images are replaced by their \e disabled images.
+ * It is not mandatory to set all visuals. A button could be defined only by setting its \e background visual or by setting its \e background and \e selected visuals.
+ *
+ * The \e button visual is shown over the \e background visual.
+ * When pressed the unselected visuals are replaced by the \e selected visual. The text label is always placed on the top of all images.
+ *
+ * When the button is disabled, \e background, \e button and \e selected visuals are replaced by their \e disabled visuals.
  *
- * Is not mandatory to set all images. A button could be defined only by setting its \e background image or by setting its \e background and \e selected images.
  *
  * Signals
  * | %Signal Name     | Method                      |
@@ -108,21 +111,98 @@ public:
      */
     enum
     {
-      DISABLED = PROPERTY_START_INDEX, ///< name "disabled",                     @see SetDisabled(),                  type bool @SINCE_1_0.0
-      AUTO_REPEATING,                  ///< name "autoRepeating",                @see SetAutoRepeating(),             type bool @SINCE_1_0.0
-      INITIAL_AUTO_REPEATING_DELAY,    ///< name "initialAutoRepeatingDelay",    @see SetInitialAutoRepeatingDelay(), type float @SINCE_1_0.0
-      NEXT_AUTO_REPEATING_DELAY,       ///< name "nextAutoRepeatingDelay",       @see SetNextAutoRepeatingDelay(),    type float @SINCE_1_0.0
-      TOGGLABLE,                       ///< name "togglable",                    @see SetTogglableButton(),           type bool @SINCE_1_0.0
-      SELECTED,                        ///< name "selected",                     @see SetSelected(),                  type bool @SINCE_1_0.0
-      UNSELECTED_STATE_IMAGE,          ///< name "unselectedStateImage",         @see SetUnselectedImage(),           type std::string @SINCE_1_0.0
-      SELECTED_STATE_IMAGE,            ///< name "selectedStateImage",           @see SetSelectedImage(),             type std::string @SINCE_1_0.0
-      DISABLED_STATE_IMAGE,            ///< name "disabledStateImage",           @see SetDisabledImage(),             type std::string @SINCE_1_0.0
-      UNSELECTED_COLOR,                ///< name "unselectedColor",                                                   type Vector4 @SINCE_1_0.0
-      SELECTED_COLOR,                  ///< name "selectedColor",                                                     type Vector4 @SINCE_1_0.0
-      LABEL,                           ///< name "label",                                                             type Property::Map @SINCE_1_0.0
-
-      // Deprecated properties:
-      LABEL_TEXT,                      ///< name "labelText",                    @see SetLabelText(),                 type std::string @SINCE_1_0.0
+      /**
+       * @brief name "disabled", type bool
+       * @details Sets the button as \e disabled.
+       * @SINCE_1_0.0
+       */
+      DISABLED = PROPERTY_START_INDEX,
+
+      /**
+       * @brief name "autoRepeating", type bool
+       * @details If the \e autorepeating property is set to \e true then the \e togglable property is set to false
+       * @SINCE_1_0.0
+       */
+      AUTO_REPEATING,
+
+      /**
+       * @brief name "initialAutoRepeatingDelay", type float
+       * @details By default this value is set to 0.15 seconds.
+       * @SINCE_1_0.0
+       */
+      INITIAL_AUTO_REPEATING_DELAY,
+
+      /**
+       * @brief name "nextAutoRepeatingDelay", type float
+       * @details default this value is set to 0.05 seconds
+       * @SINCE_1_0.0
+       */
+      NEXT_AUTO_REPEATING_DELAY,
+
+      /**
+       * @brief name "togglable", type bool
+       * @details If the \e togglable property is set to \e true, then the \e autorepeating property is set to false.
+       * @SINCE_1_0.0
+       */
+      TOGGLABLE,
+
+      /**
+       * @brief name "selected", type bool
+       * @details Sets the togglable button as either selected or unselected, \e togglable property must be set to \e true.
+       * @SINCE_1_0.0
+       */
+      SELECTED,
+
+      /**
+       * @DEPRECATED_1_1.XX Use UNSELECTED_VISUAL
+       * @brief name "unselectedStateImage", type string if it is a url, map otherwise
+       * @details Sets the unselected button foreground image
+       * @SINCE_1_0.0
+       */
+      UNSELECTED_STATE_IMAGE,
+
+      /**
+       * @DEPRECATED_1_1.XX Use SELECTED_VISUAL
+       * @brief name "selectedStateImage", type string if it is a url, map otherwise
+       * @details Sets the selected button foreground image
+       * @SINCE_1_0.0
+       */
+      SELECTED_STATE_IMAGE,
+
+      /**
+       * @DEPRECATED_1_1.XX Use DISABLED_UNSELECTED_VISUAL
+       * @brief name "disabledStateImage", type string if it is a url, map otherwise
+       * @details Sets the disabled whilst unselected foreground button visual
+       * @SINCE_1_0.0
+       */
+      DISABLED_STATE_IMAGE,
+
+      /**
+       * @DEPRECATED_1_1.XX Use UNSELECTED_BACKGROUND_VISUAL
+       * @brief name "unselectedColor", type Vector4
+       * @SINCE_1_0.0
+       */
+      UNSELECTED_COLOR,
+
+      /**
+       * @DEPRECATED_1_1.XX Use SELECTED_BACKGROUND_VISUAL
+       * @brief name "selectedColor", type Vector4
+       * @SINCE_1_0.0
+       */
+      SELECTED_COLOR,
+
+      /**
+       * @brief name "label", type Property::Map
+       * @SINCE_1_0.0
+       */
+      LABEL,
+
+      /**
+       * @DEPRECATED_1_1.32 Use LABEL
+       * @brief name "labelText", type std::string
+       * @SINCE_1_0.0
+       */
+      LABEL_TEXT
     };
   };
 
@@ -326,7 +406,7 @@ public:
   float GetAnimationTime() const DALI_DEPRECATED_API;
 
   /**
-   * @DEPRECATED_1_1.32 SetProperty LABEL or Styling file
+   * @DEPRECATED_1_1.32 SetProperty Property::LABEL or Styling file
    *
    * @brief Sets the button's label.
    *
@@ -346,7 +426,7 @@ public:
   std::string GetLabelText() const DALI_DEPRECATED_API;
 
   /**
-   * @DEPRECATED_1_1.32 Use Styling file
+   * @DEPRECATED_1_1.32 Use Styling file Property::UNSELECTED_STATE_IMAGE
    *
    * @brief Sets the unselected button image.
    *
@@ -356,7 +436,8 @@ public:
   void SetUnselectedImage( const std::string& filename ) DALI_DEPRECATED_API;
 
   /**
-   * @DEPRECATED_1_1.32 Use styling
+   * @DEPRECATED_1_1.32 Use styling Set Control::Property::BACKGROUND which is same as un-selected background
+   * Or use DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL
    *
    * @brief Sets the background image.
    *
@@ -366,7 +447,7 @@ public:
   void SetBackgroundImage( const std::string& filename ) DALI_DEPRECATED_API;
 
   /**
-   * @DEPRECATED_1_1.32 Use styling file
+   * @DEPRECATED_1_1.32 Use styling file, Property::SELECTED_STATE_IMAGE
    *
    * @brief Sets the selected image.
    *
@@ -376,7 +457,8 @@ public:
   void SetSelectedImage( const std::string& filename ) DALI_DEPRECATED_API;
 
   /**
-   * @DEPRECATED_1_1.32 Use styling file
+   * @DEPRECATED_1_1.32 Set Control::Property::BACKGROUND which is same as un-selected background
+   * Or use DevelButton::Property::SELECTED_BACKGROUND_VISUAL
    *
    * @brief Sets the selected background image.
    *
@@ -386,7 +468,8 @@ public:
   void SetSelectedBackgroundImage( const std::string& filename ) DALI_DEPRECATED_API;
 
   /**
-   * @DEPRECATED_1_1.32 Use styling file
+   * @DEPRECATED_1_1.32 Only able to set Property::DISABLED_STATE_IMAGE
+   * Or use DevelButton::Property::DISABLED_SELECTED_BACKGROUND_VISUAL
    *
    * @brief Sets the disabled background image.
    *
@@ -396,7 +479,7 @@ public:
   void SetDisabledBackgroundImage( const std::string& filename ) DALI_DEPRECATED_API;
 
   /**
-   * @DEPRECATED_1_1.32 Use styling file
+   * @DEPRECATED_1_1.32 Use styling file Property::DISABLED_STATE_IMAGE
    *
    * @brief Sets the disabled button image.
    *
@@ -406,7 +489,8 @@ public:
   void SetDisabledImage( const std::string& filename ) DALI_DEPRECATED_API;
 
   /**
-   * @DEPRECATED_1_1.32 Use styling file
+   * @DEPRECATED_1_1.32 Use Property::DISABLED_STATE_IMAGE which provides same disabled image for un/selected
+   * Or DevelButton::Property::DISABLED_SELECTED_VISUAL to disable selected visual.
    *
    * @brief Sets the disabled selected button image.
    *
index 5e40b55..80f8b16 100644 (file)
@@ -21,6 +21,8 @@
 // EXTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
 
+#include <dali/public-api/images/resource-image.h>
+
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/controls/buttons/push-button-impl.h>
 
@@ -80,49 +82,46 @@ void PushButton::SetButtonImage( Actor image )
 {
   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" );
 
-  Dali::Toolkit::GetImplementation( *this ).SetButtonImage( image );
+  // Passing Image as Actor not supported
 }
 
 void PushButton::SetBackgroundImage( Actor image )
 {
   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetBackgroundImage() is deprecated and will be removed from next release.\n" );
 
-  Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( image );
+  // Passing Image as Actor not supported}
 }
 
 void PushButton::SetSelectedImage( Actor image )
 {
   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" );
 
-  Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( image );
+  // Passing Image as Actor not supported}
 }
 
 void PushButton::SetSelectedBackgroundImage( Actor image )
 {
   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetSelectedBackgroundImage() is deprecated and will be removed from next release.\n" );
 
-  Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( image );
+  // Passing Image as Actor not supported}
 }
 
 void PushButton::SetDisabledBackgroundImage( Actor image )
 {
   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledBackgroundImage() is deprecated and will be removed from next release.\n" );
-
-  Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( image );
+  // Passing Image as Actor not supported}
 }
 
 void PushButton::SetDisabledImage( Actor image )
 {
   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" );
-
-  Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( image );
+  // Passing Image as Actor not supported
 }
 
 void PushButton::SetDisabledSelectedImage( Actor image )
 {
   DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: SetDisabledSelectedImage() is deprecated and will be removed from next release.\n" );
-
-  Dali::Toolkit::GetImplementation( *this ).SetDisabledSelectedImage( image );
+  // Passing Image as Actor not supported
 }
 
 } // namespace Toolkit
index 6142413..f0d2e29 100644 (file)
@@ -111,9 +111,9 @@ public:
      */
     enum
     {
-      UNSELECTED_ICON = PROPERTY_START_INDEX, ///< Property, name "unselectedIcon",  type std::string @SINCE_1_0.0
-      SELECTED_ICON,                          ///< Property, name "selectedIcon",    type std::string @SINCE_1_0.0
-      ICON_ALIGNMENT,                         ///< Property, name "iconAlignment",   type std::string @SINCE_1_0.0
+      UNSELECTED_ICON = PROPERTY_START_INDEX, ///< Property, name "unselectedIcon",  type std::string @SINCE_1_0.0 @DEPRECATED_1_2.XX Button::Property::UNSELECTED_VISUAL
+      SELECTED_ICON,                          ///< Property, name "selectedIcon",    type std::string @SINCE_1_0.0 @DEPRECATED_1_2.XX Button::Property::SELECTED_VISUAL
+      ICON_ALIGNMENT,                         ///< Property, name "iconAlignment",   type std::string @SINCE_1_0.0 @DEPRECATED_1_2.XX Use Button::Property::LABEL_RELATIVE_ALIGNMENT
       LABEL_PADDING,                          ///< Property, name "labelPadding",    type Vector4 @SINCE_1_0.0
       ICON_PADDING,                           ///< Property, name "iconPadding",     type Vector4 @SINCE_1_0.0
     };
@@ -172,7 +172,7 @@ public:
    */
   static PushButton DownCast( BaseHandle handle );
 
-
+  ///////////////////////////////////////////////////////////////////////////
   // Deprecated API
 
   using Button::SetButtonImage;
index 2ac22fa..ab171ad 100644 (file)
@@ -794,6 +794,8 @@ void Control::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visu
   {
     Toolkit::GetImplementation(visual).SetOnStage( self );
   }
+  DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::RegisterVisual number of registered visuals(%d)\n",  mImpl->mVisuals.Size() );
+
 }
 
 void Control::UnregisterVisual( Property::Index index )
index a710272..ea73d40 100644 (file)
     {
       "label":
       {
-        "pointSize":120,
-        "fontStyle":{"weight":"light"}
+        "visualType":"TEXT",
+        "pointSize":120
+      },
+      "unselectedBackgroundVisual":
+      {
+        "visualType": "IMAGE",
+        "url": ""
+      },
+      "selectedBackgroundVisual":
+      {
+        "visualType": "IMAGE",
+        "url": ""
       }
     },
     "TextSelectionToolbar":
     "ProgressBarValueTextLabel":
     {
       "textColor":[0.8,0.8,1,1]
+    },
+    "Button":
+    {
+      "initialAutoRepeatingDelay":2.0,
+      "nextAutoRepeatingDelay":0.9
+      // Note: Visuals added to Button will be used in all derived buttons unless overridden.
+    },
+    "PushButton":
+    {
+      "styles":["Button"],
+      "autoRepeating":false,
+      "togglable":false,
+      "labelPadding":[ 12.0, 12.0, 12.0, 12.0 ],
+      "label":
+       {
+         "visualType": "TEXT",
+         "horizontalAlignment": "CENTER",
+         "pointSize" : 15.0, // Point size must always be provided to Text Visual
+         "verticalAlignment": "CENTER"
+       },
+      "unselectedBackgroundVisual":
+       {
+         "visualType": "IMAGE",
+         "url": "{DALI_IMAGE_DIR}button-up.9.png"
+       },
+       "selectedBackgroundVisual":
+       {
+         "visualType": "IMAGE",
+         "url": "{DALI_IMAGE_DIR}button-down.9.png"
+       },
+       "disabledSelectedBackgroundVisual":
+       {
+         "visualType": "IMAGE",
+         "url": "{DALI_IMAGE_DIR}button-down-disabled.9.png"
+       },
+       "disabledUnselectedBackgroundVisual":
+       {
+         "visualType": "IMAGE",
+         "url": "{DALI_IMAGE_DIR}button-disabled.9.png"
+       }
+    },
+    "CheckBoxButton":
+    {
+      "styles":["Button"],
+      "labelPadding":[ 12.0, 12.0, 0.0, 0.0 ],
+      "label":
+       {
+         "visualType": "TEXT",
+         "pointSize" : 15.0, // Point size must always be provided to Text Visual
+         "verticalAlignment": "CENTER"
+       },
+      "unselectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}checkbox-unselected.png"
+      },
+      "selectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}checkbox-selected.png"
+      },
+      "disabledUnselectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}checkbox-unselected-disabled.png"
+      },
+      "disabledSelectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}checkbox-selected-disabled.png"
+      }
+    },
+    "RadioButton":
+    {
+      "styles":["Button"],
+      "labelPadding":[ 12.0, 12.0, 0.0, 0.0 ],
+      "label":
+       {
+         "visualType": "TEXT",
+         "pointSize" : 15.0, // Point size must always be provided to Text Visual
+         "verticalAlignment": "CENTER"
+       },
+      "unselectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}radio-button-unselected.png"
+      },
+      "selectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}radio-button-selected.png"
+      },
+      "disabledUnselectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}radio-button-unselected-disabled.png"
+      },
+      "disabledSelectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}radio-button-selected-disabled.png"
+      }
     }
   }
 }
index 4ec9d10..431f73c 100644 (file)
     {
       "pointSize":25
     },
-    "RadioButton":
-    {
-      "unselectedStateImage":"{DALI_IMAGE_DIR}radio-button-unselected.png",
-      "selectedStateImage":"{DALI_IMAGE_DIR}radio-button-selected.png",
-      "disabledUnselectedStateImage":"{DALI_IMAGE_DIR}radio-button-unselected-disabled.png",
-      "disabledSelectedStateImage":"{DALI_IMAGE_DIR}radio-button-selected-disabled.png"
-    },
-
     "TextField":
     {
       "pointSize":18,
     {
       "label":
       {
-        "pointSize":8,
-        "fontStyle":{"weight":"light"}
+        "visualType":"TEXT",
+        "pointSize":8
+      },
+      "unselectedBackgroundVisual":
+      {
+        "visualType": "IMAGE",
+        "url": ""
+      },
+      "selectedBackgroundVisual":
+      {
+        "visualType": "IMAGE",
+        "url": ""
       }
     },
     "TextSelectionToolbar":
     "ProgressBarValueTextLabel":
     {
       "textColor":[0.8,0.8,1,1]
+    },
+    "Button":
+    {
+      "initialAutoRepeatingDelay":2.0,
+      "nextAutoRepeatingDelay":0.9
+      // Note: Visuals added to Button will be used in all derived buttons unless overridden.
+    },
+    "PushButton":
+    {
+      "styles":["Button"],
+      "autoRepeating":false,
+      "togglable":false,
+      "labelPadding":[ 12.0, 12.0, 12.0, 12.0 ],
+      "label":
+       {
+         "visualType": "TEXT",
+         "horizontalAlignment": "CENTER",
+         "pointSize" : 15.0, // Point size must always be provided to Text Visual
+         "verticalAlignment": "CENTER"
+       },
+      "unselectedBackgroundVisual":
+       {
+         "visualType": "IMAGE",
+         "url": "{DALI_IMAGE_DIR}button-up.9.png"
+       },
+       "selectedBackgroundVisual":
+       {
+         "visualType": "IMAGE",
+         "url": "{DALI_IMAGE_DIR}button-down.9.png"
+       },
+       "disabledSelectedBackgroundVisual":
+       {
+         "visualType": "IMAGE",
+         "url": "{DALI_IMAGE_DIR}button-down-disabled.9.png"
+       },
+       "disabledUnselectedBackgroundVisual":
+       {
+         "visualType": "IMAGE",
+         "url": "{DALI_IMAGE_DIR}button-disabled.9.png"
+       }
+    },
+    "CheckBoxButton":
+    {
+      "styles":["Button"],
+      "labelPadding":[ 12.0, 12.0, 0.0, 0.0 ],
+      "label":
+       {
+         "visualType": "TEXT",
+         "pointSize" : 15.0, // Point size must always be provided to Text Visual
+         "verticalAlignment": "CENTER"
+       },
+      "unselectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}checkbox-unselected.png"
+      },
+      "selectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}checkbox-selected.png"
+      },
+      "disabledUnselectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}checkbox-unselected-disabled.png"
+      },
+      "disabledSelectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}checkbox-selected-disabled.png"
+      }
+    },
+    "RadioButton":
+    {
+      "styles":["Button"],
+      "labelPadding":[ 12.0, 12.0, 0.0, 0.0 ],
+      "label":
+       {
+         "visualType": "TEXT",
+         "pointSize" : 15.0, // Point size must always be provided to Text Visual
+         "verticalAlignment": "CENTER"
+       },
+      "unselectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}radio-button-unselected.png"
+      },
+      "selectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}radio-button-selected.png"
+      },
+      "disabledUnselectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}radio-button-unselected-disabled.png"
+      },
+      "disabledSelectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}radio-button-selected-disabled.png"
+      }
     }
   }
 }
index bc8931d..2f24933 100644 (file)
     {
       "pointSize":25
     },
-    "RadioButton":
-    {
-      "unselectedStateImage":"{DALI_IMAGE_DIR}radio-button-unselected.png",
-      "selectedStateImage":"{DALI_IMAGE_DIR}radio-button-selected.png",
-      "disabledUnselectedStateImage":"{DALI_IMAGE_DIR}radio-button-unselected-disabled.png",
-      "disabledSelectedStateImage":"{DALI_IMAGE_DIR}radio-button-selected-disabled.png"
-    },
-
     "TextField":
     {
       "pointSize":18,
     {
       "label":
       {
-        "pointSize":8,
-        "fontStyle":{"weight":"light"}
+        "visualType":"TEXT",
+        "pointSize":8
+      },
+      "unselectedBackgroundVisual":
+      {
+        "visualType": "IMAGE",
+        "url": ""
+      },
+      "selectedBackgroundVisual":
+      {
+        "visualType": "IMAGE",
+        "url": ""
       }
     },
     "TextSelectionToolbar":
     "ProgressBarValueTextLabel":
     {
       "textColor":[0.8,0.8,1,1]
+    },
+    "Button":
+    {
+      "initialAutoRepeatingDelay":2.0,
+      "nextAutoRepeatingDelay":0.9
+      // Note: Visuals added to Button will be used in all derived buttons unless overridden.
+    },
+    "PushButton":
+    {
+      "styles":["Button"],
+      "autoRepeating":false,
+      "togglable":false,
+      "labelPadding":[ 12.0, 12.0, 12.0, 12.0 ],
+      "label":
+       {
+         "visualType": "TEXT",
+         "horizontalAlignment": "CENTER",
+         "pointSize" : 12.0, // Point size must always be provided to Text Visual
+         "verticalAlignment": "CENTER"
+       },
+      "unselectedBackgroundVisual":
+       {
+         "visualType": "IMAGE",
+         "url": "{DALI_IMAGE_DIR}button-up.9.png"
+       },
+       "selectedBackgroundVisual":
+       {
+         "visualType": "IMAGE",
+         "url": "{DALI_IMAGE_DIR}button-down.9.png"
+       },
+       "disabledSelectedBackgroundVisual":
+       {
+         "visualType": "IMAGE",
+         "url": "{DALI_IMAGE_DIR}button-down-disabled.9.png"
+       },
+       "disabledUnselectedBackgroundVisual":
+       {
+         "visualType": "IMAGE",
+         "url": "{DALI_IMAGE_DIR}button-disabled.9.png"
+       }
+    },
+    "CheckBoxButton":
+    {
+      "styles":["Button"],
+      "labelPadding":[ 12.0, 12.0, 0.0, 0.0 ],
+      "label":
+       {
+         "visualType": "TEXT",
+         "pointSize" : 12.0, // Point size must always be provided to Text Visual
+         "verticalAlignment": "CENTER"
+       },
+      "unselectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}checkbox-unselected.png"
+      },
+      "selectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}checkbox-selected.png"
+      },
+      "disabledUnselectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}checkbox-unselected-disabled.png"
+      },
+      "disabledSelectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}checkbox-selected-disabled.png"
+      }
+    },
+    "RadioButton":
+    {
+      "styles":["Button"],
+      "labelPadding":[ 12.0, 12.0, 0.0, 0.0 ],
+      "label":
+       {
+         "visualType": "TEXT",
+         "pointSize" : 12.0, // Point size must always be provided to Text Visual
+         "verticalAlignment": "CENTER"
+       },
+      "unselectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}radio-button-unselected.png"
+      },
+      "selectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}radio-button-selected.png"
+      },
+      "disabledUnselectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}radio-button-unselected-disabled.png"
+      },
+      "disabledSelectedVisual":
+      {
+        "visualType": "IMAGE",
+        "url": "{DALI_IMAGE_DIR}radio-button-selected-disabled.png"
+      }
     }
   }
 }