assign theme to the display + minor fixes

This commit is contained in:
Gabor Kiss-Vamosi
2021-02-26 09:51:27 +01:00
parent 8a7f9cb131
commit 0ab6433c66
35 changed files with 301 additions and 293 deletions

View File

@@ -13,7 +13,7 @@ static void event_cb(lv_obj_t * obj, lv_event_t e)
lv_draw_label_dsc_t dsc; lv_draw_label_dsc_t dsc;
lv_draw_label_dsc_init(&dsc); lv_draw_label_dsc_init(&dsc);
dsc.font = LV_THEME_FONT_NORMAL; dsc.font = LV_FONT_DEFAULT;
char buf[8]; char buf[8];
lv_snprintf(buf, sizeof(buf), "%d", lv_bar_get_value(obj)); lv_snprintf(buf, sizeof(buf), "%d", lv_bar_get_value(obj));

View File

@@ -17,7 +17,7 @@ void lv_example_label_1(void)
lv_obj_t * label2 = lv_label_create(lv_scr_act(), NULL); lv_obj_t * label2 = lv_label_create(lv_scr_act(), NULL);
lv_label_set_long_mode(label2, LV_LABEL_LONG_SROLL_CIRC); /*Circular scroll*/ lv_label_set_long_mode(label2, LV_LABEL_LONG_SCROLL_CIRCULAR); /*Circular scroll*/
lv_obj_set_width(label2, 150); lv_obj_set_width(label2, 150);
lv_label_set_text(label2, "It is a circularly scrolling text. "); lv_label_set_text(label2, "It is a circularly scrolling text. ");
lv_obj_align(label2, NULL, LV_ALIGN_CENTER, 0, 40); lv_obj_align(label2, NULL, LV_ALIGN_CENTER, 0, 40);

View File

@@ -345,25 +345,6 @@ typedef void * lv_user_data_t;
* In these languages characters should be replaced with an other form based on their position in the text */ * In these languages characters should be replaced with an other form based on their position in the text */
#define LV_USE_ARABIC_PERSIAN_CHARS 0 #define LV_USE_ARABIC_PERSIAN_CHARS 0
/*==================
* THEME USAGE
*================*/
/*Set the very basic the attributes*/
#define LV_THEME_COLOR_PRIMARY lv_color_hex(0x01a2b1)
#define LV_THEME_COLOR_SECONDARY lv_color_hex(0x44d1b6)
#define LV_THEME_FONT_SMALL &lv_font_montserrat_14
#define LV_THEME_FONT_NORMAL &lv_font_montserrat_14
#define LV_THEME_FONT_LARGE &lv_font_montserrat_14
#define LV_THEME_FONT_EXTRA_LARGE &lv_font_montserrat_14
/* An external include file required to see the theme init function.
* Relative to "lv_core/lv_obj" */
#define LV_THEME_INIT_INCLUDE "../extra/themes/lv_themes.h"
/* Set a theme initialization function */
#define LV_THEME_INIT lv_theme_default_init
/*================== /*==================
* WIDGET USAGE * WIDGET USAGE
*================*/ *================*/

View File

@@ -239,6 +239,10 @@ static void flex_update(lv_obj_t * cont, lv_obj_t * item)
} }
} }
LV_ASSERT_MEM_INTEGRITY(); LV_ASSERT_MEM_INTEGRITY();
if(cont->w_set == LV_SIZE_CONTENT || cont->h_set == LV_SIZE_CONTENT) {
lv_obj_set_size(cont, cont->w_set, cont->h_set);
}
} }
/** /**
@@ -268,7 +272,9 @@ static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t
lv_obj_t * item = lv_obj_get_child(cont, item_id); lv_obj_t * item = lv_obj_get_child(cont, item_id);
while(item) { while(item) {
if(lv_obj_has_flag(item, LV_OBJ_FLAG_LAYOUTABLE) && !lv_obj_has_flag(item, LV_OBJ_FLAG_HIDDEN)) { if(!lv_obj_has_flag(item, LV_OBJ_FLAG_IGNORE_LAYOUT) && !lv_obj_has_flag(item, LV_OBJ_FLAG_HIDDEN)) {
if(item_id != item_start_id && lv_obj_has_flag(item, LV_OBJ_FLAG_LAYOUT_1)) break;
lv_coord_t main_size = (row ? item->w_set : item->h_set); lv_coord_t main_size = (row ? item->w_set : item->h_set);
if(_LV_FLEX_GET_GROW(main_size)) { if(_LV_FLEX_GET_GROW(main_size)) {
grow_sum += _LV_FLEX_GET_GROW(main_size); grow_sum += _LV_FLEX_GET_GROW(main_size);
@@ -279,8 +285,11 @@ static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t
if(wrap && t->track_main_size + item_size > max_main_size) break; if(wrap && t->track_main_size + item_size > max_main_size) break;
t->track_main_size += item_size + item_gap; t->track_main_size += item_size + item_gap;
} }
t->track_cross_size = LV_MAX(get_cross_size(item), t->track_cross_size); t->track_cross_size = LV_MAX(get_cross_size(item), t->track_cross_size);
t->item_cnt++; t->item_cnt++;
} }
item_id += f->rev ? -1 : +1; item_id += f->rev ? -1 : +1;
if(item_id < 0) break; if(item_id < 0) break;
@@ -336,7 +345,7 @@ static void children_repos(lv_obj_t * cont, int32_t item_first_id, int32_t item_
lv_obj_t * item = lv_obj_get_child(cont, item_first_id); lv_obj_t * item = lv_obj_get_child(cont, item_first_id);
/*Reposition the children*/ /*Reposition the children*/
while(item && item_first_id != item_last_id) { while(item && item_first_id != item_last_id) {
if(!lv_obj_has_flag(item, LV_OBJ_FLAG_LAYOUTABLE) || lv_obj_has_flag(item, LV_OBJ_FLAG_HIDDEN)) { if(lv_obj_has_flag(item, LV_OBJ_FLAG_IGNORE_LAYOUT) || lv_obj_has_flag(item, LV_OBJ_FLAG_HIDDEN)) {
item = get_next_item(cont, f->rev, &item_first_id); item = get_next_item(cont, f->rev, &item_first_id);
continue; continue;
} }

View File

@@ -20,7 +20,8 @@
#define CELL_SPAN_MASK (CELL_POS_MASK << CELL_SHIFT) #define CELL_SPAN_MASK (CELL_POS_MASK << CELL_SHIFT)
#define CELL_FLAG_MASK (CELL_POS_MASK << (2 * CELL_SHIFT)) #define CELL_FLAG_MASK (CELL_POS_MASK << (2 * CELL_SHIFT))
#define IS_FR(x) (LV_COORD_IS_LAYOUT(x)) #define IS_FR(x) (LV_COORD_IS_LAYOUT(x) && _LV_COORD_PLAIN(x) < 100)
#define IS_CONTENT(x) (LV_COORD_IS_LAYOUT(x) && _LV_COORD_PLAIN(x) == 100)
#define GET_FR(x) (_LV_COORD_PLAIN(x)) #define GET_FR(x) (_LV_COORD_PLAIN(x))
@@ -96,8 +97,8 @@ void lv_grid_set_place(lv_grid_t * grid, uint8_t col_place, uint8_t row_place)
grid->row_place = row_place; grid->row_place = row_place;
} }
void lv_obj_set_grid_cell(lv_obj_t * obj, lv_grid_place_t ver_place, uint8_t col_pos, uint8_t col_span, void lv_obj_set_grid_cell(lv_obj_t * obj, lv_grid_place_t hor_place, uint8_t col_pos, uint8_t col_span,
lv_grid_place_t hor_place, uint8_t row_pos, uint8_t row_span) lv_grid_place_t ver_place, uint8_t row_pos, uint8_t row_span)
{ {
if(!lv_obj_is_layout_positioned(obj)) return; if(!lv_obj_is_layout_positioned(obj)) return;
@@ -177,6 +178,10 @@ static void item_refr(lv_obj_t * item)
item_repos(item, &c, NULL); item_repos(item, &c, NULL);
calc_free(&c); calc_free(&c);
if(cont->w_set == LV_SIZE_CONTENT || cont->h_set == LV_SIZE_CONTENT) {
lv_obj_set_size(cont, cont->w_set, cont->h_set);
}
} }
/** /**
@@ -237,6 +242,28 @@ static void calc_cols(lv_obj_t * cont, _lv_grid_calc_t * c)
c->x = lv_mem_buf_get(sizeof(lv_coord_t) * c->col_num); c->x = lv_mem_buf_get(sizeof(lv_coord_t) * c->col_num);
c->w = lv_mem_buf_get(sizeof(lv_coord_t) * c->col_num); c->w = lv_mem_buf_get(sizeof(lv_coord_t) * c->col_num);
/*Set sizes for CONTENT cells*/
for(i = 0; i < c->col_num; i++) {
lv_coord_t size = LV_COORD_MIN;
if(IS_CONTENT(grid->col_dsc[i])) {
/*Check the size of children of this cell*/
uint32_t ci;
for(ci = 0; ci < lv_obj_get_child_cnt(cont); ci++) {
lv_obj_t * item = lv_obj_get_child(cont, ci);
if(LV_COORD_IS_LAYOUT(item->x_set) == false || LV_COORD_IS_LAYOUT(item->y_set) == false) continue;
if(lv_obj_has_flag(item, LV_OBJ_FLAG_IGNORE_LAYOUT)) continue;
uint32_t col_pos = GET_CELL_POS(item->x_set);
if(col_pos != i) continue;
uint32_t col_span = GET_CELL_SPAN(item->x_set);
if(col_span != 1) continue;
size = LV_MAX(size, lv_obj_get_width(item));
}
if(size >= 0) c->w[i] = size;
else c->w[i] = 0;
}
}
uint32_t col_fr_cnt = 0; uint32_t col_fr_cnt = 0;
lv_coord_t grid_w = 0; lv_coord_t grid_w = 0;
bool auto_w = cont->w_set == LV_SIZE_CONTENT ? true : false; bool auto_w = cont->w_set == LV_SIZE_CONTENT ? true : false;
@@ -244,7 +271,9 @@ static void calc_cols(lv_obj_t * cont, _lv_grid_calc_t * c)
for(i = 0; i < c->col_num; i++) { for(i = 0; i < c->col_num; i++) {
lv_coord_t x = grid->col_dsc[i]; lv_coord_t x = grid->col_dsc[i];
if(IS_FR(x)) col_fr_cnt += GET_FR(x); if(IS_FR(x)) col_fr_cnt += GET_FR(x);
else { else if (IS_CONTENT(x)) {
grid_w += c->w[i];
} else {
c->w[i] = x; c->w[i] = x;
grid_w += x; grid_w += x;
} }
@@ -274,17 +303,39 @@ static void calc_rows(lv_obj_t * cont, _lv_grid_calc_t * c)
c->row_num = grid->row_dsc_len; c->row_num = grid->row_dsc_len;
c->y = lv_mem_buf_get(sizeof(lv_coord_t) * c->row_num); c->y = lv_mem_buf_get(sizeof(lv_coord_t) * c->row_num);
c->h = lv_mem_buf_get(sizeof(lv_coord_t) * c->row_num); c->h = lv_mem_buf_get(sizeof(lv_coord_t) * c->row_num);
/*Set sizes for CONTENT cells*/
for(i = 0; i < c->row_num; i++) {
lv_coord_t size = LV_COORD_MIN;
if(IS_CONTENT(grid->row_dsc[i])) {
/*Check the size of children of this cell*/
uint32_t ci;
for(ci = 0; ci < lv_obj_get_child_cnt(cont); ci++) {
lv_obj_t * item = lv_obj_get_child(cont, ci);
if(LV_COORD_IS_LAYOUT(item->x_set) == false || LV_COORD_IS_LAYOUT(item->y_set) == false) continue;
if(lv_obj_has_flag(item, LV_OBJ_FLAG_IGNORE_LAYOUT)) continue;
uint32_t row_pos = GET_CELL_POS(item->y_set);
if(row_pos != i) continue;
uint32_t row_span = GET_CELL_SPAN(item->y_set);
if(row_span != 1) continue;
size = LV_MAX(size, lv_obj_get_height(item));
}
if(size >= 0) c->h[i] = size;
else c->h[i] = 0;
}
}
uint32_t row_fr_cnt = 0; uint32_t row_fr_cnt = 0;
lv_coord_t grid_h = 0; lv_coord_t grid_h = 0;
bool auto_h = cont->h_set == LV_SIZE_CONTENT ? true : false; bool auto_h = cont->h_set == LV_SIZE_CONTENT ? true : false;
for(i = 0; i < c->row_num; i++) {
for(i = 0; i < grid->row_dsc_len; i++) {
lv_coord_t x = grid->row_dsc[i]; lv_coord_t x = grid->row_dsc[i];
if(IS_FR(x)) row_fr_cnt += GET_FR(x); if(IS_FR(x)) row_fr_cnt += GET_FR(x);
else { else if (IS_CONTENT(x)) {
grid_h += c->h[i];
} else {
c->h[i] = x; c->h[i] = x;
grid_h += x; grid_h += x;
} }
@@ -316,7 +367,7 @@ static void calc_rows(lv_obj_t * cont, _lv_grid_calc_t * c)
static void item_repos(lv_obj_t * item, _lv_grid_calc_t * c, item_repos_hint_t * hint) static void item_repos(lv_obj_t * item, _lv_grid_calc_t * c, item_repos_hint_t * hint)
{ {
if(LV_COORD_IS_LAYOUT(item->x_set) == 0 || LV_COORD_IS_LAYOUT(item->y_set) == 0) return; if(LV_COORD_IS_LAYOUT(item->x_set) == 0 || LV_COORD_IS_LAYOUT(item->y_set) == 0) return;
if(lv_obj_has_flag(item, LV_OBJ_FLAG_LAYOUTABLE) == false) return; if(lv_obj_has_flag(item, LV_OBJ_FLAG_IGNORE_LAYOUT)) return;
uint32_t col_span = GET_CELL_SPAN(item->x_set); uint32_t col_span = GET_CELL_SPAN(item->x_set);
uint32_t row_span = GET_CELL_SPAN(item->y_set); uint32_t row_span = GET_CELL_SPAN(item->y_set);
if(row_span == 0 || col_span == 0) return; if(row_span == 0 || col_span == 0) return;

View File

@@ -91,15 +91,15 @@ void lv_grid_set_place(lv_grid_t * grid, uint8_t col_place, uint8_t row_place);
/** /**
* Set the cell of an object. The object's parent needs to have grid layout, else nothing will happen * Set the cell of an object. The object's parent needs to have grid layout, else nothing will happen
* @param obj: pointer to an object * @param obj: pointer to an object
* @param ver_place: the vertical alignment in the cell. `LV_GRID_START/END/CENTER/STRETCH` * @param hor_place: the vertical alignment in the cell. `LV_GRID_START/END/CENTER/STRETCH`
* @param col_pos: column ID * @param col_pos: column ID
* @param col_span: number of columns to take (>= 1) * @param col_span: number of columns to take (>= 1)
* @param hor_place the horizontal alignment in the cell. `LV_GRID_START/END/CENTER/STRETCH` * @param ver_place the horizontal alignment in the cell. `LV_GRID_START/END/CENTER/STRETCH`
* @param row_pos: row ID * @param row_pos: row ID
* @param row_span: number of rows to take (>= 1) * @param row_span: number of rows to take (>= 1)
*/ */
void lv_obj_set_grid_cell(struct _lv_obj_t * obj, lv_grid_place_t ver_place, uint8_t col_pos, uint8_t col_span, void lv_obj_set_grid_cell(struct _lv_obj_t * obj, lv_grid_place_t hor_place, uint8_t col_pos, uint8_t col_span,
lv_grid_place_t hor_place, uint8_t row_pos, uint8_t row_span); lv_grid_place_t ver_place, uint8_t row_pos, uint8_t row_span);
/** /**
* Can be used track size to make the track fill the free space. * Can be used track size to make the track fill the free space.
@@ -108,6 +108,8 @@ void lv_obj_set_grid_cell(struct _lv_obj_t * obj, lv_grid_place_t ver_place, uin
*/ */
#define LV_GRID_FR(x) (LV_COORD_SET_LAYOUT(x)) #define LV_GRID_FR(x) (LV_COORD_SET_LAYOUT(x))
#define LV_GRID_CONTENT (LV_COORD_SET_LAYOUT(100))
/** /**
* Just a wrapper to `LV_GRID_FR` for bindings. * Just a wrapper to `LV_GRID_FR` for bindings.
*/ */

View File

@@ -21,11 +21,10 @@
* DEFINES * DEFINES
*********************/ *********************/
#define RADIUS_DEFAULT LV_DPX(8) #define RADIUS_DEFAULT LV_DPX(10)
/*SCREEN*/ /*SCREEN*/
//#define COLOR_SCR (IS_LIGHT ? lv_color_hex(0xf5f8fa) : lv_color_hex(0x444b5a)) #define COLOR_SCR (IS_LIGHT ? lv_color_grey_lighten_5() : lv_color_hex(0x444b5a))
#define COLOR_SCR (IS_LIGHT ? lv_color_blue_grey_lighten_5() : lv_color_hex(0x444b5a))
#define COLOR_SCR_TEXT (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xe7e9ec)) #define COLOR_SCR_TEXT (IS_LIGHT ? lv_color_hex(0x3b3e42) : lv_color_hex(0xe7e9ec))
/*BUTTON*/ /*BUTTON*/
@@ -38,9 +37,6 @@
#define BTN_DIS_COLOR (lv_color_lighten(theme.color_secondary, LV_OPA_40)) #define BTN_DIS_COLOR (lv_color_lighten(theme.color_secondary, LV_OPA_40))
#define BTN_BORDER_COLOR theme.color_primary #define BTN_BORDER_COLOR theme.color_primary
#define COLOR_BTN_BORDER_PR theme.color_primary
#define COLOR_BTN_BORDER_CHK theme.color_primary
#define COLOR_BTN_BORDER_CHK_PR theme.color_primary
#define COLOR_BTN_BORDER_INA (IS_LIGHT ? lv_color_hex3(0x888) : lv_color_hex(0x404040)) #define COLOR_BTN_BORDER_INA (IS_LIGHT ? lv_color_hex3(0x888) : lv_color_hex(0x404040))
/*BACKGROUND*/ /*BACKGROUND*/
@@ -88,9 +84,10 @@ typedef struct {
/*Utility*/ /*Utility*/
lv_style_t bg_color_primary; lv_style_t bg_color_primary;
lv_style_t bg_color_primary_light;
lv_style_t bg_color_secondary; lv_style_t bg_color_secondary;
lv_style_t bg_color_gray; lv_style_t bg_color_gray;
lv_style_t bg_color_panel; lv_style_t bg_color_white;
lv_style_t pressed; lv_style_t pressed;
lv_style_t disabled; lv_style_t disabled;
lv_style_t pad_zero; lv_style_t pad_zero;
@@ -129,10 +126,6 @@ typedef struct {
lv_style_t cb_marker, cb_marker_checked, cb_bg_outline_pad; lv_style_t cb_marker, cb_marker_checked, cb_bg_outline_pad;
#endif #endif
#if LV_USE_DROPDOWN
lv_style_t ddlist_flip;
#endif
#if LV_USE_TABLE #if LV_USE_TABLE
lv_style_t table_cell; lv_style_t table_cell;
#endif #endif
@@ -161,6 +154,9 @@ typedef struct {
lv_style_t list_bg, list_btn, list_item_grow, list_label; lv_style_t list_bg, list_btn, list_item_grow, list_label;
#endif #endif
#if LV_USE_TABVIEW
lv_style_t tab_btn;
#endif
#if LV_USE_LED #if LV_USE_LED
lv_style_t led; lv_style_t led;
#endif #endif
@@ -268,9 +264,15 @@ static void style_init(void)
lv_style_set_outline_opa(&styles->edit_outline, LV_OPA_50); lv_style_set_outline_opa(&styles->edit_outline, LV_OPA_50);
style_init_reset(&styles->btn); style_init_reset(&styles->btn);
lv_style_set_radius(&styles->btn, RADIUS_DEFAULT); lv_style_set_radius(&styles->btn, LV_DPX(14));
lv_style_set_bg_opa(&styles->btn, LV_OPA_COVER); lv_style_set_bg_opa(&styles->btn, LV_OPA_COVER);
lv_style_set_bg_color(&styles->btn, COLOR_GRAY); lv_style_set_bg_color(&styles->btn, COLOR_GRAY);
lv_style_set_shadow_color(&styles->btn, COLOR_GRAY);
lv_style_set_shadow_width(&styles->btn, 1);
lv_style_set_shadow_ofs_y(&styles->btn, LV_DPX(4));
// lv_style_set_border_color(&styles->btn, COLOR_GRAY);
// lv_style_set_border_width(&styles->btn, 4);
// lv_style_set_border_side(&styles->btn, LV_BORDER_SIDE_BOTTOM);
lv_style_set_text_color(&styles->btn, CARD_TEXT_COLOR); lv_style_set_text_color(&styles->btn, CARD_TEXT_COLOR);
lv_style_set_pad_hor(&styles->btn, LV_DPX(40)); lv_style_set_pad_hor(&styles->btn, LV_DPX(40));
lv_style_set_pad_ver(&styles->btn, LV_DPX(15)); lv_style_set_pad_ver(&styles->btn, LV_DPX(15));
@@ -326,6 +328,12 @@ static void style_init(void)
lv_style_set_content_color(&styles->bg_color_primary, lv_color_white()); lv_style_set_content_color(&styles->bg_color_primary, lv_color_white());
lv_style_set_bg_opa(&styles->bg_color_primary, LV_OPA_COVER); lv_style_set_bg_opa(&styles->bg_color_primary, LV_OPA_COVER);
style_init_reset(&styles->bg_color_primary_light);
lv_style_set_bg_color(&styles->bg_color_primary_light, lv_color_lighten(theme.color_primary, LV_OPA_90));
lv_style_set_text_color(&styles->bg_color_primary_light, theme.color_primary);
lv_style_set_content_color(&styles->bg_color_primary_light, theme.color_primary);
lv_style_set_bg_opa(&styles->bg_color_primary_light, LV_OPA_COVER);
style_init_reset(&styles->bg_color_secondary); style_init_reset(&styles->bg_color_secondary);
lv_style_set_bg_color(&styles->bg_color_secondary, theme.color_secondary); lv_style_set_bg_color(&styles->bg_color_secondary, theme.color_secondary);
lv_style_set_text_color(&styles->bg_color_secondary, lv_color_white()); lv_style_set_text_color(&styles->bg_color_secondary, lv_color_white());
@@ -338,11 +346,11 @@ static void style_init(void)
lv_style_set_text_color(&styles->bg_color_gray, CARD_TEXT_COLOR); lv_style_set_text_color(&styles->bg_color_gray, CARD_TEXT_COLOR);
lv_style_set_content_color(&styles->bg_color_gray, CARD_TEXT_COLOR); lv_style_set_content_color(&styles->bg_color_gray, CARD_TEXT_COLOR);
style_init_reset(&styles->bg_color_panel); style_init_reset(&styles->bg_color_white);
lv_style_set_bg_color(&styles->bg_color_panel, lv_color_white()); lv_style_set_bg_color(&styles->bg_color_white, lv_color_white());
lv_style_set_bg_opa(&styles->bg_color_panel, LV_OPA_COVER); lv_style_set_bg_opa(&styles->bg_color_white, LV_OPA_COVER);
lv_style_set_text_color(&styles->bg_color_panel, CARD_TEXT_COLOR); lv_style_set_text_color(&styles->bg_color_white, CARD_TEXT_COLOR);
lv_style_set_content_color(&styles->bg_color_panel, CARD_TEXT_COLOR); lv_style_set_content_color(&styles->bg_color_white, CARD_TEXT_COLOR);
style_init_reset(&styles->circle); style_init_reset(&styles->circle);
lv_style_set_radius(&styles->circle, LV_RADIUS_CIRCLE); lv_style_set_radius(&styles->circle, LV_RADIUS_CIRCLE);
@@ -375,11 +383,6 @@ static void style_init(void)
lv_style_set_arc_color(&styles->arc_indic_primary, theme.color_primary); lv_style_set_arc_color(&styles->arc_indic_primary, theme.color_primary);
#endif #endif
#if LV_USE_DROPDOWN
style_init_reset(&styles->ddlist_flip);
lv_style_set_transform_angle(&styles->ddlist_flip, 1800);
#endif
#if LV_USE_CHECKBOX #if LV_USE_CHECKBOX
style_init_reset(&styles->cb_marker); style_init_reset(&styles->cb_marker);
lv_style_set_pad_all(&styles->cb_marker, LV_DPX(3)); lv_style_set_pad_all(&styles->cb_marker, LV_DPX(3));
@@ -466,6 +469,12 @@ static void style_init(void)
lv_style_set_pad_all(&styles->msgbox_btns_bg, OUTLINE_WIDTH); lv_style_set_pad_all(&styles->msgbox_btns_bg, OUTLINE_WIDTH);
#endif #endif
#if LV_USE_TABVIEW
style_init_reset(&styles->tab_btn);
lv_style_set_border_color(&styles->tab_btn, theme.color_primary);
lv_style_set_border_width(&styles->tab_btn, lv_dpx(3));
lv_style_set_border_side(&styles->tab_btn, LV_BORDER_SIDE_BOTTOM);
#endif
#if LV_USE_LIST #if LV_USE_LIST
style_init_reset(&styles->list_bg); style_init_reset(&styles->list_bg);
lv_style_set_pad_hor(&styles->list_bg, PAD_DEF); lv_style_set_pad_hor(&styles->list_bg, PAD_DEF);
@@ -502,9 +511,9 @@ static void style_init(void)
* GLOBAL FUNCTIONS * GLOBAL FUNCTIONS
**********************/ **********************/
lv_theme_t * lv_theme_default_init(lv_color_t color_primary, lv_color_t color_secondary, lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary,
const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_small, const lv_font_t * font_normal,
const lv_font_t * font_large, const lv_font_t * font_extra_large) const lv_font_t * font_large)
{ {
/* This trick is required only to avoid the garbage collection of /* This trick is required only to avoid the garbage collection of
@@ -515,12 +524,12 @@ lv_theme_t * lv_theme_default_init(lv_color_t color_primary, lv_color_t color_se
styles = (my_theme_styles_t *)LV_GC_ROOT(_lv_theme_default_styles); styles = (my_theme_styles_t *)LV_GC_ROOT(_lv_theme_default_styles);
} }
theme.disp = disp;
theme.color_primary = color_primary; theme.color_primary = color_primary;
theme.color_secondary = color_secondary; theme.color_secondary = color_secondary;
theme.font_small = font_small; theme.font_small = font_small;
theme.font_normal = font_normal; theme.font_normal = font_normal;
theme.font_large = font_large; theme.font_large = font_large;
theme.font_extra_large = font_extra_large;
theme.apply_cb = theme_apply; theme.apply_cb = theme_apply;
style_init(); style_init();
@@ -530,6 +539,11 @@ lv_theme_t * lv_theme_default_init(lv_color_t color_primary, lv_color_t color_se
return (lv_theme_t *)&theme; return (lv_theme_t *)&theme;
} }
bool lv_theme_default_is_inited(void)
{
return inited;
}
static void theme_apply(lv_theme_t * th, lv_obj_t * obj) static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
{ {
@@ -587,7 +601,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
#if LV_USE_LIST #if LV_USE_LIST
/*Add different buttons to the lists*/ /*Add different buttons to the lists*/
if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_list_class)) { if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_list_class)) {
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->bg_color_panel); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->bg_color_white);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->list_btn); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->list_btn);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->bg_color_primary); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->bg_color_primary);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->list_item_grow); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->list_item_grow);
@@ -625,10 +639,11 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
#endif #endif
#if LV_USE_TABVIEW #if LV_USE_TABVIEW
if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_tabview_class)) { if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_tabview_class)) {
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->bg_color_panel); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->bg_color_white);
lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->bg_color_gray); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->bg_color_white);
lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_PRESSED, &styles->pressed); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_PRESSED, &styles->pressed);
lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_CHECKED, &styles->bg_color_panel); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_CHECKED, &styles->bg_color_primary_light);
lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_CHECKED, &styles->tab_btn);
return; return;
} }
#endif #endif
@@ -678,7 +693,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->no_radius); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->no_radius);
lv_obj_add_style(obj, LV_PART_SCROLLBAR, LV_STATE_DEFAULT, &styles->scrollbar); lv_obj_add_style(obj, LV_PART_SCROLLBAR, LV_STATE_DEFAULT, &styles->scrollbar);
lv_obj_add_style(obj, LV_PART_SCROLLBAR, LV_STATE_SCROLLED, &styles->scrollbar_scrolled); lv_obj_add_style(obj, LV_PART_SCROLLBAR, LV_STATE_SCROLLED, &styles->scrollbar_scrolled);
lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->bg_color_panel); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->bg_color_white);
lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->table_cell); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->table_cell);
lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->pad_normal); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->pad_normal);
lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_PRESSED, &styles->pressed); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_PRESSED, &styles->pressed);
@@ -715,7 +730,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->circle); lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->circle);
lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DISABLED, &styles->disabled); lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DISABLED, &styles->disabled);
lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->knob); lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->knob);
lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->bg_color_panel); lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->bg_color_white);
lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->pad_small_negative); lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->pad_small_negative);
lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DISABLED, &styles->disabled); lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DISABLED, &styles->disabled);
} }
@@ -748,15 +763,11 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
#if LV_USE_DROPDOWN #if LV_USE_DROPDOWN
else if(lv_obj_check_type(obj, &lv_dropdown_class)) { else if(lv_obj_check_type(obj, &lv_dropdown_class)) {
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->btn); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->pad_normal); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->pad_normal);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->transition_delayed); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->transition_delayed);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->pressed); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->pressed);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->transition_normal); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->transition_normal);
#if LV_THEME_DEFAULT_GROW
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->grow);
#endif
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_CHECKED, &styles->ddlist_flip);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->transition_normal); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->transition_normal);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->focus_outline); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->focus_outline);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_EDITED, &styles->edit_outline); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_EDITED, &styles->edit_outline);
@@ -831,7 +842,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->focus_outline); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->focus_outline);
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_EDITED, &styles->edit_outline); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_EDITED, &styles->edit_outline);
lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->btn); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->btn);
lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->bg_color_panel); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->bg_color_white);
lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_PRESSED, &styles->pressed); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_PRESSED, &styles->pressed);
lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_CHECKED, &styles->bg_color_gray); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_CHECKED, &styles->bg_color_gray);
lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_FOCUSED, &styles->focus_outline); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_FOCUSED, &styles->focus_outline);
@@ -876,9 +887,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
else if(lv_obj_check_type(obj, &lv_colorwheel_class)) { else if(lv_obj_check_type(obj, &lv_colorwheel_class)) {
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->colorwheel_main); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->colorwheel_main);
lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->pad_normal); lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->pad_normal);
lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->bg_color_panel); lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->bg_color_white);
lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->pad_normal); lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->pad_normal);
lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->bg_color_panel); lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->bg_color_white);
} }
#endif #endif

View File

@@ -36,9 +36,12 @@ extern "C" {
* @param font pointer to a font to use. * @param font pointer to a font to use.
* @return a pointer to reference this theme later * @return a pointer to reference this theme later
*/ */
lv_theme_t * lv_theme_default_init(lv_color_t color_primary, lv_color_t color_secondary, lv_theme_t * lv_theme_default_init(lv_disp_t * disp,lv_color_t color_primary, lv_color_t color_secondary,
const lv_font_t * font_small, const lv_font_t * font_normal, const lv_font_t * font_small, const lv_font_t * font_normal,
const lv_font_t * font_large, const lv_font_t * font_extra_large); const lv_font_t * font_large);
bool lv_theme_default_is_inited(void);
/********************** /**********************
* MACROS * MACROS

View File

@@ -272,7 +272,7 @@ static void draw_event_cb(lv_obj_t * obj, lv_event_t e)
if(lv_btnmatrix_has_btn_ctrl(obj, hook_dsc->id, LV_CALENDAR_CTRL_HIGHLIGHT)) { if(lv_btnmatrix_has_btn_ctrl(obj, hook_dsc->id, LV_CALENDAR_CTRL_HIGHLIGHT)) {
hook_dsc->rect_dsc->bg_opa = LV_OPA_40; hook_dsc->rect_dsc->bg_opa = LV_OPA_40;
hook_dsc->rect_dsc->bg_color = lv_theme_get_color_primary(); hook_dsc->rect_dsc->bg_color = lv_theme_get_color_primary(obj);
if(lv_btnmatrix_get_selected_btn(obj) == hook_dsc->id) { if(lv_btnmatrix_get_selected_btn(obj) == hook_dsc->id) {
hook_dsc->rect_dsc->bg_opa = LV_OPA_70; hook_dsc->rect_dsc->bg_opa = LV_OPA_70;
} }
@@ -280,7 +280,7 @@ static void draw_event_cb(lv_obj_t * obj, lv_event_t e)
if(lv_btnmatrix_has_btn_ctrl(obj, hook_dsc->id, LV_CALENDAR_CTRL_TODAY)) { if(lv_btnmatrix_has_btn_ctrl(obj, hook_dsc->id, LV_CALENDAR_CTRL_TODAY)) {
hook_dsc->rect_dsc->border_opa = LV_OPA_COVER; hook_dsc->rect_dsc->border_opa = LV_OPA_COVER;
hook_dsc->rect_dsc->border_color = lv_theme_get_color_primary(); hook_dsc->rect_dsc->border_color = lv_theme_get_color_primary(obj);
hook_dsc->rect_dsc->border_width += 1; hook_dsc->rect_dsc->border_width += 1;
} }

View File

@@ -54,7 +54,7 @@ lv_obj_t * lv_calendar_header_arrow_create(lv_obj_t * parent, lv_obj_t * calenda
lv_obj_add_event_cb(mo_prev, month_event_cb, calendar); lv_obj_add_event_cb(mo_prev, month_event_cb, calendar);
lv_obj_t * label = lv_label_create(header, NULL); lv_obj_t * label = lv_label_create(header, NULL);
lv_label_set_long_mode(label, LV_LABEL_LONG_SROLL_CIRC); lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
lv_obj_set_style_text_align(label, LV_PART_MAIN, LV_STATE_DEFAULT, LV_TEXT_ALIGN_CENTER); lv_obj_set_style_text_align(label, LV_PART_MAIN, LV_STATE_DEFAULT, LV_TEXT_ALIGN_CENTER);
lv_obj_set_flex_grow(label, 1); lv_obj_set_flex_grow(label, 1);
lv_label_set_text_fmt(label, "%d %s", cur_date->year, month_names_def[cur_date->month - 1]); lv_label_set_text_fmt(label, "%d %s", cur_date->year, month_names_def[cur_date->month - 1]);

View File

@@ -152,7 +152,7 @@ static void lv_led_constructor(lv_obj_t * obj, const lv_obj_t * copy)
{ {
LV_UNUSED(copy); LV_UNUSED(copy);
lv_led_t * led = (lv_led_t *) obj; lv_led_t * led = (lv_led_t *) obj;
led->color = lv_theme_get_color_primary(); led->color = lv_theme_get_color_primary(obj);
led->bright = LV_LED_BRIGHT_MAX; led->bright = LV_LED_BRIGHT_MAX;
led->bright = LV_LED_BRIGHT_MAX; led->bright = LV_LED_BRIGHT_MAX;

View File

@@ -56,7 +56,7 @@ lv_obj_t * lv_list_add_text(lv_obj_t * list, const char * txt)
{ {
lv_obj_t * label = lv_label_create(list, NULL); lv_obj_t * label = lv_label_create(list, NULL);
lv_label_set_text(label, txt); lv_label_set_text(label, txt);
lv_label_set_long_mode(label, LV_LABEL_LONG_SROLL_CIRC); lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
lv_obj_set_width(label, LV_SIZE_PCT(100)); lv_obj_set_width(label, LV_SIZE_PCT(100));
return label; return label;
} }
@@ -76,7 +76,7 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const char * icon, const char * txt,
if(txt) { if(txt) {
lv_obj_t * label = lv_label_create(btn, NULL); lv_obj_t * label = lv_label_create(btn, NULL);
lv_label_set_text(label, txt); lv_label_set_text(label, txt);
lv_label_set_long_mode(label, LV_LABEL_LONG_SROLL_CIRC); lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
lv_obj_set_flex_grow(label, 1); lv_obj_set_flex_grow(label, 1);
} }

View File

@@ -65,7 +65,7 @@ lv_obj_t * lv_msgbox_create(const char * title, const char * txt, const char * b
lv_obj_t * label; lv_obj_t * label;
label = lv_label_create(mbox, NULL); label = lv_label_create(mbox, NULL);
lv_label_set_text(label, title); lv_label_set_text(label, title);
lv_label_set_long_mode(label, LV_LABEL_LONG_SROLL_CIRC); lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
if(add_close_btn) lv_obj_set_flex_grow(label, 1); if(add_close_btn) lv_obj_set_flex_grow(label, 1);
else lv_obj_set_width(label, LV_SIZE_PCT(100)); else lv_obj_set_width(label, LV_SIZE_PCT(100));

View File

@@ -20,6 +20,8 @@ extern "C" {
*********************/ *********************/
#define LV_NO_TASK_READY LV_NO_TIMER_READY #define LV_NO_TASK_READY LV_NO_TIMER_READY
#define LV_INDEV_STATE_REL LV_INDEV_STATE_RELEASED
#define LV_INDEV_STATE_PR LV_INDEV_STATE_PRESSED
/********************** /**********************
* TYPEDEFS * TYPEDEFS

View File

@@ -974,73 +974,6 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h" */
# endif # endif
#endif #endif
/*==================
* THEME USAGE
*================*/
/*Set the very basic the attributes*/
#ifndef LV_THEME_COLOR_PRIMARY
# ifdef CONFIG_LV_THEME_COLOR_PRIMARY
# define LV_THEME_COLOR_PRIMARY CONFIG_LV_THEME_COLOR_PRIMARY
# else
# define LV_THEME_COLOR_PRIMARY lv_color_hex(0x01a2b1)
# endif
#endif
#ifndef LV_THEME_COLOR_SECONDARY
# ifdef CONFIG_LV_THEME_COLOR_SECONDARY
# define LV_THEME_COLOR_SECONDARY CONFIG_LV_THEME_COLOR_SECONDARY
# else
# define LV_THEME_COLOR_SECONDARY lv_color_hex(0x44d1b6)
# endif
#endif
#ifndef LV_THEME_FONT_SMALL
# ifdef CONFIG_LV_THEME_FONT_SMALL
# define LV_THEME_FONT_SMALL CONFIG_LV_THEME_FONT_SMALL
# else
# define LV_THEME_FONT_SMALL &lv_font_montserrat_14
# endif
#endif
#ifndef LV_THEME_FONT_NORMAL
# ifdef CONFIG_LV_THEME_FONT_NORMAL
# define LV_THEME_FONT_NORMAL CONFIG_LV_THEME_FONT_NORMAL
# else
# define LV_THEME_FONT_NORMAL &lv_font_montserrat_14
# endif
#endif
#ifndef LV_THEME_FONT_LARGE
# ifdef CONFIG_LV_THEME_FONT_LARGE
# define LV_THEME_FONT_LARGE CONFIG_LV_THEME_FONT_LARGE
# else
# define LV_THEME_FONT_LARGE &lv_font_montserrat_14
# endif
#endif
#ifndef LV_THEME_FONT_EXTRA_LARGE
# ifdef CONFIG_LV_THEME_FONT_EXTRA_LARGE
# define LV_THEME_FONT_EXTRA_LARGE CONFIG_LV_THEME_FONT_EXTRA_LARGE
# else
# define LV_THEME_FONT_EXTRA_LARGE &lv_font_montserrat_14
# endif
#endif
/* An external include file required to see the theme init function.
* Relative to "lv_core/lv_obj" */
#ifndef LV_THEME_INIT_INCLUDE
# ifdef CONFIG_LV_THEME_INIT_INCLUDE
# define LV_THEME_INIT_INCLUDE CONFIG_LV_THEME_INIT_INCLUDE
# else
# define LV_THEME_INIT_INCLUDE "../extra/themes/lv_themes.h"
# endif
#endif
/* Set a theme initialization function */
#ifndef LV_THEME_INIT
# ifdef CONFIG_LV_THEME_INIT
# define LV_THEME_INIT CONFIG_LV_THEME_INIT
# else
# define LV_THEME_INIT lv_theme_default_init
# endif
#endif
/*================== /*==================
* WIDGET USAGE * WIDGET USAGE
*================*/ *================*/

View File

@@ -120,6 +120,25 @@ lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp)
return disp->sys_layer; return disp->sys_layer;
} }
/**
* Get the theme of a display
* @param disp pointer to a display
* @return the display's theme (can be NULL)
*/
void lv_disp_set_theme(lv_disp_t * disp, lv_theme_t * th)
{
disp->theme = th;
}
/**
* Get the theme of a display
* @param disp pointer to a display
* @return the display's theme (can be NULL)
*/
lv_theme_t * lv_disp_get_theme(lv_disp_t * disp)
{
return disp->theme;
}
/** /**
* Set the background color of a display * Set the background color of a display
* @param disp pointer to a display * @param disp pointer to a display
@@ -199,7 +218,7 @@ void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t
lv_disp_load_scr(d->scr_to_load); lv_disp_load_scr(d->scr_to_load);
lv_anim_del(d->scr_to_load, NULL); lv_anim_del(d->scr_to_load, NULL);
lv_obj_set_pos(d->scr_to_load, 0, 0); lv_obj_set_pos(d->scr_to_load, 0, 0);
// lv_style_remove_prop(lv_obj_get_local_style(d->scr_to_load, LV_PART_MAIN, LV_STATE_DEFAULT), LV_STYLE_OPA); lv_obj_remove_local_style_prop(d->scr_to_load, LV_PART_MAIN, LV_STATE_DEFAULT, LV_STYLE_OPA);
act_scr = d->scr_to_load; act_scr = d->scr_to_load;
} }
@@ -364,7 +383,7 @@ lv_timer_t * _lv_disp_get_refr_task(lv_disp_t * disp)
return NULL; return NULL;
} }
return disp->read_task; return disp->refr_timer;
} }
/********************** /**********************

View File

@@ -15,6 +15,7 @@ extern "C" {
*********************/ *********************/
#include "../lv_hal/lv_hal.h" #include "../lv_hal/lv_hal.h"
#include "lv_obj.h" #include "lv_obj.h"
#include "lv_theme.h"
/********************* /*********************
* DEFINES * DEFINES
@@ -78,6 +79,20 @@ lv_obj_t * lv_disp_get_layer_top(lv_disp_t * disp);
*/ */
lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp); lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp);
/**
* Get the theme of a display
* @param disp pointer to a display
* @return the display's theme (can be NULL)
*/
void lv_disp_set_theme(lv_disp_t * disp, lv_theme_t * th);
/**
* Get the theme of a display
* @param disp pointer to a display
* @return the display's theme (can be NULL)
*/
lv_theme_t * lv_disp_get_theme(lv_disp_t * disp);
/** /**
* Set the background color of a display * Set the background color of a display
* @param disp pointer to a display * @param disp pointer to a display
@@ -99,7 +114,6 @@ void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src);
*/ */
void lv_disp_set_bg_opa(lv_disp_t * disp, lv_opa_t opa); void lv_disp_set_bg_opa(lv_disp_t * disp, lv_opa_t opa);
/** /**
* Switch screen with animation * Switch screen with animation
* @param scr pointer to the new screen to load * @param scr pointer to the new screen to load

View File

@@ -84,7 +84,7 @@ void lv_indev_read_task_cb(lv_timer_t * task)
indev_act->proc.state = data.state; indev_act->proc.state = data.state;
/*Save the last activity time*/ /*Save the last activity time*/
if(indev_act->proc.state == LV_INDEV_STATE_PR) { if(indev_act->proc.state == LV_INDEV_STATE_PRESSED) {
indev_act->driver.disp->last_activity_time = lv_tick_get(); indev_act->driver.disp->last_activity_time = lv_tick_get();
} }
else if(indev_act->driver.type == LV_INDEV_TYPE_ENCODER && data.enc_diff) { else if(indev_act->driver.type == LV_INDEV_TYPE_ENCODER && data.enc_diff) {
@@ -183,7 +183,7 @@ void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj)
lv_obj_set_parent(indev->cursor, lv_disp_get_layer_sys(indev->driver.disp)); lv_obj_set_parent(indev->cursor, lv_disp_get_layer_sys(indev->driver.disp));
lv_obj_set_pos(indev->cursor, indev->proc.types.pointer.act_point.x, indev->proc.types.pointer.act_point.y); lv_obj_set_pos(indev->cursor, indev->proc.types.pointer.act_point.x, indev->proc.types.pointer.act_point.y);
lv_obj_clear_flag(indev->cursor, LV_OBJ_FLAG_CLICKABLE); lv_obj_clear_flag(indev->cursor, LV_OBJ_FLAG_CLICKABLE);
lv_obj_clear_flag(indev->cursor, LV_OBJ_FLAG_LAYOUTABLE); lv_obj_add_flag(indev->cursor, LV_OBJ_FLAG_IGNORE_LAYOUT);
} }
void lv_indev_set_group(lv_indev_t * indev, lv_group_t * group) void lv_indev_set_group(lv_indev_t * indev, lv_group_t * group)
@@ -275,7 +275,7 @@ lv_timer_t * lv_indev_get_read_task(lv_disp_t * indev)
return NULL; return NULL;
} }
return indev->read_task; return indev->refr_timer;
} }
lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t * point) lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t * point)
@@ -339,7 +339,7 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data)
i->proc.types.pointer.act_point.x = data->point.x; i->proc.types.pointer.act_point.x = data->point.x;
i->proc.types.pointer.act_point.y = data->point.y; i->proc.types.pointer.act_point.y = data->point.y;
if(i->proc.state == LV_INDEV_STATE_PR) { if(i->proc.state == LV_INDEV_STATE_PRESSED) {
indev_proc_press(&i->proc); indev_proc_press(&i->proc);
} }
else { else {
@@ -357,13 +357,13 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data)
*/ */
static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
{ {
if(data->state == LV_INDEV_STATE_PR && i->proc.wait_until_release) return; if(data->state == LV_INDEV_STATE_PRESSED && i->proc.wait_until_release) return;
if(i->proc.wait_until_release) { if(i->proc.wait_until_release) {
i->proc.wait_until_release = 0; i->proc.wait_until_release = 0;
i->proc.pr_timestamp = 0; i->proc.pr_timestamp = 0;
i->proc.long_pr_sent = 0; i->proc.long_pr_sent = 0;
i->proc.types.keypad.last_state = LV_INDEV_STATE_REL; /*To skip the processing of release*/ i->proc.types.keypad.last_state = LV_INDEV_STATE_RELEASED; /*To skip the processing of release*/
} }
lv_group_t * g = i->group; lv_group_t * g = i->group;
@@ -386,7 +386,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
i->proc.types.keypad.last_state = data->state; i->proc.types.keypad.last_state = data->state;
/*Key press happened*/ /*Key press happened*/
if(data->state == LV_INDEV_STATE_PR && prev_state == LV_INDEV_STATE_REL) { if(data->state == LV_INDEV_STATE_PRESSED && prev_state == LV_INDEV_STATE_RELEASED) {
i->proc.pr_timestamp = lv_tick_get(); i->proc.pr_timestamp = lv_tick_get();
/*Simulate a press on the object if ENTER was pressed*/ /*Simulate a press on the object if ENTER was pressed*/
@@ -424,7 +424,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
} }
} }
/*Pressing*/ /*Pressing*/
else if(data->state == LV_INDEV_STATE_PR && prev_state == LV_INDEV_STATE_PR) { else if(data->state == LV_INDEV_STATE_PRESSED && prev_state == LV_INDEV_STATE_PRESSED) {
if(data->key == LV_KEY_ENTER) { if(data->key == LV_KEY_ENTER) {
lv_signal_send(indev_obj_act, LV_SIGNAL_PRESSING, NULL); lv_signal_send(indev_obj_act, LV_SIGNAL_PRESSING, NULL);
@@ -477,7 +477,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
} }
} }
/*Release happened*/ /*Release happened*/
else if(data->state == LV_INDEV_STATE_REL && prev_state == LV_INDEV_STATE_PR) { else if(data->state == LV_INDEV_STATE_RELEASED && prev_state == LV_INDEV_STATE_PRESSED) {
/*The user might clear the key when it was released. Always release the pressed key*/ /*The user might clear the key when it was released. Always release the pressed key*/
data->key = prev_key; data->key = prev_key;
if(data->key == LV_KEY_ENTER) { if(data->key == LV_KEY_ENTER) {
@@ -509,13 +509,13 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
*/ */
static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
{ {
if(data->state == LV_INDEV_STATE_PR && i->proc.wait_until_release) return; if(data->state == LV_INDEV_STATE_PRESSED && i->proc.wait_until_release) return;
if(i->proc.wait_until_release) { if(i->proc.wait_until_release) {
i->proc.wait_until_release = 0; i->proc.wait_until_release = 0;
i->proc.pr_timestamp = 0; i->proc.pr_timestamp = 0;
i->proc.long_pr_sent = 0; i->proc.long_pr_sent = 0;
i->proc.types.keypad.last_state = LV_INDEV_STATE_REL; /*To skip the processing of release*/ i->proc.types.keypad.last_state = LV_INDEV_STATE_RELEASED; /*To skip the processing of release*/
} }
/* Save the last keys before anything else. /* Save the last keys before anything else.
@@ -531,7 +531,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
if(indev_obj_act == NULL) return; if(indev_obj_act == NULL) return;
/*Process the steps they are valid only with released button*/ /*Process the steps they are valid only with released button*/
if(data->state != LV_INDEV_STATE_REL) { if(data->state != LV_INDEV_STATE_RELEASED) {
data->enc_diff = 0; data->enc_diff = 0;
} }
@@ -540,7 +540,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
if(indev_obj_act == NULL) return; if(indev_obj_act == NULL) return;
/*Button press happened*/ /*Button press happened*/
if(data->state == LV_INDEV_STATE_PR && last_state == LV_INDEV_STATE_REL) { if(data->state == LV_INDEV_STATE_PRESSED && last_state == LV_INDEV_STATE_RELEASED) {
i->proc.pr_timestamp = lv_tick_get(); i->proc.pr_timestamp = lv_tick_get();
@@ -576,7 +576,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
} }
} }
/*Pressing*/ /*Pressing*/
else if(data->state == LV_INDEV_STATE_PR && last_state == LV_INDEV_STATE_PR) { else if(data->state == LV_INDEV_STATE_PRESSED && last_state == LV_INDEV_STATE_PRESSED) {
/* Long press*/ /* Long press*/
if(i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) { if(i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) {
@@ -632,7 +632,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
} }
/*Release happened*/ /*Release happened*/
else if(data->state == LV_INDEV_STATE_REL && last_state == LV_INDEV_STATE_PR) { else if(data->state == LV_INDEV_STATE_RELEASED && last_state == LV_INDEV_STATE_PRESSED) {
if(data->key == LV_KEY_ENTER) { if(data->key == LV_KEY_ENTER) {
bool editable = lv_obj_is_editable(indev_obj_act); bool editable = lv_obj_is_editable(indev_obj_act);
@@ -725,7 +725,7 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data)
lv_coord_t y = i->btn_points[data->btn_id].y; lv_coord_t y = i->btn_points[data->btn_id].y;
/*If a new point comes always make a release*/ /*If a new point comes always make a release*/
if(data->state == LV_INDEV_STATE_PR) { if(data->state == LV_INDEV_STATE_PRESSED) {
if(i->proc.types.pointer.last_point.x != x || if(i->proc.types.pointer.last_point.x != x ||
i->proc.types.pointer.last_point.y != y) { i->proc.types.pointer.last_point.y != y) {
indev_proc_release(&i->proc); indev_proc_release(&i->proc);
@@ -738,7 +738,7 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data)
i->proc.types.pointer.act_point.x = x; i->proc.types.pointer.act_point.x = x;
i->proc.types.pointer.act_point.y = y; i->proc.types.pointer.act_point.y = y;
if(data->state == LV_INDEV_STATE_PR) indev_proc_press(&i->proc); if(data->state == LV_INDEV_STATE_PRESSED) indev_proc_press(&i->proc);
else indev_proc_release(&i->proc); else indev_proc_release(&i->proc);
if(indev_reset_check(&i->proc)) return; if(indev_reset_check(&i->proc)) return;

View File

@@ -25,8 +25,6 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include LV_THEME_INIT_INCLUDE
#if LV_USE_GPU_STM32_DMA2D #if LV_USE_GPU_STM32_DMA2D
#include "../lv_gpu/lv_gpu_stm32_dma2d.h" #include "../lv_gpu/lv_gpu_stm32_dma2d.h"
#endif #endif
@@ -124,13 +122,6 @@ void lv_init(void)
_lv_ll_init(&LV_GC_ROOT(_lv_disp_ll), sizeof(lv_disp_t)); _lv_ll_init(&LV_GC_ROOT(_lv_disp_ll), sizeof(lv_disp_t));
_lv_ll_init(&LV_GC_ROOT(_lv_indev_ll), sizeof(lv_indev_t)); _lv_ll_init(&LV_GC_ROOT(_lv_indev_ll), sizeof(lv_indev_t));
#ifdef LV_THEME_INIT
lv_theme_t * th = LV_THEME_INIT(LV_THEME_COLOR_PRIMARY, LV_THEME_COLOR_SECONDARY,
LV_THEME_FONT_SMALL, LV_THEME_FONT_NORMAL,
LV_THEME_FONT_LARGE, LV_THEME_FONT_EXTRA_LARGE);
lv_theme_set_act(th);
#endif
/*Initialize the screen refresh system*/ /*Initialize the screen refresh system*/
_lv_refr_init(); _lv_refr_init();
@@ -318,9 +309,9 @@ void lv_obj_add_flag(lv_obj_t * obj, lv_obj_flag_t f)
obj->flags |= f; obj->flags |= f;
if(f & LV_OBJ_FLAG_LAYOUTABLE) lv_signal_send(lv_obj_get_parent(obj), LV_SIGNAL_CHILD_CHG, obj); if(f & LV_OBJ_FLAG_IGNORE_LAYOUT) lv_signal_send(lv_obj_get_parent(obj), LV_SIGNAL_CHILD_CHG, obj);
if(f & LV_OBJ_FLAG_HIDDEN) { if(f & (LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_LAYOUT_1 | LV_OBJ_FLAG_LAYOUT_2)) {
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
if(lv_obj_is_layout_positioned(obj)) { if(lv_obj_is_layout_positioned(obj)) {
lv_obj_update_layout(lv_obj_get_parent(obj), obj); lv_obj_update_layout(lv_obj_get_parent(obj), obj);
@@ -340,7 +331,7 @@ void lv_obj_clear_flag(lv_obj_t * obj, lv_obj_flag_t f)
lv_obj_update_layout(lv_obj_get_parent(obj), obj); lv_obj_update_layout(lv_obj_get_parent(obj), obj);
} }
} }
if(f & LV_OBJ_FLAG_LAYOUTABLE) lv_signal_send(lv_obj_get_parent(obj), LV_SIGNAL_CHILD_CHG, obj); if(f & LV_OBJ_FLAG_IGNORE_LAYOUT) lv_signal_send(lv_obj_get_parent(obj), LV_SIGNAL_CHILD_CHG, obj);
} }
void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
@@ -666,7 +657,6 @@ static void lv_obj_constructor(lv_obj_t * obj, const lv_obj_t * copy)
obj->flags |= LV_OBJ_FLAG_SNAPABLE; obj->flags |= LV_OBJ_FLAG_SNAPABLE;
if(parent) obj->flags |= LV_OBJ_FLAG_PRESS_LOCK; if(parent) obj->flags |= LV_OBJ_FLAG_PRESS_LOCK;
if(parent) obj->flags |= LV_OBJ_FLAG_SCROLL_CHAIN; if(parent) obj->flags |= LV_OBJ_FLAG_SCROLL_CHAIN;
if(parent) obj->flags |= LV_OBJ_FLAG_LAYOUTABLE;
obj->flags |= LV_OBJ_FLAG_CLICK_FOCUSABLE; obj->flags |= LV_OBJ_FLAG_CLICK_FOCUSABLE;
obj->flags |= LV_OBJ_FLAG_SCROLLABLE; obj->flags |= LV_OBJ_FLAG_SCROLLABLE;
obj->flags |= LV_OBJ_FLAG_SCROLL_ELASTIC; obj->flags |= LV_OBJ_FLAG_SCROLL_ELASTIC;

View File

@@ -193,7 +193,7 @@ enum {
LV_OBJ_FLAG_SCROLLABLE = (1 << 4), /**< Make the object scrollable*/ LV_OBJ_FLAG_SCROLLABLE = (1 << 4), /**< Make the object scrollable*/
LV_OBJ_FLAG_SCROLL_ELASTIC = (1 << 5), /**< Allow scrolling inside but with slower speed*/ LV_OBJ_FLAG_SCROLL_ELASTIC = (1 << 5), /**< Allow scrolling inside but with slower speed*/
LV_OBJ_FLAG_SCROLL_MOMENTUM = (1 << 6), /**< Make the object scroll further when "thrown"*/ LV_OBJ_FLAG_SCROLL_MOMENTUM = (1 << 6), /**< Make the object scroll further when "thrown"*/
LV_OBJ_FLAG_SCROLL_ONE = (1 << 7), /**< Allow scrolling only one snapable children*/ LV_OBJ_FLAG_SCROLL_ONE = (1 << 7), /**< Allow scrolling only one snapable children*/
LV_OBJ_FLAG_SCROLL_CHAIN = (1 << 8), /**< Allow propagating the scroll to a parent */ LV_OBJ_FLAG_SCROLL_CHAIN = (1 << 8), /**< Allow propagating the scroll to a parent */
LV_OBJ_FLAG_SCROLL_ON_FOCUS = (1 << 9), /**< Automatically scroll object to make it visible when focused*/ LV_OBJ_FLAG_SCROLL_ON_FOCUS = (1 << 9), /**< Automatically scroll object to make it visible when focused*/
LV_OBJ_FLAG_SNAPABLE = (1 << 10), /**< If scroll snap is enabled on the parent it can snap to this object*/ LV_OBJ_FLAG_SNAPABLE = (1 << 10), /**< If scroll snap is enabled on the parent it can snap to this object*/
@@ -202,7 +202,7 @@ enum {
LV_OBJ_FLAG_GESTURE_BUBBLE = (1 << 13), /**< Propagate the gestures to the parent */ LV_OBJ_FLAG_GESTURE_BUBBLE = (1 << 13), /**< Propagate the gestures to the parent */
LV_OBJ_FLAG_FOCUS_BUBBLE = (1 << 14), /**< Propagate the focus to the parent */ LV_OBJ_FLAG_FOCUS_BUBBLE = (1 << 14), /**< Propagate the focus to the parent */
LV_OBJ_FLAG_ADV_HITTEST = (1 << 15), /**< Allow performing more accurate hit (click) test. E.g. consider rounded corners. */ LV_OBJ_FLAG_ADV_HITTEST = (1 << 15), /**< Allow performing more accurate hit (click) test. E.g. consider rounded corners. */
LV_OBJ_FLAG_LAYOUTABLE = (1 << 16), /**< Make the object position-able by the layouts */ LV_OBJ_FLAG_IGNORE_LAYOUT = (1 << 16), /**< Make the object position-able by the layouts */
LV_OBJ_FLAG_LAYOUT_1 = (1 << 23), /** Custom flag, free to use by layouts*/ LV_OBJ_FLAG_LAYOUT_1 = (1 << 23), /** Custom flag, free to use by layouts*/
LV_OBJ_FLAG_LAYOUT_2 = (1 << 24), /** Custom flag, free to use by layouts*/ LV_OBJ_FLAG_LAYOUT_2 = (1 << 24), /** Custom flag, free to use by layouts*/

View File

@@ -154,7 +154,7 @@ void lv_obj_set_layout(lv_obj_t * obj, const void * layout)
bool lv_obj_is_layout_positioned(const lv_obj_t * obj) bool lv_obj_is_layout_positioned(const lv_obj_t * obj)
{ {
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_LAYOUTABLE) == false) return false; if(lv_obj_has_flag(obj, LV_OBJ_FLAG_IGNORE_LAYOUT)) return false;
lv_obj_t * parent = lv_obj_get_parent(obj); lv_obj_t * parent = lv_obj_get_parent(obj);
if(parent == NULL) return false; if(parent == NULL) return false;

View File

@@ -84,13 +84,13 @@ void lv_refr_now(lv_disp_t * disp)
lv_anim_refr_now(); lv_anim_refr_now();
if(disp) { if(disp) {
_lv_disp_refr_task(disp->read_task); _lv_disp_refr_task(disp->refr_timer);
} }
else { else {
lv_disp_t * d; lv_disp_t * d;
d = lv_disp_get_next(NULL); d = lv_disp_get_next(NULL);
while(d) { while(d) {
_lv_disp_refr_task(d->read_task); _lv_disp_refr_task(d->refr_timer);
d = lv_disp_get_next(d); d = lv_disp_get_next(d);
} }
} }
@@ -129,7 +129,7 @@ void _lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p)
if(lv_disp_is_true_double_buf(disp)) { if(lv_disp_is_true_double_buf(disp)) {
disp->inv_areas[0] = scr_area; disp->inv_areas[0] = scr_area;
disp->inv_p = 1; disp->inv_p = 1;
lv_timer_pause(disp->read_task, false); lv_timer_pause(disp->refr_timer, false);
return; return;
} }
@@ -150,7 +150,7 @@ void _lv_inv_area(lv_disp_t * disp, const lv_area_t * area_p)
lv_area_copy(&disp->inv_areas[disp->inv_p], &scr_area); lv_area_copy(&disp->inv_areas[disp->inv_p], &scr_area);
} }
disp->inv_p++; disp->inv_p++;
lv_timer_pause(disp->read_task, false); lv_timer_pause(disp->refr_timer, false);
} }
/** /**
@@ -251,7 +251,7 @@ void _lv_disp_refr_task(lv_timer_t * tmr)
} }
else { else {
perf_last_time = lv_tick_get(); perf_last_time = lv_tick_get();
uint32_t fps_limit = 1000 / disp_refr->read_task->period; uint32_t fps_limit = 1000 / disp_refr->refr_timer->period;
uint32_t fps; uint32_t fps;
if(elaps_sum == 0) elaps_sum = 1; if(elaps_sum == 0) elaps_sum = 1;

View File

@@ -24,7 +24,6 @@ static void apply_theme(lv_theme_t * th, lv_obj_t * obj);
/********************** /**********************
* STATIC VARIABLES * STATIC VARIABLES
**********************/ **********************/
static lv_theme_t * act_theme;
/********************** /**********************
* MACROS * MACROS
@@ -34,23 +33,10 @@ static lv_theme_t * act_theme;
* GLOBAL FUNCTIONS * GLOBAL FUNCTIONS
**********************/ **********************/
/** lv_theme_t * lv_theme_get_from_obj(lv_obj_t * obj)
* Set a theme for the system.
* From now, all the created objects will use styles from this theme by default
* @param th pointer to theme (return value of: 'lv_theme_init_xxx()')
*/
void lv_theme_set_act(lv_theme_t * th)
{ {
act_theme = th; lv_disp_t * disp = obj ? lv_obj_get_disp(obj) : lv_disp_get_default();
} return lv_disp_get_theme(disp);
/**
* Get the current system theme.
* @return pointer to the current system theme. NULL if not set.
*/
lv_theme_t * lv_theme_get_act(void)
{
return act_theme;
} }
/** /**
@@ -60,12 +46,14 @@ lv_theme_t * lv_theme_get_act(void)
*/ */
void lv_theme_apply(lv_obj_t * obj) void lv_theme_apply(lv_obj_t * obj)
{ {
lv_theme_t * th = lv_theme_get_from_obj(obj);
if(th == NULL) return;
lv_obj_enable_style_refresh(false); lv_obj_enable_style_refresh(false);
lv_obj_remove_style(obj, LV_PART_ANY, LV_STATE_ANY, NULL); lv_obj_remove_style(obj, LV_PART_ANY, LV_STATE_ANY, NULL);
if(act_theme == NULL) return; apply_theme(th, obj); /*Apply the theme including the base theme(s)*/
apply_theme(act_theme, obj); /*Apply the theme including the base theme(s)*/
lv_obj_enable_style_refresh(true); lv_obj_enable_style_refresh(true);
lv_obj_refresh_style(obj, LV_PART_ANY, LV_STYLE_PROP_ALL); lv_obj_refresh_style(obj, LV_PART_ANY, LV_STYLE_PROP_ALL);
@@ -94,38 +82,34 @@ void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb)
theme->apply_cb = apply_cb; theme->apply_cb = apply_cb;
} }
const lv_font_t * lv_theme_get_font_small(void) const lv_font_t * lv_theme_get_font_small(lv_obj_t * obj)
{ {
return act_theme->font_small; lv_theme_t * th = lv_theme_get_from_obj(obj);
return th ? th->font_small : LV_FONT_DEFAULT;
} }
const lv_font_t * lv_theme_get_font_normal(void) const lv_font_t * lv_theme_get_font_normal(lv_obj_t * obj)
{ {
return act_theme->font_normal; lv_theme_t * th = lv_theme_get_from_obj(obj);
return th ? th->font_normal : LV_FONT_DEFAULT;
} }
const lv_font_t * lv_theme_get_font_large(void) const lv_font_t * lv_theme_get_font_large(lv_obj_t * obj)
{ {
return act_theme->font_large; lv_theme_t * th = lv_theme_get_from_obj(obj);
return th ? th->font_large : LV_FONT_DEFAULT;
} }
const lv_font_t * lv_theme_get_font_extra_large(void) lv_color_t lv_theme_get_color_primary(lv_obj_t * obj)
{ {
return act_theme->font_extra_large; lv_theme_t * th = lv_theme_get_from_obj(obj);
return th ? th->color_primary : lv_color_blue_grey();
} }
lv_color_t lv_theme_get_color_primary(void) lv_color_t lv_theme_get_color_secondary(lv_obj_t * obj)
{ {
return act_theme->color_primary; lv_theme_t * th = lv_theme_get_from_obj(obj);
} return th ? th->color_secondary : lv_color_blue();
/**
* Get the secondary color of the theme
* @return the color
*/
lv_color_t lv_theme_get_color_secondary(void)
{
return act_theme->color_secondary;
} }
/********************** /**********************
@@ -135,5 +119,5 @@ lv_color_t lv_theme_get_color_secondary(void)
static void apply_theme(lv_theme_t * th, lv_obj_t * obj) static void apply_theme(lv_theme_t * th, lv_obj_t * obj)
{ {
if(th->parent) apply_theme(th->parent, obj); if(th->parent) apply_theme(th->parent, obj);
if(th->apply_cb) th->apply_cb(act_theme, obj); if(th->apply_cb) th->apply_cb(th, obj);
} }

View File

@@ -24,6 +24,7 @@ extern "C" {
**********************/ **********************/
struct _lv_theme_t; struct _lv_theme_t;
struct _lv_disp_t;
typedef void (*lv_theme_apply_cb_t)(struct _lv_theme_t *, lv_obj_t *); typedef void (*lv_theme_apply_cb_t)(struct _lv_theme_t *, lv_obj_t *);
@@ -31,12 +32,12 @@ typedef struct _lv_theme_t {
lv_theme_apply_cb_t apply_cb; lv_theme_apply_cb_t apply_cb;
struct _lv_theme_t * parent; /**< Apply the current theme's style on top of this theme.*/ struct _lv_theme_t * parent; /**< Apply the current theme's style on top of this theme.*/
void * user_data; void * user_data;
struct _lv_disp_t * disp;
lv_color_t color_primary; lv_color_t color_primary;
lv_color_t color_secondary; lv_color_t color_secondary;
const lv_font_t * font_small; const lv_font_t * font_small;
const lv_font_t * font_normal; const lv_font_t * font_normal;
const lv_font_t * font_large; const lv_font_t * font_large;
const lv_font_t * font_extra_large;
} lv_theme_t; } lv_theme_t;
/********************** /**********************
@@ -83,36 +84,30 @@ void lv_theme_set_apply_cb(lv_theme_t * theme, lv_theme_apply_cb_t apply_cb);
* Get the small font of the theme * Get the small font of the theme
* @return pointer to the font * @return pointer to the font
*/ */
const lv_font_t * lv_theme_get_font_small(void); const lv_font_t * lv_theme_get_font_small(lv_obj_t * obj);
/** /**
* Get the normal font of the theme * Get the normal font of the theme
* @return pointer to the font * @return pointer to the font
*/ */
const lv_font_t * lv_theme_get_font_normal(void); const lv_font_t * lv_theme_get_font_normal(lv_obj_t * obj);
/** /**
* Get the subtitle font of the theme * Get the subtitle font of the theme
* @return pointer to the font * @return pointer to the font
*/ */
const lv_font_t * lv_theme_get_font_large(void); const lv_font_t * lv_theme_get_font_large(lv_obj_t * obj);
/**
* Get the title font of the theme
* @return pointer to the font
*/
const lv_font_t * lv_theme_get_font_extra_large(void);
/** /**
* Get the primary color of the theme * Get the primary color of the theme
* @return the color * @return the color
*/ */
lv_color_t lv_theme_get_color_primary(void); lv_color_t lv_theme_get_color_primary(lv_obj_t * obj);
/** /**
* Get the secondary color of the theme * Get the secondary color of the theme
* @return the color * @return the color
*/ */
lv_color_t lv_theme_get_color_secondary(void); lv_color_t lv_theme_get_color_secondary(lv_obj_t * obj);
/********************** /**********************
* MACROS * MACROS

View File

@@ -96,7 +96,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc)
lv_memset_00(dsc, sizeof(lv_draw_label_dsc_t)); lv_memset_00(dsc, sizeof(lv_draw_label_dsc_t));
dsc->opa = LV_OPA_COVER; dsc->opa = LV_OPA_COVER;
dsc->color = lv_color_black(); dsc->color = lv_color_black();
dsc->font = LV_THEME_FONT_NORMAL; dsc->font = LV_FONT_DEFAULT;
dsc->sel_start = LV_DRAW_LABEL_NO_TXT_SEL; dsc->sel_start = LV_DRAW_LABEL_NO_TXT_SEL;
dsc->sel_end = LV_DRAW_LABEL_NO_TXT_SEL; dsc->sel_end = LV_DRAW_LABEL_NO_TXT_SEL;
dsc->sel_color = lv_color_black(); dsc->sel_color = lv_color_black();

View File

@@ -83,7 +83,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
dsc->bg_img_opa = LV_OPA_COVER; dsc->bg_img_opa = LV_OPA_COVER;
dsc->outline_opa = LV_OPA_COVER; dsc->outline_opa = LV_OPA_COVER;
dsc->border_opa = LV_OPA_COVER; dsc->border_opa = LV_OPA_COVER;
dsc->content_font = LV_THEME_FONT_NORMAL; dsc->content_font = LV_FONT_DEFAULT;
dsc->content_opa = LV_OPA_COVER; dsc->content_opa = LV_OPA_COVER;
dsc->content_align = LV_ALIGN_CENTER; dsc->content_align = LV_ALIGN_CENTER;
dsc->shadow_opa = LV_OPA_COVER; dsc->shadow_opa = LV_OPA_COVER;

View File

@@ -17,6 +17,10 @@
#include "../lv_misc/lv_assert.h" #include "../lv_misc/lv_assert.h"
#include "../lv_core/lv_obj.h" #include "../lv_core/lv_obj.h"
#include "../lv_core/lv_refr.h" #include "../lv_core/lv_refr.h"
#include "../lv_core/lv_theme.h"
#if LV_USE_THEME_DEFAULT
#include "../extra/themes/default/lv_theme_default.h"
#endif
/********************* /*********************
* DEFINES * DEFINES
@@ -119,9 +123,9 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
disp_def = disp; /*Temporarily change the default screen to create the default screens on the disp_def = disp; /*Temporarily change the default screen to create the default screens on the
new display*/ new display*/
/*Create a refresh task*/ /*Create a refresh task*/
disp->read_task = lv_timer_create(_lv_disp_refr_task, LV_DISP_DEF_REFR_PERIOD, disp); disp->refr_timer = lv_timer_create(_lv_disp_refr_task, LV_DISP_DEF_REFR_PERIOD, disp);
LV_ASSERT_MALLOC(disp->read_task); LV_ASSERT_MALLOC(disp->refr_timer);
if(disp->read_task == NULL) return NULL; if(disp->refr_timer == NULL) return NULL;
disp->inv_p = 0; disp->inv_p = 0;
disp->last_activity_time = 0; disp->last_activity_time = 0;
@@ -134,6 +138,12 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
disp->bg_opa = LV_OPA_COVER; disp->bg_opa = LV_OPA_COVER;
#endif #endif
#if LV_USE_THEME_DEFAULT
if(lv_theme_default_is_inited() == false) {
disp->theme = lv_theme_default_init(disp, lv_color_blue(), lv_color_purple(), LV_FONT_DEFAULT, LV_FONT_DEFAULT, LV_FONT_DEFAULT);
}
#endif
disp->prev_scr = NULL; disp->prev_scr = NULL;
disp->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/ disp->act_scr = lv_obj_create(NULL, NULL); /*Create a default screen on the display*/
disp->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/ disp->top_layer = lv_obj_create(NULL, NULL); /*Create top layer on the display*/
@@ -150,7 +160,7 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver)
disp_def = disp_def_tmp; /*Revert the default display*/ disp_def = disp_def_tmp; /*Revert the default display*/
lv_timer_ready(disp->read_task); /*Be sure the screen will be refreshed immediately on start up*/ lv_timer_ready(disp->refr_timer); /*Be sure the screen will be refreshed immediately on start up*/
return disp; return disp;
} }

View File

@@ -38,8 +38,9 @@ extern "C" {
* TYPEDEFS * TYPEDEFS
**********************/ **********************/
struct _disp_t; struct _lv_disp_t;
struct _disp_drv_t; struct _lv_disp_drv_t;
struct _lv_theme_t;
/** /**
* Structure for holding display buffer information. * Structure for holding display buffer information.
@@ -71,7 +72,7 @@ typedef enum {
/** /**
* Display Driver structure to be registered by HAL * Display Driver structure to be registered by HAL
*/ */
typedef struct _disp_drv_t { typedef struct _lv_disp_drv_t {
lv_coord_t hor_res; /**< Horizontal resolution. */ lv_coord_t hor_res; /**< Horizontal resolution. */
lv_coord_t ver_res; /**< Vertical resolution. */ lv_coord_t ver_res; /**< Vertical resolution. */
@@ -97,35 +98,35 @@ typedef struct _disp_drv_t {
/** MANDATORY: Write the internal buffer (VDB) to the display. 'lv_disp_flush_ready()' has to be /** MANDATORY: Write the internal buffer (VDB) to the display. 'lv_disp_flush_ready()' has to be
* called when finished */ * called when finished */
void (*flush_cb)(struct _disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p); void (*flush_cb)(struct _lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
/** OPTIONAL: Extend the invalidated areas to match with the display drivers requirements /** OPTIONAL: Extend the invalidated areas to match with the display drivers requirements
* E.g. round `y` to, 8, 16 ..) on a monochrome display*/ * E.g. round `y` to, 8, 16 ..) on a monochrome display*/
void (*rounder_cb)(struct _disp_drv_t * disp_drv, lv_area_t * area); void (*rounder_cb)(struct _lv_disp_drv_t * disp_drv, lv_area_t * area);
/** OPTIONAL: Set a pixel in a buffer according to the special requirements of the display /** OPTIONAL: Set a pixel in a buffer according to the special requirements of the display
* Can be used for color format not supported in LittelvGL. E.g. 2 bit -> 4 gray scales * Can be used for color format not supported in LittelvGL. E.g. 2 bit -> 4 gray scales
* @note Much slower then drawing with supported color formats. */ * @note Much slower then drawing with supported color formats. */
void (*set_px_cb)(struct _disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, void (*set_px_cb)(struct _lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,
lv_color_t color, lv_opa_t opa); lv_color_t color, lv_opa_t opa);
/** OPTIONAL: Called after every refresh cycle to tell the rendering and flushing time + the /** OPTIONAL: Called after every refresh cycle to tell the rendering and flushing time + the
* number of flushed pixels */ * number of flushed pixels */
void (*monitor_cb)(struct _disp_drv_t * disp_drv, uint32_t time, uint32_t px); void (*monitor_cb)(struct _lv_disp_drv_t * disp_drv, uint32_t time, uint32_t px);
/** OPTIONAL: Called periodically while lvgl waits for operation to be completed. /** OPTIONAL: Called periodically while lvgl waits for operation to be completed.
* For example flushing or GPU * For example flushing or GPU
* User can execute very simple tasks here or yield the task */ * User can execute very simple tasks here or yield the task */
void (*wait_cb)(struct _disp_drv_t * disp_drv); void (*wait_cb)(struct _lv_disp_drv_t * disp_drv);
/** OPTIONAL: Called when lvgl needs any CPU cache that affects rendering to be cleaned */ /** OPTIONAL: Called when lvgl needs any CPU cache that affects rendering to be cleaned */
void (*clean_dcache_cb)(struct _disp_drv_t * disp_drv); void (*clean_dcache_cb)(struct _lv_disp_drv_t * disp_drv);
/** OPTIONAL: called to wait while the gpu is working */ /** OPTIONAL: called to wait while the gpu is working */
void (*gpu_wait_cb)(struct _disp_drv_t * disp_drv); void (*gpu_wait_cb)(struct _lv_disp_drv_t * disp_drv);
/** OPTIONAL: Fill a memory with a color (GPU only)*/ /** OPTIONAL: Fill a memory with a color (GPU only)*/
void (*gpu_fill_cb)(struct _disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width, void (*gpu_fill_cb)(struct _lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
const lv_area_t * fill_area, lv_color_t color); const lv_area_t * fill_area, lv_color_t color);
/** On CHROMA_KEYED images this color will be transparent. /** On CHROMA_KEYED images this color will be transparent.
@@ -144,27 +145,29 @@ struct _lv_obj_t;
* Display structure. * Display structure.
* @note `lv_disp_drv_t` should be the first member of the structure. * @note `lv_disp_drv_t` should be the first member of the structure.
*/ */
typedef struct _disp_t { typedef struct _lv_disp_t {
/**< Driver to the display*/ /**< Driver to the display*/
lv_disp_drv_t driver; lv_disp_drv_t driver;
/**< A task which periodically checks the dirty areas and refreshes them*/ /**< A task which periodically checks the dirty areas and refreshes them*/
lv_timer_t * read_task; lv_timer_t * refr_timer;
/**< The theme assigned to the screen*/
struct _lv_theme_t * theme;
/** Screens of the display*/ /** Screens of the display*/
struct _lv_obj_t ** screens; /**< Array of screen objects. `NULL` terminated*/ struct _lv_obj_t ** screens; /**< Array of screen objects. */
struct _lv_obj_t * act_scr; /**< Currently active screen on this display */ struct _lv_obj_t * act_scr; /**< Currently active screen on this display */
struct _lv_obj_t * prev_scr; /**< Previous screen. Used during screen animations */ struct _lv_obj_t * prev_scr; /**< Previous screen. Used during screen animations */
struct _lv_obj_t * scr_to_load; /**< The screen prepared to load in lv_scr_load_anim*/ struct _lv_obj_t * scr_to_load; /**< The screen prepared to load in lv_scr_load_anim*/
struct _lv_obj_t * top_layer; /**< @see lv_disp_get_layer_top */ struct _lv_obj_t * top_layer; /**< @see lv_disp_get_layer_top */
struct _lv_obj_t * sys_layer; /**< @see lv_disp_get_layer_sys */ struct _lv_obj_t * sys_layer; /**< @see lv_disp_get_layer_sys */
uint32_t screen_cnt; uint32_t screen_cnt;
uint8_t del_prev : uint8_t del_prev : 1; /**< 1: Automatically delete the previous screen when the screen load animation is ready */
1; /**< 1: Automatically delete the previous screen when the screen load animation is ready */
lv_color_t bg_color; /**< Default display color when screens are transparent*/ lv_color_t bg_color; /**< Default display color when screens are transparent*/
const void * bg_img; /**< An image source to display as wallpaper*/ const void * bg_img; /**< An image source to display as wallpaper*/
lv_opa_t bg_opa; /**<Opacity of the background color or wallpaper */ lv_opa_t bg_opa; /**<Opacity of the background color or wallpaper */
/** Invalidated (marked to redraw) areas*/ /** Invalidated (marked to redraw) areas*/
lv_area_t inv_areas[LV_INV_BUF_SIZE]; lv_area_t inv_areas[LV_INV_BUF_SIZE];

View File

@@ -53,7 +53,7 @@ extern "C" {
**********************/ **********************/
struct _lv_obj_t; struct _lv_obj_t;
struct _disp_t; struct _lv_disp_t;
struct _lv_indev_t; struct _lv_indev_t;
struct _lv_indev_drv_t; struct _lv_indev_drv_t;
@@ -62,14 +62,13 @@ enum {
LV_INDEV_TYPE_NONE, /**< Uninitialized state*/ LV_INDEV_TYPE_NONE, /**< Uninitialized state*/
LV_INDEV_TYPE_POINTER, /**< Touch pad, mouse, external button*/ LV_INDEV_TYPE_POINTER, /**< Touch pad, mouse, external button*/
LV_INDEV_TYPE_KEYPAD, /**< Keypad or keyboard*/ LV_INDEV_TYPE_KEYPAD, /**< Keypad or keyboard*/
LV_INDEV_TYPE_BUTTON, /**< External (hardware button) which is assigned to a specific point of the LV_INDEV_TYPE_BUTTON, /**< External (hardware button) which is assigned to a specific point of the screen*/
screen*/
LV_INDEV_TYPE_ENCODER, /**< Encoder with only Left, Right turn and a Button*/ LV_INDEV_TYPE_ENCODER, /**< Encoder with only Left, Right turn and a Button*/
}; };
typedef uint8_t lv_indev_type_t; typedef uint8_t lv_indev_type_t;
/** States for input devices*/ /** States for input devices*/
enum { LV_INDEV_STATE_REL = 0, LV_INDEV_STATE_PR }; enum { LV_INDEV_STATE_RELEASED = 0, LV_INDEV_STATE_PRESSED };
typedef uint8_t lv_indev_state_t; typedef uint8_t lv_indev_state_t;
enum { enum {
@@ -118,7 +117,7 @@ typedef struct _lv_indev_drv_t {
#endif #endif
/**< Pointer to the assigned display*/ /**< Pointer to the assigned display*/
struct _disp_t * disp; struct _lv_disp_t * disp;
/**< Task to read the periodically read the input device*/ /**< Task to read the periodically read the input device*/
lv_timer_t * read_task; lv_timer_t * read_task;

View File

@@ -246,7 +246,7 @@ lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop)
break; break;
case LV_STYLE_TEXT_FONT: case LV_STYLE_TEXT_FONT:
case LV_STYLE_CONTENT_FONT: case LV_STYLE_CONTENT_FONT:
value.ptr = LV_THEME_FONT_NORMAL; value.ptr = LV_FONT_DEFAULT;
break; break;
case LV_STYLE_SIZE: case LV_STYLE_SIZE:
value.num = 10; value.num = 10;

View File

@@ -199,9 +199,9 @@ typedef enum {
LV_STYLE_TEXT_COLOR = 87 | LV_STYLE_PROP_INHERIT, LV_STYLE_TEXT_COLOR = 87 | LV_STYLE_PROP_INHERIT,
LV_STYLE_TEXT_COLOR_FILTERED = 87 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_FILTER, LV_STYLE_TEXT_COLOR_FILTERED = 87 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_FILTER,
LV_STYLE_TEXT_OPA = 88 | LV_STYLE_PROP_INHERIT, LV_STYLE_TEXT_OPA = 88 | LV_STYLE_PROP_INHERIT,
LV_STYLE_TEXT_FONT = 89 | LV_STYLE_PROP_INHERIT, LV_STYLE_TEXT_FONT = 89 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_LAYOUT_REFR,
LV_STYLE_TEXT_LETTER_SPACE = 90 | LV_STYLE_PROP_INHERIT, LV_STYLE_TEXT_LETTER_SPACE = 90 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_LAYOUT_REFR,
LV_STYLE_TEXT_LINE_SPACE = 91 | LV_STYLE_PROP_INHERIT, LV_STYLE_TEXT_LINE_SPACE = 91 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_LAYOUT_REFR,
LV_STYLE_TEXT_DECOR = 92 | LV_STYLE_PROP_INHERIT, LV_STYLE_TEXT_DECOR = 92 | LV_STYLE_PROP_INHERIT,
LV_STYLE_TEXT_ALIGN = 93 | LV_STYLE_PROP_INHERIT, LV_STYLE_TEXT_ALIGN = 93 | LV_STYLE_PROP_INHERIT,

View File

@@ -198,7 +198,7 @@ void lv_label_set_long_mode(lv_obj_t * obj, lv_label_long_mode_t long_mode)
label->offset.x = 0; label->offset.x = 0;
label->offset.y = 0; label->offset.y = 0;
if(long_mode == LV_LABEL_LONG_SROLL || long_mode == LV_LABEL_LONG_SROLL_CIRC || long_mode == LV_LABEL_LONG_CLIP) if(long_mode == LV_LABEL_LONG_SCROLL || long_mode == LV_LABEL_LONG_SCROLL_CIRCULAR || long_mode == LV_LABEL_LONG_CLIP)
label->expand = 1; label->expand = 1;
else else
label->expand = 0; label->expand = 0;
@@ -777,7 +777,7 @@ static lv_draw_res_t lv_label_draw(lv_obj_t * obj, const lv_area_t * clip_area,
/* In SROLL and SROLL_CIRC mode the CENTER and RIGHT are pointless so remove them. /* In SROLL and SROLL_CIRC mode the CENTER and RIGHT are pointless so remove them.
* (In addition they will result misalignment is this case)*/ * (In addition they will result misalignment is this case)*/
if((label->long_mode == LV_LABEL_LONG_SROLL || label->long_mode == LV_LABEL_LONG_SROLL_CIRC) && if((label->long_mode == LV_LABEL_LONG_SCROLL || label->long_mode == LV_LABEL_LONG_SCROLL_CIRCULAR) &&
(align == LV_TEXT_ALIGN_CENTER || align == LV_TEXT_ALIGN_RIGHT)) { (align == LV_TEXT_ALIGN_CENTER || align == LV_TEXT_ALIGN_RIGHT)) {
lv_point_t size; lv_point_t size;
lv_txt_get_size(&size, label->text, label_draw_dsc.font, label_draw_dsc.letter_space, label_draw_dsc.line_space, lv_txt_get_size(&size, label->text, label_draw_dsc.font, label_draw_dsc.letter_space, label_draw_dsc.line_space,
@@ -788,7 +788,7 @@ static lv_draw_res_t lv_label_draw(lv_obj_t * obj, const lv_area_t * clip_area,
} }
#if LV_LABEL_LONG_TXT_HINT #if LV_LABEL_LONG_TXT_HINT
lv_draw_label_hint_t * hint = &label->hint; lv_draw_label_hint_t * hint = &label->hint;
if(label->long_mode == LV_LABEL_LONG_SROLL_CIRC || lv_area_get_height(&txt_coords) < LV_LABEL_HINT_HEIGHT_LIMIT) if(label->long_mode == LV_LABEL_LONG_SCROLL_CIRCULAR || lv_area_get_height(&txt_coords) < LV_LABEL_HINT_HEIGHT_LIMIT)
hint = NULL; hint = NULL;
#else #else
@@ -798,7 +798,7 @@ static lv_draw_res_t lv_label_draw(lv_obj_t * obj, const lv_area_t * clip_area,
lv_draw_label(&txt_coords, &txt_clip, &label_draw_dsc, label->text, hint); lv_draw_label(&txt_coords, &txt_clip, &label_draw_dsc, label->text, hint);
if(label->long_mode == LV_LABEL_LONG_SROLL_CIRC) { if(label->long_mode == LV_LABEL_LONG_SCROLL_CIRCULAR) {
lv_point_t size; lv_point_t size;
lv_txt_get_size(&size, label->text, label_draw_dsc.font, label_draw_dsc.letter_space, label_draw_dsc.line_space, lv_txt_get_size(&size, label->text, label_draw_dsc.font, label_draw_dsc.letter_space, label_draw_dsc.line_space,
LV_COORD_MAX, flag); LV_COORD_MAX, flag);
@@ -899,7 +899,7 @@ static void lv_label_refr_text(lv_obj_t * obj)
lv_obj_set_size(obj, size.x, size.y); lv_obj_set_size(obj, size.x, size.y);
} }
/*In roll mode keep the size but start offset animations*/ /*In roll mode keep the size but start offset animations*/
else if(label->long_mode == LV_LABEL_LONG_SROLL) { else if(label->long_mode == LV_LABEL_LONG_SCROLL) {
uint16_t anim_speed = lv_obj_get_style_anim_time(obj, LV_PART_MAIN); uint16_t anim_speed = lv_obj_get_style_anim_time(obj, LV_PART_MAIN);
if(anim_speed == 0) anim_speed = LV_LABEL_DEF_SCROLL_SPEED; if(anim_speed == 0) anim_speed = LV_LABEL_DEF_SCROLL_SPEED;
lv_anim_t a; lv_anim_t a;
@@ -982,7 +982,7 @@ static void lv_label_refr_text(lv_obj_t * obj)
} }
} }
/*In roll inf. mode keep the size but start offset animations*/ /*In roll inf. mode keep the size but start offset animations*/
else if(label->long_mode == LV_LABEL_LONG_SROLL_CIRC) { else if(label->long_mode == LV_LABEL_LONG_SCROLL_CIRCULAR) {
uint16_t anim_speed = lv_obj_get_style_anim_time(obj, LV_PART_MAIN); uint16_t anim_speed = lv_obj_get_style_anim_time(obj, LV_PART_MAIN);
if(anim_speed == 0) anim_speed = LV_LABEL_DEF_SCROLL_SPEED; if(anim_speed == 0) anim_speed = LV_LABEL_DEF_SCROLL_SPEED;
lv_anim_t a; lv_anim_t a;

View File

@@ -42,12 +42,12 @@ LV_EXPORT_CONST_INT(LV_LABEL_TEXT_SEL_OFF);
/** Long mode behaviors. Used in 'lv_label_ext_t' */ /** Long mode behaviors. Used in 'lv_label_ext_t' */
enum { enum {
LV_LABEL_LONG_EXPAND, /**< Expand the object size to the text size*/ LV_LABEL_LONG_EXPAND, /**< Expand the object size to the text size*/
LV_LABEL_LONG_WRAP, /**< Keep the object width, wrap the too long lines and expand the object height*/ LV_LABEL_LONG_WRAP, /**< Keep the object width, wrap the too long lines and expand the object height*/
LV_LABEL_LONG_DOT, /**< Keep the size and write dots at the end if the text is too long*/ LV_LABEL_LONG_DOT, /**< Keep the size and write dots at the end if the text is too long*/
LV_LABEL_LONG_SROLL, /**< Keep the size and roll the text back and forth*/ LV_LABEL_LONG_SCROLL, /**< Keep the size and roll the text back and forth*/
LV_LABEL_LONG_SROLL_CIRC, /**< Keep the size and roll the text circularly*/ LV_LABEL_LONG_SCROLL_CIRCULAR, /**< Keep the size and roll the text circularly*/
LV_LABEL_LONG_CLIP, /**< Keep the size and clip the text out of it*/ LV_LABEL_LONG_CLIP, /**< Keep the size and clip the text out of it*/
}; };
typedef uint8_t lv_label_long_mode_t; typedef uint8_t lv_label_long_mode_t;

View File

@@ -87,6 +87,7 @@ static void lv_slider_constructor(lv_obj_t * obj, const lv_obj_t * copy)
/*Init the new slider slider*/ /*Init the new slider slider*/
if(copy == NULL) { if(copy == NULL) {
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLL_CHAIN); lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLL_CHAIN);
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_set_ext_click_area(obj, lv_dpx(5)); lv_obj_set_ext_click_area(obj, lv_dpx(5));
lv_obj_set_height(obj, LV_DPI_DEF / 15); lv_obj_set_height(obj, LV_DPI_DEF / 15);

View File

@@ -78,6 +78,7 @@ static void lv_switch_constructor(lv_obj_t * obj, const lv_obj_t * copy)
if(copy == NULL) { if(copy == NULL) {
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
lv_obj_add_flag(obj, LV_OBJ_FLAG_CHECKABLE); lv_obj_add_flag(obj, LV_OBJ_FLAG_CHECKABLE);
lv_obj_set_size(obj, LV_DPX(60), LV_DPX(35)); lv_obj_set_size(obj, LV_DPX(60), LV_DPX(35));
} }