- Image image = imageActor.GetImage();
- size = Vector3( static_cast<float>( image.GetWidth() ), static_cast<float>( image.GetHeight() ), depth );
+ size = actor.GetCurrentSize();
+ const float depth = size.depth;
+
+ // Get natural size for ImageActor.
+ // TODO: currently it doesn't work as expected.
+ ImageActor imageActor = ImageActor::DownCast( actor );
+ if( ( imageActor ) && ( imageActor.GetImage() ) )
+ {
+ Image image = imageActor.GetImage();
+ size = Vector3( static_cast<float>( image.GetWidth() ), static_cast<float>( image.GetHeight() ), depth );
+ }
+ else
+ {
+ // Get natural size for TextActor.
+ TextActor textActor = TextActor::DownCast( actor );
+ if( textActor )
+ {
+ Font font = textActor.GetFont();
+ if( !font )
+ {
+ font = Font::New();
+ }
+ size = font.MeasureText( textActor.GetText() );
+ size.depth = depth;
+ }
+ }