mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
style initialization functions added to every object type
This commit is contained in:
parent
8cda3dc1ec
commit
87a9c371bb
126
lv_objx/lv_btn.c
126
lv_objx/lv_btn.c
@ -25,6 +25,7 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_btn_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
|
||||
static void lv_btns_init(void);
|
||||
static void lv_btn_style_load(lv_obj_t * obj_dp, lv_rects_t * rects_p);
|
||||
|
||||
/**********************
|
||||
@ -34,61 +35,9 @@ static void lv_btn_style_load(lv_obj_t * obj_dp, lv_rects_t * rects_p);
|
||||
/*-----------------
|
||||
* Style definition
|
||||
*-----------------*/
|
||||
static lv_btns_t lv_btns_def =
|
||||
{
|
||||
.mcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0x40, 0x60, 0x80),
|
||||
.gcolor[LV_BTN_STATE_REL] = COLOR_BLACK,
|
||||
.bcolor[LV_BTN_STATE_REL] = COLOR_WHITE,
|
||||
|
||||
.mcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0x60, 0x80, 0xa0),
|
||||
.gcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0x20, 0x30, 0x40),
|
||||
.bcolor[LV_BTN_STATE_PR] = COLOR_WHITE,
|
||||
|
||||
.mcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x80,0x00,0x00),
|
||||
.gcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x20, 0x20, 0x20),
|
||||
.bcolor[LV_BTN_STATE_TGL_REL] = COLOR_WHITE,
|
||||
|
||||
.mcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0xf0, 0x26, 0x26),
|
||||
.gcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x40, 0x40, 0x40),
|
||||
.bcolor[LV_BTN_STATE_TGL_PR] = COLOR_WHITE,
|
||||
|
||||
.mcolor[LV_BTN_STATE_INA] = COLOR_SILVER,
|
||||
.gcolor[LV_BTN_STATE_INA] = COLOR_GRAY,
|
||||
.bcolor[LV_BTN_STATE_INA] = COLOR_WHITE,
|
||||
|
||||
.rects.bwidth = 2 * LV_STYLE_MULT,
|
||||
.rects.bopa = 50,
|
||||
.rects.empty = 0,
|
||||
.rects.round = 4 * LV_STYLE_MULT,
|
||||
.rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.rects.vpad = 15 * LV_STYLE_MULT,
|
||||
.rects.opad = 3 * LV_STYLE_MULT,
|
||||
};
|
||||
static lv_btns_t lv_btns_transp =
|
||||
{
|
||||
.rects.objs.transp = 1,
|
||||
.rects.bwidth = 0,
|
||||
.rects.empty = 1,
|
||||
.rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.rects.vpad = 15 * LV_STYLE_MULT,
|
||||
.rects.opad = 5 * LV_STYLE_MULT,
|
||||
};
|
||||
|
||||
static lv_btns_t lv_btns_border =
|
||||
{
|
||||
.bcolor[LV_BTN_STATE_REL] = COLOR_BLACK,
|
||||
.bcolor[LV_BTN_STATE_PR] = COLOR_BLACK,
|
||||
.bcolor[LV_BTN_STATE_TGL_REL] = COLOR_BLACK,
|
||||
.bcolor[LV_BTN_STATE_TGL_PR] = COLOR_BLACK,
|
||||
.bcolor[LV_BTN_STATE_INA] = COLOR_GRAY,
|
||||
.rects.bwidth = 2 * LV_STYLE_MULT,
|
||||
.rects.empty = 1,
|
||||
.rects.bopa = 50,
|
||||
.rects.round = 4 * LV_STYLE_MULT,
|
||||
.rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.rects.vpad = 10 * LV_STYLE_MULT,
|
||||
.rects.vpad = 5 * LV_STYLE_MULT,
|
||||
};
|
||||
static lv_btns_t lv_btns_def;
|
||||
static lv_btns_t lv_btns_transp;
|
||||
static lv_btns_t lv_btns_border;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -125,7 +74,7 @@ lv_obj_t* lv_btn_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
btn_ext_dp->rel_action = NULL;
|
||||
btn_ext_dp->lpr_action = NULL;
|
||||
btn_ext_dp->tgl = 0;
|
||||
lv_obj_set_style(new_obj_dp, &lv_btns_def);
|
||||
lv_obj_set_style(new_obj_dp, lv_btns_get(LV_BTNS_DEF, NULL));
|
||||
lv_rect_set_layout(new_obj_dp, LV_RECT_LAYOUT_CENTER);
|
||||
}
|
||||
/*Copy 'copy_dp'*/
|
||||
@ -333,6 +282,14 @@ bool lv_btn_get_tgl(lv_obj_t* obj_dp)
|
||||
*/
|
||||
lv_btns_t * lv_btns_get(lv_btns_builtin_t style, lv_btns_t * copy_p)
|
||||
{
|
||||
static bool style_inited = false;
|
||||
|
||||
/*Make the style initialization if it is not done yet*/
|
||||
if(style_inited == false) {
|
||||
lv_btns_init();
|
||||
style_inited = true;
|
||||
}
|
||||
|
||||
lv_btns_t *style_p;
|
||||
|
||||
switch(style) {
|
||||
@ -408,6 +365,63 @@ static bool lv_btn_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the button styles
|
||||
*/
|
||||
static void lv_btns_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
lv_btns_def.mcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0x40, 0x60, 0x80);
|
||||
lv_btns_def.gcolor[LV_BTN_STATE_REL] = COLOR_BLACK;
|
||||
lv_btns_def.bcolor[LV_BTN_STATE_REL] = COLOR_WHITE;
|
||||
|
||||
lv_btns_def.mcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0x60, 0x80, 0xa0);
|
||||
lv_btns_def.gcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0x20, 0x30, 0x40);
|
||||
lv_btns_def.bcolor[LV_BTN_STATE_PR] = COLOR_WHITE;
|
||||
|
||||
lv_btns_def.mcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x80, 0x00, 0x00);
|
||||
lv_btns_def.gcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
lv_btns_def.bcolor[LV_BTN_STATE_TGL_REL] = COLOR_WHITE;
|
||||
|
||||
lv_btns_def.mcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0xf0, 0x26, 0x26);
|
||||
lv_btns_def.gcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x40, 0x40, 0x40);
|
||||
lv_btns_def.bcolor[LV_BTN_STATE_TGL_PR] = COLOR_WHITE;
|
||||
|
||||
lv_btns_def.mcolor[LV_BTN_STATE_INA] = COLOR_SILVER;
|
||||
lv_btns_def.gcolor[LV_BTN_STATE_INA] = COLOR_GRAY;
|
||||
lv_btns_def.bcolor[LV_BTN_STATE_INA] = COLOR_WHITE;
|
||||
|
||||
lv_btns_def.rects.bwidth = 2 * LV_STYLE_MULT;
|
||||
lv_btns_def.rects.bopa = 50;
|
||||
lv_btns_def.rects.empty = 0;
|
||||
lv_btns_def.rects.round = 4 * LV_STYLE_MULT;
|
||||
lv_btns_def.rects.hpad = 10 * LV_STYLE_MULT;
|
||||
lv_btns_def.rects.vpad = 15 * LV_STYLE_MULT;
|
||||
lv_btns_def.rects.opad = 5 * LV_STYLE_MULT;
|
||||
|
||||
/*Transparent style*/
|
||||
memcpy(&lv_btns_transp, &lv_btns_def, sizeof(lv_btns_t));
|
||||
lv_btns_transp.rects.objs.transp = 1;
|
||||
lv_btns_transp.rects.bwidth = 0;
|
||||
lv_btns_transp.rects.empty = 1;
|
||||
|
||||
|
||||
/*Border style*/
|
||||
memcpy(&lv_btns_border, &lv_btns_def, sizeof(lv_btns_t));
|
||||
lv_btns_border.bcolor[LV_BTN_STATE_REL] = COLOR_BLACK;
|
||||
lv_btns_border.bcolor[LV_BTN_STATE_PR] = COLOR_BLACK;
|
||||
lv_btns_border.bcolor[LV_BTN_STATE_TGL_REL] = COLOR_BLACK;
|
||||
lv_btns_border.bcolor[LV_BTN_STATE_TGL_PR] = COLOR_BLACK;
|
||||
lv_btns_border.bcolor[LV_BTN_STATE_INA] = COLOR_GRAY;
|
||||
lv_btns_border.rects.bwidth = 2 * LV_STYLE_MULT;
|
||||
lv_btns_border.rects.empty = 1;
|
||||
lv_btns_border.rects.bopa = 50;
|
||||
lv_btns_border.rects.round = 4 * LV_STYLE_MULT;
|
||||
lv_btns_border.rects.hpad = 10 * LV_STYLE_MULT;
|
||||
lv_btns_border.rects.vpad = 10 * LV_STYLE_MULT;
|
||||
lv_btns_border.rects.vpad = 5 * LV_STYLE_MULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the corresponding style according to the state to 'rects' in 'lv_btns_t'
|
||||
* @param obj_dp pointer to a button object
|
||||
|
@ -26,6 +26,7 @@
|
||||
#if 0 /*Not necessary*/
|
||||
static bool lv_btnm_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
|
||||
#endif
|
||||
static void lv_btnms_init(void);
|
||||
static uint8_t lv_btnm_get_width_unit(const char * btn_str);
|
||||
static void lv_btnm_create_btns(lv_obj_t * obj_dp, const char ** map_p);
|
||||
static bool lv_btnm_btn_release_action(lv_obj_t * obj_dp, lv_dispi_t * dispi_p);
|
||||
@ -33,47 +34,7 @@ static bool lv_btnm_btn_release_action(lv_obj_t * obj_dp, lv_dispi_t * dispi_p);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_btnms_t lv_btnms_def =
|
||||
{
|
||||
/*Background rectangle style*/
|
||||
.rects.objs.color = COLOR_MAKE(0x50, 0x70, 0x90), .rects.gcolor = COLOR_MAKE(0x70, 0xA0, 0xC0),
|
||||
.rects.bcolor = COLOR_WHITE, .rects.bwidth = 2 * LV_STYLE_MULT, .rects.bopa = 50,
|
||||
.rects.round = 4 * LV_STYLE_MULT, .rects.empty = 0,
|
||||
.rects.hpad = 5 * LV_STYLE_MULT, .rects.vpad = 5 * LV_STYLE_MULT, .rects.opad = 5 * LV_STYLE_MULT,
|
||||
|
||||
/*Button style*/
|
||||
.btns.mcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0x40, 0x60, 0x80),
|
||||
.btns.gcolor[LV_BTN_STATE_REL] = COLOR_BLACK,
|
||||
.btns.bcolor[LV_BTN_STATE_REL] = COLOR_WHITE,
|
||||
|
||||
.btns.mcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0x60, 0x80, 0xa0),
|
||||
.btns.gcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0x20, 0x30, 0x40),
|
||||
.btns.bcolor[LV_BTN_STATE_PR] = COLOR_WHITE,
|
||||
|
||||
.btns.mcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x80,0x00,0x00),
|
||||
.btns.gcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x20, 0x20, 0x20),
|
||||
.btns.bcolor[LV_BTN_STATE_TGL_REL] = COLOR_WHITE,
|
||||
|
||||
.btns.mcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0xf0, 0x26, 0x26),
|
||||
.btns.gcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x40, 0x40, 0x40),
|
||||
.btns.bcolor[LV_BTN_STATE_TGL_PR] = COLOR_WHITE,
|
||||
|
||||
.btns.mcolor[LV_BTN_STATE_INA] = COLOR_SILVER,
|
||||
.btns.gcolor[LV_BTN_STATE_INA] = COLOR_GRAY,
|
||||
.btns.bcolor[LV_BTN_STATE_INA] = COLOR_WHITE,
|
||||
|
||||
.btns.rects.bwidth = 2 * LV_STYLE_MULT, .btns.rects.bopa = 50,
|
||||
.btns.rects.empty = 0, .btns.rects.round = 4 * LV_STYLE_MULT,
|
||||
.btns.rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.btns.rects.vpad = 15 * LV_STYLE_MULT,
|
||||
.btns.rects.opad = 3 * LV_STYLE_MULT,
|
||||
|
||||
/*Label style*/
|
||||
.labels.font = LV_FONT_DEFAULT, .labels.objs.color = COLOR_MAKE(0xd0, 0xe0, 0xf0),
|
||||
.labels.letter_space = 2 * LV_STYLE_MULT, .labels.line_space = 2 * LV_STYLE_MULT,
|
||||
.labels.mid = 1,
|
||||
|
||||
};
|
||||
static lv_btnms_t lv_btnms_def;
|
||||
|
||||
static const char * lv_btnm_def_map[] = {"Btn1","Btn2", "Btn3","\n",
|
||||
"\002Btn4","Btn5", ""};
|
||||
@ -114,7 +75,7 @@ lv_obj_t* lv_btnm_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
/*Init the new button matrix object*/
|
||||
if(copy_dp == NULL) {
|
||||
lv_obj_set_size(new_obj_dp, LV_HOR_RES / 2, LV_VER_RES / 2);
|
||||
lv_obj_set_style(new_obj_dp, &lv_btnms_def);
|
||||
lv_obj_set_style(new_obj_dp, lv_btnms_get(LV_BTNMS_DEF, NULL));
|
||||
lv_btnm_set_map(new_obj_dp, lv_btnm_def_map);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
@ -269,6 +230,14 @@ void lv_btnm_set_cb(lv_obj_t * obj_dp, lv_btnm_callback_t cb)
|
||||
*/
|
||||
lv_btnms_t * lv_btnms_get(lv_btnms_builtin_t style, lv_btnms_t * copy_p)
|
||||
{
|
||||
static bool style_inited = false;
|
||||
|
||||
/*Make the style initialization if it is not done yet*/
|
||||
if(style_inited == false) {
|
||||
lv_btnms_init();
|
||||
style_inited = true;
|
||||
}
|
||||
|
||||
lv_btnms_t *style_p;
|
||||
|
||||
switch(style) {
|
||||
@ -336,6 +305,18 @@ static bool lv_btnm_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the button matrix styles
|
||||
*/
|
||||
static void lv_btnms_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
lv_rects_get(LV_RECTS_DEF, &lv_btnms_def.rects); /*Background rectangle style*/
|
||||
lv_btns_get(LV_BTNS_DEF, &lv_btnms_def.btns); /*Button style*/
|
||||
lv_labels_get(LV_LABELS_BTN, &lv_btnms_def.labels); /*BUtton label style*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the required number of buttons according to a map
|
||||
* @param obj_dp pointer to button matrix object
|
||||
|
128
lv_objx/lv_cb.c
128
lv_objx/lv_cb.c
@ -25,77 +25,13 @@
|
||||
#if 0 /*The ancestor design function is used */
|
||||
static bool lv_cb_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
|
||||
#endif
|
||||
static void lv_cbs_init(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_cbs_t lv_cbs_def =
|
||||
{ /*Bg style*/
|
||||
.bg.rects.objs.transp = 1,
|
||||
.bg.mcolor[LV_BTN_STATE_REL] = COLOR_SILVER,
|
||||
.bg.gcolor[LV_BTN_STATE_REL] = COLOR_SILVER,
|
||||
.bg.bcolor[LV_BTN_STATE_REL] = COLOR_SILVER,
|
||||
|
||||
.bg.mcolor[LV_BTN_STATE_PR] = COLOR_SILVER,
|
||||
.bg.gcolor[LV_BTN_STATE_PR] = COLOR_SILVER,
|
||||
.bg.bcolor[LV_BTN_STATE_PR] = COLOR_SILVER,
|
||||
|
||||
.bg.mcolor[LV_BTN_STATE_TGL_REL] = COLOR_SILVER,
|
||||
.bg.gcolor[LV_BTN_STATE_TGL_REL] = COLOR_SILVER,
|
||||
.bg.bcolor[LV_BTN_STATE_TGL_REL] = COLOR_SILVER,
|
||||
|
||||
.bg.mcolor[LV_BTN_STATE_TGL_PR] = COLOR_SILVER,
|
||||
.bg.gcolor[LV_BTN_STATE_TGL_PR] = COLOR_SILVER,
|
||||
.bg.bcolor[LV_BTN_STATE_TGL_PR] = COLOR_SILVER,
|
||||
|
||||
.bg.mcolor[LV_BTN_STATE_INA] = COLOR_SILVER,
|
||||
.bg.gcolor[LV_BTN_STATE_INA] = COLOR_SILVER,
|
||||
.bg.bcolor[LV_BTN_STATE_INA] = COLOR_SILVER,
|
||||
|
||||
.bg.rects.bwidth = 0 * LV_STYLE_MULT,
|
||||
.bg.rects.bopa = 50,
|
||||
.bg.rects.empty = 1,
|
||||
.bg.rects.round = 0,
|
||||
.bg.rects.hpad = 0 * LV_STYLE_MULT,
|
||||
.bg.rects.vpad = 0 * LV_STYLE_MULT,
|
||||
.bg.rects.opad = 5 * LV_STYLE_MULT,
|
||||
|
||||
/*Bullet style*/
|
||||
.bullet.mcolor[LV_BTN_STATE_REL] = COLOR_WHITE,
|
||||
.bullet.gcolor[LV_BTN_STATE_REL] = COLOR_SILVER,
|
||||
.bullet.bcolor[LV_BTN_STATE_REL] = COLOR_BLACK,
|
||||
|
||||
.bullet.mcolor[LV_BTN_STATE_PR] = COLOR_SILVER,
|
||||
.bullet.gcolor[LV_BTN_STATE_PR] = COLOR_GRAY,
|
||||
.bullet.bcolor[LV_BTN_STATE_PR] = COLOR_BLACK,
|
||||
|
||||
.bullet.mcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x20, 0x30, 0x40),
|
||||
.bullet.gcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x10, 0x20, 0x30),
|
||||
.bullet.bcolor[LV_BTN_STATE_TGL_REL] = COLOR_WHITE,
|
||||
|
||||
.bullet.mcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x50, 0x70, 0x90),
|
||||
.bullet.gcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x20, 0x30, 0x40),
|
||||
.bullet.bcolor[LV_BTN_STATE_TGL_PR] = COLOR_WHITE,
|
||||
|
||||
.bullet.mcolor[LV_BTN_STATE_INA] = COLOR_SILVER,
|
||||
.bullet.gcolor[LV_BTN_STATE_INA] = COLOR_GRAY,
|
||||
.bullet.bcolor[LV_BTN_STATE_INA] = COLOR_WHITE,
|
||||
|
||||
.bullet.rects.bwidth = 2 * LV_STYLE_MULT,
|
||||
.bullet.rects.bopa = 70,
|
||||
.bullet.rects.empty = 0,
|
||||
.bullet.rects.round = LV_OBJ_DEF_WIDTH / 3 / 4,
|
||||
.bullet.rects.hpad = 0 * LV_STYLE_MULT,
|
||||
.bullet.rects.vpad = 0 * LV_STYLE_MULT,
|
||||
.bullet.rects.opad = 0 * LV_STYLE_MULT,
|
||||
|
||||
/*Label*/
|
||||
.label.font = LV_FONT_DEFAULT, .label.objs.color = COLOR_MAKE(0x10, 0x18, 0x20),
|
||||
.label.letter_space = 2 * LV_STYLE_MULT, .label.line_space = 2 * LV_STYLE_MULT,
|
||||
.label.mid = 0,
|
||||
|
||||
/*Others*/
|
||||
.bullet_size = LV_OBJ_DEF_WIDTH / 3
|
||||
{
|
||||
};
|
||||
|
||||
/**********************
|
||||
@ -139,7 +75,7 @@ lv_obj_t * lv_cb_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
ext->label = lv_label_create(new_obj_dp, NULL);
|
||||
lv_label_set_text(ext->label, "Check box");
|
||||
|
||||
lv_obj_set_style(new_obj_dp, &lv_cbs_def);
|
||||
lv_obj_set_style(new_obj_dp, lv_cbs_get(LV_CBS_DEF, NULL));
|
||||
} else {
|
||||
lv_cb_ext_t * copy_ext = lv_obj_get_ext(copy_dp);
|
||||
ext->bullet = lv_btn_create(new_obj_dp, copy_ext->bullet);
|
||||
@ -234,6 +170,14 @@ const char * lv_cb_get_text(lv_obj_t * obj_dp)
|
||||
*/
|
||||
lv_cbs_t * lv_cbs_get(lv_cbs_builtin_t style, lv_cbs_t * copy_p)
|
||||
{
|
||||
static bool style_inited = false;
|
||||
|
||||
/*Make the style initialization if it is not done yet*/
|
||||
if(style_inited == false) {
|
||||
lv_cbs_init();
|
||||
style_inited = true;
|
||||
}
|
||||
|
||||
lv_cbs_t *style_p;
|
||||
|
||||
switch(style) {
|
||||
@ -279,5 +223,55 @@ static bool lv_cb_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* Initialize the rectangle styles
|
||||
*/
|
||||
static void lv_cbs_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
|
||||
/*Bg style*/
|
||||
lv_rects_get(LV_RECTS_TRANSP, &lv_cbs_def.bg);
|
||||
lv_cbs_def.bg.rects.hpad = 0 * LV_STYLE_MULT;
|
||||
lv_cbs_def.bg.rects.vpad = 0 * LV_STYLE_MULT;
|
||||
lv_cbs_def.bg.rects.opad = 5 * LV_STYLE_MULT;
|
||||
|
||||
/*Bullet style*/
|
||||
lv_btns_get(LV_BTNS_DEF, &lv_cbs_def.bullet);
|
||||
|
||||
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.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.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.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.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.rects.bwidth = 2 * LV_STYLE_MULT;
|
||||
lv_cbs_def.bullet.rects.bopa = 70;
|
||||
lv_cbs_def.bullet.rects.empty = 0;
|
||||
lv_cbs_def.bullet.rects.round = LV_OBJ_DEF_WIDTH / 3 / 4;
|
||||
lv_cbs_def.bullet.rects.hpad = 0 * LV_STYLE_MULT;
|
||||
lv_cbs_def.bullet.rects.vpad = 0 * LV_STYLE_MULT;
|
||||
lv_cbs_def.bullet.rects.opad = 0 * LV_STYLE_MULT;
|
||||
|
||||
/*Label*/
|
||||
lv_labels_get(LV_LABELS_TXT, &lv_cbs_def.label);
|
||||
lv_cbs_def.label.objs.color = COLOR_MAKE(0x10, 0x18, 0x20);
|
||||
|
||||
/*Others*/
|
||||
lv_cbs_def.bullet_size = LV_OBJ_DEF_WIDTH / 3;
|
||||
}
|
||||
#endif
|
||||
|
@ -29,6 +29,7 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_chart_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
|
||||
static void lv_charts_init(void);
|
||||
static void lv_chart_draw_div(lv_obj_t* obj_dp, const area_t * mask_p);
|
||||
static void lv_chart_draw_lines(lv_obj_t* obj_dp, const area_t * mask_p);
|
||||
static void lv_chart_draw_points(lv_obj_t* obj_dp, const area_t * mask_p);
|
||||
@ -38,39 +39,8 @@ static void lv_chart_draw_cols(lv_obj_t* obj_dp, const area_t * mask_p);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static bool (*ancestor_design_fp)(lv_obj_t*, const area_t *, lv_design_mode_t);
|
||||
static lv_charts_t lv_charts_def =
|
||||
{
|
||||
/* Background */
|
||||
.bg_rects.objs.color = COLOR_MAKE(0x60, 0x80, 0xA0),
|
||||
.bg_rects.gcolor = COLOR_WHITE,
|
||||
.bg_rects.bcolor = COLOR_BLACK,
|
||||
.bg_rects.bwidth = 2 * LV_STYLE_MULT,
|
||||
.bg_rects.bopa = 50,
|
||||
.bg_rects.empty = 0,
|
||||
.bg_rects.round = 4 * LV_STYLE_MULT,
|
||||
.bg_rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.bg_rects.vpad = 15 * LV_STYLE_MULT,
|
||||
.bg_rects.opad = 3 * LV_STYLE_MULT,
|
||||
|
||||
/* Div. line */
|
||||
.div_lines.width = 1 * LV_STYLE_MULT,
|
||||
.div_lines.objs.color = COLOR_BLACK,
|
||||
.div_line_opa = 100,
|
||||
|
||||
/*Data lines*/
|
||||
.width = 3 * LV_STYLE_MULT,
|
||||
.data_opa = 100,
|
||||
.dark_eff = 150,
|
||||
.color[0] = COLOR_RED,
|
||||
.color[1] = COLOR_LIME,
|
||||
.color[2] = COLOR_BLUE,
|
||||
.color[3] = COLOR_MAGENTA,
|
||||
.color[4] = COLOR_CYAN,
|
||||
.color[5] = COLOR_YELLOW,
|
||||
.color[6] = COLOR_WHITE,
|
||||
.color[7] = COLOR_GRAY,
|
||||
};
|
||||
static lv_design_f_t ancestor_design_fp;
|
||||
static lv_charts_t lv_charts_def;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -113,7 +83,7 @@ lv_obj_t* lv_chart_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
/*Init the new chart background object*/
|
||||
if(copy_dp == NULL) {
|
||||
ext_dp->type = LV_CHART_LINE;
|
||||
lv_obj_set_style(new_obj_dp, &lv_charts_def);
|
||||
lv_obj_set_style(new_obj_dp, lv_charts_get(LV_CHARTS_DEF, NULL));
|
||||
ext_dp->ymin = LV_CHART_YMIN_DEF;
|
||||
ext_dp->ymax = LV_CHART_YMAX_DEF;
|
||||
ext_dp->hdiv_num = LV_CHART_HDIV_DEF;
|
||||
@ -300,6 +270,14 @@ void lv_chart_set_next(lv_obj_t * obj_dp, cord_t * dl_p, cord_t y)
|
||||
*/
|
||||
lv_charts_t * lv_charts_get(lv_charts_builtin_t style, lv_charts_t * copy_p)
|
||||
{
|
||||
static bool style_inited = false;
|
||||
|
||||
/*Make the style initialization if it is not done yet*/
|
||||
if(style_inited == false) {
|
||||
lv_charts_init();
|
||||
style_inited = true;
|
||||
}
|
||||
|
||||
lv_charts_t * style_p;
|
||||
|
||||
switch(style) {
|
||||
@ -587,4 +565,36 @@ static void lv_chart_draw_cols(lv_obj_t* obj_dp, const area_t * mask_p)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the chart styles
|
||||
*/
|
||||
static void lv_charts_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
/* Background */
|
||||
lv_rects_get(LV_RECTS_DEF, &lv_charts_def.bg_rects);
|
||||
lv_charts_def.bg_rects.objs.color = COLOR_MAKE(0x60, 0x80, 0xA0);
|
||||
lv_charts_def.bg_rects.gcolor = COLOR_WHITE;
|
||||
lv_charts_def.bg_rects.bcolor = COLOR_BLACK;
|
||||
|
||||
/* Div. line */
|
||||
lv_lines_get(LV_LINES_DECOR, &lv_charts_def.div_lines);
|
||||
lv_charts_def.div_lines.width = 1 * LV_STYLE_MULT;
|
||||
lv_charts_def.div_lines.objs.color = COLOR_BLACK;
|
||||
lv_charts_def.div_line_opa = OPA_COVER;
|
||||
|
||||
/*Data lines*/
|
||||
lv_charts_def.width = 3 * LV_STYLE_MULT;
|
||||
lv_charts_def.data_opa = 100;
|
||||
lv_charts_def.dark_eff = 150;
|
||||
lv_charts_def.color[0] = COLOR_RED;
|
||||
lv_charts_def.color[1] = COLOR_LIME;
|
||||
lv_charts_def.color[2] = COLOR_BLUE;
|
||||
lv_charts_def.color[3] = COLOR_MAGENTA;
|
||||
lv_charts_def.color[4] = COLOR_CYAN;
|
||||
lv_charts_def.color[5] = COLOR_YELLOW;
|
||||
lv_charts_def.color[6] = COLOR_WHITE;
|
||||
lv_charts_def.color[7] = COLOR_GRAY;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -26,16 +26,14 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_img_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
|
||||
static void lv_imgs_init(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
/*-----------------
|
||||
* Style definition
|
||||
*-----------------*/
|
||||
static lv_imgs_t lv_imgs_def = {.recolor_opa=OPA_TRANSP};
|
||||
static lv_imgs_t lv_imgs_light = {.objs.color = COLOR_WHITE, .recolor_opa=OPA_50};
|
||||
static lv_imgs_t lv_imgs_dark = {.objs.color = COLOR_BLACK, .recolor_opa=OPA_50};
|
||||
static lv_imgs_t lv_imgs_def;
|
||||
static lv_imgs_t lv_imgs_light;
|
||||
static lv_imgs_t lv_imgs_dark;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -79,7 +77,7 @@ lv_obj_t* lv_img_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
} else {
|
||||
img_ext_dp->auto_size = 0;
|
||||
}
|
||||
lv_obj_set_style(new_obj_dp, &lv_imgs_def);
|
||||
lv_obj_set_style(new_obj_dp, lv_imgs_get(LV_IMGS_DEF, NULL));
|
||||
} else {
|
||||
img_ext_dp->auto_size = LV_EA(copy_dp, lv_img_ext_t)->auto_size;
|
||||
lv_img_set_file(new_obj_dp, LV_EA(copy_dp, lv_img_ext_t)->fn_dp);
|
||||
@ -126,6 +124,14 @@ bool lv_img_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param)
|
||||
*/
|
||||
lv_imgs_t * lv_imgs_get(lv_imgs_builtin_t style, lv_imgs_t * copy_p)
|
||||
{
|
||||
static bool style_inited = false;
|
||||
|
||||
/*Make the style initialization if it is not done yet*/
|
||||
if(style_inited == false) {
|
||||
lv_imgs_init();
|
||||
style_inited = true;
|
||||
}
|
||||
|
||||
lv_imgs_t * style_p;
|
||||
|
||||
switch(style) {
|
||||
@ -152,7 +158,7 @@ lv_imgs_t * lv_imgs_get(lv_imgs_builtin_t style, lv_imgs_t * copy_p)
|
||||
|
||||
/**
|
||||
* Create a file to the RAMFS from a picture data
|
||||
* @param fn file name of the new file (e.g. "pic1", will be avaliable at "U:/pic1")
|
||||
* @param fn file name of the new file (e.g. "pic1", will be available at "U:/pic1")
|
||||
* @param data_p pointer to a color map with lv_img_raw_header_t header
|
||||
* @return result of the file operation. FS_RES_OK or any error from fs_res_t
|
||||
*/
|
||||
@ -292,6 +298,23 @@ static bool lv_img_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Initialize the image styles
|
||||
*/
|
||||
static void lv_imgs_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
lv_imgs_def.objs.color = COLOR_BLACK;
|
||||
lv_imgs_def.recolor_opa = OPA_TRANSP;
|
||||
|
||||
/*Dark style*/
|
||||
memcpy(&lv_imgs_dark, &lv_imgs_def, sizeof(lv_imgs_t));
|
||||
lv_imgs_dark.objs.color = COLOR_WHITE; lv_imgs_dark.recolor_opa = OPA_50;
|
||||
|
||||
/*Light style*/
|
||||
memcpy(&lv_imgs_light, &lv_imgs_dark, sizeof(lv_imgs_t));
|
||||
lv_imgs_light.objs.color = COLOR_WHITE; lv_imgs_light.recolor_opa = OPA_50;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -27,35 +27,15 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_label_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
|
||||
static void lv_labels_init(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_labels_t lv_labels_def = {
|
||||
.font = LV_FONT_DEFAULT, .objs.color = COLOR_MAKE(0x10, 0x18, 0x20),
|
||||
.letter_space = 2 * LV_STYLE_MULT, .line_space = 2 * LV_STYLE_MULT,
|
||||
.mid = 1
|
||||
};
|
||||
|
||||
static lv_labels_t lv_labels_btn = {
|
||||
.font = LV_FONT_DEFAULT, .objs.color = COLOR_MAKE(0xd0, 0xe0, 0xf0),
|
||||
.letter_space = 2 * LV_STYLE_MULT, .line_space = 2 * LV_STYLE_MULT,
|
||||
.mid = 1,
|
||||
};
|
||||
|
||||
static lv_labels_t lv_labels_title = {
|
||||
.font = LV_FONT_DEFAULT, .objs.color = COLOR_MAKE(0x10, 0x20, 0x30),
|
||||
.letter_space = 4 * LV_STYLE_MULT, .line_space = 4 * LV_STYLE_MULT,
|
||||
.mid = 0,
|
||||
};
|
||||
|
||||
static lv_labels_t lv_labels_txt = {
|
||||
.font = LV_FONT_DEFAULT, .objs.color = COLOR_MAKE(0x16, 0x23, 0x34),
|
||||
.letter_space = 1 * LV_STYLE_MULT, .line_space = 2 * LV_STYLE_MULT,
|
||||
.mid = 0,
|
||||
};
|
||||
|
||||
|
||||
static lv_labels_t lv_labels_def;
|
||||
static lv_labels_t lv_labels_btn;
|
||||
static lv_labels_t lv_labels_title;
|
||||
static lv_labels_t lv_labels_txt;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -90,7 +70,7 @@ lv_obj_t* lv_label_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
if(copy_dp == NULL) {
|
||||
lv_obj_set_opa(new_obj, OPA_COVER);
|
||||
lv_obj_set_click(new_obj, false);
|
||||
lv_obj_set_style(new_obj, &lv_labels_def);
|
||||
lv_obj_set_style(new_obj, lv_labels_get(LV_LABELS_DEF, NULL));
|
||||
lv_label_set_fixw(new_obj, false);
|
||||
lv_label_set_text(new_obj, "Text");
|
||||
}
|
||||
@ -367,6 +347,14 @@ uint16_t lv_label_get_letter_on(lv_obj_t * obj_dp, point_t * pos_p)
|
||||
*/
|
||||
lv_labels_t * lv_labels_get(lv_labels_builtin_t style, lv_labels_t * copy_p)
|
||||
{
|
||||
static bool style_inited = false;
|
||||
|
||||
/*Make the style initialization if it is not done yet*/
|
||||
if(style_inited == false) {
|
||||
lv_labels_init();
|
||||
style_inited = true;
|
||||
}
|
||||
|
||||
lv_labels_t * style_p;
|
||||
|
||||
switch(style) {
|
||||
@ -426,4 +414,34 @@ static bool lv_label_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_m
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the label styles
|
||||
*/
|
||||
static void lv_labels_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
lv_labels_def.font = LV_FONT_DEFAULT;
|
||||
lv_labels_def.objs.color = COLOR_MAKE(0x10, 0x18, 0x20);
|
||||
lv_labels_def.letter_space = 2 * LV_STYLE_MULT;
|
||||
lv_labels_def.line_space = 2 * LV_STYLE_MULT;
|
||||
lv_labels_def.mid = 0;
|
||||
|
||||
memcpy(&lv_labels_btn, &lv_labels_def, sizeof(lv_labels_t));
|
||||
lv_labels_btn.objs.color = COLOR_MAKE(0xd0, 0xe0, 0xf0);
|
||||
lv_labels_btn.mid = 1;
|
||||
|
||||
memcpy(&lv_labels_title, &lv_labels_def, sizeof(lv_labels_t));
|
||||
lv_labels_title.objs.color = COLOR_MAKE(0x10, 0x20, 0x30);
|
||||
lv_labels_title.letter_space = 4 * LV_STYLE_MULT;
|
||||
lv_labels_title.line_space = 4 * LV_STYLE_MULT;
|
||||
lv_labels_title.mid = 0;
|
||||
|
||||
|
||||
memcpy(&lv_labels_txt, &lv_labels_def, sizeof(lv_labels_t));
|
||||
lv_labels_txt.objs.color = COLOR_MAKE(0x16, 0x23, 0x34);
|
||||
lv_labels_txt.letter_space = 1 * LV_STYLE_MULT;
|
||||
lv_labels_txt.line_space = 2 * LV_STYLE_MULT;
|
||||
lv_labels_txt.mid = 0;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -34,25 +34,14 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_led_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
|
||||
static void lv_leds_init(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/* A RED style */
|
||||
static lv_leds_t lv_leds_def =
|
||||
{ .rects.objs.color = COLOR_RED, .rects.gcolor = COLOR_MARRON,
|
||||
.rects.bcolor = COLOR_WHITE, .rects.bwidth = 4 * LV_STYLE_MULT, .rects.bopa = 50,
|
||||
.rects.round = LV_RECT_CIRCLE, .rects.empty = 0,
|
||||
.rects.hpad = 0, .rects.vpad = 0, .rects.opad = 0 /*Fit and layout is not used*/ };
|
||||
|
||||
|
||||
/* A GREEN style */
|
||||
static lv_leds_t lv_leds_green =
|
||||
{ .rects.objs.color = COLOR_LIME, .rects.gcolor = COLOR_GREEN,
|
||||
.rects.bcolor = COLOR_WHITE, .rects.bwidth = 4 * LV_STYLE_MULT, .rects.bopa = 50,
|
||||
.rects.round = LV_RECT_CIRCLE, .rects.empty = 0,
|
||||
.rects.hpad = 0, .rects.vpad = 0, .rects.opad = 0 /*Fit and layout is not used*/ };
|
||||
static lv_leds_t lv_leds_def; /*Red*/
|
||||
static lv_leds_t lv_leds_green;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -88,7 +77,7 @@ lv_obj_t* lv_led_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
/*Init the new led object*/
|
||||
if(copy_dp == NULL) {
|
||||
ext_dp->bright = LV_LED_BRIGHTNESS_DEF;
|
||||
lv_obj_set_style(new_obj_dp, &lv_leds_def);
|
||||
lv_obj_set_style(new_obj_dp, lv_leds_get(LV_LEDS_DEF, NULL));
|
||||
lv_obj_set_size_us(new_obj_dp, 40, 40);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
@ -190,6 +179,14 @@ void lv_led_tgl(lv_obj_t * obj_dp)
|
||||
*/
|
||||
lv_leds_t * lv_leds_get(lv_leds_builtin_t style, lv_leds_t * copy_p)
|
||||
{
|
||||
static bool style_inited = false;
|
||||
|
||||
/*Make the style initialization if it is not done yet*/
|
||||
if(style_inited == false) {
|
||||
lv_leds_init();
|
||||
style_inited = true;
|
||||
}
|
||||
|
||||
lv_leds_t *style_p;
|
||||
|
||||
switch(style) {
|
||||
@ -263,5 +260,28 @@ static bool lv_led_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mod
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the led styles
|
||||
*/
|
||||
static void lv_leds_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
lv_rects_get(LV_RECTS_DEF, &lv_leds_def.rects);
|
||||
lv_leds_def.rects.objs.color = COLOR_RED;
|
||||
lv_leds_def.rects.gcolor = COLOR_MARRON,
|
||||
lv_leds_def.rects.bcolor = COLOR_WHITE;
|
||||
lv_leds_def.rects.bwidth = 4 * LV_STYLE_MULT;
|
||||
lv_leds_def.rects.bopa = 50;
|
||||
lv_leds_def.rects.round = LV_RECT_CIRCLE;
|
||||
lv_leds_def.rects.hpad = 0;
|
||||
lv_leds_def.rects.vpad = 0;
|
||||
lv_leds_def.rects.opad = 0;
|
||||
|
||||
/* Green style */
|
||||
memcpy(&lv_leds_green, &lv_leds_def, sizeof(lv_leds_t));
|
||||
lv_leds_green.rects.objs.color = COLOR_LIME;
|
||||
lv_leds_green.rects.gcolor = COLOR_GREEN;
|
||||
lv_leds_green.rects.bcolor = COLOR_WHITE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -34,15 +34,14 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_line_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
|
||||
static void lv_lines_init(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_lines_t lv_lines_def = { .width = 2 * LV_STYLE_MULT, .objs.color = COLOR_RED};
|
||||
|
||||
static lv_lines_t lv_lines_decor = { .width = 1 * LV_STYLE_MULT, .objs.color = COLOR_GRAY};
|
||||
|
||||
static lv_lines_t lv_lines_chart = { .width = 3 * LV_STYLE_MULT, .objs.color = COLOR_BLUE};
|
||||
static lv_lines_t lv_lines_def;
|
||||
static lv_lines_t lv_lines_decor;
|
||||
static lv_lines_t lv_lines_chart;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -75,7 +74,7 @@ lv_obj_t* lv_line_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
ext_p->auto_size = 1;
|
||||
ext_p->y_inv = 0;
|
||||
ext_p->upscale = 0;
|
||||
lv_obj_set_style(new_obj_dp, &lv_lines_def);
|
||||
lv_obj_set_style(new_obj_dp, lv_lines_get(LV_LINES_DEF, NULL));
|
||||
}
|
||||
/*Copy 'copy_p' is not NULL*/
|
||||
else {
|
||||
@ -249,6 +248,14 @@ bool lv_line_get_upscale(lv_obj_t * obj_dp)
|
||||
*/
|
||||
lv_lines_t * lv_lines_get(lv_lines_builtin_t style, lv_lines_t * copy_p)
|
||||
{
|
||||
static bool style_inited = false;
|
||||
|
||||
/*Make the style initialization if it is not done yet*/
|
||||
if(style_inited == false) {
|
||||
lv_lines_init();
|
||||
style_inited = true;
|
||||
}
|
||||
|
||||
lv_lines_t *style_p;
|
||||
|
||||
switch(style) {
|
||||
@ -330,4 +337,24 @@ static bool lv_line_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the line styles
|
||||
*/
|
||||
static void lv_lines_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
lv_lines_def.width = 2 * LV_STYLE_MULT;
|
||||
lv_lines_def.objs.color = COLOR_RED;
|
||||
lv_lines_def.objs.transp = 0;
|
||||
|
||||
/*Decoration line style*/
|
||||
memcpy(&lv_lines_decor, &lv_lines_def, sizeof(lv_lines_t));
|
||||
lv_lines_decor.width = 1 * LV_STYLE_MULT;
|
||||
lv_lines_decor.objs.color = COLOR_GRAY;
|
||||
|
||||
/*Chart line style*/
|
||||
memcpy(&lv_lines_chart, &lv_lines_def, sizeof(lv_lines_t));
|
||||
lv_lines_chart.width = 3 * LV_STYLE_MULT;
|
||||
lv_lines_chart.objs.color = COLOR_RED;
|
||||
}
|
||||
#endif
|
||||
|
@ -28,103 +28,13 @@
|
||||
#if 0
|
||||
static bool lv_list_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
|
||||
#endif
|
||||
static void lv_lists_init(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_lists_t lv_lists_def =
|
||||
{
|
||||
/*Page style*/
|
||||
.pages.bg_rects.objs.color = COLOR_MAKE(0x50, 0x70, 0x90), .pages.bg_rects.gcolor = COLOR_MAKE(0x70, 0xA0, 0xC0),
|
||||
.pages.bg_rects.bcolor = COLOR_WHITE, .pages.bg_rects.bopa = 50, .pages.bg_rects.bwidth = 2 * LV_STYLE_MULT,
|
||||
.pages.bg_rects.round = 4 * LV_STYLE_MULT,
|
||||
.pages.bg_rects.empty = 0,
|
||||
.pages.bg_rects.vpad = 10 * LV_STYLE_MULT,
|
||||
.pages.bg_rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.pages.bg_rects.opad = 5 * LV_STYLE_MULT,
|
||||
|
||||
.pages.scrable_rects.objs.color = COLOR_WHITE,
|
||||
.pages.scrable_rects.gcolor = COLOR_SILVER,
|
||||
.pages.scrable_rects.bcolor = COLOR_GRAY,
|
||||
.pages.scrable_rects.bopa = 100,
|
||||
.pages.scrable_rects.bwidth = 2 * LV_STYLE_MULT,
|
||||
.pages.scrable_rects.round = 4 * LV_STYLE_MULT,
|
||||
.pages.scrable_rects.empty = 0,
|
||||
.pages.scrable_rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.pages.scrable_rects.vpad = 10 * LV_STYLE_MULT,
|
||||
.pages.scrable_rects.opad = 10 * LV_STYLE_MULT,
|
||||
|
||||
.pages.sb_rects.objs.color = COLOR_BLACK, .pages.sb_rects.gcolor = COLOR_BLACK, .pages.sb_rects.bcolor = COLOR_WHITE,
|
||||
.pages.sb_rects.bopa = 50, .pages.sb_rects.bwidth = 1 * LV_STYLE_MULT, .pages.sb_rects.round = 5 * LV_STYLE_MULT,
|
||||
.pages.sb_rects.empty = 0, .pages.sb_width= 8 * LV_STYLE_MULT, .pages.sb_opa=50, .pages.sb_mode = LV_PAGE_SB_MODE_AUTO,
|
||||
|
||||
/*List element style*/
|
||||
.liste_btns.mcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0xa0, 0xa0, 0xa0), .liste_btns.gcolor[LV_BTN_STATE_REL] = COLOR_WHITE, .liste_btns.bcolor[LV_BTN_STATE_REL] = COLOR_WHITE,
|
||||
.liste_btns.mcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0xa0, 0xa0, 0xa0), .liste_btns.gcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0xa0, 0xc0, 0xe0), .liste_btns.bcolor[LV_BTN_STATE_PR] = COLOR_WHITE,
|
||||
.liste_btns.mcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x60,0x80,0xa0), .liste_btns.gcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0xc0, 0xd0, 0xf0), .liste_btns.bcolor[LV_BTN_STATE_TGL_REL] = COLOR_WHITE,
|
||||
.liste_btns.mcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x60, 0x80, 0xa0), .liste_btns.gcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x80, 0xa0, 0xc0), .liste_btns.bcolor[LV_BTN_STATE_TGL_PR] = COLOR_WHITE,
|
||||
.liste_btns.mcolor[LV_BTN_STATE_INA] = COLOR_SILVER, .liste_btns.gcolor[LV_BTN_STATE_INA] = COLOR_GRAY, .liste_btns.bcolor[LV_BTN_STATE_INA] = COLOR_WHITE,
|
||||
.liste_btns.rects.bwidth = 2 * LV_STYLE_MULT, .liste_btns.rects.bopa = 50,
|
||||
.liste_btns.rects.empty = 0, .liste_btns.rects.round = 4 * LV_STYLE_MULT,
|
||||
.liste_btns.rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.liste_btns.rects.vpad = 10 * LV_STYLE_MULT,
|
||||
.liste_btns.rects.opad = 20 * LV_STYLE_MULT,
|
||||
|
||||
.liste_labels.objs.color = COLOR_MAKE(0x20,0x20,0x20), .liste_labels.font = LV_FONT_DEFAULT,
|
||||
.liste_labels.letter_space = 2 * LV_STYLE_MULT, .liste_labels.line_space = 2 * LV_STYLE_MULT,
|
||||
.liste_labels.mid = 0,
|
||||
|
||||
.liste_imgs.recolor_opa = OPA_COVER,
|
||||
|
||||
.liste_layout = LV_RECT_LAYOUT_ROW_M
|
||||
};
|
||||
|
||||
static lv_lists_t lv_lists_tight =
|
||||
{
|
||||
/*Page style*/
|
||||
.pages.bg_rects.objs.color = COLOR_MAKE(0x50, 0x70, 0x90), .pages.bg_rects.gcolor = COLOR_MAKE(0x70, 0xA0, 0xC0),
|
||||
.pages.bg_rects.bcolor = COLOR_WHITE, .pages.bg_rects.bopa = 50, .pages.bg_rects.bwidth = 0 * LV_STYLE_MULT,
|
||||
.pages.bg_rects.round = 4 * LV_STYLE_MULT,
|
||||
.pages.bg_rects.empty = 1,
|
||||
.pages.bg_rects.vpad = 0 * LV_STYLE_MULT,
|
||||
.pages.bg_rects.hpad = 0 * LV_STYLE_MULT,
|
||||
.pages.bg_rects.opad = 0 * LV_STYLE_MULT,
|
||||
|
||||
.pages.scrable_rects.objs.color = COLOR_WHITE,
|
||||
.pages.scrable_rects.gcolor = COLOR_SILVER,
|
||||
.pages.scrable_rects.bcolor = COLOR_GRAY,
|
||||
.pages.scrable_rects.bopa = 100,
|
||||
.pages.scrable_rects.bwidth = 0 * LV_STYLE_MULT,
|
||||
.pages.scrable_rects.round = 0 * LV_STYLE_MULT,
|
||||
.pages.scrable_rects.empty = 0,
|
||||
.pages.scrable_rects.hpad = 0 * LV_STYLE_MULT,
|
||||
.pages.scrable_rects.vpad = 0 * LV_STYLE_MULT,
|
||||
.pages.scrable_rects.opad = 0 * LV_STYLE_MULT,
|
||||
|
||||
.pages.sb_rects.objs.color = COLOR_BLACK, .pages.sb_rects.gcolor = COLOR_BLACK, .pages.sb_rects.bcolor = COLOR_WHITE,
|
||||
.pages.sb_rects.bopa = 50, .pages.sb_rects.bwidth = 1 * LV_STYLE_MULT, .pages.sb_rects.round = 5 * LV_STYLE_MULT,
|
||||
.pages.sb_rects.empty = 0, .pages.sb_width= 8 * LV_STYLE_MULT, .pages.sb_opa=50, .pages.sb_mode = LV_PAGE_SB_MODE_AUTO,
|
||||
|
||||
/*List element style*/
|
||||
.liste_btns.mcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0xa0, 0xa0, 0xa0), .liste_btns.gcolor[LV_BTN_STATE_REL] = COLOR_WHITE, .liste_btns.bcolor[LV_BTN_STATE_REL] = COLOR_WHITE,
|
||||
.liste_btns.mcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0xa0, 0xa0, 0xa0), .liste_btns.gcolor[LV_BTN_STATE_PR] = COLOR_MAKE(0xa0, 0xc0, 0xe0), .liste_btns.bcolor[LV_BTN_STATE_PR] = COLOR_WHITE,
|
||||
.liste_btns.mcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0x60,0x80,0xa0), .liste_btns.gcolor[LV_BTN_STATE_TGL_REL] = COLOR_MAKE(0xc0, 0xd0, 0xf0), .liste_btns.bcolor[LV_BTN_STATE_TGL_REL] = COLOR_WHITE,
|
||||
.liste_btns.mcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x60, 0x80, 0xa0), .liste_btns.gcolor[LV_BTN_STATE_TGL_PR] = COLOR_MAKE(0x80, 0xa0, 0xc0), .liste_btns.bcolor[LV_BTN_STATE_TGL_PR] = COLOR_WHITE,
|
||||
.liste_btns.mcolor[LV_BTN_STATE_INA] = COLOR_SILVER, .liste_btns.gcolor[LV_BTN_STATE_INA] = COLOR_GRAY, .liste_btns.bcolor[LV_BTN_STATE_INA] = COLOR_WHITE,
|
||||
.liste_btns.rects.bwidth = 2 * LV_STYLE_MULT, .liste_btns.rects.bopa = 50,
|
||||
.liste_btns.rects.empty = 0, .liste_btns.rects.round = 4 * LV_STYLE_MULT,
|
||||
.liste_btns.rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.liste_btns.rects.vpad = 10 * LV_STYLE_MULT,
|
||||
.liste_btns.rects.opad = 20 * LV_STYLE_MULT,
|
||||
|
||||
.liste_labels.objs.color = COLOR_MAKE(0x20,0x20,0x20), .liste_labels.font = LV_FONT_DEFAULT,
|
||||
.liste_labels.letter_space = 2 * LV_STYLE_MULT, .liste_labels.line_space = 2 * LV_STYLE_MULT,
|
||||
.liste_labels.mid = 0,
|
||||
|
||||
.liste_imgs.recolor_opa = OPA_COVER,
|
||||
|
||||
.liste_layout = LV_RECT_LAYOUT_ROW_M
|
||||
};
|
||||
static lv_lists_t lv_lists_def;
|
||||
static lv_lists_t lv_lists_tight;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -157,7 +67,7 @@ lv_obj_t* lv_list_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
if(copy_dp == NULL) {
|
||||
ext_p->fit = LV_LIST_FIT_LONGEST;
|
||||
lv_obj_set_size_us(new_obj_dp, 100, 150);
|
||||
lv_obj_set_style(new_obj_dp, &lv_lists_def);
|
||||
lv_obj_set_style(new_obj_dp, lv_lists_get(LV_LISTS_DEF, NULL));
|
||||
lv_rect_set_layout(LV_EA(new_obj_dp, lv_list_ext_t)->page_ext.scrolling_dp, LV_LIST_LAYOUT_DEF);
|
||||
} else {
|
||||
lv_list_ext_t * copy_ext_dp = lv_obj_get_ext(copy_dp);
|
||||
@ -346,6 +256,14 @@ lv_list_fit_t lv_list_get_fit(lv_obj_t * obj_dp)
|
||||
*/
|
||||
lv_lists_t * lv_lists_get(lv_lists_builtin_t style, lv_lists_t * copy_p)
|
||||
{
|
||||
static bool style_inited = false;
|
||||
|
||||
/*Make the style initialization if it is not done yet*/
|
||||
if(style_inited == false) {
|
||||
lv_lists_init();
|
||||
style_inited = true;
|
||||
}
|
||||
|
||||
lv_lists_t *style_p;
|
||||
|
||||
switch(style) {
|
||||
@ -397,5 +315,38 @@ static bool lv_list_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initialize the list styles
|
||||
*/
|
||||
static void lv_lists_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
lv_pages_get(LV_PAGES_TRANSP, &lv_lists_def.pages);
|
||||
lv_lists_def.pages.bg_rects.vpad = 0 * LV_STYLE_MULT;
|
||||
lv_lists_def.pages.bg_rects.hpad = 0 * LV_STYLE_MULT;
|
||||
lv_lists_def.pages.bg_rects.opad = 0 * LV_STYLE_MULT;
|
||||
|
||||
lv_lists_def.pages.scrable_rects.vpad = 10 * LV_STYLE_MULT;
|
||||
lv_lists_def.pages.scrable_rects.hpad = 10 * LV_STYLE_MULT;
|
||||
lv_lists_def.pages.scrable_rects.opad = 5 * LV_STYLE_MULT;
|
||||
|
||||
lv_btns_get(LV_BTNS_DEF, &lv_lists_def.liste_btns); /*List element button style*/
|
||||
|
||||
lv_labels_get(LV_LABELS_BTN, &lv_lists_def.liste_labels); /*List element label style*/
|
||||
lv_lists_def.liste_labels.mid = 0;
|
||||
|
||||
lv_imgs_get(LV_IMGS_DEF, &lv_lists_def.liste_imgs); /*Lit element image style*/
|
||||
|
||||
lv_lists_def.liste_layout = LV_RECT_LAYOUT_ROW_M;
|
||||
|
||||
memcpy(&lv_lists_tight, &lv_lists_def, sizeof(lv_lists_t));
|
||||
lv_lists_tight.pages.bg_rects.vpad = 0 * LV_STYLE_MULT;
|
||||
lv_lists_tight.pages.bg_rects.hpad = 0 * LV_STYLE_MULT;
|
||||
lv_lists_tight.pages.bg_rects.opad = 0 * LV_STYLE_MULT;
|
||||
|
||||
lv_lists_tight.pages.scrable_rects.vpad = 0 * LV_STYLE_MULT;
|
||||
lv_lists_tight.pages.scrable_rects.hpad = 0 * LV_STYLE_MULT;
|
||||
lv_lists_tight.pages.scrable_rects.opad = 0 * LV_STYLE_MULT;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -54,7 +54,7 @@ static lv_templs_t lv_templs_def =
|
||||
* @param copy_dp pointer to a template object, if not NULL then the new object will be copied from it
|
||||
* @return pointer to the created template
|
||||
*/
|
||||
lv_obj_t* lv_templ_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
lv_obj_t * lv_templ_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
{
|
||||
/*Create the ancestor object*/
|
||||
lv_obj_t* new_obj_dp = lv_obj_create(par_dp, copy_dp);
|
||||
@ -64,6 +64,7 @@ lv_obj_t* lv_templ_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
lv_templ_ext_t * ext_dp = lv_obj_alloc_ext(new_obj_dp, sizeof(lv_templ_ext_t));
|
||||
dm_assert(ext_dp);
|
||||
|
||||
/*The signal and design functions are not copied so set them here*/
|
||||
lv_obj_set_signal_f(new_obj_dp, lv_templ_signal);
|
||||
lv_obj_set_design_f(new_obj_dp, lv_templ_design);
|
||||
|
||||
@ -73,7 +74,7 @@ lv_obj_t* lv_templ_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
else {
|
||||
|
||||
lv_templ_ext_t * copy_ext_dp = lv_obj_get_ext(copy_dp);
|
||||
}
|
||||
|
||||
return new_obj_dp;
|
||||
|
@ -52,7 +52,7 @@ typedef struct
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
lv_obj_t* lv_templ_create(lv_obj_t* par_dp, lv_obj_t * copy_dp);
|
||||
lv_obj_t * lv_templ_create(lv_obj_t* par_dp, lv_obj_t * copy_dp);
|
||||
bool lv_templ_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param);
|
||||
lv_templs_t * lv_templs_get(lv_templs_builtin_t style, lv_templs_t * copy_p);
|
||||
|
||||
|
@ -29,89 +29,16 @@
|
||||
static void lv_page_sb_refresh(lv_obj_t* main_dp);
|
||||
static bool lv_page_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
|
||||
static bool lv_scrolling_signal(lv_obj_t* obj_dp, lv_signal_t sign, void* param);
|
||||
static void lv_pages_init(void);;
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_design_f_t ancestor_design_f;
|
||||
|
||||
static lv_pages_t lv_pages_def =
|
||||
{
|
||||
.bg_rects.objs.color = COLOR_MAKE(0x50, 0x70, 0x90),
|
||||
.bg_rects.gcolor = COLOR_MAKE(0x70, 0xA0, 0xC0),
|
||||
.bg_rects.bcolor = COLOR_WHITE,
|
||||
.bg_rects.bopa = 50,
|
||||
.bg_rects.bwidth = 2 * LV_STYLE_MULT,
|
||||
.bg_rects.round = 4 * LV_STYLE_MULT,
|
||||
.bg_rects.empty = 0,
|
||||
.bg_rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.bg_rects.vpad = 10 * LV_STYLE_MULT,
|
||||
.bg_rects.opad = 5 * LV_STYLE_MULT,
|
||||
static lv_pages_t lv_pages_def;
|
||||
static lv_pages_t lv_pages_transp;
|
||||
|
||||
.scrable_rects.objs.color = COLOR_WHITE,
|
||||
.scrable_rects.gcolor = COLOR_SILVER,
|
||||
.scrable_rects.bcolor = COLOR_GRAY,
|
||||
.scrable_rects.bopa = 50,
|
||||
.scrable_rects.bwidth = 0 * LV_STYLE_MULT,
|
||||
.scrable_rects.round = 2 * LV_STYLE_MULT,
|
||||
.scrable_rects.empty = 0,
|
||||
.scrable_rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.scrable_rects.vpad = 10 * LV_STYLE_MULT,
|
||||
.scrable_rects.opad = 5 * LV_STYLE_MULT,
|
||||
|
||||
.sb_rects.objs.color = COLOR_BLACK,
|
||||
.sb_rects.gcolor = COLOR_BLACK,
|
||||
.sb_rects.bcolor = COLOR_WHITE,
|
||||
.sb_rects.bopa = 50,
|
||||
.sb_rects.bwidth = 1 * LV_STYLE_MULT,
|
||||
.sb_rects.round = 5 * LV_STYLE_MULT,
|
||||
.sb_rects.empty = 0,
|
||||
.sb_rects.hpad = 0,
|
||||
.sb_rects.vpad = 0,
|
||||
.sb_rects.opad = 0,
|
||||
|
||||
.sb_width= 8 * LV_STYLE_MULT,
|
||||
.sb_opa=50,
|
||||
.sb_mode = LV_PAGE_SB_MODE_AUTO,
|
||||
|
||||
};
|
||||
|
||||
static lv_pages_t lv_pages_transp =
|
||||
{
|
||||
.bg_rects.objs.color = COLOR_MAKE(0x50, 0x70, 0x90),
|
||||
.bg_rects.gcolor = COLOR_MAKE(0x70, 0xA0, 0xC0),
|
||||
.bg_rects.bcolor = COLOR_WHITE,
|
||||
.bg_rects.bopa = 50,
|
||||
.bg_rects.bwidth = 0 * LV_STYLE_MULT,
|
||||
.bg_rects.round = 2 * LV_STYLE_MULT,
|
||||
.bg_rects.empty = 0,
|
||||
.bg_rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.bg_rects.vpad = 10 * LV_STYLE_MULT,
|
||||
.bg_rects.opad = 5 * LV_STYLE_MULT,
|
||||
|
||||
.scrable_rects.objs.transp = 1,
|
||||
.scrable_rects.empty = 1,
|
||||
.scrable_rects.bwidth = 0,
|
||||
.scrable_rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.scrable_rects.vpad = 10 * LV_STYLE_MULT,
|
||||
.scrable_rects.vpad = 10 * LV_STYLE_MULT,
|
||||
|
||||
.sb_rects.objs.color = COLOR_BLACK,
|
||||
.sb_rects.gcolor = COLOR_BLACK,
|
||||
.sb_rects.bcolor = COLOR_WHITE,
|
||||
.sb_rects.bopa = 0,
|
||||
.sb_rects.bwidth = 1 * LV_STYLE_MULT,
|
||||
.sb_rects.round = 5 * LV_STYLE_MULT,
|
||||
.sb_rects.empty = 0,
|
||||
.sb_rects.hpad = 0,
|
||||
.sb_rects.vpad = 0,
|
||||
.sb_rects.opad = 0,
|
||||
|
||||
.sb_width = 8 * LV_STYLE_MULT,
|
||||
.sb_opa = 50,
|
||||
.sb_mode = LV_PAGE_SB_MODE_AUTO,
|
||||
|
||||
};
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
@ -146,18 +73,19 @@ lv_obj_t* lv_page_create(lv_obj_t * par_dp, lv_obj_t * copy_dp)
|
||||
|
||||
/*Init the new page object*/
|
||||
if(copy_dp == NULL) {
|
||||
lv_pages_t * style = lv_pages_get(LV_PAGES_DEF, NULL);
|
||||
ext_dp->scrolling_dp = lv_rect_create(new_obj_dp, NULL);
|
||||
lv_obj_set_signal_f(ext_dp->scrolling_dp, lv_scrolling_signal);
|
||||
lv_obj_set_drag(ext_dp->scrolling_dp, true);
|
||||
lv_obj_set_drag_throw(ext_dp->scrolling_dp, true);
|
||||
lv_rect_set_fit(ext_dp->scrolling_dp, true, true);
|
||||
lv_obj_set_style(ext_dp->scrolling_dp, &lv_pages_def.scrable_rects);
|
||||
lv_obj_set_style(ext_dp->scrolling_dp, &style->scrable_rects);
|
||||
|
||||
/* Add the signal function only if 'scrolling_dp' is created
|
||||
* because everything has to be ready before any signal is received*/
|
||||
lv_obj_set_signal_f(new_obj_dp, lv_page_signal);
|
||||
lv_obj_set_design_f(new_obj_dp, lv_page_design);
|
||||
lv_obj_set_style(new_obj_dp, &lv_pages_def);
|
||||
lv_obj_set_style(new_obj_dp, style);
|
||||
} else {
|
||||
lv_page_ext_t * copy_ext_dp = lv_obj_get_ext(copy_dp);
|
||||
ext_dp->scrolling_dp = lv_rect_create(new_obj_dp, copy_ext_dp->scrolling_dp);
|
||||
@ -364,6 +292,14 @@ void lv_page_glue_obj(lv_obj_t* obj_dp, bool en)
|
||||
*/
|
||||
lv_pages_t * lv_pages_get(lv_pages_builtin_t style, lv_pages_t * to_copy)
|
||||
{
|
||||
static bool style_inited = false;
|
||||
|
||||
/*Make the style initialization if it is not done yet*/
|
||||
if(style_inited == false) {
|
||||
lv_pages_init();
|
||||
style_inited = true;
|
||||
}
|
||||
|
||||
lv_pages_t * style_p;
|
||||
|
||||
switch(style) {
|
||||
@ -497,7 +433,37 @@ static void lv_page_sb_refresh(lv_obj_t* page_dp)
|
||||
|
||||
lv_inv_area(&page_ext_dp->sbh);
|
||||
lv_inv_area(&page_ext_dp->sbv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the page styles
|
||||
*/
|
||||
static void lv_pages_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
lv_rects_get(LV_RECTS_DEF, &lv_pages_def.bg_rects);
|
||||
|
||||
lv_rects_get(LV_RECTS_DEF, &lv_pages_def.scrable_rects);
|
||||
lv_pages_def.scrable_rects.objs.color = COLOR_WHITE;
|
||||
lv_pages_def.scrable_rects.gcolor = COLOR_SILVER;
|
||||
lv_pages_def.scrable_rects.bcolor = COLOR_GRAY;
|
||||
|
||||
lv_rects_get(LV_RECTS_DEF, &lv_pages_def.sb_rects);
|
||||
lv_pages_def.sb_rects.objs.color = COLOR_BLACK;
|
||||
lv_pages_def.sb_rects.gcolor = COLOR_BLACK;
|
||||
lv_pages_def.sb_rects.bcolor = COLOR_WHITE;
|
||||
lv_pages_def.sb_rects.bwidth = 1 * LV_STYLE_MULT;
|
||||
lv_pages_def.sb_rects.round = 5 * LV_STYLE_MULT;
|
||||
|
||||
lv_pages_def.sb_width= 8 * LV_STYLE_MULT;
|
||||
lv_pages_def.sb_opa=50;
|
||||
lv_pages_def.sb_mode = LV_PAGE_SB_MODE_AUTO;
|
||||
|
||||
/*Transparent style*/
|
||||
memcpy(&lv_pages_transp, &lv_pages_def, sizeof(lv_pages_t));
|
||||
lv_pages_transp.scrable_rects.objs.transp = 1;
|
||||
lv_pages_transp.scrable_rects.empty = 1;
|
||||
lv_pages_transp.scrable_rects.bwidth = 0;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -29,27 +29,13 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_pb_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
|
||||
static void lv_pbs_init(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static bool (*ancestor_design_fp)(lv_obj_t*, const area_t *, lv_design_mode_t);
|
||||
static lv_pbs_t lv_pbs_def =
|
||||
{
|
||||
/*Background*/
|
||||
.bg.objs.color = COLOR_WHITE, .bg.gcolor = COLOR_SILVER,
|
||||
.bg.bcolor = COLOR_BLACK, .bg.bwidth = 2 * LV_STYLE_MULT, .bg.bopa = 50,
|
||||
.bg.round = 4 * LV_STYLE_MULT, .bg.empty = 0,
|
||||
.bg.hpad = 0, .bg.vpad = 0, .bg.opad = 0,
|
||||
|
||||
/*Bar*/
|
||||
.bar.objs.color = COLOR_LIME, .bar.gcolor = COLOR_GREEN,
|
||||
.bar.bcolor = COLOR_BLACK, .bar.bwidth = 2 * LV_STYLE_MULT, .bar.bopa = 50,
|
||||
.bar.round = 4 * LV_STYLE_MULT, .bar.empty = 0,
|
||||
.bar.hpad = 0, .bar.vpad = 0, .bar.opad = 0,
|
||||
|
||||
|
||||
};
|
||||
static lv_pbs_t lv_pbs_def;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -97,7 +83,7 @@ lv_obj_t* lv_pb_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
|
||||
lv_rect_set_layout(new_obj_dp, LV_RECT_LAYOUT_CENTER);
|
||||
lv_obj_set_signal_f(new_obj_dp, lv_pb_signal);
|
||||
lv_obj_set_style(new_obj_dp, &lv_pbs_def);
|
||||
lv_obj_set_style(new_obj_dp, lv_pbs_get(LV_PBS_DEF, NULL));
|
||||
lv_obj_set_design_f(new_obj_dp, lv_pb_design);
|
||||
|
||||
lv_pb_set_value(new_obj_dp, ext_dp->act_value);
|
||||
@ -222,6 +208,14 @@ uint16_t lv_pb_get_value(lv_obj_t * obj_dp)
|
||||
*/
|
||||
lv_pbs_t * lv_pbs_get(lv_pbs_builtin_t style, lv_pbs_t * copy_p)
|
||||
{
|
||||
static bool style_inited = false;
|
||||
|
||||
/*Make the style initialization if it is not done yet*/
|
||||
if(style_inited == false) {
|
||||
lv_pbs_init();
|
||||
style_inited = true;
|
||||
}
|
||||
|
||||
lv_pbs_t *style_p;
|
||||
|
||||
switch(style) {
|
||||
@ -279,4 +273,24 @@ static bool lv_pb_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the progess bar styles
|
||||
*/
|
||||
static void lv_pbs_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
lv_rects_get(LV_RECTS_DEF, &lv_pbs_def.bg); /*Background*/
|
||||
lv_pbs_def.bg.objs.color = COLOR_WHITE;
|
||||
lv_pbs_def.bg.gcolor = COLOR_SILVER,
|
||||
lv_pbs_def.bg.bcolor = COLOR_BLACK;
|
||||
|
||||
lv_rects_get(LV_RECTS_DEF, &lv_pbs_def.bar); /*Bar*/
|
||||
lv_pbs_def.bar.objs.color = COLOR_LIME;
|
||||
lv_pbs_def.bar.gcolor = COLOR_GREEN;
|
||||
lv_pbs_def.bar.bcolor = COLOR_BLACK;
|
||||
|
||||
lv_labels_get(LV_LABELS_DEF, &lv_pbs_def.label);
|
||||
lv_pbs_def.label.objs.color = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -34,6 +34,7 @@
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static bool lv_rect_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
|
||||
static void lv_rects_init(void);
|
||||
static void lv_rect_refr_layout(lv_obj_t * obj_dp);
|
||||
static void lv_rect_layout_col(lv_obj_t * obj_dp);
|
||||
static void lv_rect_layout_row(lv_obj_t * obj_dp);
|
||||
@ -44,20 +45,9 @@ static void lv_rect_refr_autofit(lv_obj_t * obj_dp);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_rects_t lv_rects_def =
|
||||
{ .objs.color = COLOR_MAKE(0x50, 0x70, 0x90), .gcolor = COLOR_MAKE(0x70, 0xA0, 0xC0),
|
||||
.bcolor = COLOR_WHITE, .bwidth = 2 * LV_STYLE_MULT, .bopa = 50,
|
||||
.round = 4 * LV_STYLE_MULT, .empty = 0,
|
||||
.hpad = 10 * LV_STYLE_MULT, .vpad = 10 * LV_STYLE_MULT, .opad = 10 * LV_STYLE_MULT };
|
||||
|
||||
static lv_rects_t lv_rects_transp =
|
||||
{ .objs.transp = 1, .bwidth = 0, .empty = 1,
|
||||
.hpad = 10 * LV_STYLE_MULT, .vpad = 10 * LV_STYLE_MULT, .opad = 10 * LV_STYLE_MULT};
|
||||
|
||||
static lv_rects_t lv_rects_border =
|
||||
{ .bcolor = COLOR_BLACK, .bwidth = 2 * LV_STYLE_MULT, .bopa = 100,
|
||||
.round = 4 * LV_STYLE_MULT, .empty = 1,
|
||||
.hpad = 10 * LV_STYLE_MULT, .vpad = 10 * LV_STYLE_MULT, .opad = 10 * LV_STYLE_MULT};
|
||||
static lv_rects_t lv_rects_def;
|
||||
static lv_rects_t lv_rects_transp;
|
||||
static lv_rects_t lv_rects_border;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
@ -89,7 +79,7 @@ lv_obj_t* lv_rect_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
|
||||
/*Init the new rectangle*/
|
||||
if(copy_dp == NULL) {
|
||||
lv_obj_set_style(new_obj_dp, &lv_rects_def);
|
||||
lv_obj_set_style(new_obj_dp, lv_rects_get(LV_RECTS_DEF, NULL));
|
||||
rect_ext_dp->hfit_en = 0;
|
||||
rect_ext_dp->vfit_en = 0;
|
||||
} else {
|
||||
@ -217,6 +207,14 @@ bool lv_rect_get_vfit(lv_obj_t * obj_dp)
|
||||
*/
|
||||
lv_rects_t * lv_rects_get(lv_rects_builtin_t style, lv_rects_t * copy_p)
|
||||
{
|
||||
static bool style_inited = false;
|
||||
|
||||
/*Make the style initialization if it is not done yet*/
|
||||
if(style_inited == false) {
|
||||
lv_rects_init();
|
||||
style_inited = true;
|
||||
}
|
||||
|
||||
lv_rects_t * style_p;
|
||||
|
||||
switch(style) {
|
||||
@ -289,6 +287,38 @@ static bool lv_rect_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mo
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the rectangle styles
|
||||
*/
|
||||
static void lv_rects_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
lv_rects_def.objs.color = COLOR_MAKE(0x50, 0x70, 0x90);
|
||||
lv_rects_def.gcolor = COLOR_MAKE(0x70, 0xA0, 0xC0);
|
||||
lv_rects_def.bcolor = COLOR_WHITE;
|
||||
lv_rects_def.bwidth = 2 * LV_STYLE_MULT;
|
||||
lv_rects_def.bopa = 50;
|
||||
lv_rects_def.round = 4 * LV_STYLE_MULT;
|
||||
lv_rects_def.empty = 0;
|
||||
lv_rects_def.hpad = 10 * LV_STYLE_MULT;
|
||||
lv_rects_def.vpad = 10 * LV_STYLE_MULT;
|
||||
lv_rects_def.opad = 10 * LV_STYLE_MULT;
|
||||
|
||||
/*Transparent style*/
|
||||
memcpy(&lv_rects_transp, &lv_rects_def, sizeof(lv_rects_t));
|
||||
lv_rects_transp.objs.transp = 1;
|
||||
lv_rects_transp.bwidth = 0;
|
||||
lv_rects_transp.empty = 1;
|
||||
|
||||
/*Border style*/
|
||||
memcpy(&lv_rects_border, &lv_rects_def, sizeof(lv_rects_t));
|
||||
lv_rects_border.bcolor = COLOR_BLACK;
|
||||
lv_rects_border.bwidth = 2 * LV_STYLE_MULT;
|
||||
lv_rects_border.bopa = 100;
|
||||
lv_rects_border.round = 4 * LV_STYLE_MULT;
|
||||
lv_rects_border.empty = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the layout of a rectangle
|
||||
* @param obj_dp pointer to an object which layout should be refreshed
|
||||
|
@ -28,57 +28,12 @@
|
||||
static bool lv_ta_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
|
||||
static bool lv_ta_label_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
|
||||
static void lv_ta_save_valid_cursor_x(lv_obj_t * obj_dp);
|
||||
static void lv_tas_init(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_tas_t lv_tas_def =
|
||||
{ .pages.bg_rects.objs.color = COLOR_MAKE(0x50, 0x70, 0x90),
|
||||
.pages.bg_rects.gcolor = COLOR_MAKE(0x70, 0xA0, 0xC0),
|
||||
.pages.bg_rects.bcolor = COLOR_WHITE,
|
||||
.pages.bg_rects.bopa = 50,
|
||||
.pages.bg_rects.bwidth = 2 * LV_STYLE_MULT,
|
||||
.pages.bg_rects.round = 4 * LV_STYLE_MULT,
|
||||
.pages.bg_rects.empty = 0,
|
||||
.pages.bg_rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.pages.bg_rects.vpad = 10 * LV_STYLE_MULT,
|
||||
.pages.bg_rects.opad = 5 * LV_STYLE_MULT,
|
||||
|
||||
.pages.scrable_rects.objs.color = COLOR_WHITE,
|
||||
.pages.scrable_rects.gcolor = COLOR_SILVER,
|
||||
.pages.scrable_rects.bcolor = COLOR_GRAY,
|
||||
.pages.scrable_rects.bopa = 50,
|
||||
.pages.scrable_rects.bwidth = 0 * LV_STYLE_MULT,
|
||||
.pages.scrable_rects.round = 2 * LV_STYLE_MULT,
|
||||
.pages.scrable_rects.empty = 0,
|
||||
.pages.scrable_rects.hpad = 10 * LV_STYLE_MULT,
|
||||
.pages.scrable_rects.vpad = 10 * LV_STYLE_MULT,
|
||||
.pages.scrable_rects.opad = 5 * LV_STYLE_MULT,
|
||||
|
||||
.pages.sb_rects.objs.color = COLOR_BLACK,
|
||||
.pages.sb_rects.gcolor = COLOR_BLACK,
|
||||
.pages.sb_rects.bcolor = COLOR_WHITE,
|
||||
.pages.sb_rects.bopa = 50,
|
||||
.pages.sb_rects.bwidth = 1 * LV_STYLE_MULT,
|
||||
.pages.sb_rects.round = 5 * LV_STYLE_MULT,
|
||||
.pages.sb_rects.empty = 0,
|
||||
.pages.sb_rects.hpad = 0,
|
||||
.pages.sb_rects.vpad = 0,
|
||||
.pages.sb_rects.opad = 0,
|
||||
|
||||
.pages.sb_width= 8 * LV_STYLE_MULT,
|
||||
.pages.sb_opa=50,
|
||||
.pages.sb_mode = LV_PAGE_SB_MODE_AUTO,
|
||||
|
||||
.labels.font = LV_FONT_DEFAULT,
|
||||
.labels.objs.color = COLOR_MAKE(0x10, 0x18, 0x20),
|
||||
.labels.letter_space = 2 * LV_STYLE_MULT,
|
||||
.labels.line_space = 2 * LV_STYLE_MULT,
|
||||
.labels.mid = 0,
|
||||
|
||||
.cursor_color = COLOR_MAKE(0x20, 0x20, 0x20),
|
||||
.cursor_width = 2 * LV_STYLE_MULT, /*>1 px for visible cursor*/
|
||||
};
|
||||
static lv_tas_t lv_tas_def;
|
||||
|
||||
lv_design_f_t ancestor_design_f;
|
||||
lv_design_f_t label_design_f;
|
||||
@ -132,7 +87,7 @@ lv_obj_t* lv_ta_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
|
||||
lv_label_set_text(ext_dp->label_dp, "abc aaaa bbbb ccc\n123\nABC\nxyz\nwww\n007\nalma\n:)\naaaaaa");
|
||||
lv_page_glue_obj(ext_dp->label_dp, true);
|
||||
lv_obj_set_click(ext_dp->label_dp, true);
|
||||
lv_obj_set_style(new_obj_dp, &lv_tas_def);
|
||||
lv_obj_set_style(new_obj_dp, lv_tas_get(LV_TAS_DEF, NULL));
|
||||
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
@ -428,6 +383,14 @@ uint16_t lv_ta_get_cursor_pos(lv_obj_t * obj_dp)
|
||||
*/
|
||||
lv_tas_t * lv_tas_get(lv_tas_builtin_t style, lv_tas_t * copy_p)
|
||||
{
|
||||
static bool style_inited = false;
|
||||
|
||||
/*Make the style initialization if it is not done yet*/
|
||||
if(style_inited == false) {
|
||||
lv_tas_init();
|
||||
style_inited = true;
|
||||
}
|
||||
|
||||
lv_tas_t *style_p;
|
||||
|
||||
switch(style) {
|
||||
@ -526,5 +489,18 @@ static void lv_ta_save_valid_cursor_x(lv_obj_t * obj_dp)
|
||||
ta_ext_dp->cursor_valid_x = cur_pos.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the text area styles
|
||||
*/
|
||||
static void lv_tas_init(void)
|
||||
{
|
||||
/*Default style*/
|
||||
lv_pages_get(LV_PAGES_DEF, &lv_tas_def.pages);
|
||||
|
||||
lv_labels_get(LV_LABELS_TXT, &lv_tas_def.labels);
|
||||
lv_tas_def.labels.objs.color = COLOR_MAKE(0x20, 0x20, 0x20);
|
||||
|
||||
lv_tas_def.cursor_color = COLOR_MAKE(0x10, 0x10, 0x10);
|
||||
lv_tas_def.cursor_width = 2 * LV_STYLE_MULT; /*>1 px for visible cursor*/
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user