simpilfy flex constants
This commit is contained in:
@@ -263,15 +263,15 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
|
||||
lv_coord_t y;
|
||||
switch(align) {
|
||||
case LV_ALIGN_CENTER:
|
||||
x = lv_obj_get_width_fit(base) / 2 - lv_obj_get_width_fit(obj) / 2;
|
||||
y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height_fit(obj) / 2;
|
||||
x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
||||
y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
||||
break;
|
||||
case LV_ALIGN_IN_TOP_LEFT:
|
||||
x = 0;
|
||||
y = 0;
|
||||
break;
|
||||
case LV_ALIGN_IN_TOP_MID:
|
||||
x = lv_obj_get_width_fit(base) / 2 - lv_obj_get_width_fit(obj) / 2;
|
||||
x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
||||
y = 0;
|
||||
break;
|
||||
|
||||
@@ -282,26 +282,26 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
|
||||
|
||||
case LV_ALIGN_IN_BOTTOM_LEFT:
|
||||
x = 0;
|
||||
y = lv_obj_get_height_fit(base) - lv_obj_get_height_fit(obj);
|
||||
y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
||||
break;
|
||||
case LV_ALIGN_IN_BOTTOM_MID:
|
||||
x = lv_obj_get_width_fit(base) / 2 - lv_obj_get_width_fit(obj) / 2;
|
||||
y = lv_obj_get_height_fit(base) - lv_obj_get_height_fit(obj);
|
||||
x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
||||
y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_BOTTOM_RIGHT:
|
||||
x = lv_obj_get_width_fit(base) - lv_obj_get_width_fit(obj);
|
||||
y = lv_obj_get_height_fit(base) - lv_obj_get_height_fit(obj);
|
||||
x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
||||
y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_LEFT_MID:
|
||||
x = 0;
|
||||
y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height_fit(obj) / 2;
|
||||
y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_IN_RIGHT_MID:
|
||||
x = lv_obj_get_width_fit(base) - lv_obj_get_width_fit(obj);
|
||||
y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height_fit(obj) / 2;
|
||||
x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
||||
y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_TOP_LEFT:
|
||||
@@ -360,13 +360,14 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_RIGHT_BOTTOM:
|
||||
x = lv_obj_get_width_fit(base);
|
||||
y = lv_obj_get_height_fit(base) - lv_obj_get_height_fit(obj);
|
||||
x = lv_obj_get_width(base);
|
||||
y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
||||
break;
|
||||
}
|
||||
|
||||
x += x_ofs + base->coords.x1;
|
||||
y += y_ofs + base->coords.y1;
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
x += x_ofs + base->coords.x1 - parent->coords.x1 - lv_obj_get_style_pad_left(parent, LV_OBJ_PART_MAIN);
|
||||
y += y_ofs + base->coords.y1 - parent->coords.y1 - lv_obj_get_style_pad_top(parent, LV_OBJ_PART_MAIN);
|
||||
|
||||
lv_obj_set_pos(obj, x, y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user