mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
add widget_animate_value_to
This commit is contained in:
parent
9c85038e16
commit
f5442abea5
@ -339,9 +339,8 @@ static ret_t on_mem_test(void* ctx, event_t* e) {
|
||||
static ret_t on_inc(void* ctx, event_t* e) {
|
||||
widget_t* win = WIDGET(ctx);
|
||||
widget_t* progress_bar = widget_lookup(win, "bar1", TRUE);
|
||||
uint8_t value = (PROGRESS_BAR(progress_bar)->value + 10) % 100;
|
||||
progress_bar_set_value(progress_bar, value);
|
||||
|
||||
int32_t value = (PROGRESS_BAR(progress_bar)->value + 20);
|
||||
widget_animate_value_to(progress_bar, tk_min(100, value), 500);
|
||||
(void)e;
|
||||
return RET_OK;
|
||||
}
|
||||
@ -349,8 +348,8 @@ static ret_t on_inc(void* ctx, event_t* e) {
|
||||
static ret_t on_dec(void* ctx, event_t* e) {
|
||||
widget_t* win = WIDGET(ctx);
|
||||
widget_t* progress_bar = widget_lookup(win, "bar1", TRUE);
|
||||
uint8_t value = (PROGRESS_BAR(progress_bar)->value + 90) % 100;
|
||||
progress_bar_set_value(progress_bar, value);
|
||||
int32_t value = PROGRESS_BAR(progress_bar)->value - 20;
|
||||
widget_animate_value_to(progress_bar, tk_max(0, value), 500);
|
||||
|
||||
(void)e;
|
||||
return RET_OK;
|
||||
|
@ -2,6 +2,7 @@
|
||||
* 2018/12/26
|
||||
* 为了语义的一致性,把widget的虚函数destroy改名为on\_destroy。on\_destroy只是通知子类控件即将销毁。
|
||||
* 重命名NAME\_LEN为TK\_NAME\_LEN。
|
||||
* 增加函数:widget\_animate\_value\_to
|
||||
|
||||
* 2018/12/25
|
||||
* 整理控件API文档:row/column/grid/grid\_item/view/group\_box/app\_bar/system\_bar
|
||||
|
@ -113,6 +113,18 @@ ret_t widget_add_value(widget_t* widget, int32_t delta) {
|
||||
return widget_set_value(widget, widget_get_value(widget) + delta);
|
||||
}
|
||||
|
||||
ret_t widget_animate_value_to(widget_t* widget, int32_t value, uint32_t duration) {
|
||||
if (duration == 0) {
|
||||
return widget_set_value(widget, value);
|
||||
} else {
|
||||
char params[64];
|
||||
tk_snprintf(params, sizeof(params) - 1, "value(to=%d, duration=%d)", value, duration);
|
||||
|
||||
widget_destroy_animator(widget, "value");
|
||||
return widget_create_animator(widget, params);
|
||||
}
|
||||
}
|
||||
|
||||
bool_t widget_is_window_opened(widget_t* widget) {
|
||||
int32_t stage =
|
||||
widget_get_prop_int(widget_get_window(widget), WIDGET_PROP_STAGE, WINDOW_STAGE_NONE);
|
||||
|
@ -543,6 +543,19 @@ ret_t widget_move_resize(widget_t* widget, xy_t x, xy_t y, wh_t w, wh_t h);
|
||||
*/
|
||||
ret_t widget_set_value(widget_t* widget, int32_t value);
|
||||
|
||||
/**
|
||||
* @method widget_animate_value_to
|
||||
* 设置控件的值(以动画形式变化到指定的值)。
|
||||
* 只是对widget\_set\_prop的包装,值的意义由子类控件决定。
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget 控件对象。
|
||||
* @param {int32_t} value 值。
|
||||
* @param {uint32_t} duration 动画持续时间(毫秒)。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t widget_animate_value_to(widget_t* widget, int32_t value, uint32_t duration);
|
||||
|
||||
/**
|
||||
* @method widget_add_value
|
||||
* 增加控件的值。
|
||||
|
Loading…
Reference in New Issue
Block a user