Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example: lottieviewer - fixed frame no #528

Merged
merged 1 commit into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion example/lottieview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ void LottieView::seek(float pos)
{
if (!mRenderDelegate) return;


mPos = mapProgress(pos);

// check if the pos maps to the current frame
Expand Down
23 changes: 11 additions & 12 deletions example/lottieviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ _layout_del_cb(void *data, Evas *, Evas_Object *, void *)
}

static void
_update_frame_info(AppInfo *info, double pos)
_update_frame_info(AppInfo *info)
{
int frameNo = pos * info->view->getTotalFrame();
char buf[64];
long currFrameNo = info->view->mCurFrame;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about curFrameNo ?

long totalFrameNo = info->view->getTotalFrame();

sprintf(buf, "%d / %ld", frameNo, info->view->getTotalFrame());
char buf[64];
sprintf(buf, "%ld (total: %ld)", currFrameNo, totalFrameNo);
elm_object_part_text_set(info->layout, "text", buf);
}

Expand Down Expand Up @@ -96,7 +97,7 @@ _animator_cb(void *data)
if (info && info->autoPlaying && info->view)
{
float pos = info->view->getPos();
_update_frame_info(info, pos);
_update_frame_info(info);
elm_slider_value_set(info->slider, (double)pos);
evas_object_image_pixels_dirty_set(info->view->getImage(), EINA_TRUE);
if (pos >= 1.0)
Expand All @@ -111,20 +112,20 @@ _slider_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
double val = elm_slider_value_get(obj);
AppInfo *info = (AppInfo *)data;

_update_frame_info(info, val);

if (!info->autoPlaying)
{
info->view->seek(val);
evas_object_image_pixels_dirty_set(info->view->getImage(), EINA_TRUE);
}

_update_frame_info(info);
}

static void
_button_clicked_cb(void *data, Evas_Object */*obj*/, void */*event_info*/)
{
AppInfo *info = (AppInfo *)data;

if (info->view->getPos() >= 1.0f) info->view->mPos = 0.0f;
_toggle_start_button(info);
}

Expand All @@ -133,7 +134,6 @@ create_layout(Evas_Object *parent, const char *file)
{
Evas_Object *layout, *slider, *image, *button;
Ecore_Animator *animator;
char buf[64];
AppInfo *info = (AppInfo *)calloc(sizeof(AppInfo), 1);

//LAYOUT
Expand Down Expand Up @@ -176,10 +176,9 @@ create_layout(Evas_Object *parent, const char *file)
info->animator = animator;
evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL, _layout_del_cb, (void *)info);

sprintf(buf, "%d / %ld", 0, view->getTotalFrame());
elm_object_part_text_set(layout, "text", buf);

view->seek(0.0);
_update_frame_info(info);

return layout;
}

Expand Down