lv_tabview: set the first tab as active when added
This commit is contained in:
@@ -253,31 +253,30 @@ static bool roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void *
|
||||
}
|
||||
|
||||
/*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->line_space) + ext->ddlist.opt_label->cords.y1 - roller_scrl->cords.y1;
|
||||
cord_t new_y = - line_y1 + (h - font_h) / 2;
|
||||
if(id != -1) {
|
||||
cord_t h = lv_obj_get_height(roller);
|
||||
cord_t line_y1 = id * (font_h + style_label->line_space) + ext->ddlist.opt_label->cords.y1 - roller_scrl->cords.y1;
|
||||
cord_t new_y = - line_y1 + (h - font_h) / 2;
|
||||
|
||||
if(ext->ddlist.anim_time == 0) {
|
||||
lv_obj_set_y(roller_scrl, new_y);
|
||||
} else {
|
||||
anim_t a;
|
||||
a.var = roller_scrl;
|
||||
a.start = lv_obj_get_y(roller_scrl);
|
||||
a.end = new_y;
|
||||
a.fp = (anim_fp_t)lv_obj_set_y;
|
||||
a.path = anim_get_path(ANIM_PATH_LIN);
|
||||
a.end_cb = NULL;
|
||||
a.act_time = 0;
|
||||
a.time = ext->ddlist.anim_time;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
anim_create(&a);
|
||||
}
|
||||
if(ext->ddlist.anim_time == 0) {
|
||||
lv_obj_set_y(roller_scrl, new_y);
|
||||
} else {
|
||||
anim_t a;
|
||||
a.var = roller_scrl;
|
||||
a.start = lv_obj_get_y(roller_scrl);
|
||||
a.end = new_y;
|
||||
a.fp = (anim_fp_t)lv_obj_set_y;
|
||||
a.path = anim_get_path(ANIM_PATH_LIN);
|
||||
a.end_cb = NULL;
|
||||
a.act_time = 0;
|
||||
a.time = ext->ddlist.anim_time;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
anim_create(&a);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
|
||||
@@ -205,6 +205,12 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
|
||||
lv_obj_set_width(ext->indic, indic_width);
|
||||
lv_obj_set_x(ext->indic, indic_width * ext->tab_act + style_tabs->opad * ext->tab_act + style_tabs->hpad);
|
||||
|
||||
/*Set the first tab as active*/
|
||||
if(ext->tab_cnt == 1) {
|
||||
ext->tab_act = 0;
|
||||
lv_tabview_set_act(tabview, 0, false);
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user