From: Paul Wisbey Date: Thu, 9 Apr 2015 12:21:16 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/tizen' into new_text X-Git-Tag: dali_1.0.38~11^2~2^2~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=d04c5bdbb95cc98f90848c7a98b0b2804df6e5b8;hp=-c Merge remote-tracking branch 'origin/tizen' into new_text Change-Id: Iba714851799e17a461ac18d8431204835675c67b --- d04c5bdbb95cc98f90848c7a98b0b2804df6e5b8 diff --combined automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h index 736a724,4217d55..88315d4 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h @@@ -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& 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(); diff --combined dali-toolkit/internal/controls/buttons/push-button-impl.cpp index 24fa230,1890686..3910e43 --- a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp @@@ -23,7 -23,7 +23,7 @@@ #include // INTERNAL INCLUDES -#include +#include 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; diff --combined dali-toolkit/public-api/controls/control-impl.cpp index 216491b,4cea531..f8eded1 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@@ -22,7 -22,6 +22,6 @@@ #include #include #include - #include #include #include #include @@@ -140,10 -139,11 +139,11 @@@ void SetupBackgroundActor( Actor actor actor.SetZ( BACKGROUND_ACTOR_Z_POSITION ); actor.SetRelayoutEnabled( false ); - Constraint constraint = Constraint::New( constrainingIndex, - ParentSource( Actor::Property::SIZE ), + Constraint constraint = Constraint::New( 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(), @@@ -247,12 -246,6 +247,12 @@@ 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 >() ); @@@ -313,12 -306,6 +313,12 @@@ switch ( index ) { + case Toolkit::Control::Property::STYLE_NAME: + { + value = controlImpl.GetStyleName(); + break; + } + case Toolkit::Control::Property::BACKGROUND_COLOR: { value = controlImpl.GetBackgroundColor(); @@@ -360,7 -347,6 +360,7 @@@ // 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; @@@ -383,14 -369,12 +383,14 @@@ 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