BigW Consortium Gitlab

Commit 86daac14 by Gabor Kiss-Vamosi

add lv_xxx_style_t and unify style set/get

parent 39075fe0
......@@ -68,6 +68,7 @@ void lv_style_init (void)
* HUE = 210*/
/*Screen style*/
lv_style_scr.glass = 0;
lv_style_scr.body.opa = OPA_COVER;
lv_style_scr.body.color_main = COLOR_WHITE;
lv_style_scr.body.color_gradient = COLOR_WHITE;
......@@ -76,7 +77,6 @@ void lv_style_init (void)
lv_style_scr.body.padding.hor = LV_DPI / 10;
lv_style_scr.body.padding.inner = LV_DPI / 10;
lv_style_scr.body.empty = 0;
lv_style_scr.glass = 0;
lv_style_scr.body.border.color = COLOR_BLACK;
lv_style_scr.body.border.opa = OPA_COVER;
......
......@@ -162,23 +162,25 @@ void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max)
lv_obj_invalidate(bar);
}
/**
* Set the styles of a bar
* Set a style of a bar
* @param bar pointer to a bar object
* @param bg pointer to the background's style (NULL to leave unchanged)
* @param indic pointer to the indicator's style (NULL to leave unchanged)
* @param type which style should be set
* @param style pointer to a style
*/
void lv_bar_set_style(lv_obj_t * bar, lv_style_t * bg, lv_style_t * indic)
void lv_bar_set_style(lv_obj_t *bar, lv_bar_style_t type, lv_style_t *style)
{
lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar);
if(indic != NULL) {
ext->style_inicator = indic;
bar->signal_func(bar, LV_SIGNAL_REFR_EXT_SIZE, NULL);
}
if(bg != NULL) {
lv_obj_set_style(bar, bg);
switch (type) {
case LV_BAR_STYLE_BG:
lv_obj_set_style(bar, style);
break;
case LV_BAR_STYLE_INDIC:
ext->style_inicator = style;
lv_obj_refresh_ext_size(bar);
break;
}
}
......@@ -233,6 +235,26 @@ lv_style_t * lv_bar_get_style_indicator(lv_obj_t * bar)
return ext->style_inicator;
}
/**
* Get a style of a bar
* @param bar pointer to a bar object
* @param type which style should be get
* @return style pointer to a style
*/
lv_style_t * lv_bar_get_style(lv_obj_t *bar, lv_bar_style_t type)
{
lv_bar_ext_t *ext = lv_obj_get_ext_attr(bar);
switch (type) {
case LV_BAR_STYLE_BG: return lv_obj_get_style(bar);
case LV_BAR_STYLE_INDIC: return ext->style_inicator;
default: return NULL;
}
/*To avoid warning*/
return NULL;
}
/**********************
* STATIC FUNCTIONS
**********************/
......@@ -302,7 +324,7 @@ static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
if(style_indic->body.shadow.width > bar->ext_size) bar->ext_size = style_indic->body.shadow.width;
}
return LV_RES_OK;
return res;
}
......
......@@ -40,6 +40,11 @@ typedef struct
lv_style_t *style_inicator; /*Style of the indicator*/
}lv_bar_ext_t;
typedef enum {
LV_BAR_STYLE_BG,
LV_BAR_STYLE_INDIC,
}lv_bar_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
......@@ -81,12 +86,12 @@ void lv_bar_set_value_anim(lv_obj_t * bar, int16_t value, uint16_t anim_time);
void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max);
/**
* Set the styles of a bar
* Set a style of a bar
* @param bar pointer to a bar object
* @param bg pointer to the background's style (NULL to leave unchanged)
* @param indic pointer to the indicator's style (NULL to leave unchanged)
* @param type which style should be set
* @param style pointer to a style
*/
void lv_bar_set_style(lv_obj_t * bar, lv_style_t * bg, lv_style_t * indic);
void lv_bar_set_style(lv_obj_t *bar, lv_bar_style_t type, lv_style_t *style);
/*=====================
* Getter functions
......@@ -113,23 +118,14 @@ int16_t lv_bar_get_min_value(lv_obj_t * bar);
*/
int16_t lv_bar_get_max_value(lv_obj_t * bar);
/**
* Get the style of bar background
* @param bar pointer to a bar object
* @return pointer to the bar's background style
*/
static inline lv_style_t * lv_bar_get_style_bg(lv_obj_t *bar)
{
return lv_obj_get_style(bar);
}
/**
* Get the style of bar indicator
* Get a style of a bar
* @param bar pointer to a bar object
* @return pointer to the bar indicator style
* @param type which style should be get
* @return style pointer to a style
*/
lv_style_t * lv_bar_get_style_indicator(lv_obj_t * bar);
lv_style_t * lv_bar_get_style(lv_obj_t *bar, lv_bar_style_t type);
/**********************
* MACROS
......
......@@ -35,11 +35,11 @@ extern "C" {
/*Button states*/
typedef enum
{
LV_BTN_STATE_RELEASED,
LV_BTN_STATE_PRESSED,
LV_BTN_STATE_TGL_RELEASED,
LV_BTN_STATE_TGL_PRESSED,
LV_BTN_STATE_INACTIVE,
LV_BTN_STATE_REL,
LV_BTN_STATE_PR,
LV_BTN_STATE_TGL_REL,
LV_BTN_STATE_TGL_PR,
LV_BTN_STATE_INA,
LV_BTN_STATE_NUM,
}lv_btn_state_t;
......@@ -65,12 +65,18 @@ typedef struct
uint8_t long_press_action_executed :1; /*1: Long press action executed (Handled by the library)*/
}lv_btn_ext_t;
typedef enum {
LV_BTN_STYLE_REL,
LV_BTN_STYLE_PR,
LV_BTN_STYLE_TGL_REL,
LV_BTN_STYLE_TGL_PR,
LV_BTN_STYLE_INA,
}lv_btn_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a button objects
* @param par pointer to an object, it will be the parent of the new button
......@@ -132,18 +138,14 @@ static inline void lv_btn_set_fit(lv_obj_t * btn, bool hor_en, bool ver_en)
lv_cont_set_fit(btn, hor_en, ver_en);
}
/**
* Set styles of a button is each state. Use NULL for any style to leave it unchanged
* Set a style of a button.
* @param btn pointer to button object
* @param rel pointer to a style for releases state
* @param pr pointer to a style for pressed state
* @param tgl_rel pointer to a style for toggled releases state
* @param tgl_pr pointer to a style for toggled pressed state
* @param ina pointer to a style for inactive state
*/
void lv_btn_set_style(lv_obj_t * btn, lv_style_t *rel, lv_style_t *pr,
lv_style_t *tgl_rel, lv_style_t *tgl_pr,
lv_style_t *ina);
* @param type which style should be set
* @param style pointer to a style
* */
void lv_btn_set_style(lv_obj_t * btn, lv_btn_style_t type, lv_style_t *style);
/*=====================
* Getter functions
......@@ -201,12 +203,12 @@ static inline bool lv_btn_get_ver_fit(lv_obj_t * btn)
}
/**
* Get the style of a button in a given state
* @param btn pointer to a button object
* @param state a state from 'lv_btn_state_t' in which style should be get
* @return pointer to the style in the given state
*/
lv_style_t * lv_btn_get_style(lv_obj_t * btn, lv_btn_state_t state);
* Get style of a button.
* @param btn pointer to button object
* @param type which style should be get
* @return style pointer to the style
* */
lv_style_t * lv_btn_get_style(lv_obj_t * btn, lv_btn_style_t type);
/**********************
* MACROS
......
......@@ -78,11 +78,11 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
ext->action = NULL;
ext->map_p = NULL;
ext->toggle = 0;
ext->styles_btn[LV_BTN_STATE_RELEASED] = &lv_style_btn_released;
ext->styles_btn[LV_BTN_STATE_PRESSED] = &lv_style_btn_pressed;
ext->styles_btn[LV_BTN_STATE_TGL_RELEASED] = &lv_style_btn_tgl_released;
ext->styles_btn[LV_BTN_STATE_TGL_PRESSED] = &lv_style_btn_tgl_pressed;
ext->styles_btn[LV_BTN_STATE_INACTIVE] = &lv_style_btn_inactive;
ext->styles_btn[LV_BTN_STATE_REL] = &lv_style_btn_released;
ext->styles_btn[LV_BTN_STATE_PR] = &lv_style_btn_pressed;
ext->styles_btn[LV_BTN_STATE_TGL_REL] = &lv_style_btn_tgl_released;
ext->styles_btn[LV_BTN_STATE_TGL_PR] = &lv_style_btn_tgl_pressed;
ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_inactive;
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_func(new_btnm);
......@@ -234,7 +234,7 @@ void lv_btnm_set_toggle(lv_obj_t * btnm, bool en, uint16_t id)
ext->toggle = en == false ? 0 : 1;
if(ext->toggle != 0) {
if(id > ext->btn_cnt) id = LV_BTNM_PR_NONE;
if(id >= ext->btn_cnt) id = ext->btn_cnt - 1;
ext->btn_id_toggled = id;
} else {
ext->btn_id_toggled = LV_BTNM_PR_NONE;
......@@ -244,28 +244,40 @@ void lv_btnm_set_toggle(lv_obj_t * btnm, bool en, uint16_t id)
}
/**
* Set styles of the button is each state. Use NULL for any style to leave it unchanged.
* @param btnm pointer to button matrix object
* @param rel pointer to a style for releases state
* @param pr pointer to a style for pressed state
* @param tgl_rel pointer to a style for toggled releases state
* @param tgl_pr pointer to a style for toggled pressed state
* @param ina pointer to a style for inactive state
* Set a style of a button matrix
* @param btnm pointer to a button matrix object
* @param type which style should be set
* @param style pointer to a style
*/
void lv_btnm_set_style_btn(lv_obj_t *btnm, lv_style_t *rel, lv_style_t *pr,
lv_style_t *tgl_rel, lv_style_t *tgl_pr,
lv_style_t *ina)
void lv_btnm_set_style(lv_obj_t *btnm, lv_btnm_style_t type, lv_style_t *style)
{
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(rel != NULL) ext->styles_btn[LV_BTN_STATE_RELEASED] = rel;
if(pr != NULL) ext->styles_btn[LV_BTN_STATE_PRESSED] = pr;
if(tgl_rel != NULL) ext->styles_btn[LV_BTN_STATE_TGL_RELEASED] = tgl_rel;
if(tgl_pr != NULL) ext->styles_btn[LV_BTN_STATE_TGL_PRESSED] = tgl_pr;
if(ina != NULL) ext->styles_btn[LV_BTN_STATE_INACTIVE] = ina;
lv_btnm_ext_t *ext = lv_obj_get_ext_attr(btnm);
switch (type) {
case LV_BTNM_STYLE_BG:
lv_obj_set_style(btnm, style);
break;
case LV_BTNM_STYLE_BTN_REL:
ext->styles_btn[LV_BTN_STATE_REL] = style;
lv_obj_invalidate(btnm);
break;
case LV_BTNM_STYLE_BTN_PR:
ext->styles_btn[LV_BTN_STATE_PR] = style;
lv_obj_invalidate(btnm);
break;
case LV_BTNM_STYLE_BTN_TGL_REL:
ext->styles_btn[LV_BTN_STATE_TGL_REL] = style;
lv_obj_invalidate(btnm);
break;
case LV_BTNM_STYLE_BTN_TGL_PR:
ext->styles_btn[LV_BTN_STATE_TGL_PR] = style;
lv_obj_invalidate(btnm);
break;
case LV_BTNM_STYLE_BTN_INA:
ext->styles_btn[LV_BTN_STATE_INA] = style;
lv_obj_invalidate(btnm);
break;
}
}
/*=====================
......@@ -295,21 +307,39 @@ lv_btnm_action_t lv_btnm_get_action(lv_obj_t * btnm)
}
/**
* Get the style of buttons in button matrix
* @param btnm pointer to a button matrix object
* @param state style in this state (LV_BTN_STATE_PR or LV_BTN_STATE_REL)
* @return pointer the button style in the given state
* Get the toggled button
* @param btnm pointer to button matrix object
* @return index of the currently toggled button (0: if unset)
*/
lv_style_t * lv_btnm_get_style_btn(lv_obj_t * btnm, lv_btn_state_t state)
uint16_t lv_btnm_get_toggled(lv_obj_t * btnm)
{
if(state >= LV_BTN_STATE_NUM) return lv_obj_get_style(btnm);
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
lv_style_t * style = ext->styles_btn[state];
if(style == NULL) style = lv_obj_get_style(btnm);
if(ext->toggle == 0) return 0;
else return ext->btn_id_toggled;}
/**
* Get a style of a button matrix
* @param btnm pointer to a button matrix object
* @param type which style should be get
* @return style pointer to a style
*/
lv_style_t * lv_btnm_get_style(lv_obj_t *btnm, lv_btnm_style_t type)
{
lv_btnm_ext_t *ext = lv_obj_get_ext_attr(btnm);
switch (type) {
case LV_BTNM_STYLE_BG: return lv_obj_get_style(btnm);
case LV_BTNM_STYLE_BTN_REL: return ext->styles_btn[LV_BTN_STATE_REL];
case LV_BTNM_STYLE_BTN_PR: return ext->styles_btn[LV_BTN_STATE_PR];
case LV_BTNM_STYLE_BTN_TGL_REL: return ext->styles_btn[LV_BTN_STATE_TGL_REL];
case LV_BTNM_STYLE_BTN_TGL_PR: return ext->styles_btn[LV_BTN_STATE_TGL_PR];
case LV_BTNM_STYLE_BTN_INA: return ext->styles_btn[LV_BTN_STATE_INA];
default: return NULL;
}
return style;
/*To avoid warning*/
return NULL;
}
/**********************
......@@ -366,11 +396,11 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
btn_h = area_get_height(&area_tmp);
/*Load the style*/
if(button_is_inactive(ext->map_p[txt_i])) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_INACTIVE);
else if(btn_i != ext->btn_id_pressed && btn_i != ext->btn_id_toggled) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_RELEASED);
else if(btn_i == ext->btn_id_pressed && btn_i != ext->btn_id_toggled) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_PRESSED);
else if(btn_i != ext->btn_id_pressed && btn_i == ext->btn_id_toggled) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_TGL_RELEASED);
else if(btn_i == ext->btn_id_pressed && btn_i == ext->btn_id_toggled) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_TGL_PRESSED);
if(button_is_inactive(ext->map_p[txt_i])) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_INA);
else if(btn_i != ext->btn_id_pressed && btn_i != ext->btn_id_toggled) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_REL);
else if(btn_i == ext->btn_id_pressed && btn_i != ext->btn_id_toggled) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_PR);
else if(btn_i != ext->btn_id_pressed && btn_i == ext->btn_id_toggled) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_REL);
else if(btn_i == ext->btn_id_pressed && btn_i == ext->btn_id_toggled) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_PR);
lv_draw_rect(&area_tmp, mask, btn_style);
/*Calculate the size of the text*/
......
......@@ -57,6 +57,15 @@ typedef struct
uint8_t toggle :1; /*Enable toggling*/
}lv_btnm_ext_t;
typedef enum {
LV_BTNM_STYLE_BG,
LV_BTNM_STYLE_BTN_REL,
LV_BTNM_STYLE_BTN_PR,
LV_BTNM_STYLE_BTN_TGL_REL,
LV_BTNM_STYLE_BTN_TGL_PR,
LV_BTNM_STYLE_BTN_INA,
}lv_btnm_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
......@@ -105,27 +114,12 @@ void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_action_t action);
void lv_btnm_set_toggle(lv_obj_t * btnm, bool en, uint16_t id);
/**
* Set the style of a button matrix's background
* Set a style of a button matrix
* @param btnm pointer to a button matrix object
* @param bg pointer to the background style
*/
static inline void lv_btnm_set_style(lv_obj_t *btnm, lv_style_t * bg)
{
lv_obj_set_style(btnm, bg);
}
/**
* Set styles of the button is each state. Use NULL for any style to leave it unchanged.
* @param btnm pointer to button matrix object
* @param rel pointer to a style for releases state
* @param pr pointer to a style for pressed state
* @param tgl_rel pointer to a style for toggled releases state
* @param tgl_pr pointer to a style for toggled pressed state
* @param ina pointer to a style for inactive state
* @param type which style should be set
* @param style pointer to a style
*/
void lv_btnm_set_style_btn(lv_obj_t *btnm, lv_style_t *rel, lv_style_t *pr,
lv_style_t *tgl_rel, lv_style_t *tgl_pr,
lv_style_t *ina);
void lv_btnm_set_style(lv_obj_t *btnm, lv_btnm_style_t type, lv_style_t *style);
/*=====================
* Getter functions
......@@ -145,23 +139,21 @@ const char ** lv_btnm_get_map(lv_obj_t * btnm);
*/
lv_btnm_action_t lv_btnm_get_action(lv_obj_t * btnm);
/**
* Get the style of a button matrix
* @param btnm pointer to a button matrix object
* @return pointer to the backgrond style
* Get the toggled button
* @param btnm pointer to button matrix object
* @return index of the currently toggled button (0: if unset)
*/
static inline lv_style_t * lv_btnm_get_style_bg(lv_obj_t *btnm)
{
return lv_obj_get_style(btnm);
}
uint16_t lv_btnm_get_toggled(lv_obj_t * btnm);
/**
* Get the style of buttons in button matrix
* Get a style of a button matrix
* @param btnm pointer to a button matrix object
* @param state style in this state (LV_BTN_STATE_PR or LV_BTN_STATE_REL)
* @return pointer the button style in the given state
* @param type which style should be get
* @return style pointer to a style
*/
lv_style_t * lv_btnm_get_style_btn(lv_obj_t * btnm, lv_btn_state_t state);
lv_style_t * lv_btnm_get_style(lv_obj_t *btnm, lv_btnm_style_t type);
/**********************
* MACROS
......
......@@ -69,14 +69,11 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy)
ext->bullet = lv_btn_create(new_cb, NULL);
if(ancestor_bullet_design == NULL) ancestor_bullet_design = lv_obj_get_design_func(ext->bullet);
lv_obj_set_click(ext->bullet, false);
lv_btn_set_style(ext->bullet, &lv_style_pretty, &lv_style_pretty_color,
&lv_style_btn_tgl_released, &lv_style_btn_tgl_pressed,
NULL);
ext->label = lv_label_create(new_cb, NULL);
lv_obj_set_style(ext->label, NULL); /*Inherit the style of the parent*/
lv_cb_set_style(new_cb, &lv_style_transp);
lv_cb_set_style(new_cb,LV_CB_STYLE_BG, &lv_style_transp);
lv_cb_set_text(new_cb, "Check box");
lv_cont_set_layout(new_cb, LV_CONT_LAYOUT_ROW_M);
lv_cont_set_fit(new_cb, true, true);
......@@ -113,23 +110,43 @@ void lv_cb_set_text(lv_obj_t * cb, const char * txt)
}
/**
* Set styles of a checkbox's bullet in each state. Use NULL for any style to leave it unchanged
* Set a style of a check box
* @param cb pointer to check box object
* @param rel pointer to a style for releases state
* @param pr pointer to a style for pressed state
* @param tgl_rel pointer to a style for toggled releases state
* @param tgl_pr pointer to a style for toggled pressed state
* @param ina pointer to a style for inactive state
*/
void lv_cb_set_style_bullet(lv_obj_t *cb, lv_style_t *rel, lv_style_t *pr,
lv_style_t *tgl_rel, lv_style_t *tgl_pr,
lv_style_t *ina)
* @param type which style should be set
* @param style pointer to a style
* */
void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, lv_style_t *style)
{
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
lv_btn_set_style(ext->bullet, rel, pr, tgl_rel, tgl_pr, ina);
switch (type) {
case LV_CB_STYLE_BG:
lv_btn_set_style(cb, LV_BTN_STYLE_REL, style);
lv_btn_set_style(cb, LV_BTN_STYLE_PR, style);
lv_btn_set_style(cb, LV_BTN_STYLE_TGL_REL, style);
lv_btn_set_style(cb, LV_BTN_STYLE_TGL_PR, style);
lv_btn_set_style(cb, LV_BTN_STYLE_INA, style);
break;
case LV_CB_STYLE_RELEASED:
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_REL, style);
break;
case LV_CB_STYLE_PRESSED:
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_PR, style);
break;
case LV_CB_STYLE_TGL_RELEASED:
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_TGL_REL, style);
break;
case LV_CB_STYLE_TGL_PRESSED:
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_TGL_PR, style);
break;
case LV_CB_STYLE_INACTIVE:
lv_btn_set_style(ext->bullet, LV_BTN_STYLE_INA, style);
break;
}
}
/*=====================
* Getter functions
*====================*/
......@@ -145,15 +162,28 @@ const char * lv_cb_get_text(lv_obj_t * cb)
return lv_label_get_text(ext->label);
}
/**
* Get styles of a checkbox's bullet in a state.
* @param state a state from 'lv_btn_state_t' in which style should be get
* @return pointer to the style in the given state
*/
lv_style_t * lv_cb_get_style_bullet(lv_obj_t *cb, lv_btn_state_t state)
* Get a style of a button
* @param cb pointer to check box object
* @param type which style should be get
* @return style pointer to the style
* */
lv_style_t * lv_cb_get_style(lv_obj_t * cb, lv_cb_style_t type)
{
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
return lv_btn_get_style(ext->bullet, state);
switch (type) {
case LV_CB_STYLE_RELEASED: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_REL);
case LV_CB_STYLE_PRESSED: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_PR);
case LV_CB_STYLE_TGL_RELEASED: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_REL);
case LV_CB_STYLE_TGL_PRESSED: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_PR);
case LV_CB_STYLE_INACTIVE: return lv_btn_get_style(ext->bullet, LV_BTN_STYLE_INA);
default: return NULL;
}
/*To avoid awrning*/
return NULL;
}
/**********************
......@@ -269,7 +299,7 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param)
}
}
return LV_RES_OK;
return res;
}
#endif
......@@ -46,6 +46,15 @@ typedef struct
lv_obj_t * label; /*Pointer to label*/
}lv_cb_ext_t;
typedef enum {
LV_CB_STYLE_BG,
LV_CB_STYLE_RELEASED,
LV_CB_STYLE_PRESSED,
LV_CB_STYLE_TGL_RELEASED,
LV_CB_STYLE_TGL_PRESSED,
LV_CB_STYLE_INACTIVE,
}lv_cb_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
......@@ -76,7 +85,7 @@ void lv_cb_set_text(lv_obj_t * cb, const char * txt);
*/
static inline void lv_cb_set_checked(lv_obj_t * cb, bool checked)
{
lv_btn_set_state(cb, checked ? LV_BTN_STATE_TGL_RELEASED : LV_BTN_STATE_RELEASED);
lv_btn_set_state(cb, checked ? LV_BTN_STATE_TGL_REL : LV_BTN_STATE_REL);
}
/**
......@@ -85,7 +94,7 @@ static inline void lv_cb_set_checked(lv_obj_t * cb, bool checked)
*/
static inline void lv_cb_set_inactive(lv_obj_t * cb)
{
lv_btn_set_state(cb, LV_BTN_STATE_INACTIVE);
lv_btn_set_state(cb, LV_BTN_STATE_INA);
}
/**
......@@ -97,32 +106,14 @@ static inline void lv_cb_set_action(lv_obj_t * cb, lv_action_t action)
lv_btn_set_action(cb, LV_BTN_ACTION_RELEASE, action);
}
/**
* Set styles of a checkbox's background is each state. Use NULL for any style to leave it unchanged
* @param cb pointer to check box object
* @param rel pointer to a style for releases state
* @param pr pointer to a style for pressed state
* @param tgl_rel pointer to a style for toggled releases state
* @param tgl_pr pointer to a style for toggled pressed state
* @param ina pointer to a style for inactive state
*/
static inline void lv_cb_set_style(lv_obj_t *cb, lv_style_t *bg)
{
lv_btn_set_style(cb, bg, bg, bg, bg, bg);
}
/**
* Set styles of a checkbox's bullet in each state. Use NULL for any style to leave it unchanged
* Set a style of a check box
* @param cb pointer to check box object
* @param rel pointer to a style for releases state
* @param pr pointer to a style for pressed state
* @param tgl_rel pointer to a style for toggled releases state
* @param tgl_pr pointer to a style for toggled pressed state
* @param ina pointer to a style for inactive state
*/
void lv_cb_set_style_bullet(lv_obj_t *cb, lv_style_t *rel, lv_style_t *pr,
lv_style_t *tgl_rel, lv_style_t *tgl_pr,
lv_style_t *ina);
* @param type which style should be set
* @param style pointer to a style
* */
void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, lv_style_t *style);
/*=====================
* Getter functions
......@@ -142,7 +133,7 @@ const char * lv_cb_get_text(lv_obj_t * cb);
*/
static inline bool lv_cb_get_checked(lv_obj_t * cb)
{
return lv_btn_get_state(cb) == LV_BTN_STATE_RELEASED ? true : false;
return lv_btn_get_state(cb) == LV_BTN_STATE_REL ? true : false;
}
/**
......@@ -155,23 +146,14 @@ static inline lv_action_t lv_cb_get_action(lv_obj_t * cb)
return lv_btn_get_action(cb, LV_BTN_ACTION_RELEASE);
}
/**
* Get the style of a check box's background in a given state
* @param cb pointer to a check box object
* @param state a state from 'lv_btn_state_t' in which style should be get
* @return pointer to the style in the given state
*/
static inline lv_style_t * lv_cb_get_style_bg(lv_obj_t * cb)
{
return lv_btn_get_style(cb, lv_btn_get_state(cb));
}
/**
* Get styles of a checkbox's bullet in a state.
* @param state a state from 'lv_btn_state_t' in which style should be get
* @return pointer to the style in the given state
*/
lv_style_t * lv_cb_get_style_bullet(lv_obj_t *cb, lv_btn_state_t state);
* Get a style of a button
* @param cb pointer to check box object
* @param type which style should be get
* @return style pointer to the style
* */
lv_style_t * lv_cb_get_style(lv_obj_t * cb, lv_cb_style_t type);
/**********************
* MACROS
......
......@@ -30,24 +30,26 @@ typedef struct
{
cord_t * points;
color_t color;
}lv_chart_dl_t;
}lv_chart_series_t;
/*Data of chart */
typedef struct
{
/*No inherited ext*/ /*Ext. of ancestor*/
/*New data for this type */
ll_dsc_t dl_ll; /*Linked list for the data line pointers (stores lv_chart_dl_t)*/
ll_dsc_t series_ll; /*Linked list for the data line pointers (stores lv_chart_dl_t)*/
cord_t ymin; /*y min value (used to scale the data)*/
cord_t ymax; /*y max value (used to scale the data)*/
uint8_t hdiv_cnt; /*Number of horizontal division lines*/
uint8_t vdiv_cnt; /*Number of vertical division lines*/
uint16_t pnum; /*Point number in a data line*/
cord_t dl_width; /*Line width or point radius*/
uint8_t dl_num; /*Number of data lines in dl_ll*/
opa_t dl_opa; /*Opacity of data lines*/
opa_t dl_dark; /*Dark level of the point/column bottoms*/
uint16_t point_cnt; /*Point number in a data line*/
uint8_t type :3; /*Line, column or point chart (from 'lv_chart_type_t')*/
struct {
cord_t width; /*Line width or point radius*/
uint8_t num; /*Number of data lines in dl_ll*/
opa_t opa; /*Opacity of data lines*/
opa_t dark; /*Dark level of the point/column bottoms*/
}series;
}lv_chart_ext_t;
/*Chart types*/
......@@ -71,27 +73,21 @@ typedef enum
*/
lv_obj_t * lv_chart_create(lv_obj_t * par, lv_obj_t * copy);
/**
* Signal function of the chart background
* @param chart pointer to a chart background object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
*/
bool lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param);
/*======================
* Add/remove functions
*=====================*/
/**
* Allocate and add a data line to the chart
* Allocate and add a data series to the chart
* @param chart pointer to a chart object
* @param color color of the data line
* @return pointer to the allocated data line (
* @param color color of the data series
* @return pointer to the allocated data series
*/
lv_chart_dl_t * lv_chart_add_data_line(lv_obj_t * chart, color_t color);
lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, color_t color);
/**
* Refresh a chart if its data line has changed
* @param chart pointer to chart object
*/
void lv_chart_refresh(lv_obj_t * chart);
/*=====================
* Setter functions
*====================*/
/**
* Set the number of horizontal and vertical division lines
......@@ -102,10 +98,8 @@ void lv_chart_refresh(lv_obj_t * chart);
void lv_chart_set_div_line_count(lv_obj_t * chart, uint8_t hdiv, uint8_t vdiv);
/**
* Set the minimal and maximal x and y values
* Set the minimal and maximal y values
* @param chart pointer to a graph background object
* @param xmin x minimum value
* @param xmax x maximum value
* @param ymin y minimum value
* @param ymax y maximum value
*/
......@@ -121,38 +115,52 @@ void lv_chart_set_type(lv_obj_t * chart, lv_chart_type_t type);
/**
* Set the number of points on a data line on a chart
* @param chart pointer r to chart object
* @param pnum new number of points on the data lines
* @param point_cnt new number of points on the data lines
*/
void lv_chart_set_pnum(lv_obj_t * chart, uint16_t pnum);
void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt);
/**
* Set the opacity of the data lines
* @param chart pointer to chart object
* @param opa opacity of the data lines
* Set the opacity of the data series
* @param chart pointer to a chart object
* @param opa opacity of the data series
*/
void lv_chart_set_dl_opa(lv_obj_t * chart, opa_t opa);
void lv_chart_set_series_opa(lv_obj_t * chart, opa_t opa);
/**
* Set the line width or point radius of the data lines
* @param chart pointer to chart object
* Set the line width or point radius of the data series
* @param chart pointer to a chart object
* @param width the new width
*/
void lv_chart_set_dl_width(lv_obj_t * chart, cord_t width);
void lv_chart_set_series_width(lv_obj_t * chart, cord_t width);
/**
* Set the dark effect on the bottom of the points or columns
* @param chart pointer to chart object
* @param chart pointer to a chart object
* @param dark_eff dark effect level (OPA_TRANSP to turn off)
*/
void lv_chart_set_dl_dark(lv_obj_t * chart, opa_t dark_eff);
void lv_chart_set_series_darking(lv_obj_t * chart, opa_t dark_eff);
/**
* Shift all data right and set the most right data on a data line
* @param chart pointer to chart object
* @param dl pointer to a data line on 'chart'
* @param ser pointer to a data series on 'chart'
* @param y the new value of the most right data
*/
void lv_chart_set_next(lv_obj_t * chart, lv_chart_dl_t * dl, cord_t y);
void lv_chart_set_next(lv_obj_t * chart, lv_chart_series_t * ser, cord_t y);
/**
* Set the style of a chart
* @param chart pointer to a chart object
* @param style pointer to a style
*/
static inline void lv_chart_set_style(lv_obj_t *chart, lv_style_t *style)
{
lv_obj_set_style(chart, style);
}
/*=====================
* Getter functions
*====================*/
/**
* Get the type of a chart
......@@ -166,28 +174,48 @@ lv_chart_type_t lv_chart_get_type(lv_obj_t * chart);
* @param chart pointer to chart object
* @return point number on each data line
*/
uint16_t lv_chart_get_pnum(lv_obj_t * chart);
uint16_t lv_chart_get_point_cnt(lv_obj_t * chart);
/**
* Get the opacity of the data lines
* Get the opacity of the data series
* @param chart pointer to chart object
* @return the opacity of the data lines
* @return the opacity of the data series
*/
opa_t lv_chart_get_dl_opa(lv_obj_t * chart);
opa_t lv_chart_get_series_opa(lv_obj_t * chart);
/**
* Get the data line width
* Get the data series width
* @param chart pointer to chart object
* @return the width the data lines (lines or points)
* @return the width the data series (lines or points)
*/
cord_t lv_chart_get_dl_width(lv_obj_t * chart);
cord_t lv_chart_get_series_width(lv_obj_t * chart);
/**
* Get the dark effect level on the bottom of the points or columns
* @param chart pointer to chart object
* @return dark effect level (OPA_TRANSP to turn off)
*/
opa_t lv_chart_get_dl_dark(lv_obj_t * chart, opa_t dark_eff);
opa_t lv_chart_get_series_darking(lv_obj_t * chart, opa_t dark_eff);
/**
* Get the style of an chart object
* @param chart pointer to an chart object
* @return pointer to the chart's style
*/
static inline lv_style_t* lv_chart_get_style(lv_obj_t *chart)
{
return lv_obj_get_style(chart);
}
/*=====================
* Other functions
*====================*/
/**
* Refresh a chart if its data line has changed
* @param chart pointer to chart object
*/
void lv_chart_refresh(lv_obj_t * chart);
/**********************
* MACROS
......
......@@ -202,7 +202,7 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
}
}
return LV_RES_OK;
return res;
}
......
......@@ -93,7 +93,9 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
lv_cont_set_fit(new_ddlist, true, false);
lv_page_set_release_action(new_ddlist, lv_ddlist_release_action);
lv_page_set_sb_mode(new_ddlist, LV_PAGE_SB_MODE_DRAG);
lv_ddlist_set_style(new_ddlist, &lv_style_pretty, NULL, &lv_style_plain_color);
lv_page_set_style(new_ddlist, LV_PAGE_STYLE_SCRL, &lv_style_transp_tight);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_BG, &lv_style_pretty);
lv_ddlist_set_style(new_ddlist, LV_DDLIST_STYLE_SELECTED, &lv_style_plain_color);
lv_ddlist_set_options(new_ddlist, "Option 1\nOption 2\nOption 3");
}
/*Copy an existing drop down list*/
......@@ -195,19 +197,28 @@ void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time)
}
/**
* Set the style of a drop down list
* Set a style of a drop down list
* @param ddlist pointer to a drop down list object
* @param bg pointer to the new style of the background
* @param sb pointer to the new style of the scrollbars (only visible with fix height)
* @param sel pointer to the new style of the select rectangle
* @param type which style should be set
* @param style pointer to a style
*/
void lv_ddlist_set_style(lv_obj_t * ddlist, lv_style_t *bg, lv_style_t *sb, lv_style_t *sel)
void lv_ddlist_set_style(lv_obj_t *ddlist, lv_ddlist_style_t type, lv_style_t *style)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(sel != NULL) ext->selected_style = sel;
lv_obj_set_style(ext->options_label, bg);
lv_page_set_style(ddlist, bg, &lv_style_transp_tight, sb);
switch (type) {
case LV_DDLIST_STYLE_BG:
lv_page_set_style(ddlist, LV_PAGE_STYLE_BG, style);
break;
case LV_DDLIST_STYLE_SB:
lv_page_set_style(ddlist, LV_PAGE_STYLE_SB, style);
break;
case LV_DDLIST_STYLE_SELECTED:
ext->selected_style = style;
lv_obj_t *scrl = lv_page_get_scrl(ddlist);
lv_obj_refresh_ext_size(scrl); /*Because of the wider selected rectangle*/
break;
}
}
/*=====================
......@@ -295,19 +306,27 @@ uint16_t lv_ddlist_get_anim_time(lv_obj_t * ddlist)
return ext->anim_time;
}
/**
* Get the style of the rectangle on the selected option
* Get a style of a drop down list
* @param ddlist pointer to a drop down list object
* @return pointer the style of the select rectangle
* @param type which style should be get
* @return style pointer to a style
*/
lv_style_t * lv_ddlist_get_style_select(lv_obj_t * ddlist)
lv_style_t * lv_ddlist_get_style(lv_obj_t *ddlist, lv_ddlist_style_t type)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(ext->selected_style == NULL) return lv_obj_get_style(ddlist);
return ext->selected_style;
}
switch (type) {
case LV_DDLIST_STYLE_BG: return lv_page_get_style(ddlist, LV_PAGE_STYLE_BG);
case LV_DDLIST_STYLE_SB: return lv_page_get_style(ddlist, LV_PAGE_STYLE_SB);
case LV_DDLIST_STYLE_SELECTED: return ext->selected_style;
default: return NULL;
}
/*To avoid warning*/
return NULL;
}
/*=====================
* Other functions
*====================*/
......@@ -365,7 +384,7 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const area_t * mask, lv_design_m
/*If the list is opened draw a rectangle under the selected item*/
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(ext->opened != 0) {
lv_style_t *style = lv_ddlist_get_style_bg(ddlist);
lv_style_t *style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
const font_t * font = style->text.font;
cord_t font_h = font_get_height_scale(font);
area_t rect_area;
......@@ -404,8 +423,6 @@ lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
if(sign == LV_SIGNAL_STYLE_CHG) {
lv_ddlist_refr_size(ddlist, 0);
lv_obj_t *scrl = lv_page_get_scrl(ddlist);
lv_obj_refresh_ext_size(scrl); /*Because of the wider selected rectangle*/
}
else if(sign == LV_SIGNAL_FOCUS) {
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
......@@ -470,7 +487,7 @@ static lv_res_t lv_ddlist_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void *
/* Because of the wider selected rectangle ext. size
* In this way by dragging the scrollable part the wider rectangle area can be redrawn too*/
lv_obj_t *ddlist = lv_obj_get_parent(scrl);
lv_style_t *style = lv_ddlist_get_style_bg(ddlist);
lv_style_t *style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
if(scrl->ext_size < style->body.padding.hor) scrl->ext_size = style->body.padding.hor;
}
......
......@@ -51,6 +51,11 @@ typedef struct
cord_t fix_height; /*Height if the ddlist is opened. (0: auto-size)*/
}lv_ddlist_ext_t;
typedef enum {
LV_DDLIST_STYLE_BG,
LV_DDLIST_STYLE_SELECTED,
LV_DDLIST_STYLE_SB,
}lv_ddlist_style_t;
/**********************
* GLOBAL PROTOTYPES
......@@ -113,14 +118,14 @@ static inline void lv_ddlist_set_sb_mode(lv_obj_t * ddlist, lv_page_sb_mode_t mo
*/
void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time);
/**
* Set the style of a drop down list
* Set a style of a drop down list
* @param ddlist pointer to a drop down list object
* @param bg pointer to the new style of the background
* @param sb pointer to the new style of the scrollbars (only visible with fix height)
* @param sel pointer to the new style of the select rectangle
*/
void lv_ddlist_set_style(lv_obj_t * ddlist, lv_style_t *bg, lv_style_t *sb, lv_style_t *sel);
* @param type which style should be set
* @param style pointer to a style
* */
void lv_ddlist_set_style(lv_obj_t *ddlist, lv_ddlist_style_t type, lv_style_t *style);
/*=====================
* Getter functions
......@@ -132,6 +137,7 @@ void lv_ddlist_set_style(lv_obj_t * ddlist, lv_style_t *bg, lv_style_t *sb, lv_s
* @return the options separated by '\n'-s (E.g. "Option1\nOption2\nOption3")
*/
const char * lv_ddlist_get_options(lv_obj_t * ddlist);
/**
* Get the selected option
* @param ddlist pointer to drop down list object
......@@ -145,6 +151,7 @@ uint16_t lv_ddlist_get_selected(lv_obj_t * ddlist);
* @param buf pointer to an array to store the string
*/
void lv_ddlist_get_selected_str(lv_obj_t * ddlist, char * buf);
/**
* Get the "option selected" callback function
* @param ddlist pointer to a drop down list
......@@ -176,32 +183,14 @@ static inline lv_page_sb_mode_t lv_ddlist_get_sb_mode(lv_obj_t * ddlist)
*/
uint16_t lv_ddlist_get_anim_time(lv_obj_t * ddlist);
/**
* Get the style of the drop down list background
* @param ddlist pointer to a drop down list object
* @return pointer to the style of the background
*/
static inline lv_style_t * lv_ddlist_get_style_bg(lv_obj_t * ddlist)
{
return lv_page_get_style_bg(ddlist);
}
/**
* Get the style of the scrollbars of a drop down list
* @param ddlist pointer to a drop down list object
* @return pointer to the style of the scrollbars
*/
static inline lv_style_t * lv_ddlist_get_style_sb(lv_obj_t * ddlist)
{
return lv_page_get_style_sb(ddlist);
}
/**
* Get the style of the rectangle on the selected option
* Get a style of a drop down list
* @param ddlist pointer to a drop down list object
* @return pointer the style of the select rectangle
* @param type which style should be get
* @return style pointer to a style
*/
lv_style_t * lv_ddlist_get_style_select(lv_obj_t * ddlist);
lv_style_t * lv_ddlist_get_style(lv_obj_t *ddlist, lv_ddlist_style_t type);
/*=====================
* Other functions
......
......@@ -90,7 +90,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, lv_obj_t * copy)
lv_gauge_set_scale(new_gauge, LV_GAUGE_DEF_ANGLE, LV_GAUGE_DEF_LINE_COUNT, LV_GAUGE_DEF_LABEL_COUNT);
lv_gauge_set_needle_count(new_gauge, 1, NULL);
lv_obj_set_size(new_gauge, 2 * LV_DPI, 2 * LV_DPI);
lv_obj_set_style(new_gauge, &lv_style_pretty);
lv_obj_set_style(new_gauge, &lv_style_pretty_color);
}
/*Copy an existing gauge*/
else {
......
......@@ -184,10 +184,11 @@ static inline uint16_t lv_gauge_get_scale_angle(lv_obj_t * gauge)
* @param gauge pointer to a gauge object
* @return pointer to the gauge's style
*/
static inline lv_style_t * lv_gauge_get_style_bg(lv_obj_t *gauge)
static inline lv_style_t * lv_gauge_get_style(lv_obj_t *gauge)
{
return lv_obj_get_style(gauge);
}
/**********************
* MACROS
**********************/
......
......@@ -335,7 +335,7 @@ static lv_res_t lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param)
}
}
return LV_RES_OK;
return res;
}
......
......@@ -135,7 +135,7 @@ bool lv_img_get_upscale(lv_obj_t * img);
/**
* Get the style of an image object
* @param img pointer to an image object
* @return the style an image
* @return pointer to the image's style
*/
static inline lv_style_t* lv_img_get_style(lv_obj_t *img)
{
......
......@@ -185,6 +185,35 @@ void lv_kb_set_close_action(lv_obj_t * kb, lv_action_t action)
ext->close_action = action;
}
/**
* Set a style of a keyboard
* @param kb pointer to a keyboard object
* @param type which style should be set
* @param style pointer to a style
*/
void lv_kb_set_style(lv_obj_t *kb, lv_kb_style_t type, lv_style_t *style)
{
switch (type) {
case LV_KB_STYLE_BG:
lv_btnm_set_style(kb, LV_BTNM_STYLE_BG, style);
break;
case LV_KB_STYLE_BTN_REL:
lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_REL, style);
break;
case LV_KB_STYLE_BTN_PR:
lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_PR, style);
break;
case LV_KB_STYLE_BTN_TGL_REL:
lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_TGL_REL, style);
break;
case LV_KB_STYLE_BTN_TGL_PR:
lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_TGL_PR, style);
break;
case LV_KB_STYLE_BTN_INA:
lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_INA, style);
break;
}
}
/*=====================
* Getter functions
......@@ -246,6 +275,27 @@ lv_action_t lv_kb_get_close_action(lv_obj_t * kb, lv_action_t action)
return ext->close_action;
}
/**
* Get a style of a keyboard
* @param kb pointer to a keyboard object
* @param type which style should be get
* @return style pointer to a style
*/
lv_style_t * lv_kb_get_style(lv_obj_t *kb, lv_kb_style_t type)
{
switch (type) {
case LV_KB_STYLE_BG: return lv_btnm_get_style(kb, LV_BTNM_STYLE_BG);
case LV_KB_STYLE_BTN_REL: return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_REL);
case LV_KB_STYLE_BTN_PR: return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_PR);
case LV_KB_STYLE_BTN_TGL_REL: return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_REL);
case LV_KB_STYLE_BTN_TGL_PR: return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_PR);
case LV_KB_STYLE_BTN_INA: return lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_INA);
default: return NULL;
}
/*To avoid warning*/
return NULL;
}
/**********************
* STATIC FUNCTIONS
......@@ -302,18 +352,18 @@ static lv_res_t lv_app_kb_action(lv_obj_t * kb, const char * txt)
if(strcmp(txt, "Enter") == 0)lv_ta_add_char(ext->ta, '\n');
else if(strcmp(txt, SYMBOL_LEFT) == 0) lv_ta_cursor_left(ext->ta);
else if(strcmp(txt, SYMBOL_RIGHT) == 0) lv_ta_cursor_right(ext->ta);
else if(strcmp(txt, "Del") == 0) lv_ta_del(ext->ta);
else if(strcmp(txt, "Del") == 0) lv_ta_del_char(ext->ta);
else if(strcmp(txt, "+/-") == 0) {
uint16_t cur = lv_ta_get_cursor_pos(ext->ta);
const char * ta_txt = lv_ta_get_text(ext->ta);
if(ta_txt[0] == '-') {
lv_ta_set_cursor_pos(ext->ta, 1);
lv_ta_del(ext->ta);
lv_ta_del_char(ext->ta);
lv_ta_add_char(ext->ta, '+');
lv_ta_set_cursor_pos(ext->ta, cur);
} else if(ta_txt[0] == '+') {
lv_ta_set_cursor_pos(ext->ta, 1);
lv_ta_del(ext->ta);
lv_ta_del_char(ext->ta);
lv_ta_add_char(ext->ta, '-');
lv_ta_set_cursor_pos(ext->ta, cur);
} else {
......
......@@ -44,14 +44,19 @@ typedef struct {
lv_action_t close_action; /*Called when the "Hide" button is clicked*/
}lv_kb_ext_t;
typedef enum {
LV_KB_STYLE_BG,
LV_KB_STYLE_BTN_REL,
LV_KB_STYLE_BTN_PR,
LV_KB_STYLE_BTN_TGL_REL,
LV_KB_STYLE_BTN_TGL_PR,
LV_KB_STYLE_BTN_INA,
}lv_kb_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a keyboard objects
* @param par pointer to an object, it will be the parent of the new keyboard
......@@ -100,30 +105,12 @@ void lv_kb_set_ok_action(lv_obj_t * kb, lv_action_t action);
void lv_kb_set_close_action(lv_obj_t * kb, lv_action_t action);
/**
* Set the style of a keyboards's background
* Set a style of a keyboard
* @param kb pointer to a keyboard object
* @param bg pointer to the background style
*/
static inline void lv_kb_set_style(lv_obj_t *kb, lv_style_t * bg)
{
lv_btnm_set_style(kb, bg);
}
/**
* Set styles of the buttons is each state. Use NULL for any style to leave it unchanged.
* @param kb pointer to keyboard object
* @param rel pointer to a style for releases state
* @param pr pointer to a style for pressed state
* @param tgl_rel pointer to a style for toggled releases state
* @param tgl_pr pointer to a style for toggled pressed state
* @param ina pointer to a style for inactive state
* @param type which style should be set
* @param style pointer to a style
*/
static inline void lv_kb_set_style_btn(lv_obj_t *kb, lv_style_t *rel, lv_style_t *pr,
lv_style_t *tgl_rel, lv_style_t *tgl_pr,
lv_style_t *ina)
{
lv_btnm_set_style_btn(kb, rel, pr, tgl_rel, tgl_pr, ina);
}
void lv_kb_set_style(lv_obj_t *kb, lv_kb_style_t type, lv_style_t *style);
/*=====================
* Getter functions
......@@ -165,25 +152,12 @@ lv_action_t lv_kb_get_ok_action(lv_obj_t * kb, lv_action_t action);
lv_action_t lv_kb_get_close_action(lv_obj_t * kb, lv_action_t action);
/**
* Get the style of a keyboard
* @param kb pointer to a keyboard object
* @return pointer to the background style
*/
static inline lv_style_t * lv_kb_get_style_bg(lv_obj_t *kb)
{
return lv_btnm_get_style_bg(kb);
}
/**
* Get the style of the buttons of keyboard
* Get a style of a keyboard
* @param kb pointer to a keyboard object
* @param state style in this state (LV_BTN_STATE_PR or LV_BTN_STATE_REL)
* @return pointer the button style in the given state
* @param type which style should be get
* @return style pointer to a style
*/
static inline lv_style_t * lv_kb_kb_style_btn(lv_obj_t *kb, lv_btn_state_t state)
{
return lv_btnm_get_style_btn(kb, state);
}
lv_style_t * lv_kb_get_style(lv_obj_t *kb, lv_kb_style_t type);
/**********************
* MACROS
......
......@@ -234,7 +234,7 @@ uint16_t lv_label_get_letter_on(lv_obj_t * label, point_t * pos);
/**
* Get the style of an label object
* @param label pointer to an label object
* @return the style an label
* @return pointer to the label's style
*/
static inline lv_style_t* lv_label_get_style(lv_obj_t *label)
{
......
......@@ -28,11 +28,13 @@
* STATIC PROTOTYPES
**********************/
static bool lv_led_design(lv_obj_t * led, const area_t * mask, lv_design_mode_t mode);
static lv_res_t lv_led_signal(lv_obj_t * led, lv_signal_t sign, void * param);
/**********************
* STATIC VARIABLES
**********************/
static lv_design_func_t ancestor_design_f;
static lv_signal_func_t ancestor_signal;
/**********************
* MACROS
......@@ -42,10 +44,6 @@ static lv_design_func_t ancestor_design_f;
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a led objects
* @param par pointer to an object, it will be the parent of the new led
......@@ -57,14 +55,14 @@ lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy)
/*Create the ancestor basic object*/
lv_obj_t * new_led = lv_obj_create(par, copy);
dm_assert(new_led);
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_func(new_led);
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_func(new_led);
/*Allocate the object type specific extended data*/
lv_led_ext_t * ext = lv_obj_allocate_ext_attr(new_led, sizeof(lv_led_ext_t));
dm_assert(ext);
ext->bright = LV_LED_BRIGHT_ON;
if(ancestor_design_f == NULL) ancestor_design_f = lv_obj_get_design_func(new_led);
lv_obj_set_signal_func(new_led, lv_led_signal);
lv_obj_set_design_func(new_led, lv_led_design);
......@@ -85,29 +83,6 @@ lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy)
return new_led;
}
/**
* Signal function of the led
* @param led pointer to a led object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return true: the object is still valid (not deleted), false: the object become invalid
*/
bool lv_led_signal(lv_obj_t * led, lv_signal_t sign, void * param)
{
bool valid;
/* Include the ancient signal function */
valid = lv_obj_signal(led, sign, param);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
}
return valid;
}
/*=====================
* Setter functions
*====================*/
......@@ -216,4 +191,21 @@ static bool lv_led_design(lv_obj_t * led, const area_t * mask, lv_design_mode_t
return true;
}
/**
* Signal function of the led
* @param led pointer to a led object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_led_signal(lv_obj_t * led, lv_signal_t sign, void * param)
{
lv_res_t res;
/* Include the ancient signal function */
res = ancestor_signal(led, sign, param);
if(res != LV_RES_OK) return res;
return res;
}
#endif
......@@ -47,15 +47,6 @@ typedef struct
lv_obj_t * lv_led_create(lv_obj_t * par, lv_obj_t * copy);
/**
* Signal function of the led
* @param led pointer to a led object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return true: the object is still valid (not deleted), false: the object become invalid
*/
bool lv_led_signal(lv_obj_t * led, lv_signal_t sign, void * param);
/**
* Set the brightness of a LED object
* @param led pointer to a LED object
* @param bright 0 (max. dark) ... 255 (max. light)
......@@ -87,6 +78,27 @@ void lv_led_tgl(lv_obj_t * led);
*/
uint8_t lv_led_get_bright(lv_obj_t * led);
/**
* Set the style of a led
* @param led pointer to a led object
* @param style pointer to a style
*/
static inline void lv_led_set_style(lv_obj_t *led, lv_style_t *style)
{
lv_obj_set_style(led, style);
}
/**
* Get the style of an led object
* @param led pointer to an led object
* @return pointer to the led's style
*/
static inline lv_style_t* lv_led_get_style(lv_obj_t *led)
{
return lv_obj_get_style(led);
}
/**********************
* MACROS
**********************/
......
......@@ -281,6 +281,6 @@ static lv_res_t lv_line_signal(lv_obj_t * line, lv_signal_t sign, void * param)
res = lv_obj_signal(line, sign, param);
if(res != LV_RES_OK) return res;
return LV_RES_OK;
return res;
}
#endif
......@@ -122,13 +122,13 @@ bool lv_line_get_y_inv(lv_obj_t * line);
bool lv_line_get_upscale(lv_obj_t * line);
/**
* Get the style of an image object
* Get the style of an line object
* @param line pointer to an line object
* @return the style an image
* @return pointer to the line's style
*/
static inline lv_style_t* lv_line_get_style(lv_obj_t *img)
static inline lv_style_t* lv_line_get_style(lv_obj_t *line)
{
return lv_obj_get_style(img);
return lv_obj_get_style(line);
}
/**********************
......
......@@ -53,6 +53,17 @@ typedef struct
lv_style_t *style_img; /*Style of the list element images on buttons*/
}lv_list_ext_t;
typedef enum {
LV_LIST_STYLE_BG,
LV_LIST_STYLE_SCRL,
LV_LIST_STYLE_SB,
LV_LIST_STYLE_BTN_REL,
LV_LIST_STYLE_BTN_PR,
LV_LIST_STYLE_BTN_TGL_REL,
LV_LIST_STYLE_BTN_TGL_PR,
LV_LIST_STYLE_BTN_INA,
}lv_list_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
......@@ -100,30 +111,14 @@ static inline void lv_list_set_sb_mode(lv_obj_t * list, lv_page_sb_mode_t mode)
lv_page_set_sb_mode(list, mode);
}
/**
* Set a new styles for the list
* @param list pointer to a list object
* @param bg pointer to a style for the background (typically transparent)
* @param scrl pointer to a style for the scrollable area
* @param sb pointer to a style for the scroll bars
*/
static inline void lv_list_set_style(lv_obj_t *list, lv_style_t *bg, lv_style_t *scrl, lv_style_t *sb)
{
lv_page_set_style(list, bg, scrl, sb);
}
/**
* Set styles of the list elements of a list in each state
* @param list pointer to list object
* @param rel pointer to a style for releases state
* @param pr pointer to a style for pressed state
* @param tgl_rel pointer to a style for toggled releases state
* @param tgl_pr pointer to a style for toggled pressed state
* @param ina pointer to a style for inactive state
* Set a style of a list
* @param list pointer to a list object
* @param type which style should be set
* @param style pointer to a style
*/
void lv_list_set_style_btn(lv_obj_t * list, lv_style_t * rel, lv_style_t * pr,
lv_style_t * tgl_rel, lv_style_t * tgl_pr,
lv_style_t * ina);
void lv_list_set_style(lv_obj_t *list, lv_list_style_t type, lv_style_t *style);
/*=====================
* Getter functions
......@@ -167,42 +162,12 @@ static inline lv_page_sb_mode_t lv_list_get_sb_mode(lv_obj_t * list)
}
/**
* Get a style of a list's background
* Get a style of a list
* @param list pointer to a list object
* @return pointer to the background's style
*/
static inline lv_style_t * lv_list_get_style_bg(lv_obj_t *list)
{
return lv_page_get_style_bg(list);
}
/**
* Get a style of a list's scrollable part
* @param list pointer to a list object
* @return pointer to the scrollable"s style
*/
static inline lv_style_t * lv_list_get_style_scrl(lv_obj_t *list)
{
return lv_page_get_style_scrl(list);
}
/**
* Get the style of the scrollbars of a list
* @param list pointer to a list object
* @return pointer to the style of the scrollbars
*/
static inline lv_style_t * lv_list_get_style_sb(lv_obj_t *list)
{
return lv_page_get_style_sb(list);
}
/**
* Get the style of the list elements in a given state
* @param list pointer to a list object
* @param state a state from 'lv_btn_state_t' in which style should be get
* @return pointer to the style in the given state
*/
lv_style_t * lv_list_get_style_btn(lv_obj_t * list, lv_btn_state_t state);
* @param type which style should be get
* @return style pointer to a style
* */
lv_style_t * lv_list_get_style(lv_obj_t *list, lv_btn_style_t type);
/*=====================
* Other functions
......
......@@ -296,7 +296,7 @@ static lv_res_t lv_lmeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * par
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
}
return LV_RES_OK;
return res;
}
......
......@@ -21,18 +21,18 @@ extern "C" {
#error "lv_mbox: lv_cont is required. Enable it in lv_conf.h (USE_LV_CONT 1) "
#endif
#if USE_LV_BTN == 0
#error "lv_mbox: lv_btn is required. Enable it in lv_conf.h (USE_LV_BTN 1) "
#if USE_LV_BTNM == 0
#error "lv_mbox: lv_btnm is required. Enable it in lv_conf.h (USE_LV_BTNM 1) "
#endif
#if USE_LV_LABEL == 0
#error "lv_mbox: lv_rlabel is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
#error "lv_mbox: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
#endif
#include "../lv_obj/lv_obj.h"
#include "lv_cont.h"
#include "lv_btn.h"
#include "lv_btnm.h"
#include "lv_label.h"
/*********************
......@@ -48,14 +48,21 @@ typedef struct
{
lv_cont_ext_t bg; /*Ext. of ancestor*/
/*New data for this type */
lv_obj_t * txt; /*Text of the message box*/
lv_obj_t * btnh; /*Holder of the buttons*/
lv_style_t * style_btn_rel; /*Style of the released buttons*/
lv_style_t * style_btn_pr; /*Style of the pressed buttons*/
lv_obj_t *text; /*Text of the message box*/
lv_obj_t *btnm; /*Button matrix for the buttons*/
uint16_t anim_time; /*Duration of close animation [ms] (0: no animation)*/
cord_t btn_width; /*Button width (0: to auto fit)*/
}lv_mbox_ext_t;
typedef enum {
LV_MBOX_STYLE_BG,
LV_MBOX_STYLE_BTN_BG,
LV_MBOX_STYLE_BTN_REL,
LV_MBOX_STYLE_BTN_PR,
LV_MBOX_STYLE_BTN_TGL_REL,
LV_MBOX_STYLE_BTN_TGL_PR,
LV_MBOX_STYLE_BTN_INA,
}lv_mbox_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
......@@ -76,13 +83,13 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, lv_obj_t * copy);
lv_res_t lv_mbox_close_action(lv_obj_t * btn);
/**
* Add a button to the message box
* Set button to the message box
* @param mbox pointer to message box object
* @param btn_txt the text of the button
* @param rel_action a function which will be called when the button is released
* @return pointer to the created button (lv_btn)
* @param btn_map button descriptor (button matrix map).
* E.g. a const char *txt[] = {"ok", "close", ""} (Can not be local variable)
* @param action a function which will be called when a button is released
*/
lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t rel_action);
void lv_mbox_set_btns(lv_obj_t * mbox, const char **btn_map, lv_btnm_action_t action);
/*=====================
* Setter functions
......@@ -96,13 +103,6 @@ lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t re
void lv_mbox_set_text(lv_obj_t * mbox, const char * txt);
/**
* Set the width of the buttons
* @param mbox pointer to message box object
* @param w width of the buttons or 0 to use auto fit
*/
void lv_mbox_set_btn_width(lv_obj_t *mbox, cord_t w);
/**
* Set animation duration
* @param mbox pointer to a message box object
* @param time animation length in milliseconds (0: no animation)
......@@ -123,20 +123,12 @@ void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay);
void lv_mbox_stop_auto_close(lv_obj_t * mbox);
/**
* Set the styles of a message box
* Set a style of a message box
* @param mbox pointer to a message box object
* @param bg pointer to the new background style
* @param btnh pointer to the new button holder style
* @param type which style should be set
* @param style pointer to a style
*/
void lv_mbox_set_style(lv_obj_t *mbox, lv_style_t *bg, lv_style_t *btnh);
/**
* Set styles of the buttons of a message box in each state
* @param mbox pointer to a message box object
* @param rel pointer to a style for releases state
* @param pr pointer to a style for pressed state
*/
void lv_mbox_set_style_btn(lv_obj_t * mbox, lv_style_t * rel, lv_style_t * pr);
void lv_mbox_set_style(lv_obj_t *mbox, lv_mbox_style_t type, lv_style_t *style);
/*=====================
* Getter functions
......@@ -150,13 +142,6 @@ void lv_mbox_set_style_btn(lv_obj_t * mbox, lv_style_t * rel, lv_style_t * pr);
const char * lv_mbox_get_text(lv_obj_t * mbox);
/**
* Get width of the buttons
* @param mbox pointer to a message box object
* @return width of the buttons (0: auto fit enabled)
*/
cord_t lv_mbox_get_btn_width(lv_obj_t * mbox);
/**
* Get the message box object from one of its button.
* It is useful in the button release actions where only the button is known
* @param btn pointer to a button of a message box
......@@ -171,30 +156,14 @@ lv_obj_t * lv_mbox_get_from_btn(lv_obj_t * btn);
*/
uint16_t lv_mbox_get_anim_time(lv_obj_t * mbox);
/**
* Get the style of a message box's background
* @param mbox pointer to a message box object
* @return pointer to the message box's background style
*/
static inline lv_style_t * lv_mbox_get_style_bg(lv_obj_t *mbox)
{
return lv_obj_get_style(mbox);
}
/**
* Get the style of a message box's button holder
* @param mbox pointer to a message box object
* @return pointer to the message box's background style
*/
lv_style_t * lv_mbox_get_style_btnh(lv_obj_t *mbox);
/**
* Get the style of the buttons on a message box
* Get a style of a message box
* @param mbox pointer to a message box object
* @param state a state from 'lv_btn_state_t' in which style should be get
* @return pointer to the style in the given state
* @param type which style should be get
* @return style pointer to a style
*/
lv_style_t * lv_mbox_get_style_btn(lv_obj_t * mbox, lv_btn_state_t state);
lv_style_t * lv_mbox_get_style(lv_obj_t *mbox, lv_mbox_style_t type);
/**********************
* MACROS
......
......@@ -87,7 +87,10 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
* because everything has to be ready before any signal is received*/
lv_obj_set_signal_func(new_page, lv_page_signal);
lv_obj_set_design_func(new_page, lv_page_design);
lv_page_set_style(new_page, &lv_style_pretty_color, &lv_style_pretty, &lv_style_pretty_color);
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, &lv_style_pretty_color);
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, &lv_style_pretty);
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, &lv_style_pretty_color);
lv_page_set_sb_mode(new_page, ext->sb.mode);
} else {
lv_page_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
......@@ -97,7 +100,10 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy)
lv_page_set_press_action(new_page, copy_ext->pr_action);
lv_page_set_release_action(new_page, copy_ext->rel_action);
lv_page_set_sb_mode(new_page, copy_ext->sb.mode);
lv_page_set_style(new_page, lv_obj_get_style(copy), lv_obj_get_style(copy_ext->scrl), copy_ext->sb.style);
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, lv_page_get_style(copy, LV_PAGE_STYLE_BG));
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, lv_page_get_style(copy, LV_PAGE_STYLE_SCRL));
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, lv_page_get_style(copy, LV_PAGE_STYLE_SB));
/* Add the signal function only if 'scrolling' is created
* because everything has to be ready before any signal is received*/
......@@ -155,32 +161,85 @@ void lv_page_set_sb_mode(lv_obj_t * page, lv_page_sb_mode_t sb_mode)
}
/**
* Set a new styles for the page
* Set a style of a page
* @param page pointer to a page object
* @param bg pointer to a style for the background
* @param scrl pointer to a style for the scrollable area
* @param sb pointer to a style for the scroll bars
*/
void lv_page_set_style(lv_obj_t *page, lv_style_t *bg, lv_style_t *scrl, lv_style_t *sb)
* @param type which style should be set
* @param style pointer to a style
* */
void lv_page_set_style(lv_obj_t *page, lv_page_style_t type, lv_style_t *style)
{
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
if(sb != NULL) {
ext->sb.style = sb;
switch (type) {
case LV_PAGE_STYLE_BG:
lv_obj_set_style(page, style);
break;
case LV_PAGE_STYLE_SCRL:
lv_obj_set_style(ext->scrl, style);
break;
case LV_PAGE_STYLE_SB:
ext->sb.style = style;
area_set_height(&ext->sb.hor_area, ext->sb.style->body.padding.inner);
area_set_width(&ext->sb.ver_area, ext->sb.style->body.padding.inner);
lv_page_sb_refresh(page);
if(bg == NULL) {
/*If scrollbars are positioned out of page then ext. size is needed to draw it*/
/*Page's style change signal will handle it but if no bg. style specified do it manually*/
lv_obj_refresh_ext_size(page);
}
lv_obj_invalidate(page);
break;
}
}
/*=====================
* Getter functions
*====================*/
/**
* Get the scrollable object of a page
* @param page pointer to a page object
* @return pointer to a container which is the scrollable part of the page
*/
lv_obj_t * lv_page_get_scrl(lv_obj_t * page)
{
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
return ext->scrl;
}
/**
* Set the scroll bar mode on a page
* @param page pointer to a page object
* @return the mode from 'lv_page_sb.mode_t' enum
*/
lv_page_sb_mode_t lv_page_get_sb_mode(lv_obj_t * page)
{
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
return ext->sb.mode;
}
/**
* Get a style of a page
* @param page pointer to page object
* @param type which style should be get
* @return style pointer to a style
* */
lv_style_t * lv_page_get_style(lv_obj_t *page, lv_page_style_t type)
{
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
switch (type) {
case LV_PAGE_STYLE_BG: return lv_obj_get_style(page);
case LV_PAGE_STYLE_SCRL: return lv_obj_get_style(ext->scrl);
case LV_PAGE_STYLE_SB: return ext->sb.style;
default: return NULL;
}
if(scrl != NULL) lv_obj_set_style(ext->scrl, scrl);
if(bg != NULL) lv_obj_set_style(page, bg);
/*To avoid warning*/
return NULL;
}
/*=====================
* Other functions
*====================*/
/**
* Glue the object to the page. After it the page can be moved (dragged) with this object too.
* @param obj pointer to an object on a page
......@@ -201,8 +260,8 @@ void lv_page_glue_obj(lv_obj_t * obj, bool glue)
void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time)
{
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
lv_style_t * style = lv_page_get_style_bg(page);
lv_style_t * style_scrl = lv_page_get_style_scrl(page);
lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
lv_style_t * style_scrl = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
cord_t obj_y = obj->coords.y1 - ext->scrl->coords.y1;
cord_t obj_h = lv_obj_get_height(obj);
......@@ -252,54 +311,6 @@ void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time)
}
}
/*=====================
* Getter functions
*====================*/
/**
* Get the scrollable object of a page
* @param page pointer to a page object
* @return pointer to a container which is the scrollable part of the page
*/
lv_obj_t * lv_page_get_scrl(lv_obj_t * page)
{
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
return ext->scrl;
}
/**
* Set the scroll bar mode on a page
* @param page pointer to a page object
* @return the mode from 'lv_page_sb.mode_t' enum
*/
lv_page_sb_mode_t lv_page_get_sb_mode(lv_obj_t * page)
{
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
return ext->sb.mode;
}
/**
* Get the style of the scrollable part of a page
* @param page pointer to a page object
* @return pointer to the style of the scrollale part
*/
lv_style_t * lv_page_get_style_scrl(lv_obj_t * page)
{
return lv_obj_get_style(lv_page_get_scrl(page));
}
/**
* Get the style of the scrolbars of a page
* @param page pointer to a page object
* @return pointer to the style of the scrollbars
*/
lv_style_t * lv_page_get_style_sb(lv_obj_t * page)
{
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
return ext->sb.style;
}
/**********************
* STATIC FUNCTIONS
**********************/
......@@ -471,7 +482,7 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
if(page->ext_size < (-ext->sb.style->body.padding.ver)) page->ext_size = -ext->sb.style->body.padding.ver;
}
return LV_RES_OK;
return res;
}
/**
......@@ -593,7 +604,7 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi
}
}
return LV_RES_OK;
return res;
}
......
......@@ -59,11 +59,18 @@ typedef struct
}sb;
}lv_page_ext_t;
typedef enum {
LV_PAGE_STYLE_BG,
LV_PAGE_STYLE_SCRL,
LV_PAGE_STYLE_SB,
}lv_page_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a page objects
* @param par pointer to an object, it will be the parent of the new page
......@@ -72,10 +79,6 @@ typedef struct
*/
lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy);
/*=====================
* Setter functions
*====================*/
/**
* Get the scrollable object of a page
* @param page pointer to a page object
......@@ -83,6 +86,10 @@ lv_obj_t * lv_page_create(lv_obj_t * par, lv_obj_t * copy);
*/
lv_obj_t * lv_page_get_scrl(lv_obj_t * page);
/*=====================
* Setter functions
*====================*/
/**
* Set a release action for the page
* @param page pointer to a page object
......@@ -105,30 +112,6 @@ void lv_page_set_press_action(lv_obj_t * page, lv_action_t pr_action);
void lv_page_set_sb_mode(lv_obj_t * page, lv_page_sb_mode_t sb_mode);
/**
* Set a new styles for the page
* @param page pointer to a page object
* @param bg pointer to a style for the background
* @param scrl pointer to a style for the scrollable area
* @param sb pointer to a style for the scroll bars
*/
void lv_page_set_style(lv_obj_t *page, lv_style_t *bg, lv_style_t *scrl, lv_style_t *sb);
/**
* Glue the object to the page. After it the page can be moved (dragged) with this object too.
* @param obj pointer to an object on a page
* @param glue true: enable glue, false: disable glue
*/
void lv_page_glue_obj(lv_obj_t * obj, bool glue);
/**
* Focus on an object. It ensures that the object will be visible on the page.
* @param page pointer to a page object
* @param obj pointer to an object to focus (must be on the page)
* @param anim_time scroll animation time in milliseconds (0: no animation)
*/
void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time);
/**
* Set the fit attribute of the scrollable part of a page.
* It means it can set its size automatically to involve all children.
* (Can be set separately horizontally and vertically)
......@@ -172,6 +155,14 @@ static inline void lv_page_set_scrl_layout(lv_obj_t * page, lv_cont_layout_t lay
lv_cont_set_layout(lv_page_get_scrl(page), layout);
}
/**
* Set a style of a page
* @param page pointer to a page object
* @param type which style should be set
* @param style pointer to a style
* */
void lv_page_set_style(lv_obj_t *page, lv_page_style_t type, lv_style_t *style);
/*=====================
* Getter functions
*====================*/
......@@ -234,28 +225,31 @@ static inline bool lv_page_get_scrl_fit_ver(lv_obj_t * page)
}
/**
* Get the style of page's background
* @param page pointer to a page object
* @return pointer to the style of background
*/
static inline lv_style_t * lv_page_get_style_bg(lv_obj_t * page)
{
return lv_obj_get_style(page);
}
* Get a style of a page
* @param page pointer to page object
* @param type which style should be get
* @return style pointer to a style
* */
lv_style_t * lv_page_get_style(lv_obj_t *page, lv_page_style_t type);
/*=====================
* Other functions
*====================*/
/**
* Get the style of the scrollable part of a page
* @param page pointer to a page object
* @return pointer to the style of the scrollale part
*/
lv_style_t * lv_page_get_style_scrl(lv_obj_t * page);
* Glue the object to the page. After it the page can be moved (dragged) with this object too.
* @param obj pointer to an object on a page
* @param glue true: enable glue, false: disable glue
*/
void lv_page_glue_obj(lv_obj_t * obj, bool glue);
/**
* Get the style of the scrolbars of a page
* @param page pointer to a page object
* @return pointer to the style of the scrollbars
*/
lv_style_t * lv_page_get_style_sb(lv_obj_t * page);
* Focus on an object. It ensures that the object will be visible on the page.
* @param page pointer to a page object
* @param obj pointer to an object to focus (must be on the page)
* @param anim_time scroll animation time in milliseconds (0: no animation)
*/
void lv_page_focus(lv_obj_t * page, lv_obj_t * obj, uint16_t anim_time);
/**********************
* MACROS
......
......@@ -119,6 +119,24 @@ void lv_roller_set_hor_fit(lv_obj_t *roller, bool fit_en)
lv_cont_set_fit(roller, fit_en ,false);
}
/**
* Set a style of a roller
* @param roller pointer to a roller object
* @param type which style should be set
* @param style pointer to a style
*/
void lv_roller_set_style(lv_obj_t *roller, lv_roller_style_t type, lv_style_t *style)
{
switch (type) {
case LV_ROLLER_STYLE_BG:
lv_obj_set_style(roller, style);
break;
case LV_ROLLER_STYLE_SELECTED:
lv_ddlist_set_style(roller, LV_DDLIST_STYLE_SELECTED, style);
break;
}
}
/*=====================
* Getter functions
*====================*/
......@@ -133,6 +151,24 @@ bool lv_roller_get_hor_fit(lv_obj_t *roller)
return lv_page_get_scrl_hor_fit(roller);
}
/**
* Get a style of a roller
* @param roller pointer to a roller object
* @param type which style should be get
* @return style pointer to a style
* */
lv_style_t * lv_roller_get_style(lv_obj_t *roller, lv_roller_style_t type)
{
switch (type) {
case LV_ROLLER_STYLE_BG: return lv_obj_get_style(roller);
case LV_ROLLER_STYLE_SELECTED: return lv_ddlist_get_style(roller, LV_DDLIST_STYLE_SELECTED);
default: return NULL;
}
/*To avoid warning*/
return NULL;
}
/**********************
* STATIC FUNCTIONS
**********************/
......@@ -159,7 +195,7 @@ static bool lv_roller_design(lv_obj_t * roller, const area_t * mask, lv_design_m
draw_bg(roller, mask);
lv_style_t *style = lv_ddlist_get_style_bg(roller);
lv_style_t *style = lv_roller_get_style(roller, LV_ROLLER_STYLE_BG);
const font_t * font = style->text.font;
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
cord_t font_h = font_get_height_scale(font);
......@@ -281,7 +317,7 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign,
*/
static void draw_bg(lv_obj_t *roller, const area_t *mask)
{
lv_style_t *style = lv_ddlist_get_style_bg(roller);
lv_style_t *style = lv_roller_get_style(roller, LV_ROLLER_STYLE_BG);
area_t half_mask;
area_t half_roller;
cord_t h = lv_obj_get_height(roller);
......
......@@ -32,6 +32,11 @@ typedef struct {
/*New data for this type */
}lv_roller_ext_t;
typedef enum {
LV_ROLLER_STYLE_BG,
LV_ROLLER_STYLE_SELECTED,
}lv_roller_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
......@@ -77,22 +82,20 @@ static inline void lv_roller_set_anim_time(lv_obj_t *roller, uint16_t anim_time)
}
/**
* Set the style of a roller
* @param roller pointer to a roller object
* @param bg pointer to the new style of the background
* @param sel pointer to the new style of the select rectangle
*/
static inline void lv_roller_set_style(lv_obj_t *roller, lv_style_t *bg, lv_style_t *sel)
{
lv_ddlist_set_style(roller, bg, NULL, sel);
}
/**
* Enable/disable to set the width of the roller manually (by lv_obj_Set_width())
* @param roller pointer to a roller object
* @param fit_en: true: enable auto size; false: use manual width settings
*/
void lv_roller_set_hor_fit(lv_obj_t *roller, bool fit_en);
/**
* Set a style of a roller
* @param roller pointer to a roller object
* @param type which style should be set
* @param style pointer to a style
*/
void lv_roller_set_style(lv_obj_t *roller, lv_roller_style_t type, lv_style_t *style);
/*=====================
* Getter functions
*====================*/
......@@ -155,24 +158,12 @@ static inline uint16_t lv_roller_get_anim_time(lv_obj_t * roller)
bool lv_roller_get_hor_fit(lv_obj_t *roller);
/**
* Get the style of the roller's background
* @param roller pointer to a roller object
* @return pointer to the background's style
*/
static inline lv_style_t * lv_roller_get_style_bg(lv_obj_t *roller)
{
return lv_ddlist_get_style_bg(roller);
}
/**
* Get the style of the roller's selected rectangle
* @param roller pointer to a roller object
* @return pointer to the selected rectangle's style
*/
static inline lv_style_t * lv_roller_get_style_selected(lv_obj_t *roller)
{
return lv_ddlist_get_style_select(roller);
}
* Get a style of a roller
* @param roller pointer to a roller object
* @param type which style should be get
* @return style pointer to a style
* */
lv_style_t * lv_roller_get_style(lv_obj_t *roller, lv_roller_style_t type);
/**********************
* MACROS
......
......@@ -75,7 +75,7 @@ lv_obj_t * lv_slider_create(lv_obj_t * par, lv_obj_t * copy)
/*Init the new slider slider*/
if(copy == NULL) {
lv_obj_set_click(new_slider, true);
lv_slider_set_style(new_slider, NULL, NULL, ext->style_knob);
lv_slider_set_style(new_slider, LV_SLIDER_STYLE_KNOB, ext->style_knob);
}
/*Copy an existing slider*/
else {
......@@ -118,22 +118,27 @@ void lv_slider_set_knob_in(lv_obj_t * slider, bool in)
}
/**
* Set the styles of a slider
* Set a style of a slider
* @param slider pointer to a slider object
* @param bg pointer to the background's style (NULL to leave unchanged)
* @param indic pointer to the indicator's style (NULL to leave unchanged)
* @param knob pointer to the knob's style (NULL to leave unchanged)
* @param type which style should be set
* @param style pointer to a style
*/
void lv_slider_set_style(lv_obj_t * slider, lv_style_t *bg, lv_style_t *indic, lv_style_t *knob)
void lv_slider_set_style(lv_obj_t *slider, lv_slider_style_t type, lv_style_t *style)
{
if(knob != NULL) {
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
ext->style_knob = knob;
slider->signal_func(slider, LV_SIGNAL_REFR_EXT_SIZE, NULL);
lv_obj_invalidate(slider);
}
lv_bar_set_style(slider, bg, indic);
switch (type) {
case LV_SLIDER_STYLE_BG:
lv_bar_set_style(slider, LV_BAR_STYLE_BG, style);
break;
case LV_SLIDER_STYLE_INDIC:
lv_bar_set_style(slider, LV_BAR_STYLE_INDIC, style);
break;
case LV_SLIDER_STYLE_KNOB:
ext->style_knob = style;
lv_obj_refresh_ext_size(slider);
break;
}
}
/*=====================
......@@ -175,6 +180,27 @@ bool lv_slider_get_knob_in(lv_obj_t * slider)
return ext->knob_in == 0 ? false : true;
}
/**
* Get a style of a slider
* @param slider pointer to a slider object
* @param type which style should be get
* @return style pointer to a style
*/
lv_style_t * lv_slider_get_style(lv_obj_t *slider, lv_bar_style_t type)
{
lv_slider_ext_t *ext = lv_obj_get_ext_attr(slider);
switch (type) {
case LV_SLIDER_STYLE_BG: return lv_bar_get_style(slider, LV_BAR_STYLE_BG);
case LV_SLIDER_STYLE_INDIC: return lv_bar_get_style(slider, LV_BAR_STYLE_INDIC);
case LV_SLIDER_STYLE_KNOB: return ext->style_knob;
default: return NULL;
}
/*To avoid warning*/
return NULL;
}
/**********************
* STATIC FUNCTIONS
**********************/
......@@ -200,9 +226,9 @@ static bool lv_slider_design(lv_obj_t * slider, const area_t * mask, lv_design_m
else if(mode == LV_DESIGN_DRAW_MAIN) {
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
lv_style_t * style_slider = lv_slider_get_style_bg(slider);
lv_style_t * style_knob = lv_slider_get_style_knob(slider);
lv_style_t * style_indic = lv_slider_get_style_indicator(slider);
lv_style_t * style_slider = lv_slider_get_style(slider, LV_SLIDER_STYLE_BG);
lv_style_t * style_knob = lv_slider_get_style(slider, LV_SLIDER_STYLE_KNOB);
lv_style_t * style_indic = lv_slider_get_style(slider, LV_SLIDER_STYLE_INDIC);
/*Draw the bar*/
area_t area_bar;
......@@ -386,6 +412,6 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par
}
}
return LV_RES_OK;
return res;
}
#endif
......@@ -40,8 +40,10 @@ typedef struct
/*Built-in styles of slider*/
typedef enum
{
LV_SLIDERS_DEF,
}lv_sliders_builtin_t;
LV_SLIDER_STYLE_BG,
LV_SLIDER_STYLE_INDIC,
LV_SLIDER_STYLE_KNOB,
}lv_slider_style_t;
/**********************
* GLOBAL PROTOTYPES
......@@ -107,13 +109,12 @@ void lv_slider_set_action(lv_obj_t * slider, lv_action_t action);
void lv_slider_set_knob_in(lv_obj_t * slider, bool in);
/**
* Set the styles of a slider
* Set a style of a slider
* @param slider pointer to a slider object
* @param bg pointer to the background's style (NULL to leave unchanged)
* @param indic pointer to the indicator's style (NULL to leave unchanged)
* @param knob pointer to the knob's style (NULL to leave unchanged)
* @param type which style should be set
* @param style pointer to a style
*/
void lv_slider_set_style(lv_obj_t * slider, lv_style_t *bg, lv_style_t *indic, lv_style_t *knob);
void lv_slider_set_style(lv_obj_t *slider, lv_slider_style_t type, lv_style_t *style);
/*=====================
* Getter functions
......@@ -171,25 +172,14 @@ lv_style_t * lv_slider_get_style_knob(lv_obj_t * slider);
*/
bool lv_slider_get_knob_in(lv_obj_t * slider);
/**
* Get the style of the slider's background
* @param slider pointer to a slider object
* @return pointer to the slider's background style
*/
static inline lv_style_t * lv_slider_get_style_bg(lv_obj_t * slider)
{
return lv_bar_get_style_bg(slider);
}
/**
* Get the style of slider indicator
* @param bar pointer to a slider object
* @return pointer to the slider indicator style
* Get a style of a slider
* @param slider pointer to a slider object
* @param type which style should be get
* @return style pointer to a style
*/
static inline lv_style_t * lv_slider_get_style_indicator(lv_obj_t * slider)
{
return lv_bar_get_style_indicator(slider);
}
lv_style_t * lv_slider_get_style(lv_obj_t *slider, lv_bar_style_t type);
/**********************
* MACROS
......
......@@ -57,6 +57,8 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, lv_obj_t * copy)
/*Initialize the allocated 'ext' */
ext->changed = 0;
ext->style_knob_off = ext->slider.style_knob;
ext->style_knob_on = ext->slider.style_knob;
/*The signal and design functions are not copied so set them here*/
lv_obj_set_signal_func(new_sw, lv_sw_signal);
......@@ -70,11 +72,11 @@ lv_obj_t * lv_sw_create(lv_obj_t * par, lv_obj_t * copy)
/*Copy an existing switch*/
else {
lv_sw_ext_t *copy_ext = lv_obj_get_ext_attr(copy);
ext->knob_off_style = copy_ext->knob_off_style;
ext->knob_on_style = copy_ext->knob_on_style;
ext->style_knob_off = copy_ext->style_knob_off;
ext->style_knob_on = copy_ext->style_knob_on;
if(lv_sw_get_state(new_sw)) lv_slider_set_style(new_sw, NULL, NULL, ext->knob_on_style);
else lv_slider_set_style(new_sw, NULL, NULL, ext->knob_off_style);
if(lv_sw_get_state(new_sw)) lv_slider_set_style(new_sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_on);
else lv_slider_set_style(new_sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_off);
/*Refresh the style with new signal function*/
lv_obj_refresh_style(new_sw);
}
......@@ -94,7 +96,7 @@ void lv_sw_set_on(lv_obj_t *sw)
{
lv_sw_ext_t *ext = lv_obj_get_ext_attr(sw);
lv_slider_set_value(sw, 1);
lv_slider_set_style(sw, NULL, NULL,ext->knob_on_style);
lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB,ext->style_knob_on);
}
/**
......@@ -105,26 +107,35 @@ void lv_sw_set_off(lv_obj_t *sw)
{
lv_sw_ext_t *ext = lv_obj_get_ext_attr(sw);
lv_slider_set_value(sw, 0);
lv_slider_set_style(sw, NULL, NULL,ext->knob_off_style);
lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB,ext->style_knob_off);
}
/**
* Set the styles of a switch
* Set a style of a switch
* @param sw pointer to a switch object
* @param bg pointer to the background's style
* @param indic pointer to the indicator's style
* @param knob_off pointer to the knob's style when the switch is OFF
* @param knob_on pointer to the knob's style when the switch is ON
* @param type which style should be set
* @param style pointer to a style
*/
void lv_sw_set_style(lv_obj_t * sw, lv_style_t *bg, lv_style_t *indic, lv_style_t *knob_off, lv_style_t *knob_on)
void lv_sw_set_style(lv_obj_t *sw, lv_sw_style_t type, lv_style_t *style)
{
lv_sw_ext_t *ext = lv_obj_get_ext_attr(sw);
ext->knob_on_style = knob_on;
ext->knob_off_style = knob_off;
lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw);
if(lv_sw_get_state(sw)) lv_slider_set_style(sw, bg, indic, knob_on);
else lv_slider_set_style(sw, bg, indic, knob_off);
switch (type) {
case LV_SLIDER_STYLE_BG:
lv_slider_set_style(sw, LV_SLIDER_STYLE_BG, style);
break;
case LV_SLIDER_STYLE_INDIC:
lv_bar_set_style(sw, LV_SLIDER_STYLE_INDIC, style);
break;
case LV_SW_STYLE_KNOB_OFF:
ext->style_knob_off = style;
if(lv_sw_get_state(sw) == 0) lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, style);
break;
case LV_SW_STYLE_KNOB_ON:
ext->style_knob_on = style;
if(lv_sw_get_state(sw) != 0) lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, style);
break;
}
}
/*=====================
......@@ -132,28 +143,26 @@ void lv_sw_set_style(lv_obj_t * sw, lv_style_t *bg, lv_style_t *indic, lv_style_
*====================*/
/**
* Get the style of the switch's knob when the switch is OFF
* Get a style of a switch
* @param sw pointer to a switch object
* @return pointer to the switch's knob OFF style
* @param type which style should be get
* @return style pointer to a style
*/
lv_style_t * lv_sw_get_style_knob_off(lv_obj_t *sw)
lv_style_t * lv_sw_get_style(lv_obj_t *sw, lv_bar_style_t type)
{
lv_sw_ext_t *ext = lv_obj_get_ext_attr(sw);
return ext->knob_off_style;
}
switch (type) {
case LV_SW_STYLE_BG: return lv_slider_get_style(sw, LV_SLIDER_STYLE_BG);
case LV_SW_STYLE_INDIC: return lv_slider_get_style(sw, LV_SLIDER_STYLE_INDIC);
case LV_SW_STYLE_KNOB_OFF: return ext->style_knob_off;
case LV_SW_STYLE_KNOB_ON: return ext->style_knob_on;
default: return NULL;
}
/**
* Get the style of the switch's knob when the switch is ON
* @param sw pointer to a switch object
* @return pointer to the switch's knob ON style
*/
lv_style_t * lv_sw_get_style_knob_on(lv_obj_t *sw)
{
lv_sw_ext_t *ext = lv_obj_get_ext_attr(sw);
return ext->knob_on_style;
/*To avoid warning*/
return NULL;
}
/**********************
* STATIC FUNCTIONS
**********************/
......@@ -192,8 +201,8 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
}
else if(sign == LV_SIGNAL_PRESS_LOST) {
ext->changed = 0;
if(lv_sw_get_state(sw)) lv_slider_set_style(sw, NULL, NULL, ext->knob_on_style);
else lv_slider_set_style(sw, NULL, NULL, ext->knob_off_style);
if(lv_sw_get_state(sw)) lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_on);
else lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_off);
}
else if(sign == LV_SIGNAL_RELEASED) {
if(ext->changed == 0) {
......@@ -202,8 +211,8 @@ static lv_res_t lv_sw_signal(lv_obj_t * sw, lv_signal_t sign, void * param)
else lv_slider_set_value(sw, 0);
}
if(lv_sw_get_state(sw)) lv_slider_set_style(sw, NULL, NULL, ext->knob_on_style);
else lv_slider_set_style(sw, NULL, NULL, ext->knob_off_style);
if(lv_sw_get_state(sw)) lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_on);
else lv_slider_set_style(sw, LV_SLIDER_STYLE_KNOB, ext->style_knob_off);
if(slider_cb != NULL) slider_cb(sw);
......
......@@ -36,11 +36,18 @@ typedef struct
{
lv_slider_ext_t slider; /*Ext. of ancestor*/
/*New data for this type */
lv_style_t *knob_off_style; /*Style of the knob when the switch is OFF*/
lv_style_t *knob_on_style; /*Style of the knob when the switch is ON (NULL to use the same as OFF)*/
lv_style_t *style_knob_off; /*Style of the knob when the switch is OFF*/
lv_style_t *style_knob_on; /*Style of the knob when the switch is ON (NULL to use the same as OFF)*/
uint8_t changed :1; /*Indicates the switch explicitly changed by drag*/
}lv_sw_ext_t;
typedef enum {
LV_SW_STYLE_BG,
LV_SW_STYLE_INDIC,
LV_SW_STYLE_KNOB_OFF,
LV_SW_STYLE_KNOB_ON,
}lv_sw_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
......@@ -80,14 +87,12 @@ static inline void lv_sw_set_action(lv_obj_t * sw, lv_action_t action)
}
/**
* Set the styles of a switch
* Set a style of a switch
* @param sw pointer to a switch object
* @param bg pointer to the background's style
* @param indic pointer to the indicator's style
* @param knob_off pointer to the knob's style when the switch is OFF
* @param knob_on pointer to the knob's style when the switch is ON
* @param type which style should be set
* @param style pointer to a style
*/
void lv_sw_set_style(lv_obj_t * sw, lv_style_t *bg, lv_style_t *indic, lv_style_t *knob_off, lv_style_t *knob_on);
void lv_sw_set_style(lv_obj_t *sw, lv_sw_style_t type, lv_style_t *style);
/*=====================
* Getter functions
......@@ -114,39 +119,12 @@ static inline lv_action_t lv_sw_get_action(lv_obj_t * slider)
}
/**
* Get the style of the switch's background
* @param sw pointer to a switch object
* @return pointer to the switch's background style
*/
static inline lv_style_t * lv_sw_get_style_bg(lv_obj_t *sw)
{
return lv_slider_get_style_bg(sw);
}
/**
* Get the style of the switch's indicator
* @param sw pointer to a switch object
* @return pointer to the switch's indicator style
*/
static inline lv_style_t * lv_sw_get_style_indicator(lv_obj_t *sw)
{
return lv_slider_get_style_indicator(sw);
}
/**
* Get the style of the switch's knob when the switch is OFF
* Get a style of a switch
* @param sw pointer to a switch object
* @return pointer to the switch's knob OFF style
* @param type which style should be get
* @return style pointer to a style
*/
lv_style_t * lv_sw_get_style_knob_off(lv_obj_t *sw);
/**
* Get the style of the switch's knob when the switch is ON
* @param sw pointer to a switch object
* @return pointer to the switch's knob ON style
*/
lv_style_t * lv_sw_get_style_knob_on(lv_obj_t *sw);
lv_style_t * lv_sw_get_style(lv_obj_t *sw, lv_bar_style_t type);
/**********************
* MACROS
......
......@@ -62,10 +62,17 @@ typedef struct
uint8_t cursor_state :1; /*Indicates that the cursor is visible now or not (Handled by the library)*/
}lv_ta_ext_t;
typedef enum {
LV_TA_STYLE_BG,
LV_TA_STYLE_SB,
LV_TA_STYLE_CURSOR,
}lv_ta_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a text area objects
* @param par pointer to an object, it will be the parent of the new text area
......@@ -74,9 +81,10 @@ typedef struct
*/
lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy);
/*=====================
* Setter functions
*====================*/
/*======================
* Add/remove functions
*=====================*/
/**
* Insert a character to the current cursor position
......@@ -93,6 +101,16 @@ void lv_ta_add_char(lv_obj_t * ta, char c);
void lv_ta_add_text(lv_obj_t * ta, const char * txt);
/**
* Delete a the left character from the current cursor position
* @param ta pointer to a text area object
*/
void lv_ta_del_char(lv_obj_t * ta);
/*=====================
* Setter functions
*====================*/
/**
* Set the text of a text area
* @param ta pointer to a text area
* @param txt pointer to the text
......@@ -100,44 +118,15 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt);
void lv_ta_set_text(lv_obj_t * ta, const char * txt);
/**
* Delete a the left character from the current cursor position
* @param ta pointer to a text area object
*/
void lv_ta_del(lv_obj_t * ta);
/**
* Set the cursor position
* @param obj pointer to a text area object
* @param pos the new cursor position in character index
* < 0 : index from the end of the text
* LV_TA_CUR_LAST: go after the last character
* LV_TA_CURSOR_LAST: go after the last character
*/
void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos);
/**
* Move the cursor one character right
* @param ta pointer to a text area object
*/
void lv_ta_cursor_right(lv_obj_t * ta);
/**
* Move the cursor one character left
* @param ta pointer to a text area object
*/
void lv_ta_cursor_left(lv_obj_t * ta);
/**
* Move the cursor one line down
* @param ta pointer to a text area object
*/
void lv_ta_cursor_down(lv_obj_t * ta);
/**
* Move the cursor one line up
* @param ta pointer to a text area object
*/
void lv_ta_cursor_up(lv_obj_t * ta);
/**
* Set the cursor visibility.
* @param ta pointer to a text area object
* @return show true: show the cursor and blink it, false: hide cursor
......@@ -150,7 +139,6 @@ void lv_ta_set_cursor_show(lv_obj_t * ta, bool show);
* @param cur_type: element of 'lv_ta_cursor_type_t'
*/
void lv_ta_set_cursor_type(lv_obj_t * ta, lv_ta_cursor_type_t cur_type);
/**
* Enable/Disable password mode
* @param ta pointer to a text area object
......@@ -176,13 +164,12 @@ static inline void lv_ta_set_sb_mode(lv_obj_t * ta, lv_page_sb_mode_t mode)
}
/**
* Set the style of the text area
* Set a style of a text area
* @param ta pointer to a text area object
* @param bg pointer to the new background style (NULL to leave unchanged)
* @param sb pointer to the new scrollbar style (NULL to leave unchanged)
* @param cur pointer to the new cursor style (NULL to use the label's style)
* @param type which style should be set
* @param style pointer to a style
*/
void lv_ta_set_style(lv_obj_t * ta, lv_style_t *bg, lv_style_t *sb, lv_style_t *cur);
void lv_ta_set_style(lv_obj_t *ta, lv_ta_style_t type, lv_style_t *style);
/*=====================
* Getter functions
......@@ -202,7 +189,6 @@ const char * lv_ta_get_text(lv_obj_t * ta);
*/
lv_obj_t * lv_ta_get_label(lv_obj_t * ta);
/**
* Get the current cursor position in character index
* @param ta pointer to a text area object
......@@ -249,31 +235,40 @@ static inline lv_page_sb_mode_t lv_ta_get_sb_mode(lv_obj_t * ta)
}
/**
* Get the style of the text area background
* @param ta pointer to a text area object
* @return pointer to the style of the background
*/
static inline lv_style_t * lv_ta_get_style_bg(lv_obj_t * ta)
{
return lv_page_get_style_bg(ta);
}
* Get a style of a text area
* @param ta pointer to a text area object
* @param type which style should be get
* @return style pointer to a style
*/
lv_style_t * lv_ta_get_style(lv_obj_t *ta, lv_ta_style_t type);
/*=====================
* Other functions
*====================*/
/**
* Get the style of the scrollbars of a text area
* @param ta pointer to a text area object
* @return pointer to the style of the scrollbars
*/
static inline lv_style_t * lv_ta_get_style_sb(lv_obj_t * ta)
{
return lv_page_get_style_sb(ta);
}
* Move the cursor one character right
* @param ta pointer to a text area object
*/
void lv_ta_cursor_right(lv_obj_t * ta);
/**
* Move the cursor one character left
* @param ta pointer to a text area object
*/
void lv_ta_cursor_left(lv_obj_t * ta);
/**
* Get the style of the cursor
* Move the cursor one line down
* @param ta pointer to a text area object
* @return style pointer to the new cursor style
*/
lv_style_t * lv_ta_get_style_cursor(lv_obj_t * ta);
void lv_ta_cursor_down(lv_obj_t * ta);
/**
* Move the cursor one line up
* @param ta pointer to a text area object
*/
void lv_ta_cursor_up(lv_obj_t * ta);
/**********************
* MACROS
......
......@@ -46,7 +46,7 @@ typedef struct
{
/*Ext. of ancestor*/
/*New data for this type */
lv_obj_t * tabs;
lv_obj_t * btns;
lv_obj_t * indic;
lv_obj_t * content; /*A rectangle to show the current tab*/
const char ** tab_name_ptr;
......@@ -59,39 +59,53 @@ typedef struct
lv_tabview_action_t tab_load_action;
}lv_tabview_ext_t;
typedef enum {
LV_TABVIEW_STYLE_BG,
LV_TABVIEW_STYLE_BTN_BG,
LV_TABVIEW_STYLE_BTN_REL,
LV_TABVIEW_STYLE_BTN_PR,
LV_TABVIEW_STYLE_BTN_TGL_REL,
LV_TABVIEW_STYLE_BTN_TGL_PR,
LV_TABVIEW_STYLE_BTN_INA,
LV_TABVIEW_STYLE_INDIC,
}lv_tabview_style_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a Tab view objects
* Create a Tab view object
* @param par pointer to an object, it will be the parent of the new tab
* @param copy pointer to a tab object, if not NULL then the new object will be copied from it
* @return pointer to the created tab
*/
lv_obj_t * lv_tabview_create(lv_obj_t * par, lv_obj_t * copy);
/**
* Signal function of the Tab view
* @param tab pointer to a tab object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return true: the object is still valid (not deleted), false: the object become invalid
*/
bool lv_tabview_signal(lv_obj_t * tab, lv_signal_t sign, void * param);
/*======================
* Add/remove functions
*=====================*/
/**
* Realign and resize the elements of Tab view
* @param tabview pointer to a Tab view object
* Add a new tab with the given name
* @param tabview pointer to Tab view object where to ass the new tab
* @param name the text on the tab button
* @return pointer to the created page object (lv_page). You can create your content here
*/
void lv_tabview_realign(lv_obj_t * tabview);
lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name);
/*=====================
* Setter functions
*====================*/
/**
* Set a new tab
* @param tabview pointer to Tab view object
* @param id index of a tab to load
* @param anim_en true: set with sliding animation; false: set immediately
*/
void lv_tabview_set_act(lv_obj_t * tabview, uint16_t id, bool anim_en);
void lv_tabview_set_current_tab(lv_obj_t * tabview, uint16_t id, bool anim_en);
/**
* Set an action to call when a tab is loaded (Good to create content only if required)
......@@ -99,7 +113,7 @@ void lv_tabview_set_act(lv_obj_t * tabview, uint16_t id, bool anim_en);
* @param tabview pointer to a tabview object
* @param action pointer to a function to call when a tab is loaded
*/
void lv_tabview_set_tab_load_action(lv_obj_t *tabview,lv_tabview_action_t action);
void lv_tabview_set_tab_load_action(lv_obj_t *tabview, lv_tabview_action_t action);
/**
* Set the animation time of tab view when a new tab is loaded
......@@ -109,47 +123,39 @@ void lv_tabview_set_tab_load_action(lv_obj_t *tabview,lv_tabview_action_t action
void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time_ms);
/**
* Set the height of the tab buttons
* @param tabview pointer to a tabview object
* @param h the new height
*/
void lv_tabview_set_btn_height(lv_obj_t *tabview, cord_t h);
void lv_tabview_set_style(lv_obj_t *tabview, lv_tabview_style_t type, lv_style_t *style);
/*=====================
* Getter functions
*====================*/
/**
* Get the index of the currently active tab
* @param tabview pointer to Tab view object
* @return the active tab index
*/
uint16_t lv_tabview_get_tab_act(lv_obj_t * tabview);
uint16_t lv_tabview_get_current_tab(lv_obj_t * tabview);
/**
* Get the number of tabs
* @param tabview pointer to Tab view object
* @return tab count
*/
uint16_t lv_tabview_get_tab_cnt(lv_obj_t * tabview);
uint16_t lv_tabview_get_tab_count(lv_obj_t * tabview);
/**
* Get the page (content area) of a tab
* @param tabview pointer to Tab view object
* @param id index of the tab (>= 0)
* @return pointer to page (lv_page) object
*/
lv_obj_t * lv_tabview_get_tab_page(lv_obj_t * tabview, uint16_t id);
/**
* Get the tab button matrix (lv_btnm) of a Tab view
* @param tabview pointer to Tab view object
* @return pointer to button matrix (lv_btnm) object which is the tab buttons
*/
lv_obj_t * lv_tabview_get_tabs(lv_obj_t * tabview);
/**
* Get the indicator rectangle (lv_obj) of a Tab view
* @param tabview pointer to Tab view object
* @return pointer to Base object (lv_obj) which is the indicator rectangle on the tab buttons
*/
lv_obj_t * lv_tabview_get_indic(lv_obj_t * tabview);
/**
* Add a new tab with the given name
* @param tabview pointer to Tab view object where to ass the new tab
* @param name the text on the tab button
* @return pointer to page object (lv_page) which is the containter of the contet
*/
lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name);
lv_obj_t * lv_tabview_get_tab(lv_obj_t * tabview, uint16_t id);
/**
* Get the tab load action
......@@ -157,6 +163,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name);
* @param return the current tab load action
*/
lv_tabview_action_t lv_tabview_get_tab_load_action(lv_obj_t *tabview);
/**
* Get the animation time of tab view when a new tab is loaded
* @param tabview pointer to Tab view object
......@@ -164,6 +171,15 @@ lv_tabview_action_t lv_tabview_get_tab_load_action(lv_obj_t *tabview);
*/
uint16_t lv_tabview_get_anim_time(lv_obj_t * tabview, uint16_t anim_time_ms);
/**
* Get a style of a tab view
* @param tabview pointer to a ab view object
* @param type which style should be get
* @return style pointer to a style
*/
lv_style_t * lv_tabview_get_style(lv_obj_t *tabview, lv_tabview_style_t type);
/**********************
* MACROS
**********************/
......
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