App style added + minor mods
This commit is contained in:
@@ -41,6 +41,7 @@ static void lv_rect_refr_layout(lv_obj_t * rect);
|
||||
static void lv_rect_layout_col(lv_obj_t * rect);
|
||||
static void lv_rect_layout_row(lv_obj_t * rect);
|
||||
static void lv_rect_layout_center(lv_obj_t * rect);
|
||||
static void lv_rect_layout_pretty(lv_obj_t * rect);
|
||||
static void lv_rect_layout_grid(lv_obj_t * rect);
|
||||
static void lv_rect_refr_autofit(lv_obj_t * rect);
|
||||
static void lv_rects_init(void);
|
||||
@@ -364,6 +365,9 @@ static void lv_rect_refr_layout(lv_obj_t * rect)
|
||||
{
|
||||
lv_rect_layout_t type = lv_rect_get_layout(rect);
|
||||
|
||||
/*'rect' has to be at least 1 child*/
|
||||
if(lv_obj_get_child(rect, NULL) == NULL) return;
|
||||
|
||||
if(type == LV_RECT_LAYOUT_OFF) return;
|
||||
|
||||
if(type == LV_RECT_LAYOUT_CENTER) {
|
||||
@@ -372,7 +376,9 @@ static void lv_rect_refr_layout(lv_obj_t * rect)
|
||||
lv_rect_layout_col(rect);
|
||||
} else if(type == LV_RECT_LAYOUT_ROW_T || type == LV_RECT_LAYOUT_ROW_M || type == LV_RECT_LAYOUT_ROW_B) {
|
||||
lv_rect_layout_row(rect);
|
||||
} else if(type == LV_RECT_LAYOUT_GRID) {
|
||||
} else if(type == LV_RECT_LAYOUT_PRETTY) {
|
||||
lv_rect_layout_pretty(rect);
|
||||
} else if(type == LV_RECT_LAYOUT_GRID) {
|
||||
lv_rect_layout_grid(rect);
|
||||
}
|
||||
}
|
||||
@@ -510,11 +516,11 @@ static void lv_rect_layout_center(lv_obj_t * rect)
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the grid layout. Put as many object as possible in row
|
||||
* Handle the pretty layout. Put as many object as possible in row
|
||||
* then begin a new row
|
||||
* @param rect pointer to an object which layout should be handled
|
||||
*/
|
||||
static void lv_rect_layout_grid(lv_obj_t * rect)
|
||||
static void lv_rect_layout_pretty(lv_obj_t * rect)
|
||||
{
|
||||
lv_obj_t * child_rs; /* Row starter child */
|
||||
lv_obj_t * child_rc; /* Row closer child */
|
||||
@@ -585,6 +591,47 @@ static void lv_rect_layout_grid(lv_obj_t * rect)
|
||||
rect->child_chg_off = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the grid layout. Align same-sized objects in a grid
|
||||
* @param rect pointer to an object which layout should be handled
|
||||
*/
|
||||
static void lv_rect_layout_grid(lv_obj_t * rect)
|
||||
{
|
||||
lv_obj_t * child;
|
||||
lv_rects_t * style = lv_obj_get_style(rect);
|
||||
cord_t w_tot = lv_obj_get_width(rect);
|
||||
cord_t w_obj = lv_obj_get_width(lv_obj_get_child(rect, NULL));
|
||||
cord_t h_obj = lv_obj_get_height(lv_obj_get_child(rect, NULL));
|
||||
uint16_t obj_row = (w_tot - (2 * style->hpad)) / (w_obj + style->opad); /*Obj. num. in a row*/
|
||||
cord_t x_ofs = w_obj + (w_tot - (2 * style->hpad) - (obj_row * w_obj)) / (obj_row - 1);
|
||||
cord_t y_ofs = h_obj + style->opad;
|
||||
|
||||
/* Disable child change action because the children will be moved a lot
|
||||
* an unnecessary child change signals could be sent*/
|
||||
rect->child_chg_off = 1;
|
||||
|
||||
/* Align the children */
|
||||
cord_t act_x = style->hpad;
|
||||
cord_t act_y = style->vpad;
|
||||
uint16_t obj_cnt = 0;
|
||||
LL_READ_BACK(rect->child_ll, child) {
|
||||
if(lv_obj_get_hidden(child) != false) continue;
|
||||
|
||||
lv_obj_set_pos(child, act_x, act_y);
|
||||
act_x += x_ofs;
|
||||
obj_cnt ++;
|
||||
|
||||
if(obj_cnt >= obj_row) {
|
||||
obj_cnt = 0;
|
||||
act_x = style->hpad;
|
||||
act_y += y_ofs;
|
||||
}
|
||||
}
|
||||
|
||||
rect->child_chg_off = 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle auto fit. Set the size of the object to involve all children.
|
||||
* @param rect pointer to an object which size will be modified
|
||||
|
||||
Reference in New Issue
Block a user