mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
format code
This commit is contained in:
parent
1b86172f41
commit
78ad8162ab
6
demos/demo_ui_app.c
Executable file → Normal file
6
demos/demo_ui_app.c
Executable file → Normal file
@ -36,7 +36,7 @@
|
||||
#ifdef TK_MEM_SPEED_TEST
|
||||
extern uint32_t g_memcpy_speed;
|
||||
extern uint32_t g_memset_speed;
|
||||
#endif/*TK_MEM_SPEED_TEST*/
|
||||
#endif /*TK_MEM_SPEED_TEST*/
|
||||
|
||||
static ret_t on_show_dialog(void* ctx, event_t* e) {
|
||||
uint32_t code = 0;
|
||||
@ -96,10 +96,10 @@ static ret_t on_mem_test(void* ctx, event_t* e) {
|
||||
|
||||
tk_snprintf(text, sizeof(text), "set:%uk/s", memset_speed);
|
||||
widget_set_text_utf8(left, text);
|
||||
|
||||
|
||||
tk_snprintf(text, sizeof(text), "%ums", cost);
|
||||
widget_set_text_utf8(center, text);
|
||||
|
||||
|
||||
tk_snprintf(text, sizeof(text), "cpy:%uk/s", memcpy_speed);
|
||||
widget_set_text_utf8(right, text);
|
||||
|
||||
|
@ -116,4 +116,4 @@ const unsigned char image_info[] = {
|
||||
0x12,0x96,0xdb,0xb4,0x11,0x96,0xdb,0xe9,0x12,0x96,0xdb,0xff,0x12,0x96,0xdb,0xff,0x11,0x96,0xdb,0xe9,
|
||||
0x12,0x96,0xdb,0xb4,0x11,0x96,0xdb,0x78,0x0d,0x91,0xdb,0x0c,0x00,0x00,0x00,0x00,0x10,0x97,0xdf,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*2348*/
|
||||
0x00,0x00,0x00,0x00,0x30,0x21,0xd0,0xe8,};/*2348*/
|
||||
|
@ -116,4 +116,4 @@ const unsigned char image_left_off[] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*2348*/
|
||||
0x00,0x00,0x00,0x00,0x50,0x36,0xea,0x7a,};/*2348*/
|
||||
|
@ -116,4 +116,4 @@ const unsigned char image_muted[] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*2348*/
|
||||
0x00,0x00,0x00,0x00,0x88,0x2a,0xe9,0x7a,};/*2348*/
|
||||
|
@ -116,4 +116,4 @@ const unsigned char image_radio_unchecked[] = {
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x30,0x21,0x60,0x32,};/*2348*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*2348*/
|
||||
|
@ -116,4 +116,4 @@ const unsigned char image_unmuted[] = {
|
||||
0x00,0x00,0x00,0x16,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x14,
|
||||
0x00,0x00,0x00,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x88,0x2a,0xe9,0x7a,};/*2348*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*2348*/
|
||||
|
@ -11,5 +11,5 @@ const unsigned char ui_bottom[] = {
|
||||
0x1e,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6f,0x6b,0x00,0x74,0x65,0x78,0x74,0x00,0xe7,0xa1,0xae,
|
||||
0xe5,0xae,0x9a,0x00,0x00,0x00,0x01,0x00,0x0a,0x00,0x03,0x03,0x01,0x00,0x0a,0x00,0x00,0x00,0x0a,0x00,
|
||||
0x00,0x00,0x28,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x63,0x61,0x6e,0x63,0x65,
|
||||
0x6c,0x00,0x74,0x65,0x78,0x74,0x00,0xe5,0x8f,0x96,0xe6,0xb6,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,};/*261*/
|
||||
0x6c,0x00,0x74,0x65,0x78,0x74,0x00,0xe5,0x8f,0x96,0xe6,0xb6,0x88,0x00,0x00,0x00,0x00,0xbc,0xc3,0x02,
|
||||
0x01,};/*261*/
|
||||
|
@ -9,12 +9,12 @@ const unsigned char ui_window[] = {
|
||||
0x74,0x65,0x73,0x74,0x00,0x74,0x65,0x78,0x74,0x00,0x4d,0x65,0x6d,0x54,0x65,0x73,0x74,0x00,0x00,0x00,
|
||||
0x01,0x00,0x0a,0x00,0x03,0x00,0x01,0x00,0x0a,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x19,0x00,0x00,0x00,
|
||||
0x1e,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x64,0x65,0x63,0x00,0x74,0x65,0x78,0x74,0x00,0x44,0x65,
|
||||
0x63,0x00,0x00,0x00,0x01,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x28,0x00,0x00,0x00,
|
||||
0x50,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6c,0x65,0x66,0x74,0x00,0x74,0x65,
|
||||
0x78,0x74,0x00,0x4c,0x65,0x66,0x74,0x00,0x00,0x00,0x01,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x64,0x00,
|
||||
0x00,0x00,0x28,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x63,
|
||||
0x63,0x00,0x00,0x00,0x01,0x00,0x09,0x00,0x00,0x00,0x01,0x00,0x0a,0x00,0x00,0x00,0x28,0x00,0x00,0x00,
|
||||
0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6c,0x65,0x66,0x74,0x00,0x74,0x65,
|
||||
0x78,0x74,0x00,0x4c,0x65,0x66,0x74,0x00,0x00,0x00,0x01,0x00,0x09,0x00,0x02,0x00,0x01,0x00,0x00,0x00,
|
||||
0x00,0x00,0x28,0x00,0x00,0x00,0x19,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x63,
|
||||
0x65,0x6e,0x74,0x65,0x72,0x00,0x74,0x65,0x78,0x74,0x00,0x43,0x65,0x6e,0x74,0x65,0x72,0x00,0x00,0x00,
|
||||
0x01,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0xc8,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x50,0x00,0x00,0x00,
|
||||
0x01,0x00,0x09,0x00,0x03,0x00,0x01,0x00,0x0a,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,
|
||||
0x1e,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x72,0x69,0x67,0x68,0x74,0x00,0x74,0x65,0x78,0x74,0x00,
|
||||
0x52,0x69,0x67,0x68,0x74,0x00,0x00,0x00,0x01,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,
|
||||
0x46,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x62,0x61,0x72,
|
||||
|
@ -10,4 +10,4 @@ const unsigned char ui_window2[] = {
|
||||
0x6d,0x65,0x00,0x74,0x6f,0x70,0x00,0x74,0x65,0x78,0x74,0x00,0x54,0x6f,0x70,0x00,0x00,0x00,0x01,0x00,
|
||||
0x0a,0x00,0x03,0x02,0x01,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x00,0x00,0x00,0x1e,0x00,
|
||||
0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x63,0x6c,0x6f,0x73,0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x43,0x6c,
|
||||
0x6f,0x73,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*231*/
|
||||
0x6f,0x73,0x65,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,};/*231*/
|
||||
|
Binary file not shown.
@ -2,9 +2,10 @@
|
||||
<button name="inc" x="10" y="5" w="25%" h="30" text="Inc"/>
|
||||
<button name="test" x="center" y="5" w="25%" h="30" text="MemTest"/>
|
||||
<button name="dec" x="right:10" y="5" w="25%" h="30" text="Dec"/>
|
||||
<label name="left" x="10" y="40" w="80" h="30" text="Left"/>
|
||||
<label name="center" x="100" y="40" w="80" h="30" text="Center"/>
|
||||
<label name="right" x="200" y="40" w="80" h="30" text="Right"/>
|
||||
|
||||
<label name="left" x="10" y="40" w="30%" h="30" text="Left"/>
|
||||
<label name="center" x="center" y="40" w="25%" h="30" text="Center"/>
|
||||
<label name="right" x="right:10" y="40" w="30%" h="30" text="Right"/>
|
||||
|
||||
<progress_bar name="bar1" x="10" y="70" w="240" h="30" value="40"/>
|
||||
<progress_bar name="bar2" x="280" y="70" w="30" h="118" value="20" vertical="true"/>
|
||||
|
@ -320,7 +320,8 @@ mem_stat_t tk_mem_stat() {
|
||||
}
|
||||
#endif /*HAS_STD_MALLOC*/
|
||||
|
||||
uint32_t tk_mem_speed_test(void* buffer, uint32_t length, uint32_t* pmemcpy_speed, uint32_t* pmemset_speed) {
|
||||
uint32_t tk_mem_speed_test(void* buffer, uint32_t length, uint32_t* pmemcpy_speed,
|
||||
uint32_t* pmemset_speed) {
|
||||
uint32_t i = 0;
|
||||
uint32_t cost = 0;
|
||||
uint32_t total_cost = 0;
|
||||
@ -336,7 +337,7 @@ uint32_t tk_mem_speed_test(void* buffer, uint32_t length, uint32_t* pmemcpy_spee
|
||||
cost = time_now_ms() - start;
|
||||
total_cost = cost;
|
||||
if (cost) {
|
||||
memset_speed = ((max_size * 1000)/cost)/1024;
|
||||
memset_speed = ((max_size / cost) * 1000) / 1024;
|
||||
}
|
||||
|
||||
start = time_now_ms();
|
||||
@ -349,17 +350,16 @@ uint32_t tk_mem_speed_test(void* buffer, uint32_t length, uint32_t* pmemcpy_spee
|
||||
total_cost += cost;
|
||||
|
||||
if (cost) {
|
||||
memcpy_speed = ((max_size * 1000)/cost)/1024;
|
||||
memcpy_speed = ((max_size / cost) * 1000) / 1024;
|
||||
}
|
||||
|
||||
if(pmemset_speed != NULL) {
|
||||
if (pmemset_speed != NULL) {
|
||||
*pmemset_speed = memset_speed;
|
||||
}
|
||||
|
||||
if(pmemcpy_speed != NULL) {
|
||||
*pmemcpy_speed = memcpy_speed;
|
||||
if (pmemcpy_speed != NULL) {
|
||||
*pmemcpy_speed = memcpy_speed;
|
||||
}
|
||||
|
||||
return total_cost;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,8 @@ void* tk_alloc(uint32_t size);
|
||||
#define TKMEM_FREE(p) tk_free(p)
|
||||
#endif
|
||||
|
||||
uint32_t tk_mem_speed_test(void* buffer, uint32_t length, uint32_t* pmemcpy_speed, uint32_t* pmemset_speed);
|
||||
uint32_t tk_mem_speed_test(void* buffer, uint32_t length, uint32_t* pmemcpy_speed,
|
||||
uint32_t* pmemset_speed);
|
||||
|
||||
END_C_DECLS
|
||||
#endif /*TK_TKMEM_MANAGER_H*/
|
||||
|
@ -44,14 +44,14 @@ static ret_t slide_view_activate_next(slide_view_t* slide_view) {
|
||||
widget_t* widget = WIDGETP(slide_view);
|
||||
return_value_if_fail((slide_view->active + 1) < widget_count_children(widget), RET_BAD_PARAMS);
|
||||
|
||||
return slide_view_set_active(widget, slide_view->active+1);
|
||||
return slide_view_set_active(widget, slide_view->active + 1);
|
||||
}
|
||||
|
||||
static ret_t slide_view_activate_prev(slide_view_t* slide_view) {
|
||||
widget_t* widget = WIDGETP(slide_view);
|
||||
return_value_if_fail(slide_view->active > 0, RET_BAD_PARAMS);
|
||||
|
||||
return slide_view_set_active(widget, slide_view->active-1);
|
||||
return slide_view_set_active(widget, slide_view->active - 1);
|
||||
}
|
||||
static ret_t slide_view_on_paint_self(widget_t* widget, canvas_t* c) {
|
||||
return widget_paint_helper(widget, c, NULL, NULL);
|
||||
@ -69,18 +69,17 @@ static ret_t slide_view_on_pointer_down(slide_view_t* slide_view, pointer_event_
|
||||
}
|
||||
|
||||
static ret_t slide_view_on_scroll_event(void* ctx, event_t* e) {
|
||||
if(e->type == EVT_ANIM_END) {
|
||||
if (e->type == EVT_ANIM_END) {
|
||||
slide_view_t* slide_view = SLIDE_VIEW(ctx);
|
||||
if(slide_view->vertical) {
|
||||
|
||||
if (slide_view->vertical) {
|
||||
} else {
|
||||
if(slide_view->xoffset > 0) {
|
||||
if (slide_view->xoffset > 0) {
|
||||
slide_view_activate_prev(slide_view);
|
||||
} else if(slide_view->xoffset < 0) {
|
||||
} else if (slide_view->xoffset < 0) {
|
||||
slide_view_activate_next(slide_view);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
slide_view->xoffset = 0;
|
||||
slide_view->yoffset = 0;
|
||||
}
|
||||
@ -93,13 +92,12 @@ static ret_t slide_view_on_pointer_up(slide_view_t* slide_view, pointer_event_t*
|
||||
velocity_t* v = &(slide_view->velocity);
|
||||
|
||||
velocity_update(v, e->e.time, e->x, e->y);
|
||||
if(slide_view->vertical) {
|
||||
|
||||
if (slide_view->vertical) {
|
||||
} else {
|
||||
int xoffset = slide_view->xoffset;
|
||||
int xoffset_end = xoffset > 0 ? widget->w : -widget->w;
|
||||
widget_animator_t* animator = widget_animator_scroll_create(widget, 500, 0, EASING_SIN_INOUT);
|
||||
widget_animator_scroll_set_params(animator, xoffset, 0, xoffset_end, 0);
|
||||
widget_animator_scroll_set_params(animator, xoffset, 0, xoffset_end, 0);
|
||||
widget_animator_on(animator, EVT_ANIM_END, slide_view_on_scroll_event, slide_view);
|
||||
widget_animator_start(animator);
|
||||
}
|
||||
@ -125,7 +123,7 @@ static ret_t slide_view_on_event(widget_t* widget, event_t* e) {
|
||||
slide_view_on_pointer_down(slide_view, (pointer_event_t*)e);
|
||||
break;
|
||||
case EVT_POINTER_UP: {
|
||||
if(slide_view->xoffset || slide_view->yoffset) {
|
||||
if (slide_view->xoffset || slide_view->yoffset) {
|
||||
slide_view_on_pointer_up(slide_view, (pointer_event_t*)e);
|
||||
}
|
||||
break;
|
||||
|
@ -30,13 +30,13 @@ static ret_t widget_animator_scroll_update(widget_animator_t* animator, float_t
|
||||
widget_animator_scroll_t* scroll = (widget_animator_scroll_t*)animator;
|
||||
return_value_if_fail(scroll != NULL, RET_BAD_PARAMS);
|
||||
|
||||
if(scroll->x_to != scroll->x_from) {
|
||||
if (scroll->x_to != scroll->x_from) {
|
||||
xoffset = scroll->x_from + (scroll->x_to - scroll->x_from) * percent;
|
||||
value_set_int(&v, xoffset);
|
||||
widget_set_prop(animator->widget, WIDGET_PROP_XOFFSET, &v);
|
||||
}
|
||||
|
||||
if(scroll->y_to != scroll->y_from) {
|
||||
if (scroll->y_to != scroll->y_from) {
|
||||
yoffset = scroll->y_from + (scroll->y_to - scroll->y_from) * percent;
|
||||
value_set_int(&v, yoffset);
|
||||
widget_set_prop(animator->widget, WIDGET_PROP_YOFFSET, &v);
|
||||
@ -45,8 +45,8 @@ static ret_t widget_animator_scroll_update(widget_animator_t* animator, float_t
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
widget_animator_t* widget_animator_scroll_create(widget_t* widget, uint32_t duration, uint32_t delay,
|
||||
easing_type_t easing) {
|
||||
widget_animator_t* widget_animator_scroll_create(widget_t* widget, uint32_t duration,
|
||||
uint32_t delay, easing_type_t easing) {
|
||||
widget_animator_t* animator = NULL;
|
||||
return_value_if_fail(widget != NULL && duration > 0, NULL);
|
||||
|
||||
@ -59,7 +59,7 @@ widget_animator_t* widget_animator_scroll_create(widget_t* widget, uint32_t dura
|
||||
}
|
||||
|
||||
ret_t widget_animator_scroll_set_params(widget_animator_t* animator, xy_t x_from, xy_t y_from,
|
||||
xy_t x_to, xy_t y_to) {
|
||||
xy_t x_to, xy_t y_to) {
|
||||
widget_animator_scroll_t* scroll = (widget_animator_scroll_t*)animator;
|
||||
return_value_if_fail(scroll != NULL, RET_BAD_PARAMS);
|
||||
|
||||
|
@ -49,8 +49,8 @@ typedef struct _widget_animator_scroll_t {
|
||||
*
|
||||
* @return {widget_animator_t*} 成功返回动画对象,失败返回NULL。
|
||||
*/
|
||||
widget_animator_t* widget_animator_scroll_create(widget_t* widget, uint32_t duration, uint32_t delay,
|
||||
easing_type_t easing);
|
||||
widget_animator_t* widget_animator_scroll_create(widget_t* widget, uint32_t duration,
|
||||
uint32_t delay, easing_type_t easing);
|
||||
|
||||
/**
|
||||
* @method widget_animator_scroll_set_params
|
||||
@ -64,7 +64,7 @@ widget_animator_t* widget_animator_scroll_create(widget_t* widget, uint32_t dura
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t widget_animator_scroll_set_params(widget_animator_t* animator, xy_t x_from, xy_t y_from,
|
||||
xy_t x_to, xy_t y_to);
|
||||
xy_t x_to, xy_t y_to);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user