+Vector3 PushButton::GetNaturalSize()
+{
+ Vector3 size = Control::GetNaturalSize();
+
+ const bool widthIsZero = EqualsZero( size.width );
+ const bool heightIsZero = EqualsZero( size.height );
+
+ if( widthIsZero || heightIsZero )
+ {
+ // If background and background not scale9 try get size from that
+ ImageActor imageActor = FindImageActor( mButtonImage );
+ if( imageActor && imageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
+ {
+ Vector3 imageSize = RelayoutHelper::GetNaturalSize( imageActor );
+
+ if( widthIsZero )
+ {
+ size.width = imageSize.width;
+ }
+
+ if( heightIsZero )
+ {
+ size.height = imageSize.height;
+ }
+ }
+
+ ImageActor backgroundImageActor = FindImageActor( mBackgroundImage );
+ if( backgroundImageActor && backgroundImageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
+ {
+ Vector3 imageSize = RelayoutHelper::GetNaturalSize( backgroundImageActor );
+
+ if( widthIsZero )
+ {
+ size.width = std::max( size.width, imageSize.width );
+ }
+
+ if( heightIsZero )
+ {
+ size.height = std::max( size.height, imageSize.height );
+ }
+ }
+
+ // If label, test against it's size
+ Toolkit::TextView textView = Toolkit::TextView::DownCast( mLabel );
+ if( textView )
+ {
+ Vector3 textViewSize = textView.GetNaturalSize();
+
+ if( widthIsZero )
+ {
+ size.width = std::max( size.width, textViewSize.width + TEXT_PADDING * 2.0f );
+ }
+
+ if( heightIsZero )
+ {
+ size.height = std::max( size.height, textViewSize.height + TEXT_PADDING * 2.0f );
+ }
+ }
+ }
+
+ return size;
+}
+