lua/wrappers/gfx/lua_asset.cpp
/**
	 * Sets the inner borders of a scale nine system.
	 * Scale nine allows for an asset to be stretched only whilst keep the outer edge unstretched.
	 *
	 * The table is expected to have the values for "left_x", "right_x", "top_y" and "bottom_y".
	 * If these values are not defined, the values are left unset.
	 *
	 * These values are used in connection with the scale nine state, which defines if the scale nine
	 * system is to be turned off or used in horizontal, verticle or both modes.
	 * The valid values for setting the scale nine state are "none", "verticle", "horizontal" and "both".
	 * 
	 * @param table values A table of values defining the scale nine inner borders in pixels.
	 * @param string state The scale nine state to set.
	 * @returns am.asset This
	 */
Sets the inner borders of a scale nine system.
Scale nine allows for an asset to be stretched only whilst keep the outer edge unstretched.



These values are used in connection with the scale nine state, which defines if the scale nine
system is to be turned off or used in horizontal, verticle or both modes.

@param table values A table of values defining the scale nine inner borders in pixels.
@param string state The scale nine state to set.
Sets the inner borders of a scale nine system . Scale nine allows for an asset to be stretched only whilst keep the outer edge unstretched . These values are used in connection with the scale nine state which defines if the scale nine system is to be turned off or used in horizontal verticle or both modes . @param table values A table of values defining the scale nine inner borders in pixels . @param string state The scale nine state to set .
int Asset_scale_nine(lua_State *lua)
	{
		Asset *asset = castUData<Asset>(lua, 1);
		if (asset)
		{
			if (lua_gettop(lua) == 1)
			{
				const ScaleNine &scaleNine = asset->getScaleNine();
				lua_createtable(lua, 0, 4);
				LuaState L(lua);
				L.setTableValue("left_x", scaleNine.getLeft());
				L.setTableValue("right_x", scaleNine.getRight());
				L.setTableValue("top_y", scaleNine.getTop());
				L.setTableValue("bottom_y", scaleNine.getBottom());
				return 1;
			}
			else if (lua_istable(lua, 2))
			{
				LuaState L(lua);
				double leftX = -1.0, rightX = -1.0, topY = -1.0, bottomY = -1.0;
				lua_pushvalue(lua, 2);
				L.getTableDouble("left_x", leftX);
				L.getTableDouble("right_x", rightX);
				L.getTableDouble("top_y", topY);
				L.getTableDouble("bottom_y", bottomY);
				L.pop(1);
				ScaleNine scaleNine;
				scaleNine.setInnerBounds(leftX, rightX, topY, bottomY);
				if (lua_isbool(lua, 3) && lua_tobool(lua, 3))
				{
					bool verticle = topY >= 0.0 && bottomY > 0.0;
					bool horizontal = leftX >= 0.0 && rightX > 0.0;
					ScaleNineState state = SCALE_NINE_NONE;
					if (verticle && !horizontal)
					{
						state = SCALE_NINE_VERTICAL;
					}
					else if (!verticle && horizontal)
					{
						state = SCALE_NINE_HORIZONTAL;
					}
					else if (verticle && horizontal)
					{
						state = SCALE_NINE_BOTH;
					}
					asset->setScaleNine(scaleNine, state);
				}
				else if (lua_isstr(lua, 3))
				{
					ScaleNineState state = ScaleNine::getState(lua_tostring(lua, 3));
					asset->setScaleNine(scaleNine, state);
				}
				else
				{
					asset->setScaleNine(scaleNine);
				}
				lua_first(lua);
			}
			return LuaState::expectedArgs(lua, "scale_nine", 2, "table values, boolean [false] calc_state", "table values, string state");
		}
		return LuaState::expectedContext(lua, "scale_nine", "am.asset");
	}
int Asset_scale_nine ( lua_State * lua ) { Asset * asset = castUData < Asset > ( lua , 1 ) ; if ( asset ) { if ( lua_gettop ( lua ) == 1 ) { const ScaleNine & scaleNine = asset -> getScaleNine ( ) ; lua_createtable ( lua , 0 , 4 ) ; LuaState L ( lua ) ; L . setTableValue ( " " , scaleNine . getLeft ( ) ) ; L . setTableValue ( " " , scaleNine . getRight ( ) ) ; L . setTableValue ( " " , scaleNine . getTop ( ) ) ; L . setTableValue ( " " , scaleNine . getBottom ( ) ) ; return 1 ; } else if ( lua_istable ( lua , 2 ) ) { LuaState L ( lua ) ; double leftX = -1.0 , rightX = -1.0 , topY = -1.0 , bottomY = -1.0 ; lua_pushvalue ( lua , 2 ) ; L . getTableDouble ( " " , leftX ) ; L . getTableDouble ( " " , rightX ) ; L . getTableDouble ( " " , topY ) ; L . getTableDouble ( " " , bottomY ) ; L . pop ( 1 ) ; ScaleNine scaleNine ; scaleNine . setInnerBounds ( leftX , rightX , topY , bottomY ) ; if ( lua_isbool ( lua , 3 ) && lua_tobool ( lua , 3 ) ) { bool verticle = topY >= 0.0 && bottomY > 0.0 ; bool horizontal = leftX >= 0.0 && rightX > 0.0 ; ScaleNineState state = SCALE_NINE_NONE ; if ( verticle && ! horizontal ) { state = SCALE_NINE_VERTICAL ; } else if ( ! verticle && horizontal ) { state = SCALE_NINE_HORIZONTAL ; } else if ( verticle && horizontal ) { state = SCALE_NINE_BOTH ; } asset -> setScaleNine ( scaleNine , state ) ; } else if ( lua_isstr ( lua , 3 ) ) { ScaleNineState state = ScaleNine :: getState ( lua_tostring ( lua , 3 ) ) ; asset -> setScaleNine ( scaleNine , state ) ; } else { asset -> setScaleNine ( scaleNine ) ; } lua_first ( lua ) ; } return LuaState :: expectedArgs ( lua , " " , 2 , " " , " " ) ; } return LuaState :: expectedContext ( lua , " " , " " ) ; }
Sets the inner borders of a scale nine system.
Sets the inner borders of a scale nine system .