{
/**
- * 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
{
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::TextLabel label = Toolkit::TextLabel::DownCast( GetLabel() );