Fixed some TCT tests 48/37648/3
authorPaul Wisbey <p.wisbey@samsung.com>
Wed, 1 Apr 2015 15:47:10 +0000 (16:47 +0100)
committerPaul Wisbey <p.wisbey@samsung.com>
Wed, 1 Apr 2015 17:24:51 +0000 (18:24 +0100)
Change-Id: I7ebf6ba557f311fe42322c680d84392bab1b408c

automated-tests/src/dali-toolkit-internal/utc-Dali-PushButton.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h
dali-toolkit/internal/controls/popup/popup-impl.cpp
dali-toolkit/internal/controls/popup/popup-impl.h
dali-toolkit/public-api/controls/popup/popup.cpp
dali-toolkit/public-api/controls/popup/popup.h

index 05ced5a..8d2734b 100644 (file)
@@ -713,7 +713,7 @@ int UtcDaliPushButtonProperties(void)
   //  Button::PROPERTY_LABEL_ACTOR
   {
     button.SetLabel( "LABEL_TEXT_CUSTOM" );
   //  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";
 
     Property::Map map;
     map[ "type" ] = "Actor";
index e2b419e..3557c0d 100644 (file)
@@ -110,8 +110,7 @@ DummyControlImplOverride::~DummyControlImplOverride() { }
 
 
 void DummyControlImplOverride::OnInitialize() { initializeCalled = true; }
 
 
 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; }
 void DummyControlImplOverride::OnPinch(const PinchGesture& pinch) { pinchCalled = true; }
 void DummyControlImplOverride::OnPan(const PanGesture& pan) { panCalled = true; }
 void DummyControlImplOverride::OnTap(const TapGesture& tap) { tapCalled = true; }
index d923ac1..473a01d 100644 (file)
@@ -102,8 +102,7 @@ private:
 private: // From Internal::Control
 
   virtual void OnInitialize();
 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);
   virtual void OnPinch(const PinchGesture& pinch);
   virtual void OnPan(const PanGesture& pan);
   virtual void OnTap(const TapGesture& tap);
index b67bdcc..23df7aa 100755 (executable)
@@ -263,13 +263,35 @@ void Popup::SetButtonAreaImage( Actor image )
 
 void Popup::SetTitle( const std::string& text )
 {
 
 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<std::string>( Toolkit::TextLabel::Property::TEXT );
+  }
+
+  return std::string();
 }
 
 void Popup::CreateFooter()
 }
 
 void Popup::CreateFooter()
@@ -712,6 +734,29 @@ Vector3 Popup::GetNaturalSize()
 
   Vector3 naturalSize( 0.0f, 0.0f, 0.0f );
 
 
   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();
   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 ) );
 
   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;
   if( mContent )
   {
     height += mContent.GetHeightForWidth( popupWidth ) + mPopupStyle->margin;
index 3fe2aba..efdac51 100755 (executable)
@@ -28,6 +28,7 @@
 #include <dali-toolkit/public-api/controls/popup/popup.h>
 #include <dali-toolkit/internal/controls/popup/popup-style-impl.h>
 #include <dali-toolkit/public-api/controls/table-view/table-view.h>
 #include <dali-toolkit/public-api/controls/popup/popup.h>
 #include <dali-toolkit/internal/controls/popup/popup-style-impl.h>
 #include <dali-toolkit/public-api/controls/table-view/table-view.h>
+#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
 
 namespace Dali
 {
 
 namespace Dali
 {
@@ -86,7 +87,7 @@ public:
   /**
    * @copydoc Toolkit::Popup::GetTitle
    */
   /**
    * @copydoc Toolkit::Popup::GetTitle
    */
-  const std::string& GetTitle() const;
+  std::string GetTitle() const;
 
   /**
    * @copydoc Toolkit::Popup::AddButton
 
   /**
    * @copydoc Toolkit::Popup::AddButton
@@ -320,6 +321,7 @@ private:
 
   Actor mBackgroundImage;                 ///< Stores the background image.
   Actor mButtonAreaImage;                 ///< Stores the button background image.
 
   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
   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
index 1bb3fab..b557f01 100644 (file)
@@ -87,7 +87,7 @@ void Popup::SetTitle( const std::string& text )
   GetImpl(*this).SetTitle( text );
 }
 
   GetImpl(*this).SetTitle( text );
 }
 
-const std::string& Popup::GetTitle() const
+std::string Popup::GetTitle() const
 {
   return GetImpl(*this).GetTitle();
 }
 {
   return GetImpl(*this).GetTitle();
 }
index 108dd9e..1ab708b 100644 (file)
@@ -170,7 +170,7 @@ public:
    *
    * @return The text to appear as the heading for this Popup
    */
    *
    * @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.
 
   /**
    * @brief Adds a button to this Popup.