1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

Adding lv_cpicker_set_type

This commit is contained in:
Paul Peavyhouse 2019-09-24 21:06:51 -07:00
parent 93cef9e121
commit c4e9f69868
2 changed files with 34 additions and 11 deletions

View File

@ -118,19 +118,9 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy)
ext->color_mode = LV_CPICKER_COLOR_MODE_HUE;
ext->color_mode_fixed = 0;
ext->last_click = 0;
ext->type = LV_CPICKER_DEF_TYPE;
/*The signal and design functions are not copied so set them here*/
if(ext->type == LV_CPICKER_TYPE_DISC)
{
lv_obj_set_signal_cb(new_cpicker, lv_cpicker_disc_signal);
lv_obj_set_design_cb(new_cpicker, lv_cpicker_disc_design);
}
else if(ext->type == LV_CPICKER_TYPE_RECT)
{
lv_obj_set_signal_cb(new_cpicker, lv_cpicker_rect_signal);
lv_obj_set_design_cb(new_cpicker, lv_cpicker_rect_design);
}
lv_cpicker_set_type(new_cpicker, LV_CPICKER_DEF_TYPE);
/*If no copy do the basic initialization*/
if(copy == NULL) {
@ -158,6 +148,32 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy)
* Setter functions
*====================*/
/**
* Set a new type for a cpicker
* @param cpicker pointer to a cpicker object
* @param type new type of the cpicker (from 'lv_cpicker_type_t' enum)
*/
void lv_cpicker_set_type(lv_obj_t * cpicker, lv_cpicker_type_t type)
{
lv_cpicker_ext_t * ext = lv_obj_get_ext_attr(cpicker);
if(ext->type == type) return;
ext->type = type;
if(ext->type == LV_CPICKER_TYPE_DISC)
{
lv_obj_set_signal_cb(cpicker, lv_cpicker_disc_signal);
lv_obj_set_design_cb(cpicker, lv_cpicker_disc_design);
}
else if(ext->type == LV_CPICKER_TYPE_RECT)
{
lv_obj_set_signal_cb(cpicker, lv_cpicker_rect_signal);
lv_obj_set_design_cb(cpicker, lv_cpicker_rect_design);
}
lv_obj_invalidate(cpicker);
}
/**
* Set a style of a colorpicker.
* @param cpicker pointer to colorpicker object

View File

@ -96,6 +96,13 @@ lv_obj_t * lv_cpicker_create(lv_obj_t * par, const lv_obj_t * copy);
* Setter functions
*====================*/
/**
* Set a new type for a colorpicker
* @param cpicker pointer to a colorpicker object
* @param type new type of the colorpicker (from 'lv_cpicker_type_t' enum)
*/
void lv_cpicker_set_type(lv_obj_t * chart, lv_cpicker_type_t type);
/**
* Set a style of a colorpicker.
* @param cpicker pointer to colorpicker object