" \"parentOrigin\": \"TOP_LEFT\","
" \"anchorPoint\": \"{ANCHOR}\","
" \"padding\": \"{PADDING}\","
- " \"image\": { \"imageUrl\": \"dir/{IMAGE_PATH}\" },"
+ " \"image\": { \"url\": \"dir/{IMAGE_PATH}\" },"
" \"sizeWidth\": \"{WIDTH}\","
" \"signals\": [{"
" \"name\": \"touched\","
" \"name\": \"touched\",\n"
" \"action\": \"quit\"\n"
" }],\n"
- " \"customProperties\": {\n"
+ " \"properties\": {\n"
" \"newproperty\": true\n"
" },\n"
+ " \"animatableProperties\": {\n"
+ " \"newAnimatableproperty\": 3\n"
+ " },\n"
" \"actors\": [\n"
" {\n"
" \"type\":\"ImageView\",\n"
Property::Value value = actor.GetProperty(index);
DALI_TEST_CHECK( value.Get<bool>() == true );
+ index = actor.GetPropertyIndex("newAnimatableproperty");
+ DALI_TEST_CHECK( Property::INVALID_INDEX != index );
+ value = actor.GetProperty(index);
+ DALI_TEST_CHECK( value.Get<int>() == 3 );
+
END_TEST;
}
-int UtcDaliBuilderShaderEffectP(void)
+int UtcDaliBuilderCustomShaderP(void)
{
ToolkitTestApplication application;
" \"size\": [200, 200, 0],\n"
" \"effect\": \"Ripple2D\",\n"
" \"image\": {\n"
- " \"filename\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\",\n"
- " \"width\": 200,\n"
- " \"height\": 80,\n"
- " \"loadPolicy\": \"IMMEDIATE\",\n"
- " \"releasePolicy\": \"NEVER\"\n"
+ " \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\",\n"
+ " \"desiredWidth\": 200,\n"
+ " \"desiredHeight\": 80,\n"
+ " \"shader\": {\n"
+ " \"fragmentShader\": \"precision mediump float;\\nuniform sampler2D sTexture;\\nuniform vec4 uColor;\\nuniform float uAmplitude;\\nuniform float uTime;\\nvarying vec2 vTexCoord;\\nvoid main()\\n{\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude;\\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;}\\n\\n\"\n"
+ " }\n"
+ " },\n"
+ " \"customAnimatableProperties\": {\n"
+ " \"uAmplitude\": 0.02,\n"
+ " \"uTime\": 0.0\n"
" },\n"
" \"signals\": [\n"
" {\n"
" ]\n"
" }\n"
" ],\n"
- " \"paths\": {},\n"
" \"animations\": {\n"
" \"Animation_1\": {\n"
" \"loop\":true,\n"
" \"timePeriod\": {\n"
" \"delay\": 0,\n"
" \"duration\": 10.0\n"
- " },\n"
- " \"gui-builder-timeline-color\": \"#8dc0da\"\n"
+ " }\n"
" }\n"
" ]\n"
" }\n"
- " },\n"
- " \"shaderEffects\": {\n"
- " \"Ripple2D\": {\n"
- " \"program\": {\n"
- " \"vertexPrefix\": \"\",\n"
- " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
- " \"fragmentPrefix\": \"\",\n"
- " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
- " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n"
- " },\n"
- " \"geometryHints\": \"HINT_NONE\",\n"
- " \"gridDensity\": 0,\n"
- " \"loop\": true,\n"
- " \"uAmplitude\": 0.02,\n"
- " \"uTime\": 0.0\n"
- " }\n"
" }\n"
"}\n"
Builder builder = Builder::New();
builder.LoadFromString( json );
- ShaderEffect effect = builder.GetShaderEffect("Ripple2D");
+ builder.AddActors ( "stage", Stage::GetCurrent().GetRootLayer() );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Actor actor = Stage::GetCurrent().GetRootLayer().FindChildByName("Image1");
// coverage
- DALI_TEST_CHECK( effect );
+ DALI_TEST_CHECK( actor );
END_TEST;
}
END_TEST;
}
-int UtcDaliBuilderShaderEffect2P(void)
-{
- ToolkitTestApplication application;
-
- // JSON with a quit event when the actor is touched
- std::string json(
- "{\n"
- "\"templates\":\n"
- "{\n"
- " \"imageTree\": { \n"
- " \"type\": \"ImageView\",\n"
- " \"size\": [100,100,1],\n"
- " \"parentOrigin\": [0.5, 0.5, 0.5],\n"
- " \"position\": [\n"
- " 0.40461349487305,\n"
- " 0.9150390625,\n"
- " 0.0\n"
- " ],\n"
- " \"signals\": [{\n"
- " \"name\": \"touched\",\n"
- " \"action\": \"quit\"\n"
- " }],\n"
- " \"actors\": [\n"
- " {\n"
- " \"type\":\"ImageView\",\n"
- " \"name\":\"childImage\" \n"
- " }\n"
- " ]\n"
- " }\n"
- "},\n"
- " \"stage\": [\n"
- " {\n"
- " \"type\": \"imageTree\",\n"
- " \"name\": \"Image1\",\n"
- " \"effect\": \"Ripple2D\",\n"
- " \"image\": \"offscreen\""
- " }\n"
- " ],\n"
- " \"shaderEffects\": {\n"
- " \"Ripple2D\": {\n"
- " \"program\": {\n"
- " \"vertexPrefix\": \"\",\n"
- " \"vertex\": \"void main(void)\\n{\\n gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\\n vTexCoord = aTexCoord;\\n}\\n\\n\",\n"
- " \"fragmentPrefix\": \"\",\n"
- " \"fragment\": \"precision mediump float;\\nuniform float uAmplitude; // 0.02; (< 1)\\nuniform float uTime;\\nvoid main()\\n{\\n highp vec2 textureSize = sTextureRect.zw - sTextureRect.xy;\\n highp vec2 pos = -1.0 + 2.0 * vTexCoord.st/textureSize;\\n highp float len = length(pos);\\n highp vec2 texCoord = vTexCoord.st/textureSize + pos/len * sin( len * 12.0 - uTime * 4.0 ) * uAmplitude; \\n gl_FragColor = texture2D(sTexture, texCoord) * uColor;\\n}\\n\\n\\n\",\n"
- " \"geometryType\": \"GEOMETRY_TYPE_IMAGE\"\n"
- " },\n"
- " \"geometryHints\": \"HINT_NONE\",\n"
- " \"gridDensity\": 0,\n"
- " \"loop\": true,\n"
- " \"uAmplitude\": 0.02,\n"
- " \"uTime\": 0.0\n"
- " }\n"
- " },\n"
- " \"frameBufferImages\": {\n"
- " \"offscreen\": {\n"
- " \"type\": \"FrameBufferImage\","
- " \"pixelFormat\":\"RGBA8888\","
- " \"width\": 400,"
- " \"height\": 400"
- " }"
- " }"
- "}\n"
-
- );
-
- Builder builder = Builder::New();
- builder.LoadFromString( json );
-
- // coverage
- DALI_TEST_CHECK( true );
-
- END_TEST;
-}
int UtcDaliBuilderAddActorsP(void)
{
" \"parentOrigin\": [0.5, 0.5, 0.5],\n"
" \"effect\": \"Ripple2D\",\n"
" \"image\": {\n"
- " \"imageUrl\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\"\n"
+ " \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\"\n"
" },\n"
" \"signals\": [\n"
" {\n"
" \"parentOrigin\": [0.5, 0.5, 0.5],\n"
" \"effect\": \"Ripple2D\",\n"
" \"image\": {\n"
- " \"imageUrl\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\"\n"
+ " \"url\": \"{DALI_IMAGE_DIR}gallery-medium-25.jpg\"\n"
" },\n"
" \"signals\": [\n"
" {\n"
GetImpl(*this).CreateRenderTask( name );
}
-ShaderEffect Builder::GetShaderEffect( const std::string &name )
-{
- return GetImpl(*this).GetShaderEffect( name );
-}
-
FrameBufferImage Builder::GetFrameBufferImage( const std::string &name )
{
return GetImpl(*this).GetFrameBufferImage( name );
void CreateRenderTask( const std::string &name );
/**
- * Get or create ShaderEffect from the ShaderEffect instance library.
- * An empty handle is returned otherwise.
- * @pre The Builder has been initialized.
- * @param name The name of a ShaderEffect in the loaded representation
- * @return A handle to a ShaderEffect if found, otherwise empty
- */
- ShaderEffect GetShaderEffect( const std::string &name );
-
- /**
* Get or create FrameBufferImage from the FrameBufferImage instance library.
* An empty handle is returned otherwise.
* @pre The Builder has been initialized.
* ImageView imageView = ImageView::New(image);
* imageView.SetParentOrigin( ParentOrigin::CENTER );
* imageView.SetAnchorPoint( AnchorPoint::CENTER );
- * shadowView.Add(imageActor);\n Add the renderable actor to the shadow view
+ * shadowView.Add(imageView);\n Add the renderable actor to the shadow view
*
* ImageView shadowPlaneBg = ImageView::New(); //This will be the shadow plane
* shadowPlaneBg.SetParentOrigin( ParentOrigin::CENTER );
}
}
- // Add custom properties
- if( OptionalChild customPropertiesChild = IsChild(child, "customProperties") )
- {
- const TreeNode& customPropertiesNode = *customPropertiesChild;
- const TreeConstIter endIter = customPropertiesNode.CEnd();
- for( TreeConstIter iter = customPropertiesNode.CBegin(); endIter != iter; ++iter )
- {
- const TreeNode::KeyNodePair& keyChild = *iter;
- std::string key( keyChild.first );
-
- Property::Value value;
- DeterminePropertyFromNode( keyChild.second, value, constant );
- // Register/Set property.
- actor.RegisterProperty( key, value, Property::READ_WRITE );
- }
- }
-
return actor;
}
// to allow animating shader uniforms
if( propIndex == Property::INVALID_INDEX )
{
- ImageActor imageActor = ImageActor::DownCast( targetHandle );
- if( imageActor )
- {
- // A limitation here is that its possible that between creation of animation
- // and running it the ShaderEffect of the actor has been changed.
- // However this is a unlikely use case especially when using scripts.
- if( ShaderEffect effect = imageActor.GetShaderEffect() )
- {
- propIndex = effect.GetPropertyIndex( *property );
- if(propIndex != Property::INVALID_INDEX)
- {
- targetHandle = effect;
- }
- else
- {
- DALI_SCRIPT_WARNING( "Cannot find property on object or ShaderEffect\n" );
- continue;
- }
- }
- }
- else
- {
- DALI_SCRIPT_WARNING( "Cannot find property on object or ShaderEffect\n" );
+ DALI_SCRIPT_WARNING( "Cannot find property on object\n" );
continue;
- }
}
if( propIndex == Property::INVALID_INDEX)
const std::string KEYNAME_INCLUDES = "includes";
const std::string KEYNAME_MAPPINGS = "mappings";
+const std::string PROPERTIES = "properties";
+const std::string ANIMATABLE_PROPERTIES = "animatableProperties";
+
typedef std::vector<const TreeNode*> TreeNodeList;
continue;
}
- // special field 'image' usually contains an json object description
- // although sometimes refers to a framebuffer
- if( key == "image" )
- {
- if( 0 == keyChild.second.Size() )
- {
- ImageActor imageActor = ImageActor::DownCast(handle);
- if(imageActor)
- {
- if( OptionalString s = constant.IsString( keyChild.second ) )
- {
- FrameBufferImage fb = GetFrameBufferImage(*s, constant);
- if(fb)
- {
- imageActor.SetImage( fb );
- }
- }
- }
- }
- }
-
- // special field 'effect' references the shader effect instances
- if( key == "effect" )
- {
- ImageActor actor = ImageActor::DownCast(handle);
- if( actor )
- {
- OptionalString str = constant.IsString( keyChild.second );
- if( str )
- {
- ShaderEffect effect = GetShaderEffect( *str, constant );
- actor.SetShaderEffect(effect);
- }
- }
- else
- {
- DALI_SCRIPT_WARNING("Could not find or set shader effect\n");
- }
-
- continue;
- }
-
Handle propertyObject( handle );
Dali::Property::Index index = propertyObject.GetPropertyIndex( key );
- if( Property::INVALID_INDEX == index )
- {
- ImageActor actor = ImageActor::DownCast(handle);
- if( actor )
- {
- if( ShaderEffect effect = actor.GetShaderEffect() )
- {
- index = effect.GetPropertyIndex( key );
- if(index != Property::INVALID_INDEX)
- {
- propertyObject = effect;
- }
- }
- }
- }
-
if( Property::INVALID_INDEX != index )
{
Property::Type type = propertyObject.GetPropertyType(index);
DALI_SCRIPT_VERBOSE("SetProperty INVALID '%s' Index=:%d\n", key.c_str(), index);
}
+ // Add custom properties
+ SetCustomProperties(node, handle, constant, PROPERTIES, Property::READ_WRITE);
+ SetCustomProperties(node, handle, constant, ANIMATABLE_PROPERTIES, Property::ANIMATABLE);
+
} // for property nodes
}
else
}
}
+void Builder::SetCustomProperties( const TreeNode& node, Handle& handle, const Replacement& constant,
+ const std::string& childName, Property::AccessMode accessMode )
+{
+ // Add custom properties
+ if( OptionalChild customPropertiesChild = IsChild(node, childName) )
+ {
+ const TreeNode& customPropertiesNode = *customPropertiesChild;
+ const TreeConstIter endIter = customPropertiesNode.CEnd();
+ for( TreeConstIter iter = customPropertiesNode.CBegin(); endIter != iter; ++iter )
+ {
+ const TreeNode::KeyNodePair& keyChild = *iter;
+ std::string key( keyChild.first );
+
+ Property::Value value;
+ DeterminePropertyFromNode( keyChild.second, value, constant );
+ // Register/Set property.
+ handle.RegisterProperty( key, value, accessMode );
+ }
+ }
+}
+
// Set properties from node on handle.
void Builder::ApplyProperties( const TreeNode& root, const TreeNode& node,
Dali::Handle& handle, const Replacement& constant )
}
}
-ShaderEffect Builder::GetShaderEffect( const std::string &name)
-{
- Replacement constant( mReplacementMap );
- return GetShaderEffect( name, constant );
-}
-
-ShaderEffect Builder::GetShaderEffect( const std::string &name, const Replacement& constant )
-{
- DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
-
- ShaderEffect ret;
-
- ShaderEffectLut::const_iterator iter( mShaderEffectLut.find( name ) );
- if( iter != mShaderEffectLut.end() )
- {
- ret = iter->second;
- }
- else
- {
- if( OptionalChild effects = IsChild( *mParser.GetRoot(), "shaderEffects") )
- {
- if( OptionalChild effect = IsChild( *effects, name ) )
- {
- Dali::Property::Value propertyMap(Property::MAP);
- if( DeterminePropertyFromNode( *effect, Property::MAP, propertyMap, constant ) )
- {
- ret = Dali::Scripting::NewShaderEffect( propertyMap );
- mShaderEffectLut[ name ] = ret;
- }
- }
- }
- }
-
- return ret;
-}
-
FrameBufferImage Builder::GetFrameBufferImage( const std::string &name )
{
Replacement constant( mReplacementMap );
void CreateRenderTask( const std::string &name );
/**
- * @copydoc Toolkit::Builder::GetShaderEffect
- */
- ShaderEffect GetShaderEffect( const std::string &name );
-
- /**
- * @copydoc Toolkit::Builder::GetShaderEffect
- */
- ShaderEffect GetShaderEffect( const std::string &name, const Replacement& constant );
-
- /**
* @copydoc Toolkit::Builder::GetFrameBufferImage
*/
FrameBufferImage GetFrameBufferImage( const std::string &name );
void SetupTask( RenderTask& task, const Toolkit::TreeNode& node, const Replacement& replacement );
+ void SetCustomProperties( const TreeNode& node, Handle& handle, const Replacement& constant, const std::string& childName, Property::AccessMode accessMode );
+
private:
Toolkit::JsonParser mParser;
typedef std::map<const std::string, FrameBufferImage> ImageLut;
ImageLut mFrameBufferImageLut;
- typedef std::map<const std::string, ShaderEffect> ShaderEffectLut;
- ShaderEffectLut mShaderEffectLut;
-
typedef std::map<const std::string, Path> PathLut;
PathLut mPathLut;
*
* When the page is turned over in landscape, call
* SetIsBackImageVisible(true), this effect can display the back image
- * correctly after the imageActor been rotated 180 degrees. To
+ * correctly after the page been rotated 180 degrees. To
* display the pages visually consistent with its turning state,
* please set the uniforms with the same values as the PageTurnEffect.
*
*
* | %Property Name | Type |
* |-------------------------|------------------|
- * | imageUrl | STRING |
- * | imageFittingMode | STRING |
- * | imageSamplingMode | STRING |
- * | imageDesiredWidth | INT |
- * | imageDesiredHeight | INT |
+ * | url | STRING |
+ * | fittingMode | STRING |
+ * | samplingMode | STRING |
+ * | desiredWidth | INT |
+ * | desiredHeight | INT |
*
* where imageFittingMode should be one of the following fitting modes:
- * "shrinkToFit"
- * "scaleToFill"
- * "fitWidth"
- * "fitHeight"
- * "default"
+ * "SHRINK_TO_FIT"
+ * "SCALE_TO_FIT"
+ * "FIT_WIDTH"
+ * "FIT_HEIGHT"
+ * "DEFAULT"
*
* where imageSamplingMode should be one of the following sampling modes:
- * "box"
- * "nearest"
- * "linear"
- * "boxThenNearest"
- * "boxThenLinear"
- * "noFilter"
- * "dontCare"
- * "default"
+ * "BOX"
+ * "NEAREST"
+ * "LINEAR"
+ * "BOX_THEN_NEAREST"
+ * "BOX_THEN_LINEAR"
+ * "NO_FILTER"
+ * "DONT_CARE"
+ * "DEFAULT"
*
*/
class ImageRenderer: public ControlRenderer, public ConnectionTracker
/**
* Callback function of transition animation finished
- * Hide transition layer, show current imageActor, and set isAnimating flag to false
+ * Hide transition layer, show current image, and set isAnimating flag to false
* @param[in] source The cube transition animation
*/
void OnTransitionFinished(Animation& source);
* "image": {
* "url": "{DALI_IMAGE_DIR}gallery-small-1.jpg"
* },
- * "customProperties": {
+ * "properties": {
* "cellIndex":[1,1], // property to specify the top-left cell this child occupies, if not set, the first available cell is used
* "rowSpan":3, // property to specify how many rows this child occupies, if not set, default value is 1
* "columnSpan": 2, // property to specify how many columns this child occupies, if nor set, default value is 1
// Set another property to set the image-map
Property::Map imageMap;
imageMap[ "rendererType" ] = "image";
- imageMap[ "imageUrl" ] = IMAGE_CARDS;
- imageMap[ "width" ] = 100;
- imageMap[ "height" ] = 100;
+ imageMap[ "url" ] = IMAGE_CARDS;
+ imageMap[ "desiredWidth" ] = 100;
+ imageMap[ "desiredHeight" ] = 100;
mImageView.SetProperty( ImageView::Property::IMAGE, imageMap );
// Add the image view to the stage
// At this point we own a Dali::Actor named "container"
// Enter a code block
{
- // Create an image actor
- Image img = Image::New(SomeImageFile);
- Actor actor = ImageActor::New(img);
+ // Create an image view
+ Actor actor = Toolkit::ImageView::New(SomeImageFile);
// Add the image actor to a container
container.Add(actor);
// Set an image view property
imageView.image = {
"rendererType" : "image",
- "imageUrl" : "images/icon-0.png",
- "width" : 100,
- "height" : 100
+ "url": "images/icon-0.png",
+ "desiredWidth" : 100,
+ "desiredHeight" : 100
};
// add to the stage
"image":
{
"rendererType" : "image",
- "imageUrl" : "images/icon-0.png",
- "width" : 100,
- "height" : 100
+ "url" : "images/icon-0.png",
+ "desiredWidth" : 100,
+ "desiredHeight" : 100
}
}
]
Add Actors to this ScrollView
@code
- Image image = Image::New(DALI_IMAGE_DIR "button-background.png");
- ImageActor imageActor = ImageActor::New(image);
+ ImageView imageActor = Toolkit::ImageView::New(DALI_IMAGE_DIR "button-background.png");
myScrollView.Add( imageActor );
@endcode
var image = {
"rendererType" : "image",
- "imageUrl" : getImageDirectory()+"gallery-medium-50.jpg",
+ "url" : getImageDirectory()+"gallery-medium-50.jpg",
"shader" : shader
};
var image = {
"rendererType" : "image",
- "imageUrl" : "myImage.jpg",
- "width" : desiredWidth, // The desired image width while loading (optional but preferable to set for efficiency)
- "height" : desiredHeight, // The desired image height while loading (optional but preferable to set for efficiency)
+ "url" : "myImage.jpg",
+ "desiredWidth" : desiredWidth, // The desired image width while loading (optional but preferable to set for efficiency)
+ "desiredHeight" : desiredHeight, // The desired image height while loading (optional but preferable to set for efficiency)
"shader" : shader // Optional
};
"image":
{
"rendererType" : "image",
- "imageUrl": "{icon_path}"
+ "url": "{icon_path}"
},
"position":[20.0, 0.0, 0.0],
"size":[70.0, 70.0, 0.0],