namespace Internal
{
-bool Layer::mFirstInstance = true;
-Actor::DefaultPropertyLookup* Layer::mDefaultLayerPropertyLookup = NULL;
namespace
{
+// Actions
+
+const char* const ACTION_RAISE = "raise";
+const char* const ACTION_LOWER = "lower";
+const char* const ACTION_RAISE_TO_TOP = "raise-to-top";
+const char* const ACTION_LOWER_TO_BOTTOM = "lower-to-bottom";
+
BaseHandle Create()
{
return Dali::Layer::New();
}
-TypeRegistration mType( typeid(Dali::Layer), typeid(Dali::Actor), Create );
-
-TypeAction a1(mType, Dali::Layer::ACTION_RAISE, &Layer::DoAction);
-TypeAction a2(mType, Dali::Layer::ACTION_LOWER, &Layer::DoAction);
-TypeAction a3(mType, Dali::Layer::ACTION_RAISE_TO_TOP, &Layer::DoAction);
-TypeAction a4(mType, Dali::Layer::ACTION_LOWER_TO_BOTTOM, &Layer::DoAction);
+TypeRegistration mType( typeid( Dali::Layer ), typeid( Dali::Actor ), Create );
-const std::string DEFAULT_LAYER_PROPERTY_NAMES[] =
-{
- "clipping-enable",
- "clipping-box"
-};
-const int DEFAULT_LAYER_PROPERTY_COUNT = sizeof( DEFAULT_LAYER_PROPERTY_NAMES ) / sizeof( std::string );
+TypeAction a1( mType, ACTION_RAISE, &Layer::DoAction );
+TypeAction a2( mType, ACTION_LOWER, &Layer::DoAction );
+TypeAction a3( mType, ACTION_RAISE_TO_TOP, &Layer::DoAction );
+TypeAction a4( mType, ACTION_LOWER_TO_BOTTOM, &Layer::DoAction );
-const Property::Type DEFAULT_LAYER_PROPERTY_TYPES[DEFAULT_LAYER_PROPERTY_COUNT] =
+const PropertyDetails DEFAULT_PROPERTY_DETAILS[] =
{
- Property::BOOLEAN, // "clipping-enable",
- Property::RECTANGLE, // "clipping-box",
+ // Name Type writable animatable constraint-input
+ { "clipping-enable", Property::BOOLEAN, true, false, true }, // CLIPPING_ENABLE
+ { "clipping-box", Property::RECTANGLE, true, false, true }, // CLIPPING_BOX
};
+const int DEFAULT_LAYER_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTY_DETAILS ) / sizeof( DEFAULT_PROPERTY_DETAILS[0] );
} // unnamed namespace
mSortFunction(Dali::Layer::ZValue),
mIsClipping(false),
mDepthTestDisabled(false),
- mTouchConsumed(false)
+ mTouchConsumed(false),
+ mHoverConsumed(false)
{
}
void Layer::OnInitialize()
{
- if(Layer::mFirstInstance)
- {
- mDefaultLayerPropertyLookup = new DefaultPropertyLookup();
- const int start = DEFAULT_ACTOR_PROPERTY_MAX_COUNT;
- for ( int i = 0; i < DEFAULT_LAYER_PROPERTY_COUNT; ++i )
- {
- (*mDefaultLayerPropertyLookup)[DEFAULT_LAYER_PROPERTY_NAMES[i]] = i + start;
- }
- Layer::mFirstInstance = false;
- }
}
Layer::~Layer()
// Clipping box is not animatable; this is the most up-to-date value
mClippingBox.Set(x, y, width, height);
+ // Convert mClippingBox to GL based coordinates (from bottom-left)
+ ClippingBox clippingBox( mClippingBox );
+ clippingBox.y = mStage->GetSize().height - clippingBox.y - clippingBox.height;
+
// layerNode is being used in a separate thread; queue a message to set the value
- SetClippingBoxMessage( mStage->GetUpdateInterface(), GetSceneLayerOnStage(), mClippingBox );
+ SetClippingBoxMessage( mStage->GetUpdateInterface(), GetSceneLayerOnStage(), clippingBox );
}
}
return mTouchConsumed;
}
+void Layer::SetHoverConsumed( bool consume )
+{
+ mHoverConsumed = consume;
+}
+
+bool Layer::IsHoverConsumed() const
+{
+ return mHoverConsumed;
+}
+
SceneGraph::Node* Layer::CreateNode() const
{
return SceneGraph::Layer::New();
}
else
{
- return true;
+ return true; // all properties writable, no need to lookup the table
}
}
}
else
{
- return false;
+ return false; // all properties non animateable, no need to lookup the table
}
}
{
return Actor::IsDefaultPropertyAConstraintInput(index);
}
- return true; // our properties can be used as an input to a constraint
+ return true; // our properties can be used as an input to a constraint, no need to lookup the table
}
Property::Type Layer::GetDefaultPropertyType( Property::Index index ) const
if ( ( index >= 0 ) && ( index < DEFAULT_LAYER_PROPERTY_COUNT ) )
{
- return DEFAULT_LAYER_PROPERTY_TYPES[index];
+ return DEFAULT_PROPERTY_DETAILS[index].type;
}
else
{
}
}
-
-const std::string& Layer::GetDefaultPropertyName( Property::Index index ) const
+const char* Layer::GetDefaultPropertyName( Property::Index index ) const
{
if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT)
{
if ( ( index >= 0 ) && ( index < DEFAULT_LAYER_PROPERTY_COUNT ) )
{
- return DEFAULT_LAYER_PROPERTY_NAMES[index];
+ return DEFAULT_PROPERTY_DETAILS[index].name;
}
else
{
- // index out-of-bounds
- static const std::string INVALID_PROPERTY_NAME;
- return INVALID_PROPERTY_NAME;
+ return NULL;
}
}
}
{
Property::Index index = Property::INVALID_INDEX;
- DALI_ASSERT_DEBUG( NULL != mDefaultLayerPropertyLookup );
-
// Look for name in current class' default properties
- DefaultPropertyLookup::const_iterator result = mDefaultLayerPropertyLookup->find( name );
- if ( mDefaultLayerPropertyLookup->end() != result )
+ for( int i = 0; i < DEFAULT_LAYER_PROPERTY_COUNT; ++i )
{
- index = result->second;
+ const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ];
+ if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string
+ {
+ index = i + DEFAULT_ACTOR_PROPERTY_MAX_COUNT;
+ break;
+ }
}
- else
+ if( Property::INVALID_INDEX == index )
{
// If not found, check in base class
index = Actor::GetDefaultPropertyIndex( name );
return ret;
}
-bool Layer::DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes)
+bool Layer::DoAction( BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes )
{
bool done = false;
- Layer* layer = dynamic_cast<Layer*>(object);
+ Layer* layer = dynamic_cast<Layer*>( object );
- if(layer)
+ if( layer )
{
- if(Dali::Layer::ACTION_RAISE == actionName)
+ if( 0 == strcmp( actionName.c_str(), ACTION_RAISE ) )
{
layer->Raise();
done = true;
}
- else if(Dali::Layer::ACTION_LOWER == actionName)
+ else if( 0 == strcmp( actionName.c_str(), ACTION_LOWER ) )
{
layer->Lower();
done = true;
}
- else if(Dali::Layer::ACTION_RAISE_TO_TOP == actionName)
+ else if( 0 == strcmp( actionName.c_str(), ACTION_RAISE_TO_TOP ) )
{
layer->RaiseToTop();
done = true;
}
- else if(Dali::Layer::ACTION_LOWER_TO_BOTTOM == actionName)
+ else if( 0 == strcmp( actionName.c_str(), ACTION_LOWER_TO_BOTTOM ) )
{
layer->LowerToBottom();
done = true;