From 9ace90e31c4ed088e439449b5a6eb4cc1f355b25 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Wed, 16 Jan 2019 10:27:59 +0900 Subject: [PATCH] Elm_Animation_View : Add elm_animation_view_frame_set/get apis Summary: elm_animation_view_frame_set is index of frame of animation view. Range of frame value is 0 to elm_animation_view_fame_count - 1. This value calculated with keyframe value. elm_animation_view_frame_get return index of current frame. Test Plan: setenv("ECTOR_BACKEND", "default", 1); setenv("ELM_ACCEL", "gl", 1); elm_init(argc, argv); Eo *win = elm_win_util_standard_add(NULL, "test"); evas_object_smart_callback_add(win, "delete,request", win_del, 0); elm_win_autodel_set(win, 1); //Animation View Evas_Object *anim_view = elm_animation_view_add(win); elm_animation_view_auto_repeat_set(anim_view, 1); elm_animation_view_file_set(anim_view, "a.json", NULL); evas_object_show(anim_view); evas_object_size_hint_align_set(anim_view, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(anim_view, 1, 1); elm_win_resize_object_add(win, anim_view); evas_object_resize(win, WIDTH, HEIGHT); evas_object_show(win); printf("Get frame count : %d\n", elm_animation_view_frame_count_get(anim_view)); printf("Set frame : 35\n"); elm_animation_view_frame_set(anim_view , 35); printf("Get frame : %d\n", elm_animation_view_frame_get(anim_view)); printf("Get keyframe : %f\n", elm_animation_view_keyframe_get(anim_view)); printf("Set frame : 0\n"); elm_animation_view_frame_set(anim_view , 0); printf("Get frame : %d\n", elm_animation_view_frame_get(anim_view)); printf("Get keyframe : %f\n", elm_animation_view_keyframe_get(anim_view)); printf("Set keyframe : 0.5\n"); elm_animation_view_keyframe_set(anim_view , 0.5); printf("Get keyframe : %f\n", elm_animation_view_keyframe_get(anim_view)); printf("Get frame : %d\n", elm_animation_view_frame_get(anim_view)); elm_run(); elm_shutdown(); Reviewers: Hermet Subscribers: YOhoho, cedric, SanghyeonLee, #reviewers, smohanty, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D7624 Change-Id: I9be2cfb1166ba6b27196b0d8ecb95d55960932c5 --- src/lib/elementary/elm_animation_view.c | 12 ++++++++++++ src/lib/elementary/elm_animation_view.eo | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/lib/elementary/elm_animation_view.c b/src/lib/elementary/elm_animation_view.c index 7acddc6..949424f 100644 --- a/src/lib/elementary/elm_animation_view.c +++ b/src/lib/elementary/elm_animation_view.c @@ -512,6 +512,18 @@ _elm_animation_view_keyframe_get(const Eo *obj EINA_UNUSED, Elm_Animation_View_D return pd->keyframe; } +EOLIAN static void +_elm_animation_view_frame_set(Eo *obj EINA_UNUSED, Elm_Animation_View_Data *pd, int frame) +{ + elm_animation_view_keyframe_set(obj, (double) frame / (double) (evas_object_vg_animated_frame_count_get(pd->vg) - 1)); +} + +EOLIAN static int +_elm_animation_view_frame_get(const Eo *obj EINA_UNUSED, Elm_Animation_View_Data *pd) +{ + return (int) ((double) (evas_object_vg_animated_frame_count_get(pd->vg) - 1) * pd->keyframe); +} + EOLIAN static double _elm_animation_view_speed_get(const Eo *obj EINA_UNUSED, Elm_Animation_View_Data *pd) { diff --git a/src/lib/elementary/elm_animation_view.eo b/src/lib/elementary/elm_animation_view.eo index 8c07fcd..30f2de5 100644 --- a/src/lib/elementary/elm_animation_view.eo +++ b/src/lib/elementary/elm_animation_view.eo @@ -95,6 +95,20 @@ class Elm.Animation_View (Efl.Ui.Widget, Efl.Gfx.View, Efl.Ui.Legacy, Efl.File) keyframe: double; [[Keyframe position. Value must be 0 ~ 1.]] } } + @property frame { + //FIXME : frame_count need add '@' symbol after add eo method frame_count. + [[Index of the current frame of an animated animation view. + + Ranges from 0 to frame_count - 1. + ]] + set { + [[Set the frame to current frame of an animation view object.]] + } + get {} + values { + frame: int; [[The index of current frame.]] + } + } play { [[Play animation one time instantly when it's available. -- 2.7.4