mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
vletter draw optimited, LV_UPSCALE_STYLE and LV_STYLE_MULT removed and replaced with LV_DOWNSCALE
This commit is contained in:
parent
f758c4b25c
commit
7636c5d97b
@ -7,6 +7,9 @@
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0
|
||||
|
||||
#include "lvgl/lv_misc/anim.h"
|
||||
|
||||
/*********************
|
||||
@ -47,6 +50,7 @@ static lv_obj_t * app_scr;
|
||||
static lv_obj_t * menuh; /*Holder of timg_bubbleshe menu on the top*/
|
||||
static lv_obj_t * app_btn; /*The "Apps" button on the menu*/
|
||||
static lv_obj_t * sys_apph; /*Holder of the system app. buttons*/
|
||||
static lv_obj_t * clock; /*Clock on the menu bar (right top)*/
|
||||
static lv_obj_t * app_list;
|
||||
static lv_obj_t * sc_page;
|
||||
|
||||
@ -125,9 +129,18 @@ void lv_app_init(void)
|
||||
lv_btn_set_rel_action(app_btn, lv_app_menu_rel_action);
|
||||
lv_obj_t * app_label = lv_label_create(app_btn, NULL);
|
||||
lv_obj_set_style(app_label, &app_style.menu_btn_label_style);
|
||||
lv_obj_set_pos(app_btn, 0, 0);
|
||||
lv_label_set_text(app_label, "Apps");
|
||||
lv_obj_set_pos(app_btn, 0, 0);
|
||||
|
||||
sys_apph = lv_rect_create(menuh, NULL);
|
||||
lv_rect_set_layout(sys_apph, LV_RECT_LAYOUT_ROW_M);
|
||||
lv_rect_set_fit(sys_apph, true, false);
|
||||
lv_obj_set_height(sys_apph, app_style.menu_h);
|
||||
lv_obj_set_style(sys_apph, lv_rects_get(LV_RECTS_TRANSP, NULL));
|
||||
clock = lv_label_create(sys_apph, NULL);
|
||||
lv_obj_set_style(clock, &app_style.menu_btn_label_style);
|
||||
lv_label_set_text(clock, "20:17");
|
||||
lv_obj_align(sys_apph, NULL, LV_ALIGN_IN_RIGHT_MID, 0, 0);
|
||||
lv_app_refr_style();
|
||||
|
||||
|
||||
@ -177,13 +190,16 @@ void lv_app_close(lv_app_inst_t * app)
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish an event.
|
||||
* @param app pointer to an application which publishes the event
|
||||
* @param event an event from 'lv_app_event_t' enum
|
||||
* Send data to other applications
|
||||
* @param app_send pointer to the application which is sending the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param len length of 'data' in bytes
|
||||
* @return number application which were received the message
|
||||
*/
|
||||
void lv_app_event_send(lv_app_inst_t * app, lv_app_event_t event)
|
||||
uint16_t lv_app_com_send(lv_app_inst_t * app_send, lv_app_com_type_t type , void * data, uint32_t len)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -211,7 +227,7 @@ lv_obj_t * lv_app_sc_open(lv_app_inst_t * app)
|
||||
|
||||
app->sc_title = lv_label_create(app->sc, NULL);
|
||||
lv_obj_set_style(app->sc_title, &app_style.sc_title_style);
|
||||
lv_label_set_long_mode(app->sc_title, LV_LABEL_LONG_SCROLL);
|
||||
//lv_label_set_long_mode(app->sc_title, LV_LABEL_LONG_SCROLL);
|
||||
lv_label_set_text(app->sc_title, app->name);
|
||||
lv_obj_align_us(app->sc_title, NULL, LV_ALIGN_IN_TOP_MID, 0, app_style.sc_title_margin);
|
||||
|
||||
@ -264,6 +280,9 @@ lv_obj_t * lv_app_win_open(lv_app_inst_t * app)
|
||||
lv_win_add_ctrl_btn(app->win, "U:/icon_down", lv_app_win_minim_action);
|
||||
lv_win_add_ctrl_btn(app->win, "U:/icon_close", lv_app_win_close_action);
|
||||
|
||||
app->win_data = dm_alloc(app->dsc->win_data_size);
|
||||
app->dsc->win_open(app, app->win);
|
||||
|
||||
return app->win;
|
||||
}
|
||||
|
||||
@ -330,6 +349,29 @@ const lv_app_dsc_t * lv_app_get_dsc(const char * name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the list of the running applications. (Get he next element)
|
||||
* @param prev the previous application (at the first call give NULL to get the first application)
|
||||
* @param dsc pointer to an application descriptor to filer the applications (NULL to do not filter)
|
||||
* @return pointer to the next running application or NULL if no more
|
||||
*/
|
||||
lv_app_inst_t * lv_app_get_next_app(lv_app_inst_t * prev, lv_app_dsc_t * dsc)
|
||||
{
|
||||
lv_app_inst_t * next;
|
||||
|
||||
while(1) {
|
||||
if(prev == NULL) next = ll_get_head(&app_inst_ll);
|
||||
else next = ll_get_next(&app_inst_ll, prev);
|
||||
if(next == NULL) break;
|
||||
|
||||
if(next->dsc == dsc || dsc == NULL) return next;
|
||||
|
||||
};
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
lv_app_style_t * lv_app_get_style(void)
|
||||
{
|
||||
return &app_style;
|
||||
@ -349,6 +391,7 @@ static lv_action_res_t lv_app_menu_rel_action(lv_obj_t * app_btn, lv_dispi_t * d
|
||||
/*Create the app. list*/
|
||||
else {
|
||||
app_list = lv_list_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_hidden(app_list, true);
|
||||
lv_obj_set_style(app_list, &app_style.app_list_style);
|
||||
lv_obj_set_opa(app_list, app_style.menu_opa);
|
||||
lv_obj_set_size(app_list, app_style.app_list_w, app_style.app_list_h);
|
||||
@ -386,6 +429,7 @@ static lv_action_res_t lv_app_menu_rel_action(lv_obj_t * app_btn, lv_dispi_t * d
|
||||
lv_obj_set_opa(elem, app_style.menu_btn_opa);
|
||||
|
||||
}
|
||||
lv_obj_set_hidden(app_list, false);
|
||||
}
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
@ -394,6 +438,10 @@ static lv_action_res_t lv_app_menu_elem_rel_action(lv_obj_t * app_elem_btn, lv_d
|
||||
{
|
||||
lv_app_dsc_t * dsc = lv_obj_get_free_p(app_elem_btn);
|
||||
|
||||
/*Close the app list*/
|
||||
lv_obj_del(app_list);
|
||||
app_list = NULL;
|
||||
|
||||
lv_app_inst_t * app = lv_app_run(dsc, "");
|
||||
lv_app_sc_open(app);
|
||||
|
||||
@ -401,9 +449,6 @@ static lv_action_res_t lv_app_menu_elem_rel_action(lv_obj_t * app_elem_btn, lv_d
|
||||
lv_obj_anim(app->sc, LV_ANIM_FADE | ANIM_IN, LV_APP_ANIM_SC, 0, NULL);
|
||||
#endif
|
||||
|
||||
/*Close the app list*/
|
||||
lv_obj_del(app_list);
|
||||
app_list = NULL;
|
||||
|
||||
return LV_ACTION_RES_INV;
|
||||
}
|
||||
@ -447,8 +492,6 @@ static lv_action_res_t lv_app_sc_rel_action(lv_obj_t * sc, lv_dispi_t * dispi)
|
||||
lv_app_inst_t * app = lv_obj_get_free_p(sc);
|
||||
lv_app_win_open(app);
|
||||
|
||||
app->dsc->win_open(app, app->win);
|
||||
|
||||
/*Make an animation on window open*/
|
||||
#if LV_APP_ANIM_WIN != 0 && LV_APP_ANIM_LEVEL != 0
|
||||
|
||||
@ -656,11 +699,6 @@ static void lv_app_init_style(void)
|
||||
app_style.app_list_h = (2 * LV_VER_RES) / 3;
|
||||
app_style.sc_title_margin = 2 * LV_DOWNSCALE;
|
||||
|
||||
/*Fonts*/
|
||||
app_style.font_small = FONT_DEJAVU_20;
|
||||
app_style.font_medium = FONT_DEJAVU_30;
|
||||
app_style.font_large = FONT_DEJAVU_40;
|
||||
|
||||
/*Opacity*/
|
||||
app_style.menu_opa = OPA_80;
|
||||
app_style.menu_btn_opa = OPA_50;
|
||||
@ -688,7 +726,7 @@ static void lv_app_init_style(void)
|
||||
app_style.menu_btn_style.gcolor[LV_BTN_STATE_PR] = COLOR_GRAY;
|
||||
|
||||
lv_labels_get(LV_LABELS_BTN,&app_style.menu_btn_label_style);
|
||||
app_style.menu_btn_label_style.font = app_style.font_large;
|
||||
app_style.menu_btn_label_style.font = LV_APP_FONT_LARGE;
|
||||
app_style.menu_btn_label_style.objs.color = COLOR_MAKE(0xd0, 0xe0, 0xf0);
|
||||
|
||||
lv_imgs_get(LV_IMGS_DEF,&app_style.menu_btn_img_style);
|
||||
@ -736,7 +774,7 @@ static void lv_app_init_style(void)
|
||||
app_style.sc_style.rects.bwidth = 1 * LV_DOWNSCALE;
|
||||
|
||||
lv_labels_get(LV_LABELS_DEF,&app_style.sc_title_style);
|
||||
app_style.sc_title_style.font = app_style.font_small;
|
||||
app_style.sc_title_style.font = LV_APP_FONT_SMALL;
|
||||
app_style.sc_title_style.objs.color = COLOR_MAKE(0x20, 0x30, 0x40);
|
||||
app_style.sc_title_style.mid = 1;
|
||||
|
||||
@ -758,4 +796,6 @@ static void lv_app_init_style(void)
|
||||
app_style.win_style.content.scrable_rects.objs.transp = 1;
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0*/
|
||||
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
*********************/
|
||||
#include "lvgl/lvgl.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@ -32,13 +34,12 @@ typedef enum
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_APP_EVENT_OPEN,
|
||||
LV_APP_EVENT_CLOSE,
|
||||
LV_APP_EVENT_SC_OPENED,
|
||||
LV_APP_EVENT_SC_CLOSED,
|
||||
LV_APP_EVENT_WIN_OPENED,
|
||||
LV_APP_EVENT_WIN_CLOSED,
|
||||
}lv_app_event_t;
|
||||
LV_APP_COM_TYPE_STR, /*String data to process*/
|
||||
LV_APP_COM_TYPE_BIN, /*Binary data as 'int32_t' array*/
|
||||
LV_APP_COM_TYPE_SYS, /*System level event*/
|
||||
LV_APP_COM_TYPE_LOG, /*String about an event to log*/
|
||||
LV_APP_COM_TYPE_NOTE, /*String to display to the user as a notification*/
|
||||
}lv_app_com_type_t;
|
||||
|
||||
struct __LV_APP_DSC_T;
|
||||
|
||||
@ -60,7 +61,7 @@ typedef struct __LV_APP_DSC_T
|
||||
lv_app_mode_t mode;
|
||||
void (*app_run)(lv_app_inst_t *, const char *);
|
||||
void (*app_close) (lv_app_inst_t *);
|
||||
void (*event_read) (lv_app_inst_t *, lv_app_event_t);
|
||||
void (*com_rec) (lv_app_inst_t *, lv_app_inst_t *, lv_app_com_type_t, void *, uint32_t);
|
||||
void (*sc_open) (lv_app_inst_t *, lv_obj_t *);
|
||||
void (*sc_close) (lv_app_inst_t *);
|
||||
void (*win_open) (lv_app_inst_t *, lv_obj_t *);
|
||||
@ -89,10 +90,6 @@ typedef struct {
|
||||
cord_t app_list_w;
|
||||
cord_t app_list_h;
|
||||
cord_t sc_title_margin;
|
||||
|
||||
font_types_t font_small;
|
||||
font_types_t font_medium;
|
||||
font_types_t font_large;
|
||||
}lv_app_style_t;
|
||||
|
||||
|
||||
@ -102,7 +99,7 @@ typedef struct {
|
||||
void lv_app_init(void);
|
||||
lv_app_inst_t * lv_app_run(const lv_app_dsc_t * app_dsc, const char * cstr);
|
||||
void lv_app_close(lv_app_inst_t * app);
|
||||
void lv_app_event_send(lv_app_inst_t * app, lv_app_event_t event);
|
||||
uint16_t lv_app_com_send(lv_app_inst_t * app_send, lv_app_com_type_t type , void * data, uint32_t len);
|
||||
lv_obj_t * lv_app_sc_open(lv_app_inst_t * app);
|
||||
void lv_app_sc_close(lv_app_inst_t * app);
|
||||
lv_obj_t * lv_app_win_open(lv_app_inst_t * app);
|
||||
@ -114,10 +111,14 @@ lv_app_style_t * lv_app_get_style(void);
|
||||
void lv_app_rename(lv_app_inst_t * app, const char * name);
|
||||
void lv_app_refr_style(void);
|
||||
|
||||
lv_app_inst_t * lv_app_get_next_app(lv_app_inst_t * prev, lv_app_dsc_t * dsc);
|
||||
|
||||
const lv_app_dsc_t * lv_app_example_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
#endif /*LV_APP_ENABLE != 0*/
|
||||
|
||||
#endif /*LV_APP_H*/
|
||||
|
@ -6,7 +6,9 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <lvgl/lv_app/lv_app_sup.h>
|
||||
#include "lv_app_sup.h"
|
||||
#if LV_APP_ENABLE != 0
|
||||
|
||||
#include "../lv_objx/lv_btnm.h"
|
||||
#include "../lv_objx/lv_ta.h"
|
||||
|
||||
@ -30,14 +32,14 @@ static lv_obj_t * kb_btnm;
|
||||
static lv_obj_t * kb_win;
|
||||
static lv_obj_t * kb_ta;
|
||||
static const char * kb_map_lc[] = {
|
||||
"\0061#", "\004q", "\004w", "\004e", "\004r", "\004t", "\004y", "\004u", "\004i", "\004o", "\004p", "\010Del", "\n",
|
||||
"\0051#", "\004q", "\004w", "\004e", "\004r", "\004t", "\004y", "\004u", "\004i", "\004o", "\004p", "\007Del", "\n",
|
||||
"\007ABC", "\004a", "\004s", "\004d", "\004f", "\004g", "\004h", "\004j", "\004k", "\004l", "\010Enter", "\n",
|
||||
"*", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ";", "\n",
|
||||
"\002Hide", "\002Left", "\006 ", "\002Right", "\002Ok", ""
|
||||
};
|
||||
|
||||
static const char * kb_map_uc[] = {
|
||||
"\0061#", "\004Q", "\004W", "\004E", "\004R", "\004T", "\004Y", "\004U", "\004I", "\004O", "\004P", "\010Del", "\n",
|
||||
"\0051#", "\004Q", "\004W", "\004E", "\004R", "\004T", "\004Y", "\004U", "\004I", "\004O", "\004P", "\007Del", "\n",
|
||||
"\007abc", "\004A", "\004S", "\004D", "\004F", "\004G", "\004H", "\004J", "\004K", "\004L", "\010Enter", "\n",
|
||||
"*", "/", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ";", "\n",
|
||||
"\002Hide", "\002Left", "\006 ", "\002Right", "\002Ok", ""
|
||||
@ -79,6 +81,7 @@ void lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t
|
||||
kb_btnms.rects.opad = 4 + LV_DOWNSCALE;
|
||||
kb_btnms.rects.vpad = 3 + LV_DOWNSCALE;
|
||||
kb_btnms.rects.hpad = 3 + LV_DOWNSCALE;
|
||||
kb_btnms.rects.round = 0;
|
||||
kb_inited = true;
|
||||
}
|
||||
|
||||
@ -94,10 +97,16 @@ void lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t
|
||||
kb_btnm = lv_btnm_create(lv_scr_act(), NULL);
|
||||
lv_obj_set_size(kb_btnm, LV_HOR_RES, LV_VER_RES / 2);
|
||||
lv_obj_align(kb_btnm, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||
lv_obj_set_style(kb_btnm, &kb_btnms);
|
||||
lv_btnm_set_cb(kb_btnm, lv_app_kb_action);
|
||||
if(mode & LV_APP_KB_MODE_TXT) lv_btnm_set_map(kb_btnm, kb_map_lc);
|
||||
else if(mode & LV_APP_KB_MODE_NUM) lv_btnm_set_map(kb_btnm, kb_map_num);
|
||||
if(mode & LV_APP_KB_MODE_TXT) {
|
||||
kb_btnms.labels.font = LV_APP_FONT_MEDIUM;
|
||||
lv_btnm_set_map(kb_btnm, kb_map_lc);
|
||||
}
|
||||
else if(mode & LV_APP_KB_MODE_NUM) {
|
||||
kb_btnms.labels.font = LV_APP_FONT_LARGE;
|
||||
lv_btnm_set_map(kb_btnm, kb_map_num);
|
||||
}
|
||||
lv_obj_set_style(kb_btnm, &kb_btnms);
|
||||
|
||||
kb_win = lv_app_get_win_from_obj(kb_ta);
|
||||
lv_obj_set_height(kb_win, LV_VER_RES / 2);
|
||||
@ -140,63 +149,74 @@ void lv_app_kb_close(bool ok)
|
||||
kb_ta = NULL;
|
||||
}
|
||||
|
||||
static lv_action_res_t lv_app_kb_action(lv_obj_t * btnm, uint16_t i)
|
||||
{
|
||||
const char ** map = lv_btnm_get_map(btnm);
|
||||
const char * txt = map[i];
|
||||
|
||||
if(txt[0] <= '\011') txt++;
|
||||
|
||||
if(strcmp(txt, "abc") == 0) {
|
||||
lv_btnm_set_map(btnm, kb_map_lc);
|
||||
} else if(strcmp(txt, "ABC") == 0) {
|
||||
lv_btnm_set_map(btnm, kb_map_uc);
|
||||
} else if(strcmp(txt, "1#") == 0) {
|
||||
lv_btnm_set_map(btnm, kb_map_spec);
|
||||
} else if(strcmp(txt, "Enter") == 0) {
|
||||
lv_ta_add_char(kb_ta, '\n');
|
||||
} else if(strcmp(txt, "Left") == 0) {
|
||||
lv_ta_cursor_left(kb_ta);
|
||||
} else if(strcmp(txt, "Right") == 0) {
|
||||
lv_ta_cursor_right(kb_ta);
|
||||
} else if(strcmp(txt, "Del") == 0) {
|
||||
lv_ta_del(kb_ta);
|
||||
} else if(strcmp(txt, "+/-") == 0) {
|
||||
uint16_t cur = lv_ta_get_cursor_pos(kb_ta);
|
||||
const char * ta_txt = lv_ta_get_txt(kb_ta);
|
||||
if(ta_txt[0] == '-') {
|
||||
lv_ta_set_cursor_pos(kb_ta, 1);
|
||||
lv_ta_del(kb_ta);
|
||||
lv_ta_add_char(kb_ta, '+');
|
||||
lv_ta_set_cursor_pos(kb_ta, cur);
|
||||
} else if(ta_txt[0] == '+') {
|
||||
lv_ta_set_cursor_pos(kb_ta, 1);
|
||||
lv_ta_del(kb_ta);
|
||||
lv_ta_add_char(kb_ta, '-');
|
||||
lv_ta_set_cursor_pos(kb_ta, cur);
|
||||
} else {
|
||||
lv_ta_set_cursor_pos(kb_ta, 0);
|
||||
lv_ta_add_char(kb_ta, '-');
|
||||
lv_ta_set_cursor_pos(kb_ta, cur + 1);
|
||||
}
|
||||
} else if(strcmp(txt, "Hide") == 0) {
|
||||
lv_app_kb_close(false);
|
||||
return LV_ACTION_RES_INV;
|
||||
} else if(strcmp(txt, "Ok") == 0) {
|
||||
lv_app_kb_close(true);
|
||||
return LV_ACTION_RES_INV;
|
||||
} else {
|
||||
lv_ta_add_text(kb_ta, txt);
|
||||
}
|
||||
|
||||
#if LV_APP_ANIM_LEVEL != 0
|
||||
lv_page_focus(lv_win_get_content(kb_win), kb_ta, true);
|
||||
#else
|
||||
lv_page_focus(lv_win_get_content(kb_win), kb_ta, false);
|
||||
#endif
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Called when a button of 'kb_btnm' is released
|
||||
* @param btnm pointer to 'kb_btnm'
|
||||
* @param i the index of the released button from the current btnm map
|
||||
* @return LV_ACTION_RES_INV if the btnm is deleted else LV_ACTION_RES_OK
|
||||
*/
|
||||
static lv_action_res_t lv_app_kb_action(lv_obj_t * btnm, uint16_t i)
|
||||
{
|
||||
const char ** map = lv_btnm_get_map(btnm);
|
||||
const char * txt = map[i];
|
||||
|
||||
/*Ignore the unit size number of the text*/
|
||||
if(txt[0] <= '\011') txt++;
|
||||
|
||||
/*Do the corresponding action according to the text of the button*/
|
||||
if(strcmp(txt, "abc") == 0) {
|
||||
lv_btnm_set_map(btnm, kb_map_lc);
|
||||
} else if(strcmp(txt, "ABC") == 0) {
|
||||
lv_btnm_set_map(btnm, kb_map_uc);
|
||||
} else if(strcmp(txt, "1#") == 0) {
|
||||
lv_btnm_set_map(btnm, kb_map_spec);
|
||||
} else if(strcmp(txt, "Enter") == 0) {
|
||||
lv_ta_add_char(kb_ta, '\n');
|
||||
} else if(strcmp(txt, "Left") == 0) {
|
||||
lv_ta_cursor_left(kb_ta);
|
||||
} else if(strcmp(txt, "Right") == 0) {
|
||||
lv_ta_cursor_right(kb_ta);
|
||||
} else if(strcmp(txt, "Del") == 0) {
|
||||
lv_ta_del(kb_ta);
|
||||
} else if(strcmp(txt, "+/-") == 0) {
|
||||
uint16_t cur = lv_ta_get_cursor_pos(kb_ta);
|
||||
const char * ta_txt = lv_ta_get_txt(kb_ta);
|
||||
if(ta_txt[0] == '-') {
|
||||
lv_ta_set_cursor_pos(kb_ta, 1);
|
||||
lv_ta_del(kb_ta);
|
||||
lv_ta_add_char(kb_ta, '+');
|
||||
lv_ta_set_cursor_pos(kb_ta, cur);
|
||||
} else if(ta_txt[0] == '+') {
|
||||
lv_ta_set_cursor_pos(kb_ta, 1);
|
||||
lv_ta_del(kb_ta);
|
||||
lv_ta_add_char(kb_ta, '-');
|
||||
lv_ta_set_cursor_pos(kb_ta, cur);
|
||||
} else {
|
||||
lv_ta_set_cursor_pos(kb_ta, 0);
|
||||
lv_ta_add_char(kb_ta, '-');
|
||||
lv_ta_set_cursor_pos(kb_ta, cur + 1);
|
||||
}
|
||||
} else if(strcmp(txt, "Hide") == 0) {
|
||||
lv_app_kb_close(false);
|
||||
return LV_ACTION_RES_INV;
|
||||
} else if(strcmp(txt, "Ok") == 0) {
|
||||
lv_app_kb_close(true);
|
||||
return LV_ACTION_RES_INV;
|
||||
} else {
|
||||
lv_ta_add_text(kb_ta, txt);
|
||||
}
|
||||
|
||||
#if LV_APP_ANIM_LEVEL != 0
|
||||
lv_page_focus(lv_win_get_content(kb_win), kb_ta, true);
|
||||
#else
|
||||
lv_page_focus(lv_win_get_content(kb_win), kb_ta, false);
|
||||
#endif
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0*/
|
||||
|
@ -10,6 +10,7 @@
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_app.h"
|
||||
#if LV_APP_ENABLE != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@ -33,5 +34,6 @@ void lv_app_kb_close(bool ok);
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
#endif /*LV_APP_ENABLE != 0*/
|
||||
|
||||
#endif /*LV_APP_SUP_H*/
|
||||
|
@ -6,8 +6,11 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <lvgl/lv_app/lv_app_sup.h>
|
||||
#include "lv_app_example.h"
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0
|
||||
|
||||
#include "../lv_app/lv_app_sup.h"
|
||||
#include "misc/os/ptask.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
@ -22,31 +25,33 @@
|
||||
typedef struct
|
||||
{
|
||||
const char * txt;
|
||||
}app_data_t;
|
||||
}my_app_data_t;
|
||||
|
||||
/*Application specific data a window of this application*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}win_data_t;
|
||||
}my_win_data_t;
|
||||
|
||||
/*Application specific data for a shortcut of this application*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}sc_data_t;
|
||||
lv_obj_t * label;
|
||||
}my_sc_data_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void my_app_run(lv_app_inst_t * app, const char * cstr);
|
||||
static void my_app_close(lv_app_inst_t * app);
|
||||
static void my_event_read(lv_app_inst_t * app, lv_app_event_t event);
|
||||
static void my_com_rec(lv_app_inst_t * app_rec, lv_app_inst_t * app_sender, lv_app_com_type_t type , void * data, uint32_t len);
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc);
|
||||
static void my_sc_close(lv_app_inst_t * app);
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win);
|
||||
static void my_win_close(lv_app_inst_t * app);
|
||||
|
||||
static void task(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
@ -56,14 +61,14 @@ static lv_app_dsc_t my_app_dsc =
|
||||
.mode = LV_APP_MODE_NONE,
|
||||
.app_run = my_app_run,
|
||||
.app_close = my_app_close,
|
||||
.event_read = my_event_read,
|
||||
.com_rec = my_com_rec,
|
||||
.win_open = my_win_open,
|
||||
.win_close = my_win_close,
|
||||
.sc_open = my_sc_open,
|
||||
.sc_close = my_sc_close,
|
||||
.app_data_size = sizeof(app_data_t),
|
||||
.sc_data_size = sizeof(sc_data_t),
|
||||
.win_data_size = sizeof(win_data_t),
|
||||
.app_data_size = sizeof(my_app_data_t),
|
||||
.sc_data_size = sizeof(my_sc_data_t),
|
||||
.win_data_size = sizeof(my_win_data_t),
|
||||
};
|
||||
|
||||
/**********************
|
||||
@ -76,6 +81,8 @@ static lv_app_dsc_t my_app_dsc =
|
||||
|
||||
const lv_app_dsc_t * lv_app_example_init(void)
|
||||
{
|
||||
ptask_create(task, 200, PTASK_PRIO_MID);
|
||||
|
||||
return &my_app_dsc;
|
||||
}
|
||||
|
||||
@ -97,7 +104,7 @@ static void my_app_run(lv_app_inst_t * app, const char * cstr)
|
||||
}
|
||||
|
||||
/*Initialize the application*/
|
||||
((app_data_t *)app->app_data)->txt = cstr; /*Save the create string*/
|
||||
((my_app_data_t *)app->app_data)->txt = cstr; /*Save the create string*/
|
||||
char buf[256];
|
||||
sprintf(buf,"%s - %s", my_app_dsc.name, cstr);
|
||||
lv_app_rename(app, buf);
|
||||
@ -115,13 +122,22 @@ static void my_app_close(lv_app_inst_t * app)
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish an event.
|
||||
* @param app pointer to an application which publishes the event
|
||||
* @param event an event from 'lv_app_event_t' enum
|
||||
* Read the data have been sent to this application
|
||||
* @param app_rec pointer to an application which is receiving the message
|
||||
* @param app_send pointer to an application which sent the message
|
||||
* @param type type of data from 'lv_app_com_type_t' enum
|
||||
* @param data pointer to the sent data
|
||||
* @param len length of 'data' in bytes
|
||||
*/
|
||||
static void my_event_read(lv_app_inst_t * app, lv_app_event_t event)
|
||||
static void my_com_rec(lv_app_inst_t * app_rec, lv_app_inst_t * app_send,
|
||||
lv_app_com_type_t type , void * data, uint32_t len)
|
||||
{
|
||||
if(type == LV_APP_COM_TYPE_STR) { /*data: string*/
|
||||
|
||||
}
|
||||
else if(type == LV_APP_COM_TYPE_BIN) { /*data: array of 'int32_t' */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,11 +148,12 @@ static void my_event_read(lv_app_inst_t * app, lv_app_event_t event)
|
||||
*/
|
||||
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
|
||||
{
|
||||
lv_obj_t * label;
|
||||
label = lv_label_create(sc, NULL);
|
||||
lv_label_set_text(label, ((app_data_t *)app->app_data)->txt);
|
||||
lv_obj_set_style(label, lv_labels_get(LV_LABELS_BTN, NULL));
|
||||
lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
|
||||
sc_data->label = lv_label_create(sc, NULL);
|
||||
lv_label_set_text(sc_data->label, ((my_app_data_t *)app->app_data)->txt);
|
||||
lv_obj_set_style(sc_data->label, lv_labels_get(LV_LABELS_DEF, NULL));
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,24 +174,23 @@ lv_action_res_t kb_open(lv_obj_t * ta, lv_dispi_t * dispi);
|
||||
*/
|
||||
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
|
||||
{
|
||||
my_sc_data_t * win_data = app->win_data;
|
||||
|
||||
|
||||
lv_obj_t * label;
|
||||
label = lv_label_create(win, NULL);
|
||||
lv_label_set_text(label, ((app_data_t *)app->app_data)->txt);
|
||||
win_data->label = lv_label_create(win, NULL);
|
||||
lv_label_set_text(win_data->label, ((my_app_data_t *)app->app_data)->txt);
|
||||
|
||||
|
||||
lv_obj_t * ta;
|
||||
ta = lv_ta_create(win, NULL);
|
||||
lv_obj_set_size_us(ta, 200, 100);
|
||||
lv_obj_set_pos_us(ta, 20, 200);
|
||||
// lv_rect_set_fit(ta, false, true);
|
||||
lv_page_set_rel_action(ta, kb_open);
|
||||
}
|
||||
|
||||
lv_action_res_t kb_open(lv_obj_t * ta, lv_dispi_t * dispi)
|
||||
{
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_NUM, NULL, NULL);
|
||||
lv_app_kb_open(ta, LV_APP_KB_MODE_TXT, NULL, NULL);
|
||||
return LV_ACTION_RES_OK;
|
||||
}
|
||||
|
||||
@ -188,3 +204,38 @@ static void my_win_close(lv_app_inst_t * app)
|
||||
}
|
||||
|
||||
|
||||
static void task(void)
|
||||
{
|
||||
|
||||
return;
|
||||
dm_defrag();
|
||||
|
||||
dm_mon_t mon;
|
||||
dm_monitor(&mon);
|
||||
|
||||
lv_app_inst_t * app;
|
||||
app = lv_app_get_next_app(NULL, &my_app_dsc);
|
||||
|
||||
while(app != NULL) {
|
||||
char buf[256];
|
||||
sprintf(buf, "Mem. total: %d\nMem. free: %d (%d)\nFrag: %d%%",
|
||||
DM_MEM_SIZE, mon.size_free, mon.size_free * 100 / DM_MEM_SIZE, mon.pct_frag);
|
||||
|
||||
if(app->sc_data != NULL) {
|
||||
my_sc_data_t * sc_data = app->sc_data;
|
||||
lv_label_set_text(sc_data->label, buf);
|
||||
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
if(app->win_data != NULL) {
|
||||
my_sc_data_t * win_data = app->win_data;
|
||||
lv_label_set_text(win_data->label, buf);
|
||||
// lv_obj_align(win_data->label, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
|
||||
}
|
||||
app = lv_app_get_next_app(app, &my_app_dsc);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
|
@ -11,6 +11,8 @@
|
||||
*********************/
|
||||
#include "lvgl/lv_app/lv_app.h"
|
||||
|
||||
#if LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
@ -18,6 +20,10 @@
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
}lv_app_example_conf_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
@ -27,4 +33,6 @@
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/
|
||||
|
||||
#endif /* LV_APP_EXAMPLE */
|
||||
|
@ -113,27 +113,87 @@ void lv_vletter(const point_t * pos_p, const area_t * mask_p,
|
||||
color_t color, opa_t opa)
|
||||
{
|
||||
if(font_p == NULL) return;
|
||||
|
||||
uint8_t w = font_get_width(font_p, letter);
|
||||
uint8_t h = font_get_height(font_p);
|
||||
|
||||
uint8_t letter_w = font_get_width(font_p, letter);
|
||||
uint8_t letter_h = font_get_height(font_p);
|
||||
|
||||
const uint8_t * map_p = font_get_bitmap(font_p, letter);
|
||||
|
||||
if(map_p == NULL) return;
|
||||
|
||||
/*If the letter is completely out of mask don't draw it */
|
||||
if(pos_p->x + w < mask_p->x1 || pos_p->x > mask_p->x2 ||
|
||||
pos_p->y + h < mask_p->y1 || pos_p->y > mask_p->y2) return;
|
||||
if(pos_p->x + letter_w < mask_p->x1 || pos_p->x > mask_p->x2 ||
|
||||
pos_p->y + letter_h < mask_p->y1 || pos_p->y > mask_p->y2) return;
|
||||
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
cord_t vdb_width = area_get_width(&vdb_p->vdb_area);
|
||||
color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
cord_t col, row;
|
||||
point_t act_point;
|
||||
uint8_t col_bit;
|
||||
uint8_t col_byte_cnt;
|
||||
|
||||
for(row = 0; row < h; row ++) {
|
||||
for(col = 0; col < w; col ++) {
|
||||
act_point.x = pos_p->x + col;
|
||||
act_point.y = pos_p->y + row;
|
||||
cord_t col_start = pos_p->x >= mask_p->x1 ? 0 : mask_p->x1 - pos_p->x;
|
||||
cord_t col_end = pos_p->x + letter_w <= mask_p->x2 ? letter_w : mask_p->x2 - pos_p->x + 1;
|
||||
cord_t row_start = pos_p->y >= mask_p->y1 ? 0 : mask_p->y1 - pos_p->y;
|
||||
cord_t row_end = pos_p->y + letter_h <= mask_p->y2 ? letter_h : mask_p->y2 - pos_p->y + 1;
|
||||
|
||||
if(lv_vletter_get_px(font_p, letter, col, row)) {
|
||||
lv_put_vpx(&act_point, mask_p, color, opa);
|
||||
/*Set a pointer on VDB to the first pixel of the letter*/
|
||||
vdb_buf_tmp += ((pos_p->y - vdb_p->vdb_area.y1) * vdb_width)
|
||||
+ pos_p->x - vdb_p->vdb_area.x1;
|
||||
|
||||
/*If the letter is partially out of mask the move there on VDB*/
|
||||
vdb_buf_tmp += (row_start * vdb_width) + col_start;
|
||||
|
||||
/*Move on the map too*/
|
||||
#if LV_UPSCALE_FONT == 0 || LV_DOWNSCALE == 1
|
||||
map_p += (row_start * font_p->width_byte) + (col_start>>3);
|
||||
#elif LV_DOWNSCALE == 2
|
||||
map_p += ((row_start >> 1) * font_p->width_byte) + ((col_start >> 1)>>3);
|
||||
#elif LV_DOWNSCALE == 4
|
||||
map_p += ((row_start >> 2) * font_p->width_byte) + ((col_start >> 2)>>3);
|
||||
#endif
|
||||
|
||||
for(row = row_start; row < row_end; row ++) {
|
||||
col_byte_cnt = 0;
|
||||
col_bit = 7 - ((col_start / 2) % 8);
|
||||
for(col = col_start; col < col_end; col ++) {
|
||||
|
||||
if((*map_p & (1 << col_bit)) != 0) {
|
||||
if(opa == OPA_COVER) *vdb_buf_tmp = color;
|
||||
else *vdb_buf_tmp = color_mix(color, *vdb_buf_tmp, opa);
|
||||
}
|
||||
vdb_buf_tmp++;
|
||||
|
||||
/*Use a col. more times depending on LV_UPSCALE_FONT*/
|
||||
#if LV_UPSCALE_FONT == 0 || LV_DOWNSCALE == 1
|
||||
/*Use all cols.*/
|
||||
#elif LV_DOWNSCALE == 2
|
||||
if((col & 0x01) == 0)
|
||||
#elif LV_DOWNSCALE == 4
|
||||
if((col & 0x03) == 0)
|
||||
#endif
|
||||
{
|
||||
if(col_bit != 0) col_bit --;
|
||||
else {
|
||||
col_bit = 7;
|
||||
col_byte_cnt ++;
|
||||
map_p ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Use a row more times depending on LV_UPSCALE_FONT*/
|
||||
#if LV_UPSCALE_FONT == 0 || LV_DOWNSCALE == 1
|
||||
map_p += font_p->width_byte - col_byte_cnt;
|
||||
#elif LV_DOWNSCALE == 2
|
||||
if((row & 0x01) == 0) map_p += font_p->width_byte - col_byte_cnt; /*Next row in the map*/
|
||||
else map_p -= col_byte_cnt; /*Reset the row*/
|
||||
#elif LV_DOWNSCALE == 4
|
||||
if((row & 0x03) == 0) map_p += font_p->width_byte - col_byte_cnt; /*Next row in the map*/
|
||||
else map_p -= col_byte_cnt; /*Reset the row*/
|
||||
#endif
|
||||
|
||||
vdb_buf_tmp += vdb_width - (col_end - col_start); /*Next row in VDB*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,85 +372,6 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p,
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Put a pixel into the Virtual Dispaly Buffer
|
||||
* @param x x coordinate of the pixel
|
||||
* @param y y coordinate of the pixel
|
||||
* @param mask_p the pixel will be drawn on this area
|
||||
* @param color color of the pixel
|
||||
* @param opa opacity of the pixel
|
||||
*/
|
||||
static void lv_put_vpx(point_t * point_p, const area_t * mask_p,
|
||||
color_t color, opa_t opa)
|
||||
{
|
||||
if(opa == OPA_TRANSP) return;
|
||||
|
||||
bool point_ok;
|
||||
lv_vdb_t * vdb_p = lv_vdb_get();
|
||||
|
||||
/*The point is on vdb?*/
|
||||
point_ok = area_is_point_on(mask_p, point_p);
|
||||
|
||||
/*If there are common part of the three area then draw to the vdb*/
|
||||
if(point_ok == false) return;
|
||||
point_t vdb_rel_point; /*Stores relative coordinates on vdb*/
|
||||
vdb_rel_point.x = point_p->x - vdb_p->vdb_area.x1;
|
||||
vdb_rel_point.y = point_p->y - vdb_p->vdb_area.y1;
|
||||
|
||||
color_t * vdb_buf_tmp = vdb_p->buf;
|
||||
uint32_t vdb_width = vdb_p->vdb_area.x2 - vdb_p->vdb_area.x1 + 1;
|
||||
|
||||
/*Move the vdb_tmp to the point*/
|
||||
vdb_buf_tmp += vdb_width * vdb_rel_point.y + vdb_rel_point.x;
|
||||
|
||||
if(opa == OPA_COVER) *vdb_buf_tmp = color;
|
||||
else *vdb_buf_tmp = color_mix(color, *vdb_buf_tmp, opa);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pixel from a letter
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @param x x coordinate of the pixel to get
|
||||
* @param y y coordinate of the pixel to get
|
||||
* @return true: pixel is set, false: pixel is clear
|
||||
*/
|
||||
static bool lv_vletter_get_px(const font_t * font_p, uint8_t letter, cord_t x, cord_t y)
|
||||
{
|
||||
uint8_t w = font_get_width(font_p, letter);
|
||||
uint8_t h = font_get_height(font_p);
|
||||
const uint8_t * map_p = font_get_bitmap(font_p, letter);
|
||||
|
||||
if(map_p == NULL) return NULL;
|
||||
|
||||
if(x < 0) x = 0;
|
||||
if(y < 0) x = 0;
|
||||
if(x >= w) x = w - 1;
|
||||
if(y >= h) y = h - 1;
|
||||
|
||||
#if LV_UPSCALE_FONT != 0
|
||||
#if LV_DOWNSCALE == 1
|
||||
/*Do nothing*/
|
||||
#elif LV_DOWNSCALE == 2
|
||||
x = x >> 1;
|
||||
y = y >> 1;
|
||||
#elif LV_DOWNSCALE == 4
|
||||
x = x >> 2;
|
||||
y = y >> 2;
|
||||
#else
|
||||
#error "LV: not supported LV_DOWNSCALE value"
|
||||
#endif
|
||||
#endif /*LV_UPSCALE_FONT == 0*/
|
||||
|
||||
map_p += (uint32_t)y * font_p->width_byte; /*Go to the corresponding row of the map*/
|
||||
map_p += (x >> 3); /*Go to he corresponding col of the map*/
|
||||
|
||||
/*Get the corresponding col within a byte*/
|
||||
uint8_t map_byte = *map_p;
|
||||
uint8_t col_sub = 7 - (x % 8);
|
||||
if((map_byte & (1 << col_sub)) == 0) return false;
|
||||
else return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1958,7 +1958,7 @@ static const uint8_t dejavu_20_bitmaps[8960] =
|
||||
0x36, 0x00, // --OO-OO--.......
|
||||
0x22, 0x00, // --O---O--.......
|
||||
0x63, 0x00, // -OO---OO-.......
|
||||
0x10, 0x10, // O-------O.......
|
||||
0x80, 0x10, // O-------O.......
|
||||
0x00, 0x00, // ---------.......
|
||||
0x00, 0x00, // ---------.......
|
||||
0x00, 0x00, // ---------.......
|
||||
|
@ -249,7 +249,6 @@ static void dispi_proc_press(lv_dispi_t * dispi_p)
|
||||
/* The reset can be set in the signal function.
|
||||
* In case of reset query ignore the remaining parts.*/
|
||||
if(lv_dispi_reset_qry == false) {
|
||||
pr_obj->signal_f(pr_obj, LV_SIGNAL_PRESSING, dispi_p);
|
||||
dispi_p->act_obj = pr_obj; /*Save the pressed object*/
|
||||
dispi_p->last_obj = dispi_p->act_obj; /*Refresh the last_obj*/
|
||||
|
||||
@ -259,6 +258,8 @@ static void dispi_proc_press(lv_dispi_t * dispi_p)
|
||||
|
||||
/*If there is active object and it can be dragged run the drag*/
|
||||
if(dispi_p->act_obj != NULL) {
|
||||
dispi_p->act_obj->signal_f(dispi_p->act_obj, LV_SIGNAL_PRESSING, dispi_p);
|
||||
|
||||
dispi_drag(dispi_p);
|
||||
|
||||
/*If there is no drag then check for long press time*/
|
||||
|
@ -38,8 +38,8 @@ typedef struct
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LV_ACTION_RES_OK = 0,
|
||||
LV_ACTION_RES_INV = 0,
|
||||
LV_ACTION_RES_INV = 0,
|
||||
LV_ACTION_RES_OK,
|
||||
}lv_action_res_t;
|
||||
|
||||
typedef lv_action_res_t ( * lv_action_t) (struct __LV_OBJ_T * obj, lv_dispi_t * dispi);
|
||||
|
@ -35,6 +35,7 @@
|
||||
**********************/
|
||||
static void lv_obj_pos_child_refr(lv_obj_t * obj, cord_t x_diff, cord_t y_diff);
|
||||
static void lv_style_refr_core(void * style_p, lv_obj_t * obj);
|
||||
static void lv_obj_del_child(lv_obj_t * obj);
|
||||
static bool lv_obj_design(lv_obj_t * obj, const area_t * mask_p, lv_design_mode_t mode);
|
||||
|
||||
/**********************
|
||||
@ -95,6 +96,12 @@ void lv_init(void)
|
||||
/*Init the display input handling*/
|
||||
lv_dispi_init();
|
||||
#endif
|
||||
|
||||
/*Initialize the application level*/
|
||||
#if LV_APP_ENABLE != 0
|
||||
lv_app_init();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,6 +110,10 @@ void lv_init(void)
|
||||
*/
|
||||
void lv_obj_inv(lv_obj_t * obj)
|
||||
{
|
||||
|
||||
/*Do not invalidate hidden objects*/
|
||||
if(obj->hidden != 0) return;
|
||||
|
||||
/*Invalidate the object only if it belongs to the 'act_scr'*/
|
||||
lv_obj_t * act_scr_p = lv_scr_act();
|
||||
if(lv_obj_get_scr(obj) == act_scr_p) {
|
||||
@ -121,6 +132,10 @@ void lv_obj_inv(lv_obj_t * obj)
|
||||
/*Check through all parents*/
|
||||
while(par != NULL) {
|
||||
union_ok = area_union(&area_trunc, &area_trunc, &par->cords);
|
||||
|
||||
/*Do not invalidate hidden objects*/
|
||||
if(par->hidden != 0) union_ok = false;
|
||||
|
||||
if(union_ok == false) break; /*If no common parts with parent break;*/
|
||||
|
||||
par = lv_obj_get_parent(par);
|
||||
@ -290,7 +305,7 @@ void lv_obj_del(lv_obj_t * obj)
|
||||
i_next = ll_get_next(&(obj->child_ll), i);
|
||||
|
||||
/*Call the recursive del to the child too*/
|
||||
lv_obj_del(i);
|
||||
lv_obj_del_child(i);
|
||||
|
||||
/*Set i to the next node*/
|
||||
i = i_next;
|
||||
@ -877,7 +892,9 @@ void lv_obj_set_hidden(lv_obj_t * obj, bool en)
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
par->signal_f(par, LV_SIGNAL_CHILD_CHG, obj);
|
||||
|
||||
lv_obj_inv(obj);
|
||||
/*Invalidate the area because the hidden object are not invalidated*/
|
||||
if(en = false) lv_obj_inv(obj);
|
||||
else lv_inv_area(&obj->cords);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1481,4 +1498,43 @@ static void lv_style_refr_core(void * style_p, lv_obj_t * obj)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by 'lv_obj_del' to delete the children objects
|
||||
* @param obj pointer to an object (all of its children will be deleted)
|
||||
*/
|
||||
static void lv_obj_del_child(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * i;
|
||||
lv_obj_t * i_next;
|
||||
i = ll_get_head(&(obj->child_ll));
|
||||
while(i != NULL) {
|
||||
/*Get the next object before delete this*/
|
||||
i_next = ll_get_next(&(obj->child_ll), i);
|
||||
|
||||
/*Call the recursive del to the child too*/
|
||||
lv_obj_del_child(i);
|
||||
|
||||
/*Set i to the next node*/
|
||||
i = i_next;
|
||||
}
|
||||
|
||||
/*Remove the animations from this object*/
|
||||
anim_del(obj, NULL);
|
||||
|
||||
/*Remove the object from parent's children list*/
|
||||
lv_obj_t * par = lv_obj_get_parent(obj);
|
||||
|
||||
ll_rem(&(par->child_ll), obj);
|
||||
|
||||
/* All children deleted.
|
||||
* Now clean up the object specific data*/
|
||||
obj->signal_f(obj, LV_SIGNAL_CLEANUP, NULL);
|
||||
|
||||
/*Delete the base objects*/
|
||||
if(obj->ext != NULL) dm_free(obj->ext);
|
||||
if(obj->style_iso != 0) dm_free(obj->style_p);
|
||||
dm_free(obj); /*Free the object itself*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
111
lv_obj/lv_refr.c
111
lv_obj/lv_refr.c
@ -30,8 +30,8 @@ typedef struct
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void lv_refr_task(void);
|
||||
static void lv_refr_join_area(lv_join_t * area_a, uint32_t inv_num);
|
||||
static void lv_refr_areas(lv_join_t * area_a, uint32_t area_num);
|
||||
static void lv_refr_join_area(void);
|
||||
static void lv_refr_areas(void);
|
||||
#if LV_VDB_SIZE == 0
|
||||
static void lv_refr_area_no_vdb(const area_t * area_p);
|
||||
#else
|
||||
@ -45,8 +45,8 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
fifo_t fifo_inv;
|
||||
area_t fifo_inv_buf[LV_INV_FIFO_SIZE];
|
||||
lv_join_t inv_buf[LV_INV_FIFO_SIZE];
|
||||
uint16_t inv_buf_p;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -61,8 +61,9 @@ area_t fifo_inv_buf[LV_INV_FIFO_SIZE];
|
||||
*/
|
||||
void lv_refr_init(void)
|
||||
{
|
||||
fifo_init(&fifo_inv, fifo_inv_buf, sizeof(area_t), LV_INV_FIFO_SIZE);
|
||||
|
||||
inv_buf_p = 0;
|
||||
memset(inv_buf, 0, sizeof(inv_buf));
|
||||
|
||||
ptask_t* task;
|
||||
task = ptask_create(lv_refr_task, LV_REFR_PERIOD, PTASK_PRIO_MID);
|
||||
dm_assert(task);
|
||||
@ -101,16 +102,22 @@ void lv_inv_area(const area_t * area_p)
|
||||
com_area.x2 = com_area.x2 | 0x3;
|
||||
com_area.y2 = com_area.y2 | 0x3;
|
||||
#endif
|
||||
/*Save the area*/
|
||||
suc = fifo_push(&fifo_inv, &com_area);
|
||||
|
||||
/* There is no place for the new area
|
||||
* clear the fifo and add the whole screen*/
|
||||
if(suc == false)
|
||||
{
|
||||
fifo_clear(&fifo_inv);
|
||||
fifo_push(&fifo_inv, &scr_area);
|
||||
/*Save only if this area is not in one of the saved areas*/
|
||||
uint16_t i;
|
||||
for(i = 0; i < inv_buf_p; i++) {
|
||||
if(area_is_in(&com_area, &inv_buf[i].area) != false) return;
|
||||
}
|
||||
|
||||
|
||||
/*Save the area*/
|
||||
if(inv_buf_p < LV_INV_FIFO_SIZE) {
|
||||
area_cpy(&inv_buf[inv_buf_p].area,&com_area);
|
||||
} else {/*If no place for the area add the screen*/
|
||||
inv_buf_p = 0;
|
||||
area_cpy(&inv_buf[inv_buf_p].area,&scr_area);
|
||||
}
|
||||
inv_buf_p ++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,66 +130,50 @@ void lv_inv_area(const area_t * area_p)
|
||||
*/
|
||||
static void lv_refr_task(void)
|
||||
{
|
||||
lv_join_t area_tmp[LV_INV_FIFO_SIZE];
|
||||
lv_refr_join_area();
|
||||
|
||||
memset(area_tmp, 0, sizeof(area_tmp));
|
||||
|
||||
/*Read all data from the fifo_inv*/
|
||||
uint32_t inv_num;
|
||||
bool suc;
|
||||
for(inv_num = 0; inv_num < LV_INV_FIFO_SIZE; inv_num++)
|
||||
{
|
||||
suc = fifo_pop(&fifo_inv, &area_tmp[inv_num].area);
|
||||
|
||||
if(suc == false) /*Break id the fifo is empty*/
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
lv_refr_join_area(area_tmp, inv_num);
|
||||
|
||||
lv_refr_areas(area_tmp, inv_num);
|
||||
lv_refr_areas();
|
||||
|
||||
memset(inv_buf, 0, sizeof(inv_buf));
|
||||
inv_buf_p = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Join the areas which has got common parts
|
||||
* @param join_a an array of areas to join
|
||||
* @param inv_num item number of the array
|
||||
*/
|
||||
static void lv_refr_join_area(lv_join_t * area_a, uint32_t area_num)
|
||||
static void lv_refr_join_area(void)
|
||||
{
|
||||
uint32_t join_from;
|
||||
uint32_t join_in;
|
||||
area_t joined_area;
|
||||
for(join_in = 0; join_in < area_num; join_in++) {
|
||||
if(area_a[join_in].joined != 0) continue;
|
||||
for(join_in = 0; join_in < inv_buf_p; join_in++) {
|
||||
if(inv_buf[join_in].joined != 0) continue;
|
||||
|
||||
/*Check all areas to join them in 'join_in'*/
|
||||
for(join_from = 0; join_from < area_num; join_from++) {
|
||||
for(join_from = 0; join_from < inv_buf_p; join_from++) {
|
||||
/*Handle only unjoined areas and ignore itself*/
|
||||
if(area_a[join_from].joined != 0 || join_in == join_from) {
|
||||
if(inv_buf[join_from].joined != 0 || join_in == join_from) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*Check if the areas are on each other*/
|
||||
if(area_is_on(&area_a[join_in].area,
|
||||
&area_a[join_from].area) == false)
|
||||
if(area_is_on(&inv_buf[join_in].area,
|
||||
&inv_buf[join_from].area) == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
area_join(&joined_area, &area_a[join_in].area,
|
||||
&area_a[join_from].area);
|
||||
area_join(&joined_area, &inv_buf[join_in].area,
|
||||
&inv_buf[join_from].area);
|
||||
|
||||
/*Join two area only if the joined area size is smaller*/
|
||||
if(area_get_size(&joined_area) <
|
||||
(area_get_size(&area_a[join_in].area) + area_get_size(&area_a[join_from].area))) {
|
||||
area_cpy(&area_a[join_in].area, &joined_area);
|
||||
(area_get_size(&inv_buf[join_in].area) + area_get_size(&inv_buf[join_from].area))) {
|
||||
area_cpy(&inv_buf[join_in].area, &joined_area);
|
||||
|
||||
/*Mark 'join_form' is joined into 'join_in'*/
|
||||
area_a[join_from].joined = 1;
|
||||
inv_buf[join_from].joined = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -190,22 +181,20 @@ static void lv_refr_join_area(lv_join_t * area_a, uint32_t area_num)
|
||||
|
||||
/**
|
||||
* Refresh the joined areas
|
||||
* @param area_a array of joined invalid areas
|
||||
* @param area_num item number of the array
|
||||
*/
|
||||
static void lv_refr_areas(lv_join_t * area_a, uint32_t area_num)
|
||||
static void lv_refr_areas(void)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for(i = 0; i < area_num; i++) {
|
||||
for(i = 0; i < inv_buf_p; i++) {
|
||||
/*Refresh the unjoined areas*/
|
||||
if(area_a[i].joined == 0) {
|
||||
if(inv_buf[i].joined == 0) {
|
||||
/*If there is no VDB do simple drawing*/
|
||||
#if LV_VDB_SIZE == 0
|
||||
lv_refr_area_no_vdb(&area_a[i].area);
|
||||
lv_refr_area_no_vdb(&inv_buf[i].area);
|
||||
#else
|
||||
/*If VDB is used...*/
|
||||
lv_refr_area_with_vdb(&area_a[i].area);
|
||||
lv_refr_area_with_vdb(&inv_buf[i].area);
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -314,10 +303,7 @@ static lv_obj_t * lv_refr_get_top_obj(const area_t * area_p, lv_obj_t * obj)
|
||||
lv_obj_t * found_p = NULL;
|
||||
|
||||
/*If this object is fully cover the draw area check the children too */
|
||||
if(obj->opa == OPA_COVER &&
|
||||
obj->hidden == 0 &&
|
||||
LV_SA(obj, lv_objs_t)->transp == 0 &&
|
||||
obj->design_f(obj, area_p, LV_DESIGN_COVER_CHK) != false)
|
||||
if(area_is_in(area_p, &obj->cords) && obj->hidden == 0)
|
||||
{
|
||||
LL_READ(obj->child_ll, i) {
|
||||
found_p = lv_refr_get_top_obj(area_p, i);
|
||||
@ -328,9 +314,13 @@ static lv_obj_t * lv_refr_get_top_obj(const area_t * area_p, lv_obj_t * obj)
|
||||
}
|
||||
}
|
||||
|
||||
/*If there is no better children use this object*/
|
||||
/*If no better children check this object*/
|
||||
if(found_p == NULL) {
|
||||
found_p = obj;
|
||||
if(obj->opa == OPA_COVER &&
|
||||
LV_SA(obj, lv_objs_t)->transp == 0 &&
|
||||
obj->design_f(obj, area_p, LV_DESIGN_COVER_CHK) != false) {
|
||||
found_p = obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -408,6 +398,7 @@ static void lv_refr_obj(lv_obj_t * obj, const area_t * mask_ori_p)
|
||||
/* Redraw the object */
|
||||
if(obj->opa != OPA_TRANSP && LV_SA(obj, lv_objs_t)->transp == 0) {
|
||||
obj->design_f(obj, &obj_ext_mask, LV_DESIGN_DRAW_MAIN);
|
||||
/* tick_wait_ms(100); */ /*DEBUG: Wait after every object draw to see the order of drawing*/
|
||||
}
|
||||
|
||||
/*Create a new 'obj_mask' without 'ext_size' because the children can't be visible there*/
|
||||
|
@ -128,7 +128,6 @@ bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void* param)
|
||||
} else if(ext->state == LV_BTN_STATE_TGL_REL) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_TGL_PR);
|
||||
}
|
||||
lv_obj_inv(btn);
|
||||
|
||||
ext->lpr_exec = 0;
|
||||
/*Call the press action, here 'param' is the caller dispi*/
|
||||
@ -143,8 +142,7 @@ bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void* param)
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
} else if(ext->state == LV_BTN_STATE_TGL_PR) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
|
||||
}
|
||||
lv_obj_inv(btn);
|
||||
}lv_obj_inv(btn);
|
||||
break;
|
||||
|
||||
case LV_SIGNAL_RELEASED:
|
||||
@ -161,7 +159,6 @@ bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void* param)
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_REL);
|
||||
}
|
||||
|
||||
|
||||
if(ext->rel_action != NULL && state != LV_BTN_STATE_INA) {
|
||||
valid = ext->rel_action(btn, param);
|
||||
}
|
||||
@ -171,9 +168,9 @@ bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void* param)
|
||||
} else if(ext->state == LV_BTN_STATE_TGL_PR) {
|
||||
lv_btn_set_state(btn, LV_BTN_STATE_TGL_REL);
|
||||
}
|
||||
lv_obj_inv(btn);
|
||||
}
|
||||
|
||||
lv_obj_inv(btn);
|
||||
break;
|
||||
case LV_SIGNAL_LONG_PRESS:
|
||||
/*Call the long press action, here 'param' is the caller dispi*/
|
||||
|
@ -344,9 +344,8 @@ lv_btnms_t * lv_btnms_get(lv_btnms_builtin_t style, lv_btnms_t * copy)
|
||||
static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_t mode)
|
||||
{
|
||||
if(mode == LV_DESIGN_COVER_CHK) {
|
||||
ancestor_design_f(btnm, mask, mode);
|
||||
return ancestor_design_f(btnm, mask, mode);
|
||||
/*Return false if the object is not covers the mask_p area*/
|
||||
return false;
|
||||
}
|
||||
/*Draw the object*/
|
||||
else if (mode == LV_DESIGN_DRAW_MAIN) {
|
||||
@ -405,7 +404,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
|
||||
area_tmp.x2 = area_tmp.x1 + txt_size.x;
|
||||
area_tmp.y2 = area_tmp.y1 + txt_size.y;
|
||||
|
||||
lv_draw_label(&area_tmp, mask, lv_labels_get(LV_LABELS_BTN, NULL), OPA_COVER, ext->map_p[txt_i]);
|
||||
lv_draw_label(&area_tmp, mask, &style->labels, OPA_COVER, ext->map_p[txt_i]);
|
||||
txt_i ++;
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,7 @@ static void lv_cbs_init(void);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_cbs_t lv_cbs_def =
|
||||
{
|
||||
};
|
||||
static lv_cbs_t lv_cbs_def;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -243,27 +241,27 @@ static void lv_cbs_init(void)
|
||||
lv_cbs_def.bullet.mcolor[LV_BTN_STATE_REL] = COLOR_WHITE;
|
||||
lv_cbs_def.bullet.gcolor[LV_BTN_STATE_REL] = COLOR_SILVER;
|
||||
lv_cbs_def.bullet.bcolor[LV_BTN_STATE_REL] = COLOR_BLACK;
|
||||
lv_cbs_def.bullet.light_en[LV_BTN_STATE_REL] = 0;
|
||||
lv_cbs_def.bullet.flags[LV_BTN_STATE_REL].light_en = 0;
|
||||
|
||||
lv_cbs_def.bullet.mcolor[LV_BTN_STATE_PR] = COLOR_SILVER;
|
||||
lv_cbs_def.bullet.gcolor[LV_BTN_STATE_PR] = COLOR_GRAY;
|
||||
lv_cbs_def.bullet.bcolor[LV_BTN_STATE_PR] = COLOR_BLACK;
|
||||
lv_cbs_def.bullet.light_en[LV_BTN_STATE_PR] = 0;
|
||||
lv_cbs_def.bullet.flags[LV_BTN_STATE_PR].light_en = 0;
|
||||
|
||||
lv_cbs_def.bullet.mcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x20, 0x30, 0x40);
|
||||
lv_cbs_def.bullet.gcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x10, 0x20, 0x30);
|
||||
lv_cbs_def.bullet.bcolor[LV_BTN_STATE_TGL_REL] = COLOR_WHITE;
|
||||
lv_cbs_def.bullet.light_en[LV_BTN_STATE_TGL_REL] = 0;
|
||||
lv_cbs_def.bullet.flags[LV_BTN_STATE_TGL_REL].light_en = 0;
|
||||
|
||||
lv_cbs_def.bullet.mcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x50, 0x70, 0x90);
|
||||
lv_cbs_def.bullet.gcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x20, 0x30, 0x40);
|
||||
lv_cbs_def.bullet.bcolor[LV_BTN_STATE_TGL_PR] = COLOR_WHITE;
|
||||
lv_cbs_def.bullet.light_en[LV_BTN_STATE_TGL_PR] = 0;
|
||||
lv_cbs_def.bullet.flags[LV_BTN_STATE_TGL_PR].light_en = 0;
|
||||
|
||||
lv_cbs_def.bullet.mcolor[LV_BTN_STATE_INA] = COLOR_SILVER;
|
||||
lv_cbs_def.bullet.gcolor[LV_BTN_STATE_INA] = COLOR_GRAY;
|
||||
lv_cbs_def.bullet.bcolor[LV_BTN_STATE_INA] = COLOR_WHITE;
|
||||
lv_cbs_def.bullet.light_en[LV_BTN_STATE_INA] = 0;
|
||||
lv_cbs_def.bullet.flags[LV_BTN_STATE_INA].light_en = 0;
|
||||
|
||||
lv_cbs_def.bullet.rects.bwidth = 2 * LV_DOWNSCALE;
|
||||
lv_cbs_def.bullet.rects.bopa = 70;
|
||||
|
@ -491,6 +491,8 @@ static bool lv_page_design(lv_obj_t * page, const area_t * mask, lv_design_mode_
|
||||
*/
|
||||
static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
{
|
||||
|
||||
|
||||
lv_page_ext_t * page_ext = lv_obj_get_ext(page);
|
||||
lv_pages_t * pages = lv_obj_get_style(page);
|
||||
lv_obj_t * scrolling = page_ext->scrolling;
|
||||
@ -504,8 +506,12 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
cord_t page_x0 = page->cords.x1;
|
||||
cord_t page_y0 = page->cords.y1;
|
||||
|
||||
lv_inv_area(&page_ext->sbh);
|
||||
lv_inv_area(&page_ext->sbv);
|
||||
|
||||
if(pages->sb_mode == LV_PAGE_SB_MODE_OFF) return;
|
||||
|
||||
/*Invalidate the current (old) scrollbar areas*/
|
||||
if(page_ext->sbh_draw != 0) lv_inv_area(&page_ext->sbh);
|
||||
if(page_ext->sbv_draw != 0) lv_inv_area(&page_ext->sbv);
|
||||
|
||||
/*Horizontal scrollbar*/
|
||||
if(scrolling_w <= obj_w - 2 * hpad) { /*Full sized scroll bar*/
|
||||
@ -540,9 +546,10 @@ static void lv_page_sb_refresh(lv_obj_t * page)
|
||||
(-(lv_obj_get_y(scrolling) - vpad) * (obj_h - size_tmp - pages->sb_width)) /
|
||||
(scrolling_h - obj_h + 2 * vpad));
|
||||
}
|
||||
|
||||
lv_inv_area(&page_ext->sbh);
|
||||
lv_inv_area(&page_ext->sbv);
|
||||
|
||||
/*Invalidate the new scrollbar areas*/
|
||||
if(page_ext->sbh_draw != 0) lv_inv_area(&page_ext->sbh);
|
||||
if(page_ext->sbv_draw != 0) lv_inv_area(&page_ext->sbv);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -654,7 +654,7 @@ void lv_rect_refr_autofit(lv_obj_t * rect)
|
||||
return;
|
||||
}
|
||||
|
||||
area_t rect_cords;
|
||||
area_t new_cords;
|
||||
area_t ori;
|
||||
lv_rects_t * style = lv_obj_get_style(rect);
|
||||
lv_obj_t * i;
|
||||
@ -663,48 +663,55 @@ void lv_rect_refr_autofit(lv_obj_t * rect)
|
||||
|
||||
/*Search the side coordinates of the children*/
|
||||
lv_obj_get_cords(rect, &ori);
|
||||
lv_obj_get_cords(rect, &rect_cords);
|
||||
lv_obj_get_cords(rect, &new_cords);
|
||||
|
||||
rect_cords.x1 = LV_CORD_MAX;
|
||||
rect_cords.y1 = LV_CORD_MAX;
|
||||
rect_cords.x2 = LV_CORD_MIN;
|
||||
rect_cords.y2 = LV_CORD_MIN;
|
||||
new_cords.x1 = LV_CORD_MAX;
|
||||
new_cords.y1 = LV_CORD_MAX;
|
||||
new_cords.x2 = LV_CORD_MIN;
|
||||
new_cords.y2 = LV_CORD_MIN;
|
||||
|
||||
LL_READ(rect->child_ll, i) {
|
||||
if(lv_obj_get_hidden(i) != false) continue;
|
||||
rect_cords.x1 = min(rect_cords.x1, i->cords.x1);
|
||||
rect_cords.y1 = min(rect_cords.y1, i->cords.y1);
|
||||
rect_cords.x2 = max(rect_cords.x2, i->cords.x2);
|
||||
rect_cords.y2 = max(rect_cords.y2, i->cords.y2);
|
||||
new_cords.x1 = min(new_cords.x1, i->cords.x1);
|
||||
new_cords.y1 = min(new_cords.y1, i->cords.y1);
|
||||
new_cords.x2 = max(new_cords.x2, i->cords.x2);
|
||||
new_cords.y2 = max(new_cords.y2, i->cords.y2);
|
||||
}
|
||||
|
||||
/*If the value is not the init value then the page has >=1 child.*/
|
||||
if(rect_cords.x1 != LV_CORD_MAX) {
|
||||
if(new_cords.x1 != LV_CORD_MAX) {
|
||||
if(ext->hfit_en != 0) {
|
||||
rect_cords.x1 -= hpad;
|
||||
rect_cords.x2 += hpad;
|
||||
new_cords.x1 -= hpad;
|
||||
new_cords.x2 += hpad;
|
||||
} else {
|
||||
rect_cords.x1 = rect->cords.x1;
|
||||
rect_cords.x2 = rect->cords.x2;
|
||||
new_cords.x1 = rect->cords.x1;
|
||||
new_cords.x2 = rect->cords.x2;
|
||||
}
|
||||
if(ext->vfit_en != 0) {
|
||||
rect_cords.y1 -= vpad;
|
||||
rect_cords.y2 += vpad;
|
||||
new_cords.y1 -= vpad;
|
||||
new_cords.y2 += vpad;
|
||||
} else {
|
||||
rect_cords.y1 = rect->cords.y1;
|
||||
rect_cords.y2 = rect->cords.y2;
|
||||
new_cords.y1 = rect->cords.y1;
|
||||
new_cords.y2 = rect->cords.y2;
|
||||
}
|
||||
|
||||
lv_obj_inv(rect);
|
||||
area_cpy(&rect->cords, &rect_cords);
|
||||
lv_obj_inv(rect);
|
||||
/*Do nothing if the coordinates are not changed*/
|
||||
if(rect->cords.x1 != new_cords.x1 ||
|
||||
rect->cords.y1 != new_cords.y1 ||
|
||||
rect->cords.x2 != new_cords.x2 ||
|
||||
rect->cords.y2 != new_cords.y2) {
|
||||
|
||||
/*Notify the object about its new coordinates*/
|
||||
rect->signal_f(rect, LV_SIGNAL_CORD_CHG, &ori);
|
||||
lv_obj_inv(rect);
|
||||
area_cpy(&rect->cords, &new_cords);
|
||||
lv_obj_inv(rect);
|
||||
|
||||
/*Inform the parent about the new coordinates*/
|
||||
lv_obj_t * par = lv_obj_get_parent(rect);
|
||||
par->signal_f(par, LV_SIGNAL_CHILD_CHG, rect);
|
||||
/*Notify the object about its new coordinates*/
|
||||
rect->signal_f(rect, LV_SIGNAL_CORD_CHG, &ori);
|
||||
|
||||
/*Inform the parent about the new coordinates*/
|
||||
lv_obj_t * par = lv_obj_get_parent(rect);
|
||||
par->signal_f(par, LV_SIGNAL_CHILD_CHG, rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user