#include <dali/internal/event/actors/image-actor-impl.h>
// INTERNAL INCLUDES
-#include <dali/internal/event/images/nine-patch-image-impl.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/internal/event/common/property-index-ranges.h>
-#include <dali/internal/event/images/image-connector.h>
#include <dali/public-api/scripting/scripting.h>
+#include <dali/internal/event/common/property-helper.h>
+#include <dali/internal/event/images/image-connector.h>
+#include <dali/internal/event/images/nine-patch-image-impl.h>
namespace Dali
{
-const Property::Index ImageActor::PIXEL_AREA = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT;
-const Property::Index ImageActor::STYLE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 1;
-const Property::Index ImageActor::BORDER = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 2;
-const Property::Index ImageActor::IMAGE = Internal::DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT + 3;
-
namespace Internal
{
namespace
{
+// Properties
+
+// 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_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX )
+
BaseHandle Create()
{
return Dali::ImageActor::New();
}
-TypeRegistration mType( typeid(Dali::ImageActor), typeid(Dali::RenderableActor), Create );
-
-const Internal::PropertyDetails DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[] =
-{
- // Name Type writable animatable constraint-input
- { "pixel-area", Property::RECTANGLE, true, false, true }, // PIXEL_AREA
- { "style", Property::STRING, true, false, true }, // STYLE
- { "border", Property::VECTOR4, true, false, true }, // BORDER
- { "image", Property::MAP, true, false, false }, // IMAGE
-};
-const int DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT = sizeof( DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS ) / sizeof( DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[0] );
+TypeRegistration mType( typeid( Dali::ImageActor ), typeid( Dali::RenderableActor ), Create );
ImageActor::Style StyleEnum(const std::string &s)
{
unsigned int ImageActor::GetDefaultPropertyCount() const
{
- return RenderableActor::GetDefaultPropertyCount() + DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT;
+ return RenderableActor::GetDefaultPropertyCount() + DEFAULT_PROPERTY_COUNT;
}
void ImageActor::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
{
RenderableActor::GetDefaultPropertyIndices( indices ); // RenderableActor class properties
- indices.reserve( indices.size() + DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT );
+ indices.reserve( indices.size() + DEFAULT_PROPERTY_COUNT );
- int index = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT;
- for ( int i = 0; i < DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT; ++i, ++index )
+ int index = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
+ for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i, ++index )
{
indices.push_back( index );
}
bool ImageActor::IsDefaultPropertyWritable( Property::Index index ) const
{
- if( index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT )
+ if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
{
return RenderableActor::IsDefaultPropertyWritable(index);
}
- else
+
+ index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
+ if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) )
{
- index -= DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT;
- if ( ( index >= 0 ) && ( index < DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT ) )
- {
- return DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[ index ].writable;
- }
+ return DEFAULT_PROPERTY_DETAILS[ index ].writable;
}
+
return false;
}
bool ImageActor::IsDefaultPropertyAnimatable( Property::Index index ) const
{
- if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT)
+ if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
{
- return RenderableActor::IsDefaultPropertyAnimatable(index);
+ return RenderableActor::IsDefaultPropertyAnimatable( index );
}
- else
+
+ index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
+ if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) )
{
- index -= DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT;
- if ( ( index >= 0 ) && ( index < DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT ) )
- {
- return DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[ index ].animatable;
- }
+ return DEFAULT_PROPERTY_DETAILS[ index ].animatable;
}
+
return false;
}
bool ImageActor::IsDefaultPropertyAConstraintInput( Property::Index index ) const
{
- if( index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT )
+ if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
{
- return RenderableActor::IsDefaultPropertyAConstraintInput(index);
+ return RenderableActor::IsDefaultPropertyAConstraintInput( index );
}
- else
+
+ index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
+ if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) )
{
- index -= DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT;
- if ( ( index >= 0 ) && ( index < DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT ) )
- {
- return DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[ index ].constraintInput;
- }
+ return DEFAULT_PROPERTY_DETAILS[ index ].constraintInput;
}
+
return false;
}
Property::Type ImageActor::GetDefaultPropertyType( Property::Index index ) const
{
- if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT)
+ if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
{
- return RenderableActor::GetDefaultPropertyType(index);
+ return RenderableActor::GetDefaultPropertyType( index );
}
- else
- {
- index -= DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT;
- if ( ( index >= 0 ) && ( index < DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT ) )
- {
- return DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[index].type;
- }
- else
- {
- // index out-of-bounds
- return Property::NONE;
- }
+ index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
+ if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) )
+ {
+ return DEFAULT_PROPERTY_DETAILS[index].type;
}
+
+ // index out-of-bounds
+ return Property::NONE;
}
const char* ImageActor::GetDefaultPropertyName( Property::Index index ) const
{
- if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT)
+ if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
{
return RenderableActor::GetDefaultPropertyName(index);
}
- else
- {
- index -= DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT;
- if ( ( index >= 0 ) && ( index < DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT ) )
- {
- return DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[index].name;
- }
- else
- {
- // index out-of-bounds
- return NULL;
- }
+ index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
+ if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) )
+ {
+ return DEFAULT_PROPERTY_DETAILS[index].name;
}
+
+ // index out-of-bounds
+ return NULL;
}
Property::Index ImageActor::GetDefaultPropertyIndex(const std::string& name) const
Property::Index index = Property::INVALID_INDEX;
// Look for name in default properties
- for( int i = 0; i < DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT; ++i )
+ for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
{
- const Internal::PropertyDetails* property = &DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[ i ];
- if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string
+ const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ];
+ if( 0 == strcmp( name.c_str(), property->name ) ) // Don't want to convert rhs to string
{
- index = i + DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT;
+ index = i + DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
break;
}
}
void ImageActor::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue )
{
- if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT)
+ if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
{
- RenderableActor::SetDefaultProperty(index, propertyValue);
+ RenderableActor::SetDefaultProperty( index, propertyValue );
}
else
{
switch(index)
{
- case Dali::ImageActor::PIXEL_AREA:
+ case Dali::ImageActor::Property::PixelArea:
{
SetPixelArea(propertyValue.Get<Rect<int> >());
break;
}
- case Dali::ImageActor::STYLE:
+ case Dali::ImageActor::Property::Style:
{
- SetStyle(StyleEnum(propertyValue.Get<std::string>()));
+ SetStyle( StyleEnum( propertyValue.Get<std::string>() ) );
break;
}
- case Dali::ImageActor::BORDER:
+ case Dali::ImageActor::Property::Border:
{
SetNinePatchBorder( propertyValue.Get<Vector4>(), true /*in pixels*/ );
break;
}
- case Dali::ImageActor::IMAGE:
+ case Dali::ImageActor::Property::Image:
{
Dali::Image img = Scripting::NewImage( propertyValue );
if(img)
Property::Value ImageActor::GetDefaultProperty( Property::Index index ) const
{
Property::Value ret;
- if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT)
+ if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
{
- ret = RenderableActor::GetDefaultProperty(index);
+ ret = RenderableActor::GetDefaultProperty( index );
}
else
{
- switch(index)
+ switch( index )
{
- case Dali::ImageActor::PIXEL_AREA:
+ case Dali::ImageActor::Property::PixelArea:
{
Rect<int> r = GetPixelArea();
ret = r;
break;
}
- case Dali::ImageActor::STYLE:
+ case Dali::ImageActor::Property::Style:
{
- ret = StyleString(GetStyle());
+ ret = StyleString( GetStyle() );
break;
}
- case Dali::ImageActor::BORDER:
+ case Dali::ImageActor::Property::Border:
{
ret = GetNinePatchBorder();
break;
}
- case Dali::ImageActor::IMAGE:
+ case Dali::ImageActor::Property::Image:
{
Property::Map map;
Scripting::CreatePropertyMap( Dali::Image( mImageAttachment->GetImage().Get() ), map );
}
default:
{
- DALI_LOG_WARNING("Unknown property (%d)\n", index);
+ DALI_LOG_WARNING( "Unknown property (%d)\n", index );
break;
}
} // switch(index)