// CLASS HEADER
#include <dali/internal/event/actors/image-actor-impl.h>
+// EXTERNAL INCLUDES
+#include <cstring> // for strcmp
+
// INTERNAL INCLUDES
#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/scripting/scripting.h>
+#include <dali/devel-api/scripting/scripting.h>
#include <dali/internal/event/common/property-helper.h>
#include <dali/internal/event/effects/shader-effect-impl.h>
#include <dali/internal/event/images/image-connector.h>
// Name Type writable animatable constraint-input enum for index-checking
DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "pixel-area", RECTANGLE, true, false, true, Dali::ImageActor::Property::PixelArea )
-DALI_PROPERTY( "style", STRING, true, false, true, Dali::ImageActor::Property::Style )
-DALI_PROPERTY( "border", VECTOR4, true, false, true, Dali::ImageActor::Property::Border )
-DALI_PROPERTY( "image", MAP, true, false, false, Dali::ImageActor::Property::Image )
+DALI_PROPERTY( "pixel-area", RECTANGLE, true, false, true, Dali::ImageActor::Property::PIXEL_AREA )
+DALI_PROPERTY( "style", STRING, true, false, true, Dali::ImageActor::Property::STYLE )
+DALI_PROPERTY( "border", VECTOR4, true, false, true, Dali::ImageActor::Property::BORDER )
+DALI_PROPERTY( "image", MAP, true, false, false, Dali::ImageActor::Property::IMAGE )
DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX )
BaseHandle Create()
return Dali::ImageActor::New();
}
-TypeRegistration mType( typeid( Dali::ImageActor ), typeid( Dali::RenderableActor ), Create );
+TypeRegistration mType( typeid( Dali::ImageActor ), typeid( Dali::Actor ), Create );
ImageActor::Style StyleEnum(const std::string &s)
{
actor->Initialize();
// Create the attachment
- actor->mImageAttachment = ImageAttachment::New( *actor->mStage, *actor->mNode );
+ actor->mImageAttachment = ImageAttachment::New( actor->GetEventThreadServices(), *actor->mNode );
actor->Attach( *actor->mImageAttachment );
return actor;
void ImageActor::OnInitialize()
{
+ SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
}
void ImageActor::SetImage( ImagePtr& image )
}
// set the actual image (normal or 9 patch) and natural size based on that
mImageAttachment->SetImage( newImage );
- SetNaturalSize();
+
+ RelayoutRequest();
}
ImagePtr ImageActor::GetImage()
return mImageAttachment->GetImage();
}
-void ImageActor::SetToNaturalSize()
-{
- mUsingNaturalSize = true;
-
- SetNaturalSize();
-}
-
void ImageActor::SetPixelArea( const PixelArea& pixelArea )
{
mImageAttachment->SetPixelArea( pixelArea );
- SetNaturalSize();
+ RelayoutRequest();
}
const ImageActor::PixelArea& ImageActor::GetPixelArea() const
{
mImageAttachment->ClearPixelArea();
- if( mUsingNaturalSize )
- {
- ImagePtr image = mImageAttachment->GetImage();
- if( image )
- {
- mInternalSetSize = true;
- SetSize( image->GetNaturalSize() );
- mInternalSetSize = false;
- }
- }
+ RelayoutRequest();
}
void ImageActor::SetStyle( Style style )
}
ImageActor::ImageActor()
-: RenderableActor(),
- mUsingNaturalSize(true),
- mInternalSetSize(false)
+: Actor( Actor::RENDERABLE )
{
}
{
}
-void ImageActor::SetNaturalSize()
-{
- if( mUsingNaturalSize )
- {
- mInternalSetSize = true;
- SetSize( CalculateNaturalSize() );
- mInternalSetSize = false;
- }
-}
-
Vector3 ImageActor::GetNaturalSize() const
{
Vector2 naturalSize( CalculateNaturalSize() );
return size;
}
-void ImageActor::OnSizeSet( const Vector3& targetSize )
-{
- if( !mInternalSetSize )
- {
- mUsingNaturalSize = false;
- }
-}
-
-void ImageActor::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
-{
- mUsingNaturalSize = false;
-}
-
void ImageActor::OnStageConnectionInternal()
{
}
unsigned int ImageActor::GetDefaultPropertyCount() const
{
- return RenderableActor::GetDefaultPropertyCount() + DEFAULT_PROPERTY_COUNT;
+ return Actor::GetDefaultPropertyCount() + DEFAULT_PROPERTY_COUNT;
}
void ImageActor::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
{
- RenderableActor::GetDefaultPropertyIndices( indices ); // RenderableActor class properties
+ Actor::GetDefaultPropertyIndices( indices ); // Actor class properties
- indices.reserve( indices.size() + DEFAULT_PROPERTY_COUNT );
+ indices.Reserve( indices.Size() + DEFAULT_PROPERTY_COUNT );
int index = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i, ++index )
{
- indices.push_back( index );
+ indices.PushBack( index );
}
}
{
if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
{
- return RenderableActor::IsDefaultPropertyWritable(index);
+ return Actor::IsDefaultPropertyWritable(index);
}
index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
{
if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
{
- return RenderableActor::IsDefaultPropertyAnimatable( index );
+ return Actor::IsDefaultPropertyAnimatable( index );
}
index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
{
if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
{
- return RenderableActor::IsDefaultPropertyAConstraintInput( index );
+ return Actor::IsDefaultPropertyAConstraintInput( index );
}
index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
{
if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
{
- return RenderableActor::GetDefaultPropertyType( index );
+ return Actor::GetDefaultPropertyType( index );
}
index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
{
if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
{
- return RenderableActor::GetDefaultPropertyName(index);
+ return Actor::GetDefaultPropertyName(index);
}
index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
// If not found, check in base class
if( Property::INVALID_INDEX == index )
{
- index = RenderableActor::GetDefaultPropertyIndex( name );
+ index = Actor::GetDefaultPropertyIndex( name );
}
return index;
}
{
if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
{
- RenderableActor::SetDefaultProperty( index, propertyValue );
+ Actor::SetDefaultProperty( index, propertyValue );
}
else
{
switch(index)
{
- case Dali::ImageActor::Property::PixelArea:
+ case Dali::ImageActor::Property::PIXEL_AREA:
{
SetPixelArea(propertyValue.Get<Rect<int> >());
break;
}
- case Dali::ImageActor::Property::Style:
+ case Dali::ImageActor::Property::STYLE:
{
SetStyle( StyleEnum( propertyValue.Get<std::string>() ) );
break;
}
- case Dali::ImageActor::Property::Border:
+ case Dali::ImageActor::Property::BORDER:
{
SetNinePatchBorder( propertyValue.Get<Vector4>(), true /*in pixels*/ );
break;
}
- case Dali::ImageActor::Property::Image:
+ case Dali::ImageActor::Property::IMAGE:
{
Dali::Image img = Scripting::NewImage( propertyValue );
if(img)
Property::Value ret;
if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
{
- ret = RenderableActor::GetDefaultProperty( index );
+ ret = Actor::GetDefaultProperty( index );
}
else
{
switch( index )
{
- case Dali::ImageActor::Property::PixelArea:
+ case Dali::ImageActor::Property::PIXEL_AREA:
{
Rect<int> r = GetPixelArea();
ret = r;
break;
}
- case Dali::ImageActor::Property::Style:
+ case Dali::ImageActor::Property::STYLE:
{
ret = StyleString( GetStyle() );
break;
}
- case Dali::ImageActor::Property::Border:
+ case Dali::ImageActor::Property::BORDER:
{
ret = GetNinePatchBorder();
break;
}
- case Dali::ImageActor::Property::Image:
+ case Dali::ImageActor::Property::IMAGE:
{
Property::Map map;
Scripting::CreatePropertyMap( Dali::Image( mImageAttachment->GetImage().Get() ), map );
void ImageActor::SetSortModifier(float modifier)
{
- mImageAttachment->SetSortModifier(modifier);
+ mImageAttachment->SetSortModifier( modifier );
}
float ImageActor::GetSortModifier() const
return mImageAttachment->GetSortModifier();
}
+void ImageActor::SetDepthIndex( int depthIndex )
+{
+ mImageAttachment->SetSortModifier( depthIndex );
+}
+
+int ImageActor::GetDepthIndex() const
+{
+ return static_cast< int >( mImageAttachment->GetSortModifier() );
+}
+
void ImageActor::SetCullFace(CullFaceMode mode)
{
mImageAttachment->SetCullFace( mode );