refactor the lvgl wasm api layer

This commit is contained in:
Wang Xin
2020-04-12 14:19:23 +08:00
parent d02d772def
commit 66d6a3986a
27 changed files with 1706 additions and 915 deletions

View File

@ -3,14 +3,14 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/wgl.h"
#include "wa-inc/lvgl/lvgl.h"
#include "bh_platform.h"
#include "gui_api.h"
#define ARGC sizeof(argv)/sizeof(uint32)
#define CALL_BTN_NATIVE_FUNC(id) wasm_btn_native_call(id, argv, ARGC)
wgl_obj_t wgl_btn_create(wgl_obj_t par, wgl_obj_t copy)
lv_obj_t * lv_btn_create(lv_obj_t * par, const lv_obj_t * copy);
{
uint32 argv[2] = {0};
@ -20,7 +20,7 @@ wgl_obj_t wgl_btn_create(wgl_obj_t par, wgl_obj_t copy)
return (wgl_obj_t)argv[0];
}
void wgl_btn_set_toggle(wgl_obj_t btn, bool tgl)
void lv_btn_set_toggle(lv_obj_t * btn, bool tgl);
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
@ -28,7 +28,7 @@ void wgl_btn_set_toggle(wgl_obj_t btn, bool tgl)
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_TOGGLE);
}
void wgl_btn_set_state(wgl_obj_t btn, wgl_btn_state_t state)
void lv_btn_set_state(lv_obj_t * btn, lv_btn_state_t state);
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
@ -36,14 +36,14 @@ void wgl_btn_set_state(wgl_obj_t btn, wgl_btn_state_t state)
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_STATE);
}
void wgl_btn_toggle(wgl_obj_t btn)
void lv_btn_toggle(lv_obj_t * btn);
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_TOGGLE);
}
void wgl_btn_set_ink_in_time(wgl_obj_t btn, uint16_t time)
void lv_btn_set_ink_in_time(lv_obj_t * btn, uint16_t time);
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
@ -51,7 +51,7 @@ void wgl_btn_set_ink_in_time(wgl_obj_t btn, uint16_t time)
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_INK_IN_TIME);
}
void wgl_btn_set_ink_wait_time(wgl_obj_t btn, uint16_t time)
void lv_btn_set_ink_wait_time(lv_obj_t * btn, uint16_t time);
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
@ -59,7 +59,7 @@ void wgl_btn_set_ink_wait_time(wgl_obj_t btn, uint16_t time)
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_INK_WAIT_TIME);
}
void wgl_btn_set_ink_out_time(wgl_obj_t btn, uint16_t time)
void lv_btn_set_ink_out_time(lv_obj_t * btn, uint16_t time);
{
uint32 argv[2] = {0};
argv[0] = (uint32)btn;
@ -73,7 +73,7 @@ void wgl_btn_set_ink_out_time(wgl_obj_t btn, uint16_t time)
// //wasm_btn_set_style(btn, type, style);
//}
//
wgl_btn_state_t wgl_btn_get_state(const wgl_obj_t btn)
lv_btn_state_t lv_btn_get_state(const lv_obj_t * btn);
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
@ -81,7 +81,7 @@ wgl_btn_state_t wgl_btn_get_state(const wgl_obj_t btn)
return (wgl_btn_state_t)argv[0];
}
bool wgl_btn_get_toggle(const wgl_obj_t btn)
bool lv_btn_get_toggle(const lv_obj_t * btn);
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
@ -89,7 +89,7 @@ bool wgl_btn_get_toggle(const wgl_obj_t btn)
return (bool)argv[0];
}
uint16_t wgl_btn_get_ink_in_time(const wgl_obj_t btn)
uint16_t lv_btn_get_ink_in_time(const lv_obj_t * btn);
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
@ -97,7 +97,7 @@ uint16_t wgl_btn_get_ink_in_time(const wgl_obj_t btn)
return (uint16_t)argv[0];
}
uint16_t wgl_btn_get_ink_wait_time(const wgl_obj_t btn)
uint16_t lv_btn_get_ink_wait_time(const lv_obj_t * btn);
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;
@ -105,7 +105,7 @@ uint16_t wgl_btn_get_ink_wait_time(const wgl_obj_t btn)
return (uint16_t)argv[0];
}
uint16_t wgl_btn_get_ink_out_time(const wgl_obj_t btn)
uint16_t lv_btn_get_ink_out_time(const lv_obj_t * btn);
{
uint32 argv[1] = {0};
argv[0] = (uint32)btn;

View File

@ -3,7 +3,8 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/wgl.h"
#include "wa-inc/lvgl/lvgl.h"
#include "gui_api.h"
#include <string.h>
@ -11,7 +12,7 @@
#define ARGC sizeof(argv)/sizeof(uint32)
#define CALL_CB_NATIVE_FUNC(id) wasm_cb_native_call(id, argv, ARGC)
wgl_obj_t wgl_cb_create(wgl_obj_t par, const wgl_obj_t copy)
lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy);
{
uint32 argv[2] = {0};
@ -21,7 +22,7 @@ wgl_obj_t wgl_cb_create(wgl_obj_t par, const wgl_obj_t copy)
return (wgl_obj_t)argv[0];
}
void wgl_cb_set_text(wgl_obj_t cb, const char * txt)
void lv_cb_set_text(lv_obj_t * cb, const char * txt);
{
uint32 argv[3] = {0};
argv[0] = (uint32)cb;
@ -30,7 +31,7 @@ void wgl_cb_set_text(wgl_obj_t cb, const char * txt)
CALL_CB_NATIVE_FUNC(CB_FUNC_ID_SET_TEXT);
}
void wgl_cb_set_static_text(wgl_obj_t cb, const char * txt)
void lv_cb_set_static_text(lv_obj_t * cb, const char * txt);
{
uint32 argv[3] = {0};
argv[0] = (uint32)cb;
@ -45,7 +46,7 @@ void wgl_cb_set_static_text(wgl_obj_t cb, const char * txt)
//}
//
unsigned int wgl_cb_get_text_length(wgl_obj_t cb)
static unsigned int wgl_cb_get_text_length(wgl_obj_t cb)
{
uint32 argv[1] = {0};
argv[0] = (uint32)cb;
@ -53,7 +54,7 @@ unsigned int wgl_cb_get_text_length(wgl_obj_t cb)
return argv[0];
}
char *wgl_cb_get_text(wgl_obj_t cb, char *buffer, int buffer_len)
static char *wgl_cb_get_text(wgl_obj_t cb, char *buffer, int buffer_len)
{
uint32 argv[3] = {0};
argv[0] = (uint32)cb;
@ -63,6 +64,14 @@ char *wgl_cb_get_text(wgl_obj_t cb, char *buffer, int buffer_len)
return (char *)argv[0];
}
// TODO: need to use a global data buffer for the returned text
const char * lv_cb_get_text(const lv_obj_t * cb)
{
return NULL;
}
//const wgl_style_t * wgl_cb_get_style(const wgl_obj_t cb, wgl_cb_style_t type)
//{
// //TODO

View File

@ -4,7 +4,8 @@
*/
#include "wa-inc/wgl.h"
#include "wa-inc/lvgl/lvgl.h"
#include "gui_api.h"
#include <string.h>
@ -12,7 +13,7 @@
#define ARGC sizeof(argv)/sizeof(uint32)
#define CALL_LABEL_NATIVE_FUNC(id) wasm_label_native_call(id, argv, ARGC)
wgl_obj_t wgl_label_create(wgl_obj_t par, wgl_obj_t copy)
lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy);
{
uint32 argv[2] = {0};
@ -22,7 +23,7 @@ wgl_obj_t wgl_label_create(wgl_obj_t par, wgl_obj_t copy)
return (wgl_obj_t)argv[0];
}
void wgl_label_set_text(wgl_obj_t label, const char * text)
void lv_label_set_text(lv_obj_t * label, const char * text);
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;
@ -32,7 +33,7 @@ void wgl_label_set_text(wgl_obj_t label, const char * text)
}
void wgl_label_set_array_text(wgl_obj_t label, const char * array, uint16_t size)
void lv_label_set_array_text(lv_obj_t * label, const char * array, uint16_t size);
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;
@ -42,7 +43,7 @@ void wgl_label_set_array_text(wgl_obj_t label, const char * array, uint16_t size
}
void wgl_label_set_static_text(wgl_obj_t label, const char * text)
void lv_label_set_static_text(lv_obj_t * label, const char * text);
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;
@ -52,7 +53,7 @@ void wgl_label_set_static_text(wgl_obj_t label, const char * text)
}
void wgl_label_set_long_mode(wgl_obj_t label, wgl_label_long_mode_t long_mode)
void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode);
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
@ -61,7 +62,7 @@ void wgl_label_set_long_mode(wgl_obj_t label, wgl_label_long_mode_t long_mode)
}
void wgl_label_set_align(wgl_obj_t label, wgl_label_align_t align)
void lv_label_set_align(lv_obj_t * label, lv_label_align_t align);
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
@ -70,7 +71,7 @@ void wgl_label_set_align(wgl_obj_t label, wgl_label_align_t align)
}
void wgl_label_set_recolor(wgl_obj_t label, bool en)
void lv_label_set_recolor(lv_obj_t * label, bool en);
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
@ -79,7 +80,7 @@ void wgl_label_set_recolor(wgl_obj_t label, bool en)
}
void wgl_label_set_body_draw(wgl_obj_t label, bool en)
void lv_label_set_body_draw(lv_obj_t * label, bool en);
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
@ -88,7 +89,7 @@ void wgl_label_set_body_draw(wgl_obj_t label, bool en)
}
void wgl_label_set_anim_speed(wgl_obj_t label, uint16_t anim_speed)
void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed);
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
@ -97,7 +98,7 @@ void wgl_label_set_anim_speed(wgl_obj_t label, uint16_t anim_speed)
}
void wgl_label_set_text_sel_start(wgl_obj_t label, uint16_t index)
void lv_label_set_text_sel_start(lv_obj_t * label, uint16_t index);
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
@ -106,7 +107,7 @@ void wgl_label_set_text_sel_start(wgl_obj_t label, uint16_t index)
}
void wgl_label_set_text_sel_end(wgl_obj_t label, uint16_t index)
void lv_label_set_text_sel_end(lv_obj_t * label, uint16_t index);
{
uint32 argv[2] = {0};
argv[0] = (uint32)label;
@ -132,6 +133,12 @@ char * wgl_label_get_text(wgl_obj_t label, char *buffer, int buffer_len)
return (char *)argv[0];
}
// TODO:
char * lv_label_get_text(const lv_obj_t * label)
{
}
wgl_label_long_mode_t wgl_label_get_long_mode(const wgl_obj_t label)
{
@ -142,7 +149,7 @@ wgl_label_long_mode_t wgl_label_get_long_mode(const wgl_obj_t label)
}
wgl_label_align_t wgl_label_get_align(const wgl_obj_t label)
lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * label);
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -151,7 +158,7 @@ wgl_label_align_t wgl_label_get_align(const wgl_obj_t label)
}
bool wgl_label_get_recolor(const wgl_obj_t label)
bool lv_label_get_recolor(const lv_obj_t * label);
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -160,7 +167,7 @@ bool wgl_label_get_recolor(const wgl_obj_t label)
}
bool wgl_label_get_body_draw(const wgl_obj_t label)
bool lv_label_get_body_draw(const lv_obj_t * label);
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -169,7 +176,7 @@ bool wgl_label_get_body_draw(const wgl_obj_t label)
}
uint16_t wgl_label_get_anim_speed(const wgl_obj_t label)
uint16_t lv_label_get_anim_speed(const lv_obj_t * label);
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -178,7 +185,7 @@ uint16_t wgl_label_get_anim_speed(const wgl_obj_t label)
}
void wgl_label_get_letter_pos(const wgl_obj_t label, uint16_t index, wgl_point_t * pos)
void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t * pos);
{
uint32 argv[4] = {0};
argv[0] = (uint32)label;
@ -189,7 +196,7 @@ void wgl_label_get_letter_pos(const wgl_obj_t label, uint16_t index, wgl_point_t
}
uint16_t wgl_label_get_letter_on(const wgl_obj_t label, wgl_point_t * pos)
uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos);
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;
@ -200,7 +207,7 @@ uint16_t wgl_label_get_letter_on(const wgl_obj_t label, wgl_point_t * pos)
}
bool wgl_label_is_char_under_pos(const wgl_obj_t label, wgl_point_t * pos)
bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos);
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;
@ -211,7 +218,7 @@ bool wgl_label_is_char_under_pos(const wgl_obj_t label, wgl_point_t * pos)
}
uint16_t wgl_label_get_text_sel_start(const wgl_obj_t label)
uint16_t lv_label_get_text_sel_start(const lv_obj_t * label);
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -220,7 +227,7 @@ uint16_t wgl_label_get_text_sel_start(const wgl_obj_t label)
}
uint16_t wgl_label_get_text_sel_end(const wgl_obj_t label)
uint16_t lv_label_get_text_sel_end(const lv_obj_t * label);
{
uint32 argv[1] = {0};
argv[0] = (uint32)label;
@ -229,7 +236,7 @@ uint16_t wgl_label_get_text_sel_end(const wgl_obj_t label)
}
void wgl_label_ins_text(wgl_obj_t label, uint32_t pos, const char * txt)
void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt);
{
uint32 argv[4] = {0};
argv[0] = (uint32)label;
@ -240,7 +247,7 @@ void wgl_label_ins_text(wgl_obj_t label, uint32_t pos, const char * txt)
}
void wgl_label_cut_text(wgl_obj_t label, uint32_t pos, uint32_t cnt)
void lv_label_cut_text(lv_obj_t * label, uint32_t pos, uint32_t cnt);
{
uint32 argv[3] = {0};
argv[0] = (uint32)label;

View File

@ -3,7 +3,8 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/wgl.h"
#include "wa-inc/lvgl/lvgl.h"
#include "gui_api.h"
#include <string.h>
@ -12,7 +13,7 @@
#define CALL_LIST_NATIVE_FUNC(id) wasm_list_native_call(id, argv, ARGC)
wgl_obj_t wgl_list_create(wgl_obj_t par, const wgl_obj_t copy)
lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy);
{
uint32 argv[2] = {0};
@ -30,7 +31,7 @@ wgl_obj_t wgl_list_create(wgl_obj_t par, const wgl_obj_t copy)
//}
//
wgl_obj_t wgl_list_add_btn(wgl_obj_t list, const void * img_src, const char * txt)
lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * img_src, const char * txt);
{
uint32 argv[3] = {0};

View File

@ -3,7 +3,8 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "wa-inc/wgl.h"
#include "wa-inc/lvgl/lvgl.h"
#include "gui_api.h"
#include <stdlib.h>
#include <string.h>
@ -24,7 +25,7 @@ static obj_evt_cb_t *g_obj_evt_cb_list = NULL;
/* For lvgl compatible */
char g_widget_text[100];
wgl_res_t wgl_obj_del(wgl_obj_t obj)
lv_res_t lv_obj_del(lv_obj_t * obj);
{
uint32 argv[1] = {0};
argv[0] = (uint32)obj;
@ -32,21 +33,21 @@ wgl_res_t wgl_obj_del(wgl_obj_t obj)
return (wgl_res_t)argv[0];
}
void wgl_obj_del_async(wgl_obj_t obj)
void lv_obj_del_async(struct _lv_obj_t *obj);
{
uint32 argv[1] = {0};
argv[0] = (uint32)obj;
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_DEL_ASYNC);
}
void wgl_obj_clean(wgl_obj_t obj)
void lv_obj_clean(lv_obj_t * obj);
{
uint32 argv[1] = {0};
argv[0] = (uint32)obj;
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_CLEAN);
}
void wgl_obj_align(wgl_obj_t obj, const wgl_obj_t base, wgl_align_t align, wgl_coord_t x_mod, wgl_coord_t y_mod)
void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod);
{
uint32 argv[5] = {0};
argv[0] = (uint32)obj;
@ -57,7 +58,7 @@ void wgl_obj_align(wgl_obj_t obj, const wgl_obj_t base, wgl_align_t align, wgl_c
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_ALIGN);
}
wgl_event_cb_t wgl_obj_get_event_cb(const wgl_obj_t obj)
lv_event_cb_t lv_obj_get_event_cb(const lv_obj_t * obj);
{
obj_evt_cb_t *obj_evt_cb = g_obj_evt_cb_list;
while (obj_evt_cb != NULL) {
@ -70,7 +71,7 @@ wgl_event_cb_t wgl_obj_get_event_cb(const wgl_obj_t obj)
return NULL;
}
void wgl_obj_set_event_cb(wgl_obj_t obj, wgl_event_cb_t event_cb)
void lv_obj_set_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb);
{
obj_evt_cb_t *obj_evt_cb;
uint32 argv[1] = {0};