Most of my drop down lists are created dynamically, and it does not make sense to allocate static memory for the storage of the options. I have to guess the maximum size of the options and have a list sitting in memory for each drop down, even it is it not currently used. I could handle dynamic memory allocation outside the lv functions but that would just be duplication.
I propose adding functionality to the dropdown list to allow dynamical option storage in a similar way that label uses the static_txt flag.
The first step will be to add another function to set the options with a string which is stored in allocated memory:
void lv_dropdown_set_options(lv_obj_t * ddlist, const char * options);
void lv_dropdown_set_options_dynamic(lv_obj_t * ddlist, const char * options);
The first decision is whether we should follow the convention of the label and default to dynamic storage or keep the current default of static storage
void lv_dropdown_set_options(lv_obj_t * ddlist, const char * options);
void lv_dropdown_set_static_options(lv_obj_t * ddlist, const char * options);
Then the next logical thing would be to add a function which adds another option to the list. That would simplify the loop I use to create the options string. Not that efficient, since it would realloc for even added option, but I don’t think that is a big concern.
void lv_dropdown_add_option(lv_obj_t * ddlist, const char * option);
Also this would not work for static option lists, so depending on the previous decision the function might be
void lv_dropdown_add_option_dynamic(lv_obj_t * ddlist, const char * option);
My preference is to default to dynamic storage.
Any comments?