api(style) add lv_style_selector_t instead of lv_part_t and lv_state_t in style API

This commit is contained in:
Gabor Kiss-Vamosi
2021-03-31 19:57:14 +02:00
parent 0527874f8d
commit 663bcfd030
63 changed files with 763 additions and 734 deletions
@@ -40,9 +40,9 @@ void lv_example_get_started_2(void)
lv_obj_t * btn = lv_btn_create(lv_scr_act()); /*Add a button the current screen*/
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
lv_obj_set_size(btn, 120, 50); /*Set its size*/
lv_obj_remove_style(btn, LV_PART_ANY, LV_STATE_ANY, NULL); /*Remove the styles coming from the theme*/
lv_obj_add_style(btn, LV_PART_MAIN, LV_STATE_DEFAULT, &style_btn);
lv_obj_add_style(btn, LV_PART_MAIN, LV_STATE_PRESSED, &style_btn_pressed);
lv_obj_remove_style_all(btn); /*Remove the styles coming from the theme*/
lv_obj_add_style(btn, &style_btn, 0);
lv_obj_add_style(btn, &style_btn_pressed, LV_STATE_PRESSED);
lv_obj_t * label = lv_label_create(btn); /*Add a label to the button*/
lv_label_set_text(label, "Button"); /*Set the labels text*/
@@ -52,11 +52,11 @@ void lv_example_get_started_2(void)
lv_obj_t * btn2 = lv_btn_create(lv_scr_act());
lv_obj_set_pos(btn2, 10, 80);
lv_obj_set_size(btn2, 120, 50); /*Set its size*/
lv_obj_remove_style(btn2, LV_PART_ANY, LV_STATE_ANY, NULL); /*Remove the styles coming from the theme*/
lv_obj_add_style(btn2, LV_PART_MAIN, LV_STATE_DEFAULT, &style_btn);
lv_obj_add_style(btn2, LV_PART_MAIN, LV_STATE_DEFAULT, &style_btn_red);
lv_obj_add_style(btn2, LV_PART_MAIN, LV_STATE_PRESSED, &style_btn_pressed);
lv_obj_set_style_radius(btn2, LV_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); /*Add a local style*/
lv_obj_remove_style_all(btn2); /*Remove the styles coming from the theme*/
lv_obj_add_style(btn2, &style_btn, 0);
lv_obj_add_style(btn2, &style_btn_red, 0);
lv_obj_add_style(btn2, &style_btn_pressed, LV_STATE_PRESSED);
lv_obj_set_style_radius(btn2, LV_RADIUS_CIRCLE, 0); /*Add a local style*/
label = lv_label_create(btn2); /*Add a label to the button*/
lv_label_set_text(label, "Button 2"); /*Set the labels text*/
+1 -1
View File
@@ -15,7 +15,7 @@ void lv_example_flex_2(void)
lv_obj_t * cont = lv_obj_create(lv_scr_act());
lv_obj_set_size(cont, 300, 220);
lv_obj_center(cont);
lv_obj_add_style(cont, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_add_style(cont, &style, 0);
uint32_t i;
for(i = 0; i < 8; i++) {
+2 -2
View File
@@ -3,12 +3,12 @@
static void row_gap_anim(void * obj, int32_t v)
{
lv_obj_set_style_pad_row(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v);
lv_obj_set_style_pad_row(obj, v, 0);
}
static void column_gap_anim(void * obj, int32_t v)
{
lv_obj_set_style_pad_column(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v);
lv_obj_set_style_pad_column(obj, v, 0);
}
/**
+2 -2
View File
@@ -11,8 +11,8 @@ void lv_example_grid_1(void)
/*Create a container with grid*/
lv_obj_t * cont = lv_obj_create(lv_scr_act());
lv_obj_set_style_grid_column_template(cont, LV_PART_MAIN, LV_STATE_DEFAULT, col_dsc);
lv_obj_set_style_grid_row_template(cont, LV_PART_MAIN, LV_STATE_DEFAULT, row_dsc);
lv_obj_set_style_grid_column_template(cont, col_dsc, 0);
lv_obj_set_style_grid_row_template(cont, row_dsc, 0);
lv_obj_set_size(cont, 300, 220);
lv_obj_center(cont);
lv_obj_set_layout(cont, LV_LAYOUT_GRID);
+2 -2
View File
@@ -3,12 +3,12 @@
static void row_gap_anim(void * obj, int32_t v)
{
lv_obj_set_style_pad_row(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v);
lv_obj_set_style_pad_row(obj, v, 0);
}
static void column_gap_anim(void * obj, int32_t v)
{
lv_obj_set_style_pad_column(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v);
lv_obj_set_style_pad_column(obj, v, 0);
}
/**
+3 -3
View File
@@ -38,9 +38,9 @@ void lv_example_scroll_3(void)
lv_obj_add_flag(float_btn, LV_OBJ_FLAG_FLOATING);
lv_obj_align(float_btn, LV_ALIGN_BOTTOM_RIGHT, 0, -lv_obj_get_style_pad_right(list, LV_PART_MAIN));
lv_obj_add_event_cb(float_btn, float_btn_event_cb, list);
lv_obj_set_style_radius(float_btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
lv_obj_set_style_bg_img_src(float_btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_PLUS);
lv_obj_set_style_text_font(float_btn, LV_PART_MAIN, LV_STATE_DEFAULT, lv_theme_get_font_large(float_btn));
lv_obj_set_style_radius(float_btn, LV_RADIUS_CIRCLE, 0);
lv_obj_set_style_bg_img_src(float_btn, LV_SYMBOL_PLUS, 0);
lv_obj_set_style_text_font(float_btn, lv_theme_get_font_large(float_btn), 0);
}
#endif
+1 -1
View File
@@ -22,7 +22,7 @@ void lv_example_style_1(void)
/*Create an object with the new style*/
lv_obj_t * obj = lv_obj_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_add_style(obj, &style, 0);
lv_obj_center(obj);
}
+1 -1
View File
@@ -15,7 +15,7 @@ void lv_example_style_11(void)
/*Create an object with the new style*/
lv_obj_t * obj = lv_arc_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_add_style(obj, &style, 0);
lv_obj_center(obj);
}
#endif
+1 -1
View File
@@ -22,7 +22,7 @@ void lv_example_style_2(void)
/*Create an object with the new style*/
lv_obj_t * obj = lv_obj_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_add_style(obj, &style, 0);
lv_obj_center(obj);
}
+1 -1
View File
@@ -21,7 +21,7 @@ void lv_example_style_3(void)
/*Create an object with the new style*/
lv_obj_t * obj = lv_obj_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_add_style(obj, &style, 0);
lv_obj_center(obj);
}
+1 -1
View File
@@ -22,7 +22,7 @@ void lv_example_style_4(void)
/*Create an object with the new style*/
lv_obj_t * obj = lv_obj_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_add_style(obj, &style, 0);
lv_obj_center(obj);
}
+1 -1
View File
@@ -23,7 +23,7 @@ void lv_example_style_7(void)
/*Create an object with the new style*/
lv_obj_t * obj = lv_label_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_add_style(obj, &style, 0);
lv_label_set_text(obj, "Text of\n"
"a label");
+1 -1
View File
@@ -15,7 +15,7 @@ void lv_example_style_8(void)
/*Create an object with the new style*/
lv_obj_t * obj = lv_line_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_add_style(obj, &style, 0);
static lv_point_t p[] = {{10, 30}, {30, 50}, {100, 0}};
lv_line_set_points(obj, p, 3);
+1 -1
View File
@@ -22,7 +22,7 @@ void lv_example_style_9(void)
/*Create an object with the new style*/
lv_obj_t * obj = lv_img_create(lv_scr_act());
lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_add_style(obj, &style, 0);
LV_IMG_DECLARE(img_cogwheel_argb);
lv_img_set_src(obj, &img_cogwheel_argb);
+3 -3
View File
@@ -22,9 +22,9 @@ void lv_example_bar_2(void)
lv_style_set_radius(&style_indic, 3);
lv_obj_t * bar = lv_bar_create(lv_scr_act());
lv_obj_remove_style(bar, LV_PART_ANY, LV_STATE_ANY, NULL); /*To have a clean start*/
lv_obj_add_style(bar, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
lv_obj_add_style(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, &style_indic);
lv_obj_remove_style_all(bar); /*To have a clean start*/
lv_obj_add_style(bar, &style_bg, 0);
lv_obj_add_style(bar, &style_indic, LV_PART_INDICATOR);
lv_obj_set_size(bar, 200, 20);
lv_obj_center(bar);
+1 -1
View File
@@ -27,7 +27,7 @@ void lv_example_bar_3(void)
// lv_style_set_content_color(&style_indic, lv_color_grey());
lv_obj_t * bar = lv_bar_create(lv_scr_act());
lv_obj_add_style(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, &style_indic);
lv_obj_add_style(bar, &style_indic, LV_PART_INDICATOR);
lv_obj_set_size(bar, 20, 200);
lv_obj_center(bar);
lv_bar_set_range(bar, -20, 40);
+1 -1
View File
@@ -15,7 +15,7 @@ void lv_example_bar_4(void)
lv_style_set_bg_img_opa(&style_indic, LV_OPA_30);
lv_obj_t * bar = lv_bar_create(lv_scr_act());
lv_obj_add_style(bar, LV_PART_INDICATOR, LV_STATE_DEFAULT, &style_indic);
lv_obj_add_style(bar, &style_indic, LV_PART_INDICATOR);
lv_obj_set_size(bar, 260, 20);
lv_obj_center(bar);
+4 -4
View File
@@ -10,16 +10,16 @@ void lv_example_bar_5(void)
lv_obj_set_size(bar_ltr, 200, 20);
lv_bar_set_value(bar_ltr, 70, LV_ANIM_OFF);
lv_obj_align(bar_ltr, LV_ALIGN_CENTER, 0, -30);
// lv_obj_add_style(bar_ltr, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
// lv_obj_set_style_content_text(bar_ltr, LV_PART_MAIN, LV_STATE_DEFAULT, "Left to Right base direction");
// lv_obj_add_style(bar_ltr, &style_bg);
// lv_obj_set_style_content_text(bar_ltr, "Left to Right base direction");
lv_obj_t * bar_rtl = lv_bar_create(lv_scr_act());
lv_obj_set_base_dir(bar_rtl, LV_BIDI_DIR_RTL);
lv_obj_set_size(bar_rtl, 200, 20);
lv_bar_set_value(bar_rtl, 70, LV_ANIM_OFF);
lv_obj_align(bar_rtl, LV_ALIGN_CENTER, 0, 30);
// lv_obj_add_style(bar_rtl, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
// lv_obj_set_style_content_text(bar_rtl, LV_PART_MAIN, LV_STATE_DEFAULT, "Right to Left base direction");
// lv_obj_add_style(bar_rtl, &style_bg);
// lv_obj_set_style_content_text(bar_rtl, "Right to Left base direction");
}
#endif
+2 -2
View File
@@ -51,8 +51,8 @@ void lv_example_btn_2(void)
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
// lv_obj_remove_style(btn1, LV_PART_ANY, LV_STATE_ANY, NULL);
lv_obj_add_style(btn1, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_add_style(btn1, LV_PART_MAIN, LV_STATE_PRESSED, &style_pr);
lv_obj_add_style(btn1, &style, 0);
lv_obj_add_style(btn1, &style_pr, LV_STATE_PRESSED);
lv_obj_set_size(btn1, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_center(btn1);
+2 -2
View File
@@ -47,8 +47,8 @@ void lv_example_btn_3(void)
lv_obj_t * btn1 = lv_btn_create(lv_scr_act());
lv_obj_align(btn1, LV_ALIGN_CENTER, 0, -80);
lv_obj_add_style(btn1, LV_PART_MAIN, LV_STATE_PRESSED, &style_pr);
lv_obj_add_style(btn1, LV_PART_MAIN, LV_STATE_DEFAULT, &style_def);
lv_obj_add_style(btn1, &style_pr, LV_STATE_PRESSED);
lv_obj_add_style(btn1, &style_def, 0);
lv_obj_t * label = lv_label_create(btn1);
lv_label_set_text(label, "Gum");
@@ -49,8 +49,8 @@ void lv_example_btnmatrix_3(void)
lv_obj_t * btnm = lv_btnmatrix_create(lv_scr_act());
lv_btnmatrix_set_map(btnm, map);
lv_obj_add_style(btnm, LV_PART_MAIN, LV_STATE_DEFAULT, &style_bg);
lv_obj_add_style(btnm, LV_PART_ITEMS, LV_STATE_DEFAULT, &style_btn);
lv_obj_add_style(btnm, &style_bg, 0);
lv_obj_add_style(btnm, &style_btn, LV_PART_ITEMS);
lv_obj_add_event_cb(btnm, event_cb, NULL);
lv_obj_set_size(btnm, 225, 35);
+1 -1
View File
@@ -75,7 +75,7 @@ void lv_example_chart_5(void)
lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_Y, -1000, 1000);
/*Do not display points on the data*/
lv_obj_set_style_size(chart, LV_PART_ITEMS, LV_STATE_DEFAULT, 0);
lv_obj_set_style_size(chart, 0, LV_PART_ITEMS);
lv_chart_series_t * ser = lv_chart_add_series(chart, lv_color_red(), LV_CHART_AXIS_PRIMARY_Y);
@@ -31,7 +31,7 @@ void lv_example_dropdown_3(void)
/*Use a custom image as down icon and flip it when the list is opened*/
LV_IMG_DECLARE(img_caret_down)
lv_dropdown_set_symbol(dropdown, &img_caret_down);
lv_obj_set_style_transform_angle(dropdown, LV_PART_MAIN, LV_STATE_CHECKED, 1800);
lv_obj_set_style_transform_angle(dropdown, 1800, LV_STATE_CHECKED);
/*In a menu we don't need to show the last clicked item*/
lv_dropdown_set_selected_highlight(dropdown, false);
+4 -5
View File
@@ -46,8 +46,8 @@ static void slider_event_cb(lv_obj_t * slider, lv_event_t event)
/*Recolor the image based on the sliders' values*/
lv_color_t color = lv_color_make(lv_slider_get_value(red_slider), lv_slider_get_value(green_slider), lv_slider_get_value(blue_slider));
lv_opa_t intense = lv_slider_get_value(intense_slider);
lv_obj_set_style_img_recolor_opa(img1, LV_PART_MAIN, LV_STATE_DEFAULT, intense);
lv_obj_set_style_img_recolor(img1, LV_PART_MAIN, LV_STATE_DEFAULT, color);
lv_obj_set_style_img_recolor_opa(img1, intense, 0);
lv_obj_set_style_img_recolor(img1, color, 0);
}
}
@@ -56,11 +56,10 @@ static lv_obj_t * create_slider(lv_color_t color)
lv_obj_t * slider = lv_slider_create(lv_scr_act());
lv_slider_set_range(slider, 0, 255);
lv_obj_set_size(slider, 10, 200);
lv_obj_set_style_bg_color(slider, LV_PART_KNOB, LV_STATE_DEFAULT, color);
lv_obj_set_style_bg_color(slider, LV_PART_INDICATOR, LV_STATE_DEFAULT, lv_color_darken(color, LV_OPA_40));
lv_obj_set_style_bg_color(slider, color, LV_PART_KNOB);
lv_obj_set_style_bg_color(slider, lv_color_darken(color, LV_OPA_40), LV_PART_INDICATOR);
lv_obj_add_event_cb(slider, slider_event_cb, NULL);
return slider;
}
#endif
+1 -1
View File
@@ -21,7 +21,7 @@ void lv_example_img_4(void)
lv_style_set_img_recolor(&style, lv_color_black());
lv_obj_t * img = lv_img_create(lv_scr_act());
lv_obj_add_style(img, LV_PART_MAIN, LV_STATE_DEFAULT, &style);
lv_obj_add_style(img, &style, 0);
lv_img_set_src(img, &img_skew_strip);
lv_obj_set_size(img, 150, 100);
lv_obj_center(img);
@@ -27,8 +27,8 @@ void lv_example_imgbtn_1(void)
/*Create an image button*/
lv_obj_t * imgbtn1 = lv_imgbtn_create(lv_scr_act());
lv_imgbtn_set_src(imgbtn1, LV_IMGBTN_STATE_RELEASED, &imgbtn_left, &imgbtn_mid, &imgbtn_right);
lv_obj_add_style(imgbtn1, LV_PART_MAIN, LV_STATE_DEFAULT, &style_def);
lv_obj_add_style(imgbtn1, LV_PART_MAIN, LV_STATE_PRESSED, &style_pr);
lv_obj_add_style(imgbtn1, &style_def, 0);
lv_obj_add_style(imgbtn1, &style_pr, LV_STATE_PRESSED);
lv_obj_align(imgbtn1, LV_ALIGN_CENTER, 0, 0);
+1 -1
View File
@@ -12,7 +12,7 @@ void lv_example_label_1(void)
lv_label_set_text(label1, "#0000ff Re-color# #ff00ff words# #ff0000 of a# label, align the lines to the center"
"and wrap long text automatically.");
lv_obj_set_width(label1, 150); /*Set smaller width to make the lines wrap*/
lv_obj_set_style_text_align(label1, LV_PART_MAIN, LV_STATE_DEFAULT, LV_TEXT_ALIGN_CENTER);
lv_obj_set_style_text_align(label1, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_align(label1, LV_ALIGN_CENTER, 0, -40);
+1 -1
View File
@@ -14,7 +14,7 @@ void lv_example_label_2(void)
/*Create a label for the shadow first (it's in the background)*/
lv_obj_t * shadow_label = lv_label_create(lv_scr_act());
lv_obj_add_style(shadow_label, LV_PART_MAIN, LV_STATE_DEFAULT, &style_shadow);
lv_obj_add_style(shadow_label, &style_shadow, 0);
/*Create the main label*/
lv_obj_t * main_label = lv_label_create(lv_scr_act());
+1 -1
View File
@@ -17,7 +17,7 @@ void lv_example_line_1(void)
lv_obj_t * line1;
line1 = lv_line_create(lv_scr_act());
lv_line_set_points(line1, line_points, 5); /*Set the points*/
lv_obj_add_style(line1, LV_PART_MAIN, LV_STATE_DEFAULT, &style_line); /*Set the points*/
lv_obj_add_style(line1, &style_line, 0);
lv_obj_center(line1);
}
+1 -1
View File
@@ -18,7 +18,7 @@ void lv_example_meter_2(void)
lv_obj_center(meter);
/*Remove the circle from the middle*/
lv_obj_remove_style(meter, LV_PART_INDICATOR, LV_STATE_ANY, NULL);
lv_obj_remove_style(meter, NULL, LV_PART_INDICATOR);
/*Add a scale first*/
lv_meter_scale_t * scale = lv_meter_add_scale(meter);
+2 -2
View File
@@ -10,8 +10,8 @@ void lv_example_meter_4(void)
lv_obj_center(meter);
/*Remove the background and the circle from the middle*/
lv_obj_remove_style(meter, LV_PART_MAIN, LV_STATE_ANY, NULL);
lv_obj_remove_style(meter, LV_PART_INDICATOR, LV_STATE_ANY, NULL);
lv_obj_remove_style(meter, NULL, LV_PART_MAIN);
lv_obj_remove_style(meter, NULL, LV_PART_INDICATOR);
/*Add a scale first with no ticks.*/
lv_meter_scale_t * scale = lv_meter_add_scale(meter);
+1 -1
View File
@@ -16,7 +16,7 @@ void lv_example_obj_1(void)
lv_obj_t * obj3;
obj3 = lv_obj_create(lv_scr_act());
lv_obj_add_style(obj3, LV_PART_MAIN, LV_STATE_DEFAULT, &style_shadow);
lv_obj_add_style(obj3, &style_shadow, 0);
lv_obj_align(obj3, LV_ALIGN_CENTER, 60, 30);
}
#endif
@@ -28,8 +28,8 @@ void lv_example_roller_2(void)
lv_roller_set_options(roller, opts, LV_ROLLER_MODE_NORMAL);
lv_roller_set_visible_row_count(roller, 2);
lv_obj_set_width(roller, 100);
lv_obj_add_style(roller, LV_PART_SELECTED, LV_STATE_DEFAULT, &style_sel);
lv_obj_set_style_text_align(roller, LV_PART_MAIN, LV_STATE_DEFAULT, LV_TEXT_ALIGN_LEFT);
lv_obj_add_style(roller, &style_sel, LV_PART_SELECTED);
lv_obj_set_style_text_align(roller, LV_TEXT_ALIGN_LEFT, 0);
lv_obj_align(roller, LV_ALIGN_LEFT_MID, 10, 0);
lv_obj_add_event_cb(roller, event_handler, NULL);
lv_roller_set_selected(roller, 2, LV_ANIM_OFF);
@@ -38,7 +38,7 @@ void lv_example_roller_2(void)
roller = lv_roller_create(lv_scr_act());
lv_roller_set_options(roller, opts, LV_ROLLER_MODE_NORMAL);
lv_roller_set_visible_row_count(roller, 3);
lv_obj_add_style(roller, LV_PART_SELECTED, LV_STATE_DEFAULT, &style_sel);
lv_obj_add_style(roller, &style_sel, LV_PART_SELECTED);
lv_obj_align(roller, LV_ALIGN_CENTER, 0, 0);
lv_obj_add_event_cb(roller, event_handler, NULL);
lv_roller_set_selected(roller, 5, LV_ANIM_OFF);
@@ -48,8 +48,8 @@ void lv_example_roller_2(void)
lv_roller_set_options(roller, opts, LV_ROLLER_MODE_NORMAL);
lv_roller_set_visible_row_count(roller, 4);
lv_obj_set_width(roller, 80);
lv_obj_add_style(roller, LV_PART_SELECTED, LV_STATE_DEFAULT, &style_sel);
lv_obj_set_style_text_align(roller, LV_PART_MAIN, LV_STATE_DEFAULT, LV_TEXT_ALIGN_RIGHT);
lv_obj_add_style(roller, &style_sel, LV_PART_SELECTED);
lv_obj_set_style_text_align(roller, LV_TEXT_ALIGN_RIGHT, 0);
lv_obj_align(roller, LV_ALIGN_RIGHT_MID, -10, 0);
lv_obj_add_event_cb(roller, event_handler, NULL);
lv_roller_set_selected(roller, 8, LV_ANIM_OFF);
@@ -35,13 +35,13 @@ void lv_example_spinbox_1(void)
lv_obj_t * btn = lv_btn_create(lv_scr_act());
lv_obj_set_size(btn, h, h);
lv_obj_align_to(btn, spinbox, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
lv_obj_set_style_bg_img_src(btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_PLUS);
lv_obj_set_style_bg_img_src(btn, LV_SYMBOL_PLUS, 0);
lv_obj_add_event_cb(btn, lv_spinbox_increment_event_cb, NULL);
btn = lv_btn_create(lv_scr_act());
lv_obj_set_size(btn, h, h);
lv_obj_align_to(btn, spinbox, LV_ALIGN_OUT_LEFT_MID, -5, 0);
lv_obj_set_style_bg_img_src(btn, LV_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_MINUS);
lv_obj_set_style_bg_img_src(btn, LV_SYMBOL_MINUS, 0);
lv_obj_add_event_cb(btn, lv_spinbox_decrement_event_cb, NULL);
}
+1 -1
View File
@@ -68,7 +68,7 @@ void lv_example_table_2(void)
lv_table_set_col_cnt(table, 1);
/*Don't make the cell pressed, we will draw something different in the event*/
lv_obj_remove_style(table, LV_PART_ITEMS, LV_STATE_PRESSED, NULL);
lv_obj_remove_style(table, NULL, LV_PART_ITEMS | LV_STATE_PRESSED);
uint32_t i;
for(i = 0; i < ITEM_CNT; i++) {
+2 -2
View File
@@ -116,12 +116,12 @@ def style_set(p):
def local_style_set(p):
func_cast = get_func_cast(p['style_type'])
print("static inline void lv_obj_set_style_" + p['name'].lower() + "(struct _lv_obj_t * obj, uint32_t part, uint32_t state, " + p['var_type'] +" value)")
print("static inline void lv_obj_set_style_" + p['name'].lower() + "(struct _lv_obj_t * obj, " + p['var_type'] +" value, lv_style_selector_t selector)")
print("{")
print(" lv_style_value_t v = {")
print(" ." + p['style_type'] +" = " + func_cast + "value")
print(" };")
print(" lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_" + p['name'] +", v);")
print(" lv_obj_set_local_style_prop(obj, LV_STYLE_" + p['name'] +", v, selector);")
print("}")
print("")
+5 -5
View File
@@ -226,7 +226,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_anim_del(d->scr_to_load, NULL);
lv_obj_set_pos(d->scr_to_load, 0, 0);
lv_obj_remove_local_style_prop(d->scr_to_load, LV_PART_MAIN, LV_STATE_DEFAULT, LV_STYLE_OPA);
lv_obj_remove_local_style_prop(d->scr_to_load, LV_STYLE_OPA, 0);
act_scr = d->scr_to_load;
}
@@ -247,8 +247,8 @@ void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t
/*Be sure both screens are in a normal position*/
lv_obj_set_pos(new_scr, 0, 0);
lv_obj_set_pos(lv_scr_act(), 0, 0);
lv_obj_remove_local_style_prop(new_scr, LV_PART_MAIN, LV_STATE_DEFAULT, LV_STYLE_OPA);
lv_obj_remove_local_style_prop(lv_scr_act(), LV_PART_MAIN, LV_STATE_DEFAULT, LV_STYLE_OPA);
lv_obj_remove_local_style_prop(new_scr, LV_STYLE_OPA, 0);
lv_obj_remove_local_style_prop(lv_scr_act(), LV_STYLE_OPA, 0);
lv_anim_t a_new;
lv_anim_init(&a_new);
@@ -408,7 +408,7 @@ static void scr_load_anim_start(lv_anim_t * a)
static void opa_scale_anim(void * obj, int32_t v)
{
lv_obj_set_style_opa(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v);
lv_obj_set_style_opa(obj, v, 0);
}
static void set_x_anim(void * obj, int32_t v)
@@ -428,5 +428,5 @@ static void scr_anim_ready(lv_anim_t * a)
if(d->prev_scr && d->del_prev) lv_obj_del(d->prev_scr);
d->prev_scr = NULL;
d->scr_to_load = NULL;
lv_obj_remove_local_style_prop(a->var, LV_PART_MAIN, LV_STATE_DEFAULT, LV_STYLE_OPA);
lv_obj_remove_local_style_prop(a->var, LV_STYLE_OPA, 0);
}
+8 -7
View File
@@ -51,8 +51,7 @@ typedef struct _lv_event_temp_data {
typedef struct {
uint16_t time;
uint16_t delay;
lv_part_t part;
lv_state_t state;
lv_style_selector_t selector;
lv_style_prop_t prop;
const lv_anim_path_t * path;
}trans_set_t;
@@ -990,7 +989,8 @@ static void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
uint32_t i;
for(i = 0; i < obj->style_cnt && tsi < STYLE_TRANSITION_MAX; i++) {
lv_obj_style_t * obj_style = &obj->styles[i];
if(obj_style->state & (~new_state)) continue; /*Skip unrelated styles*/
lv_state_t state_act = lv_obj_style_get_selector_state(obj->styles[i].selector);
if(state_act & (~new_state)) continue; /*Skip unrelated styles*/
if(obj_style->is_trans) continue;
lv_style_value_t v;
@@ -1002,7 +1002,8 @@ static void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
for(j = 0; tr->props[j] != 0 && tsi < STYLE_TRANSITION_MAX; j++) {
uint32_t t;
for(t = 0; t < tsi; t++) {
if(ts[t].prop == tr->props[j] && ts[t].state >= obj_style->state) break;
lv_state_t state_tr = lv_obj_style_get_selector_state(ts[t].selector);
if(ts[t].prop == tr->props[j] && state_tr >= state_act) break;
}
/*If not found add it*/
@@ -1011,15 +1012,15 @@ static void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
ts[tsi].delay = tr->delay;
ts[tsi].path = tr->path;
ts[tsi].prop = tr->props[j];
ts[tsi].part = obj_style->part;
ts[tsi].state = obj_style->state;
ts[tsi].selector = obj_style->selector;
tsi++;
}
}
}
for(i = 0;i < tsi; i++) {
_lv_obj_style_create_transition(obj, ts[i].prop, ts[i].part, prev_state, new_state, ts[i].time, ts[i].delay, ts[i].path);
lv_part_t part_act = lv_obj_style_get_selector_part(ts[i].selector);
_lv_obj_style_create_transition(obj, ts[i].prop, part_act, prev_state, new_state, ts[i].time, ts[i].delay, ts[i].path);
}
lv_mem_buf_release(ts);
+11 -18
View File
@@ -138,28 +138,21 @@ typedef uint16_t lv_state_t;
* Note every part is used by every widget
*/
enum {
LV_PART_MAIN, /**< A background like rectangle*/
LV_PART_SCROLLBAR, /**< The scrollbar(s)*/
LV_PART_INDICATOR, /**< Indicator, e.g. for slider, bar, switch, or the tick box of the checkbox*/
LV_PART_KNOB, /**< Like handle to grab to adjust the value*/
LV_PART_SELECTED, /**< Indicate the currently selected option or section*/
LV_PART_ITEMS, /**< Used if the widget has multiple similar elements (e.g. tabel cells)*/
LV_PART_TICKS, /**< Ticks on scale e.g. for a chart or meter*/
LV_PART_CURSOR, /**< Mark a specific place e.g. for text area's cursor or on a chart*/
LV_PART_MAIN = 0x000000, /**< A background like rectangle*/
LV_PART_SCROLLBAR = 0x010000, /**< The scrollbar(s)*/
LV_PART_INDICATOR = 0x020000, /**< Indicator, e.g. for slider, bar, switch, or the tick box of the checkbox*/
LV_PART_KNOB = 0x030000, /**< Like handle to grab to adjust the value*/
LV_PART_SELECTED = 0x040000, /**< Indicate the currently selected option or section*/
LV_PART_ITEMS = 0x050000, /**< Used if the widget has multiple similar elements (e.g. tabel cells)*/
LV_PART_TICKS = 0x060000, /**< Ticks on scale e.g. for a chart or meter*/
LV_PART_CURSOR = 0x070000, /**< Mark a specific place e.g. for text area's cursor or on a chart*/
LV_PART_CUSTOM_1 = 0x40, /**< Extension point for custom widgets*/
LV_PART_CUSTOM_2, /**< Extension point for custom widgets*/
LV_PART_CUSTOM_3, /**< Extension point for custom widgets*/
LV_PART_CUSTOM_4, /**< Extension point for custom widgets*/
LV_PART_CUSTOM_5, /**< Extension point for custom widgets*/
LV_PART_CUSTOM_6, /**< Extension point for custom widgets*/
LV_PART_CUSTOM_7, /**< Extension point for custom widgets*/
LV_PART_CUSTOM_8, /**< Extension point for custom widgets*/
LV_PART_CUSTOM_FIRST = 0x800000, /**< Extension point for custom widgets*/
LV_PART_ANY = 0xFF, /**< Special value can be used in some functions to target all parts*/
LV_PART_ANY = 0xFF0000, /**< Special value can be used in some functions to target all parts*/
};
typedef uint16_t lv_part_t;
typedef uint32_t lv_part_t;
/**
* On/Off features controlling the object's behavior.
+6 -6
View File
@@ -36,7 +36,7 @@
* GLOBAL FUNCTIONS
**********************/
void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t * draw_dsc)
void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint32_t part, lv_draw_rect_dsc_t * draw_dsc)
{
#if LV_DRAW_COMPLEX
@@ -179,7 +179,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t
#endif
}
void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_t * draw_dsc)
void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint32_t part, lv_draw_label_dsc_t * draw_dsc)
{
draw_dsc->opa = lv_obj_get_style_text_opa(obj, part);
if(draw_dsc->opa <= LV_OPA_MIN) return;
@@ -211,7 +211,7 @@ void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_
}
}
void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint8_t part, lv_draw_img_dsc_t * draw_dsc)
void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint32_t part, lv_draw_img_dsc_t * draw_dsc)
{
draw_dsc->opa = lv_obj_get_style_img_opa(obj, part);
if(draw_dsc->opa <= LV_OPA_MIN) return;
@@ -236,7 +236,7 @@ void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint8_t part, lv_draw_img_dsc_t *
#endif
}
void lv_obj_init_draw_line_dsc(lv_obj_t * obj, uint8_t part, lv_draw_line_dsc_t * draw_dsc)
void lv_obj_init_draw_line_dsc(lv_obj_t * obj, uint32_t part, lv_draw_line_dsc_t * draw_dsc)
{
draw_dsc->width = lv_obj_get_style_line_width(obj, part);
if(draw_dsc->width == 0) return;
@@ -265,7 +265,7 @@ void lv_obj_init_draw_line_dsc(lv_obj_t * obj, uint8_t part, lv_draw_line_dsc_t
#endif
}
void lv_obj_init_draw_arc_dsc(lv_obj_t * obj, uint8_t part, lv_draw_arc_dsc_t * draw_dsc)
void lv_obj_init_draw_arc_dsc(lv_obj_t * obj, uint32_t part, lv_draw_arc_dsc_t * draw_dsc)
{
draw_dsc->width = lv_obj_get_style_arc_width(obj, part);
if(draw_dsc->width == 0) return;
@@ -289,7 +289,7 @@ void lv_obj_init_draw_arc_dsc(lv_obj_t * obj, uint8_t part, lv_draw_arc_dsc_t *
#endif
}
lv_coord_t lv_obj_calculate_ext_draw_size(lv_obj_t * obj, uint8_t part)
lv_coord_t lv_obj_calculate_ext_draw_size(lv_obj_t * obj, uint32_t part)
{
lv_coord_t s = 0;
+7 -7
View File
@@ -49,7 +49,7 @@ typedef struct
char text[16];
int32_t value;
uint32_t id;
uint32_t part :8;
uint32_t part;
const void * sub_part_ptr;
}lv_obj_draw_dsc_t;
@@ -67,7 +67,7 @@ typedef struct
* @note Only the relevant fields will be set.
* E.g. if `border width == 0` the other border properties won't be evaluated.
*/
void lv_obj_init_draw_rect_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_rect_dsc_t * draw_dsc);
void lv_obj_init_draw_rect_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_rect_dsc_t * draw_dsc);
/**
* Initialize a label draw descriptor from an object's styles in its current state
@@ -77,7 +77,7 @@ void lv_obj_init_draw_rect_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_rec
* If the `opa` filed is set to or the property is equal to `LV_OPA_TRANSP` the rest won't be initialized.
* Should be initialized with `lv_draw_label_dsc_init(draw_dsc)`.
*/
void lv_obj_init_draw_label_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_label_dsc_t * draw_dsc);
void lv_obj_init_draw_label_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_label_dsc_t * draw_dsc);
/**
* Initialize an image draw descriptor from an object's styles in its current state
@@ -86,7 +86,7 @@ void lv_obj_init_draw_label_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_la
* @param draw_dsc the descriptor the initialize.
* Should be initialized with `lv_draw_image_dsc_init(draw_dsc)`.
*/
void lv_obj_init_draw_img_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_img_dsc_t * draw_dsc);
void lv_obj_init_draw_img_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_img_dsc_t * draw_dsc);
/**
@@ -96,7 +96,7 @@ void lv_obj_init_draw_img_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_img_
* @param draw_dsc the descriptor the initialize.
* Should be initialized with `lv_draw_line_dsc_init(draw_dsc)`.
*/
void lv_obj_init_draw_line_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_line_dsc_t * draw_dsc);
void lv_obj_init_draw_line_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_line_dsc_t * draw_dsc);
/**
* Initialize an arc draw descriptor from an object's styles in its current state
@@ -105,7 +105,7 @@ void lv_obj_init_draw_line_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_lin
* @param draw_dsc the descriptor the initialize.
* Should be initialized with `lv_draw_arc_dsc_init(draw_dsc)`.
*/
void lv_obj_init_draw_arc_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_arc_dsc_t * draw_dsc);
void lv_obj_init_draw_arc_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_arc_dsc_t * draw_dsc);
/**
* Get the required extra size (around the object's part) to draw shadow, outline, value etc.
@@ -113,7 +113,7 @@ void lv_obj_init_draw_arc_dsc(struct _lv_obj_t * obj, uint8_t part, lv_draw_arc_
* @param part part of the object
* @return the extra size required around the object
*/
lv_coord_t lv_obj_calculate_ext_draw_size(struct _lv_obj_t * obj, uint8_t part);
lv_coord_t lv_obj_calculate_ext_draw_size(struct _lv_obj_t * obj, uint32_t part);
/**
* Initialize a draw descriptor used in events.
+11 -11
View File
@@ -57,10 +57,10 @@ void lv_obj_set_x(lv_obj_t * obj, lv_coord_t x)
lv_res_t res_x;
lv_style_value_t v_x;
res_x = lv_obj_get_local_style_prop(obj, LV_PART_MAIN, LV_STATE_DEFAULT, LV_STYLE_X, &v_x);
res_x = lv_obj_get_local_style_prop(obj, LV_STYLE_X, &v_x, 0);
if((res_x == LV_RES_OK && v_x.num != x) || res_x == LV_RES_INV) {
lv_obj_set_style_x(obj, LV_PART_MAIN, LV_STATE_DEFAULT, x);
lv_obj_set_style_x(obj, x, 0);
}
lv_obj_refr_pos(obj);
@@ -76,10 +76,10 @@ void lv_obj_set_y(lv_obj_t * obj, lv_coord_t y)
lv_res_t res_y;
lv_style_value_t v_y;
res_y = lv_obj_get_local_style_prop(obj, LV_PART_MAIN, LV_STATE_DEFAULT, LV_STYLE_Y, &v_y);
res_y = lv_obj_get_local_style_prop(obj, LV_STYLE_Y, &v_y, 0);
if((res_y == LV_RES_OK && v_y.num != y) || res_y == LV_RES_INV) {
lv_obj_set_style_y(obj, LV_PART_MAIN, LV_STATE_DEFAULT, y);
lv_obj_set_style_y(obj, y, 0);
}
lv_obj_refr_pos(obj);
@@ -182,10 +182,10 @@ void lv_obj_set_width(lv_obj_t * obj, lv_coord_t w)
lv_res_t res_w;
lv_style_value_t v_w;
res_w = lv_obj_get_local_style_prop(obj, LV_PART_MAIN, LV_STATE_DEFAULT, LV_STYLE_WIDTH, &v_w);
res_w = lv_obj_get_local_style_prop(obj, LV_STYLE_WIDTH, &v_w, 0);
if((res_w == LV_RES_OK && v_w.num != w) || res_w == LV_RES_INV) {
lv_obj_set_style_width(obj, LV_PART_MAIN, LV_STATE_DEFAULT, w);
lv_obj_set_style_width(obj, w, 0);
}
lv_obj_refr_size(obj);
@@ -197,10 +197,10 @@ void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h)
lv_res_t res_h;
lv_style_value_t v_h;
res_h = lv_obj_get_local_style_prop(obj, LV_PART_MAIN, LV_STATE_DEFAULT, LV_STYLE_HEIGHT, &v_h);
res_h = lv_obj_get_local_style_prop(obj, LV_STYLE_HEIGHT, &v_h, 0);
if((res_h == LV_RES_OK && v_h.num != h) || res_h == LV_RES_INV) {
lv_obj_set_style_height(obj, LV_PART_MAIN, LV_STATE_DEFAULT, h);
lv_obj_set_style_height(obj, h, 0);
}
lv_obj_refr_size(obj);
@@ -226,7 +226,7 @@ void lv_obj_set_layout(lv_obj_t * obj, uint32_t layout)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_obj_set_style_layout(obj, LV_PART_MAIN, LV_STATE_DEFAULT, layout);
lv_obj_set_style_layout(obj, layout, 0);
lv_obj_mark_layout_as_dirty(obj);
}
@@ -290,7 +290,7 @@ uint32_t lv_layout_register(lv_layout_update_cb_t cb)
void lv_obj_align(lv_obj_t * obj, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs)
{
lv_obj_set_style_align(obj, LV_PART_MAIN, LV_STATE_DEFAULT, align);
lv_obj_set_style_align(obj, align, 0);
lv_obj_set_pos(obj, x_ofs, y_ofs);
}
@@ -414,7 +414,7 @@ void lv_obj_align_to(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv
x += x_ofs + base->coords.x1 - parent->coords.x1 + lv_obj_get_scroll_left(parent);
y += y_ofs + base->coords.y1 - parent->coords.y1 + lv_obj_get_scroll_top(parent);
lv_obj_set_style_align(obj, LV_PART_MAIN, LV_STATE_DEFAULT, LV_ALIGN_TOP_LEFT);
lv_obj_set_style_align(obj, LV_ALIGN_TOP_LEFT, 0);
lv_obj_set_pos(obj, x, y);
}
+78 -58
View File
@@ -22,7 +22,7 @@
typedef struct {
lv_obj_t * obj;
lv_style_prop_t prop;
uint8_t part;
lv_style_selector_t selector;
lv_style_value_t start_value;
lv_style_value_t end_value;
} trans_t;
@@ -42,13 +42,13 @@ typedef enum {
/**********************
* STATIC PROTOTYPES
**********************/
static lv_style_t * get_local_style(lv_obj_t * obj, uint32_t part, uint32_t state);
static lv_style_t * get_local_style(lv_obj_t * obj, lv_style_selector_t selector);
static lv_obj_style_t * get_trans_style(lv_obj_t * obj, uint32_t part);
static bool get_prop_core(const lv_obj_t * obj, uint8_t part, lv_style_prop_t prop, lv_style_value_t * v);
static bool get_prop_core(const lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop, lv_style_value_t * v);
static lv_style_value_t apply_color_filter(const lv_obj_t * obj, uint32_t part, lv_style_value_t v);
static void report_style_change_core(void * style, lv_obj_t * obj);
static void refresh_children_style(lv_obj_t * obj);
static bool trans_del(lv_obj_t * obj, uint8_t part, lv_style_prop_t prop, trans_t * tr_limit);
static bool trans_del(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop, trans_t * tr_limit);
static void trans_anim_cb(void * _tr, int32_t v);
static void trans_anim_start_cb(lv_anim_t * a);
static void trans_anim_ready_cb(lv_anim_t * a);
@@ -73,9 +73,9 @@ void _lv_obj_style_init(void)
_lv_ll_init(&LV_GC_ROOT(_lv_obj_style_trans_ll), sizeof(trans_t));
}
void lv_obj_add_style(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_t * style)
void lv_obj_add_style(struct _lv_obj_t * obj, lv_style_t * style, lv_style_selector_t selector)
{
trans_del(obj, part, 0xFF, NULL);
trans_del(obj, selector, LV_STYLE_PROP_ALL, NULL);
uint32_t i;
/*Go after the transition and local styles*/
@@ -98,19 +98,22 @@ void lv_obj_add_style(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_
lv_memset_00(&obj->styles[i], sizeof(lv_obj_style_t));
obj->styles[i].style = style;
obj->styles[i].part = part;
obj->styles[i].state = state;
obj->styles[i].selector = selector;
lv_obj_refresh_style(obj, part, LV_STYLE_PROP_ALL);
lv_obj_refresh_style(obj, selector, LV_STYLE_PROP_ALL);
}
void lv_obj_remove_style(lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_t * style)
void lv_obj_remove_style(lv_obj_t * obj, lv_style_t * style, lv_style_selector_t selector)
{
lv_state_t state = lv_obj_style_get_selector_state(selector);
lv_part_t part = lv_obj_style_get_selector_part(selector);
uint32_t i = 0;
bool deleted = false;
while(i < obj->style_cnt) {
if((state != LV_STATE_ANY && obj->styles[i].state != state) ||
(part != LV_PART_ANY && obj->styles[i].part != part) ||
lv_state_t state_act = lv_obj_style_get_selector_state(obj->styles[i].selector);
lv_part_t part_act = lv_obj_style_get_selector_part(obj->styles[i].selector);
if((state != LV_STATE_ANY && state_act != state) ||
(part != LV_PART_ANY && part_act != part) ||
(style != NULL && style != obj->styles[i].style))
{
i++;
@@ -159,13 +162,16 @@ void lv_obj_report_style_change(lv_style_t * style)
}
}
void lv_obj_refresh_style(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop)
void lv_obj_refresh_style(lv_obj_t * obj, lv_style_selector_t selector, lv_style_prop_t prop)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
if(!style_refr) return;
lv_obj_invalidate(obj);
lv_part_t part = lv_obj_style_get_selector_part(selector);
if((part == LV_PART_ANY || part == LV_PART_MAIN) && (prop == LV_STYLE_PROP_ALL || (prop & LV_STYLE_PROP_LAYOUT_REFR))) {
lv_event_send(obj, LV_EVENT_STYLE_CHANGED, NULL); /*To update layout*/
} else if(prop & LV_STYLE_PROP_EXT_DRAW) {
@@ -187,7 +193,7 @@ void lv_obj_enable_style_refresh(bool en)
style_refr = en;
}
lv_style_value_t lv_obj_get_style_prop(const lv_obj_t * obj, uint8_t part, lv_style_prop_t prop)
lv_style_value_t lv_obj_get_style_prop(const lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop)
{
lv_style_value_t value_act;
bool inherit = prop & LV_STYLE_PROP_INHERIT ? true : false;
@@ -216,21 +222,20 @@ lv_style_value_t lv_obj_get_style_prop(const lv_obj_t * obj, uint8_t part, lv_st
return value_act;
}
void lv_obj_set_local_style_prop(lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_prop_t prop, lv_style_value_t value)
void lv_obj_set_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t value, lv_style_selector_t selector)
{
lv_style_t * style = get_local_style(obj, part, state);
lv_style_t * style = get_local_style(obj, selector);
lv_style_set_prop(style, prop, value);
lv_obj_refresh_style(obj, part, prop);
lv_obj_refresh_style(obj, selector, prop);
}
lv_res_t lv_obj_get_local_style_prop(lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_prop_t prop, lv_style_value_t * value)
lv_res_t lv_obj_get_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t * value, lv_style_selector_t selector)
{
uint32_t i;
for(i = 0; i < obj->style_cnt; i++) {
if(obj->styles[i].is_local &&
obj->styles[i].part == part &&
obj->styles[i].state == state)
obj->styles[i].selector == selector)
{
return lv_style_get_prop(obj->styles[i].style, prop, value);
}
@@ -239,7 +244,7 @@ lv_res_t lv_obj_get_local_style_prop(lv_obj_t * obj, uint32_t part, uint32_t sta
return LV_RES_INV;
}
bool lv_obj_remove_local_style_prop(lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_prop_t prop)
bool lv_obj_remove_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_selector_t selector)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
@@ -247,8 +252,7 @@ bool lv_obj_remove_local_style_prop(lv_obj_t * obj, uint32_t part, uint32_t stat
/*Find the style*/
for(i = 0; i < obj->style_cnt; i++) {
if(obj->styles[i].is_local &&
obj->styles[i].state == state &&
obj->styles[i].part == part) {
obj->styles[i].selector == selector) {
break;
}
}
@@ -259,7 +263,7 @@ bool lv_obj_remove_local_style_prop(lv_obj_t * obj, uint32_t part, uint32_t stat
return lv_style_remove_prop(obj->styles[i].style, prop);
}
void _lv_obj_style_create_transition(lv_obj_t * obj, lv_style_prop_t prop, uint8_t part, lv_state_t prev_state,
void _lv_obj_style_create_transition(lv_obj_t * obj, lv_style_prop_t prop, lv_part_t part, lv_state_t prev_state,
lv_state_t new_state, uint32_t time, uint32_t delay, const lv_anim_path_t * path)
{
trans_t * tr;
@@ -298,7 +302,7 @@ void _lv_obj_style_create_transition(lv_obj_t * obj, lv_style_prop_t prop, uint8
if(tr) {
tr->obj = obj;
tr->prop = prop;
tr->part = part;
tr->selector = part;
lv_anim_t a;
lv_anim_init(&a);
@@ -324,9 +328,11 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t sta
for(i = 0; i < obj->style_cnt; i++) {
if(obj->styles[i].is_trans) continue;
lv_state_t state_act = lv_obj_style_get_selector_state(obj->styles[i].selector);
lv_part_t part_act = lv_obj_style_get_selector_part(obj->styles[i].selector);
/*The style is valid for a stat but not the other*/
bool valid1 = obj->styles[i].state & (~state1) ? false : true;
bool valid2 = obj->styles[i].state & (~state2) ? false : true;
bool valid1 = state_act & (~state1) ? false : true;
bool valid2 = state_act & (~state2) ? false : true;
if(valid1 != valid2) {
lv_style_t * style = obj->styles[i].style;
lv_style_value_t v;
@@ -340,7 +346,7 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t sta
else if(lv_style_get_prop(style, LV_STYLE_PAD_ROW, &v)) res_tmp = _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
if(res_tmp == _LV_STYLE_STATE_CMP_DIFF_LAYOUT) {
if(obj->styles[i].part == LV_PART_MAIN) return _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
if(part_act == LV_PART_MAIN) return _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
else {
res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
continue;
@@ -362,7 +368,7 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t sta
else if(lv_style_get_prop(style, LV_STYLE_LINE_WIDTH, &v)) res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
else {
if(res != _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) {
if((obj->styles[i].part == LV_PART_MAIN || obj->styles[i].part == LV_PART_SCROLLBAR)) {
if((part_act == LV_PART_MAIN || part_act == LV_PART_SCROLLBAR)) {
res = _LV_STYLE_STATE_CMP_DIFF_REDRAW;
}
}
@@ -398,6 +404,16 @@ void lv_obj_fade_out(lv_obj_t * obj, uint32_t time, uint32_t delay)
lv_anim_start(&a);
}
lv_state_t lv_obj_style_get_selector_state(lv_style_selector_t selector)
{
return selector & 0xFFFF;
}
lv_part_t lv_obj_style_get_selector_part(lv_style_selector_t selector)
{
return selector & 0xFF0000;
}
/**********************
* STATIC FUNCTIONS
**********************/
@@ -410,13 +426,12 @@ void lv_obj_fade_out(lv_obj_t * obj, uint32_t time, uint32_t delay)
* @param state the state in whose local style to get
* @return pointer to the local style
*/
static lv_style_t * get_local_style(lv_obj_t * obj, uint32_t part, uint32_t state)
static lv_style_t * get_local_style(lv_obj_t * obj, lv_style_selector_t selector)
{
uint32_t i;
for(i = 0; i < obj->style_cnt; i++) {
if(obj->styles[i].is_local &&
obj->styles[i].part == part &&
obj->styles[i].state == state)
obj->styles[i].selector == selector)
{
return obj->styles[i].style;
}
@@ -437,8 +452,7 @@ static lv_style_t * get_local_style(lv_obj_t * obj, uint32_t part, uint32_t stat
obj->styles[i].style = lv_mem_alloc(sizeof(lv_style_t));
lv_style_init(obj->styles[i].style);
obj->styles[i].is_local = 1;
obj->styles[i].part = part;
obj->styles[i].state = state;
obj->styles[i].selector = selector;
return obj->styles[i].style;
}
@@ -450,11 +464,11 @@ static lv_style_t * get_local_style(lv_obj_t * obj, uint32_t part, uint32_t stat
* @param state the state in whose local style to get
* @return pointer to the transition style
*/
static lv_obj_style_t * get_trans_style(lv_obj_t * obj, uint32_t part)
static lv_obj_style_t * get_trans_style(lv_obj_t * obj, lv_style_selector_t selector)
{
uint32_t i;
for(i = 0; i < obj->style_cnt; i++) {
if(obj->styles[i].is_trans && obj->styles[i].part == part) break;
if(obj->styles[i].is_trans && obj->styles[i].selector == selector) break;
}
/*Already have a transition style for it*/
@@ -471,12 +485,12 @@ static lv_obj_style_t * get_trans_style(lv_obj_t * obj, uint32_t part)
obj->styles[0].style = lv_mem_alloc(sizeof(lv_style_t));
lv_style_init(obj->styles[0].style);
obj->styles[0].is_trans = 1;
obj->styles[0].part = part;
obj->styles[0].selector = selector;
return &obj->styles[0];
}
static bool get_prop_core(const lv_obj_t * obj, uint8_t part, lv_style_prop_t prop, lv_style_value_t * v)
static bool get_prop_core(const lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop, lv_style_value_t * v)
{
uint8_t group = 1 << _lv_style_get_prop_group(prop);
int32_t weight = -1;
@@ -490,7 +504,10 @@ static bool get_prop_core(const lv_obj_t * obj, uint8_t part, lv_style_prop_t pr
lv_obj_style_t * obj_style = &obj->styles[i];
if(obj_style->is_trans == false) break;
if(skip_trans) continue;
if(obj_style->part != part) continue;
lv_part_t part_act = lv_obj_style_get_selector_part(obj->styles[i].selector);
if(part_act != part) continue;
if((obj_style->style->has_group & group) == 0) continue;
found = lv_style_get_prop(obj_style->style, prop, &value_tmp);
if(found) {
@@ -501,26 +518,28 @@ static bool get_prop_core(const lv_obj_t * obj, uint8_t part, lv_style_prop_t pr
for(; i < obj->style_cnt; i++) {
lv_obj_style_t * obj_style = &obj->styles[i];
if(obj_style->part != part) continue;
lv_part_t part_act = lv_obj_style_get_selector_part(obj->styles[i].selector);
lv_state_t state_act = lv_obj_style_get_selector_state(obj->styles[i].selector);
if(part_act != part) continue;
if((obj_style->style->has_group & group) == 0) continue;
/*Be sure the style not specifies other state than the requested.
*E.g. For HOVER+PRESS object state, HOVER style only is OK, but HOVER+FOCUS style is not*/
if((obj_style->state & state_inv)) continue;
if((state_act & state_inv)) continue;
/*Check only better candidates*/
if(obj_style->state <= weight) continue;
if(state_act <= weight) continue;
found = lv_style_get_prop(obj_style->style, prop, &value_tmp);
if(found) {
if(obj_style->state == state) {
if(state_act == state) {
*v = value_tmp;
return true;
}
if(weight < obj_style->state) {
weight = obj_style->state;
if(weight < state_act) {
weight = state_act;
*v = value_tmp;
}
}
@@ -591,7 +610,7 @@ static void refresh_children_style(lv_obj_t * obj)
* @param prop a property or 0xFF to remove all properties
* @param tr_limit delete transitions only "older" than this. `NULL` if not used
*/
static bool trans_del(lv_obj_t * obj, uint8_t part, lv_style_prop_t prop, trans_t * tr_limit)
static bool trans_del(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop, trans_t * tr_limit)
{
trans_t * tr;
trans_t * tr_prev;
@@ -603,12 +622,12 @@ static bool trans_del(lv_obj_t * obj, uint8_t part, lv_style_prop_t prop, trans_
/*'tr' might be deleted, so get the next object while 'tr' is valid*/
tr_prev = _lv_ll_get_prev(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr);
if(tr->obj == obj && (part == tr->part || part == LV_PART_ANY) && (prop == tr->prop || prop == LV_STYLE_PROP_ALL)) {
if(tr->obj == obj && (part == tr->selector || part == LV_PART_ANY) && (prop == tr->prop || prop == LV_STYLE_PROP_ALL)) {
/*Remove the transitioned property from trans. style
*to allow changing it by normal styles*/
uint32_t i;
for(i = 0; i < obj->style_cnt; i++) {
if(obj->styles[i].is_trans && (part == LV_PART_ANY || obj->styles[i].part == part)) {
if(obj->styles[i].is_trans && (part == LV_PART_ANY || obj->styles[i].selector == part)) {
lv_style_remove_prop(obj->styles[i].style, tr->prop);
lv_anim_del(tr, NULL);
_lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr);
@@ -630,7 +649,7 @@ static void trans_anim_cb(void * _tr, int32_t v)
uint32_t i;
for(i = 0; i < obj->style_cnt; i++) {
if(obj->styles[i].is_trans == 0 || obj->styles[i].part != tr->part) continue;
if(obj->styles[i].is_trans == 0 || obj->styles[i].selector != tr->selector) continue;
lv_style_value_t value_final;
switch (tr->prop) {
@@ -678,7 +697,7 @@ static void trans_anim_cb(void * _tr, int32_t v)
}
}
lv_style_set_prop(obj->styles[i].style, tr->prop, value_final);
if (refr) lv_obj_refresh_style(tr->obj, tr->part, tr->prop);
if (refr) lv_obj_refresh_style(tr->obj, tr->selector, tr->prop);
break;
}
@@ -689,18 +708,19 @@ static void trans_anim_start_cb(lv_anim_t * a)
{
trans_t * tr = a->var;
tr->start_value = lv_obj_get_style_prop(tr->obj, tr->part, tr->prop);
lv_part_t part = lv_obj_style_get_selector_part(tr->selector);
tr->start_value = lv_obj_get_style_prop(tr->obj, part, tr->prop);
/*Init prop to an invalid values to be sure `trans_del` won't delete this added `tr`*/
lv_style_prop_t prop_tmp = tr->prop;
tr->prop = LV_STYLE_PROP_INV;
/*Delete the related transitions if any*/
trans_del(tr->obj, tr->part, prop_tmp, tr);
trans_del(tr->obj, part, prop_tmp, tr);
tr->prop = prop_tmp;
lv_obj_style_t * style_trans = get_trans_style(tr->obj, tr->part);
lv_obj_style_t * style_trans = get_trans_style(tr->obj, tr->selector);
lv_style_set_prop(style_trans->style, tr->prop, tr->start_value); /*Be sure `trans_style` has a valid value*/
}
@@ -717,7 +737,7 @@ static void trans_anim_ready_cb(lv_anim_t * a)
bool running = false;
trans_t * tr_i;
_LV_LL_READ(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr_i) {
if(tr_i != tr && tr_i->obj == tr->obj && tr_i->part == tr->part && tr_i->prop == tr->prop) {
if(tr_i != tr && tr_i->obj == tr->obj && tr_i->selector == tr->selector && tr_i->prop == tr->prop) {
running = true;
break;
}
@@ -726,7 +746,7 @@ static void trans_anim_ready_cb(lv_anim_t * a)
if(!running) {
uint32_t i;
for(i = 0; i < obj->style_cnt; i++) {
if(obj->styles[i].is_trans && obj->styles[i].part == tr->part) {
if(obj->styles[i].is_trans && obj->styles[i].selector == tr->selector) {
_lv_ll_remove(&LV_GC_ROOT(_lv_obj_style_trans_ll), tr);
lv_mem_free(tr);
@@ -734,7 +754,7 @@ static void trans_anim_ready_cb(lv_anim_t * a)
lv_style_remove_prop(obj_style->style, prop);
if(lv_style_is_empty(obj->styles[i].style)) {
lv_obj_remove_style(obj, obj_style->part, obj_style->state, obj_style->style);
lv_obj_remove_style(obj, obj_style->style, obj_style->selector);
//trans_del(obj, obj_style->part, prop, NULL);
}
@@ -746,12 +766,12 @@ static void trans_anim_ready_cb(lv_anim_t * a)
static void fade_anim_cb(void * obj, int32_t v)
{
lv_obj_set_style_opa(obj, LV_PART_MAIN, LV_STATE_DEFAULT, v);
lv_obj_set_style_opa(obj, v, 0);
}
static void fade_in_anim_ready(lv_anim_t * a)
{
lv_obj_remove_local_style_prop(a->var, LV_PART_MAIN,LV_STATE_DEFAULT, LV_STYLE_OPA);
lv_obj_remove_local_style_prop(a->var, LV_STYLE_OPA, 0);
}
+31 -26
View File
@@ -33,12 +33,13 @@ typedef enum {
_LV_STYLE_STATE_CMP_DIFF_LAYOUT, /*The differences can be shown with a simple redraw*/
} _lv_style_state_cmp_t;
typedef uint32_t lv_style_selector_t;
typedef struct {
lv_style_t * style;
uint16_t state;
uint8_t part;
uint8_t is_local :1;
uint8_t is_trans :1;
uint32_t selector;
uint32_t is_local :1;
uint32_t is_trans :1;
}lv_obj_style_t;
/**********************
@@ -59,7 +60,7 @@ void _lv_obj_style_init(void);
* @param style pointer to a style to add
* @example lv_obj_add_style_no_refresh(slider, LV_PART_KNOB, LV_STATE_PRESSED, &style1);
*/
void lv_obj_add_style(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_t * style);
void lv_obj_add_style(struct _lv_obj_t * obj, lv_style_t * style, lv_style_selector_t selector);
/**
* Add a style to an object.
@@ -71,7 +72,7 @@ void lv_obj_add_style(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_
* @example lv_obj_remove_style(obj, LV_PART_MAIN, LV_STATE_ANY, &style); //Remove all styles from the main part
* @example lv_obj_remove_style(obj, LV_PART_ANY, LV_STATE_ANY, NULL); //Remove all styles
*/
void lv_obj_remove_style(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_t * style);
void lv_obj_remove_style(struct _lv_obj_t * obj, lv_style_t * style, lv_style_selector_t selector);
/**
* Remove all styles from an object
@@ -79,7 +80,7 @@ void lv_obj_remove_style(struct _lv_obj_t * obj, uint32_t part, uint32_t state,
*/
static inline void lv_obj_remove_style_all(struct _lv_obj_t * obj)
{
lv_obj_remove_style(obj, LV_PART_ANY, LV_STATE_ANY, NULL);
lv_obj_remove_style(obj, NULL, LV_PART_ANY | LV_STATE_ANY);
}
/**
@@ -116,7 +117,7 @@ void lv_obj_enable_style_refresh(bool en);
* @return the value of the property.
* Should be read from the correct field of the `lv_style_value_t` according to the type of the property.
*/
lv_style_value_t lv_obj_get_style_prop(const struct _lv_obj_t * obj, uint8_t part, lv_style_prop_t prop);
lv_style_value_t lv_obj_get_style_prop(const struct _lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop);
/**
* Set local style property on an object's part and state.
@@ -126,9 +127,9 @@ lv_style_value_t lv_obj_get_style_prop(const struct _lv_obj_t * obj, uint8_t par
* @param prop the property
* @param value value of the property. The correct element should be set according to the type of the property
*/
void lv_obj_set_local_style_prop(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_prop_t prop, lv_style_value_t value);
void lv_obj_set_local_style_prop(struct _lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t value, lv_style_selector_t selector);
lv_res_t lv_obj_get_local_style_prop(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_prop_t prop, lv_style_value_t * value);
lv_res_t lv_obj_get_local_style_prop(struct _lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t * value, lv_style_selector_t selector);
/**
* Remove a local style property from a part of an object with a given state.
@@ -138,7 +139,7 @@ lv_res_t lv_obj_get_local_style_prop(struct _lv_obj_t * obj, uint32_t part, uint
* @param prop a style property to remove.
* @return true the property was found and removed; false: the property was not found
*/
bool lv_obj_remove_local_style_prop(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_style_prop_t prop);
bool lv_obj_remove_local_style_prop(struct _lv_obj_t * obj, lv_style_prop_t prop, lv_style_selector_t selector);
/**
* Used internally to create a style tarnsition
@@ -151,7 +152,7 @@ bool lv_obj_remove_local_style_prop(struct _lv_obj_t * obj, uint32_t part, uint3
* @param delay
* @param path
*/
void _lv_obj_style_create_transition(struct _lv_obj_t * obj, lv_style_prop_t prop, uint8_t part, lv_state_t prev_state,
void _lv_obj_style_create_transition(struct _lv_obj_t * obj, lv_style_prop_t prop, lv_part_t part, lv_state_t prev_state,
lv_state_t new_state, uint32_t time, uint32_t delay, const lv_anim_path_t * path);
/**
@@ -179,28 +180,32 @@ void lv_obj_fade_in(struct _lv_obj_t * obj, uint32_t time, uint32_t delay);
*/
void lv_obj_fade_out(struct _lv_obj_t * obj, uint32_t time, uint32_t delay);
lv_state_t lv_obj_style_get_selector_state(lv_style_selector_t selector);
lv_part_t lv_obj_style_get_selector_part(lv_style_selector_t selector);
#include "lv_obj_style_gen.h"
static inline void lv_obj_set_style_pad_all(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) {
lv_obj_set_style_pad_left(obj, part, state, value);
lv_obj_set_style_pad_right(obj, part, state, value);
lv_obj_set_style_pad_top(obj, part, state, value);
lv_obj_set_style_pad_bottom(obj, part, state, value);
static inline void lv_obj_set_style_pad_all(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) {
lv_obj_set_style_pad_left(obj, value, selector);
lv_obj_set_style_pad_right(obj, value, selector);
lv_obj_set_style_pad_top(obj, value, selector);
lv_obj_set_style_pad_bottom(obj, value, selector);
}
static inline void lv_obj_set_style_pad_hor(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) {
lv_obj_set_style_pad_left(obj, part, state, value);
lv_obj_set_style_pad_right(obj, part, state, value);
static inline void lv_obj_set_style_pad_hor(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) {
lv_obj_set_style_pad_left(obj, value, selector);
lv_obj_set_style_pad_right(obj, value, selector);
}
static inline void lv_obj_set_style_pad_ver(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) {
lv_obj_set_style_pad_top(obj, part, state, value);
lv_obj_set_style_pad_bottom(obj, part, state, value);
static inline void lv_obj_set_style_pad_ver(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) {
lv_obj_set_style_pad_top(obj, value, selector);
lv_obj_set_style_pad_bottom(obj, value, selector);
}
static inline void lv_obj_set_style_pad_gap(struct _lv_obj_t * obj, uint32_t part, uint32_t state, lv_coord_t value) {
lv_obj_set_style_pad_row(obj, part, state, value);
lv_obj_set_style_pad_column(obj, part, state, value);
static inline void lv_obj_set_style_pad_gap(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) {
lv_obj_set_style_pad_row(obj, value, selector);
lv_obj_set_style_pad_column(obj, value, selector);
}
/**********************
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -346,7 +346,7 @@ static void obj_del_core(lv_obj_t * obj)
/*Remove all style*/
lv_obj_enable_style_refresh(false); /*No need to refresh the style because the object will be deleted*/
lv_obj_remove_style(obj, LV_PART_ANY, LV_STATE_ANY, NULL);
lv_obj_remove_style_all(obj);
lv_obj_enable_style_refresh(true);
/*Reset all input devices if the object to delete is used*/
+15 -15
View File
@@ -240,14 +240,14 @@ void _lv_disp_refr_timer(lv_timer_t * tmr)
static lv_obj_t * perf_label = NULL;
if(perf_label == NULL) {
perf_label = lv_label_create(lv_layer_sys());
lv_obj_set_style_bg_opa(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
lv_obj_set_style_bg_color(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, lv_color_black());
lv_obj_set_style_text_color(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, lv_color_white());
lv_obj_set_style_pad_top(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, 3);
lv_obj_set_style_pad_bottom(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, 3);
lv_obj_set_style_pad_left(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, 3);
lv_obj_set_style_pad_right(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, 3);
lv_obj_set_style_text_align(perf_label, LV_PART_MAIN, LV_STATE_DEFAULT, LV_TEXT_ALIGN_RIGHT);
lv_obj_set_style_bg_opa(perf_label, LV_OPA_50, 0);
lv_obj_set_style_bg_color(perf_label, lv_color_black(), 0);
lv_obj_set_style_text_color(perf_label, lv_color_white(), 0);
lv_obj_set_style_pad_top(perf_label, 3, 0);
lv_obj_set_style_pad_bottom(perf_label, 3, 0);
lv_obj_set_style_pad_left(perf_label, 3, 0);
lv_obj_set_style_pad_right(perf_label, 3, 0);
lv_obj_set_style_text_align(perf_label, LV_TEXT_ALIGN_RIGHT, 0);
lv_label_set_text(perf_label, "?");
lv_obj_align(perf_label, LV_ALIGN_BOTTOM_RIGHT, 0, 0);
}
@@ -284,13 +284,13 @@ void _lv_disp_refr_timer(lv_timer_t * tmr)
static lv_obj_t * mem_label = NULL;
if(mem_label == NULL) {
mem_label = lv_label_create(lv_layer_sys());
lv_obj_set_style_bg_opa(mem_label, LV_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50);
lv_obj_set_style_bg_color(mem_label, LV_PART_MAIN, LV_STATE_DEFAULT, lv_color_black());
lv_obj_set_style_text_color(mem_label, LV_PART_MAIN, LV_STATE_DEFAULT, lv_color_white());
lv_obj_set_style_pad_top(mem_label, LV_PART_MAIN, LV_STATE_DEFAULT, 3);
lv_obj_set_style_pad_bottom(mem_label, LV_PART_MAIN, LV_STATE_DEFAULT, 3);
lv_obj_set_style_pad_left(mem_label, LV_PART_MAIN, LV_STATE_DEFAULT, 3);
lv_obj_set_style_pad_right(mem_label, LV_PART_MAIN, LV_STATE_DEFAULT, 3);
lv_obj_set_style_bg_opa(mem_label, LV_OPA_50, 0);
lv_obj_set_style_bg_color(mem_label, lv_color_black(), 0);
lv_obj_set_style_text_color(mem_label, lv_color_white(), 0);
lv_obj_set_style_pad_top(mem_label, 3, 0);
lv_obj_set_style_pad_bottom(mem_label, 3, 0);
lv_obj_set_style_pad_left(mem_label, 3, 0);
lv_obj_set_style_pad_right(mem_label, 3, 0);
lv_label_set_text(mem_label, "?");
lv_obj_align(mem_label, LV_ALIGN_BOTTOM_LEFT, 0, 0);
}
+1 -1
View File
@@ -49,7 +49,7 @@ void lv_theme_apply(lv_obj_t * obj)
lv_theme_t * th = lv_theme_get_from_obj(obj);
if(th == NULL) return;
lv_obj_remove_style(obj, LV_PART_ANY, LV_STATE_ANY, NULL);
lv_obj_remove_style_all(obj);
apply_theme(th, obj); /*Apply the theme including the base theme(s)*/
}
+7 -7
View File
@@ -86,21 +86,21 @@ void lv_flex_init(void)
void lv_obj_set_flex_flow(lv_obj_t * obj, lv_flex_flow_t flow)
{
lv_obj_set_style_flex_flow(obj, LV_PART_MAIN, LV_STATE_DEFAULT, flow);
lv_obj_set_style_layout(obj, LV_PART_MAIN, LV_STATE_DEFAULT, LV_LAYOUT_FLEX);
lv_obj_set_style_flex_flow(obj, flow, 0);
lv_obj_set_style_layout(obj, LV_LAYOUT_FLEX, 0);
}
void lv_obj_set_flex_place(lv_obj_t * obj, lv_flex_place_t main_place, lv_flex_place_t cross_place, lv_flex_place_t track_place)
{
lv_obj_set_style_flex_main_place(obj, LV_PART_MAIN, LV_STATE_DEFAULT, main_place);
lv_obj_set_style_flex_cross_place(obj, LV_PART_MAIN, LV_STATE_DEFAULT, cross_place);
lv_obj_set_style_flex_track_place(obj, LV_PART_MAIN, LV_STATE_DEFAULT, track_place);
lv_obj_set_style_layout(obj, LV_PART_MAIN, LV_STATE_DEFAULT, LV_LAYOUT_FLEX);
lv_obj_set_style_flex_main_place(obj, main_place, 0);
lv_obj_set_style_flex_cross_place(obj, cross_place, 0);
lv_obj_set_style_flex_track_place(obj, track_place, 0);
lv_obj_set_style_layout(obj, LV_LAYOUT_FLEX, 0);
}
void lv_obj_set_flex_grow(struct _lv_obj_t * obj, uint8_t grow)
{
lv_obj_set_style_flex_grow(obj, LV_PART_MAIN, LV_STATE_DEFAULT, grow);
lv_obj_set_style_flex_grow(obj, grow, 0);
}
/**********************
+10 -10
View File
@@ -141,44 +141,44 @@ static inline void lv_style_set_flex_grow(lv_style_t * style, uint8_t value)
static inline void lv_obj_set_style_flex_flow(lv_obj_t * obj, lv_part_t part, lv_state_t state, lv_flex_flow_t value)
static inline void lv_obj_set_style_flex_flow(lv_obj_t * obj, lv_flex_flow_t value, lv_style_selector_t selector)
{
lv_style_value_t v = {
.num = (int32_t) value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_FLEX_FLOW, v);
lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_FLOW, v, selector);
}
static inline void lv_obj_set_style_flex_main_place(lv_obj_t * obj, lv_part_t part, lv_state_t state, lv_flex_place_t value)
static inline void lv_obj_set_style_flex_main_place(lv_obj_t * obj, lv_flex_place_t value, lv_style_selector_t selector)
{
lv_style_value_t v = {
.num = (int32_t) value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_FLEX_MAIN_PLACE, v);
lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_MAIN_PLACE, v, selector);
}
static inline void lv_obj_set_style_flex_cross_place(lv_obj_t * obj, lv_part_t part, lv_state_t state, lv_flex_place_t value)
static inline void lv_obj_set_style_flex_cross_place(lv_obj_t * obj, lv_flex_place_t value, lv_style_selector_t selector)
{
lv_style_value_t v = {
.num = (int32_t) value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_FLEX_CROSS_PLACE, v);
lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_CROSS_PLACE, v, selector);
}
static inline void lv_obj_set_style_flex_track_place(lv_obj_t * obj, lv_part_t part, lv_state_t state, lv_flex_place_t value)
static inline void lv_obj_set_style_flex_track_place(lv_obj_t * obj, lv_flex_place_t value, lv_style_selector_t selector)
{
lv_style_value_t v = {
.num = (int32_t) value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_FLEX_TRACK_PLACE, v);
lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_TRACK_PLACE, v, selector);
}
static inline void lv_obj_set_style_flex_grow(lv_obj_t * obj, lv_part_t part, lv_state_t state, uint8_t value)
static inline void lv_obj_set_style_flex_grow(lv_obj_t * obj, uint8_t value, lv_style_selector_t selector)
{
lv_style_value_t v = {
.num = (int32_t) value
};
lv_obj_set_local_style_prop(obj, part, state, LV_STYLE_FLEX_GROW, v);
lv_obj_set_local_style_prop(obj, LV_STYLE_FLEX_GROW, v, selector);
}
static inline lv_flex_flow_t lv_obj_get_style_flex_flow(const lv_obj_t * obj, uint32_t part)

Some files were not shown because too many files have changed in this diff Show More