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

minor fixes

This commit is contained in:
Gabor Kiss-Vamosi 2020-10-13 16:41:55 +02:00
parent 778c2a5cb7
commit 68058eeff1
5 changed files with 133 additions and 20 deletions

View File

@ -48,7 +48,7 @@
#define LV_OBJX_NAME "lv_obj"
#define LV_OBJ_DEF_WIDTH (LV_DPX(100))
#define LV_OBJ_DEF_HEIGHT (LV_DPX(50))
#define GRID_DEBUG 0 /*Draw rectangles on grid cells*/
#define GRID_DEBUG 1 /*Draw rectangles on grid cells*/
/**********************
* TYPEDEFS
@ -1759,13 +1759,13 @@ static lv_design_res_t lv_obj_design(lv_obj_t * obj, const lv_area_t * clip_area
uint32_t row;
uint32_t col;
for(row = 0; row < calc.row_dsc_len - 1; row ++) {
for(col = 0; col < calc.col_dsc_len - 1; col ++) {
for(row = 0; row < calc.row_num; row ++) {
for(col = 0; col < calc.col_num; col ++) {
lv_area_t a;
a.x1 = grid_abs.x + calc.col_dsc[col];
a.x2 = grid_abs.x + calc.col_dsc[col + 1];
a.y1 = grid_abs.y + calc.row_dsc[row];
a.y2 = grid_abs.y + calc.row_dsc[row + 1];
a.x1 = grid_abs.x + calc.x[col];
a.x2 = a.x1 + calc.w[col];
a.y1 = grid_abs.y + calc.y[row];
a.y2 = a.y1 + calc.h[row];
lv_draw_rect(&a, clip_area, &grid_rect_dsc);
}
}
@ -1914,6 +1914,17 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param)
_lv_grid_full_refresh(obj);
}
}
/* If the parent has an implicit grid in a direction and this object (whose child has changed)
* is stretched in that direction then the grid of the parent might have changed because
* the track size of implicit grids with stretched cells is calculated from the children bounding box.*/
lv_obj_t * par = lv_obj_get_parent(obj);
if(par && _lv_obj_is_grid_item(obj) &&
((par->grid->col_dsc == NULL && _GRID_GET_CELL_FLAG(obj->x_set) == LV_GRID_STRETCH) ||
(par->grid->row_dsc == NULL && _GRID_GET_CELL_FLAG(obj->y_set) == LV_GRID_STRETCH))) {
_lv_grid_full_refresh(par);
}
}
else if(sign == LV_SIGNAL_SCROLL) {
res = lv_event_send(obj, LV_EVENT_SCROLL, NULL);

View File

@ -264,19 +264,120 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
LV_ASSERT_OBJ(base, LV_OBJX_NAME);
lv_point_t new_pos;
_lv_area_align(&base->coords, &obj->coords, align, &new_pos);
// lv_point_t new_pos;
// _lv_area_align(&base->coords, &obj->coords, align, &new_pos);
/*Bring together the coordination system of base and obj*/
lv_obj_t * par = lv_obj_get_parent(obj);
lv_coord_t par_abs_x = par->coords.x1;
lv_coord_t par_abs_y = par->coords.y1;
new_pos.x += x_ofs;
new_pos.y += y_ofs;
new_pos.x -= par_abs_x;
new_pos.y -= par_abs_y;
lv_obj_set_pos(obj, new_pos.x, new_pos.y);
lv_coord_t x;
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;
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;
y = 0;
break;
case LV_ALIGN_IN_TOP_RIGHT:
x = lv_obj_get_width_fit(base) - lv_obj_get_width_fit(obj);
y = 0;
break;
case LV_ALIGN_IN_BOTTOM_LEFT:
x = 0;
y = lv_obj_get_height_fit(base) - lv_obj_get_height_fit(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);
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);
break;
case LV_ALIGN_IN_LEFT_MID:
x = 0;
y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height_fit(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;
break;
case LV_ALIGN_OUT_TOP_LEFT:
x = 0;
y = -lv_obj_get_height_fit(obj);
break;
case LV_ALIGN_OUT_TOP_MID:
x = lv_obj_get_width_fit(base) / 2 - lv_obj_get_width_fit(obj) / 2;
y = -lv_obj_get_height_fit(obj);
break;
case LV_ALIGN_OUT_TOP_RIGHT:
x = lv_obj_get_width_fit(base) - lv_obj_get_width_fit(obj);
y = -lv_obj_get_height_fit(obj);
break;
case LV_ALIGN_OUT_BOTTOM_LEFT:
x = 0;
y = lv_obj_get_height_fit(base);
break;
case LV_ALIGN_OUT_BOTTOM_MID:
x = lv_obj_get_width_fit(base) / 2 - lv_obj_get_width_fit(obj) / 2;
y = lv_obj_get_height_fit(base);
break;
case LV_ALIGN_OUT_BOTTOM_RIGHT:
x = lv_obj_get_width_fit(base) - lv_obj_get_width_fit(obj);
y = lv_obj_get_height_fit(base);
break;
case LV_ALIGN_OUT_LEFT_TOP:
x = -lv_obj_get_width_fit(obj);
y = 0;
break;
case LV_ALIGN_OUT_LEFT_MID:
x = -lv_obj_get_width_fit(obj);
y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height_fit(obj) / 2;
break;
case LV_ALIGN_OUT_LEFT_BOTTOM:
x = -lv_obj_get_width_fit(obj);
y = lv_obj_get_height_fit(base) - lv_obj_get_height_fit(obj);
break;
case LV_ALIGN_OUT_RIGHT_TOP:
x = lv_obj_get_width_fit(base);
y = 0;
break;
case LV_ALIGN_OUT_RIGHT_MID:
x = lv_obj_get_width_fit(base);
y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height_fit(obj) / 2;
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);
break;
}
x += x_ofs;
y += y_ofs;
lv_obj_set_pos(obj, x, y);
}

View File

@ -314,7 +314,7 @@ lv_anim_value_t lv_anim_path_ease_in_out(const lv_anim_path_t * path, const lv_a
else
t = (uint32_t)((uint32_t)a->act_time * 1024) / a->time;
int32_t step = _lv_bezier3(t, 0, 0, 1024, 1024);
int32_t step = _lv_bezier3(t, 0, 64, 1024 - 64, 1024);
int32_t new_value;
new_value = (int32_t)step * (a->end - a->start);

View File

@ -25,7 +25,7 @@
*********************/
/*Add memory junk on alloc (0xaa) and free(0xbb) (just for testing purposes)*/
#ifndef LV_MEM_ADD_JUNK
#define LV_MEM_ADD_JUNK 0
#define LV_MEM_ADD_JUNK 1
#endif
#ifndef LV_MEM_FULL_DEFRAG_CNT

View File

@ -71,6 +71,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * parent, const lv_obj_t * copy)
/*Set layout if the button is not a screen*/
if(parent) {
lv_obj_set_size(btn, LV_DPI, LV_DPI / 3);
lv_obj_clear_flag(btn, LV_OBJ_FLAG_SCROLLABLE);
}
lv_theme_apply(btn, LV_THEME_BTN);