fixes and updates according to test results

This commit is contained in:
Gabor Kiss-Vamosi
2017-10-26 21:20:10 +02:00
parent 816327f4f7
commit f0080b944d
23 changed files with 432 additions and 422 deletions

View File

@@ -74,9 +74,9 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy)
lv_page_set_rel_action(new_roller, NULL); /*Handle roller specific actions*/
lv_cont_set_fit(lv_page_get_scrl(new_roller), true, false); /*Height is specified directly*/
lv_obj_set_signal_func(scrl, roller_scrl_signal);
lv_ddlist_open(new_roller, true, 0);
lv_ddlist_open(new_roller, false);
lv_style_t * style_label = lv_obj_get_style(ext->ddlist.opt_label);
lv_style_t * style_label = lv_obj_get_style(ext->ddlist.options_label);
lv_ddlist_set_fix_height(new_roller, (font_get_height(style_label->text.font) >> FONT_ANTIALIAS) * 3
+ style_label->text.space_line * 4);
lv_obj_refresh_style(new_roller); /*To set scrollable size automatically*/
@@ -112,15 +112,15 @@ bool lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * param)
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
if(sign == LV_SIGNAL_STYLE_CHG) {
lv_obj_set_height(lv_page_get_scrl(roller),
lv_obj_get_height(ext->ddlist.opt_label) + lv_obj_get_height(roller));
lv_obj_align(ext->ddlist.opt_label, NULL, LV_ALIGN_CENTER, 0, 0);
lv_ddlist_set_selected(roller, ext->ddlist.sel_opt);
lv_obj_get_height(ext->ddlist.options_label) + lv_obj_get_height(roller));
lv_obj_align(ext->ddlist.options_label, NULL, LV_ALIGN_CENTER, 0, 0);
lv_ddlist_set_selected(roller, ext->ddlist.selected_option_id);
} else if(sign == LV_SIGNAL_CORD_CHG) {
lv_ddlist_set_fix_height(roller, lv_obj_get_height(roller));
lv_obj_set_height(lv_page_get_scrl(roller),
lv_obj_get_height(ext->ddlist.opt_label) + lv_obj_get_height(roller));
lv_obj_align(ext->ddlist.opt_label, NULL, LV_ALIGN_CENTER, 0, 0);
lv_ddlist_set_selected(roller, ext->ddlist.sel_opt);
lv_obj_get_height(ext->ddlist.options_label) + lv_obj_get_height(roller));
lv_obj_align(ext->ddlist.options_label, NULL, LV_ALIGN_CENTER, 0, 0);
lv_ddlist_set_selected(roller, ext->ddlist.selected_option_id);
}
}
@@ -193,10 +193,10 @@ static bool lv_roller_design(lv_obj_t * roller, const area_t * mask, lv_design_m
area_t rect_area;
rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->text.space_line - 2;
rect_area.y2 = rect_area.y1 + font_h + style->text.space_line;
rect_area.x1 = ext->ddlist.opt_label->coords.x1 - style->body.padding.horizontal;
rect_area.x1 = ext->ddlist.options_label->coords.x1 - style->body.padding.hor;
rect_area.x2 = rect_area.x1 + lv_obj_get_width(lv_page_get_scrl(roller));
lv_draw_rect(&rect_area, mask, ext->ddlist.style_sel);
lv_draw_rect(&rect_area, mask, ext->ddlist.selected_style);
}
/*Post draw when the children are drawn*/
else if(mode == LV_DESIGN_DRAW_POST) {
@@ -227,36 +227,36 @@ static bool roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void *
int32_t id = -1;
lv_obj_t * roller = lv_obj_get_parent(roller_scrl);
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
lv_style_t * style_label = lv_obj_get_style(ext->ddlist.opt_label);
lv_style_t * style_label = lv_obj_get_style(ext->ddlist.options_label);
const font_t * font = style_label->text.font;
cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS;
if(sign == LV_SIGNAL_DRAG_END) {
/*If dragged then align the list to there be an element in the middle*/
cord_t label_y1 = ext->ddlist.opt_label->coords.y1 - roller->coords.y1;
cord_t label_y1 = ext->ddlist.options_label->coords.y1 - roller->coords.y1;
cord_t label_unit = (font_get_height(style_label->text.font) >> FONT_ANTIALIAS) + style_label->text.space_line / 2;
cord_t mid = (roller->coords.y2 - roller->coords.y1) / 2;
id = (mid - label_y1) / label_unit;
if(id < 0) id = 0;
if(id >= ext->ddlist.num_opt) id = ext->ddlist.num_opt - 1;
ext->ddlist.sel_opt = id;
if(id >= ext->ddlist.option_cnt) id = ext->ddlist.option_cnt - 1;
ext->ddlist.selected_option_id = id;
}
else if(sign == LV_SIGNAL_RELEASED) {
/*If picked an option by clicking then set it*/
if(!lv_indev_is_dragging(indev)) {
point_t p;
lv_indev_get_point(indev, &p);
p.y = p.y - ext->ddlist.opt_label->coords.y1;
p.y = p.y - ext->ddlist.options_label->coords.y1;
id = p.y / (font_h + style_label->text.space_line);
if(id < 0) id = 0;
if(id >= ext->ddlist.num_opt) id = ext->ddlist.num_opt - 1;
ext->ddlist.sel_opt = id;
if(id >= ext->ddlist.option_cnt) id = ext->ddlist.option_cnt - 1;
ext->ddlist.selected_option_id = id;
}
}
/*Position the scrollable according to the new selected option*/
if(id != -1) {
cord_t h = lv_obj_get_height(roller);
cord_t line_y1 = id * (font_h + style_label->text.space_line) + ext->ddlist.opt_label->coords.y1 - roller_scrl->coords.y1;
cord_t line_y1 = id * (font_h + style_label->text.space_line) + ext->ddlist.options_label->coords.y1 - roller_scrl->coords.y1;
cord_t new_y = - line_y1 + (h - font_h) / 2;
if(ext->ddlist.anim_time == 0) {