api(style) add lv_style_selector_t instead of lv_part_t and lv_state_t in style API
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
Reference in New Issue
Block a user