diff --git a/src/examples/evas/evas-vg-simple.c b/src/examples/evas/evas-vg-simple.c index 854bde843e..7332ce703c 100644 --- a/src/examples/evas/evas-vg-simple.c +++ b/src/examples/evas/evas-vg-simple.c @@ -50,6 +50,12 @@ typedef struct _Point int y; }Point; +static Efl_VG *beginning = NULL; +static Efl_VG *end = NULL; +static Efl_VG *root = NULL; +static double start_time = 0; +static Ecore_Animator *anim = NULL; + static Bezier bezierFromPoints(Point p1, Point p2, Point p3, Point p4) @@ -440,18 +446,22 @@ vector_set(int x, int y, int w, int h) eina_matrix3_identity(&matrix); eina_matrix3_rotate(&matrix, radian); - Efl_VG *root = evas_object_vg_root_node_get(d.vg); + root = evas_object_vg_root_node_get(d.vg); //eo_do(root, evas_vg_node_transformation_set(&matrix)); - Efl_VG *bg = eo_add(EFL_VG_SHAPE_CLASS, root); + Efl_VG *bg = eo_add(EFL_VG_SHAPE_CLASS, root, + efl_vg_name_set("bg")); _rect_add(bg, 0, 0 , vg_w, vg_h); evas_vg_node_origin_set(bg, 0,0); evas_vg_shape_stroke_width_set(bg, 1.0); evas_vg_node_color_set(bg, 80, 80, 80, 80); - Efl_VG *shape = eo_add(EFL_VG_SHAPE_CLASS, root); - Efl_VG *rgradient = eo_add(EFL_VG_GRADIENT_RADIAL_CLASS, root); - Efl_VG *lgradient = eo_add(EFL_VG_GRADIENT_LINEAR_CLASS, root); + Efl_VG *shape = eo_add(EFL_VG_SHAPE_CLASS, root, + efl_vg_name_set("shape")); + Efl_VG *rgradient = eo_add(EFL_VG_GRADIENT_RADIAL_CLASS, root, + efl_vg_name_set("rgradient")); + Efl_VG *lgradient = eo_add(EFL_VG_GRADIENT_LINEAR_CLASS, root, + efl_vg_name_set("lgradient")); _arcto(shape, 0, 0, 100, 100, 25, 330); @@ -492,7 +502,8 @@ vector_set(int x, int y, int w, int h) evas_vg_node_color_set(shape, 0, 0, 255, 255); evas_vg_shape_stroke_color_set(shape, 0, 0, 255, 128); - Efl_VG *rect = eo_add(EFL_VG_SHAPE_CLASS, root); + Efl_VG *rect = eo_add(EFL_VG_SHAPE_CLASS, root, + efl_vg_name_set("rect")); _rect_add(rect, 0, 0, 100, 100); evas_vg_node_origin_set(rect, 100, 100); evas_vg_shape_fill_set(rect, lgradient); @@ -500,7 +511,8 @@ vector_set(int x, int y, int w, int h) evas_vg_shape_stroke_join_set(rect, EFL_GFX_JOIN_ROUND); evas_vg_shape_stroke_color_set(rect, 255, 255, 255, 255); - Efl_VG *rect1 = eo_add(EFL_VG_SHAPE_CLASS, root); + Efl_VG *rect1 = eo_add(EFL_VG_SHAPE_CLASS, root, + efl_vg_name_set("rect1")); _rect_add(rect1, 0, 0, 70, 70); evas_vg_node_origin_set(rect1, 50, 70); evas_vg_shape_stroke_scale_set(rect1, 2); @@ -508,7 +520,8 @@ vector_set(int x, int y, int w, int h) evas_vg_shape_stroke_join_set(rect1, EFL_GFX_JOIN_ROUND); evas_vg_shape_stroke_color_set(rect1, 0, 100, 80, 100); - Efl_VG *circle = eo_add(EFL_VG_SHAPE_CLASS, root); + Efl_VG *circle = eo_add(EFL_VG_SHAPE_CLASS, root, + efl_vg_name_set("circle")); _arcto(circle, 0, 0, 250, 100, 30, 300); evas_vg_shape_fill_set(circle, lgradient); //evas_vg_node_transformation_set(&matrix), @@ -516,24 +529,80 @@ vector_set(int x, int y, int w, int h) evas_vg_node_color_set(circle, 50, 0, 0, 50); // Foreground - Efl_VG *fg = eo_add(EFL_VG_SHAPE_CLASS, root); + Efl_VG *fg = eo_add(EFL_VG_SHAPE_CLASS, root, + efl_vg_name_set("fg")); _rect_add(fg, 0, 0, vg_w, vg_h); evas_vg_node_origin_set(fg, 0, 0); evas_vg_shape_stroke_width_set(fg, 5.0); evas_vg_shape_stroke_join_set(fg, EFL_GFX_JOIN_ROUND); evas_vg_shape_stroke_color_set(fg, 70, 70, 0, 70); - Efl_VG *tst = eo_add(EFL_VG_SHAPE_CLASS, root); + Efl_VG *tst = eo_add(EFL_VG_SHAPE_CLASS, root, + efl_vg_name_set("tst")); evas_vg_shape_shape_append_rect(tst, 50, 25, 200, 200, 3, 5); evas_vg_node_color_set(tst, 0, 0, 200, 200); evas_vg_shape_stroke_width_set(tst, 2); evas_vg_shape_stroke_color_set(tst, 255, 0, 0, 255); - Efl_VG *vc = eo_add(EFL_VG_SHAPE_CLASS, root); + Efl_VG *vc = eo_add(EFL_VG_SHAPE_CLASS, root, + efl_vg_name_set("vc")); evas_vg_shape_shape_append_circle(vc, 100, 100, 23); evas_vg_node_color_set(vc, 0, 200, 0, 255); evas_vg_shape_stroke_width_set(vc, 4); evas_vg_shape_stroke_color_set(vc, 255, 0, 0, 255); + + beginning = eo_add(EFL_VG_CONTAINER_CLASS, NULL, + efl_vg_dup(root)); + end = eo_add(EFL_VG_CONTAINER_CLASS, NULL, + efl_vg_dup(root)); + + eo_do(end, circle = efl_vg_container_child_get("circle")); + eo_do(circle, efl_vg_transformation_set(&matrix)); +} + +static Eina_Bool +_anim(void *data EINA_UNUSED) +{ + double pos, now; + + now = ecore_loop_time_get(); + + if (now - start_time > 3) + { + Efl_VG *tmp = beginning; + + beginning = end; + end = tmp; + start_time = now; + } + + pos = ecore_animator_pos_map((now - start_time) / 3, ECORE_POS_MAP_SINUSOIDAL, 0, 0); + + eo_do(root, efl_vg_interpolate(beginning, end, pos)); + + return EINA_TRUE; +} + +static void +_keydown(void *data EINA_UNUSED, Evas *evas EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *einfo) +{ + Evas_Event_Key_Down *ev = einfo; + + if (strcmp(ev->key, "a") == 0) + { + if (!anim) + { + anim = ecore_animator_add(_anim, NULL); + start_time = ecore_loop_time_get(); + } + else + { + ecore_animator_del(anim); + anim = NULL; + } + /* eo_do(root, efl_vg_interpolate(beginning, end, 0.5)); */ + } + fprintf(stderr, "key: [%s]\n", ev->key); } int @@ -556,6 +625,8 @@ main(void) d.bg = evas_object_rectangle_add(d.evas); evas_object_color_set(d.bg, 70, 70, 70, 255); /* white bg */ + evas_object_focus_set(d.bg, 1); + evas_object_event_callback_add(d.bg, EVAS_CALLBACK_KEY_DOWN, _keydown, NULL); evas_object_show(d.bg); _canvas_resize_cb(d.ee);