From: Paul Wisbey Date: Wed, 1 Apr 2015 15:47:10 +0000 (+0100) Subject: Fixed some TCT tests X-Git-Tag: dali_1.0.38~11^2~18 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=ab3b0a1938288a30a72e9bdf9a875afb9e56eb3d Fixed some TCT tests Change-Id: I7ebf6ba557f311fe42322c680d84392bab1b408c --- diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp index 05ced5a..8d2734b 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp @@ -713,7 +713,7 @@ int UtcDaliPushButtonProperties(void) // Button::PROPERTY_LABEL_ACTOR { button.SetLabel( "LABEL_TEXT_CUSTOM" ); - DALI_TEST_EQUALS( "TextView", button.GetProperty( Button::Property::LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); + DALI_TEST_EQUALS( "TextLabel", button.GetProperty( Button::Property::LABEL_ACTOR ).GetValue( "type" ).Get< std::string >(), TEST_LOCATION ); Property::Map map; map[ "type" ] = "Actor"; diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp index e2b419e..3557c0d 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp @@ -110,8 +110,7 @@ DummyControlImplOverride::~DummyControlImplOverride() { } void DummyControlImplOverride::OnInitialize() { initializeCalled = true; } -void DummyControlImplOverride::OnThemeChange(StyleManager change) { themeChangeCalled = true;} -void DummyControlImplOverride::OnFontChange(bool defaultFontChange, bool defaultFontSizeChange) { fontChangeCalled = true; } +void DummyControlImplOverride::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change ) { themeChangeCalled = change.themeChange; fontChangeCalled = change.defaultFontSizeChange; } void DummyControlImplOverride::OnPinch(const PinchGesture& pinch) { pinchCalled = true; } void DummyControlImplOverride::OnPan(const PanGesture& pan) { panCalled = true; } void DummyControlImplOverride::OnTap(const TapGesture& tap) { tapCalled = true; } diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h index d923ac18..473a01d 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h @@ -102,8 +102,7 @@ private: private: // From Internal::Control virtual void OnInitialize(); - virtual void OnThemeChange( StyleManager styleManager ); - virtual void OnFontChange(bool defaultFontChange, bool defaultFontSizeChange); + virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change ); virtual void OnPinch(const PinchGesture& pinch); virtual void OnPan(const PanGesture& pan); virtual void OnTap(const TapGesture& tap); diff --git a/dali-toolkit/internal/controls/popup/popup-impl.cpp b/dali-toolkit/internal/controls/popup/popup-impl.cpp index b67bdcc..23df7aa 100755 --- a/dali-toolkit/internal/controls/popup/popup-impl.cpp +++ b/dali-toolkit/internal/controls/popup/popup-impl.cpp @@ -263,13 +263,35 @@ void Popup::SetButtonAreaImage( Actor image ) void Popup::SetTitle( const std::string& text ) { -// TODO + // Replaces the current title actor. + if( mPopupLayout ) + { + mPopupLayout.RemoveChildAt( Toolkit::TableView::CellPosition( 0, 0 ) ); + } + + mTitle = Toolkit::TextLabel::New( text ); + mTitle.SetName( "POPUP_TITLE" ); + mTitle.SetColor( Color::BLACK ); + + if( mPopupLayout ) + { + mTitle.SetPadding( Padding( 0.0f, 0.0f, mPopupStyle->margin, mPopupStyle->margin ) ); + mTitle.SetResizePolicy( FILL_TO_PARENT, WIDTH ); + mTitle.SetDimensionDependency( HEIGHT, WIDTH ); // HeightForWidth + mPopupLayout.AddChild( mTitle, Toolkit::TableView::CellPosition( 0, 0 ) ); + } + + RelayoutRequest(); } -const std::string& Popup::GetTitle() const +std::string Popup::GetTitle() const { - static std::string temp(""); - return temp; + if( mTitle ) + { + return mTitle.GetProperty( Toolkit::TextLabel::Property::TEXT ); + } + + return std::string(); } void Popup::CreateFooter() @@ -712,6 +734,29 @@ Vector3 Popup::GetNaturalSize() Vector3 naturalSize( 0.0f, 0.0f, 0.0f ); + if ( mTitle ) + { + Vector3 titleNaturalSize = mTitle.GetImplementation().GetNaturalSize(); + // Buffer to avoid errors. The width of the popup could potentially be the width of the title text. + // It was observed in this case that text wrapping was then inconsistent when seen on device + const float titleBuffer = 0.5f; + titleNaturalSize.width += titleBuffer; + + // As TextLabel GetNaturalSize does not take wrapping into account, limit the width + // to that of the stage + if( titleNaturalSize.width >= maxWidth) + { + naturalSize.width = maxWidth; + naturalSize.height = mTitle.GetImplementation().GetHeightForWidth( naturalSize.width ); + } + else + { + naturalSize += titleNaturalSize; + } + + naturalSize.height += mPopupStyle->margin; + } + if( mContent ) { Vector3 contentSize = mContent.GetNaturalSize(); @@ -742,6 +787,12 @@ float Popup::GetHeightForWidth( float width ) float height( 0.0f ); float popupWidth( width - 2.f * ( POPUP_OUT_MARGIN_WIDTH + mPopupStyle->margin ) ); + if ( mTitle ) + { + height += mTitle.GetImplementation().GetHeightForWidth( popupWidth ); + height += mPopupStyle->margin; + } + if( mContent ) { height += mContent.GetHeightForWidth( popupWidth ) + mPopupStyle->margin; diff --git a/dali-toolkit/internal/controls/popup/popup-impl.h b/dali-toolkit/internal/controls/popup/popup-impl.h index 3fe2aba..efdac51 100755 --- a/dali-toolkit/internal/controls/popup/popup-impl.h +++ b/dali-toolkit/internal/controls/popup/popup-impl.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace Dali { @@ -86,7 +87,7 @@ public: /** * @copydoc Toolkit::Popup::GetTitle */ - const std::string& GetTitle() const; + std::string GetTitle() const; /** * @copydoc Toolkit::Popup::AddButton @@ -320,6 +321,7 @@ private: Actor mBackgroundImage; ///< Stores the background image. Actor mButtonAreaImage; ///< Stores the button background image. + Toolkit::TextLabel mTitle; ///< Stores the text title. Actor mContent; ///< Stores popup's content. Actor mBottomBg; ///< bottom button bar background. ImageActor is replaced with Actor due to hidden image. Actor mTailImage; ///< Stores the tail image diff --git a/dali-toolkit/public-api/controls/popup/popup.cpp b/dali-toolkit/public-api/controls/popup/popup.cpp index 1bb3fab..b557f01 100644 --- a/dali-toolkit/public-api/controls/popup/popup.cpp +++ b/dali-toolkit/public-api/controls/popup/popup.cpp @@ -87,7 +87,7 @@ void Popup::SetTitle( const std::string& text ) GetImpl(*this).SetTitle( text ); } -const std::string& Popup::GetTitle() const +std::string Popup::GetTitle() const { return GetImpl(*this).GetTitle(); } diff --git a/dali-toolkit/public-api/controls/popup/popup.h b/dali-toolkit/public-api/controls/popup/popup.h index 108dd9e..1ab708b 100644 --- a/dali-toolkit/public-api/controls/popup/popup.h +++ b/dali-toolkit/public-api/controls/popup/popup.h @@ -170,7 +170,7 @@ public: * * @return The text to appear as the heading for this Popup */ - const std::string& GetTitle() const; + std::string GetTitle() const; /** * @brief Adds a button to this Popup.