+ * Return the natural size of the actor.
+ *
+ * @for Actor
+ * @method getNaturalSize
+ * @return {Object} { x, y, z }
+ */
+void ActorApi::GetNaturalSize( const v8::FunctionCallbackInfo<v8::Value>& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+ Actor actor = GetActor( isolate, args );
+
+ Vector3 size( actor.GetNaturalSize() );
+
+ v8::Local<v8::Object> sizeObject = v8::Object::New( isolate );
+
+ sizeObject->Set( v8::String::NewFromUtf8( isolate, "x" ), v8::Integer::New( isolate, size.width ) );
+ sizeObject->Set( v8::String::NewFromUtf8( isolate, "y" ), v8::Integer::New( isolate, size.height ) );
+ sizeObject->Set( v8::String::NewFromUtf8( isolate, "z" ), v8::Integer::New( isolate, size.depth ) );
+
+ args.GetReturnValue().Set( sizeObject );
+}
+
+/**
+ * Return the value of negotiated dimension for the given dimension
+ *
+ * @for Actor
+ * @method getRelayoutSize
+ * @param {Integer} dimension The dimension of layout to retrieve (either dali.DIMENSION_WIDTH or dali.DIMENSION_HEIGHT)
+ * @return {Number} The value of the negotiated dimension
+ */
+void ActorApi::GetRelayoutSize( const v8::FunctionCallbackInfo<v8::Value>& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+ Actor actor = GetActor( isolate, args );
+
+ bool found;
+ int dimension = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing dimension parameter");
+ return;
+ }
+
+ args.GetReturnValue().Set( v8::Number::New( isolate, actor.GetRelayoutSize( static_cast<Dimension::Type>(dimension) ) ) );
+}
+
+/**
+ * Calculate the width of the actor given a height
+ *
+ * The natural size is used for default calculation.
+ * size 0 is treated as aspect ratio 1:1.
+ * @for Actor
+ * @method getWidthForHeight
+ * @param {Float} height to use
+ * @return {Float} Return the width based on the height
+ * @example
+ * myTextLabel.getWidthForHeight(40);
+ *
+ * // DALi uses this formula internally
+ * // width = naturalSize.width * height / naturalSize.height;
+ *
+ *
+ */
+void ActorApi::GetWidthForHeight( const v8::FunctionCallbackInfo<v8::Value>& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+ Actor actor = GetActor( isolate, args );
+
+ bool found;
+ float height = V8Utils::GetFloatParameter( PARAMETER_0, found, isolate, args, 0.f );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing height parameter");
+ return;
+ }
+ args.GetReturnValue().Set( v8::Number::New( isolate, actor.GetWidthForHeight( height ) ) );
+}
+
+/**
+ * Calculate the height of the actor given a width
+ *
+ * The natural size is used for default calculation.
+ * size 0 is treated as aspect ratio 1:1.
+ * @for Actor
+ * @method getHeightForWidth
+ * @param {Float} width to use
+ * @return {Float} Return the height based on the width
+ * @example
+ * myTextLabel.getHeightForWidth(250);
+ *
+ * // DALi uses this formula internally
+ * // height = naturalSize.height * width / naturalSize.width
+ */
+void ActorApi::GetHeightForWidth( const v8::FunctionCallbackInfo<v8::Value>& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+ Actor actor = GetActor( isolate, args );
+
+ bool found;
+ float width = V8Utils::GetFloatParameter( PARAMETER_0, found, isolate, args, 0.f );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing width parameter");
+ return;
+ }
+ args.GetReturnValue().Set( v8::Number::New( isolate, actor.GetHeightForWidth( width ) ) );
+}
+/**