BigW Consortium Gitlab

Commit 70805142 by Kiss-Vamosi Gabor

layouts moved to rectangles

parent aca65294
......@@ -27,9 +27,6 @@
static void lv_obj_pos_child_refr(lv_obj_t* obj_dp, cord_t x_diff, cord_t y_diff);
static void lv_style_refr_core(void * style_p, lv_obj_t* obj_dp);
static bool lv_obj_design(lv_obj_t* obj_dp, const area_t * mask_p, lv_design_mode_t mode);
static void lv_obj_refr_layout(lv_obj_t * obj_dp);
static void lv_layout_col(lv_obj_t * obj_dp);
static void lv_layout_row(lv_obj_t * obj_dp);
/**********************
* STATIC VARIABLES
......@@ -311,18 +308,6 @@ bool lv_obj_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param)
switch(sign) {
case LV_SIGNAL_CHILD_CHG:
if(obj_dp->child_chg_off != 0) valid = false;
else lv_obj_refr_layout(obj_dp);
break;
case LV_SIGNAL_CORD_CHG:
if(param == NULL)
{
break;
}
if(lv_obj_get_width(obj_dp) != area_get_width(param) ||
lv_obj_get_height(obj_dp) != area_get_height(param)) {
lv_obj_refr_layout(obj_dp);
}
break;
default:
break;
......@@ -607,44 +592,6 @@ void lv_obj_set_height_us(lv_obj_t* obj_dp, cord_t h)
lv_obj_set_size(obj_dp, lv_obj_get_width(obj_dp), h * LV_DOWNSCALE);
}
/**
* Set a layout for an object.
* @param obj_dp pointer to an object
* @param layout type of the layout (an element from lv_layout_t)
*/
void lv_obj_set_layout(lv_obj_t* obj_dp, lv_layout_t layout)
{
obj_dp->layout_type = layout;
/*Send signal to refresh the layout*/
obj_dp->signal_f(obj_dp, LV_SIGNAL_CHILD_CHG, NULL);
}
/**
* Set the layout spacing for an object.
* @param obj_dp pointer to an object
* @param space space between object on the layout (space / 2 on edges)
*/
void lv_obj_set_layout_space(lv_obj_t * obj_dp, cord_t space)
{
obj_dp->layout_space = space;
/*Send signal to refresh the layout*/
obj_dp->signal_f(obj_dp, LV_SIGNAL_CHILD_CHG, NULL);
}
/**
* Set the layout spacing for an object.
* The space will be upscaled to compensate LV_DOWNSCALE
* @param obj_dp pointer to an object
* @param space space between object on the layout (space / 2 on edges)
*/
void lv_obj_set_layout_space_us(lv_obj_t * obj_dp, cord_t space)
{
lv_obj_set_layout_space(obj_dp, space * LV_DOWNSCALE);
}
/**
* Align an object to an other object.
* @param obj_dp pointer to an object to align
......@@ -1132,26 +1079,6 @@ cord_t lv_obj_get_height(lv_obj_t* obj_dp)
return area_get_height(&obj_dp->cords);
}
/**
* Get the layout type of an object
* @param obj_dp pointer to an object
* @return type of the layout (from lv_layout_t)
*/
lv_layout_t lv_obj_get_layout(lv_obj_t * obj_dp)
{
return obj_dp->layout_type;
}
/**
* Get the layout space of an object
* @param obj_dp pointer to an object
* @return the layout space
*/
cord_t lv_obj_get_layout_space(lv_obj_t * obj_dp)
{
return obj_dp->layout_space;
}
/*-----------------
* Appearance get
*---------------*/
......@@ -1373,146 +1300,3 @@ static void lv_style_refr_core(void * style_p, lv_obj_t* obj_dp)
}
/**
* Refresh the layout of an object
* @param obj_dp pointer to an object which layout should be refreshed
*/
static void lv_obj_refr_layout(lv_obj_t * obj_dp)
{
lv_layout_t type = obj_dp->layout_type;
if(type == LV_LAYOUT_OFF) return;
if(type == LV_LAYOUT_COL_L || type == LV_LAYOUT_COL_M || type == LV_LAYOUT_COL_R) {
lv_layout_col(obj_dp);
} else if(type == LV_LAYOUT_ROW_T || type == LV_LAYOUT_ROW_M || type == LV_LAYOUT_ROW_B) {
lv_layout_row(obj_dp);
}
}
/**
* Handle column type layouts
* @param obj_dp pointer to an object which layout should be handled
*/
static void lv_layout_col(lv_obj_t * obj_dp)
{
lv_layout_t type = lv_obj_get_layout(obj_dp);
cord_t space = lv_obj_get_layout_space(obj_dp); /*Space between objects*/
cord_t margin = abs(space); /*Margin by the parent*/
lv_obj_t * child;
/*Recalculate space in justified mode*/
if(space < 0) {
uint32_t h_tot = 0;
uint32_t obj_cnt = 0;
LL_READ(obj_dp->child_ll, child) {
h_tot += lv_obj_get_height(child);
obj_cnt ++;
}
if(obj_cnt == 0) return;
space = lv_obj_get_height(obj_dp) - h_tot;
if(obj_cnt == 5) {
obj_cnt = 5;
}
space = space / (cord_t)obj_cnt;
}
/*Adjust margin and get the alignment type*/
lv_align_t align;
switch(type) {
case LV_LAYOUT_COL_L:
align = LV_ALIGN_IN_TOP_LEFT;
margin = margin / 2;
break;
case LV_LAYOUT_COL_M:
align = LV_ALIGN_IN_TOP_MID;
margin = 0;
break;
case LV_LAYOUT_COL_R:
align = LV_ALIGN_IN_TOP_RIGHT;
margin = -(margin / 2);
break;
default:
align = LV_ALIGN_IN_TOP_LEFT;
margin = 0;
break;
}
/* Disable child change action because the children will be moved a lot
* an unnecessary child change signals could be sent*/
obj_dp->child_chg_off = 1;
/* Align the children */
cord_t last_cord = space / 2;
LL_READ_BACK(obj_dp->child_ll, child) {
lv_obj_align(child, obj_dp, align, margin , last_cord);
last_cord += lv_obj_get_height(child) + space;
}
obj_dp->child_chg_off = 0;
}
/**
* Handle row type layouts
* @param obj_dp pointer to an object which layout should be handled
*/
static void lv_layout_row(lv_obj_t * obj_dp)
{
lv_layout_t type = lv_obj_get_layout(obj_dp);
cord_t space = lv_obj_get_layout_space(obj_dp); /*Space between objects*/
cord_t margin = abs(space); /*Margin by the parent*/
lv_obj_t * child;
/*Recalculate space in justified mode*/
if(space < 0) {
uint32_t w_tot = 0;
uint32_t obj_cnt = 0;
LL_READ(obj_dp->child_ll, child) {
w_tot += lv_obj_get_width(child);
obj_cnt ++;
}
if(obj_cnt == 0) return;
space = lv_obj_get_width(obj_dp) - w_tot;
space = space / (cord_t)obj_cnt;
}
/*Adjust margin and get the alignment type*/
lv_align_t align;
switch(type) {
case LV_LAYOUT_ROW_T:
align = LV_ALIGN_IN_TOP_LEFT;
margin = margin / 2;
break;
case LV_LAYOUT_ROW_M:
align = LV_ALIGN_IN_LEFT_MID;
margin = 0;
break;
case LV_LAYOUT_ROW_B:
align = LV_ALIGN_IN_BOTTOM_LEFT;
margin = -(margin / 2);
break;
default:
align = LV_ALIGN_IN_TOP_LEFT;
margin = 0;
break;
}
/* Disable child change action because the children will be moved a lot
* an unnecessary child change signals could be sent*/
obj_dp->child_chg_off = 1;
/* Align the children */
cord_t last_cord = space / 2;
LL_READ_BACK(obj_dp->child_ll, child) {
lv_obj_align(child, obj_dp, align, last_cord, margin);
last_cord += lv_obj_get_width(child) + space;
}
obj_dp->child_chg_off = 0;
}
......@@ -70,18 +70,6 @@ typedef enum
LV_SIGNAL_STYLE_CHG,
}lv_signal_t;
typedef enum
{
LV_LAYOUT_OFF = 0,
LV_LAYOUT_COL_L,
LV_LAYOUT_COL_M,
LV_LAYOUT_COL_R,
LV_LAYOUT_ROW_T,
LV_LAYOUT_ROW_M,
LV_LAYOUT_ROW_B,
}lv_layout_t;
typedef bool (* lv_signal_f_t) (struct __LV_OBJ_T* obj_dp, lv_signal_t sign, void * param);
typedef struct __LV_OBJ_T
......@@ -101,10 +89,6 @@ typedef struct __LV_OBJ_T
void * free_p; /*Application specific pointer (set it freely)*/
#endif
/*Layout settings*/
cord_t layout_space;
uint8_t layout_type;
/*Attributes and states*/
uint8_t click_en :1; /*1: can be pressed by a display input device*/
uint8_t drag_en :1; /*1: enable the dragging*/
......@@ -189,9 +173,6 @@ void lv_obj_set_width(lv_obj_t* obj_dp, cord_t w);
void lv_obj_set_width_us(lv_obj_t* obj_dp, cord_t w);
void lv_obj_set_height(lv_obj_t* obj_dp, cord_t h);
void lv_obj_set_height_us(lv_obj_t* obj_dp, cord_t h);
void lv_obj_set_layout(lv_obj_t* obj_dp, lv_layout_t layout);
void lv_obj_set_layout_space(lv_obj_t * obj_dp, cord_t space);
void lv_obj_set_layout_space_us(lv_obj_t * obj_dp, cord_t space);
void lv_obj_align(lv_obj_t* obj_dp,lv_obj_t* base_dp, lv_align_t align, cord_t x_mod, cord_t y_mod);
void lv_obj_align_us(lv_obj_t* obj_dp,lv_obj_t* base_dp, lv_align_t align, cord_t x_mod, cord_t y_mod);
/*Appearance set*/
......@@ -228,8 +209,6 @@ cord_t lv_obj_get_x(lv_obj_t* obj_dp);
cord_t lv_obj_get_y(lv_obj_t* obj_dp);
cord_t lv_obj_get_width(lv_obj_t* obj_dp);
cord_t lv_obj_get_height(lv_obj_t* obj_dp);
lv_layout_t lv_obj_get_layout(lv_obj_t * obj_dp);
cord_t lv_obj_get_layout_space(lv_obj_t * obj_dp);
/*Appearance get*/
bool lv_obj_get_hidden(lv_obj_t* obj_dp);
opa_t lv_obj_get_opa(lv_obj_t* obj_dp);
......
......@@ -62,6 +62,7 @@ static lv_btns_t lv_btns_def =
.rects.round = 4 * LV_STYLE_MULT,
.rects.hpad = 10 * LV_STYLE_MULT,
.rects.vpad = 15 * LV_STYLE_MULT,
.rects.opad = 5 * LV_STYLE_MULT,
};
static lv_btns_t lv_btns_transp =
{
......@@ -69,6 +70,7 @@ static lv_btns_t lv_btns_transp =
.rects.empty = 1,
.rects.hpad = 10 * LV_STYLE_MULT,
.rects.vpad = 15 * LV_STYLE_MULT,
.rects.opad = 10 * LV_STYLE_MULT,
};
static lv_btns_t lv_btns_border =
......@@ -84,6 +86,7 @@ static lv_btns_t lv_btns_border =
.rects.round = 4 * LV_STYLE_MULT,
.rects.hpad = 10 * LV_STYLE_MULT,
.rects.vpad = 15 * LV_STYLE_MULT,
.rects.vpad = 10 * LV_STYLE_MULT,
};
/**********************
......@@ -122,8 +125,7 @@ lv_obj_t* lv_btn_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
btn_ext_dp->lpr_action = NULL;
btn_ext_dp->tgl = 0;
lv_obj_set_style(new_obj_dp, &lv_btns_def);
lv_obj_set_layout(new_obj_dp, LV_LAYOUT_COL_M);
lv_obj_set_layout_space_us(new_obj_dp, -40); /*Justified align*/
lv_rect_set_layout(new_obj_dp, LV_LAYOUT_CENTER);
}
/*Copy 'copy_dp'*/
else{
......
......@@ -10,6 +10,8 @@
#if USE_LV_LIST != 0
#include "lv_list.h"
#include "lv_rect.h"
#include "lv_label.h"
/*********************
* DEFINES
......@@ -32,16 +34,20 @@ static lv_lists_t lv_lists_def =
/*Page style*/
.pages.bg_rects.objs.color = COLOR_WHITE, .pages.bg_rects.gcolor = COLOR_SILVER, .pages.bg_rects.bcolor = COLOR_GRAY,
.pages.bg_rects.bopa = 50, .pages.bg_rects.bwidth = 0 * LV_STYLE_MULT, .pages.bg_rects.round = 2 * LV_STYLE_MULT,
.pages.bg_rects.empty = 0, .pages.bg_rects.hpad = 0, .pages.bg_rects.vpad = 0,
.pages.bg_rects.empty = 0,
.pages.bg_rects.vpad = 40,
.pages.bg_rects.hpad = 20,
.pages.bg_rects.opad = 10,
.pages.sb_rects.objs.color = COLOR_BLACK, .pages.sb_rects.gcolor = COLOR_BLACK, .pages.sb_rects.bcolor = COLOR_WHITE,
.pages.sb_rects.bopa = 50, .pages.sb_rects.bwidth = 1 * LV_STYLE_MULT, .pages.sb_rects.round = 5 * LV_STYLE_MULT,
.pages.sb_rects.empty = 0, .pages.sb_width= 8 * LV_STYLE_MULT, .pages.sb_opa=50, .pages.sb_mode = LV_PAGE_SB_MODE_ON,
.pages.margin_hor = 0 * LV_STYLE_MULT, .pages.margin_ver = 0 * LV_STYLE_MULT,
.pages.margin_ver = 0 * LV_STYLE_MULT,
.pages.margin_ver = 0 * LV_STYLE_MULT,
/*List style*/
.list_layout = LV_LAYOUT_COL_M, .list_layout_space = 0 * LV_STYLE_MULT,
.list_layout = LV_LAYOUT_CENTER,
/*List element style*/
.liste_btns.mcolor[LV_BTN_STATE_REL] = COLOR_MAKE(0xa0, 0xa0, 0xa0), .liste_btns.gcolor[LV_BTN_STATE_REL] = COLOR_WHITE, .liste_btns.bcolor[LV_BTN_STATE_REL] = COLOR_WHITE,
......@@ -51,9 +57,11 @@ static lv_lists_t lv_lists_def =
.liste_btns.mcolor[LV_BTN_STATE_INA] = COLOR_SILVER, .liste_btns.gcolor[LV_BTN_STATE_INA] = COLOR_GRAY, .liste_btns.bcolor[LV_BTN_STATE_INA] = COLOR_WHITE,
.liste_btns.rects.bwidth = 2 * LV_STYLE_MULT, .liste_btns.rects.bopa = 50,
.liste_btns.rects.empty = 0, .liste_btns.rects.round = 4 * LV_STYLE_MULT,
.liste_btns.rects.hpad = 10 * LV_STYLE_MULT, .liste_btns.rects.vpad = 15 * LV_STYLE_MULT,
.liste_btns.rects.hpad = 10 * LV_STYLE_MULT,
.liste_btns.rects.vpad = 20 * LV_STYLE_MULT,
.liste_btns.rects.opad = 5 * LV_STYLE_MULT,
.liste_layout = LV_LAYOUT_ROW_M, .liste_layout_space = 50 * LV_STYLE_MULT,
.liste_layout = LV_LAYOUT_ROW_M,
};
/**********************
......@@ -82,8 +90,7 @@ lv_obj_t* lv_list_create(lv_obj_t* par_dp, lv_obj_t * copy_dp)
/*Init the new list object*/
lv_obj_set_style(new_obj_dp, &lv_lists_def.pages);
lv_obj_set_layout(new_obj_dp, lv_lists_def.list_layout);
lv_obj_set_layout_space(new_obj_dp, lv_lists_def.list_layout_space);
lv_rect_set_layout(new_obj_dp, lv_lists_def.list_layout);
return new_obj_dp;
}
......@@ -114,12 +121,23 @@ bool lv_list_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param)
}
void lv_list_add(lv_obj_t * obj_dp)
void lv_list_add(lv_obj_t * obj_dp, const char * img_fn, const char * txt, void (*release) (lv_obj_t *))
{
lv_obj_t * liste;
liste = lv_btn_create(obj_dp, NULL);
lv_obj_set_style(liste, &lv_lists_def.liste_btns);
//lv_btn_set_rel_action(liste, release);
lv_page_glue_obj(liste, true);
lv_rect_set_layout(liste, lv_lists_def.liste_layout);
lv_rect_set_fit(liste, true, true);
if(img_fn != NULL) {
}
lv_obj_t * label = lv_label_create(liste, NULL);
lv_label_set_text(label, txt);
}
/**
......
......@@ -49,6 +49,9 @@ typedef enum
typedef struct
{
lv_page_ext_t page_ext;
uint8_t fit_size :1; /*Automatically set the size of list elements to the holder */
uint8_t sel_en :1; /*Enable selecting list elements by toggling them */
uint8_t sel_one :1; /*Enable to select only one list element*/
}lv_list_ext_t;
......@@ -57,7 +60,7 @@ typedef struct
**********************/
lv_obj_t* lv_list_create(lv_obj_t* par_dp, lv_obj_t * copy_dp);
bool lv_list_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param);
void lv_list_add(lv_obj_t * obj_dp);
void lv_list_add(lv_obj_t * obj_dp, const char * img_fn, const char * txt, void (*release) (lv_obj_t *));
lv_lists_t * lv_lists_get(lv_lists_builtin_t style, lv_lists_t * copy_p);
/**********************
......
......@@ -141,7 +141,7 @@ lv_obj_t* lv_page_create(lv_obj_t * par_dp, lv_obj_t * ori_dp)
lv_obj_set_drag(new_dp, true);
lv_obj_set_drag_throw(new_dp, true);
lv_obj_set_style(new_dp, &lv_pages_def);
lv_rect_set_pad_en(new_dp, true, true);
lv_rect_set_fit(new_dp, true, true);
} else {
lv_obj_set_style(new_dp, lv_obj_get_style(ori_dp));
}
......
......@@ -23,6 +23,18 @@
* TYPEDEFS
**********************/
typedef enum
{
LV_LAYOUT_OFF = 0,
LV_LAYOUT_COL_L,
LV_LAYOUT_COL_M,
LV_LAYOUT_COL_R,
LV_LAYOUT_ROW_T,
LV_LAYOUT_ROW_M,
LV_LAYOUT_ROW_B,
LV_LAYOUT_CENTER,
}lv_layout_t;
typedef struct
{
lv_objs_t objs;
......@@ -31,6 +43,7 @@ typedef struct
uint16_t bwidth;
cord_t hpad;
cord_t vpad;
cord_t opad;
uint16_t round;
uint8_t bopa;
uint8_t empty :1;
......@@ -39,8 +52,9 @@ typedef struct
typedef struct
{
uint8_t hpad_en:1;
uint8_t vpad_en:1;
uint8_t hfit_en:1;
uint8_t vfit_en:1;
lv_layout_t layout;
}lv_rect_ext_t;
typedef enum
......@@ -57,9 +71,10 @@ typedef enum
lv_obj_t* lv_rect_create(lv_obj_t* par_dp, lv_obj_t * copy_dp);
bool lv_rect_signal(lv_obj_t* obj_dp, lv_signal_t sign, void * param);
void lv_rect_set_pad_en(lv_obj_t * obj_dp, bool hor_en, bool ver_en);
void lv_rect_set_fit(lv_obj_t * obj_dp, bool hor_en, bool ver_en);
void lv_rect_set_layout(lv_obj_t * obj_dp, lv_layout_t layout);
lv_layout_t lv_rect_get_layout(lv_obj_t * obj_dp);
bool lv_rect_get_hpad_en(lv_obj_t * obj_dp);
bool lv_rect_get_vpad_en(lv_obj_t * obj_dp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment