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

Add default cases in lv_tabview.c

This commit is contained in:
Themba Dube 2019-10-31 20:19:21 -04:00
parent 7a0dad4f17
commit 859e14bedc

View File

@ -240,6 +240,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
* to LV_TABVIEW_BTNS_POS_TOP or LV_TABVIEW_BTNS_POS_BOTTOM.
*/
switch(ext->btns_pos) {
default: /*default case is prevented in lv_tabview_set_btns_pos(), but here for safety*/
case LV_TABVIEW_BTNS_POS_NONE:
case LV_TABVIEW_BTNS_POS_TOP:
case LV_TABVIEW_BTNS_POS_BOTTOM:
@ -323,6 +324,7 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an
lv_coord_t cont_x;
switch(ext->btns_pos) {
default: /*default case is prevented in lv_tabview_set_btns_pos(), but here for safety*/
case LV_TABVIEW_BTNS_POS_NONE:
case LV_TABVIEW_BTNS_POS_TOP:
case LV_TABVIEW_BTNS_POS_BOTTOM:
@ -362,9 +364,12 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an
/*Move the indicator*/
const lv_style_t * tabs_style = lv_obj_get_style(ext->btns);
lv_coord_t indic_size;
lv_coord_t indic_pos;
lv_coord_t indic_pos = 0; /*silence uninitialized variable warning*/;
switch(ext->btns_pos) {
default: /*default case is prevented in lv_tabview_set_btns_pos(), but here for safety*/
case LV_TABVIEW_BTNS_POS_NONE:
break;
case LV_TABVIEW_BTNS_POS_TOP:
case LV_TABVIEW_BTNS_POS_BOTTOM:
indic_size = lv_obj_get_width(ext->indic);
@ -382,6 +387,8 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an
#endif
{
switch(ext->btns_pos) {
default: /*default case is prevented in lv_tabview_set_btns_pos(), but here for safety*/
case LV_TABVIEW_BTNS_POS_NONE: break;
case LV_TABVIEW_BTNS_POS_TOP:
case LV_TABVIEW_BTNS_POS_BOTTOM: lv_obj_set_x(ext->indic, indic_pos); break;
case LV_TABVIEW_BTNS_POS_LEFT:
@ -394,6 +401,9 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, lv_anim_enable_t an
a.var = ext->indic;
switch(ext->btns_pos) {
default: /*default case is prevented in lv_tabview_set_btns_pos(), but here for safety*/
case LV_TABVIEW_BTNS_POS_NONE:
break;
case LV_TABVIEW_BTNS_POS_TOP:
case LV_TABVIEW_BTNS_POS_BOTTOM:
a.start = lv_obj_get_x(ext->indic);
@ -480,6 +490,14 @@ void lv_tabview_set_style(lv_obj_t * tabview, lv_tabview_style_t type, const lv_
*/
void lv_tabview_set_btns_pos(lv_obj_t * tabview, lv_tabview_btns_pos_t btns_pos)
{
if(btns_pos != LV_TABVIEW_BTNS_POS_NONE &&
btns_pos != LV_TABVIEW_BTNS_POS_TOP &&
btns_pos != LV_TABVIEW_BTNS_POS_BOTTOM &&
btns_pos != LV_TABVIEW_BTNS_POS_LEFT &&
btns_pos != LV_TABVIEW_BTNS_POS_RIGHT) {
LV_LOG_WARN("lv_tabview_set_btns_pos: unexpected button position");
return;
}
LV_ASSERT_OBJ(tabview, LV_OBJX_NAME);
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
@ -806,8 +824,11 @@ static void refr_indic_size(lv_obj_t * tabview)
lv_coord_t max_h;
switch(ext->btns_pos) {
default: /*default case is prevented in lv_tabview_set_btns_pos(), but here for safety*/
case LV_TABVIEW_BTNS_POS_NONE:
lv_obj_set_hidden(ext->indic, true);
indic_w = 0;
indic_h = 0;
break;
case LV_TABVIEW_BTNS_POS_TOP:
case LV_TABVIEW_BTNS_POS_BOTTOM:
@ -855,6 +876,7 @@ static void refr_btns_size(lv_obj_t * tabview)
lv_coord_t btns_h;
switch(ext->btns_pos) {
default: /*default case is prevented in lv_tabview_set_btns_pos(), but here for safety*/
case LV_TABVIEW_BTNS_POS_NONE:
btns_w = 0;
btns_h = 0;
@ -890,6 +912,7 @@ static void refr_content_size(lv_obj_t * tabview)
lv_coord_t cont_h;
switch(ext->btns_pos) {
default: /*default case is prevented in lv_tabview_set_btns_pos(), but here for safety*/
case LV_TABVIEW_BTNS_POS_NONE:
cont_w = lv_obj_get_width(tabview);
cont_h = lv_obj_get_height(tabview);
@ -927,6 +950,7 @@ static void refr_align(lv_obj_t * tabview)
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
switch(ext->btns_pos) {
default: /*default case is prevented in lv_tabview_set_btns_pos(), but here for safety*/
case LV_TABVIEW_BTNS_POS_NONE:
lv_obj_align(ext->content, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
break;