Commit 6c6724c3eef63a78918b2dd1c46e090934959438

Authored by Heeyong Song
1 parent ba6f3934

(Vector) Use dynamic property

Change-Id: I9bb4e4d44b2e9ad87214d054df82ddf047bd1c77
examples/animated-vector-images/animated-vector-images-example.cpp
1 1 /*
2   - * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  2 + * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3 3 *
4 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 5 * you may not use this file except in compliance with the License.
... ... @@ -22,6 +22,7 @@
22 22 #include <dali-toolkit/devel-api/visuals/animated-vector-image-visual-signals-devel.h>
23 23 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
24 24 #include <dali/dali.h>
  25 +#include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
25 26 #include <string>
26 27 #include "shared/view.h"
27 28  
... ... @@ -35,8 +36,8 @@ const char* TOOLBAR_IMAGE(DEMO_IMAGE_DIR &quot;top-bar.png&quot;);
35 36 const char* APPLICATION_TITLE("Animated Vector Images");
36 37  
37 38 const char* IMAGE_PATH[] = {
  39 + DEMO_IMAGE_DIR "done.json",
38 40 DEMO_IMAGE_DIR "insta_camera.json",
39   - DEMO_IMAGE_DIR "you're_in!.json",
40 41 DEMO_IMAGE_DIR "jolly_walker.json"};
41 42  
42 43 const unsigned int NUMBER_OF_IMAGES = 3;
... ... @@ -140,10 +141,80 @@ public:
140 141 mTable.AddChild(mImageViews[x], TableView::CellPosition(CellPlacement::IMAGE, x));
141 142 }
142 143  
  144 + DevelAnimatedVectorImageVisual::DynamicPropertyInfo info;
  145 + info.id = 1;
  146 + info.keyPath = "Shape Layer 1.Ellipse 1.Fill 1";
  147 + info.property = static_cast<int>(VectorAnimationRenderer::VectorProperty::FILL_COLOR);
  148 + info.callback = MakeCallback(this, &AnimatedVectorImageViewController::FillColorCallback);
  149 +
  150 + DevelControl::DoActionExtension(mImageViews[0], ImageView::Property::IMAGE, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info));
  151 +
  152 + info.id = 2;
  153 + info.keyPath = "**";
  154 + info.property = static_cast<int>(VectorAnimationRenderer::VectorProperty::STROKE_COLOR);
  155 + info.callback = MakeCallback(this, &AnimatedVectorImageViewController::StrokeColorCallback);
  156 +
  157 + DevelControl::DoActionExtension(mImageViews[0], ImageView::Property::IMAGE, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info));
  158 +
  159 + info.id = 3;
  160 + info.keyPath = "**";
  161 + info.property = static_cast<int>(VectorAnimationRenderer::VectorProperty::STROKE_WIDTH);
  162 + info.callback = MakeCallback(this, &AnimatedVectorImageViewController::StrokeWidthCallback);
  163 +
  164 + DevelControl::DoActionExtension(mImageViews[0], ImageView::Property::IMAGE, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info));
  165 +
  166 + info.id = 4;
  167 + info.keyPath = "Shape Layer 2.Shape 1";
  168 + info.property = static_cast<int>(VectorAnimationRenderer::VectorProperty::TRANSFORM_ROTATION);
  169 + info.callback = MakeCallback(this, &AnimatedVectorImageViewController::TransformRotationCallback);
  170 +
  171 + DevelControl::DoActionExtension(mImageViews[0], ImageView::Property::IMAGE, DevelAnimatedVectorImageVisual::Action::SET_DYNAMIC_PROPERTY, Any(info));
  172 +
143 173 application.GetWindow().KeyEventSignal().Connect(this, &AnimatedVectorImageViewController::OnKeyEvent);
144 174 }
145 175  
146 176 private:
  177 + Property::Value FillColorCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber)
  178 + {
  179 + if(frameNumber < 60)
  180 + {
  181 + return Vector3(0, 0, 1);
  182 + }
  183 + else
  184 + {
  185 + return Vector3(1, 0, 0);
  186 + }
  187 + }
  188 +
  189 + Property::Value StrokeColorCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber)
  190 + {
  191 + if(frameNumber < 60)
  192 + {
  193 + return Vector3(1, 0, 1);
  194 + }
  195 + else
  196 + {
  197 + return Vector3(1, 1, 0);
  198 + }
  199 + }
  200 +
  201 + Property::Value StrokeWidthCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber)
  202 + {
  203 + if(frameNumber < 60)
  204 + {
  205 + return 2.0f;
  206 + }
  207 + else
  208 + {
  209 + return 5.0f;
  210 + }
  211 + }
  212 +
  213 + Property::Value TransformRotationCallback(int32_t id, VectorAnimationRenderer::VectorProperty property, uint32_t frameNumber)
  214 + {
  215 + return frameNumber * 20.0f;
  216 + }
  217 +
147 218 bool OnPlayButtonClicked(Button button)
148 219 {
149 220 unsigned int controlIndex = GetControlIndex(button);
... ...
resources/images/done.json 0 → 100644
  1 +{"v":"4.11.1","fr":29.9700012207031,"ip":0,"op":76.0000030955435,"w":70,"h":70,"nm":"Comp 1","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[35,35,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_1_0p333_0"],"t":33,"s":[0,0,100],"e":[120,120,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_1_0p333_0"],"t":46,"s":[120,120,100],"e":[100,100,100]},{"t":52.0000021180034}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[-7,1.438],[-2.656,5.781],[7.422,-4.297]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":3,"ix":5},"lc":2,"lj":2,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":0,"k":0,"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"n":["0p667_1_0p333_0"],"t":33,"s":[0],"e":[100]},{"t":52.0000021180034}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":450.000018328876,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[35,35,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_1_0p333_0"],"t":18,"s":[0,0,100],"e":[120,120,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_1_0p333_0"],"t":33,"s":[120,120,100],"e":[80,80,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_1_0p333_0"],"t":41,"s":[80,80,100],"e":[110,110,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"n":["0p667_1_0p333_0","0p667_1_0p333_0","0p667_1_0p333_0"],"t":49,"s":[110,110,100],"e":[100,100,100]},{"t":52.0000021180034}],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[13.015,0],[0,-13.015],[-13.015,0],[0,13.015]],"o":[[-13.015,0],[0,13.015],[13.015,0],[0,-13.015]],"v":[[0,-23.566],[-23.566,0],[0,23.566],[23.566,0]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.898039215686,0.898039215686,0.898039215686,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":0,"ix":5},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.760784313725,0.2,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[105.535,105.535],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":450.000018328876,"st":0,"bm":0}]}
0 2 \ No newline at end of file
... ...