Merge remote-tracking branch 'origin/tizen' into new_text 10/38010/1
authorPaul Wisbey <p.wisbey@samsung.com>
Thu, 9 Apr 2015 12:21:16 +0000 (13:21 +0100)
committerPaul Wisbey <p.wisbey@samsung.com>
Thu, 9 Apr 2015 12:22:40 +0000 (13:22 +0100)
Change-Id: Iba714851799e17a461ac18d8431204835675c67b

1  2 
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h
dali-toolkit/internal/controls/buttons/push-button-impl.cpp
dali-toolkit/public-api/controls/control-impl.cpp

@@@ -296,6 -296,41 +296,6 @@@ void DALI_TEST_EQUALS( const std::strin
  void DALI_TEST_EQUALS( const char* str1, const std::string &str2, const char* location);
  
  /**
 - * Test whether two UTF32 strings are equal.
 - * @param[in] str1 The first string
 - * @param[in] str2 The second string
 - * @param[in] location The TEST_LOCATION macro should be used here
 - */
 -template<>
 -inline void DALI_TEST_EQUALS<const Integration::TextArray&>( const Integration::TextArray& str1, const Integration::TextArray& str2, const char* location)
 -{
 -  if( !std::equal( str1.Begin(), str1.End(), str2.Begin() ) )
 -  {
 -    fprintf(stderr, "%s, checking '", location);
 -
 -    for( unsigned int i = 0; i < str1.Count(); ++i )
 -    {
 -      fprintf(stderr, "%c", str1[i]);
 -    }
 -
 -    fprintf(stderr, "' == '");
 -
 -    for( unsigned int i = 0; i < str2.Count(); ++i )
 -    {
 -      fprintf(stderr, "%c", str2[i]);
 -    }
 -
 -    fprintf(stderr, "'\n");
 -
 -    tet_result(TET_FAIL);
 -  }
 -  else
 -  {
 -    tet_result(TET_PASS);
 -  }
 -}
 -
 -/**
   * Test whether one unsigned integer value is greater than another.
   * Test succeeds if value1 > value2
   * @param[in] value1 The first value
@@@ -336,7 -371,7 +336,7 @@@ inline void DALI_TEST_PRINT_ASSERT( Dal
  struct ConstraintAppliedCheck
  {
    ConstraintAppliedCheck( bool& signalReceived );
-   void operator()( ActiveConstraint& constraint );
+   void operator()( Constraint& constraint );
    void Reset();
    void CheckSignalReceived();
    void CheckSignalNotReceived();
@@@ -23,7 -23,7 +23,7 @@@
  #include <dali/public-api/object/type-registry.h>
  
  // INTERNAL INCLUDES
 -#include <dali-toolkit/public-api/controls/text-view/text-view.h>
 +#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
  
  namespace Dali
  {
@@@ -53,24 -53,18 +53,18 @@@ namespac
  {
  
  /**
-  * Find the first image actor in the actor hierarchy
+  * 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
   */
ImageActor FindImageActor( Actor root )
void SizeOfActorIfLarger( Actor root, Vector3& size )
  {
-   ImageActor imageActor = ImageActor::DownCast( root );
-   if( !imageActor && root )
+   if ( root )
    {
-     for( unsigned int i = 0, numChildren = root.GetChildCount(); i < numChildren; ++i )
-     {
-       ImageActor childImageActor = FindImageActor( root.GetChildAt( i ) );
-       if( childImageActor )
-       {
-         return childImageActor;
-       }
-     }
+     // RelayoutSize retreived for Actor to use any padding set to it.
+     size.width = std::max( root.GetRelayoutSize( WIDTH ), size.width );
+     size.height = std::max( root.GetRelayoutSize( HEIGHT ), size.height );
    }
-   return imageActor;
  }
  
  } // unnamed namespace
@@@ -580,29 -574,18 +574,18 @@@ Vector3 PushButton::GetNaturalSize(
  {
    Vector3 size;
  
-   // If background and background not scale9 try get size from that
-   ImageActor imageActor = FindImageActor( GetButtonImage() );
-   if( imageActor && imageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
-   {
-     size.width = imageActor.GetRelayoutSize( WIDTH );
-     size.height = imageActor.GetRelayoutSize( HEIGHT );
-   }
-   ImageActor backgroundImageActor = FindImageActor( GetBackgroundImage() );
-   if( backgroundImageActor && backgroundImageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
-   {
-     size.width = std::max( size.width, backgroundImageActor.GetRelayoutSize( WIDTH ) );
-     size.height = std::max( size.height, backgroundImageActor.GetRelayoutSize( HEIGHT ) );
-   }
+   // Check Image and Background image and use the largest size as the control's Natural size.
+   SizeOfActorIfLarger( GetButtonImage(), size );
+   SizeOfActorIfLarger( GetBackgroundImage(), size );
  
    // If label, test against it's size
 -  Toolkit::TextView textView = Toolkit::TextView::DownCast( GetLabel() );
 -  if( textView )
 +  Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( GetLabel() );
 +  if( label )
    {
 -    Vector3 textViewSize = textView.GetNaturalSize();
 +    Vector3 labelSize = label.GetNaturalSize();
  
 -    size.width = std::max( size.width, textViewSize.width + TEXT_PADDING * 2.0f );
 -    size.height = std::max( size.height, textViewSize.height + TEXT_PADDING * 2.0f );
 +    size.width  = std::max( size.width,  labelSize.width  + TEXT_PADDING * 2.0f );
 +    size.height = std::max( size.height, labelSize.height + TEXT_PADDING * 2.0f );
    }
  
    return size;
@@@ -22,7 -22,6 +22,6 @@@
  #include <stack>
  #include <dali/public-api/actors/image-actor.h>
  #include <dali/public-api/actors/mesh-actor.h>
- #include <dali/public-api/animation/active-constraint.h>
  #include <dali/public-api/animation/constraint.h>
  #include <dali/public-api/animation/constraints.h>
  #include <dali/public-api/geometry/mesh.h>
@@@ -140,10 -139,11 +139,11 @@@ void SetupBackgroundActor( Actor actor
    actor.SetZ( BACKGROUND_ACTOR_Z_POSITION );
    actor.SetRelayoutEnabled( false );
  
-   Constraint constraint = Constraint::New<Vector3>( constrainingIndex,
-                                                     ParentSource( Actor::Property::SIZE ),
+   Constraint constraint = Constraint::New<Vector3>( actor,
+                                                     constrainingIndex,
                                                      EqualToConstraint() );
-   actor.ApplyConstraint( constraint );
+   constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+   constraint.Apply();
  }
  
  } // unnamed namespace
@@@ -168,7 -168,6 +168,7 @@@ public
    // Construction & Destruction
    Impl(Control& controlImpl)
    : mControlImpl( controlImpl ),
 +    mStyleName(""),
      mBackground( NULL ),
      mStartingPinchScale( NULL ),
      mKeyEventSignal(),
  
        switch ( index )
        {
 +        case Toolkit::Control::Property::STYLE_NAME:
 +        {
 +          controlImpl.SetStyleName( value.Get< std::string >() );
 +          break;
 +        }
 +
          case Toolkit::Control::Property::BACKGROUND_COLOR:
          {
            controlImpl.SetBackgroundColor( value.Get< Vector4 >() );
  
        switch ( index )
        {
 +        case Toolkit::Control::Property::STYLE_NAME:
 +        {
 +          value = controlImpl.GetStyleName();
 +          break;
 +        }
 +
          case Toolkit::Control::Property::BACKGROUND_COLOR:
          {
            value = controlImpl.GetBackgroundColor();
    // Data
  
    Control& mControlImpl;
 +  std::string mStyleName;
    Background* mBackground;           ///< Only create the background if we use it
    Vector3* mStartingPinchScale;      ///< The scale when a pinch gesture starts, TODO: consider removing this
    Toolkit::Control::KeyEventSignalType mKeyEventSignal;
    static PropertyRegistration PROPERTY_1;
    static PropertyRegistration PROPERTY_2;
    static PropertyRegistration PROPERTY_3;
 +  static PropertyRegistration PROPERTY_4;
  };
  
  // Properties registered without macro to use specific member variables.
 -PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "background-color", Toolkit::Control::Property::BACKGROUND_COLOR, Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 -PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "background-image", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP,     &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 -PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "key-input-focus",  Toolkit::Control::Property::KEY_INPUT_FOCUS,  Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 +PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "style-name",       Toolkit::Control::Property::STYLE_NAME,       Property::STRING,  &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 +PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "background-color", Toolkit::Control::Property::BACKGROUND_COLOR, Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 +PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "background-image", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP,     &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 +PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "key-input-focus",  Toolkit::Control::Property::KEY_INPUT_FOCUS,  Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
  
  Toolkit::Control Control::New()
  {
@@@ -507,23 -491,6 +507,23 @@@ LongPressGestureDetector Control::GetLo
    return mImpl->mLongPressGestureDetector;
  }
  
 +void Control::SetStyleName( const std::string& styleName )
 +{
 +  if( styleName != mImpl->mStyleName )
 +  {
 +    mImpl->mStyleName = styleName;
 +
 +    // Apply new style
 +    Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
 +    GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
 +  }
 +}
 +
 +const std::string& Control::GetStyleName() const
 +{
 +  return mImpl->mStyleName;
 +}
 +
  void Control::SetBackgroundColor( const Vector4& color )
  {
    Background& background( mImpl->GetBackground() );
@@@ -763,7 -730,7 +763,7 @@@ void Control::Initialize(
      Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
  
      // Register for style changes
 -    styleManager.StyleChangeSignal().Connect( this, &Control::DoStyleChange );
 +    styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
  
      // SetTheme
      GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
@@@ -841,13 -808,13 +841,13 @@@ void Control::OnActivated(
  {
  }
  
 -void Control::OnThemeChange( Toolkit::StyleManager styleManager )
 -{
 -  GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
 -}
 -
 -void Control::OnFontChange( bool defaultFontChange, bool defaultFontSizeChange )
 +void Control::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
  {
 +  // By default the control is only interested in theme (not font) changes
 +  if( change.themeChange )
 +  {
 +    GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
 +  }
  }
  
  void Control::OnPinch(const PinchGesture& pinch)
@@@ -1017,6 -984,18 +1017,6 @@@ void Control::SignalDisconnected( SlotO
    mImpl->SignalDisconnected( slotObserver, callback );
  }
  
 -void Control::DoStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
 -{
 -  if( change.themeChange )
 -  {
 -    OnThemeChange( styleManager );
 -  }
 -  else if( change.defaultFontChange || change.defaultFontSizeChange )
 -  {
 -    OnFontChange( change.defaultFontChange, change.defaultFontSizeChange );
 -  }
 -}
 -
  } // namespace Internal
  
  } // namespace Toolkit