mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
update demos
This commit is contained in:
parent
792e736c44
commit
3e54175570
@ -123,10 +123,37 @@ static ret_t on_dec(void* ctx, event_t* e) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
#include "widget_animators/widget_animator_opacity.h"
|
||||
#include "widget_animators/widget_animator_value.h"
|
||||
#include "widget_animators/widget_animator_move.h"
|
||||
#include "widget_animators/widget_animator_scale.h"
|
||||
#include "widget_animators/widget_animator_rotation.h"
|
||||
|
||||
static void on_move_animator(widget_t* widget) {
|
||||
widget_animator_t* animator = widget_animator_move_create(widget, 1000, 0, EASING_SIN_INOUT);
|
||||
widget_animator_move_set_params(animator, widget->x, widget->y, widget->x + 200, widget->y);
|
||||
widget_animator_set_repeat(animator, 1000);
|
||||
widget_animator_start(animator);
|
||||
}
|
||||
|
||||
static void on_fade_animator(widget_t* widget) {
|
||||
widget_animator_t* animator = widget_animator_opacity_create(widget, 1000, 0, EASING_SIN_OUT);
|
||||
widget_animator_opacity_set_params(animator, 50, 255);
|
||||
widget_animator_set_yoyo(animator, 1000);
|
||||
widget_animator_start(animator);
|
||||
}
|
||||
|
||||
static void on_value_animator(widget_t* widget) {
|
||||
widget_animator_t* animator = widget_animator_value_create(widget, 1000, 0, EASING_SIN_INOUT);
|
||||
widget_animator_value_set_params(animator, 50, 100);
|
||||
widget_animator_set_yoyo(animator, 1000);
|
||||
widget_animator_start(animator);
|
||||
}
|
||||
|
||||
static void install_click_hander(widget_t* widget) {
|
||||
uint32_t i = 0;
|
||||
uint32_t nr = 0;
|
||||
if (widget->name.size && widget->type == WIDGET_BUTTON) {
|
||||
if (widget->name.size) {
|
||||
const char* name = widget->name.str;
|
||||
if (strstr(name, "open:") != NULL) {
|
||||
widget_on(widget, EVT_CLICK, on_open_window, (void*)(name + 5));
|
||||
@ -151,6 +178,12 @@ static void install_click_hander(widget_t* widget) {
|
||||
if (win) {
|
||||
widget_on(widget, EVT_CLICK, on_quit, win);
|
||||
}
|
||||
} else if (strcmp(name, "move") == 0) {
|
||||
on_move_animator(widget);
|
||||
} else if (strcmp(name, "fade") == 0) {
|
||||
on_fade_animator(widget);
|
||||
} else if (strcmp(name, "value") == 0) {
|
||||
on_value_animator(widget);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,0x30,0x23,0xd0,0x31,};/*2348*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*2348*/
|
||||
|
@ -116,4 +116,4 @@ const unsigned char image_radio_checked[] = {
|
||||
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,0x00,0x00,0x00,};/*2348*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*2348*/
|
||||
|
@ -181,4 +181,4 @@ const unsigned char image_rgba[] = {
|
||||
0x00,0xff,0x00,0xea,0x00,0xff,0x00,0xc7,0x00,0xff,0x00,0x94,0x00,0xff,0x00,0x50,0x00,0x00,0xff,0x00,
|
||||
0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,
|
||||
0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,};/*3644*/
|
||||
0x48,0x59,0x73,0x00,};/*3644*/
|
||||
|
@ -116,4 +116,4 @@ const unsigned char image_right_on[] = {
|
||||
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,0x23,0xd0,0x58,};/*2348*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*2348*/
|
||||
|
@ -6,4 +6,4 @@ const unsigned char theme_calibration[] = {
|
||||
0x0d,0x00,0x00,0x00,0x63,0x72,0x6f,0x73,0x73,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xc0,0xc0,
|
||||
0xc0,0xff,0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x63,0x72,0x6f,0x73,0x73,0x00,0x01,0x00,0x00,0x00,
|
||||
0x01,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xff,0x01,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x63,0x72,0x6f,0x73,
|
||||
0x73,0x00,0x00,0x50,0x02,0x00,};/*146*/
|
||||
0x73,0x00,0x00,0x80,0x02,0x00,};/*146*/
|
||||
|
@ -1,10 +1,21 @@
|
||||
const unsigned char ui_animator[] = {
|
||||
0x04,0x00,0x01,0x01,0x8d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x6e,0x69,0x6d,0x61,0x74,0x6f,0x72,
|
||||
0x04,0x00,0x01,0x01,0x60,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x6e,0x69,0x6d,0x61,0x74,0x6f,0x72,
|
||||
0x00,0x64,0x61,0x74,0x61,0x00,0x00,0x00,0x12,0x12,0x22,0x11,0x77,0x69,0x6e,0x64,0x6f,0x77,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x40,0x01,0x00,0x00,0xe0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6d,0x61,0x69,
|
||||
0x6e,0x00,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,0x77,0x31,0x30,0x30,0x20,0x68,0x33,0x30,0x20,0x35,0x20,
|
||||
0x31,0x30,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x01,0x00,0x0a,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x19,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,
|
||||
0x00,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,0xb5,0xf0,0x6b,0x82,};/*173*/
|
||||
0x64,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x69,0x6d,0x61,0x67,0x65,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,
|
||||
0x00,0xc8,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x66,0x61,
|
||||
0x64,0x65,0x00,0x69,0x6d,0x61,0x67,0x65,0x00,0x6c,0x6f,0x67,0x6f,0x00,0x00,0x00,0x69,0x6d,0x61,0x67,
|
||||
0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x50,0x00,0x00,0x00,0xc8,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,
|
||||
0x00,0x66,0x61,0x64,0x65,0x00,0x69,0x6d,0x61,0x67,0x65,0x00,0x6c,0x6f,0x67,0x6f,0x00,0x00,0x00,0x69,
|
||||
0x6d,0x61,0x67,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0xd8,0xff,0xff,0xff,0xc8,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,
|
||||
0x61,0x6d,0x65,0x00,0x6d,0x6f,0x76,0x65,0x00,0x69,0x6d,0x61,0x67,0x65,0x00,0x6c,0x6f,0x67,0x6f,0x00,
|
||||
0x00,0x00,0x70,0x72,0x6f,0x67,0x72,0x65,0x73,0x73,0x5f,0x62,0x61,0x72,0x00,0x00,0x00,0x00,0x02,0x02,
|
||||
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5a,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x76,0x61,0x6c,0x75,0x65,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,
|
||||
0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x0a,
|
||||
0x00,0x00,0x00,0x19,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,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,};/*384*/
|
||||
|
@ -1,15 +1,18 @@
|
||||
const unsigned char ui_image[] = {
|
||||
0x04,0x00,0x01,0x01,0xf6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x69,0x6d,0x61,0x67,0x65,0x00,0x64,0x61,
|
||||
0x04,0x00,0x01,0x01,0x2b,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x69,0x6d,0x61,0x67,0x65,0x00,0x64,0x61,
|
||||
0x74,0x61,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x12,0x22,0x11,0x77,0x69,0x6e,0x64,0x6f,0x77,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x40,0x01,0x00,0x00,0xe0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6d,0x61,0x69,
|
||||
0x6e,0x00,0x61,0x6e,0x69,0x6d,0x5f,0x68,0x69,0x6e,0x74,0x00,0x68,0x74,0x72,0x61,0x6e,0x73,0x6c,0x61,
|
||||
0x74,0x65,0x00,0x00,0x69,0x6d,0x61,0x67,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0xa0,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x28,0x00,0x00,0x00,
|
||||
0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x28,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x69,0x6d,0x61,0x67,0x65,0x00,0x72,0x67,0x62,0x61,0x00,0x00,0x00,0x69,0x6d,0x61,
|
||||
0x67,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x00,0x00,
|
||||
0x00,0xa0,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x69,0x6d,0x61,
|
||||
0x67,0x65,0x00,0x72,0x67,0x62,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x19,0x00,0x00,
|
||||
0x00,0x1e,0x00,0x00,0x00,0x00,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,};/*278*/
|
||||
0x67,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x50,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x69,0x6d,0x61,
|
||||
0x67,0x65,0x00,0x72,0x67,0x62,0x00,0x00,0x00,0x69,0x6d,0x61,0x67,0x65,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x00,0x00,0x00,0x94,0x00,0x00,
|
||||
0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x69,0x6d,0x61,0x67,0x65,0x00,0x6c,0x6f,0x67,0x6f,0x00,
|
||||
0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x03,
|
||||
0x01,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,0x00,0x00,0x19,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,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,};/*331*/
|
||||
|
@ -20,4 +20,4 @@ const unsigned char ui_memtest[] = {
|
||||
0x62,0x65,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x01,0x00,0x00,0x00,
|
||||
0x00,0x00,0x5a,0x00,0x00,0x00,0x64,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6e,0x61,
|
||||
0x6d,0x65,0x00,0x6d,0x65,0x6d,0x63,0x70,0x79,0x00,0x74,0x65,0x78,0x74,0x00,0x6e,0x2f,0x61,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x68,0x7f,};/*426*/
|
||||
0x00,0x00,0x00,0x00,0x68,0x0f,};/*426*/
|
||||
|
Binary file not shown.
@ -1,3 +1,7 @@
|
||||
<window name="main" x="0" y="0" w="320" h="480" layout="w100 h30 5 10">
|
||||
<button name="close" x="10" y="5" w="25%" h="30" text="Close"/>
|
||||
<window>
|
||||
<image name="fade" image="logo" x="center" y="10" w="200" h="60"/>
|
||||
<image name="fade" image="logo" x="center" y="80" w="200" h="60"/>
|
||||
<image name="move" image="logo" x="0" y="middle:-40" w="200" h="60"/>
|
||||
<progress_bar name="value" x="center" y="middle" w="90%" h="40"/>
|
||||
<button name="close" x="center" y="bottom:10" w="25%" h="30" text="Close"/>
|
||||
</window>
|
||||
|
Binary file not shown.
@ -1,5 +1,6 @@
|
||||
<window name="main" anim_hint="htranslate" x="0" y="0" w="320" h="480">
|
||||
<image image="rgba" x="60" y="160" w="40" h="40"/>
|
||||
<image image="rgb" x="110" y="160" w="40" h="40"/>
|
||||
<button name="close" x="center" y="240" w="25%" h="30" text="Close"/>
|
||||
<image image="rgba" x="center" y="10" w="40" h="40"/>
|
||||
<image image="rgb" x="center" y="80" w="40" h="40"/>
|
||||
<image image="logo" x="center" y="160" w="148" h="68"/>
|
||||
<button name="close" x="center" y="bottom:60" w="25%" h="30" text="Close"/>
|
||||
</window>
|
||||
|
@ -101,13 +101,13 @@
|
||||
#include "res/inc/images/unchecked.data"
|
||||
#include "res/inc/images/unmuted.data"
|
||||
#include "res/inc/images/warn.data"
|
||||
#endif /*WITH_STB_IMAGE*/
|
||||
#endif/*WITH_STB_IMAGE*/
|
||||
#ifdef WITH_STB_FONT
|
||||
#include "res/inc/fonts/default.res"
|
||||
#else
|
||||
#include "res/inc/fonts/default.data"
|
||||
#endif /*WITH_STB_FONT*/
|
||||
#endif /*WITH_FS_RES*/
|
||||
#endif/*WITH_STB_FONT*/
|
||||
#endif/*WITH_FS_RES*/
|
||||
|
||||
ret_t resource_init(void) {
|
||||
resource_manager_t* rm = resource_manager();
|
||||
|
4
src/base/resource_manager.h
Normal file → Executable file
4
src/base/resource_manager.h
Normal file → Executable file
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* File: resource_manager.h
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: resource manager
|
||||
@ -79,7 +79,7 @@ typedef enum _resource_ui_type_t {
|
||||
* 预加载资源的描述信息。
|
||||
*/
|
||||
typedef struct _preload_res_t {
|
||||
uint16_t type;
|
||||
resource_type_t type;
|
||||
const char* name;
|
||||
} preload_res_t;
|
||||
|
||||
|
4
src/base/widget_factory.c
Normal file → Executable file
4
src/base/widget_factory.c
Normal file → Executable file
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* File: widget_factory.c
|
||||
* Author: AWTK Develop Team
|
||||
* Brief: widget factory
|
||||
@ -66,7 +66,7 @@ static const creator_item_t s_builtin_creators[] = {
|
||||
static const creator_item_t* widget_factory_find_builtin_creator(const char* type) {
|
||||
uint32_t i = 0;
|
||||
for (i = 0; i < ARRAY_SIZE(s_builtin_creators); i++) {
|
||||
creator_item_t* iter = s_builtin_creators + i;
|
||||
const creator_item_t* iter = s_builtin_creators + i;
|
||||
if (str_fast_equal(iter->type, type)) {
|
||||
return iter;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user