Replace TextView with TextLabel
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / push-button-impl.cpp
index 08948de..1a5c3a4 100644 (file)
@@ -23,6 +23,7 @@
 #include <dali/public-api/object/type-registry.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
 
 namespace Dali
 {
@@ -1071,6 +1072,23 @@ Vector3 PushButton::GetNaturalSize()
         size.height = std::max( size.height, imageSize.height );
       }
     }
+
+    // If label, test against it's size
+    Toolkit::TextLabel textLabel = Toolkit::TextLabel::DownCast( GetLabel() );
+    if( textLabel )
+    {
+      Vector3 textLabelSize = textLabel.GetNaturalSize();
+
+      if( widthIsZero )
+      {
+        size.width = std::max( size.width, textLabelSize.width + TEXT_PADDING * 2.0f );
+      }
+
+      if( heightIsZero )
+      {
+        size.height = std::max( size.height, textLabelSize.height + TEXT_PADDING * 2.0f );
+      }
+    }
   }
 
   return size;