Implement 2D graphic API (#87)
* Implement 2D graphic library based on LittlevGL * Add lvgl license file
This commit is contained in:
@ -39,6 +39,7 @@
|
||||
#include "sensor.h"
|
||||
#include "connection.h"
|
||||
#include "timer_wasm_app.h"
|
||||
#include "wgl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
8
core/iwasm/lib/app-libs/extension/gui/inc/LICENCE.txt
Normal file
8
core/iwasm/lib/app-libs/extension/gui/inc/LICENCE.txt
Normal file
@ -0,0 +1,8 @@
|
||||
MIT licence
|
||||
Copyright (c) 2016 Gábor Kiss-Vámosi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
173
core/iwasm/lib/app-libs/extension/gui/inc/wgl_btn.h
Normal file
173
core/iwasm/lib/app-libs/extension/gui/inc/wgl_btn.h
Normal file
@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WAMR_GRAPHIC_LIBRARY_BTN_H
|
||||
#define WAMR_GRAPHIC_LIBRARY_BTN_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Possible states of a button.
|
||||
* It can be used not only by buttons but other button-like objects too*/
|
||||
enum {
|
||||
/**Released*/
|
||||
WGL_BTN_STATE_REL,
|
||||
|
||||
/**Pressed*/
|
||||
WGL_BTN_STATE_PR,
|
||||
|
||||
/**Toggled released*/
|
||||
WGL_BTN_STATE_TGL_REL,
|
||||
|
||||
/**Toggled pressed*/
|
||||
WGL_BTN_STATE_TGL_PR,
|
||||
|
||||
/**Inactive*/
|
||||
WGL_BTN_STATE_INA,
|
||||
|
||||
/**Number of states*/
|
||||
_WGL_BTN_STATE_NUM,
|
||||
};
|
||||
typedef uint8_t wgl_btn_state_t;
|
||||
|
||||
/**Styles*/
|
||||
enum {
|
||||
/** Release style */
|
||||
WGL_BTN_STYLE_REL,
|
||||
|
||||
/**Pressed style*/
|
||||
WGL_BTN_STYLE_PR,
|
||||
|
||||
/** Toggle released style*/
|
||||
WGL_BTN_STYLE_TGL_REL,
|
||||
|
||||
/** Toggle pressed style */
|
||||
WGL_BTN_STYLE_TGL_PR,
|
||||
|
||||
/** Inactive style*/
|
||||
WGL_BTN_STYLE_INA,
|
||||
};
|
||||
typedef uint8_t wgl_btn_style_t;
|
||||
|
||||
|
||||
/* Create a button */
|
||||
wgl_obj_t wgl_btn_create(wgl_obj_t par, wgl_obj_t copy);
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Enable the toggled states. On release the button will change from/to toggled state.
|
||||
* @param btn pointer to a button object
|
||||
* @param tgl true: enable toggled states, false: disable
|
||||
*/
|
||||
void wgl_btn_set_toggle(wgl_obj_t btn, bool tgl);
|
||||
|
||||
/**
|
||||
* Set the state of the button
|
||||
* @param btn pointer to a button object
|
||||
* @param state the new state of the button (from wgl_btn_state_t enum)
|
||||
*/
|
||||
void wgl_btn_set_state(wgl_obj_t btn, wgl_btn_state_t state);
|
||||
|
||||
/**
|
||||
* Toggle the state of the button (ON->OFF, OFF->ON)
|
||||
* @param btn pointer to a button object
|
||||
*/
|
||||
void wgl_btn_toggle(wgl_obj_t btn);
|
||||
|
||||
/**
|
||||
* Set time of the ink effect (draw a circle on click to animate in the new state)
|
||||
* @param btn pointer to a button object
|
||||
* @param time the time of the ink animation
|
||||
*/
|
||||
void wgl_btn_set_ink_in_time(wgl_obj_t btn, uint16_t time);
|
||||
|
||||
/**
|
||||
* Set the wait time before the ink disappears
|
||||
* @param btn pointer to a button object
|
||||
* @param time the time of the ink animation
|
||||
*/
|
||||
void wgl_btn_set_ink_wait_time(wgl_obj_t btn, uint16_t time);
|
||||
|
||||
/**
|
||||
* Set time of the ink out effect (animate to the released state)
|
||||
* @param btn pointer to a button object
|
||||
* @param time the time of the ink animation
|
||||
*/
|
||||
void wgl_btn_set_ink_out_time(wgl_obj_t btn, uint16_t time);
|
||||
|
||||
/**
|
||||
* Set a style of a button.
|
||||
* @param btn pointer to button object
|
||||
* @param type which style should be set
|
||||
* @param style pointer to a style
|
||||
* */
|
||||
//void wgl_btn_set_style(wgl_obj_t btn, wgl_btn_style_t type, const wgl_style_t * style);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the current state of the button
|
||||
* @param btn pointer to a button object
|
||||
* @return the state of the button (from wgl_btn_state_t enum)
|
||||
*/
|
||||
wgl_btn_state_t wgl_btn_get_state(wgl_obj_t btn);
|
||||
|
||||
/**
|
||||
* Get the toggle enable attribute of the button
|
||||
* @param btn pointer to a button object
|
||||
* @return true: toggle enabled, false: disabled
|
||||
*/
|
||||
bool wgl_btn_get_toggle(wgl_obj_t btn);
|
||||
|
||||
/**
|
||||
* Get time of the ink in effect (draw a circle on click to animate in the new state)
|
||||
* @param btn pointer to a button object
|
||||
* @return the time of the ink animation
|
||||
*/
|
||||
uint16_t wgl_btn_get_ink_in_time(wgl_obj_t btn);
|
||||
|
||||
/**
|
||||
* Get the wait time before the ink disappears
|
||||
* @param btn pointer to a button object
|
||||
* @return the time of the ink animation
|
||||
*/
|
||||
uint16_t wgl_btn_get_ink_wait_time(wgl_obj_t btn);
|
||||
|
||||
/**
|
||||
* Get time of the ink out effect (animate to the releases state)
|
||||
* @param btn pointer to a button object
|
||||
* @return the time of the ink animation
|
||||
*/
|
||||
uint16_t wgl_btn_get_ink_out_time(wgl_obj_t btn);
|
||||
|
||||
/**
|
||||
* Get style of a button.
|
||||
* @param btn pointer to button object
|
||||
* @param type which style should be get
|
||||
* @return style pointer to the style
|
||||
* */
|
||||
//const wgl_style_t * wgl_btn_get_style(const wgl_obj_t btn, wgl_btn_style_t type);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WAMR_GRAPHIC_LIBRARY_BTN_H */
|
||||
90
core/iwasm/lib/app-libs/extension/gui/inc/wgl_cb.h
Normal file
90
core/iwasm/lib/app-libs/extension/gui/inc/wgl_cb.h
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WAMR_GRAPHIC_LIBRARY_CB_H
|
||||
#define WAMR_GRAPHIC_LIBRARY_CB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Checkbox styles. */
|
||||
enum {
|
||||
WGL_CB_STYLE_BG, /**< Style of object background. */
|
||||
WGL_CB_STYLE_BOX_REL, /**< Style of box (released). */
|
||||
WGL_CB_STYLE_BOX_PR, /**< Style of box (pressed). */
|
||||
WGL_CB_STYLE_BOX_TGL_REL, /**< Style of box (released but checked). */
|
||||
WGL_CB_STYLE_BOX_TGL_PR, /**< Style of box (pressed and checked). */
|
||||
WGL_CB_STYLE_BOX_INA, /**< Style of disabled box */
|
||||
};
|
||||
typedef uint8_t wgl_cb_style_t;
|
||||
|
||||
|
||||
/**
|
||||
* Create a check box objects
|
||||
* @param par pointer to an object, it will be the parent of the new check box
|
||||
* @param copy pointer to a check box object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created check box
|
||||
*/
|
||||
wgl_obj_t wgl_cb_create(wgl_obj_t par, const wgl_obj_t copy);
|
||||
|
||||
/*=====================
|
||||
* Setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Set the text of a check box. `txt` will be copied and may be deallocated
|
||||
* after this function returns.
|
||||
* @param cb pointer to a check box
|
||||
* @param txt the text of the check box. NULL to refresh with the current text.
|
||||
*/
|
||||
void wgl_cb_set_text(wgl_obj_t cb, const char * txt);
|
||||
|
||||
/**
|
||||
* Set the text of a check box. `txt` must not be deallocated during the life
|
||||
* of this checkbox.
|
||||
* @param cb pointer to a check box
|
||||
* @param txt the text of the check box. NULL to refresh with the current text.
|
||||
*/
|
||||
void wgl_cb_set_static_text(wgl_obj_t cb, const char * txt);
|
||||
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
|
||||
/**
|
||||
* Get the length of the text of a check box
|
||||
* @param label the check box object
|
||||
* @return the length of the text of the check box
|
||||
*/
|
||||
unsigned int wgl_cb_get_text_length(wgl_obj_t cb);
|
||||
|
||||
/**
|
||||
* Get the text of a check box
|
||||
* @param label the check box object
|
||||
* @param buffer buffer to save the text
|
||||
* @param buffer_len length of the buffer
|
||||
* @return the text of the check box, note that the text will be truncated if buffer is not long enough
|
||||
*/
|
||||
char *wgl_cb_get_text(wgl_obj_t cb, char *buffer, int buffer_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WAMR_GRAPHIC_LIBRARY_CB_H */
|
||||
77
core/iwasm/lib/app-libs/extension/gui/inc/wgl_label.h
Normal file
77
core/iwasm/lib/app-libs/extension/gui/inc/wgl_label.h
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WAMR_GRAPHIC_LIBRARY_LABEL_H
|
||||
#define WAMR_GRAPHIC_LIBRARY_LABEL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Long mode behaviors. Used in 'wgl_label_ext_t' */
|
||||
enum {
|
||||
WGL_LABEL_LONG_EXPAND, /**< Expand the object size to the text size*/
|
||||
WGL_LABEL_LONG_BREAK, /**< Keep the object width, break the too long lines and expand the object
|
||||
height*/
|
||||
WGL_LABEL_LONG_DOT, /**< Keep the size and write dots at the end if the text is too long*/
|
||||
WGL_LABEL_LONG_SROLL, /**< Keep the size and roll the text back and forth*/
|
||||
WGL_LABEL_LONG_SROLL_CIRC, /**< Keep the size and roll the text circularly*/
|
||||
WGL_LABEL_LONG_CROP, /**< Keep the size and crop the text out of it*/
|
||||
};
|
||||
typedef uint8_t wgl_label_long_mode_t;
|
||||
|
||||
/** Label align policy*/
|
||||
enum {
|
||||
WGL_LABEL_ALIGN_LEFT, /**< Align text to left */
|
||||
WGL_LABEL_ALIGN_CENTER, /**< Align text to center */
|
||||
WGL_LABEL_ALIGN_RIGHT, /**< Align text to right */
|
||||
};
|
||||
typedef uint8_t wgl_label_align_t;
|
||||
|
||||
/** Label styles*/
|
||||
enum {
|
||||
WGL_LABEL_STYLE_MAIN,
|
||||
};
|
||||
typedef uint8_t wgl_label_style_t;
|
||||
|
||||
/* Create a label */
|
||||
wgl_obj_t wgl_label_create(wgl_obj_t par, wgl_obj_t copy);
|
||||
|
||||
/* Set text for the label */
|
||||
void wgl_label_set_text(wgl_obj_t label, const char * text);
|
||||
|
||||
/**
|
||||
* Get the length of the text of a label
|
||||
* @param label the label object
|
||||
* @return the length of the text of the label
|
||||
*/
|
||||
unsigned int wgl_label_get_text_length(wgl_obj_t label);
|
||||
|
||||
/**
|
||||
* Get the text of a label
|
||||
* @param label the label object
|
||||
* @param buffer buffer to save the text
|
||||
* @param buffer_len length of the buffer
|
||||
* @return the text of the label, note that the text will be truncated if buffer is not long enough
|
||||
*/
|
||||
char *wgl_label_get_text(wgl_obj_t label, char *buffer, int buffer_len);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WAMR_GRAPHIC_LIBRARY_LABEL_H */
|
||||
65
core/iwasm/lib/app-libs/extension/gui/inc/wgl_list.h
Normal file
65
core/iwasm/lib/app-libs/extension/gui/inc/wgl_list.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WAMR_GRAPHIC_LIBRARY_LIST_H
|
||||
#define WAMR_GRAPHIC_LIBRARY_LIST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** List styles. */
|
||||
enum {
|
||||
WGL_LIST_STYLE_BG, /**< List background style */
|
||||
WGL_LIST_STYLE_SCRL, /**< List scrollable area style. */
|
||||
WGL_LIST_STYLE_SB, /**< List scrollbar style. */
|
||||
WGL_LIST_STYLE_EDGE_FLASH, /**< List edge flash style. */
|
||||
WGL_LIST_STYLE_BTN_REL, /**< Same meaning as the ordinary button styles. */
|
||||
WGL_LIST_STYLE_BTN_PR,
|
||||
WGL_LIST_STYLE_BTN_TGL_REL,
|
||||
WGL_LIST_STYLE_BTN_TGL_PR,
|
||||
WGL_LIST_STYLE_BTN_INA,
|
||||
};
|
||||
typedef uint8_t wgl_list_style_t;
|
||||
|
||||
|
||||
/**
|
||||
* Create a list objects
|
||||
* @param par pointer to an object, it will be the parent of the new list
|
||||
* @param copy pointer to a list object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created list
|
||||
*/
|
||||
wgl_obj_t wgl_list_create(wgl_obj_t par, wgl_obj_t copy);
|
||||
|
||||
|
||||
/*======================
|
||||
* Add/remove functions
|
||||
*=====================*/
|
||||
|
||||
/**
|
||||
* Add a list element to the list
|
||||
* @param list pointer to list object
|
||||
* @param img_fn file name of an image before the text (NULL if unused)
|
||||
* @param txt text of the list element (NULL if unused)
|
||||
* @return pointer to the new list element which can be customized (a button)
|
||||
*/
|
||||
wgl_obj_t wgl_list_add_btn(wgl_obj_t list, const void * img_src, const char * txt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WAMR_GRAPHIC_LIBRARY_LIST_H */
|
||||
101
core/iwasm/lib/app-libs/extension/gui/inc/wgl_obj.h
Normal file
101
core/iwasm/lib/app-libs/extension/gui/inc/wgl_obj.h
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WAMR_GRAPHIC_LIBRARY_OBJ_H
|
||||
#define WAMR_GRAPHIC_LIBRARY_OBJ_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void * wgl_obj_t;
|
||||
|
||||
enum {
|
||||
WGL_EVENT_PRESSED, /**< The object has been pressed*/
|
||||
WGL_EVENT_PRESSING, /**< The object is being pressed (called continuously while pressing)*/
|
||||
WGL_EVENT_PRESS_LOST, /**< User is still pressing but slid cursor/finger off of the object */
|
||||
WGL_EVENT_SHORT_CLICKED, /**< User pressed object for a short period of time, then released it. Not called if dragged. */
|
||||
WGL_EVENT_LONG_PRESSED, /**< Object has been pressed for at least `WGL_INDEV_LONG_PRESS_TIME`. Not called if dragged.*/
|
||||
WGL_EVENT_LONG_PRESSED_REPEAT, /**< Called after `WGL_INDEV_LONG_PRESS_TIME` in every
|
||||
`WGL_INDEV_LONG_PRESS_REP_TIME` ms. Not called if dragged.*/
|
||||
WGL_EVENT_CLICKED, /**< Called on release if not dragged (regardless to long press)*/
|
||||
WGL_EVENT_RELEASED, /**< Called in every cases when the object has been released*/
|
||||
WGL_EVENT_DRAG_BEGIN,
|
||||
WGL_EVENT_DRAG_END,
|
||||
WGL_EVENT_DRAG_THROW_BEGIN,
|
||||
WGL_EVENT_KEY,
|
||||
WGL_EVENT_FOCUSED,
|
||||
WGL_EVENT_DEFOCUSED,
|
||||
WGL_EVENT_VALUE_CHANGED, /**< The object's value has changed (i.e. slider moved) */
|
||||
WGL_EVENT_INSERT,
|
||||
WGL_EVENT_REFRESH,
|
||||
WGL_EVENT_APPLY, /**< "Ok", "Apply" or similar specific button has clicked*/
|
||||
WGL_EVENT_CANCEL, /**< "Close", "Cancel" or similar specific button has clicked*/
|
||||
WGL_EVENT_DELETE, /**< Object is being deleted */
|
||||
};
|
||||
typedef uint8_t wgl_event_t; /**< Type of event being sent to the object. */
|
||||
|
||||
|
||||
/** Object alignment. */
|
||||
enum {
|
||||
WGL_ALIGN_CENTER = 0,
|
||||
WGL_ALIGN_IN_TOP_LEFT,
|
||||
WGL_ALIGN_IN_TOP_MID,
|
||||
WGL_ALIGN_IN_TOP_RIGHT,
|
||||
WGL_ALIGN_IN_BOTTOM_LEFT,
|
||||
WGL_ALIGN_IN_BOTTOM_MID,
|
||||
WGL_ALIGN_IN_BOTTOM_RIGHT,
|
||||
WGL_ALIGN_IN_LEFT_MID,
|
||||
WGL_ALIGN_IN_RIGHT_MID,
|
||||
WGL_ALIGN_OUT_TOP_LEFT,
|
||||
WGL_ALIGN_OUT_TOP_MID,
|
||||
WGL_ALIGN_OUT_TOP_RIGHT,
|
||||
WGL_ALIGN_OUT_BOTTOM_LEFT,
|
||||
WGL_ALIGN_OUT_BOTTOM_MID,
|
||||
WGL_ALIGN_OUT_BOTTOM_RIGHT,
|
||||
WGL_ALIGN_OUT_LEFT_TOP,
|
||||
WGL_ALIGN_OUT_LEFT_MID,
|
||||
WGL_ALIGN_OUT_LEFT_BOTTOM,
|
||||
WGL_ALIGN_OUT_RIGHT_TOP,
|
||||
WGL_ALIGN_OUT_RIGHT_MID,
|
||||
WGL_ALIGN_OUT_RIGHT_BOTTOM,
|
||||
};
|
||||
typedef uint8_t wgl_align_t;
|
||||
|
||||
|
||||
enum {
|
||||
WGL_DRAG_DIR_HOR = 0x1, /**< Object can be dragged horizontally. */
|
||||
WGL_DRAG_DIR_VER = 0x2, /**< Object can be dragged vertically. */
|
||||
WGL_DRAG_DIR_ALL = 0x3, /**< Object can be dragged in all directions. */
|
||||
};
|
||||
|
||||
typedef uint8_t wgl_drag_dir_t;
|
||||
|
||||
typedef void (*wgl_event_cb_t)(wgl_obj_t obj, wgl_event_t event);
|
||||
|
||||
void wgl_obj_align(wgl_obj_t obj, wgl_obj_t base, wgl_align_t align, wgl_coord_t x_mod, wgl_coord_t y_mod);
|
||||
void wgl_obj_set_event_cb(wgl_obj_t obj, wgl_event_cb_t event_cb);
|
||||
wgl_res_t wgl_obj_del(wgl_obj_t obj);
|
||||
void wgl_obj_del_async(wgl_obj_t obj);
|
||||
void wgl_obj_clean(wgl_obj_t obj);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WAMR_GRAPHIC_LIBRARY_OBJ_H */
|
||||
40
core/iwasm/lib/app-libs/extension/gui/inc/wgl_types.h
Normal file
40
core/iwasm/lib/app-libs/extension/gui/inc/wgl_types.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WAMR_GRAPHIC_LIBRARY_TYPES_H
|
||||
#define WAMR_GRAPHIC_LIBRARY_TYPES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* WGL error codes.
|
||||
*/
|
||||
enum {
|
||||
WGL_RES_INV = 0, /*Typically indicates that the object is deleted (become invalid) in the action
|
||||
function or an operation was failed*/
|
||||
WGL_RES_OK, /*The object is valid (no deleted) after the action*/
|
||||
};
|
||||
typedef uint8_t wgl_res_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WAMR_GRAPHIC_LIBRARY_TYPES_H */
|
||||
@ -0,0 +1,8 @@
|
||||
MIT licence
|
||||
Copyright (c) 2016 Gábor Kiss-Vámosi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WAMR_GRAPHIC_LIBRARY_BTN_LVGL_COMPATIBLE_H
|
||||
#define WAMR_GRAPHIC_LIBRARY_BTN_LVGL_COMPATIBLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../inc/wgl_btn.h"
|
||||
|
||||
/** Possible states of a button.
|
||||
* It can be used not only by buttons but other button-like objects too*/
|
||||
enum {
|
||||
/**Released*/
|
||||
LV_BTN_STATE_REL,
|
||||
|
||||
/**Pressed*/
|
||||
LV_BTN_STATE_PR,
|
||||
|
||||
/**Toggled released*/
|
||||
LV_BTN_STATE_TGL_REL,
|
||||
|
||||
/**Toggled pressed*/
|
||||
LV_BTN_STATE_TGL_PR,
|
||||
|
||||
/**Inactive*/
|
||||
LV_BTN_STATE_INA,
|
||||
|
||||
/**Number of states*/
|
||||
_LV_BTN_STATE_NUM,
|
||||
};
|
||||
typedef wgl_btn_state_t lv_btn_state_t;
|
||||
|
||||
/**Styles*/
|
||||
enum {
|
||||
/** Release style */
|
||||
LV_BTN_STYLE_REL,
|
||||
|
||||
/**Pressed style*/
|
||||
LV_BTN_STYLE_PR,
|
||||
|
||||
/** Toggle released style*/
|
||||
LV_BTN_STYLE_TGL_REL,
|
||||
|
||||
/** Toggle pressed style */
|
||||
LV_BTN_STYLE_TGL_PR,
|
||||
|
||||
/** Inactive style*/
|
||||
LV_BTN_STYLE_INA,
|
||||
};
|
||||
typedef wgl_btn_style_t lv_btn_style_t;
|
||||
|
||||
|
||||
#define lv_btn_create wgl_btn_create
|
||||
#define lv_btn_set_toggle wgl_btn_set_toggle
|
||||
#define lv_btn_set_state wgl_btn_set_state
|
||||
#define lv_btn_toggle wgl_btn_toggle
|
||||
#define lv_btn_set_ink_in_time wgl_btn_set_ink_in_time
|
||||
#define lv_btn_set_ink_wait_time wgl_btn_set_ink_wait_time
|
||||
#define lv_btn_set_ink_out_time wgl_btn_set_ink_out_time
|
||||
#define lv_btn_get_state wgl_btn_get_state
|
||||
#define lv_btn_get_toggle wgl_btn_get_toggle
|
||||
#define lv_btn_get_ink_in_time wgl_btn_get_ink_in_time
|
||||
#define lv_btn_get_ink_wait_time wgl_btn_get_ink_wait_time
|
||||
#define lv_btn_get_ink_out_time wgl_btn_get_ink_out_time
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WAMR_GRAPHIC_LIBRARY_BTN_LVGL_COMPATIBLE_H */
|
||||
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WAMR_GRAPHIC_LIBRARY_CB_LVGL_COMPATIBLE_H
|
||||
#define WAMR_GRAPHIC_LIBRARY_CB_LVGL_COMPATIBLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../inc/wgl_cb.h"
|
||||
|
||||
/** Checkbox styles. */
|
||||
enum {
|
||||
LV_CB_STYLE_BG, /**< Style of object background. */
|
||||
LV_CB_STYLE_BOX_REL, /**< Style of box (released). */
|
||||
LV_CB_STYLE_BOX_PR, /**< Style of box (pressed). */
|
||||
LV_CB_STYLE_BOX_TGL_REL, /**< Style of box (released but checked). */
|
||||
LV_CB_STYLE_BOX_TGL_PR, /**< Style of box (pressed and checked). */
|
||||
LV_CB_STYLE_BOX_INA, /**< Style of disabled box */
|
||||
};
|
||||
typedef wgl_cb_style_t lv_cb_style_t;
|
||||
|
||||
|
||||
#define lv_cb_create wgl_cb_create
|
||||
#define lv_cb_set_text wgl_cb_set_text
|
||||
#define lv_cb_set_static_text wgl_cb_set_static_text
|
||||
#define lv_cb_get_text(cb) wgl_cb_get_text(cb, g_widget_text, 100)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WAMR_GRAPHIC_LIBRARY_CB_LVGL_COMPATIBLE_H */
|
||||
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WAMR_GRAPHIC_LIBRARY_LABEL_LVGL_COMPATIBLE_H
|
||||
#define WAMR_GRAPHIC_LIBRARY_LABEL_LVGL_COMPATIBLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../inc/wgl_label.h"
|
||||
|
||||
/** Long mode behaviors. Used in 'lv_label_ext_t' */
|
||||
enum {
|
||||
LV_LABEL_LONG_EXPAND, /**< Expand the object size to the text size*/
|
||||
LV_LABEL_LONG_BREAK, /**< Keep the object width, break the too long lines and expand the object
|
||||
height*/
|
||||
LV_LABEL_LONG_DOT, /**< Keep the size and write dots at the end if the text is too long*/
|
||||
LV_LABEL_LONG_SROLL, /**< Keep the size and roll the text back and forth*/
|
||||
LV_LABEL_LONG_SROLL_CIRC, /**< Keep the size and roll the text circularly*/
|
||||
LV_LABEL_LONG_CROP, /**< Keep the size and crop the text out of it*/
|
||||
};
|
||||
typedef wgl_label_long_mode_t lv_label_long_mode_t;
|
||||
|
||||
/** Label align policy*/
|
||||
enum {
|
||||
LV_LABEL_ALIGN_LEFT, /**< Align text to left */
|
||||
LV_LABEL_ALIGN_CENTER, /**< Align text to center */
|
||||
LV_LABEL_ALIGN_RIGHT, /**< Align text to right */
|
||||
};
|
||||
typedef wgl_label_align_t lv_label_align_t;
|
||||
|
||||
/** Label styles*/
|
||||
enum {
|
||||
LV_LABEL_STYLE_MAIN,
|
||||
};
|
||||
typedef wgl_label_style_t lv_label_style_t;
|
||||
|
||||
|
||||
#define lv_label_create wgl_label_create
|
||||
#define lv_label_set_text wgl_label_set_text
|
||||
#define lv_label_get_text(label) wgl_label_get_text(label, g_widget_text, 100)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WAMR_GRAPHIC_LIBRARY_LABEL_LVGL_COMPATIBLE_H */
|
||||
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WAMR_GRAPHIC_LIBRARY_LIST_LVGL_COMPATIBLE_H
|
||||
#define WAMR_GRAPHIC_LIBRARY_LIST_LVGL_COMPATIBLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../inc/wgl_list.h"
|
||||
|
||||
/** List styles. */
|
||||
enum {
|
||||
LV_LIST_STYLE_BG, /**< List background style */
|
||||
LV_LIST_STYLE_SCRL, /**< List scrollable area style. */
|
||||
LV_LIST_STYLE_SB, /**< List scrollbar style. */
|
||||
LV_LIST_STYLE_EDGE_FLASH, /**< List edge flash style. */
|
||||
LV_LIST_STYLE_BTN_REL, /**< Same meaning as the ordinary button styles. */
|
||||
LV_LIST_STYLE_BTN_PR,
|
||||
LV_LIST_STYLE_BTN_TGL_REL,
|
||||
LV_LIST_STYLE_BTN_TGL_PR,
|
||||
LV_LIST_STYLE_BTN_INA,
|
||||
};
|
||||
typedef wgl_list_style_t lv_list_style_t;
|
||||
|
||||
|
||||
#define lv_list_create wgl_list_create
|
||||
#define lv_list_add_btn wgl_list_add_btn
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WAMR_GRAPHIC_LIBRARY_LIST_LVGL_COMPATIBLE_H */
|
||||
100
core/iwasm/lib/app-libs/extension/gui/lvgl-compatible/lv_obj.h
Normal file
100
core/iwasm/lib/app-libs/extension/gui/lvgl-compatible/lv_obj.h
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WAMR_GRAPHIC_LIBRARY_OBJ_LVGL_COMPATIBLE_H
|
||||
#define WAMR_GRAPHIC_LIBRARY_OBJ_LVGL_COMPATIBLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../inc/wgl_obj.h"
|
||||
|
||||
typedef void lv_obj_t;
|
||||
|
||||
enum {
|
||||
LV_EVENT_PRESSED,
|
||||
LV_EVENT_PRESSING,
|
||||
LV_EVENT_PRESS_LOST,
|
||||
LV_EVENT_SHORT_CLICKED,
|
||||
LV_EVENT_LONG_PRESSED,
|
||||
LV_EVENT_LONG_PRESSED_REPEAT,
|
||||
LV_EVENT_CLICKED,
|
||||
LV_EVENT_RELEASED,
|
||||
LV_EVENT_DRAG_BEGIN,
|
||||
LV_EVENT_DRAG_END,
|
||||
LV_EVENT_DRAG_THROW_BEGIN,
|
||||
LV_EVENT_KEY,
|
||||
LV_EVENT_FOCUSED,
|
||||
LV_EVENT_DEFOCUSED,
|
||||
LV_EVENT_VALUE_CHANGED,
|
||||
LV_EVENT_INSERT,
|
||||
LV_EVENT_REFRESH,
|
||||
LV_EVENT_APPLY,
|
||||
LV_EVENT_CANCEL,
|
||||
LV_EVENT_DELETE,
|
||||
};
|
||||
typedef wgl_event_t lv_event_t;
|
||||
|
||||
|
||||
/** Object alignment. */
|
||||
enum {
|
||||
LV_ALIGN_CENTER,
|
||||
LV_ALIGN_IN_TOP_LEFT,
|
||||
LV_ALIGN_IN_TOP_MID,
|
||||
LV_ALIGN_IN_TOP_RIGHT,
|
||||
LV_ALIGN_IN_BOTTOM_LEFT,
|
||||
LV_ALIGN_IN_BOTTOM_MID,
|
||||
LV_ALIGN_IN_BOTTOM_RIGHT,
|
||||
LV_ALIGN_IN_LEFT_MID,
|
||||
LV_ALIGN_IN_RIGHT_MID,
|
||||
LV_ALIGN_OUT_TOP_LEFT,
|
||||
LV_ALIGN_OUT_TOP_MID,
|
||||
LV_ALIGN_OUT_TOP_RIGHT,
|
||||
LV_ALIGN_OUT_BOTTOM_LEFT,
|
||||
LV_ALIGN_OUT_BOTTOM_MID,
|
||||
LV_ALIGN_OUT_BOTTOM_RIGHT,
|
||||
LV_ALIGN_OUT_LEFT_TOP,
|
||||
LV_ALIGN_OUT_LEFT_MID,
|
||||
LV_ALIGN_OUT_LEFT_BOTTOM,
|
||||
LV_ALIGN_OUT_RIGHT_TOP,
|
||||
LV_ALIGN_OUT_RIGHT_MID,
|
||||
LV_ALIGN_OUT_RIGHT_BOTTOM,
|
||||
};
|
||||
typedef wgl_align_t lv_align_t;
|
||||
|
||||
|
||||
enum {
|
||||
LV_DRAG_DIR_HOR,
|
||||
LV_DRAG_DIR_VER,
|
||||
LV_DRAG_DIR_ALL,
|
||||
};
|
||||
|
||||
typedef wgl_drag_dir_t lv_drag_dir_t;
|
||||
|
||||
|
||||
#define lv_obj_align wgl_obj_align
|
||||
#define lv_obj_set_event_cb wgl_obj_set_event_cb
|
||||
#define lv_obj_del wgl_obj_del
|
||||
#define lv_obj_del_async wgl_obj_del_async
|
||||
#define lv_obj_clean wgl_obj_clean
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WAMR_GRAPHIC_LIBRARY_OBJ_LVGL_COMPATIBLE_H */
|
||||
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WAMR_GRAPHIC_LIBRARY_TYPES_LVGL_COMPATIBLE_H
|
||||
#define WAMR_GRAPHIC_LIBRARY_TYPES_LVGL_COMPATIBLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../inc/wgl_types.h"
|
||||
|
||||
/**
|
||||
* error codes.
|
||||
*/
|
||||
enum {
|
||||
LV_RES_INV,
|
||||
LV_RES_OK,
|
||||
};
|
||||
typedef wgl_res_t lv_res_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WAMR_GRAPHIC_LIBRARY_TYPES_LVGL_COMPATIBLE_H */
|
||||
37
core/iwasm/lib/app-libs/extension/gui/lvgl.h
Normal file
37
core/iwasm/lib/app-libs/extension/gui/lvgl.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WAMR_GRAPHIC_LIBRARY_LVGL_COMPATIBLE_H
|
||||
#define WAMR_GRAPHIC_LIBRARY_LVGL_COMPATIBLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "wgl_shared_utils.h" /* shared types between app and native */
|
||||
#include "lvgl-compatible/lv_types.h"
|
||||
#include "lvgl-compatible/lv_obj.h"
|
||||
#include "lvgl-compatible/lv_btn.h"
|
||||
#include "lvgl-compatible/lv_cb.h"
|
||||
#include "lvgl-compatible/lv_label.h"
|
||||
#include "lvgl-compatible/lv_list.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WAMR_GRAPHIC_LIBRARY_LVGL_COMPATIBLE_H */
|
||||
131
core/iwasm/lib/app-libs/extension/gui/src/wgl_btn.c
Normal file
131
core/iwasm/lib/app-libs/extension/gui/src/wgl_btn.c
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "wgl.h"
|
||||
#include "native_interface.h"
|
||||
|
||||
|
||||
#define ARGC sizeof(argv)/sizeof(uint32)
|
||||
#define CALL_BTN_NATIVE_FUNC(id) wasm_btn_native_call(id, (int32)argv, ARGC)
|
||||
|
||||
wgl_obj_t wgl_btn_create(wgl_obj_t par, wgl_obj_t copy)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)par;
|
||||
argv[1] = (uint32)copy;
|
||||
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_CREATE);
|
||||
return (wgl_obj_t)argv[0];
|
||||
}
|
||||
|
||||
void wgl_btn_set_toggle(wgl_obj_t btn, bool tgl)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)btn;
|
||||
argv[1] = tgl;
|
||||
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_TOGGLE);
|
||||
}
|
||||
|
||||
void wgl_btn_set_state(wgl_obj_t btn, wgl_btn_state_t state)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)btn;
|
||||
argv[1] = state;
|
||||
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_STATE);
|
||||
}
|
||||
|
||||
void wgl_btn_toggle(wgl_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)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)btn;
|
||||
argv[1] = 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)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)btn;
|
||||
argv[1] = 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)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)btn;
|
||||
argv[1] = time;
|
||||
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_SET_INK_OUT_TIME);
|
||||
}
|
||||
|
||||
//void wgl_btn_set_style(wgl_obj_t btn, wgl_btn_style_t type, const wgl_style_t * style)
|
||||
//{
|
||||
// //TODO: pack style
|
||||
// //wasm_btn_set_style(btn, type, style);
|
||||
//}
|
||||
//
|
||||
wgl_btn_state_t wgl_btn_get_state(const wgl_obj_t btn)
|
||||
{
|
||||
uint32 argv[1] = {0};
|
||||
argv[0] = (uint32)btn;
|
||||
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_STATE);
|
||||
return (wgl_btn_state_t)argv[0];
|
||||
}
|
||||
|
||||
bool wgl_btn_get_toggle(const wgl_obj_t btn)
|
||||
{
|
||||
uint32 argv[1] = {0};
|
||||
argv[0] = (uint32)btn;
|
||||
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_TOGGLE);
|
||||
return (bool)argv[0];
|
||||
}
|
||||
|
||||
uint16_t wgl_btn_get_ink_in_time(const wgl_obj_t btn)
|
||||
{
|
||||
uint32 argv[1] = {0};
|
||||
argv[0] = (uint32)btn;
|
||||
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_INK_IN_TIME);
|
||||
return (uint16_t)argv[0];
|
||||
}
|
||||
|
||||
uint16_t wgl_btn_get_ink_wait_time(const wgl_obj_t btn)
|
||||
{
|
||||
uint32 argv[1] = {0};
|
||||
argv[0] = (uint32)btn;
|
||||
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_INK_WAIT_TIME);
|
||||
return (uint16_t)argv[0];
|
||||
}
|
||||
|
||||
uint16_t wgl_btn_get_ink_out_time(const wgl_obj_t btn)
|
||||
{
|
||||
uint32 argv[1] = {0};
|
||||
argv[0] = (uint32)btn;
|
||||
CALL_BTN_NATIVE_FUNC(BTN_FUNC_ID_GET_INK_OUT_TIME);
|
||||
return (uint16_t)argv[0];
|
||||
}
|
||||
//
|
||||
//const wgl_style_t * wgl_btn_get_style(const wgl_obj_t btn, wgl_btn_style_t type)
|
||||
//{
|
||||
// //TODO: pack style
|
||||
// //wasm_btn_get_style(btn, type);
|
||||
// return NULL;
|
||||
//}
|
||||
83
core/iwasm/lib/app-libs/extension/gui/src/wgl_cb.c
Normal file
83
core/iwasm/lib/app-libs/extension/gui/src/wgl_cb.c
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "wgl.h"
|
||||
#include "native_interface.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define ARGC sizeof(argv)/sizeof(uint32)
|
||||
#define CALL_CB_NATIVE_FUNC(id) wasm_cb_native_call(id, (uint32)argv, ARGC)
|
||||
|
||||
wgl_obj_t wgl_cb_create(wgl_obj_t par, const wgl_obj_t copy)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)par;
|
||||
argv[1] = (uint32)copy;
|
||||
CALL_CB_NATIVE_FUNC(CB_FUNC_ID_CREATE);
|
||||
return (wgl_obj_t)argv[0];
|
||||
}
|
||||
|
||||
void wgl_cb_set_text(wgl_obj_t cb, const char * txt)
|
||||
{
|
||||
uint32 argv[3] = {0};
|
||||
argv[0] = (uint32)cb;
|
||||
argv[1] = (uint32)txt;
|
||||
argv[2] = strlen(txt) + 1;
|
||||
CALL_CB_NATIVE_FUNC(CB_FUNC_ID_SET_TEXT);
|
||||
}
|
||||
|
||||
void wgl_cb_set_static_text(wgl_obj_t cb, const char * txt)
|
||||
{
|
||||
uint32 argv[3] = {0};
|
||||
argv[0] = (uint32)cb;
|
||||
argv[1] = (uint32)txt;
|
||||
argv[2] = strlen(txt) + 1;
|
||||
CALL_CB_NATIVE_FUNC(CB_FUNC_ID_SET_STATIC_TEXT);
|
||||
}
|
||||
|
||||
//void wgl_cb_set_style(wgl_obj_t cb, wgl_cb_style_t type, const wgl_style_t * style)
|
||||
//{
|
||||
// //TODO:
|
||||
//}
|
||||
//
|
||||
|
||||
unsigned int wgl_cb_get_text_length(wgl_obj_t cb)
|
||||
{
|
||||
uint32 argv[1] = {0};
|
||||
argv[0] = (uint32)cb;
|
||||
CALL_CB_NATIVE_FUNC(CB_FUNC_ID_GET_TEXT_LENGTH);
|
||||
return argv[0];
|
||||
}
|
||||
|
||||
char *wgl_cb_get_text(wgl_obj_t cb, char *buffer, int buffer_len)
|
||||
{
|
||||
uint32 argv[3] = {0};
|
||||
argv[0] = (uint32)cb;
|
||||
argv[1] = (uint32)buffer;
|
||||
argv[2] = buffer_len;
|
||||
CALL_CB_NATIVE_FUNC(CB_FUNC_ID_GET_TEXT);
|
||||
return (char *)argv[0];
|
||||
}
|
||||
|
||||
//const wgl_style_t * wgl_cb_get_style(const wgl_obj_t cb, wgl_cb_style_t type)
|
||||
//{
|
||||
// //TODO
|
||||
// return NULL;
|
||||
//}
|
||||
//
|
||||
|
||||
|
||||
262
core/iwasm/lib/app-libs/extension/gui/src/wgl_label.c
Normal file
262
core/iwasm/lib/app-libs/extension/gui/src/wgl_label.c
Normal file
@ -0,0 +1,262 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include "wgl.h"
|
||||
#include "native_interface.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define ARGC sizeof(argv)/sizeof(uint32)
|
||||
#define CALL_LABEL_NATIVE_FUNC(id) wasm_label_native_call(id, (uint32)argv, ARGC)
|
||||
|
||||
wgl_obj_t wgl_label_create(wgl_obj_t par, wgl_obj_t copy)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)par;
|
||||
argv[1] = (uint32)copy;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_CREATE);
|
||||
return (wgl_obj_t)argv[0];
|
||||
}
|
||||
|
||||
void wgl_label_set_text(wgl_obj_t label, const char * text)
|
||||
{
|
||||
uint32 argv[3] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = (uint32)text;
|
||||
argv[2] = strlen(text) + 1;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_TEXT);
|
||||
}
|
||||
|
||||
|
||||
void wgl_label_set_array_text(wgl_obj_t label, const char * array, uint16_t size)
|
||||
{
|
||||
uint32 argv[3] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = (uint32)array;
|
||||
argv[2] = size;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_ARRAY_TEXT);
|
||||
}
|
||||
|
||||
|
||||
void wgl_label_set_static_text(wgl_obj_t label, const char * text)
|
||||
{
|
||||
uint32 argv[3] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = (uint32)text;
|
||||
argv[2] = strlen(text) + 1;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_STATIC_TEXT);
|
||||
}
|
||||
|
||||
|
||||
void wgl_label_set_long_mode(wgl_obj_t label, wgl_label_long_mode_t long_mode)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = long_mode;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_LONG_MODE);
|
||||
}
|
||||
|
||||
|
||||
void wgl_label_set_align(wgl_obj_t label, wgl_label_align_t align)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = align;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_ALIGN);
|
||||
}
|
||||
|
||||
|
||||
void wgl_label_set_recolor(wgl_obj_t label, bool en)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = en;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_RECOLOR);
|
||||
}
|
||||
|
||||
|
||||
void wgl_label_set_body_draw(wgl_obj_t label, bool en)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = en;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_BODY_DRAW);
|
||||
}
|
||||
|
||||
|
||||
void wgl_label_set_anim_speed(wgl_obj_t label, uint16_t anim_speed)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = anim_speed;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_ANIM_SPEED);
|
||||
}
|
||||
|
||||
|
||||
void wgl_label_set_text_sel_start(wgl_obj_t label, uint16_t index)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = index;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_TEXT_SEL_START);
|
||||
}
|
||||
|
||||
|
||||
void wgl_label_set_text_sel_end(wgl_obj_t label, uint16_t index)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = index;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_SET_TEXT_SEL_END);
|
||||
}
|
||||
|
||||
unsigned int wgl_label_get_text_length(wgl_obj_t label)
|
||||
{
|
||||
uint32 argv[1] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_TEXT_LENGTH);
|
||||
return argv[0];
|
||||
}
|
||||
|
||||
char * wgl_label_get_text(wgl_obj_t label, char *buffer, int buffer_len)
|
||||
{
|
||||
uint32 argv[3] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = (uint32)buffer;
|
||||
argv[2] = buffer_len;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_TEXT);
|
||||
return (char *)argv[0];
|
||||
}
|
||||
|
||||
|
||||
wgl_label_long_mode_t wgl_label_get_long_mode(const wgl_obj_t label)
|
||||
{
|
||||
uint32 argv[1] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_LONG_MODE);
|
||||
return (wgl_label_long_mode_t)argv[0];
|
||||
}
|
||||
|
||||
|
||||
wgl_label_align_t wgl_label_get_align(const wgl_obj_t label)
|
||||
{
|
||||
uint32 argv[1] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_ALIGN);
|
||||
return (wgl_label_align_t)argv[0];
|
||||
}
|
||||
|
||||
|
||||
bool wgl_label_get_recolor(const wgl_obj_t label)
|
||||
{
|
||||
uint32 argv[1] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_RECOLOR);
|
||||
return (bool)argv[0];
|
||||
}
|
||||
|
||||
|
||||
bool wgl_label_get_body_draw(const wgl_obj_t label)
|
||||
{
|
||||
uint32 argv[1] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_BODY_DRAW);
|
||||
return (bool)argv[0];
|
||||
}
|
||||
|
||||
|
||||
uint16_t wgl_label_get_anim_speed(const wgl_obj_t label)
|
||||
{
|
||||
uint32 argv[1] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_ANIM_SPEED);
|
||||
return (uint16_t)argv[0];
|
||||
}
|
||||
|
||||
|
||||
void wgl_label_get_letter_pos(const wgl_obj_t label, uint16_t index, wgl_point_t * pos)
|
||||
{
|
||||
uint32 argv[4] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = index;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_LETTER_POS);
|
||||
pos->x = argv[2];
|
||||
pos->y = argv[3];
|
||||
}
|
||||
|
||||
|
||||
uint16_t wgl_label_get_letter_on(const wgl_obj_t label, wgl_point_t * pos)
|
||||
{
|
||||
uint32 argv[3] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = pos->x;
|
||||
argv[2] = pos->y;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_LETTER_POS);
|
||||
return (uint16_t)argv[0];
|
||||
}
|
||||
|
||||
|
||||
bool wgl_label_is_char_under_pos(const wgl_obj_t label, wgl_point_t * pos)
|
||||
{
|
||||
uint32 argv[3] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = pos->x;
|
||||
argv[2] = pos->y;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_LETTER_POS);
|
||||
return (bool)argv[0];
|
||||
}
|
||||
|
||||
|
||||
uint16_t wgl_label_get_text_sel_start(const wgl_obj_t label)
|
||||
{
|
||||
uint32 argv[1] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_TEXT_SEL_START);
|
||||
return (uint16_t)argv[0];
|
||||
}
|
||||
|
||||
|
||||
uint16_t wgl_label_get_text_sel_end(const wgl_obj_t label)
|
||||
{
|
||||
uint32 argv[1] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_GET_TEXT_SEL_END);
|
||||
return (uint16_t)argv[0];
|
||||
}
|
||||
|
||||
|
||||
void wgl_label_ins_text(wgl_obj_t label, uint32_t pos, const char * txt)
|
||||
{
|
||||
uint32 argv[4] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = pos;
|
||||
argv[2] = (uint32)txt;
|
||||
argv[3] = strlen(txt) + 1;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_INS_TEXT);
|
||||
}
|
||||
|
||||
|
||||
void wgl_label_cut_text(wgl_obj_t label, uint32_t pos, uint32_t cnt)
|
||||
{
|
||||
uint32 argv[3] = {0};
|
||||
argv[0] = (uint32)label;
|
||||
argv[1] = pos;
|
||||
argv[2] = cnt;
|
||||
CALL_LABEL_NATIVE_FUNC(LABEL_FUNC_ID_CUT_TEXT);
|
||||
}
|
||||
|
||||
|
||||
162
core/iwasm/lib/app-libs/extension/gui/src/wgl_list.c
Normal file
162
core/iwasm/lib/app-libs/extension/gui/src/wgl_list.c
Normal file
@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "wgl.h"
|
||||
#include "native_interface.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define ARGC sizeof(argv)/sizeof(uint32)
|
||||
#define CALL_LIST_NATIVE_FUNC(id) wasm_list_native_call(id, (int32)argv, ARGC)
|
||||
|
||||
|
||||
wgl_obj_t wgl_list_create(wgl_obj_t par, const wgl_obj_t copy)
|
||||
{
|
||||
uint32 argv[2] = {0};
|
||||
argv[0] = (uint32)par;
|
||||
argv[1] = (uint32)copy;
|
||||
CALL_LIST_NATIVE_FUNC(LIST_FUNC_ID_CREATE);
|
||||
return (wgl_obj_t)argv[0];
|
||||
}
|
||||
//
|
||||
//
|
||||
//void wgl_list_clean(wgl_obj_t obj)
|
||||
//{
|
||||
// wasm_list_clean(obj);
|
||||
//}
|
||||
//
|
||||
|
||||
wgl_obj_t wgl_list_add_btn(wgl_obj_t list, const void * img_src, const char * txt)
|
||||
{
|
||||
(void)img_src; /* doesn't support img src currently */
|
||||
|
||||
uint32 argv[3] = {0};
|
||||
argv[0] = (uint32)list;
|
||||
argv[1] = (uint32)txt;
|
||||
argv[2] = strlen(txt) + 1;
|
||||
CALL_LIST_NATIVE_FUNC(LIST_FUNC_ID_ADD_BTN);
|
||||
return (wgl_obj_t)argv[0];
|
||||
}
|
||||
//
|
||||
//
|
||||
//bool wgl_list_remove(const wgl_obj_t list, uint16_t index)
|
||||
//{
|
||||
// return wasm_list_remove(list, index);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//void wgl_list_set_single_mode(wgl_obj_t list, bool mode)
|
||||
//{
|
||||
// wasm_list_set_single_mode(list, mode);
|
||||
//}
|
||||
//
|
||||
//#if LV_USE_GROUP
|
||||
//
|
||||
//
|
||||
//void wgl_list_set_btn_selected(wgl_obj_t list, wgl_obj_t btn)
|
||||
//{
|
||||
// wasm_list_set_btn_selected(list, btn);
|
||||
//}
|
||||
//#endif
|
||||
//
|
||||
//
|
||||
//void wgl_list_set_style(wgl_obj_t list, wgl_list_style_t type, const wgl_style_t * style)
|
||||
//{
|
||||
// //TODO
|
||||
//}
|
||||
//
|
||||
//
|
||||
//bool wgl_list_get_single_mode(wgl_obj_t list)
|
||||
//{
|
||||
// return wasm_list_get_single_mode(list);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//const char * wgl_list_get_btn_text(const wgl_obj_t btn)
|
||||
//{
|
||||
// return wasm_list_get_btn_text(btn);
|
||||
//}
|
||||
//
|
||||
//wgl_obj_t wgl_list_get_btn_label(const wgl_obj_t btn)
|
||||
//{
|
||||
// return wasm_list_get_btn_label(btn);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//wgl_obj_t wgl_list_get_btn_img(const wgl_obj_t btn)
|
||||
//{
|
||||
// return wasm_list_get_btn_img(btn);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//wgl_obj_t wgl_list_get_prev_btn(const wgl_obj_t list, wgl_obj_t prev_btn)
|
||||
//{
|
||||
// return wasm_list_get_prev_btn(list, prev_btn);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//wgl_obj_t wgl_list_get_next_btn(const wgl_obj_t list, wgl_obj_t prev_btn)
|
||||
//{
|
||||
// return wasm_list_get_next_btn(list, prev_btn);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//int32_t wgl_list_get_btn_index(const wgl_obj_t list, const wgl_obj_t btn)
|
||||
//{
|
||||
// return wasm_list_get_btn_index(list, btn);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//uint16_t wgl_list_get_size(const wgl_obj_t list)
|
||||
//{
|
||||
// return wasm_list_get_size(list);
|
||||
//}
|
||||
//
|
||||
//#if LV_USE_GROUP
|
||||
//
|
||||
//wgl_obj_t wgl_list_get_btn_selected(const wgl_obj_t list)
|
||||
//{
|
||||
// return wasm_list_get_btn_selected(list);
|
||||
//}
|
||||
//#endif
|
||||
//
|
||||
//
|
||||
//
|
||||
//const wgl_style_t * wgl_list_get_style(const wgl_obj_t list, wgl_list_style_t type)
|
||||
//{
|
||||
// //TODO
|
||||
// return NULL;
|
||||
//}
|
||||
//
|
||||
//
|
||||
//void wgl_list_up(const wgl_obj_t list)
|
||||
//{
|
||||
// wasm_list_up(list);
|
||||
//}
|
||||
//
|
||||
//void wgl_list_down(const wgl_obj_t list)
|
||||
//{
|
||||
// wasm_list_down(list);
|
||||
//}
|
||||
//
|
||||
//
|
||||
//void wgl_list_focus(const wgl_obj_t btn, wgl_anim_enable_t anim)
|
||||
//{
|
||||
// wasm_list_focus(btn, anim);
|
||||
//}
|
||||
//
|
||||
|
||||
|
||||
127
core/iwasm/lib/app-libs/extension/gui/src/wgl_obj.c
Normal file
127
core/iwasm/lib/app-libs/extension/gui/src/wgl_obj.c
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "wgl.h"
|
||||
#include "native_interface.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define ARGC sizeof(argv)/sizeof(uint32)
|
||||
#define CALL_OBJ_NATIVE_FUNC(id) wasm_obj_native_call(id, (int32)argv, ARGC)
|
||||
|
||||
typedef struct _obj_evt_cb {
|
||||
struct _obj_evt_cb *next;
|
||||
|
||||
wgl_obj_t obj;
|
||||
|
||||
wgl_event_cb_t event_cb;
|
||||
} obj_evt_cb_t;
|
||||
|
||||
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)
|
||||
{
|
||||
uint32 argv[1] = {0};
|
||||
argv[0] = (uint32)obj;
|
||||
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_DEL);
|
||||
return (wgl_res_t)argv[0];
|
||||
}
|
||||
|
||||
void wgl_obj_del_async(wgl_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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
uint32 argv[5] = {0};
|
||||
argv[0] = (uint32)obj;
|
||||
argv[1] = (uint32)base;
|
||||
argv[2] = align;
|
||||
argv[3] = x_mod;
|
||||
argv[4] = y_mod;
|
||||
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_ALIGN);
|
||||
}
|
||||
|
||||
wgl_event_cb_t wgl_obj_get_event_cb(const wgl_obj_t obj)
|
||||
{
|
||||
obj_evt_cb_t *obj_evt_cb = g_obj_evt_cb_list;
|
||||
while (obj_evt_cb != NULL) {
|
||||
if (obj_evt_cb->obj == obj) {
|
||||
return obj_evt_cb->event_cb;
|
||||
}
|
||||
obj_evt_cb = obj_evt_cb->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void wgl_obj_set_event_cb(wgl_obj_t obj, wgl_event_cb_t event_cb)
|
||||
{
|
||||
obj_evt_cb_t *obj_evt_cb;
|
||||
uint32 argv[1] = {0};
|
||||
|
||||
obj_evt_cb = g_obj_evt_cb_list;
|
||||
while (obj_evt_cb) {
|
||||
if (obj_evt_cb->obj == obj) {
|
||||
obj_evt_cb->event_cb = event_cb;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
obj_evt_cb = (obj_evt_cb_t *)malloc(sizeof(*obj_evt_cb));
|
||||
if (obj_evt_cb == NULL)
|
||||
return;
|
||||
|
||||
memset(obj_evt_cb, 0, sizeof(*obj_evt_cb));
|
||||
obj_evt_cb->obj = obj;
|
||||
obj_evt_cb->event_cb = event_cb;
|
||||
|
||||
if (g_obj_evt_cb_list != NULL) {
|
||||
obj_evt_cb->next = g_obj_evt_cb_list;
|
||||
g_obj_evt_cb_list = obj_evt_cb;
|
||||
} else {
|
||||
g_obj_evt_cb_list = obj_evt_cb;
|
||||
}
|
||||
|
||||
argv[0] = (uint32)obj;
|
||||
CALL_OBJ_NATIVE_FUNC(OBJ_FUNC_ID_SET_EVT_CB);
|
||||
}
|
||||
|
||||
void on_widget_event(wgl_obj_t obj, wgl_event_t event)
|
||||
{
|
||||
obj_evt_cb_t *obj_evt_cb = g_obj_evt_cb_list;
|
||||
|
||||
while (obj_evt_cb != NULL) {
|
||||
if (obj_evt_cb->obj == obj) {
|
||||
obj_evt_cb->event_cb(obj, event);
|
||||
return;
|
||||
}
|
||||
obj_evt_cb = obj_evt_cb->next;
|
||||
}
|
||||
}
|
||||
37
core/iwasm/lib/app-libs/extension/gui/wgl.h
Normal file
37
core/iwasm/lib/app-libs/extension/gui/wgl.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef WAMR_GRAPHIC_LIBRARY_H
|
||||
#define WAMR_GRAPHIC_LIBRARY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "wgl_shared_utils.h" /* shared types between app and native */
|
||||
|
||||
#include "inc/wgl_types.h"
|
||||
#include "inc/wgl_obj.h"
|
||||
#include "inc/wgl_btn.h"
|
||||
#include "inc/wgl_cb.h"
|
||||
#include "inc/wgl_label.h"
|
||||
#include "inc/wgl_list.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WAMR_GRAPHIC_LIBRARY_H */
|
||||
Reference in New Issue
Block a user