diff --git a/demos/stress/lv_demo_stress.c b/demos/stress/lv_demo_stress.c index ef864f9321..c4b3437ded 100644 --- a/demos/stress/lv_demo_stress.c +++ b/demos/stress/lv_demo_stress.c @@ -209,7 +209,7 @@ static void obj_test_task_cb(lv_timer_t * tmr) obj = lv_dropdown_create(main_page); lv_dropdown_set_options(obj, "Zero\nOne\nTwo\nThree\nFour\nFive\nSix\nSeven\nEight"); lv_dropdown_open(obj); - lv_dropdown_set_selected(obj, 2, LV_ANIM_ON); + lv_dropdown_set_selected(obj, 2); auto_delete(obj, LV_DEMO_STRESS_TIME_STEP * 3 + 11); break; diff --git a/docs/src/details/widgets/dropdown.rst b/docs/src/details/widgets/dropdown.rst index ce7da652ba..9e22874d25 100644 --- a/docs/src/details/widgets/dropdown.rst +++ b/docs/src/details/widgets/dropdown.rst @@ -87,7 +87,7 @@ the options string's contents must remain available for the life of the Drop-Dow List and :cpp:func:`lv_dropdown_add_option` cannot be used. You can select an option programmatically with -:cpp:expr:`lv_dropdown_set_selected(dropdown, id, LV_ANIM_ON/LV_ANIM_OFF)`, where ``id`` is the index of +:cpp:expr:`lv_dropdown_set_selected(dropdown, id)`, where ``id`` is the index of the target option. Get selected option diff --git a/env_support/pikascript/pika_lv_wegit.c b/env_support/pikascript/pika_lv_wegit.c index df3fd614b9..122347cf53 100644 --- a/env_support/pikascript/pika_lv_wegit.c +++ b/env_support/pikascript/pika_lv_wegit.c @@ -264,9 +264,9 @@ void pika_lvgl_dropdown_set_dir(PikaObj *self, int dir){ lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj"); lv_dropdown_set_dir(lv_obj, dir); } -void pika_lvgl_dropdown_set_selected(PikaObj *self, int sel_opt, int anim){ +void pika_lvgl_dropdown_set_selected(PikaObj *self, int sel_opt){ lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj"); - lv_dropdown_set_selected(lv_obj, sel_opt, anim); + lv_dropdown_set_selected(lv_obj, sel_opt); } void pika_lvgl_dropdown_set_selected_highlight(PikaObj *self, int en){ lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj"); @@ -361,4 +361,4 @@ void pika_lvgl_textarea_set_one_line(PikaObj* self, int en) { lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj"); lv_textarea_set_one_line(lv_obj, en); } -#endif +#endif \ No newline at end of file diff --git a/src/others/observer/lv_observer.c b/src/others/observer/lv_observer.c index dd4f125019..2603561a90 100644 --- a/src/others/observer/lv_observer.c +++ b/src/others/observer/lv_observer.c @@ -898,7 +898,7 @@ static void dropdown_value_changed_event_cb(lv_event_t * e) static void dropdown_value_observer_cb(lv_observer_t * observer, lv_subject_t * subject) { - lv_dropdown_set_selected(observer->target, subject->value.num, LV_ANIM_OFF); + lv_dropdown_set_selected(observer->target, subject->value.num); } #endif /*LV_USE_DROPDOWN*/ diff --git a/src/others/xml/parsers/lv_xml_dropdown_parser.c b/src/others/xml/parsers/lv_xml_dropdown_parser.c index 928a7059e6..153ec25d90 100644 --- a/src/others/xml/parsers/lv_xml_dropdown_parser.c +++ b/src/others/xml/parsers/lv_xml_dropdown_parser.c @@ -57,7 +57,7 @@ void lv_xml_dropdown_apply(lv_xml_parser_state_t * state, const char ** attrs) if(lv_streq("options", name)) lv_dropdown_set_options(item, value); else if(lv_streq("text", name)) lv_dropdown_set_text(item, value); - else if(lv_streq("selected", name)) lv_dropdown_set_selected(item, lv_xml_atoi(value), LV_ANIM_OFF); + else if(lv_streq("selected", name)) lv_dropdown_set_selected(item, lv_xml_atoi(value)); else if(lv_streq("symbol", name)) lv_dropdown_set_symbol(item, lv_xml_get_image(&state->scope, value)); else if(lv_streq("bind_value", name)) { lv_subject_t * subject = lv_xml_get_subject(&state->scope, value); diff --git a/src/widgets/calendar/lv_calendar_header_dropdown.c b/src/widgets/calendar/lv_calendar_header_dropdown.c index 2052981827..6a696958d0 100644 --- a/src/widgets/calendar/lv_calendar_header_dropdown.c +++ b/src/widgets/calendar/lv_calendar_header_dropdown.c @@ -174,10 +174,10 @@ static void value_changed_event_cb(lv_event_t * e) const uint32_t year = (year_p[0] - '0') * 1000 + (year_p[1] - '0') * 100 + (year_p[2] - '0') * 10 + (year_p[3] - '0'); - lv_dropdown_set_selected(year_dd, year - cur_date->year, LV_ANIM_OFF); + lv_dropdown_set_selected(year_dd, year - cur_date->year); lv_obj_t * month_dd = lv_obj_get_child(header, 1); - lv_dropdown_set_selected(month_dd, cur_date->month - 1, LV_ANIM_OFF); + lv_dropdown_set_selected(month_dd, cur_date->month - 1); } #endif /*LV_USE_CALENDAR_HEADER_ARROW*/ diff --git a/src/widgets/dropdown/lv_dropdown.c b/src/widgets/dropdown/lv_dropdown.c index c913670060..5de58b9d1a 100644 --- a/src/widgets/dropdown/lv_dropdown.c +++ b/src/widgets/dropdown/lv_dropdown.c @@ -336,7 +336,7 @@ void lv_dropdown_clear_options(lv_obj_t * obj) if(dropdown->list) lv_obj_invalidate(dropdown->list); } -void lv_dropdown_set_selected(lv_obj_t * obj, uint32_t sel_opt, lv_anim_enable_t anim) +void lv_dropdown_set_selected(lv_obj_t * obj, uint32_t sel_opt) { LV_ASSERT_OBJ(obj, MY_CLASS); @@ -347,7 +347,7 @@ void lv_dropdown_set_selected(lv_obj_t * obj, uint32_t sel_opt, lv_anim_enable_t dropdown->sel_opt_id_orig = dropdown->sel_opt_id; if(dropdown->list) { - position_to_selected(obj, anim); + position_to_selected(obj, LV_ANIM_OFF); } lv_obj_invalidate(obj); diff --git a/src/widgets/dropdown/lv_dropdown.h b/src/widgets/dropdown/lv_dropdown.h index 67f2b09f10..c9f55be12f 100644 --- a/src/widgets/dropdown/lv_dropdown.h +++ b/src/widgets/dropdown/lv_dropdown.h @@ -36,8 +36,8 @@ enum { LV_PROPERTY_ID(DROPDOWN, TEXT, LV_PROPERTY_TYPE_TEXT, 0), LV_PROPERTY_ID(DROPDOWN, OPTIONS, LV_PROPERTY_TYPE_TEXT, 1), LV_PROPERTY_ID(DROPDOWN, OPTION_COUNT, LV_PROPERTY_TYPE_INT, 2), + LV_PROPERTY_ID(DROPDOWN, SELECTED, LV_PROPERTY_TYPE_INT, 3), // LV_PROPERTY_ID(DROPDOWN, SELECTED_STR, LV_PROPERTY_TYPE_TEXT, 4), - LV_PROPERTY_ID2(DROPDOWN, SELECTED, LV_PROPERTY_TYPE_INT, LV_PROPERTY_TYPE_BOOL, 3), LV_PROPERTY_ID(DROPDOWN, DIR, LV_PROPERTY_TYPE_INT, 5), LV_PROPERTY_ID(DROPDOWN, SYMBOL, LV_PROPERTY_TYPE_TEXT, 6), LV_PROPERTY_ID(DROPDOWN, SELECTED_HIGHLIGHT, LV_PROPERTY_TYPE_INT, 7), @@ -108,9 +108,8 @@ void lv_dropdown_clear_options(lv_obj_t * obj); * Set the selected option * @param obj pointer to drop-down list object * @param sel_opt id of the selected option (0 ... number of option - 1); - * @param anim LV_ANIM_ON: set the selected option with an animation; LV_ANIM_OFF: set the option immediately */ -void lv_dropdown_set_selected(lv_obj_t * obj, uint32_t sel_opt, lv_anim_enable_t anim); +void lv_dropdown_set_selected(lv_obj_t * obj, uint32_t sel_opt); /** * Set the direction of the a drop-down list diff --git a/tests/src/test_cases/widgets/test_dropdown.c b/tests/src/test_cases/widgets/test_dropdown.c index 9d420f4c05..d78dd45bf9 100644 --- a/tests/src/test_cases/widgets/test_dropdown.c +++ b/tests/src/test_cases/widgets/test_dropdown.c @@ -117,7 +117,7 @@ void test_dropdown_set_options(void) void test_dropdown_select(void) { lv_obj_t * dd1 = lv_dropdown_create(lv_screen_active()); - lv_dropdown_set_selected(dd1, 2, LV_ANIM_OFF); + lv_dropdown_set_selected(dd1, 2); TEST_ASSERT_EQUAL(2, lv_dropdown_get_selected(dd1)); @@ -131,7 +131,7 @@ void test_dropdown_select(void) TEST_ASSERT_EQUAL_STRING("Opt", buf); /*Out of range*/ - lv_dropdown_set_selected(dd1, 3, LV_ANIM_OFF); + lv_dropdown_set_selected(dd1, 3); TEST_ASSERT_EQUAL(2, lv_dropdown_get_selected(dd1)); } @@ -323,12 +323,12 @@ void test_dropdown_render_1(void) lv_obj_t * dd1 = lv_dropdown_create(lv_screen_active()); lv_obj_set_pos(dd1, 10, 10); - lv_dropdown_set_selected(dd1, 1, LV_ANIM_OFF); + lv_dropdown_set_selected(dd1, 1); lv_obj_t * dd2 = lv_dropdown_create(lv_screen_active()); lv_obj_set_pos(dd2, 200, 10); lv_obj_set_width(dd2, 200); - lv_dropdown_set_selected(dd2, 2, LV_ANIM_OFF); + lv_dropdown_set_selected(dd2, 2); lv_dropdown_open(dd2); TEST_ASSERT_TRUE(lv_dropdown_get_selected_highlight(dd2)); lv_dropdown_set_selected_highlight(dd2, false); @@ -342,7 +342,7 @@ void test_dropdown_render_1(void) lv_dropdown_set_text(dd3, "A text"); TEST_ASSERT_EQUAL_STRING("A text", lv_dropdown_get_text(dd3)); - lv_dropdown_set_selected(dd3, 2, LV_ANIM_OFF); + lv_dropdown_set_selected(dd3, 2); TEST_ASSERT_EQUAL(LV_DIR_BOTTOM, lv_dropdown_get_dir(dd3)); lv_dropdown_set_dir(dd3, LV_DIR_LEFT); @@ -357,7 +357,7 @@ void test_dropdown_render_1(void) lv_obj_t * list = lv_dropdown_get_list(dd3); lv_obj_set_style_text_line_space(list, 5, 0); lv_obj_set_style_bg_color(list, lv_color_hex3(0xf00), LV_PART_SELECTED | LV_STATE_CHECKED); - lv_dropdown_set_selected(dd3, 3, LV_ANIM_OFF); + lv_dropdown_set_selected(dd3, 3); TEST_ASSERT_EQUAL_SCREENSHOT("widgets/dropdown_1.png"); } @@ -474,8 +474,7 @@ void test_dropdown_properties(void) TEST_ASSERT_EQUAL(2, lv_obj_get_property(obj, LV_PROPERTY_DROPDOWN_OPTION_COUNT).num); prop.id = LV_PROPERTY_DROPDOWN_SELECTED; - prop.arg1.num = 1; - prop.arg2.enable = LV_ANIM_OFF; + prop.num = 1; TEST_ASSERT_TRUE(lv_obj_set_property(obj, &prop) == LV_RESULT_OK); TEST_ASSERT_EQUAL_INT(1, lv_dropdown_get_selected(obj)); TEST_ASSERT_EQUAL_INT(1, lv_obj_get_property(obj, LV_PROPERTY_DROPDOWN_SELECTED).num);