mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
improve gif image
This commit is contained in:
parent
3ec3bbabbd
commit
08de739b76
@ -1,5 +1,12 @@
|
||||
# 最新动态
|
||||
|
||||
2023/03/10
|
||||
* 完善gif image(感谢雨欣提供补丁)
|
||||
* 修复 loop 属性的表现,作为控件循环播放的次数;
|
||||
* loop 归零,播放完毕后,需要停留在 gif 图的最后一帧,而不是先跳到第0帧,再刷新的最后一帧;
|
||||
* loop 归零,播放完毕后,调用 gif_image_set_loop 接口设置循环次数后,需要从第一帧开始播放,而不是最后一帧。
|
||||
|
||||
|
||||
2023/03/09
|
||||
* 完善api\_doc\_lint工具(感谢俊圣提供补丁)
|
||||
* 新增scons dblite版本检查,编译时python版本与当前python版本不一致则删除dblite(感谢高源提供补丁)
|
||||
|
@ -91,7 +91,7 @@ static ret_t gif_image_on_paint_self(widget_t* widget, canvas_t* c) {
|
||||
|
||||
if (frames_nr > 0) {
|
||||
image->index %= frames_nr;
|
||||
if (image->loop > 0) {
|
||||
if (image->loop > 0 && image->index == frames_nr - 1 && !image->loop_done) {
|
||||
image->loop--;
|
||||
}
|
||||
} else {
|
||||
@ -104,13 +104,14 @@ static ret_t gif_image_on_paint_self(widget_t* widget, canvas_t* c) {
|
||||
} else {
|
||||
image->index = 0;
|
||||
}
|
||||
image->loop_done = TRUE;
|
||||
}
|
||||
#ifdef AWTK_WEB
|
||||
if (image->timer_id == TK_INVALID_ID) {
|
||||
image->timer_id = timer_add(gif_image_on_timer, image, 16);
|
||||
}
|
||||
#else
|
||||
if (frames_nr > 1) {
|
||||
if (image->loop > 0 && frames_nr > 1) {
|
||||
uint32_t delay = bitmap.gif_delays[image->index];
|
||||
if (image->timer_id == TK_INVALID_ID) {
|
||||
image->index = 0;
|
||||
@ -122,7 +123,6 @@ static ret_t gif_image_on_paint_self(widget_t* widget, canvas_t* c) {
|
||||
if (timer) timer->duration = image->delay;
|
||||
}
|
||||
} else if (image->timer_id != TK_INVALID_ID) {
|
||||
image->index = 0;
|
||||
timer_remove(image->timer_id);
|
||||
image->timer_id = TK_INVALID_ID;
|
||||
}
|
||||
@ -201,6 +201,11 @@ ret_t gif_image_set_loop(widget_t* widget, uint32_t loop) {
|
||||
gif_image_t* gif_image = GIF_IMAGE(widget);
|
||||
return_value_if_fail(gif_image != NULL, RET_BAD_PARAMS);
|
||||
|
||||
if (gif_image->loop_done) {
|
||||
gif_image->index = 0;
|
||||
gif_image->loop_done = FALSE;
|
||||
}
|
||||
|
||||
gif_image->loop = loop;
|
||||
|
||||
return RET_OK;
|
||||
@ -258,6 +263,7 @@ widget_t* gif_image_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
image_base_init(widget);
|
||||
gif_image_play(widget);
|
||||
gif_image->loop = 0xffffffff;
|
||||
gif_image->loop_done = FALSE;
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
@ -99,6 +99,7 @@ typedef struct _gif_image_t {
|
||||
uint32_t index;
|
||||
uint32_t delay;
|
||||
uint32_t timer_id;
|
||||
uint32_t loop_done;
|
||||
} gif_image_t;
|
||||
|
||||
/**
|
||||
@ -127,7 +128,7 @@ ret_t gif_image_play(widget_t* widget);
|
||||
|
||||
/**
|
||||
* @method gif_image_stop
|
||||
* 停止(并重置index为-1)。
|
||||
* 停止(并重置index为0)。
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget gif_image对象。
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user