diff --git a/README.md b/README.md index cad55b71a1..8ee754e93b 100644 --- a/README.md +++ b/README.md @@ -218,7 +218,8 @@ lv_obj_add_state(cb, LV_STATE_DISABLED); lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL); cb = lv_checkbox_create(lv_screen_active()); -lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED); +lv_obj_add_state(cb, LV_STATE_CHECKED); +lv_obj_add_state(cb, LV_STATE_DISABLED); lv_checkbox_set_text(cb, "Melon\nand a new line"); lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL); ``` diff --git a/demos/benchmark/lv_demo_benchmark.c b/demos/benchmark/lv_demo_benchmark.c index c5c39f3049..8f5297c15b 100644 --- a/demos/benchmark/lv_demo_benchmark.c +++ b/demos/benchmark/lv_demo_benchmark.c @@ -228,7 +228,7 @@ static void multiple_labels_cb(void) #endif lv_point_t s; - lv_text_get_size(&s, "Hello LVGL!", lv_obj_get_style_text_font(scr, 0), 0, 0, LV_COORD_MAX, + lv_text_get_size(&s, "Hello LVGL!", lv_obj_get_style_text_font(scr, LV_PART_MAIN), 0, 0, LV_COORD_MAX, LV_TEXT_FLAG_NONE); int32_t hor_cnt = ((int32_t)lv_obj_get_content_width(scr)) / (s.x * 3 / 2); diff --git a/demos/music/lv_demo_music_main.c b/demos/music/lv_demo_music_main.c index 00f5609a0d..32404a2239 100644 --- a/demos/music/lv_demo_music_main.c +++ b/demos/music/lv_demo_music_main.c @@ -699,7 +699,7 @@ static void track_load(uint32_t id) lv_anim_t a; lv_anim_init(&a); lv_anim_set_var(&a, album_image_obj); - lv_anim_set_values(&a, lv_obj_get_style_image_opa(album_image_obj, 0), LV_OPA_TRANSP); + lv_anim_set_values(&a, lv_obj_get_style_image_opa(album_image_obj, LV_PART_MAIN), LV_OPA_TRANSP); lv_anim_set_exec_cb(&a, album_fade_anim_cb); lv_anim_set_duration(&a, 500); lv_anim_start(&a); diff --git a/demos/render/lv_demo_render.c b/demos/render/lv_demo_render.c index 2c22d5b1d1..c43f1a9eed 100644 --- a/demos/render/lv_demo_render.c +++ b/demos/render/lv_demo_render.c @@ -561,14 +561,14 @@ static void triangle_draw_event_cb(lv_event_t * e) dsc.p[2].x = p_rel[2].x + coords.x1 + 8; dsc.p[2].y = p_rel[2].y + coords.y1 + 2; - lv_opa_t opa = lv_obj_get_style_opa(obj, 0); - dsc.grad.dir = lv_obj_get_style_bg_grad_dir(obj, 0); - dsc.grad.stops[0].color = lv_obj_get_style_bg_color(obj, 0); - dsc.grad.stops[0].frac = lv_obj_get_style_bg_main_stop(obj, 0); - dsc.grad.stops[0].opa = LV_OPA_MIX2(lv_obj_get_style_bg_main_opa(obj, 0), opa); - dsc.grad.stops[1].color = lv_obj_get_style_bg_grad_color(obj, 0); - dsc.grad.stops[1].frac = lv_obj_get_style_bg_grad_stop(obj, 0); - dsc.grad.stops[1].opa = LV_OPA_MIX2(lv_obj_get_style_bg_grad_opa(obj, 0), opa); + lv_opa_t opa = lv_obj_get_style_opa(obj, LV_PART_MAIN); + dsc.grad.dir = lv_obj_get_style_bg_grad_dir(obj, LV_PART_MAIN); + dsc.grad.stops[0].color = lv_obj_get_style_bg_color(obj, LV_PART_MAIN); + dsc.grad.stops[0].frac = lv_obj_get_style_bg_main_stop(obj, LV_PART_MAIN); + dsc.grad.stops[0].opa = LV_OPA_MIX2(lv_obj_get_style_bg_main_opa(obj, LV_PART_MAIN), opa); + dsc.grad.stops[1].color = lv_obj_get_style_bg_grad_color(obj, LV_PART_MAIN); + dsc.grad.stops[1].frac = lv_obj_get_style_bg_grad_stop(obj, LV_PART_MAIN); + dsc.grad.stops[1].opa = LV_OPA_MIX2(lv_obj_get_style_bg_grad_opa(obj, LV_PART_MAIN), opa); dsc.grad.stops_count = 2; dsc.color = dsc.grad.stops[0].color; diff --git a/demos/stress/lv_demo_stress.c b/demos/stress/lv_demo_stress.c index c4b3437ded..1b08413bc7 100644 --- a/demos/stress/lv_demo_stress.c +++ b/demos/stress/lv_demo_stress.c @@ -388,7 +388,8 @@ static void obj_test_task_cb(lv_timer_t * tmr) lv_obj_add_state(obj, LV_STATE_CHECKED); obj = lv_checkbox_create(main_page); - lv_obj_add_state(obj, LV_STATE_CHECKED | LV_STATE_DISABLED); + lv_obj_add_state(obj, LV_STATE_CHECKED); + lv_obj_add_state(obj, LV_STATE_DISABLED); auto_delete(obj, LV_DEMO_STRESS_TIME_STEP * 1 + 60); lv_obj_scroll_by(main_page, 0, 20, LV_ANIM_ON); diff --git a/demos/widgets/lv_demo_widgets_analytics.c b/demos/widgets/lv_demo_widgets_analytics.c index c40c0471fd..d8ba8147de 100644 --- a/demos/widgets/lv_demo_widgets_analytics.c +++ b/demos/widgets/lv_demo_widgets_analytics.c @@ -560,8 +560,8 @@ static lv_obj_t * create_chart_with_scales(lv_obj_t * parent, const char * title lv_scale_set_text_src(scale_hor, hor_text); lv_obj_set_width(scale_hor, lv_pct(200)); lv_obj_set_height(scale_hor, 40); - lv_obj_set_style_pad_hor(scale_hor, lv_obj_get_style_pad_left(chart, 0), 0); - lv_obj_set_style_pad_ver(scale_ver, lv_obj_get_style_pad_top(chart, 0), 0); + lv_obj_set_style_pad_hor(scale_hor, lv_obj_get_style_pad_left(chart, LV_PART_MAIN), 0); + lv_obj_set_style_pad_ver(scale_ver, lv_obj_get_style_pad_top(chart, LV_PART_MAIN), 0); return chart; } diff --git a/demos/widgets/lv_demo_widgets_shop.c b/demos/widgets/lv_demo_widgets_shop.c index 4cf1a53d8d..d05194606f 100644 --- a/demos/widgets/lv_demo_widgets_shop.c +++ b/demos/widgets/lv_demo_widgets_shop.c @@ -199,7 +199,8 @@ void lv_demo_widgets_shop_create(lv_obj_t * parent) cb = lv_checkbox_create(notifications); lv_checkbox_set_text_static(cb, "Milestone reached"); - lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED); + lv_obj_add_state(cb, LV_STATE_CHECKED); + lv_obj_add_state(cb, LV_STATE_DISABLED); cb = lv_checkbox_create(notifications); lv_checkbox_set_text_static(cb, "Out of stock"); diff --git a/docs/README_he.md b/docs/README_he.md index c605d5ace8..07fd63763b 100644 --- a/docs/README_he.md +++ b/docs/README_he.md @@ -215,7 +215,8 @@ lv_obj_add_state(cb, LV_STATE_DISABLED); lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL); cb = lv_checkbox_create(lv_screen_active()); -lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED); +lv_obj_add_state(cb, LV_STATE_CHECKED); +lv_obj_add_state(cb, LV_STATE_DISABLED); lv_checkbox_set_text(cb, "מלון\nושורה חדשה"); lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL); ``` @@ -450,4 +451,4 @@ LVGL הוא פרויקט פתוח ותרומה מתקבלת בברכה. ישנן -... ורבים אחרים. \ No newline at end of file +... ורבים אחרים. diff --git a/docs/README_jp.md b/docs/README_jp.md index 73ec499db1..58355c6aa8 100644 --- a/docs/README_jp.md +++ b/docs/README_jp.md @@ -173,7 +173,8 @@ lv_obj_add_state(cb, LV_STATE_DISABLED); lv_obj_add_event(cb, event_handler, LV_EVENT_ALL, NULL); cb = lv_checkbox_create(lv_screen_active()); -lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED); +lv_obj_add_state(cb, LV_STATE_CHECKED); +lv_obj_add_state(cb, LV_STATE_DISABLED); lv_checkbox_set_text(cb, "Melon\nand a new line"); lv_obj_add_event(cb, event_handler, LV_EVENT_ALL, NULL); ``` diff --git a/docs/README_pt_BR.md b/docs/README_pt_BR.md index 3b311b401c..0f3a796018 100644 --- a/docs/README_pt_BR.md +++ b/docs/README_pt_BR.md @@ -201,7 +201,8 @@ lv_obj_add_state(cb, LV_STATE_DISABLED); lv_obj_add_event(cb, event_handler, LV_EVENT_ALL, NULL); cb = lv_checkbox_create(lv_screen_active()); -lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED); +lv_obj_add_state(cb, LV_STATE_CHECKED); +lv_obj_add_state(cb, LV_STATE_DISABLED); lv_checkbox_set_text(cb, "Melão\ne uma nova linha"); lv_obj_add_event(cb, event_handler, LV_EVENT_ALL, NULL); ``` diff --git a/docs/README_zh.md b/docs/README_zh.md index 9b0cf1c462..427732fae4 100644 --- a/docs/README_zh.md +++ b/docs/README_zh.md @@ -240,7 +240,8 @@ lv_obj_add_state(cb, LV_STATE_DISABLED); lv_obj_add_event(cb, event_handler, LV_EVENT_ALL, NULL); cb = lv_checkbox_create(lv_screen_active()); -lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED); +lv_obj_add_state(cb, LV_STATE_CHECKED); +lv_obj_add_state(cb, LV_STATE_DISABLED); lv_checkbox_set_text(cb, "Melon\nand a new line"); lv_obj_add_event(cb, event_handler, LV_EVENT_ALL, NULL); ``` diff --git a/docs/src/details/common-widget-features/basics.rst b/docs/src/details/common-widget-features/basics.rst index dbdd70d7c4..0cc5d37120 100644 --- a/docs/src/details/common-widget-features/basics.rst +++ b/docs/src/details/common-widget-features/basics.rst @@ -435,7 +435,7 @@ leave the other states untouched) use :cpp:expr:`lv_obj_add_state(widget, LV_STATE_...)` and :cpp:expr:`lv_obj_remove_state(widget, LV_STATE_...)`. In both cases OR-ed state values can be used as well. E.g. -:cpp:expr:`lv_obj_add_state(widget, part, LV_STATE_PRESSED | LV_PRESSED_CHECKED)`. +:cpp:expr:`lv_obj_add_state(widget, LV_STATE_PRESSED | LV_PRESSED_CHECKED)`. To learn more about the states, read the related section of :ref:`styles_overview`. diff --git a/docs/src/details/widgets/checkbox.rst b/docs/src/details/widgets/checkbox.rst index 24d5993dbe..de217dddd3 100644 --- a/docs/src/details/widgets/checkbox.rst +++ b/docs/src/details/widgets/checkbox.rst @@ -53,7 +53,8 @@ common state add/clear function: lv_obj_add_state(cb, LV_STATE_CHECKED); /* Make Checkbox checked */ lv_obj_remove_state(cb, LV_STATE_CHECKED); /* Make Checkbox unchecked */ - lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED); /* Make Checkbox checked and disabled */ + lv_obj_add_state(cb, LV_STATE_CHECKED); /* Make Checkbox checked */ + lv_obj_add_state(cb, LV_STATE_DISABLED); /* Make Checkbox disabled */ To find out whether the Checkbox is checked use :cpp:expr:`lv_obj_has_state(cb, LV_STATE_CHECKED)`. diff --git a/examples/widgets/checkbox/lv_example_checkbox_1.c b/examples/widgets/checkbox/lv_example_checkbox_1.c index ee4ffe80a8..7e47daad24 100644 --- a/examples/widgets/checkbox/lv_example_checkbox_1.c +++ b/examples/widgets/checkbox/lv_example_checkbox_1.c @@ -36,7 +36,8 @@ void lv_example_checkbox_1(void) lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL); cb = lv_checkbox_create(lv_screen_active()); - lv_obj_add_state(cb, LV_STATE_CHECKED | LV_STATE_DISABLED); + lv_obj_add_state(cb, LV_STATE_CHECKED); + lv_obj_add_state(cb, LV_STATE_DISABLED); lv_checkbox_set_text(cb, "Melon\nand a new line"); lv_obj_add_event_cb(cb, event_handler, LV_EVENT_ALL, NULL); diff --git a/examples/widgets/menu/lv_example_menu_5.c b/examples/widgets/menu/lv_example_menu_5.c index f8ab367efa..c8057ed086 100644 --- a/examples/widgets/menu/lv_example_menu_5.c +++ b/examples/widgets/menu/lv_example_menu_5.c @@ -20,12 +20,12 @@ void lv_example_menu_5(void) { lv_obj_t * menu = lv_menu_create(lv_screen_active()); - lv_color_t bg_color = lv_obj_get_style_bg_color(menu, 0); + lv_color_t bg_color = lv_obj_get_style_bg_color(menu, LV_PART_MAIN); if(lv_color_brightness(bg_color) > 127) { - lv_obj_set_style_bg_color(menu, lv_color_darken(lv_obj_get_style_bg_color(menu, 0), 10), 0); + lv_obj_set_style_bg_color(menu, lv_color_darken(lv_obj_get_style_bg_color(menu, LV_PART_MAIN), 10), 0); } else { - lv_obj_set_style_bg_color(menu, lv_color_darken(lv_obj_get_style_bg_color(menu, 0), 50), 0); + lv_obj_set_style_bg_color(menu, lv_color_darken(lv_obj_get_style_bg_color(menu, LV_PART_MAIN), 50), 0); } lv_menu_set_mode_root_back_button(menu, LV_MENU_ROOT_BACK_BUTTON_ENABLED); lv_obj_add_event_cb(menu, back_event_handler, LV_EVENT_CLICKED, menu); @@ -37,7 +37,7 @@ void lv_example_menu_5(void) /*Create sub pages*/ lv_obj_t * sub_mechanics_page = lv_menu_page_create(menu, NULL); - lv_obj_set_style_pad_hor(sub_mechanics_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), 0), 0); + lv_obj_set_style_pad_hor(sub_mechanics_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), LV_PART_MAIN), 0); lv_menu_separator_create(sub_mechanics_page); section = lv_menu_section_create(sub_mechanics_page); create_slider(section, LV_SYMBOL_SETTINGS, "Velocity", 0, 150, 120); @@ -45,24 +45,26 @@ void lv_example_menu_5(void) create_slider(section, LV_SYMBOL_SETTINGS, "Weight limit", 0, 150, 80); lv_obj_t * sub_sound_page = lv_menu_page_create(menu, NULL); - lv_obj_set_style_pad_hor(sub_sound_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), 0), 0); + lv_obj_set_style_pad_hor(sub_sound_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), LV_PART_MAIN), 0); lv_menu_separator_create(sub_sound_page); section = lv_menu_section_create(sub_sound_page); create_switch(section, LV_SYMBOL_AUDIO, "Sound", false); lv_obj_t * sub_display_page = lv_menu_page_create(menu, NULL); - lv_obj_set_style_pad_hor(sub_display_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), 0), 0); + lv_obj_set_style_pad_hor(sub_display_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), LV_PART_MAIN), 0); lv_menu_separator_create(sub_display_page); section = lv_menu_section_create(sub_display_page); create_slider(section, LV_SYMBOL_SETTINGS, "Brightness", 0, 150, 100); lv_obj_t * sub_software_info_page = lv_menu_page_create(menu, NULL); - lv_obj_set_style_pad_hor(sub_software_info_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), 0), 0); + lv_obj_set_style_pad_hor(sub_software_info_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), LV_PART_MAIN), + 0); section = lv_menu_section_create(sub_software_info_page); create_text(section, NULL, "Version 1.0", LV_MENU_ITEM_BUILDER_VARIANT_1); lv_obj_t * sub_legal_info_page = lv_menu_page_create(menu, NULL); - lv_obj_set_style_pad_hor(sub_legal_info_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), 0), 0); + lv_obj_set_style_pad_hor(sub_legal_info_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), LV_PART_MAIN), + 0); section = lv_menu_section_create(sub_legal_info_page); for(uint32_t i = 0; i < 15; i++) { create_text(section, NULL, @@ -71,7 +73,7 @@ void lv_example_menu_5(void) } lv_obj_t * sub_about_page = lv_menu_page_create(menu, NULL); - lv_obj_set_style_pad_hor(sub_about_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), 0), 0); + lv_obj_set_style_pad_hor(sub_about_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), LV_PART_MAIN), 0); lv_menu_separator_create(sub_about_page); section = lv_menu_section_create(sub_about_page); cont = create_text(section, NULL, "Software information", LV_MENU_ITEM_BUILDER_VARIANT_1); @@ -80,7 +82,7 @@ void lv_example_menu_5(void) lv_menu_set_load_page_event(menu, cont, sub_legal_info_page); lv_obj_t * sub_menu_mode_page = lv_menu_page_create(menu, NULL); - lv_obj_set_style_pad_hor(sub_menu_mode_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), 0), 0); + lv_obj_set_style_pad_hor(sub_menu_mode_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), LV_PART_MAIN), 0); lv_menu_separator_create(sub_menu_mode_page); section = lv_menu_section_create(sub_menu_mode_page); cont = create_switch(section, LV_SYMBOL_AUDIO, "Sidebar enable", true); @@ -88,7 +90,7 @@ void lv_example_menu_5(void) /*Create a root page*/ root_page = lv_menu_page_create(menu, "Settings"); - lv_obj_set_style_pad_hor(root_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), 0), 0); + lv_obj_set_style_pad_hor(root_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), LV_PART_MAIN), 0); section = lv_menu_section_create(root_page); cont = create_text(section, LV_SYMBOL_SETTINGS, "Mechanics", LV_MENU_ITEM_BUILDER_VARIANT_1); lv_menu_set_load_page_event(menu, cont, sub_mechanics_page); @@ -193,7 +195,7 @@ static lv_obj_t * create_switch(lv_obj_t * parent, const char * icon, const char lv_obj_t * obj = create_text(parent, icon, txt, LV_MENU_ITEM_BUILDER_VARIANT_1); lv_obj_t * sw = lv_switch_create(obj); - lv_obj_add_state(sw, chk ? LV_STATE_CHECKED : 0); + lv_obj_add_state(sw, chk ? LV_STATE_CHECKED : LV_STATE_DEFAULT); return obj; } diff --git a/examples/widgets/switch/lv_example_switch_1.c b/examples/widgets/switch/lv_example_switch_1.c index 6b1f640981..0cd13f473b 100644 --- a/examples/widgets/switch/lv_example_switch_1.c +++ b/examples/widgets/switch/lv_example_switch_1.c @@ -31,7 +31,8 @@ void lv_example_switch_1(void) lv_obj_add_event_cb(sw, event_handler, LV_EVENT_ALL, NULL); sw = lv_switch_create(lv_screen_active()); - lv_obj_add_state(sw, LV_STATE_CHECKED | LV_STATE_DISABLED); + lv_obj_add_state(sw, LV_STATE_CHECKED); + lv_obj_add_state(sw, LV_STATE_DISABLED); lv_obj_add_event_cb(sw, event_handler, LV_EVENT_ALL, NULL); } diff --git a/src/core/lv_obj.c b/src/core/lv_obj.c index a6a8274e8e..7b79822c6d 100644 --- a/src/core/lv_obj.c +++ b/src/core/lv_obj.c @@ -649,14 +649,14 @@ static void lv_obj_draw(lv_event_t * e) return; } - if(lv_obj_get_style_bg_grad_dir(obj, 0) != LV_GRAD_DIR_NONE) { - if(lv_obj_get_style_bg_grad_opa(obj, 0) < LV_OPA_MAX || - lv_obj_get_style_bg_main_opa(obj, 0) < LV_OPA_MAX) { + if(lv_obj_get_style_bg_grad_dir(obj, LV_PART_MAIN) != LV_GRAD_DIR_NONE) { + if(lv_obj_get_style_bg_grad_opa(obj, LV_PART_MAIN) < LV_OPA_MAX || + lv_obj_get_style_bg_main_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) { info->res = LV_COVER_RES_NOT_COVER; return; } } - const lv_grad_dsc_t * grad_dsc = lv_obj_get_style_bg_grad(obj, 0); + const lv_grad_dsc_t * grad_dsc = lv_obj_get_style_bg_grad(obj, LV_PART_MAIN); if(grad_dsc) { uint32_t i; for(i = 0; i < grad_dsc->stops_count; i++) { diff --git a/src/core/lv_obj.h b/src/core/lv_obj.h index 8412017e80..e6b4ff44ce 100644 --- a/src/core/lv_obj.h +++ b/src/core/lv_obj.h @@ -38,50 +38,6 @@ extern "C" { /********************** * TYPEDEFS **********************/ - -/** - * Possible states of a widget. - * OR-ed values are possible - */ -enum _lv_state_t { - LV_STATE_DEFAULT = 0x0000, - LV_STATE_CHECKED = 0x0001, - LV_STATE_FOCUSED = 0x0002, - LV_STATE_FOCUS_KEY = 0x0004, - LV_STATE_EDITED = 0x0008, - LV_STATE_HOVERED = 0x0010, - LV_STATE_PRESSED = 0x0020, - LV_STATE_SCROLLED = 0x0040, - LV_STATE_DISABLED = 0x0080, - LV_STATE_USER_1 = 0x1000, - LV_STATE_USER_2 = 0x2000, - LV_STATE_USER_3 = 0x4000, - LV_STATE_USER_4 = 0x8000, - - LV_STATE_ANY = 0xFFFF, /**< Special value can be used in some functions to target all states*/ -}; - -/** - * The possible parts of widgets. - * The parts can be considered as the internal building block of the widgets. - * E.g. slider = background + indicator + knob - * Not all parts are used by every widget - */ - -enum _lv_part_t { - 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. table cells)*/ - LV_PART_CURSOR = 0x060000, /**< Mark a specific place e.g. for text area's cursor or on a chart*/ - - LV_PART_CUSTOM_FIRST = 0x080000, /**< Extension point for custom widgets*/ - - LV_PART_ANY = 0x0F0000, /**< Special value can be used in some functions to target all parts*/ -}; - /** * On/Off features controlling the object's behavior. * OR-ed values are possible diff --git a/src/core/lv_obj_draw.h b/src/core/lv_obj_draw.h index 9df48c5eb7..10ebf993cb 100644 --- a/src/core/lv_obj_draw.h +++ b/src/core/lv_obj_draw.h @@ -20,6 +20,7 @@ extern "C" { #include "../draw/lv_draw_line.h" #include "../draw/lv_draw_arc.h" #include "../draw/lv_draw_triangle.h" +#include "lv_obj_style.h" /********************* * DEFINES diff --git a/src/core/lv_obj_pos.c b/src/core/lv_obj_pos.c index ed84b1cc1e..6e3aa6e493 100644 --- a/src/core/lv_obj_pos.c +++ b/src/core/lv_obj_pos.c @@ -639,12 +639,12 @@ void lv_obj_refr_pos(lv_obj_t * obj) int32_t pw = lv_obj_get_content_width(parent); int32_t ph = lv_obj_get_content_height(parent); if(LV_COORD_IS_PCT(x)) { - if(lv_obj_get_style_width(parent, 0) == LV_SIZE_CONTENT) x = 0; /*Avoid circular dependency*/ + if(lv_obj_get_style_width(parent, LV_PART_MAIN) == LV_SIZE_CONTENT) x = 0; /*Avoid circular dependency*/ else x = (pw * LV_COORD_GET_PCT(x)) / 100; } if(LV_COORD_IS_PCT(y)) { - if(lv_obj_get_style_height(parent, 0) == LV_SIZE_CONTENT) y = 0; /*Avoid circular dependency*/ + if(lv_obj_get_style_height(parent, LV_PART_MAIN) == LV_SIZE_CONTENT) y = 0; /*Avoid circular dependency*/ y = (ph * LV_COORD_GET_PCT(y)) / 100; } @@ -1108,7 +1108,7 @@ static int32_t calc_content_width(lv_obj_t * obj) if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue; if(!lv_obj_is_layout_positioned(child)) { - lv_align_t align = lv_obj_get_style_align(child, 0); + lv_align_t align = lv_obj_get_style_align(child, LV_PART_MAIN); switch(align) { case LV_ALIGN_DEFAULT: case LV_ALIGN_TOP_RIGHT: @@ -1120,7 +1120,7 @@ static int32_t calc_content_width(lv_obj_t * obj) default: /* Consider other cases only if x=0 and use the width of the object. * With x!=0 circular dependency could occur. */ - if(lv_obj_get_style_x(child, 0) == 0) { + if(lv_obj_get_style_x(child, LV_PART_MAIN) == 0) { child_res_tmp = lv_area_get_width(&child->coords) + space_right; child_res_tmp += lv_obj_get_style_margin_left(child, LV_PART_MAIN); } @@ -1144,7 +1144,7 @@ static int32_t calc_content_width(lv_obj_t * obj) if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue; if(!lv_obj_is_layout_positioned(child)) { - lv_align_t align = lv_obj_get_style_align(child, 0); + lv_align_t align = lv_obj_get_style_align(child, LV_PART_MAIN); switch(align) { case LV_ALIGN_DEFAULT: case LV_ALIGN_TOP_LEFT: @@ -1156,7 +1156,7 @@ static int32_t calc_content_width(lv_obj_t * obj) default: /* Consider other cases only if x=0 and use the width of the object. * With x!=0 circular dependency could occur. */ - if(lv_obj_get_style_x(child, 0) == 0) { + if(lv_obj_get_style_x(child, LV_PART_MAIN) == 0) { child_res_tmp = lv_area_get_width(&child->coords) + space_left; child_res_tmp += lv_obj_get_style_margin_right(child, LV_PART_MAIN); } @@ -1201,7 +1201,7 @@ static int32_t calc_content_height(lv_obj_t * obj) if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue; if(!lv_obj_is_layout_positioned(child)) { - lv_align_t align = lv_obj_get_style_align(child, 0); + lv_align_t align = lv_obj_get_style_align(child, LV_PART_MAIN); switch(align) { case LV_ALIGN_DEFAULT: case LV_ALIGN_TOP_RIGHT: @@ -1213,7 +1213,7 @@ static int32_t calc_content_height(lv_obj_t * obj) default: /* Consider other cases only if y=0 and use the height of the object. * With y!=0 circular dependency could occur. */ - if(lv_obj_get_style_y(child, 0) == 0) { + if(lv_obj_get_style_y(child, LV_PART_MAIN) == 0) { child_res_tmp = lv_area_get_height(&child->coords) + space_top; child_res_tmp += lv_obj_get_style_margin_top(child, LV_PART_MAIN); } @@ -1285,17 +1285,17 @@ static void transform_point_array(const lv_obj_t * obj, lv_point_t * p, size_t p } #endif /* LV_DRAW_TRANSFORM_USE_MATRIX */ - int32_t angle = lv_obj_get_style_transform_rotation(obj, 0); - int32_t scale_x = lv_obj_get_style_transform_scale_x_safe(obj, 0); - int32_t scale_y = lv_obj_get_style_transform_scale_y_safe(obj, 0); + int32_t angle = lv_obj_get_style_transform_rotation(obj, LV_PART_MAIN); + int32_t scale_x = lv_obj_get_style_transform_scale_x_safe(obj, LV_PART_MAIN); + int32_t scale_y = lv_obj_get_style_transform_scale_y_safe(obj, LV_PART_MAIN); if(scale_x == 0) scale_x = 1; if(scale_y == 0) scale_y = 1; if(angle == 0 && scale_x == LV_SCALE_NONE && scale_y == LV_SCALE_NONE) return; lv_point_t pivot = { - .x = lv_obj_get_style_transform_pivot_x(obj, 0), - .y = lv_obj_get_style_transform_pivot_y(obj, 0) + .x = lv_obj_get_style_transform_pivot_x(obj, LV_PART_MAIN), + .y = lv_obj_get_style_transform_pivot_y(obj, LV_PART_MAIN) }; if(LV_COORD_IS_PCT(pivot.x)) { diff --git a/src/core/lv_obj_private.h b/src/core/lv_obj_private.h index 747e756eb3..1a6540bf28 100644 --- a/src/core/lv_obj_private.h +++ b/src/core/lv_obj_private.h @@ -67,7 +67,7 @@ struct _lv_obj_t { #endif lv_area_t coords; lv_obj_flag_t flags; - lv_state_t state; + uint16_t state; uint16_t layout_inv : 1; uint16_t readjust_scroll_after_layout : 1; uint16_t scr_layout_inv : 1; diff --git a/src/core/lv_obj_style.c b/src/core/lv_obj_style.c index dc947c986f..8bd2d1d1bb 100644 --- a/src/core/lv_obj_style.c +++ b/src/core/lv_obj_style.c @@ -52,7 +52,7 @@ typedef enum { * STATIC PROTOTYPES **********************/ 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, lv_part_t part); +static lv_obj_style_t * get_trans_style(lv_obj_t * obj, lv_style_selector_t selector); static lv_style_res_t get_prop_core(const lv_obj_t * obj, lv_style_selector_t selector, lv_style_prop_t prop, lv_style_value_t * v); static void report_style_change_core(void * style, lv_obj_t * obj); @@ -272,7 +272,7 @@ void lv_obj_report_style_change(lv_style_t * style) } } -void lv_obj_refresh_style(lv_obj_t * obj, lv_style_selector_t selector, lv_style_prop_t prop) +void lv_obj_refresh_style(lv_obj_t * obj, lv_part_t part, lv_style_prop_t prop) { LV_ASSERT_OBJ(obj, MY_CLASS); @@ -282,8 +282,6 @@ void lv_obj_refresh_style(lv_obj_t * obj, lv_style_selector_t selector, lv_style lv_obj_invalidate(obj); - lv_part_t part = lv_obj_style_get_selector_part(selector); - bool is_layout_refr = lv_style_prop_has_flag(prop, LV_STYLE_PROP_FLAG_LAYOUT_UPDATE); bool is_ext_draw = lv_style_prop_has_flag(prop, LV_STYLE_PROP_FLAG_EXT_DRAW_UPDATE); bool is_inheritable = lv_style_prop_has_flag(prop, LV_STYLE_PROP_FLAG_INHERITABLE); @@ -292,8 +290,8 @@ void lv_obj_refresh_style(lv_obj_t * obj, lv_style_selector_t selector, lv_style if(is_layout_refr) { if(part == LV_PART_ANY || part == LV_PART_MAIN || - lv_obj_get_style_height(obj, 0) == LV_SIZE_CONTENT || - lv_obj_get_style_width(obj, 0) == LV_SIZE_CONTENT) { + lv_obj_get_style_height(obj, LV_PART_MAIN) == LV_SIZE_CONTENT || + lv_obj_get_style_width(obj, LV_PART_MAIN) == LV_SIZE_CONTENT) { lv_obj_send_event(obj, LV_EVENT_STYLE_CHANGED, NULL); lv_obj_mark_layout_as_dirty(obj); } @@ -604,7 +602,7 @@ void lv_obj_fade_out(lv_obj_t * obj, uint32_t time, uint32_t delay) lv_anim_t a; lv_anim_init(&a); lv_anim_set_var(&a, obj); - lv_anim_set_values(&a, lv_obj_get_style_opa(obj, 0), LV_OPA_TRANSP); + lv_anim_set_values(&a, lv_obj_get_style_opa(obj, LV_PART_MAIN), LV_OPA_TRANSP); lv_anim_set_exec_cb(&a, fade_anim_cb); lv_anim_set_duration(&a, time); lv_anim_set_delay(&a, delay); @@ -829,7 +827,7 @@ static lv_style_res_t get_prop_core(const lv_obj_t * obj, lv_style_selector_t se if((state_act & state_inv)) continue; /*Check only better candidates*/ - if(state_act <= weight) continue; + if((int32_t)state_act <= weight) continue; found = lv_style_get_prop_inlined(obj_style->style, prop, v); if(found == LV_STYLE_RES_FOUND) { @@ -1059,14 +1057,14 @@ static lv_layer_type_t calculate_layer_type(lv_obj_t * obj) #if LV_DRAW_TRANSFORM_USE_MATRIX if(lv_obj_get_transform(obj) != NULL) return LV_LAYER_TYPE_TRANSFORM; #endif - if(lv_obj_get_style_transform_rotation(obj, 0) != 0) return LV_LAYER_TYPE_TRANSFORM; - if(lv_obj_get_style_transform_scale_x(obj, 0) != 256) return LV_LAYER_TYPE_TRANSFORM; - if(lv_obj_get_style_transform_scale_y(obj, 0) != 256) return LV_LAYER_TYPE_TRANSFORM; - if(lv_obj_get_style_transform_skew_x(obj, 0) != 0) return LV_LAYER_TYPE_TRANSFORM; - if(lv_obj_get_style_transform_skew_y(obj, 0) != 0) return LV_LAYER_TYPE_TRANSFORM; - if(lv_obj_get_style_opa_layered(obj, 0) != LV_OPA_COVER) return LV_LAYER_TYPE_SIMPLE; - if(lv_obj_get_style_bitmap_mask_src(obj, 0) != NULL) return LV_LAYER_TYPE_SIMPLE; - if(lv_obj_get_style_blend_mode(obj, 0) != LV_BLEND_MODE_NORMAL) return LV_LAYER_TYPE_SIMPLE; + if(lv_obj_get_style_transform_rotation(obj, LV_PART_MAIN) != 0) return LV_LAYER_TYPE_TRANSFORM; + if(lv_obj_get_style_transform_scale_x(obj, LV_PART_MAIN) != 256) return LV_LAYER_TYPE_TRANSFORM; + if(lv_obj_get_style_transform_scale_y(obj, LV_PART_MAIN) != 256) return LV_LAYER_TYPE_TRANSFORM; + if(lv_obj_get_style_transform_skew_x(obj, LV_PART_MAIN) != 0) return LV_LAYER_TYPE_TRANSFORM; + if(lv_obj_get_style_transform_skew_y(obj, LV_PART_MAIN) != 0) return LV_LAYER_TYPE_TRANSFORM; + if(lv_obj_get_style_opa_layered(obj, LV_PART_MAIN) != LV_OPA_COVER) return LV_LAYER_TYPE_SIMPLE; + if(lv_obj_get_style_bitmap_mask_src(obj, LV_PART_MAIN) != NULL) return LV_LAYER_TYPE_SIMPLE; + if(lv_obj_get_style_blend_mode(obj, LV_PART_MAIN) != LV_BLEND_MODE_NORMAL) return LV_LAYER_TYPE_SIMPLE; return LV_LAYER_TYPE_NONE; } diff --git a/src/core/lv_obj_style.h b/src/core/lv_obj_style.h index 95e0458540..a5306d2440 100644 --- a/src/core/lv_obj_style.h +++ b/src/core/lv_obj_style.h @@ -25,6 +25,49 @@ extern "C" { * TYPEDEFS **********************/ +/** + * Possible states of a widget. + * OR-ed values are possible + */ +typedef enum { + LV_STATE_DEFAULT = 0x0000, + LV_STATE_CHECKED = 0x0001, + LV_STATE_FOCUSED = 0x0002, + LV_STATE_FOCUS_KEY = 0x0004, + LV_STATE_EDITED = 0x0008, + LV_STATE_HOVERED = 0x0010, + LV_STATE_PRESSED = 0x0020, + LV_STATE_SCROLLED = 0x0040, + LV_STATE_DISABLED = 0x0080, + LV_STATE_USER_1 = 0x1000, + LV_STATE_USER_2 = 0x2000, + LV_STATE_USER_3 = 0x4000, + LV_STATE_USER_4 = 0x8000, + + LV_STATE_ANY = 0xFFFF, /**< Special value can be used in some functions to target all states*/ +} lv_state_t; + +/** + * The possible parts of widgets. + * The parts can be considered as the internal building block of the widgets. + * E.g. slider = background + indicator + knob + * Not all parts are used by every widget + */ + +typedef enum { + 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. table cells)*/ + LV_PART_CURSOR = 0x060000, /**< Mark a specific place e.g. for text area's cursor or on a chart*/ + + LV_PART_CUSTOM_FIRST = 0x080000, /**< Extension point for custom widgets*/ + + LV_PART_ANY = 0x0F0000, /**< Special value can be used in some functions to target all parts*/ +} lv_part_t; + typedef enum { LV_STYLE_STATE_CMP_SAME, /**< The style properties in the 2 states are identical */ LV_STYLE_STATE_CMP_DIFF_REDRAW, /**< The differences can be shown with a simple redraw */ @@ -208,12 +251,12 @@ void lv_obj_fade_out(lv_obj_t * obj, uint32_t time, uint32_t delay); static inline lv_state_t lv_obj_style_get_selector_state(lv_style_selector_t selector) { - return selector & 0xFFFF; + return (lv_state_t)(selector & 0xFFFF); } static inline lv_part_t lv_obj_style_get_selector_part(lv_style_selector_t selector) { - return selector & 0xFF0000; + return (lv_part_t)(selector & 0xFF0000); } #include "lv_obj_style_gen.h" diff --git a/src/core/lv_refr.c b/src/core/lv_refr.c index 9990f6f00a..d4f86221b8 100644 --- a/src/core/lv_refr.c +++ b/src/core/lv_refr.c @@ -539,7 +539,7 @@ void lv_obj_refr(lv_layer_t * layer, lv_obj_t * obj) layer_area_act.y2 = layer_area_act.y1 + max_rgb_row_height - 1; if(layer_area_act.y2 > layer_area_full.y2) layer_area_act.y2 = layer_area_full.y2; - const void * bitmap_mask_src = lv_obj_get_style_bitmap_mask_src(obj, 0); + const void * bitmap_mask_src = lv_obj_get_style_bitmap_mask_src(obj, LV_PART_MAIN); bool area_need_alpha = bitmap_mask_src || alpha_test_area_on_obj(obj, &layer_area_act); if(area_need_alpha) { @@ -552,8 +552,8 @@ void lv_obj_refr(lv_layer_t * layer, lv_obj_t * obj) lv_obj_redraw(new_layer, obj); lv_point_t pivot = { - .x = lv_obj_get_style_transform_pivot_x(obj, 0), - .y = lv_obj_get_style_transform_pivot_y(obj, 0) + .x = lv_obj_get_style_transform_pivot_x(obj, LV_PART_MAIN), + .y = lv_obj_get_style_transform_pivot_y(obj, LV_PART_MAIN) }; if(LV_COORD_IS_PCT(pivot.x)) { @@ -569,14 +569,14 @@ void lv_obj_refr(lv_layer_t * layer, lv_obj_t * obj) layer_draw_dsc.pivot.y = obj->coords.y1 + pivot.y - new_layer->buf_area.y1; layer_draw_dsc.opa = opa_layered; - layer_draw_dsc.rotation = lv_obj_get_style_transform_rotation(obj, 0); + layer_draw_dsc.rotation = lv_obj_get_style_transform_rotation(obj, LV_PART_MAIN); while(layer_draw_dsc.rotation > 3600) layer_draw_dsc.rotation -= 3600; while(layer_draw_dsc.rotation < 0) layer_draw_dsc.rotation += 3600; - layer_draw_dsc.scale_x = lv_obj_get_style_transform_scale_x(obj, 0); - layer_draw_dsc.scale_y = lv_obj_get_style_transform_scale_y(obj, 0); - layer_draw_dsc.skew_x = lv_obj_get_style_transform_skew_x(obj, 0); - layer_draw_dsc.skew_y = lv_obj_get_style_transform_skew_y(obj, 0); - layer_draw_dsc.blend_mode = lv_obj_get_style_blend_mode(obj, 0); + layer_draw_dsc.scale_x = lv_obj_get_style_transform_scale_x(obj, LV_PART_MAIN); + layer_draw_dsc.scale_y = lv_obj_get_style_transform_scale_y(obj, LV_PART_MAIN); + layer_draw_dsc.skew_x = lv_obj_get_style_transform_skew_x(obj, LV_PART_MAIN); + layer_draw_dsc.skew_y = lv_obj_get_style_transform_skew_y(obj, LV_PART_MAIN); + layer_draw_dsc.blend_mode = lv_obj_get_style_blend_mode(obj, LV_PART_MAIN); layer_draw_dsc.antialias = disp_refr->antialiasing; layer_draw_dsc.bitmap_mask_src = bitmap_mask_src; layer_draw_dsc.image_area = obj_draw_size; @@ -1194,18 +1194,18 @@ static bool obj_get_matrix(lv_obj_t * obj, lv_matrix_t * matrix) } lv_point_t pivot = { - .x = lv_obj_get_style_transform_pivot_x(obj, 0), - .y = lv_obj_get_style_transform_pivot_y(obj, 0) + .x = lv_obj_get_style_transform_pivot_x(obj, LV_PART_MAIN), + .y = lv_obj_get_style_transform_pivot_y(obj, LV_PART_MAIN) }; pivot.x = obj->coords.x1 + lv_pct_to_px(pivot.x, lv_area_get_width(&obj->coords)); pivot.y = obj->coords.y1 + lv_pct_to_px(pivot.y, lv_area_get_height(&obj->coords)); - int32_t rotation = lv_obj_get_style_transform_rotation(obj, 0); - int32_t scale_x = lv_obj_get_style_transform_scale_x(obj, 0); - int32_t scale_y = lv_obj_get_style_transform_scale_y(obj, 0); - int32_t skew_x = lv_obj_get_style_transform_skew_x(obj, 0); - int32_t skew_y = lv_obj_get_style_transform_skew_y(obj, 0); + int32_t rotation = lv_obj_get_style_transform_rotation(obj, LV_PART_MAIN); + int32_t scale_x = lv_obj_get_style_transform_scale_x(obj, LV_PART_MAIN); + int32_t scale_y = lv_obj_get_style_transform_scale_y(obj, LV_PART_MAIN); + int32_t skew_x = lv_obj_get_style_transform_skew_x(obj, LV_PART_MAIN); + int32_t skew_y = lv_obj_get_style_transform_skew_y(obj, LV_PART_MAIN); if(scale_x <= 0 || scale_y <= 0) { /* NOT draw if scale is negative or zero */ @@ -1281,7 +1281,7 @@ static void refr_obj_matrix(lv_layer_t * layer, lv_obj_t * obj) static bool refr_check_obj_clip_overflow(lv_layer_t * layer, lv_obj_t * obj) { - if(lv_obj_get_style_transform_rotation(obj, 0) == 0) { + if(lv_obj_get_style_transform_rotation(obj, LV_PART_MAIN) == 0) { return false; } diff --git a/src/draw/lv_draw.h b/src/draw/lv_draw.h index 3b2c85d3cb..818ae8b850 100644 --- a/src/draw/lv_draw.h +++ b/src/draw/lv_draw.h @@ -149,7 +149,7 @@ typedef struct { lv_obj_t * obj; /**The widget part for which draw descriptor was created */ - lv_part_t part; + uint32_t part; /**A widget type specific ID (e.g. table row index). See the docs of the given widget.*/ uint32_t id1; diff --git a/src/indev/lv_indev.c b/src/indev/lv_indev.c index 55f3b3effe..8f167b2b8e 100644 --- a/src/indev/lv_indev.c +++ b/src/indev/lv_indev.c @@ -1502,9 +1502,9 @@ static void indev_proc_release(lv_indev_t * indev) lv_point_t pivot = { 0, 0 }; lv_obj_t * parent = scroll_obj; while(parent) { - angle += lv_obj_get_style_transform_rotation(parent, 0); - int32_t zoom_act_x = lv_obj_get_style_transform_scale_x_safe(parent, 0); - int32_t zoom_act_y = lv_obj_get_style_transform_scale_y_safe(parent, 0); + angle += lv_obj_get_style_transform_rotation(parent, LV_PART_MAIN); + int32_t zoom_act_x = lv_obj_get_style_transform_scale_x_safe(parent, LV_PART_MAIN); + int32_t zoom_act_y = lv_obj_get_style_transform_scale_y_safe(parent, LV_PART_MAIN); scale_x = (scale_x * zoom_act_x) >> 8; scale_y = (scale_x * zoom_act_y) >> 8; parent = lv_obj_get_parent(parent); @@ -1583,7 +1583,7 @@ static void indev_proc_pointer_diff(lv_indev_t * indev) if(editable) { uint32_t indev_sensitivity = indev->rotary_sensitivity; - uint32_t obj_sensitivity = lv_obj_get_style_rotary_sensitivity(indev_obj_act, 0); + uint32_t obj_sensitivity = lv_obj_get_style_rotary_sensitivity(indev_obj_act, LV_PART_MAIN); int32_t diff = (int32_t)((int32_t)indev->pointer.diff * indev_sensitivity * obj_sensitivity + 32768) >> 16; send_event(LV_EVENT_ROTARY, &diff); } @@ -1595,7 +1595,7 @@ static void indev_proc_pointer_diff(lv_indev_t * indev) lv_obj_t * scroll_obj = lv_indev_find_scroll_obj(indev); if(scroll_obj == NULL) return; uint32_t indev_sensitivity = indev->rotary_sensitivity; - uint32_t obj_sensitivity = lv_obj_get_style_rotary_sensitivity(scroll_obj, 0); + uint32_t obj_sensitivity = lv_obj_get_style_rotary_sensitivity(scroll_obj, LV_PART_MAIN); int32_t diff = (int32_t)((int32_t)indev->pointer.diff * indev_sensitivity * obj_sensitivity + 32768) >> 16; indev->pointer.scroll_throw_vect.y = diff; diff --git a/src/indev/lv_indev_scroll.c b/src/indev/lv_indev_scroll.c index 7996467a46..3de9d3efbe 100644 --- a/src/indev/lv_indev_scroll.c +++ b/src/indev/lv_indev_scroll.c @@ -69,9 +69,9 @@ void lv_indev_scroll_handler(lv_indev_t * indev) int16_t scale_y = 256; lv_obj_t * parent = scroll_obj; while(parent) { - angle += lv_obj_get_style_transform_rotation(parent, 0); - int32_t zoom_act_x = lv_obj_get_style_transform_scale_x_safe(parent, 0); - int32_t zoom_act_y = lv_obj_get_style_transform_scale_y_safe(parent, 0); + angle += lv_obj_get_style_transform_rotation(parent, LV_PART_MAIN); + int32_t zoom_act_x = lv_obj_get_style_transform_scale_x_safe(parent, LV_PART_MAIN); + int32_t zoom_act_y = lv_obj_get_style_transform_scale_y_safe(parent, LV_PART_MAIN); scale_x = (scale_x * zoom_act_x) >> 8; scale_y = (scale_y * zoom_act_y) >> 8; parent = lv_obj_get_parent(parent); @@ -293,9 +293,9 @@ lv_obj_t * lv_indev_find_scroll_obj(lv_indev_t * indev) lv_point_t pivot = { 0, 0 }; lv_obj_t * parent = obj_act; while(parent) { - angle += lv_obj_get_style_transform_rotation(parent, 0); - int32_t zoom_act_x = lv_obj_get_style_transform_scale_x_safe(parent, 0); - int32_t zoom_act_y = lv_obj_get_style_transform_scale_y_safe(parent, 0); + angle += lv_obj_get_style_transform_rotation(parent, LV_PART_MAIN); + int32_t zoom_act_x = lv_obj_get_style_transform_scale_x_safe(parent, LV_PART_MAIN); + int32_t zoom_act_y = lv_obj_get_style_transform_scale_y_safe(parent, LV_PART_MAIN); scale_x = (scale_x * zoom_act_x) >> 8; scale_y = (scale_y * zoom_act_y) >> 8; parent = lv_obj_get_parent(parent); @@ -717,18 +717,18 @@ static void has_more_snap_points(lv_obj_t * scroll_obj, lv_dir_t dir, bool * has int32_t x = 0; switch(snap) { case LV_SCROLL_SNAP_CENTER: { - int32_t pad_left = lv_obj_get_style_pad_left(scroll_obj, 0); - int32_t pad_right = lv_obj_get_style_pad_right(scroll_obj, 0); + int32_t pad_left = lv_obj_get_style_pad_left(scroll_obj, LV_PART_MAIN); + int32_t pad_right = lv_obj_get_style_pad_right(scroll_obj, LV_PART_MAIN); x = scroll_obj->coords.x1; x += (lv_area_get_width(&scroll_obj->coords) - pad_left - pad_right) / 2; x += pad_left; } break; case LV_SCROLL_SNAP_START: - x = scroll_obj->coords.x1 + lv_obj_get_style_pad_left(scroll_obj, 0); + x = scroll_obj->coords.x1 + lv_obj_get_style_pad_left(scroll_obj, LV_PART_MAIN); break; case LV_SCROLL_SNAP_END: - x = scroll_obj->coords.x2 - lv_obj_get_style_pad_right(scroll_obj, 0); + x = scroll_obj->coords.x2 - lv_obj_get_style_pad_right(scroll_obj, LV_PART_MAIN); break; default: break; @@ -743,18 +743,18 @@ static void has_more_snap_points(lv_obj_t * scroll_obj, lv_dir_t dir, bool * has int32_t y = 0; switch(snap) { case LV_SCROLL_SNAP_CENTER: { - int32_t pad_top = lv_obj_get_style_pad_top(scroll_obj, 0); - int32_t pad_bottom = lv_obj_get_style_pad_bottom(scroll_obj, 0); + int32_t pad_top = lv_obj_get_style_pad_top(scroll_obj, LV_PART_MAIN); + int32_t pad_bottom = lv_obj_get_style_pad_bottom(scroll_obj, LV_PART_MAIN); y = scroll_obj->coords.y1; y += (lv_area_get_height(&scroll_obj->coords) - pad_top - pad_bottom) / 2; y += pad_top; } break; case LV_SCROLL_SNAP_START: - y = scroll_obj->coords.y1 + lv_obj_get_style_pad_top(scroll_obj, 0); + y = scroll_obj->coords.y1 + lv_obj_get_style_pad_top(scroll_obj, LV_PART_MAIN); break; case LV_SCROLL_SNAP_END: - y = scroll_obj->coords.y2 - lv_obj_get_style_pad_bottom(scroll_obj, 0); + y = scroll_obj->coords.y2 - lv_obj_get_style_pad_bottom(scroll_obj, LV_PART_MAIN); break; default: break; diff --git a/src/layouts/flex/lv_flex.c b/src/layouts/flex/lv_flex.c index 0f8b7d66a6..b90514bae4 100644 --- a/src/layouts/flex/lv_flex.c +++ b/src/layouts/flex/lv_flex.c @@ -339,7 +339,7 @@ static void children_repos(lv_obj_t * cont, flex_t * f, int32_t item_first_id, i int32_t (*area_get_main_size)(const lv_area_t *) = (f->row ? lv_area_get_width : lv_area_get_height); int32_t (*area_get_cross_size)(const lv_area_t *) = (!f->row ? lv_area_get_width : lv_area_get_height); - typedef int32_t (*margin_func_t)(const lv_obj_t *, uint32_t); + typedef int32_t (*margin_func_t)(const lv_obj_t *, lv_part_t); margin_func_t get_margin_main_start = (f->row ? lv_obj_get_style_margin_left : lv_obj_get_style_margin_top); margin_func_t get_margin_main_end = (f->row ? lv_obj_get_style_margin_right : lv_obj_get_style_margin_bottom); margin_func_t get_margin_cross_start = (!f->row ? lv_obj_get_style_margin_left : lv_obj_get_style_margin_top); diff --git a/src/layouts/grid/lv_grid.c b/src/layouts/grid/lv_grid.c index f04da4303a..79ffa20624 100644 --- a/src/layouts/grid/lv_grid.c +++ b/src/layouts/grid/lv_grid.c @@ -66,43 +66,43 @@ static uint32_t count_tracks(const int32_t * templ); static inline const int32_t * get_col_dsc(lv_obj_t * obj) { - return lv_obj_get_style_grid_column_dsc_array(obj, 0); + return lv_obj_get_style_grid_column_dsc_array(obj, LV_PART_MAIN); } static inline const int32_t * get_row_dsc(lv_obj_t * obj) { - return lv_obj_get_style_grid_row_dsc_array(obj, 0); + return lv_obj_get_style_grid_row_dsc_array(obj, LV_PART_MAIN); } static inline int32_t get_col_pos(lv_obj_t * obj) { - return lv_obj_get_style_grid_cell_column_pos(obj, 0); + return lv_obj_get_style_grid_cell_column_pos(obj, LV_PART_MAIN); } static inline int32_t get_row_pos(lv_obj_t * obj) { - return lv_obj_get_style_grid_cell_row_pos(obj, 0); + return lv_obj_get_style_grid_cell_row_pos(obj, LV_PART_MAIN); } static inline int32_t get_col_span(lv_obj_t * obj) { - return lv_obj_get_style_grid_cell_column_span(obj, 0); + return lv_obj_get_style_grid_cell_column_span(obj, LV_PART_MAIN); } static inline int32_t get_row_span(lv_obj_t * obj) { - return lv_obj_get_style_grid_cell_row_span(obj, 0); + return lv_obj_get_style_grid_cell_row_span(obj, LV_PART_MAIN); } static inline lv_grid_align_t get_cell_col_align(lv_obj_t * obj) { - return lv_obj_get_style_grid_cell_x_align(obj, 0); + return lv_obj_get_style_grid_cell_x_align(obj, LV_PART_MAIN); } static inline lv_grid_align_t get_cell_row_align(lv_obj_t * obj) { - return lv_obj_get_style_grid_cell_y_align(obj, 0); + return lv_obj_get_style_grid_cell_y_align(obj, LV_PART_MAIN); } static inline lv_grid_align_t get_grid_col_align(lv_obj_t * obj) { - return lv_obj_get_style_grid_column_align(obj, 0); + return lv_obj_get_style_grid_column_align(obj, LV_PART_MAIN); } static inline lv_grid_align_t get_grid_row_align(lv_obj_t * obj) { - return lv_obj_get_style_grid_row_align(obj, 0); + return lv_obj_get_style_grid_row_align(obj, LV_PART_MAIN); } static inline int32_t get_margin_hor(lv_obj_t * obj) { diff --git a/src/misc/lv_types.h b/src/misc/lv_types.h index 46cb8a81cb..7bb7a6aea8 100644 --- a/src/misc/lv_types.h +++ b/src/misc/lv_types.h @@ -106,9 +106,6 @@ typedef struct _lv_obj_t lv_obj_t; typedef lv_obj_t * (*lv_screen_create_cb_t)(void); -typedef uint16_t lv_state_t; -typedef uint32_t lv_part_t; - typedef uint8_t lv_opa_t; typedef uint8_t lv_style_prop_t; diff --git a/src/others/gridnav/lv_gridnav.c b/src/others/gridnav/lv_gridnav.c index 5f348af58c..4458fce757 100644 --- a/src/others/gridnav/lv_gridnav.c +++ b/src/others/gridnav/lv_gridnav.c @@ -118,7 +118,7 @@ void lv_gridnav_set_focused(lv_obj_t * cont, lv_obj_t * to_focus, lv_anim_enable lv_obj_remove_state(dsc->focused_obj, LV_STATE_FOCUSED | LV_STATE_FOCUS_KEY); } - lv_obj_add_state(to_focus, LV_STATE_FOCUSED | LV_STATE_FOCUS_KEY); + lv_obj_add_state(to_focus, (lv_state_t)(LV_STATE_FOCUSED | LV_STATE_FOCUS_KEY)); lv_obj_scroll_to_view(to_focus, anim_en); dsc->focused_obj = to_focus; @@ -231,7 +231,7 @@ static void gridnav_event_cb(lv_event_t * e) if(guess && guess != dsc->focused_obj) { lv_obj_remove_state(dsc->focused_obj, LV_STATE_FOCUSED | LV_STATE_FOCUS_KEY); lv_obj_send_event(dsc->focused_obj, LV_EVENT_DEFOCUSED, lv_indev_active()); - lv_obj_add_state(guess, LV_STATE_FOCUSED | LV_STATE_FOCUS_KEY); + lv_obj_add_state(guess, (lv_state_t)(LV_STATE_FOCUSED | LV_STATE_FOCUS_KEY)); lv_obj_send_event(guess, LV_EVENT_FOCUSED, lv_indev_active()); lv_obj_scroll_to_view(guess, LV_ANIM_ON); dsc->focused_obj = guess; @@ -240,7 +240,7 @@ static void gridnav_event_cb(lv_event_t * e) else if(code == LV_EVENT_FOCUSED) { if(dsc->focused_obj == NULL) dsc->focused_obj = find_first_focusable(obj); if(dsc->focused_obj) { - lv_obj_add_state(dsc->focused_obj, LV_STATE_FOCUSED | LV_STATE_FOCUS_KEY); + lv_obj_add_state(dsc->focused_obj, (lv_state_t)(LV_STATE_FOCUSED | LV_STATE_FOCUS_KEY)); lv_obj_remove_state(dsc->focused_obj, LV_STATE_PRESSED); /*Be sure the focuses obj is not stuck in pressed state*/ lv_obj_scroll_to_view(dsc->focused_obj, LV_ANIM_OFF); } @@ -256,7 +256,7 @@ static void gridnav_event_cb(lv_event_t * e) if(dsc->focused_obj == NULL) { dsc->focused_obj = child; if(lv_obj_has_state(obj, LV_STATE_FOCUSED)) { - lv_obj_add_state(child, LV_STATE_FOCUSED | LV_STATE_FOCUS_KEY); + lv_obj_add_state(child, (lv_state_t)(LV_STATE_FOCUSED | LV_STATE_FOCUS_KEY)); lv_obj_scroll_to_view(child, LV_ANIM_OFF); } } diff --git a/src/widgets/3dtexture/lv_3dtexture.c b/src/widgets/3dtexture/lv_3dtexture.c index 8db3f4e4da..a2e4fade16 100644 --- a/src/widgets/3dtexture/lv_3dtexture.c +++ b/src/widgets/3dtexture/lv_3dtexture.c @@ -135,7 +135,7 @@ static void draw_3dtexture(lv_event_t * e) lv_draw_3d_dsc_t dsc; lv_draw_3d_dsc_init(&dsc); dsc.tex_id = tex->id; - dsc.opa = lv_obj_get_style_opa(obj, 0); + dsc.opa = lv_obj_get_style_opa(obj, LV_PART_MAIN); lv_area_t coords; lv_obj_get_coords(obj, &coords); lv_draw_3d(layer, &dsc, &coords); diff --git a/src/widgets/msgbox/lv_msgbox.c b/src/widgets/msgbox/lv_msgbox.c index 3fea09ea26..6fc8b457d8 100644 --- a/src/widgets/msgbox/lv_msgbox.c +++ b/src/widgets/msgbox/lv_msgbox.c @@ -287,7 +287,7 @@ static void msgbox_size_changed_event_cb(lv_event_t * e) { lv_obj_t * mbox = lv_event_get_target(e); lv_obj_t * content = lv_msgbox_get_content(mbox); - bool is_msgbox_height_size_content = (lv_obj_get_style_height(mbox, 0) == LV_SIZE_CONTENT); + bool is_msgbox_height_size_content = (lv_obj_get_style_height(mbox, LV_PART_MAIN) == LV_SIZE_CONTENT); lv_obj_set_flex_grow(content, !is_msgbox_height_size_content); } diff --git a/src/widgets/roller/lv_roller.c b/src/widgets/roller/lv_roller.c index f9ac5c2e92..3700ccb955 100644 --- a/src/widgets/roller/lv_roller.c +++ b/src/widgets/roller/lv_roller.c @@ -151,8 +151,9 @@ void lv_roller_set_options(lv_obj_t * obj, const char * options, lv_roller_mode_ else { roller->mode = LV_ROLLER_MODE_INFINITE; - const lv_font_t * font = lv_obj_get_style_text_font(obj, 0); - int32_t normal_h = roller->option_cnt * (lv_font_get_line_height(font) + lv_obj_get_style_text_letter_space(obj, 0)); + const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN); + int32_t normal_h = roller->option_cnt * (lv_font_get_line_height(font) + lv_obj_get_style_text_letter_space(obj, + LV_PART_MAIN)); roller->inf_page_cnt = LV_CLAMP(3, EXTRA_INF_SIZE / normal_h, 15); if(!(roller->inf_page_cnt & 1)) roller->inf_page_cnt++; /*Make it odd*/ LV_LOG_INFO("Using %" LV_PRIu32 " pages to make the roller look infinite", roller->inf_page_cnt); @@ -883,9 +884,9 @@ static void transform_vect_recursive(lv_obj_t * roller, lv_point_t * vect) int32_t scale_y = 256; lv_obj_t * parent = roller; while(parent) { - angle += lv_obj_get_style_transform_rotation(parent, 0); - int32_t zoom_act_x = lv_obj_get_style_transform_scale_x_safe(parent, 0); - int32_t zoom_act_y = lv_obj_get_style_transform_scale_y_safe(parent, 0); + angle += lv_obj_get_style_transform_rotation(parent, LV_PART_MAIN); + int32_t zoom_act_x = lv_obj_get_style_transform_scale_x_safe(parent, LV_PART_MAIN); + int32_t zoom_act_y = lv_obj_get_style_transform_scale_y_safe(parent, LV_PART_MAIN); scale_x = (scale_x * zoom_act_x) >> 8; scale_y = (scale_y * zoom_act_y) >> 8; parent = lv_obj_get_parent(parent); diff --git a/src/widgets/table/lv_table.c b/src/widgets/table/lv_table.c index 379bde80e0..062e12e62f 100644 --- a/src/widgets/table/lv_table.c +++ b/src/widgets/table/lv_table.c @@ -1114,12 +1114,12 @@ static void get_cell_area(lv_obj_t * obj, uint32_t row, uint32_t col, lv_area_t if(rtl) { area->x1 += lv_obj_get_scroll_x(obj); int32_t w = lv_obj_get_width(obj); - area->x2 = w - area->x1 - lv_obj_get_style_pad_right(obj, 0); + area->x2 = w - area->x1 - lv_obj_get_style_pad_right(obj, LV_PART_MAIN); area->x1 = area->x2 - (table->col_w[col] + offset); } else { area->x1 -= lv_obj_get_scroll_x(obj); - area->x1 += lv_obj_get_style_pad_left(obj, 0); + area->x1 += lv_obj_get_style_pad_left(obj, LV_PART_MAIN); area->x2 = area->x1 + (table->col_w[col] + offset) - 1; } @@ -1129,7 +1129,7 @@ static void get_cell_area(lv_obj_t * obj, uint32_t row, uint32_t col, lv_area_t area->y1 += table->row_h[r]; } - area->y1 += lv_obj_get_style_pad_top(obj, 0); + area->y1 += lv_obj_get_style_pad_top(obj, LV_PART_MAIN); area->y1 -= lv_obj_get_scroll_y(obj); area->y2 = area->y1 + table->row_h[row] - 1; diff --git a/src/widgets/textarea/lv_textarea.c b/src/widgets/textarea/lv_textarea.c index 02026a4025..de146810f7 100644 --- a/src/widgets/textarea/lv_textarea.c +++ b/src/widgets/textarea/lv_textarea.c @@ -1431,7 +1431,7 @@ static void draw_cursor(lv_event_t * e) /*Draw the letter over the cursor only if *the cursor has background or the letter has different color than the original. *Else the original letter is drawn twice which makes it look bolder*/ - lv_color_t label_color = lv_obj_get_style_text_color(ta->label, 0); + lv_color_t label_color = lv_obj_get_style_text_color(ta->label, LV_PART_MAIN); lv_draw_label_dsc_t cur_label_dsc; lv_draw_label_dsc_init(&cur_label_dsc); cur_label_dsc.base.layer = layer; diff --git a/src/widgets/textarea/lv_textarea.h b/src/widgets/textarea/lv_textarea.h index 0fb6d652e5..13c23e2fa1 100644 --- a/src/widgets/textarea/lv_textarea.h +++ b/src/widgets/textarea/lv_textarea.h @@ -26,9 +26,11 @@ extern "C" { * DEFINES *********************/ #define LV_TEXTAREA_CURSOR_LAST (0x7FFF) /*Put the cursor after the last character*/ - LV_EXPORT_CONST_INT(LV_TEXTAREA_CURSOR_LAST); +#define LV_PART_TEXTAREA_PLACEHOLDER LV_PART_CUSTOM_FIRST +LV_EXPORT_CONST_INT(LV_PART_TEXTAREA_PLACEHOLDER); + /********************** * TYPEDEFS **********************/ @@ -56,10 +58,6 @@ enum _lv_property_textarea_id_t { LV_ATTRIBUTE_EXTERN_DATA extern const lv_obj_class_t lv_textarea_class; -enum _lv_part_textarea_id_t { - LV_PART_TEXTAREA_PLACEHOLDER = LV_PART_CUSTOM_FIRST, -}; - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/tests/src/test_cases/libs/test_font_stress.c b/tests/src/test_cases/libs/test_font_stress.c index 43568d782e..fba60f0c5e 100644 --- a/tests/src/test_cases/libs/test_font_stress.c +++ b/tests/src/test_cases/libs/test_font_stress.c @@ -116,7 +116,7 @@ static lv_obj_t * font_stress_label_create(font_stress_ctx_t * ctx, const char * static void font_stress_label_delete(font_stress_ctx_t * ctx, lv_obj_t * label) { - const lv_font_t * font = lv_obj_get_style_text_font(label, 0); + const lv_font_t * font = lv_obj_get_style_text_font(label, LV_PART_MAIN); TEST_ASSERT_NOT_NULL(font); lv_obj_del(label); ctx->font_delete_cb(ctx, (lv_font_t *)font); diff --git a/tests/src/test_cases/widgets/test_msgbox.c b/tests/src/test_cases/widgets/test_msgbox.c index fe9157ed0a..68c943cc22 100644 --- a/tests/src/test_cases/widgets/test_msgbox.c +++ b/tests/src/test_cases/widgets/test_msgbox.c @@ -157,7 +157,7 @@ void test_msgbox_content_auto_height(void) lv_msgbox_add_close_button(msgbox); /* Test1 : msgbox's height is LV_SIZE_CONTENT by default */ - bool is_height_size_content = (lv_obj_get_style_height(msgbox, 0) == LV_SIZE_CONTENT); + bool is_height_size_content = (lv_obj_get_style_height(msgbox, LV_PART_MAIN) == LV_SIZE_CONTENT); TEST_ASSERT_EQUAL(is_height_size_content, 1); lv_obj_update_layout(msgbox); @@ -177,7 +177,7 @@ void test_msgbox_content_auto_height(void) /* Test2 : Now change size of msgbox manually*/ lv_obj_set_size(msgbox, lv_pct(80), lv_pct(80)); - is_height_size_content = (lv_obj_get_style_height(msgbox, 0) == LV_SIZE_CONTENT); + is_height_size_content = (lv_obj_get_style_height(msgbox, LV_PART_MAIN) == LV_SIZE_CONTENT); TEST_ASSERT_EQUAL(is_height_size_content, 0); lv_obj_update_layout(msgbox); diff --git a/tests/src/test_cases/widgets/test_obj_property.c b/tests/src/test_cases/widgets/test_obj_property.c index 1db665fd32..c3381e3c5b 100644 --- a/tests/src/test_cases/widgets/test_obj_property.c +++ b/tests/src/test_cases/widgets/test_obj_property.c @@ -41,7 +41,7 @@ void test_obj_property_set_get_should_match(void) prop.id = LV_PROPERTY_STYLE_X; prop.num = 0xaabb; TEST_ASSERT_TRUE(lv_obj_set_property(obj, &prop) == LV_RESULT_OK); - TEST_ASSERT_EQUAL_UINT32(0xaabb, lv_obj_get_style_x(obj, 0)); + TEST_ASSERT_EQUAL_UINT32(0xaabb, lv_obj_get_style_x(obj, LV_PART_MAIN)); TEST_ASSERT_EQUAL_UINT32(0xaabb, lv_obj_get_property(obj, LV_PROPERTY_STYLE_X).num); /* color type */ @@ -106,7 +106,7 @@ void test_obj_property_style_selector(void) prop.num = 0xaabb; /* `num` shares same memory with `prop.style.value.num` */ /* selector is initialed to zero when prop is defined. */ TEST_ASSERT_TRUE(lv_obj_set_property(obj, &prop) == LV_RESULT_OK); - TEST_ASSERT_EQUAL_UINT32(0xaabb, lv_obj_get_style_x(obj, 0)); + TEST_ASSERT_EQUAL_UINT32(0xaabb, lv_obj_get_style_x(obj, LV_PART_MAIN)); TEST_ASSERT_EQUAL_UINT32(0xaabb, lv_obj_get_style_property(obj, LV_PROPERTY_STYLE_X, 0).num); lv_style_selector_t selector = LV_PART_MAIN | LV_STATE_PRESSED; diff --git a/tests/src/test_cases/widgets/test_switch.c b/tests/src/test_cases/widgets/test_switch.c index 4569fcbc7e..0cb6f69215 100644 --- a/tests/src/test_cases/widgets/test_switch.c +++ b/tests/src/test_cases/widgets/test_switch.c @@ -145,7 +145,7 @@ void test_screeshots(void) sw = lv_switch_create(lv_screen_active()); sw = lv_switch_create(lv_screen_active()); - lv_obj_add_state(sw, LV_STATE_CHECKED | LV_STATE_DISABLED); + lv_obj_add_state(sw, (lv_state_t)(LV_STATE_CHECKED | LV_STATE_DISABLED)); sw = lv_switch_create(lv_screen_active()); lv_switch_set_orientation(sw, LV_SWITCH_ORIENTATION_VERTICAL); diff --git a/tests/src/test_cases/xml/test_xml_style.c b/tests/src/test_cases/xml/test_xml_style.c index 083a6cd511..b8d29029d8 100644 --- a/tests/src/test_cases/xml/test_xml_style.c +++ b/tests/src/test_cases/xml/test_xml_style.c @@ -137,7 +137,7 @@ void test_xml_style_same_name(void) lv_xml_component_register_from_data("comp1", comp1); lv_obj_t * obj = lv_xml_create(lv_screen_active(), "comp1", NULL); - TEST_ASSERT_EQUAL(20, lv_obj_get_style_bg_opa(obj, 0)); + TEST_ASSERT_EQUAL(20, lv_obj_get_style_bg_opa(obj, LV_PART_MAIN)); } @@ -165,7 +165,7 @@ void test_xml_style_remove(void) lv_obj_t * obj = lv_xml_create(lv_screen_active(), "comp1", NULL); /*The first remove_style removed the main style, so the radius should be the default 0*/ - TEST_ASSERT_EQUAL(0, lv_obj_get_style_radius(obj, 0)); + TEST_ASSERT_EQUAL(0, lv_obj_get_style_radius(obj, LV_PART_MAIN)); /*Styles are removed from the knob in the default state*/ TEST_ASSERT_EQUAL(0, lv_obj_get_style_radius(obj, LV_PART_KNOB));