Apply the new style system on the applications too
This commit is contained in:
@@ -128,8 +128,6 @@ bool lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
|
||||
if(valid != false) {
|
||||
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
|
||||
lv_style_t * style = lv_obj_get_style(bar);
|
||||
point_t p;
|
||||
char buf[LV_BAR_TXT_MAX_LENGTH];
|
||||
|
||||
switch(sign) {
|
||||
case LV_SIGNAL_CLEANUP:
|
||||
|
||||
@@ -123,7 +123,6 @@ bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
|
||||
* make the object specific signal handling */
|
||||
if(valid != false) {
|
||||
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
|
||||
lv_style_t * style = lv_obj_get_style(btn);
|
||||
lv_btn_state_t state = lv_btn_get_state(btn);
|
||||
bool tgl = lv_btn_get_tgl(btn);
|
||||
|
||||
|
||||
@@ -294,16 +294,18 @@ void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_callback_t cb)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the style of the buttons in a given state
|
||||
* Set the styles of the buttons of the button matrox
|
||||
* @param btnm pointer to a button matrix object
|
||||
* @param state style in this state (LV_BTN_STATE_PR or LV_BTN_STATE_REL)
|
||||
* @param style pointer to style
|
||||
*/
|
||||
void lv_btnm_set_styles_btn(lv_obj_t * btnm, lv_btn_state_t state, lv_style_t * style)
|
||||
void lv_btnm_set_styles_btn(lv_obj_t * btnm, lv_style_t * rel, lv_style_t * pr)
|
||||
{
|
||||
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
|
||||
if(state == LV_BTN_STATE_REL) ext->style_btn_rel = style;
|
||||
if(state == LV_BTN_STATE_PR) ext->style_btn_pr = style;
|
||||
ext->style_btn_rel = rel;
|
||||
ext->style_btn_pr = pr;
|
||||
|
||||
lv_obj_inv(btnm);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,8 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map);
|
||||
*/
|
||||
void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_callback_t cb);
|
||||
|
||||
void lv_btnm_set_styles_btn(lv_obj_t * btnm, lv_btn_state_t state, lv_style_t * style);
|
||||
void lv_btnm_set_styles_btn(lv_obj_t * btnm, lv_style_t * rel, lv_style_t * pr);
|
||||
|
||||
/**
|
||||
* Get the current map of a button matrix
|
||||
* @param btnm pointer to a button matrix object
|
||||
|
||||
@@ -137,9 +137,9 @@ bool lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param)
|
||||
* @param chart pointer to a chart object
|
||||
* @param color color of the data line
|
||||
* @param width line width/point radius/column width
|
||||
* @return pointer to the allocated data line (an array for the data points)
|
||||
* @return pointer to the allocated data line (
|
||||
*/
|
||||
cord_t * lv_chart_add_dataline(lv_obj_t * chart, color_t color, cord_t width)
|
||||
lv_chart_dl_t * lv_chart_add_dataline(lv_obj_t * chart, color_t color, cord_t width)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
lv_chart_dl_t * dl = ll_ins_head(&ext->dl_ll);
|
||||
@@ -158,7 +158,7 @@ cord_t * lv_chart_add_dataline(lv_obj_t * chart, color_t color, cord_t width)
|
||||
|
||||
ext->dl_num++;
|
||||
|
||||
return dl->points;
|
||||
return dl;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,16 +267,16 @@ void lv_chart_set_drak_effect(lv_obj_t * chart, opa_t dark_eff)
|
||||
* @param dl pointer to a data line on 'chart'
|
||||
* @param y the new value of the most right data
|
||||
*/
|
||||
void lv_chart_set_next(lv_obj_t * chart, cord_t * dl, cord_t y)
|
||||
void lv_chart_set_next(lv_obj_t * chart, lv_chart_dl_t * dl, cord_t y)
|
||||
{
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
|
||||
|
||||
uint16_t i;
|
||||
for(i = 0; i < ext->pnum - 1; i++) {
|
||||
dl[i] = dl[i + 1];
|
||||
dl->points[i] = dl->points[i + 1];
|
||||
}
|
||||
|
||||
dl[ext->pnum - 1] = y;
|
||||
dl->points[ext->pnum - 1] = y;
|
||||
lv_chart_refr(chart);
|
||||
|
||||
}
|
||||
|
||||
@@ -90,9 +90,9 @@ bool lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param);
|
||||
/**
|
||||
* Allocate and add a data line to the chart
|
||||
* @param chart pointer to a chart object
|
||||
* @return pointer to the allocated data lie (an array for the data points)
|
||||
* @return pointer to the allocated data line
|
||||
*/
|
||||
cord_t * lv_chart_add_dataline(lv_obj_t * chart, color_t color, cord_t width);
|
||||
lv_chart_dl_t * lv_chart_add_dataline(lv_obj_t * chart, color_t color, cord_t width);
|
||||
|
||||
/**
|
||||
* Refresh a chart if its data line has changed
|
||||
@@ -142,7 +142,7 @@ void lv_chart_set_drak_effect(lv_obj_t * chart, opa_t dark_eff);
|
||||
* @param dl pointer to a data line on 'chart'
|
||||
* @param y the new value of the most right data
|
||||
*/
|
||||
void lv_chart_set_next(lv_obj_t * chart, cord_t * dl, cord_t y);
|
||||
void lv_chart_set_next(lv_obj_t * chart, lv_chart_dl_t * dl, cord_t y);
|
||||
|
||||
/**
|
||||
* Get the type of a chart
|
||||
|
||||
@@ -221,11 +221,12 @@ void lv_list_set_styles_liste(lv_obj_t * list, lv_style_t * rel, lv_style_t * pr
|
||||
ext->styles_liste[LV_BTN_STATE_TPR] = tpr;
|
||||
ext->styles_liste[LV_BTN_STATE_INA] = ina;
|
||||
|
||||
lv_obj_t * liste = lv_obj_get_child(list, NULL);
|
||||
|
||||
while(liste != NULL) {
|
||||
lv_obj_t * scrl = lv_page_get_scrl(list);
|
||||
lv_obj_t * liste = lv_obj_get_child(scrl, NULL);
|
||||
while(liste != NULL)
|
||||
{
|
||||
lv_btn_set_styles(liste, rel, pr, trel, tpr, ina);
|
||||
liste = lv_obj_get_child(list, liste);
|
||||
liste = lv_obj_get_child(scrl, liste);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -134,7 +134,6 @@ bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
||||
* make the object specific signal handling */
|
||||
if(obj_valid != false) {
|
||||
lv_page_ext_t * ext = lv_obj_get_ext(page);
|
||||
lv_style_t * style = lv_obj_get_style(page);
|
||||
lv_obj_t * child;
|
||||
switch(sign) {
|
||||
case LV_SIGNAL_CHILD_CHG: /*Move children to the scrollable object*/
|
||||
|
||||
@@ -94,7 +94,9 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
lv_label_set_text(ext->label, "Text area");
|
||||
lv_page_glue_obj(ext->label, true);
|
||||
lv_obj_set_click(ext->label, false);
|
||||
lv_obj_set_style(new_ta, lv_obj_get_style(ext->page.scrl));
|
||||
lv_obj_set_style(new_ta, lv_style_get(LV_STYLE_PRETTY, NULL));
|
||||
lv_page_set_sb_mode(new_ta, LV_PAGE_SB_MODE_AUTO);
|
||||
lv_obj_set_style(lv_page_get_scrl(new_ta), lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
|
||||
lv_obj_set_size(new_ta, LV_TA_DEF_WIDTH, LV_TA_DEF_HEIGHT);
|
||||
}
|
||||
/*Copy an existing object*/
|
||||
|
||||
@@ -63,12 +63,9 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
ext->header = NULL;
|
||||
ext->title = NULL;
|
||||
ext->style_header = lv_style_get(LV_STYLE_PLAIN_COLOR, NULL);
|
||||
ext->styles_btn[LV_BTN_STATE_REL] = lv_style_get(LV_STYLE_BTN_REL, NULL);
|
||||
ext->styles_btn[LV_BTN_STATE_PR] = lv_style_get(LV_STYLE_BTN_PR, NULL);
|
||||
ext->styles_btn[LV_BTN_STATE_TREL] = lv_style_get(LV_STYLE_BTN_TREL, NULL);
|
||||
ext->styles_btn[LV_BTN_STATE_TPR] = lv_style_get(LV_STYLE_BTN_TPR, NULL);
|
||||
ext->styles_btn[LV_BTN_STATE_INA] = lv_style_get(LV_STYLE_BTN_INA, NULL);
|
||||
ext->btn_size = LV_DPI;
|
||||
ext->style_cbtn_rel = lv_style_get(LV_STYLE_BTN_REL, NULL);
|
||||
ext->style_cbtn_pr = lv_style_get(LV_STYLE_BTN_PR, NULL);
|
||||
ext->cbtn_size = (3 * LV_DPI) / 4;
|
||||
|
||||
/*Init the new window object*/
|
||||
if(copy == NULL) {
|
||||
@@ -216,10 +213,9 @@ lv_obj_t * lv_win_add_ctrl_btn(lv_obj_t * win, const char * img_path, lv_action_
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
|
||||
lv_obj_t * btn = lv_btn_create(ext->btnh, NULL);
|
||||
lv_btn_set_styles(btn, ext->styles_btn[LV_BTN_STATE_REL], ext->styles_btn[LV_BTN_STATE_PR],
|
||||
ext->styles_btn[LV_BTN_STATE_TREL], ext->styles_btn[LV_BTN_STATE_TPR],
|
||||
ext->styles_btn[LV_BTN_STATE_INA]);
|
||||
lv_obj_set_size(btn, ext->btn_size, ext->btn_size);
|
||||
lv_btn_set_styles(btn, ext->style_cbtn_rel, ext->style_cbtn_pr,
|
||||
NULL, NULL, NULL);
|
||||
lv_obj_set_size(btn, ext->cbtn_size, ext->cbtn_size);
|
||||
lv_btn_set_rel_action(btn, rel_action);
|
||||
|
||||
lv_obj_t * img = lv_img_create(btn, NULL);
|
||||
@@ -259,6 +255,40 @@ void lv_win_set_title(lv_obj_t * win, const char * title)
|
||||
lv_win_realign(win);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the control button size of a window
|
||||
* @param win pointer to a window object
|
||||
* @return control button size
|
||||
*/
|
||||
void lv_win_set_cbtn_size(lv_obj_t * win, cord_t size)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
ext->cbtn_size = size;
|
||||
|
||||
lv_win_realign(win);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the style of the window control buttons in a given state
|
||||
* @param win pointer to a window object
|
||||
* @param state style in this state (LV_BTN_STATE_PR or LV_BTN_STATE_REL)
|
||||
* @param style pointer to style
|
||||
*/
|
||||
void lv_win_set_style_cbtn(lv_obj_t * win, lv_btn_state_t state, lv_style_t * style)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
if(state == LV_BTN_STATE_REL) ext->style_cbtn_rel = style;
|
||||
if(state == LV_BTN_STATE_PR) ext->style_cbtn_pr = style;
|
||||
lv_obj_t * cbtn;
|
||||
cbtn = lv_obj_get_child(ext->btnh, NULL);
|
||||
while(cbtn != NULL) {
|
||||
lv_btn_set_styles(cbtn, ext->style_cbtn_rel, ext->style_cbtn_pr, NULL, NULL, NULL);
|
||||
|
||||
cbtn = lv_obj_get_child(ext->btnh, cbtn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
@@ -285,6 +315,42 @@ lv_obj_t * lv_win_get_page(lv_obj_t * win)
|
||||
return ext->page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the s window header
|
||||
* @param win pointer to a window object
|
||||
* @return pointer to the window header object (lv_rect)
|
||||
*/
|
||||
lv_obj_t * lv_win_get_header(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
return ext->header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the control button size of a window
|
||||
* @param win pointer to a window object
|
||||
* @return control button size
|
||||
*/
|
||||
cord_t lv_win_get_cbtn_size(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
return ext->cbtn_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get width of the content area (page scrollable) of the window
|
||||
* @param win pointer to a window object
|
||||
* @return the width of the contetn area
|
||||
*/
|
||||
cord_t lv_win_get_width(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
lv_obj_t * scrl = lv_page_get_scrl(ext->page);
|
||||
lv_style_t * style_scrl = lv_obj_get_style(scrl);
|
||||
|
||||
return lv_obj_get_width(scrl) - 2 * style_scrl->hpad;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pointer of a widow from one of its control button.
|
||||
* It is useful in the action of the control buttons where only button is known.
|
||||
@@ -341,7 +407,6 @@ static bool lv_win_design(lv_obj_t * win, const area_t * mask, lv_design_mode_t
|
||||
static void lv_win_realign(lv_obj_t * win)
|
||||
{
|
||||
lv_win_ext_t * ext = lv_obj_get_ext(win);
|
||||
lv_style_t * style = lv_obj_get_style(win);
|
||||
|
||||
if(ext->page == NULL || ext->btnh == NULL || ext->header == NULL || ext->title == NULL) return;
|
||||
|
||||
@@ -349,12 +414,12 @@ static void lv_win_realign(lv_obj_t * win)
|
||||
/*Refresh the style of all control buttons*/
|
||||
cbtn = lv_obj_get_child(ext->btnh, NULL);
|
||||
while(cbtn != NULL) {
|
||||
lv_obj_set_size(cbtn, ext->btn_size, ext->btn_size);
|
||||
lv_obj_set_size(cbtn, ext->cbtn_size, ext->cbtn_size);
|
||||
cbtn = lv_obj_get_child(ext->btnh, cbtn);
|
||||
}
|
||||
|
||||
lv_style_t * btnh_style = lv_obj_get_style(ext->btnh);
|
||||
lv_obj_set_height(ext->btnh, ext->btn_size + 2 * btnh_style->vpad * 2);
|
||||
lv_obj_set_height(ext->btnh, ext->cbtn_size + 2 * btnh_style->vpad * 2);
|
||||
lv_obj_set_width(ext->header, lv_obj_get_width(win));
|
||||
|
||||
/*Align the higher object first to make the correct header size first*/
|
||||
|
||||
@@ -62,8 +62,9 @@ typedef struct
|
||||
lv_obj_t * title; /*Pointer to the title label of the window*/
|
||||
lv_obj_t * btnh; /*Pointer to the control button holder rectangle of the window*/
|
||||
lv_style_t * style_header; /*Style of the header rectangle*/
|
||||
lv_style_t * styles_btn[LV_BTN_STATE_NUM]; /*Style of the control buttons*/
|
||||
cord_t btn_size; /*Size of the control buttons (square)*/
|
||||
lv_style_t * style_cbtn_rel; /*Control button releases style*/
|
||||
lv_style_t * style_cbtn_pr; /*Control button pressed style*/
|
||||
cord_t cbtn_size; /*Size of the control buttons (square)*/
|
||||
}lv_win_ext_t;
|
||||
|
||||
/**********************
|
||||
@@ -120,6 +121,10 @@ const char * lv_win_get_title(lv_obj_t * win);
|
||||
|
||||
lv_obj_t * lv_win_get_page(lv_obj_t * win);
|
||||
|
||||
lv_obj_t * lv_win_get_header(lv_obj_t * win);
|
||||
|
||||
cord_t lv_win_get_width(lv_obj_t * win);
|
||||
|
||||
/**
|
||||
* Get the pointer of a widow from one of its control button.
|
||||
* It is useful in the action of the control buttons where only button is known.
|
||||
|
||||
Reference in New Issue
Block a user