BigW Consortium Gitlab

Commit 63d54b02 by Gabor Kiss-Vamosi

some api updates and style border.part added

parent b973dd34
......@@ -257,8 +257,8 @@ static void style_mod_def(lv_style_t * style)
style->body.border.opa = OPA_COVER;
if(style->body.border.width == 0 && style->body.empty == 0) style->body.border.width = 2 << LV_ANTIALIAS; /*Add border to not transparent styles*/
else style->body.border.width = style->body.border.width * 2; /*Make the border thicker*/
style->body.color_main = color_mix(style->body.color_main, COLOR_ORANGE, OPA_80);
style->body.color_gradient = color_mix(style->body.color_gradient, COLOR_ORANGE, OPA_80);
style->body.main_color = color_mix(style->body.main_color, COLOR_ORANGE, OPA_80);
style->body.gradient_color = color_mix(style->body.gradient_color, COLOR_ORANGE, OPA_80);
}
#endif /*LV_OBJ_GROUP != 0*/
......@@ -70,17 +70,17 @@ void lv_style_init (void)
/*Screen style*/
lv_style_scr.glass = 0;
lv_style_scr.body.opa = OPA_COVER;
lv_style_scr.body.color_main = COLOR_WHITE;
lv_style_scr.body.color_gradient = COLOR_WHITE;
lv_style_scr.body.main_color = COLOR_WHITE;
lv_style_scr.body.gradient_color = COLOR_WHITE;
lv_style_scr.body.radius = 0;
lv_style_scr.body.padding.ver = LV_DPI / 12;
lv_style_scr.body.padding.hor = LV_DPI / 12;
lv_style_scr.body.padding.inner = LV_DPI / 12;
lv_style_scr.body.empty = 0;
lv_style_scr.body.border.color = COLOR_BLACK;
lv_style_scr.body.border.opa = OPA_COVER;
lv_style_scr.body.border.width = 0;
lv_style_scr.body.border.part = LV_BORDER_FULL;
lv_style_scr.body.shadow.color = COLOR_GRAY;
lv_style_scr.body.shadow.type = LV_SHADOW_FULL;
......@@ -108,16 +108,16 @@ void lv_style_init (void)
lv_style_plain_color.text.color = COLOR_MAKE(0xf0, 0xf0, 0xf0);
lv_style_plain_color.image.color = COLOR_MAKE(0xf0, 0xf0, 0xf0);
lv_style_plain_color.line.color = COLOR_MAKE(0xf0, 0xf0, 0xf0);
lv_style_plain_color.body.color_main = COLOR_MAKE(0x55, 0x96, 0xd8);
lv_style_plain_color.body.color_gradient = lv_style_plain_color.body.color_main;
lv_style_plain_color.body.main_color = COLOR_MAKE(0x55, 0x96, 0xd8);
lv_style_plain_color.body.gradient_color = lv_style_plain_color.body.main_color;
/*Pretty style */
memcpy(&lv_style_pretty, &lv_style_plain, sizeof(lv_style_t));
lv_style_pretty.text.color = COLOR_MAKE(0x20, 0x20, 0x20);
lv_style_pretty.image.color = COLOR_MAKE(0x20, 0x20, 0x20);
lv_style_pretty.line.color = COLOR_MAKE(0x20, 0x20, 0x20);
lv_style_pretty.body.color_main = COLOR_WHITE;
lv_style_pretty.body.color_gradient = COLOR_SILVER;
lv_style_pretty.body.main_color = COLOR_WHITE;
lv_style_pretty.body.gradient_color = COLOR_SILVER;
lv_style_pretty.body.radius = LV_DPI / 15;
lv_style_pretty.body.border.color = COLOR_MAKE(0x40, 0x40, 0x40);
lv_style_pretty.body.border.width = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1;
......@@ -128,8 +128,8 @@ void lv_style_init (void)
lv_style_pretty_color.text.color = COLOR_MAKE(0xe0, 0xe0, 0xe0);
lv_style_pretty_color.image.color = COLOR_MAKE(0xe0, 0xe0, 0xe0);
lv_style_pretty_color.line.color = COLOR_MAKE(0xe0, 0xe0, 0xe0);
lv_style_pretty_color.body.color_main = COLOR_MAKE(0x6b, 0x9a, 0xc7);
lv_style_pretty_color.body.color_gradient = COLOR_MAKE(0x2b, 0x59, 0x8b);
lv_style_pretty_color.body.main_color = COLOR_MAKE(0x6b, 0x9a, 0xc7);
lv_style_pretty_color.body.gradient_color = COLOR_MAKE(0x2b, 0x59, 0x8b);
lv_style_pretty_color.body.border.color = COLOR_MAKE(0x15, 0x2c, 0x42);
/*Transparent style*/
......@@ -149,8 +149,8 @@ void lv_style_init (void)
/*Button released style*/
memcpy(&lv_style_btn_released, &lv_style_plain, sizeof(lv_style_t));
lv_style_btn_released.body.color_main = COLOR_MAKE(0x76, 0xa2, 0xd0);
lv_style_btn_released.body.color_gradient = COLOR_MAKE(0x19, 0x3a, 0x5d);
lv_style_btn_released.body.main_color = COLOR_MAKE(0x76, 0xa2, 0xd0);
lv_style_btn_released.body.gradient_color = COLOR_MAKE(0x19, 0x3a, 0x5d);
lv_style_btn_released.body.radius = LV_DPI / 15;
lv_style_btn_released.body.padding.hor = LV_DPI / 4;
lv_style_btn_released.body.padding.ver = LV_DPI / 6;
......@@ -164,16 +164,16 @@ void lv_style_init (void)
/*Button pressed style*/
memcpy(&lv_style_btn_pressed, &lv_style_btn_released, sizeof(lv_style_t));
lv_style_btn_pressed.body.color_main = COLOR_MAKE(0x33, 0x62, 0x94);
lv_style_btn_pressed.body.color_gradient = COLOR_MAKE(0x10, 0x26, 0x3c);
lv_style_btn_pressed.body.main_color = COLOR_MAKE(0x33, 0x62, 0x94);
lv_style_btn_pressed.body.gradient_color = COLOR_MAKE(0x10, 0x26, 0x3c);
lv_style_btn_pressed.text.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_pressed.image.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_pressed.line.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
/*Button toggle released style*/
memcpy(&lv_style_btn_tgl_released, &lv_style_btn_released, sizeof(lv_style_t));
lv_style_btn_tgl_released.body.color_main = COLOR_MAKE(0x0a, 0x11, 0x22);
lv_style_btn_tgl_released.body.color_gradient = COLOR_MAKE(0x37, 0x62, 0x90);
lv_style_btn_tgl_released.body.main_color = COLOR_MAKE(0x0a, 0x11, 0x22);
lv_style_btn_tgl_released.body.gradient_color = COLOR_MAKE(0x37, 0x62, 0x90);
lv_style_btn_tgl_released.body.border.color = COLOR_MAKE(0x01, 0x07, 0x0d);
lv_style_btn_tgl_released.text.color = COLOR_MAKE(0xc8, 0xdd, 0xf4);
lv_style_btn_tgl_released.image.color = COLOR_MAKE(0xc8, 0xdd, 0xf4);
......@@ -181,16 +181,16 @@ void lv_style_init (void)
/*Button toggle pressed style*/
memcpy(&lv_style_btn_tgl_pressed, &lv_style_btn_tgl_released, sizeof(lv_style_t));
lv_style_btn_tgl_pressed.body.color_main = COLOR_MAKE(0x02, 0x14, 0x27);
lv_style_btn_tgl_pressed.body.color_gradient = COLOR_MAKE(0x2b, 0x4c, 0x70);
lv_style_btn_tgl_pressed.body.main_color = COLOR_MAKE(0x02, 0x14, 0x27);
lv_style_btn_tgl_pressed.body.gradient_color = COLOR_MAKE(0x2b, 0x4c, 0x70);
lv_style_btn_tgl_pressed.text.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_tgl_pressed.image.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
lv_style_btn_tgl_pressed.line.color = COLOR_MAKE(0xa4, 0xb5, 0xc6);
/*Button inactive style*/
memcpy(&lv_style_btn_inactive, &lv_style_btn_released, sizeof(lv_style_t));
lv_style_btn_inactive.body.color_main = COLOR_MAKE(0xd8, 0xd8, 0xd8);
lv_style_btn_inactive.body.color_gradient = COLOR_MAKE(0xd8, 0xd8, 0xd8);
lv_style_btn_inactive.body.main_color = COLOR_MAKE(0xd8, 0xd8, 0xd8);
lv_style_btn_inactive.body.gradient_color = COLOR_MAKE(0xd8, 0xd8, 0xd8);
lv_style_btn_inactive.body.border.color = COLOR_MAKE(0x90, 0x90, 0x90);
lv_style_btn_inactive.text.color = COLOR_MAKE(0x70, 0x70, 0x70);
lv_style_btn_inactive.image.color = COLOR_MAKE(0x70, 0x70, 0x70);
......@@ -264,8 +264,8 @@ static void lv_style_aimator(lv_style_anim_dsc_t * dsc, int32_t val)
STYLE_ATTR_ANIM(line.width, val);
STYLE_ATTR_ANIM(image.intense, val);
act->body.color_main = color_mix(end->body.color_main, start->body.color_main, val);
act->body.color_gradient = color_mix(end->body.color_gradient, start->body.color_gradient, val);
act->body.main_color = color_mix(end->body.main_color, start->body.main_color, val);
act->body.gradient_color = color_mix(end->body.gradient_color, start->body.gradient_color, val);
act->body.border.color = color_mix(end->body.border.color, start->body.border.color, val);
act->body.shadow.color = color_mix(end->body.shadow.color, start->body.shadow.color, val);
act->text.color = color_mix(end->text.color, start->text.color, val);
......
......@@ -28,6 +28,18 @@ extern "C" {
* TYPEDEFS
**********************/
/*Border types (Use 'OR'ed values)*/
typedef enum
{
LV_BORDER_NONE = 0x00,
LV_BORDER_BOTTOM = 0x01,
LV_BORDER_TOP = 0x02,
LV_BORDER_LEFT = 0x04,
LV_BORDER_RIGHT = 0x08,
LV_BORDER_FULL = 0x0F,
}lv_border_part_t;
/*Shadow types*/
typedef enum
{
......@@ -40,14 +52,15 @@ typedef struct
uint8_t glass :1; /*1: Do not inherit this style*/
struct {
color_t color_main;
color_t color_gradient;
color_t main_color;
color_t gradient_color;
cord_t radius;
opa_t opa;
struct {
color_t color;
cord_t width;
lv_border_part_t part;
opa_t opa;
}border;
......
......@@ -81,16 +81,16 @@ lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy)
/*If no copy do the basic initialization*/
if(copy == NULL) {
lv_btn_set_layout(new_btn, LV_CONT_LAYOUT_CENTER);
lv_btn_set_layout(new_btn, LV_LAYOUT_CENTER);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
if(th) {
lv_btn_set_style(new_btn, LV_BTN_STYLE_REL, th->btn.md.rel);
lv_btn_set_style(new_btn, LV_BTN_STYLE_PR, th->btn.md.pr);
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_REL, th->btn.md.tgl_rel);
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_PR, th->btn.md.tgl_pr);
lv_btn_set_style(new_btn, LV_BTN_STYLE_INA, th->btn.md.ina);
lv_btn_set_style(new_btn, LV_BTN_STYLE_REL, th->btn.rel);
lv_btn_set_style(new_btn, LV_BTN_STYLE_PR, th->btn.pr);
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_REL, th->btn.tgl_rel);
lv_btn_set_style(new_btn, LV_BTN_STYLE_TGL_PR, th->btn.tgl_pr);
lv_btn_set_style(new_btn, LV_BTN_STYLE_INA, th->btn.ina);
} else {
lv_obj_set_style(new_btn, ext->styles[LV_BTN_STATE_REL]);
}
......
......@@ -121,7 +121,7 @@ void lv_btn_set_action(lv_obj_t * btn, lv_btn_action_t type, lv_action_t action)
* @param btn pointer to a button object
* @param layout a layout from 'lv_cont_layout_t'
*/
static inline void lv_btn_set_layout(lv_obj_t * btn, lv_cont_layout_t layout)
static inline void lv_btn_set_layout(lv_obj_t * btn, lv_layout_t layout)
{
lv_cont_set_layout(btn, layout);
}
......@@ -177,7 +177,7 @@ lv_action_t lv_btn_get_action(lv_obj_t * btn, lv_btn_action_t type);
* @param btn pointer to button object
* @return the layout from 'lv_cont_layout_t'
*/
static inline lv_cont_layout_t lv_btn_get_layout(lv_obj_t * btn)
static inline lv_layout_t lv_btn_get_layout(lv_obj_t * btn)
{
return lv_cont_get_layout(btn);
}
......
......@@ -74,7 +74,7 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy)
ext->label = lv_label_create(new_cb, NULL);
lv_cb_set_text(new_cb, "Check box");
lv_btn_set_layout(new_cb, LV_CONT_LAYOUT_ROW_M);
lv_btn_set_layout(new_cb, LV_LAYOUT_ROW_M);
lv_btn_set_fit(new_cb, true, true);
lv_btn_set_toggle(new_cb, true);
......
......@@ -553,8 +553,8 @@ static void lv_chart_draw_points(lv_obj_t * chart, const area_t * mask)
/*Go through all data lines*/
LL_READ_BACK(ext->series_ll, ser) {
style_point.body.color_main = ser->color;
style_point.body.color_gradient = color_mix(COLOR_BLACK, ser->color, ext->series.dark);
style_point.body.main_color = ser->color;
style_point.body.gradient_color = color_mix(COLOR_BLACK, ser->color, ext->series.dark);
for(i = 0; i < ext->point_cnt; i ++) {
cir_a.x1 = ((w * i) / (ext->point_cnt - 1)) + x_ofs;
......@@ -611,8 +611,8 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const area_t * mask)
/*Draw the current point of all data line*/
LL_READ_BACK(ext->series_ll, ser) {
rects.body.color_main = ser->color;
rects.body.color_gradient = color_mix(COLOR_BLACK, ser->color, ext->series.dark);
rects.body.main_color = ser->color;
rects.body.gradient_color = color_mix(COLOR_BLACK, ser->color, ext->series.dark);
col_a.x1 = x_act;
col_a.x2 = col_a.x1 + col_w;
x_act += col_w;
......
......@@ -74,7 +74,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, lv_obj_t * copy)
dm_assert(ext);
ext->hor_fit = 0;
ext->ver_fit = 0;
ext->layout = LV_CONT_LAYOUT_OFF;
ext->layout = LV_LAYOUT_OFF;
lv_obj_set_signal_func(new_cont, lv_cont_signal);
......@@ -111,7 +111,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, lv_obj_t * copy)
* @param cont pointer to a container object
* @param layout a layout from 'lv_cont_layout_t'
*/
void lv_cont_set_layout(lv_obj_t * cont, lv_cont_layout_t layout)
void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout)
{
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
ext->layout = layout;
......@@ -148,7 +148,7 @@ void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en)
* @param cont pointer to container object
* @return the layout from 'lv_cont_layout_t'
*/
lv_cont_layout_t lv_cont_get_layout(lv_obj_t * cont)
lv_layout_t lv_cont_get_layout(lv_obj_t * cont)
{
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
return ext->layout;
......@@ -219,22 +219,22 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
*/
static void lv_cont_refr_layout(lv_obj_t * cont)
{
lv_cont_layout_t type = lv_cont_get_layout(cont);
lv_layout_t type = lv_cont_get_layout(cont);
/*'cont' has to be at least 1 child*/
if(lv_obj_get_child(cont, NULL) == NULL) return;
if(type == LV_CONT_LAYOUT_OFF) return;
if(type == LV_LAYOUT_OFF) return;
if(type == LV_CONT_LAYOUT_CENTER) {
if(type == LV_LAYOUT_CENTER) {
lv_cont_layout_center(cont);
} else if(type == LV_CONT_LAYOUT_COL_L || type == LV_CONT_LAYOUT_COL_M || type == LV_CONT_LAYOUT_COL_R) {
} else if(type == LV_LAYOUT_COL_L || type == LV_LAYOUT_COL_M || type == LV_LAYOUT_COL_R) {
lv_cont_layout_col(cont);
} else if(type == LV_CONT_LAYOUT_ROW_T || type == LV_CONT_LAYOUT_ROW_M || type == LV_CONT_LAYOUT_ROW_B) {
} else if(type == LV_LAYOUT_ROW_T || type == LV_LAYOUT_ROW_M || type == LV_LAYOUT_ROW_B) {
lv_cont_layout_row(cont);
} else if(type == LV_CONT_LAYOUT_PRETTY) {
} else if(type == LV_LAYOUT_PRETTY) {
lv_cont_layout_pretty(cont);
} else if(type == LV_CONT_LAYOUT_GRID) {
} else if(type == LV_LAYOUT_GRID) {
lv_cont_layout_grid(cont);
}
}
......@@ -245,7 +245,7 @@ static void lv_cont_refr_layout(lv_obj_t * cont)
*/
static void lv_cont_layout_col(lv_obj_t * cont)
{
lv_cont_layout_t type = lv_cont_get_layout(cont);
lv_layout_t type = lv_cont_get_layout(cont);
lv_obj_t * child;
/*Adjust margin and get the alignment type*/
......@@ -254,15 +254,15 @@ static void lv_cont_layout_col(lv_obj_t * cont)
cord_t hpad_corr;
switch(type) {
case LV_CONT_LAYOUT_COL_L:
case LV_LAYOUT_COL_L:
hpad_corr = style->body.padding.hor;
align = LV_ALIGN_IN_TOP_LEFT;
break;
case LV_CONT_LAYOUT_COL_M:
case LV_LAYOUT_COL_M:
hpad_corr = 0;
align = LV_ALIGN_IN_TOP_MID;
break;
case LV_CONT_LAYOUT_COL_R:
case LV_LAYOUT_COL_R:
hpad_corr = -style->body.padding.hor;
align = LV_ALIGN_IN_TOP_RIGHT;
break;
......@@ -294,7 +294,7 @@ static void lv_cont_layout_col(lv_obj_t * cont)
*/
static void lv_cont_layout_row(lv_obj_t * cont)
{
lv_cont_layout_t type = lv_cont_get_layout(cont);
lv_layout_t type = lv_cont_get_layout(cont);
lv_obj_t * child;
/*Adjust margin and get the alignment type*/
......@@ -303,15 +303,15 @@ static void lv_cont_layout_row(lv_obj_t * cont)
cord_t vpad_corr = style->body.padding.ver;
switch(type) {
case LV_CONT_LAYOUT_ROW_T:
case LV_LAYOUT_ROW_T:
vpad_corr = style->body.padding.ver;
align = LV_ALIGN_IN_TOP_LEFT;
break;
case LV_CONT_LAYOUT_ROW_M:
case LV_LAYOUT_ROW_M:
vpad_corr = 0;
align = LV_ALIGN_IN_LEFT_MID;
break;
case LV_CONT_LAYOUT_ROW_B:
case LV_LAYOUT_ROW_B:
vpad_corr = -style->body.padding.ver;
align = LV_ALIGN_IN_BOTTOM_LEFT;
break;
......
......@@ -29,17 +29,17 @@ extern "C" {
/*Layout options*/
typedef enum
{
LV_CONT_LAYOUT_OFF = 0,
LV_CONT_LAYOUT_CENTER,
LV_CONT_LAYOUT_COL_L, /*Column left align*/
LV_CONT_LAYOUT_COL_M, /*Column middle align*/
LV_CONT_LAYOUT_COL_R, /*Column right align*/
LV_CONT_LAYOUT_ROW_T, /*Row top align*/
LV_CONT_LAYOUT_ROW_M, /*Row middle align*/
LV_CONT_LAYOUT_ROW_B, /*Row bottom align*/
LV_CONT_LAYOUT_PRETTY, /*Put as many object as possible in row and begin a new row*/
LV_CONT_LAYOUT_GRID, /*Align same-sized object into a grid*/
}lv_cont_layout_t;
LV_LAYOUT_OFF = 0,
LV_LAYOUT_CENTER,
LV_LAYOUT_COL_L, /*Column left align*/
LV_LAYOUT_COL_M, /*Column middle align*/
LV_LAYOUT_COL_R, /*Column right align*/
LV_LAYOUT_ROW_T, /*Row top align*/
LV_LAYOUT_ROW_M, /*Row middle align*/
LV_LAYOUT_ROW_B, /*Row bottom align*/
LV_LAYOUT_PRETTY, /*Put as many object as possible in row and begin a new row*/
LV_LAYOUT_GRID, /*Align same-sized object into a grid*/
}lv_layout_t;
typedef struct
{
......@@ -71,7 +71,7 @@ lv_obj_t * lv_cont_create(lv_obj_t * par, lv_obj_t * copy);
* @param cont pointer to a container object
* @param layout a layout from 'lv_cont_layout_t'
*/
void lv_cont_set_layout(lv_obj_t * cont, lv_cont_layout_t layout);
void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout);
/**
......@@ -102,7 +102,7 @@ static inline void lv_cont_set_style(lv_obj_t *cont, lv_style_t * style)
* @param cont pointer to container object
* @return the layout from 'lv_cont_layout_t'
*/
lv_cont_layout_t lv_cont_get_layout(lv_obj_t * cont);
lv_layout_t lv_cont_get_layout(lv_obj_t * cont);
/**
* Get horizontal fit enable attribute of a container
......
......@@ -185,7 +185,7 @@ void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t action)
}
/**
* Set the fix height value.
* Set the fix height for the drop down list
* If 0 then the opened ddlist will be auto. sized else the set height will be applied.
* @param ddlist pointer to a drop down list
* @param h the height when the list is opened (0: auto size)
......@@ -194,10 +194,33 @@ void lv_ddlist_set_fix_height(lv_obj_t * ddlist, cord_t h)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
ext->fix_height = h;
lv_ddlist_refr_size(ddlist, 0);
}
/**
* Set the fix width for the drop down list
* If 0 then the ddlist will be auto. sized else the set width will be applied.
* @param ddlist pointer to a drop down list
* @param w the new width (0: auto size)
*/
void lv_ddlist_set_fix_width(lv_obj_t * ddlist, cord_t w)
{
if(w) {
lv_cont_set_fit(ddlist, false, lv_cont_get_ver_fit(ddlist));
lv_page_set_scrl_fit(ddlist, false, lv_page_get_scrl_fit_ver(ddlist));
lv_obj_set_width(ddlist, w);
} else {
lv_cont_set_fit(ddlist, true, lv_cont_get_ver_fit(ddlist));
lv_page_set_scrl_fit(ddlist, true, lv_page_get_scrl_fit_ver(ddlist));
}
lv_ddlist_refr_size(ddlist, 0);
}
/**
* Set the open/close animation time.
* @param ddlist pointer to a drop down list
* @param anim_time: open/close animation time [ms]
......
......@@ -94,7 +94,7 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt);
void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t action);
/**
* Set the fix height value.
* Set the fix height for the drop down list
* If 0 then the opened ddlist will be auto. sized else the set height will be applied.
* @param ddlist pointer to a drop down list
* @param h the height when the list is opened (0: auto size)
......@@ -102,6 +102,14 @@ void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t action);
void lv_ddlist_set_fix_height(lv_obj_t * ddlist, cord_t h);
/**
* Set the fix width for the drop down list
* If 0 then the ddlist will be auto. sized else the set width will be applied.
* @param ddlist pointer to a drop down list
* @param w the new width (0: auto size)
*/
void lv_ddlist_set_fix_width(lv_obj_t * ddlist, cord_t w);
/**
* Set the scroll bar mode of a drop down list
* @param ddlist pointer to a drop down list object
* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
......
......@@ -406,8 +406,8 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask)
/*Draw the needle middle area*/
lv_style_t style_neddle_mid;
lv_style_copy(&style_neddle_mid, &lv_style_plain);
style_neddle_mid.body.color_main = style->body.border.color;
style_neddle_mid.body.color_gradient = style->body.border.color;
style_neddle_mid.body.main_color = style->body.border.color;
style_neddle_mid.body.gradient_color = style->body.border.color;
style_neddle_mid.body.radius = LV_RADIUS_CIRCLE;
area_t nm_cord;
......
......@@ -453,7 +453,7 @@ void lv_label_get_letter_pos(lv_obj_t * label, uint16_t index, point_t * pos)
continue; /*Skip the letter is it is part of a command*/
}
}
x += (font_get_width(font, letter) >> FONT_ANTIALIAS) + style->text.letter_space;
x += font_get_width_scale(font, letter) + style->text.letter_space;
}
if(ext->align == LV_LABEL_ALIGN_CENTER) {
......@@ -528,7 +528,7 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos)
}
}
x += (font_get_width(font, letter) >> FONT_ANTIALIAS);
x += font_get_width_scale(font, letter);
if(pos->x < x) {
i = i_current;
break;
......@@ -739,17 +739,17 @@ static void lv_label_refr_text(lv_obj_t * label)
anim.var = label;
anim.repeat = 1;
anim.playback = 1;
anim.start = font_get_width(font, ' ') >> FONT_ANTIALIAS;
anim.start = font_get_width_scale(font, ' ');
anim.act_time = 0;
anim.end_cb = NULL;
anim.path = anim_get_path(ANIM_PATH_LIN);
anim.time = 3000;
anim.playback_pause = (((font_get_width(style->text.font, ' ') + style->text.letter_space) * 1000) / ext->anim_speed) * ANIM_WAIT_CHAR_COUNT;
anim.playback_pause = (((font_get_width_scale(style->text.font, ' ') + style->text.letter_space) * 1000) /ext->anim_speed)
* ANIM_WAIT_CHAR_COUNT;
anim.repeat_pause = anim.playback_pause;
if(lv_obj_get_width(label) > lv_obj_get_width(parent)) {
anim.end = lv_obj_get_width(parent) - lv_obj_get_width(label) -
(font_get_width(font, ' ') >> FONT_ANTIALIAS);
anim.end = lv_obj_get_width(parent) - lv_obj_get_width(label) - font_get_width_scale(font, ' ');
anim.fp = (anim_fp_t) lv_obj_set_x;
anim.time = anim_speed_to_time(ext->anim_speed, anim.start, anim.end);
anim_create(&anim);
......@@ -767,17 +767,16 @@ static void lv_label_refr_text(lv_obj_t * label)
anim.var = label;
anim.repeat = 1;
anim.playback = 1;
anim.start = font_get_width(font, ' ') >> FONT_ANTIALIAS;
anim.start = font_get_width_scale(font, ' ');
anim.act_time = 0;
anim.end_cb = NULL;
anim.path = anim_get_path(ANIM_PATH_LIN);
anim.playback_pause = (((font_get_width(style->text.font, ' ') + style->text.letter_space) * 1000) / ext->anim_speed) * ANIM_WAIT_CHAR_COUNT;;
anim.playback_pause = (((font_get_width_scale(style->text.font, ' ') + style->text.letter_space) * 1000) / ext->anim_speed) * ANIM_WAIT_CHAR_COUNT;;
anim.repeat_pause = anim.playback_pause;
bool hor_anim = false;
if(size.x > lv_obj_get_width(label)) {
anim.end = lv_obj_get_width(label) - size.x -
(font_get_width(font, ' ') >> FONT_ANTIALIAS);
anim.end = lv_obj_get_width(label) - size.x - font_get_width_scale(font, ' ');
anim.fp = (anim_fp_t) lv_label_set_offset_x;
anim.time = anim_speed_to_time(LV_LABEL_SCROLL_SPEED, anim.start, anim.end);
anim_create(&anim);
......
......@@ -184,8 +184,8 @@ static bool lv_led_design(lv_obj_t * led, const area_t * mask, lv_design_mode_t
memcpy(&leds_tmp, style, sizeof(leds_tmp));
/*Mix. the color with black proportionally with brightness*/
leds_tmp.body.color_main = color_mix(leds_tmp.body.color_main, COLOR_BLACK, ext->bright);
leds_tmp.body.color_gradient = color_mix(leds_tmp.body.color_gradient, COLOR_BLACK, ext->bright);
leds_tmp.body.main_color = color_mix(leds_tmp.body.main_color, COLOR_BLACK, ext->bright);
leds_tmp.body.gradient_color = color_mix(leds_tmp.body.gradient_color, COLOR_BLACK, ext->bright);
leds_tmp.body.border.color = color_mix(leds_tmp.body.border.color, COLOR_BLACK, ext->bright);
/*Set the current swidth according to brightness proportionally between LV_LED_BRIGHT_OFF and LV_LED_BRIGHT_ON*/
......
......@@ -18,7 +18,7 @@
/*********************
* DEFINES
*********************/
#define LV_LIST_LAYOUT_DEF LV_CONT_LAYOUT_COL_M
#define LV_LIST_LAYOUT_DEF LV_LAYOUT_COL_M
#ifndef LV_LIST_FOCUS_TIME
#define LV_LIST_FOCUS_TIME 100 /*Animation time of focusing to the a list element [ms] (0: no animation) */
#endif
......@@ -151,7 +151,7 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, l
lv_btn_set_action(liste, LV_BTN_ACTION_REL, rel_action);
lv_page_glue_obj(liste, true);
lv_btn_set_layout(liste, LV_CONT_LAYOUT_ROW_M);
lv_btn_set_layout(liste, LV_LAYOUT_ROW_M);
lv_btn_set_fit(liste, false, true);
if(btn_signal == NULL) btn_signal = lv_obj_get_signal_func(liste);
......
......@@ -248,7 +248,7 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const area_t * mask, lv_design_m
int16_t level = (int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value);
uint8_t i;
style_tmp.line.color = style->body.color_main;
style_tmp.line.color = style->body.main_color;
for(i = 0; i < ext->line_cnt; i++) {
/*Calculate the position a scale label*/
......@@ -270,7 +270,7 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const area_t * mask, lv_design_m
if(i > level) style_tmp.line.color = style->line.color;
else {
style_tmp.line.color = color_mix(style->body.color_gradient, style->body.color_main, (255 * i) / ext->line_cnt);
style_tmp.line.color = color_mix(style->body.gradient_color, style->body.main_color, (255 * i) / ext->line_cnt);
}
lv_draw_line(&p1, &p2, mask, &style_tmp);
......
......@@ -75,7 +75,7 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
lv_label_set_long_mode(ext->text, LV_LABEL_LONG_BREAK);
lv_label_set_text(ext->text, "Message");
lv_cont_set_layout(new_mbox, LV_CONT_LAYOUT_COL_M);
lv_cont_set_layout(new_mbox, LV_LAYOUT_COL_M);
lv_cont_set_fit(new_mbox, false, true);
lv_obj_set_width(new_mbox, LV_HOR_RES / 3);
lv_obj_align(new_mbox, NULL, LV_ALIGN_CENTER, 0, 0);
......@@ -105,21 +105,24 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy)
return new_mbox;
}
/*======================
* Add/remove functions
*=====================*/
/**
* Set button to the message box
* Add button to the message box
* @param mbox pointer to message box object
* @param btn_map button descriptor (button matrix map).
* E.g. a const char *txt[] = {"ok", "close", ""} (Can not be local variable)
* @param action a function which will be called when a button is released
*/
void lv_mbox_set_btns(lv_obj_t * mbox, const char **btn_map, lv_btnm_action_t action)
void lv_mbox_add_btns(lv_obj_t * mbox, const char **btn_map, lv_btnm_action_t action)
{
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
/*Create a button matrix if not exists yet*/
if(ext->btnm == NULL) {
ext->btnm = lv_btnm_create(mbox, NULL);
lv_obj_set_height(ext->btnm, LV_DPI / 2);
/*Set the default styles*/
lv_theme_t *th = lv_theme_get_current();
......@@ -362,8 +365,17 @@ static void mbox_realign(lv_obj_t *mbox)
lv_style_t *style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BG);
cord_t w = lv_obj_get_width(mbox) - 2 * style->body.padding.hor;
if(ext->btnm) lv_obj_set_width(ext->btnm, w);
if(ext->text) lv_obj_set_width(ext->text, w);
if(ext->text) {
lv_obj_set_width(ext->text, w);
}
if(ext->btnm) {
lv_style_t *btn_bg_style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BTN_BG);
lv_style_t *btn_rel_style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BTN_REL);
cord_t font_h = font_get_height_scale(btn_rel_style->text.font);
lv_obj_set_size(ext->btnm, w, font_h + 2 * btn_rel_style->body.padding.ver + 2 * btn_bg_style->body.padding.ver);
}
}
static lv_res_t lv_mbox_close_action(lv_obj_t *btn, const char *txt)
......
......@@ -75,14 +75,18 @@ typedef enum {
*/
lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy);
/*======================
* Add/remove functions
*=====================*/
/**
* Set button to the message box
* Add button to the message box
* @param mbox pointer to message box object
* @param btn_map button descriptor (button matrix map).
* E.g. a const char *txt[] = {"ok", "close", ""} (Can not be local variable)
* @param action a function which will be called when a button is released
*/
void lv_mbox_set_btns(lv_obj_t * mbox, const char **btn_map, lv_btnm_action_t action);
void lv_mbox_add_btns(lv_obj_t * mbox, const char **btn_map, lv_btnm_action_t action);
/*=====================
* Setter functions
......
......@@ -150,7 +150,7 @@ static inline void lv_page_set_scrl_height(lv_obj_t *page, cord_t h)
* @param page pointer to a page object
* @param layout a layout from 'lv_cont_layout_t'
*/
static inline void lv_page_set_scrl_layout(lv_obj_t * page, lv_cont_layout_t layout)
static inline void lv_page_set_scrl_layout(lv_obj_t * page, lv_layout_t layout)
{
lv_cont_set_layout(lv_page_get_scrl(page), layout);
}
......@@ -199,7 +199,7 @@ static inline cord_t lv_page_get_scrl_height(lv_obj_t *page)
* @param page pointer to page object
* @return the layout from 'lv_cont_layout_t'
*/
static inline lv_cont_layout_t lv_page_get_scrl_layout(lv_obj_t * page)
static inline lv_layout_t lv_page_get_scrl_layout(lv_obj_t * page)
{
return lv_cont_get_layout(lv_page_get_scrl(page));
}
......
......@@ -119,17 +119,6 @@ void lv_roller_set_selected(lv_obj_t *roller, uint16_t sel_opt, bool anim_en)
}
/**
* Enable/disable to set the width of the roller manually (by lv_obj_Set_width())
* @param roller pointer to a roller object
* @param fit_en: true: enable auto size; false: use manual width settings
*/
void lv_roller_set_hor_fit(lv_obj_t *roller, bool fit_en)
{
lv_page_set_scrl_fit(roller, fit_en ,false);
lv_cont_set_fit(roller, fit_en ,false);
}
/**
* Set a style of a roller
* @param roller pointer to a roller object
* @param type which style should be set
......@@ -382,14 +371,14 @@ static void draw_bg(lv_obj_t *roller, const area_t *mask)
half_roller.y1 -= style->body.radius;
if(union_ok){
color_t main_tmp = style->body.color_main;
color_t grad_tmp = style->body.color_gradient;
color_t main_tmp = style->body.main_color;
color_t grad_tmp = style->body.gradient_color;
style->body.color_main = grad_tmp;
style->body.color_gradient = main_tmp;
style->body.main_color = grad_tmp;
style->body.gradient_color = main_tmp;
lv_draw_rect(&half_roller, &half_mask, style);
style->body.color_main = main_tmp;
style->body.color_gradient = grad_tmp;
style->body.main_color = main_tmp;
style->body.gradient_color = grad_tmp;
}
}
......
......@@ -72,6 +72,17 @@ static inline void lv_roller_set_options(lv_obj_t * roller, const char * options
void lv_roller_set_selected(lv_obj_t *roller, uint16_t sel_opt, bool anim_en);
/**
* Set the fix width for the roller
* If 0 then the roller will be auto. sized else the set width will be applied.
* @param roller pointer to a drop down list
* @param w the new width (0: auto size)
*/
static inline void lv_roller_set_fix_width(lv_obj_t * roller, cord_t w)
{
lv_ddlist_set_fix_width(roller, w);
}
/**
* Set the open/close animation time.
* @param roller pointer to a roller object
* @param anim_time: open/close animation time [ms]
......@@ -81,12 +92,6 @@ static inline void lv_roller_set_anim_time(lv_obj_t *roller, uint16_t anim_time)
lv_ddlist_set_anim_time(roller, anim_time);
}
/**
* Enable/disable to set the width of the roller manually (by lv_obj_Set_width())
* @param roller pointer to a roller object
* @param fit_en: true: enable auto size; false: use manual width settings
*/
void lv_roller_set_hor_fit(lv_obj_t *roller, bool fit_en);
/**
* Set a style of a roller
......
......@@ -39,11 +39,12 @@ extern "C" {
**********************/
typedef enum {
LV_TA_CURSOR_LINE,
LV_TA_CURSOR_BLOCK,
LV_TA_CURSOR_OUTLINE,
LV_TA_CURSOR_UNDERLINE,
}lv_ta_cursor_type_t;
LV_CURSOR_NONE,
LV_CURSOR_LINE,
LV_CURSOR_BLOCK,
LV_CURSOR_OUTLINE,
LV_CURSOR_UNDERLINE,
}lv_cursor_type_t;
/*Data of text area*/
typedef struct
......@@ -51,15 +52,16 @@ typedef struct
lv_page_ext_t page; /*Ext. of ancestor*/
/*New data for this type */
lv_obj_t * label; /*Label of the text area*/
lv_style_t * cursor_style; /*Style of the cursor (NULL to use label's style)*/
char * pwd_tmp; /*Used to store the original text in password mode*/
cord_t cursor_valid_x; /*Used when stepping up/down in text area when stepping to a shorter line. (Handled by the library)*/
uint16_t cursor_pos; /*The current cursor position (0: before 1. letter; 1: before 2. letter etc.)*/
lv_ta_cursor_type_t cursor_type; /*Shape of the cursor*/
uint8_t cursor_show :1; /*Show or hide cursor */
uint8_t pwd_mode :1; /*Replace characters with '*' */
uint8_t one_line :1; /*One line mode (ignore line breaks)*/
uint8_t cursor_state :1; /*Indicates that the cursor is visible now or not (Handled by the library)*/
struct {
lv_style_t *style; /*Style of the cursor (NULL to use label's style)*/
cord_t valid_x; /*Used when stepping up/down in text area when stepping to a shorter line. (Handled by the library)*/
uint16_t pos; /*The current cursor position (0: before 1. letter; 1: before 2. letter etc.)*/
lv_cursor_type_t type; /*Shape of the cursor*/
uint8_t state :1; /*Indicates that the cursor is visible now or not (Handled by the library)*/
}cursor;
}lv_ta_ext_t;
typedef enum {
......@@ -127,18 +129,11 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt);
void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos);
/**
* Set the cursor visibility.
* @param ta pointer to a text area object
* @return show true: show the cursor and blink it, false: hide cursor
*/
void lv_ta_set_cursor_show(lv_obj_t * ta, bool show);
/**
* Set the cursor type.
* @param ta pointer to a text area object
* @param cur_type: element of 'lv_ta_cursor_type_t'
* @param cur_type: element of 'lv_cursor_type_t'
*/
void lv_ta_set_cursor_type(lv_obj_t * ta, lv_ta_cursor_type_t cur_type);
void lv_ta_set_cursor_type(lv_obj_t * ta, lv_cursor_type_t cur_type);
/**
* Enable/Disable password mode
* @param ta pointer to a text area object
......@@ -206,9 +201,9 @@ bool lv_ta_get_cursor_show(lv_obj_t * ta);
/**
* Get the current cursor type.
* @param ta pointer to a text area object
* @return element of 'lv_ta_cursor_type_t'
* @return element of 'lv_cursor_type_t'
*/
lv_ta_cursor_type_t lv_ta_get_cursor_type(lv_obj_t * ta);
lv_cursor_type_t lv_ta_get_cursor_type(lv_obj_t * ta);
/**
* Get the password mode attribute
......
......@@ -103,7 +103,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, lv_obj_t * copy)
ext->content = lv_cont_create(new_tabview, NULL);
lv_cont_set_fit(ext->content, true, false);
lv_cont_set_layout(ext->content, LV_CONT_LAYOUT_ROW_T);
lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T);
lv_cont_set_style(ext->content, &lv_style_transp_tight);
lv_obj_set_height(ext->content, LV_VER_RES - lv_obj_get_height(ext->btns));
lv_obj_align(ext->content, ext->btns, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
......
......@@ -20,9 +20,6 @@
/**********************
* STATIC PROTOTYPES
**********************/
static void create_tab1(lv_theme_t * th, lv_obj_t *parent);
static void create_tab2(lv_theme_t * th, lv_obj_t *parent);
static void create_tab3(lv_theme_t * th, lv_obj_t *parent);
/**********************
* STATIC VARIABLES
......@@ -56,249 +53,6 @@ lv_theme_t * lv_theme_get_current(void)
return current_theme;
}
/**
* Create a test screen with a lot objects and apply the given theme on them
* @param th pointer to a theme
*/
void lv_theme_create_test_screen(lv_theme_t *th)
{
lv_theme_set_current(th);
lv_obj_t *scr = lv_cont_create(NULL, NULL);
lv_scr_load(scr);
lv_cont_set_style(scr, th->bg);
lv_obj_t *tv = lv_tabview_create(scr, NULL);
lv_obj_set_size(tv, LV_HOR_RES, LV_VER_RES);
lv_obj_t *tab1 = lv_tabview_add_tab(tv, "Tab 1");
lv_obj_t *tab2 = lv_tabview_add_tab(tv, "Tab 2");
lv_obj_t *tab3 = lv_tabview_add_tab(tv, "Tab 3");
create_tab1(th, tab1);
create_tab2(th, tab2);
create_tab3(th, tab3);
lv_tabview_set_current_tab(tv, 2, false);
}
/**********************
* STATIC FUNCTIONS
**********************/
static void create_tab1(lv_theme_t * th, lv_obj_t *parent)
{
lv_page_set_scrl_layout(parent, LV_CONT_LAYOUT_PRETTY);
static lv_style_t h_style;
lv_style_copy(&h_style, &lv_style_transp);
h_style.body.padding.inner = LV_DPI / 4;
h_style.body.padding.hor = LV_DPI / 4;
h_style.body.padding.ver = LV_DPI / 6;
lv_obj_t *h = lv_cont_create(parent, NULL);
lv_obj_set_style(h, &h_style);
lv_cont_set_fit(h, true, true);
lv_cont_set_layout(h, LV_CONT_LAYOUT_COL_M);
lv_obj_t *btn = lv_btn_create(h, NULL);
lv_btn_set_style(btn, LV_BTN_STYLE_REL, th->btn.sm.rel);
lv_btn_set_style(btn, LV_BTN_STYLE_PR, th->btn.sm.pr);
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_REL, th->btn.sm.tgl_rel);
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_PR, th->btn.sm.tgl_pr);
lv_btn_set_style(btn, LV_BTN_STYLE_INA, th->btn.sm.ina);
lv_btn_set_fit(btn, true, true);
lv_btn_set_toggle(btn, true);
lv_obj_t *btn_label = lv_label_create(btn, NULL);
lv_label_set_text(btn_label, "Small");
btn = lv_btn_create(h, btn);
lv_btn_toggle(btn);
btn_label = lv_label_create(btn, NULL);
lv_label_set_text(btn_label, "Toggled");
btn = lv_btn_create(h, btn);
lv_btn_set_state(btn, LV_BTN_STATE_INA);
btn_label = lv_label_create(btn, NULL);
lv_label_set_text(btn_label, "Inactive");
btn = lv_btn_create(h, btn);
lv_btn_set_state(btn, LV_BTN_STATE_REL);
btn_label = lv_label_create(btn, NULL);
lv_label_set_text(btn_label, "Medium");
btn = lv_btn_create(h, btn);
lv_btn_set_style(btn, LV_BTN_STYLE_REL, th->btn.lg.rel);
lv_btn_set_style(btn, LV_BTN_STYLE_PR, th->btn.lg.pr);
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_REL, th->btn.lg.tgl_rel);
lv_btn_set_style(btn, LV_BTN_STYLE_TGL_PR, th->btn.lg.tgl_pr);
lv_btn_set_style(btn, LV_BTN_STYLE_INA, th->btn.lg.ina);
btn_label = lv_label_create(btn, NULL);
lv_label_set_text(btn_label, "Large");
lv_obj_t *label = lv_label_create(h, NULL);
lv_label_set_text(label, "Small");
lv_obj_set_style(label, th->label.sm);
label = lv_label_create(h, NULL);
lv_label_set_text(label, "Medium");
lv_obj_set_style(label, th->label.md);
label = lv_label_create(h, NULL);
lv_label_set_text(label, "Large");
lv_obj_set_style(label, th->label.lg);
lv_obj_set_protect(label, LV_PROTECT_FOLLOW);
h = lv_cont_create(parent, h);
lv_obj_t *sw_h = lv_cont_create(h, NULL);
lv_cont_set_style(sw_h, &lv_style_transp);
lv_cont_set_fit(sw_h, false, true);
lv_obj_set_width(sw_h, LV_HOR_RES / 4);
lv_cont_set_layout(sw_h, LV_CONT_LAYOUT_PRETTY);
lv_obj_t *sw = lv_sw_create(sw_h, NULL);
sw = lv_sw_create(sw_h, sw);
lv_sw_set_on(sw);
lv_obj_t *bar = lv_bar_create(h, NULL);
lv_bar_set_value(bar, 70);
lv_obj_t *slider = lv_slider_create(h, NULL);
lv_obj_set_height(slider, LV_DPI / 2);
lv_bar_set_value(slider, 70);
lv_obj_t *line = lv_line_create(h, NULL);
static const point_t line_p[] = {{0,0},{LV_HOR_RES / 5, 0}};
lv_line_set_points(line, line_p, 2);
lv_line_set_style(line, th->line.decor);
lv_obj_t *ta = lv_ta_create(h, NULL);
lv_obj_set_style(ta, th->ta.oneline);
lv_ta_set_text(ta, "Some text");
lv_ta_set_one_line(ta, true);
lv_obj_t *cb = lv_cb_create(h, NULL);
cb = lv_cb_create(h, cb);
lv_btn_set_state(cb, LV_BTN_STATE_TGL_REL);
lv_obj_t *ddlist = lv_ddlist_create(h, NULL);
lv_ddlist_open(ddlist, false);
lv_ddlist_set_selected(ddlist, 1);
static const char *btnm_str[] = {"1", "2", "3", SYMBOL_OK, SYMBOL_CLOSE, ""};
lv_obj_t *btnm = lv_btnm_create(h, NULL);
lv_obj_set_size(btnm,LV_HOR_RES / 4, 2 * LV_DPI / 3);
lv_btnm_set_map(btnm, btnm_str);
((lv_btnm_ext_t *) btnm->ext_attr)->btn_id_pr = 3; /*Hack to show a button pressed*/
h = lv_cont_create(parent, h);
lv_obj_t * list = lv_list_create(h, NULL);
lv_list_add(list, SYMBOL_GPS, "GPS", NULL);
lv_list_add(list, SYMBOL_WIFI, "WiFi", NULL);
lv_list_add(list, SYMBOL_CALL, "Call", NULL);
lv_list_add(list, SYMBOL_BELL, "Bell", NULL);
lv_list_add(list, SYMBOL_FILE, "File", NULL);
lv_list_add(list, SYMBOL_EDIT, "Edit", NULL);
lv_list_add(list, SYMBOL_CUT, "Cut", NULL);
lv_list_add(list, SYMBOL_COPY, "Copy", NULL);
lv_obj_t *roller = lv_roller_create(h, NULL);
lv_roller_set_options(roller, "Monday\nTuesday\nWednesday\nThursday\nFriday\nSaturday\nSunday");
lv_obj_set_height(roller, LV_DPI);
lv_obj_t *gauge = lv_gauge_create(h, NULL);
lv_gauge_set_value(gauge, 0, 40);
lv_obj_set_size(gauge, 3 * LV_DPI / 2, 3 * LV_DPI / 2);
}
static void create_tab2(lv_theme_t * th, lv_obj_t *parent)
{
cord_t w = lv_page_get_scrl_width(parent);
lv_obj_t *chart = lv_chart_create(parent, NULL);
lv_chart_series_t * s1 = lv_chart_add_series(chart, COLOR_RED);
lv_chart_set_next(chart, s1, 30);
lv_chart_set_next(chart, s1, 20);
lv_chart_set_next(chart, s1, 10);
lv_chart_set_next(chart, s1, 12);
lv_chart_set_next(chart, s1, 20);
lv_chart_set_next(chart, s1, 27);
lv_chart_set_next(chart, s1, 35);
lv_chart_set_next(chart, s1, 55);
lv_chart_set_next(chart, s1, 70);
lv_chart_set_next(chart, s1, 75);
lv_obj_t *ta = lv_ta_create(parent, NULL);
lv_obj_set_size(ta, w / 3, LV_VER_RES / 4);
lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
lv_ta_set_cursor_type(ta, LV_TA_CURSOR_BLOCK);
lv_obj_t *kb = lv_kb_create(parent, NULL);
lv_obj_set_size(kb, w / 2, LV_VER_RES / 3);
lv_obj_align(kb, ta, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, LV_DPI / 4);
lv_kb_set_ta(kb, ta);
}
static void create_tab3(lv_theme_t * th, lv_obj_t *parent)
{
lv_obj_t *win = lv_win_create(parent, NULL);
lv_win_add_btn(win, SYMBOL_CLOSE, lv_win_close_action);
lv_win_add_btn(win, SYMBOL_DOWN, NULL);
lv_obj_set_size(win, LV_HOR_RES / 2, LV_VER_RES / 2);
lv_obj_set_top(win, true);
lv_obj_t *label = lv_label_create(win, NULL);
lv_label_set_text(label, "Label in the window");
lv_obj_t *lmeter = lv_lmeter_create(win, NULL);
lv_obj_align(lmeter, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 2);
lv_lmeter_set_value(lmeter, 70);
lv_obj_t *led1 = lv_led_create(win, NULL);
lv_obj_align(led1, lmeter, LV_ALIGN_OUT_BOTTOM_MID, 0, LV_DPI / 2);
lv_led_on(led1);
lv_obj_t *led2 = lv_led_create(win, NULL);
lv_obj_align(led2, led1, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 2, 0);
lv_led_off(led2);
lv_obj_t *page = lv_page_create(parent, NULL);
lv_obj_set_size(page, LV_HOR_RES / 3, LV_VER_RES / 2);
lv_obj_set_top(page, true);
lv_obj_align(page, win, LV_ALIGN_IN_TOP_RIGHT, LV_DPI, LV_DPI);
label = lv_label_create(page, NULL);
lv_label_set_text(label, "Lorem ipsum dolor sit amet, repudiare voluptatibus pri cu. "
"Ei mundi pertinax posidonium eum, cum tempor maiorum at, "
"mea fuisset assentior ad. Usu cu suas civibus iudicabit. "
"Eum eu congue tempor facilisi. Tale hinc unum te vim. "
"Te cum populo animal eruditi, labitur inciderint at nec.\n\n"
"Eius corpora et quo. Everti voluptaria instructior est id, "
"vel in falli primis. Mea ei porro essent admodum, "
"his ei malis quodsi, te quis aeterno his. "
"Qui tritani recusabo reprehendunt ne, "
"per duis explicari at. Simul mediocritatem mei et.");
lv_label_set_long_mode(label, LV_LABEL_LONG_BREAK);
lv_obj_set_width(label, lv_page_get_scrl_width(page));
static const char * mbox_btn_map[] = {"\211", "\222Got it!", "\211", ""};
lv_obj_t *mbox = lv_mbox_create(parent, NULL);
lv_mbox_set_text(mbox, "Click on the window or the page to bring it to the foreground");
lv_mbox_set_btns(mbox, mbox_btn_map, NULL);
lv_obj_set_top(mbox, true);
}
......@@ -36,37 +36,19 @@ typedef struct {
#endif
#if USE_LV_BTN != 0
struct {
struct {
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
}sm;
struct {
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
}md;
struct {
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
}lg;
lv_style_t *rel;
lv_style_t *pr;
lv_style_t *tgl_rel;
lv_style_t *tgl_pr;
lv_style_t *ina;
}btn;
#endif
#if USE_LV_LABEL != 0
struct {
lv_style_t *sm;
lv_style_t *md;
lv_style_t *lg;
lv_style_t *prim;
lv_style_t *sec;
lv_style_t *hint;
}label;
#endif
......@@ -265,12 +247,6 @@ void lv_theme_set_current(lv_theme_t *th);
*/
lv_theme_t * lv_theme_get_current(void);
/**
* Create a test screen with a lot objects and apply the given theme on them
* @param th pointer to a theme
*/
void lv_theme_create_test_screen(lv_theme_t *th);
/**********************
* MACROS
**********************/
......@@ -278,6 +254,7 @@ void lv_theme_create_test_screen(lv_theme_t *th);
/**********************
* POST INCLUDE
*********************/
#include "lv_theme_templ.h"
#include "lv_theme_alien.h"
#ifdef __cplusplus
......
......@@ -28,15 +28,14 @@ extern "C" {
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initalize the alien theme
* Initialize the alien theme
* @param hue [0..360] hue value from HSV color space to define the theme's base color
* @param font_sm pointer to a small font (NULL to use the default)
* @param font_md pointer to a medium font (NULL to use the default)
* @param font_lg pointer to a large font (NULL to use the default)
* @param font pointer to a font (NULL to use the default)
* @return pointer to the initialized theme
*/
void lv_theme_alien_init(uint16_t hue, font_t *font_sm, font_t *font_md, font_t *font_lg);
lv_theme_t * lv_theme_alien_init(uint16_t hue, font_t *font);
/**
* Get a pointer to the theme
* @return pointer to the theme
......
/**
* @file lv_theme_alien.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lvgl/lvgl.h"
#include "lv_theme.h"
#include "lv_conf.h"
#if USE_LV_THEME_ALIEN
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
static lv_theme_t theme;
static lv_style_t def;
/*Static style definitions*/
/*Saved input parameters*/
static uint16_t _hue;
static font_t * _font;
/**********************
* MACROS
**********************/
/**********************
* STATIC FUNCTIONS
**********************/
static void basic_init(void)
{
lv_style_copy(&def, &lv_style_pretty); /*Initialize the default style*/
theme.bg = &def;
theme.panel = &def;
}
static void btn_init(void)
{
#if USE_LV_BTN != 0
theme.btn.rel = &def;
theme.btn.pr = &def;
theme.btn.tgl_rel = &def;
theme.btn.tgl_pr = &def;
theme.btn.ina = &def;
#endif
}
static void label_init(void)
{
#if USE_LV_LABEL != 0
theme.label.prim = &def;
theme.label.sec = &def;
theme.label.hint = &def;
#endif
}
static void bar_init(void)
{
#if USE_LV_BAR
theme.bar.bg = &def;
theme.bar.indic = &def;
#endif
}
static void img_init(void)
{
#if USE_LV_IMG != 0
theme.img.light = &def;
theme.img.dark = &def;
#endif
}
static void line_init(void)
{
#if USE_LV_LINE != 0
theme.line.decor = &def;
#endif
}
static void led_init(void)
{
#if USE_LV_LED != 0
theme.led = &def;
#endif
}
static void slider_init(void)
{
#if USE_LV_SLIDER != 0
theme.slider.bg = &def;
theme.slider.indic = &def;
theme.slider.knob = &def;
#endif
}
static void sw_init(void)
{
#if USE_LV_SW != 0
theme.sw.bg = &def;
theme.sw.indic = &def;
theme.sw.knob_off = &def;
theme.sw.knob_on = &def;
#endif
}
static void lmeter_init(void)
{
#if USE_LV_LMETER != 0
theme.lmeter = &def;
#endif
}
static void gauge_init(void)
{
#if USE_LV_GAUGE != 0
theme.gauge = &def;
#endif
}
static void chart_init(void)
{
#if USE_LV_CHART
theme.chart = &def;
#endif
}
static void cb_init(void)
{
#if USE_LV_CB != 0
theme.cb.bg = &def;
theme.cb.box.rel = &def;
theme.cb.box.pr = &def;
theme.cb.box.tgl_rel = &def;
theme.cb.box.tgl_pr = &def;
theme.cb.box.ina = &def;
#endif
}
static void btnm_init(void)
{
#if USE_LV_BTNM
theme.btnm.bg = &def;
theme.btnm.btn.rel = &def;
theme.btnm.btn.pr = &def;
theme.btnm.btn.tgl_rel = &def;
theme.btnm.btn.tgl_pr = &def;
theme.btnm.btn.ina = &def;
#endif
}
static void kb_init(void)
{
#if USE_LV_KB
theme.kb.bg = &def;
theme.kb.btn.rel = &def;
theme.kb.btn.pr = &def;
theme.kb.btn.tgl_rel = &def;
theme.kb.btn.tgl_pr = &def;
theme.kb.btn.ina = &def;
#endif
}
static void mbox_init(void)
{
#if USE_LV_MBOX
theme.mbox.bg = &def;
theme.mbox.btn.bg = &def;
theme.mbox.btn.rel = &def;
theme.mbox.btn.pr = &def;
#endif
}
static void page_init(void)
{
#if USE_LV_PAGE
theme.page.bg = &def;
theme.page.scrl = &def;
theme.page.sb = &def;
#endif
}
static void ta_init(void)
{
#if USE_LV_TA
theme.ta.area = &def;
theme.ta.oneline = &def;
theme.ta.sb = &def;
#endif
}
static void list_init(void)
{
#if USE_LV_LIST != 0
theme.list.sb = &def;
theme.list.bg = &def;
theme.list.scrl = &def;
theme.list.btn.rel = &def;
theme.list.btn.pr = &def;
theme.list.btn.tgl_rel = &def;
theme.list.btn.tgl_pr = &def;
theme.list.btn.ina = &def;
#endif
}
static void ddlist_init(void)
{
#if USE_LV_DDLIST != 0
theme.ddlist.bg = &def;
theme.ddlist.sel = &def;
theme.ddlist.sb = &def;
#endif
}
static void roller_init(void)
{
#if USE_LV_ROLLER != 0
theme.roller.bg = &def;
theme.roller.sel = &def;
#endif
}
static void tabview_init(void)
{
#if USE_LV_TABVIEW != 0
theme.tabview.bg = &def;
theme.tabview.indic = &def;
theme.tabview.btn.bg = &def;
theme.tabview.btn.rel = &def;
theme.tabview.btn.pr = &def;
theme.tabview.btn.tgl_rel = &def;
theme.tabview.btn.tgl_pr = &def;
#endif
}
static void win_init(void)
{
#if USE_LV_WIN != 0
theme.win.bg = &def;
theme.win.sb = &def;
theme.win.header = &def;
theme.win.content = &def;
theme.win.btn.rel = &def;
theme.win.btn.pr = &def;
#endif
}
/**********************
* GLOBAL FUNCTIONS
**********************/
/**
* Initialize the alien theme
* @param hue [0..360] hue value from HSV color space to define the theme's base color
* @param font pointer to a font (NULL to use the default)
* @return pointer to the initialized theme
*/
lv_theme_t * lv_theme_templ_init(uint16_t hue, font_t *font)
{
if(font == NULL) font = FONT_DEFAULT;
_hue = hue;
_font = font;
/*For backward compatibility initialize all theme elements with a default style */
uint16_t i;
lv_style_t **style_p = (lv_style_t**) &theme;
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t*); i++) {
*style_p = &def;
style_p++;
}
basic_init();
btn_init();
label_init();
bar_init();
img_init();
line_init();
led_init();
slider_init();
sw_init();
lmeter_init();
gauge_init();
chart_init();
cb_init();
btnm_init();
kb_init();
mbox_init();
page_init();
ta_init();
list_init();
ddlist_init();
roller_init();
tabview_init();
win_init();
return &theme;
}
/**
* Get a pointer to the theme
* @return pointer to the theme
*/
lv_theme_t * lv_theme_get_templ(void)
{
return &theme;
}
/**********************
* STATIC FUNCTIONS
**********************/
#endif
/**
* @file lv_theme_alien.h
*
*/
#ifndef LV_THEME_TEMPL_H
#define LV_THEME_TEMPL_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "lv_conf.h"
#if USE_LV_THEME_TEMPL
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initialize the alien theme
* @param hue [0..360] hue value from HSV color space to define the theme's base color
* @param font pointer to a font (NULL to use the default)
* @return pointer to the initialized theme
*/
lv_theme_t * lv_theme_templ_init(uint16_t hue, font_t *font);
/**
* Get a pointer to the theme
* @return pointer to the theme
*/
lv_theme_t * lv_theme_get_templ(void);
/**********************
* MACROS
**********************/
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /*LV_THEME_TEMPL_H*/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment