Example #1
0
Vector3 GetNaturalSize( Actor actor )
{
  Vector3 size = actor.GetCurrentSize();
  const float depth = size.depth;

  // 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;
  }

  // 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 );
  }

  return size;
}
Example #2
0
float GetHeightForWidth( Actor actor, float width )
{
  Vector3 size = actor.GetCurrentSize();
  float height = 0.f;

  TextActor textActor = TextActor::DownCast( actor );
  if( textActor )
  {
    Font font = textActor.GetFont();
    if( !font )
    {
      font = Font::New();
    }
    size = font.MeasureText( textActor.GetText() );
  }

  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() ), 0.f );
  }

  height = size.height / ( size.width / width );

  return height;
}
int UtcDaliImageActorSetImage(void)
{
  TestApplication application;

  ImageActor actor = ImageActor::New(Image());

  DALI_TEST_CHECK(actor);

  actor.SetImage( Image() );

  DALI_TEST_CHECK(!actor.GetImage());
  END_TEST;
}