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

set function order

This commit is contained in:
Gabor Kiss-Vamosi 2017-11-10 15:01:40 +01:00
parent 4ecd589d84
commit 8f715434ac
28 changed files with 1023 additions and 1063 deletions

View File

@ -44,10 +44,6 @@ static lv_signal_func_t ancestor_signal;
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a bar objects
* @param par pointer to an object, it will be the parent of the new bar

View File

@ -52,6 +52,10 @@ typedef struct
*/
lv_obj_t * lv_bar_create(lv_obj_t * par, lv_obj_t * copy);
/*=====================
* Setter functions
*====================*/
/**
* Set a new value on the bar
* @param bar pointer to a bar object
@ -67,23 +71,27 @@ void lv_bar_set_value(lv_obj_t * bar, int16_t value);
*/
void lv_bar_set_value_anim(lv_obj_t * bar, int16_t value, uint16_t anim_time);
/**
* Set minimum and the maximum values of a bar
* @param bar pointer to he bar object
* @param bar pointer to the bar object
* @param min minimum value
* @param max maximum value
*/
void lv_bar_set_range(lv_obj_t * bar, int16_t min, int16_t max);
/**
* Set the styles of a bar
* @param bar pointer to a bar object
* @param bg pointer to the background's style
* @param indic pointer to the indicator's style
* @param bg pointer to the background's style (NULL to leave unchanged)
* @param indic pointer to the indicator's style (NULL to leave unchanged)
*/
void lv_bar_set_style(lv_obj_t * bar, lv_style_t * bg, lv_style_t * indic);
/*=====================
* Getter functions
*====================*/
/**
* Get the value of a bar
* @param bar pointer to a bar object
@ -105,17 +113,6 @@ 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 indicator
* @param bar pointer to a bar object
* @return pointer to the bar indicator style
*/
lv_style_t * lv_bar_get_style_indicator(lv_obj_t * bar);
/****************************
* TRANSPARENT API FUNCTIONS
***************************/
/**
* Get the style of bar background
* @param bar pointer to a bar object
@ -126,6 +123,14 @@ 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
* @param bar pointer to a bar object
* @return pointer to the bar indicator style
*/
lv_style_t * lv_bar_get_style_indicator(lv_obj_t * bar);
/**********************
* MACROS
**********************/

View File

@ -238,7 +238,6 @@ lv_style_t * lv_btn_get_style(lv_obj_t * btn, lv_btn_state_t state)
return ext->styles[state];
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@ -70,6 +70,7 @@ typedef struct
* GLOBAL PROTOTYPES
**********************/
/**
* Create a button objects
* @param par pointer to an object, it will be the parent of the new button
@ -78,8 +79,12 @@ typedef struct
*/
lv_obj_t * lv_btn_create(lv_obj_t * par, lv_obj_t * copy);
/*=====================
* Setter functions
*====================*/
/**
* Enable the toggled states
* Enable the toggled states. On release the button will change from/to toggled state.
* @param btn pointer to a button object
* @param tgl true: enable toggled states, false: disable
*/
@ -105,6 +110,28 @@ void lv_btn_toggle(lv_obj_t * btn);
*/
void lv_btn_set_action(lv_obj_t * btn, lv_btn_action_t type, lv_action_t action);
/**
* Set the layout on a button
* @param btn pointer to a button object
* @param layout a layout from 'lv_cont_layout_t'
*/
static inline void lv_btn_set_layout(lv_obj_t * btn, lv_cont_layout_t layout)
{
lv_cont_set_layout(btn, layout);
}
/**
* Enable the horizontal or vertical fit.
* The button size will be set to involve the children horizontally or vertically.
* @param btn pointer to a button object
* @param hor_en true: enable the horizontal fit
* @param ver_en true: enable the vertical fit
*/
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
* @param btn pointer to button object
@ -112,11 +139,15 @@ void lv_btn_set_action(lv_obj_t * btn, lv_btn_action_t type, lv_action_t action)
* @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 inactive pointer to a style for inactive 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);
lv_style_t *tgl_rel, lv_style_t *tgl_pr,
lv_style_t *ina);
/*=====================
* Getter functions
*====================*/
/**
* Get the current state of the button
@ -139,40 +170,6 @@ bool lv_btn_get_toggle(lv_obj_t * btn);
*/
lv_action_t lv_btn_get_action(lv_obj_t * btn, lv_btn_action_t type);
/**
* 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);
/****************************
* TRANSPARENT API FUNCTIONS
***************************/
/**
* Set the layout on a button
* @param btn pointer to a button object
* @param layout a layout from 'lv_cont_layout_t'
*/
static inline void lv_btn_set_layout(lv_obj_t * btn, lv_cont_layout_t layout)
{
lv_cont_set_layout(btn, layout);
}
/**
* Enable the horizontal or vertical fit.
* The button size will be set to involve the children horizontally or vertically.
* @param btn pointer to a button object
* @param hor_en true: enable the horizontal fit
* @param ver_en true: enable the vertical fit
*/
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);
}
/**
* Get the layout of a button
* @param btn pointer to button object
@ -203,6 +200,14 @@ static inline bool lv_btn_get_ver_fit(lv_obj_t * btn)
return lv_cont_get_ver_fit(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);
/**********************
* MACROS
**********************/

View File

@ -27,6 +27,7 @@
/**********************
* STATIC PROTOTYPES
**********************/
static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param);
static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_t mode);
static uint8_t get_button_width(const char * btn_str);
static bool button_is_hidden(const char * btn_str);
@ -44,6 +45,7 @@ static const char * lv_btnm_def_map[] = {"Btn1","Btn2", "Btn3","\n",
"\002Btn4","Btn5", ""};
static lv_design_func_t ancestor_design_f;
static lv_signal_func_t ancestor_signal;
/**********************
* MACROS
@ -53,10 +55,6 @@ static lv_design_func_t ancestor_design_f;
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a button matrix objects
* @param par pointer to an object, it will be the parent of the new button matrix
@ -68,13 +66,14 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
/*Create the ancestor object*/
lv_obj_t * new_btnm = lv_obj_create(par, copy);
dm_assert(new_btnm);
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_func(new_btnm);
/*Allocate the object type specific extended data*/
lv_btnm_ext_t * ext = lv_obj_allocate_ext_attr(new_btnm, sizeof(lv_btnm_ext_t));
dm_assert(ext);
ext->button_cnt = 0;
ext->button_id_pressed = LV_BTNM_PR_NONE;
ext->button_id_toggled = LV_BTNM_PR_NONE;
ext->btn_cnt = 0;
ext->btn_id_pressed = LV_BTNM_PR_NONE;
ext->btn_id_toggled = LV_BTNM_PR_NONE;
ext->button_areas = NULL;
ext->action = NULL;
ext->map_p = NULL;
@ -101,144 +100,14 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy)
lv_btnm_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
memcpy(ext->styles_btn, copy_ext->styles_btn, sizeof(ext->styles_btn));
ext->action = copy_ext->action;
ext->toggle = copy_ext->toggle;
ext->btn_id_toggled = copy_ext->btn_id_toggled;
lv_btnm_set_map(new_btnm, lv_btnm_get_map(copy));
}
return new_btnm;
}
/**
* Signal function of the button matrix
* @param btnm pointer to a button matrix 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_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
{
bool valid;
/* Include the ancient signal function */
valid = lv_obj_signal(btnm, sign, param);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
area_t btnm_area;
area_t btn_area;
point_t p;
if(sign == LV_SIGNAL_CLEANUP) {
dm_free(ext->button_areas);
}
else if(sign == LV_SIGNAL_STYLE_CHG || sign == LV_SIGNAL_CORD_CHG) {
lv_btnm_set_map(btnm, ext->map_p);
}
else if(sign == LV_SIGNAL_PRESSING) {
uint16_t btn_pr;
/*Search the pressed area*/
lv_indev_get_point(param, &p);
btn_pr = get_button_from_point(btnm, &p);
/*Invalidate to old and the new areas*/;
lv_obj_get_coords(btnm, &btnm_area);
if(btn_pr != ext->button_id_pressed) {
lv_indev_reset_lpr(param);
if(ext->button_id_pressed != LV_BTNM_PR_NONE) {
area_cpy(&btn_area, &ext->button_areas[ext->button_id_pressed]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area);
}
if(btn_pr != LV_BTNM_PR_NONE) {
area_cpy(&btn_area, &ext->button_areas[btn_pr]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area);
}
}
ext->button_id_pressed = btn_pr;
}
else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
if(ext->action && ext->button_id_pressed != LV_BTNM_PR_NONE) {
uint16_t txt_i = get_button_text(btnm, ext->button_id_pressed);
if(txt_i != LV_BTNM_PR_NONE) {
if(button_is_repeat_disabled(ext->map_p[txt_i]) == false &&
button_is_inactive(ext->map_p[txt_i]) == false) {
ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
}
}
}
}
else if(sign == LV_SIGNAL_RELEASED) {
if(ext->button_id_pressed != LV_BTNM_PR_NONE) {
if(ext->action) {
uint16_t txt_i = get_button_text(btnm, ext->button_id_pressed);
if(txt_i != LV_BTNM_PR_NONE && button_is_inactive(ext->map_p[txt_i]) == false) {
ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
}
}
/*Invalidate to old pressed area*/;
lv_obj_get_coords(btnm, &btnm_area);
area_cpy(&btn_area, &ext->button_areas[ext->button_id_pressed]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area);
if(ext->toggle != 0) {
/*Invalidate to old toggled area*/;
area_cpy(&btn_area, &ext->button_areas[ext->button_id_toggled]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area);
ext->button_id_toggled = ext->button_id_pressed;
}
ext->button_id_pressed = LV_BTNM_PR_NONE;
}
} else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
ext->button_id_pressed = LV_BTNM_PR_NONE;
lv_obj_invalidate(btnm);
} else if(sign == LV_SIGNAL_FOCUS) {
ext->button_id_pressed = 0;
lv_obj_invalidate(btnm);
} else if(sign == LV_SIGNAL_CONTROLL) {
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
char c = *((char*)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
if(ext->button_id_pressed == LV_BTNM_PR_NONE) ext->button_id_pressed = 0;
else ext->button_id_pressed++;
if(ext->button_id_pressed >= ext->button_cnt - 1) ext->button_id_pressed = ext->button_cnt - 1;
lv_obj_invalidate(btnm);
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) {
if(ext->button_id_pressed == LV_BTNM_PR_NONE) ext->button_id_pressed = 0;
if(ext->button_id_pressed > 0) ext->button_id_pressed--;
lv_obj_invalidate(btnm);
} else if(c == LV_GROUP_KEY_ENTER) {
if(ext->action != NULL) {
uint16_t txt_i = get_button_text(btnm, ext->button_id_pressed);
if(txt_i != LV_BTNM_PR_NONE) {
ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
}
}
}
}
}
return valid;
}
/*=====================
* Setter functions
*====================*/
@ -347,10 +216,10 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map)
* @param btnm: pointer to button matrix object
* @param cb pointer to a callback function
*/
void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_action_t cb)
void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_action_t action)
{
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
ext->action = cb;
ext->action = action;
}
/**
@ -365,10 +234,10 @@ 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->button_cnt) id = LV_BTNM_PR_NONE;
ext->button_id_toggled = id;
if(id > ext->btn_cnt) id = LV_BTNM_PR_NONE;
ext->btn_id_toggled = id;
} else {
ext->button_id_toggled = LV_BTNM_PR_NONE;
ext->btn_id_toggled = LV_BTNM_PR_NONE;
}
lv_obj_invalidate(btnm);
@ -478,7 +347,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
uint16_t btn_i = 0;
uint16_t txt_i = 0;
for(btn_i = 0; btn_i < ext->button_cnt; btn_i ++, txt_i ++) {
for(btn_i = 0; btn_i < ext->btn_cnt; btn_i ++, txt_i ++) {
/*Search the next valid text in the map*/
while(strcmp(ext->map_p[txt_i], "\n") == 0) txt_i ++;
@ -498,10 +367,10 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
/*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->button_id_pressed && btn_i != ext->button_id_toggled) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_RELEASED);
else if(btn_i == ext->button_id_pressed && btn_i != ext->button_id_toggled) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_PRESSED);
else if(btn_i != ext->button_id_pressed && btn_i == ext->button_id_toggled) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_TGL_RELEASED);
else if(btn_i == ext->button_id_pressed && btn_i == ext->button_id_toggled) btn_style = lv_btnm_get_style_btn(btnm, LV_BTN_STATE_TGL_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_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);
lv_draw_rect(&area_tmp, mask, btn_style);
/*Calculate the size of the text*/
@ -524,6 +393,138 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
return true;
}
/**
* Signal function of the button matrix
* @param btnm pointer to a button matrix 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_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param)
{
lv_res_t res;
/* Include the ancient signal function */
res = ancestor_signal(btnm, sign, param);
if(res != LV_RES_OK) return res;
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
area_t btnm_area;
area_t btn_area;
point_t p;
if(sign == LV_SIGNAL_CLEANUP) {
dm_free(ext->button_areas);
}
else if(sign == LV_SIGNAL_STYLE_CHG || sign == LV_SIGNAL_CORD_CHG) {
lv_btnm_set_map(btnm, ext->map_p);
}
else if(sign == LV_SIGNAL_PRESSING) {
uint16_t btn_pr;
/*Search the pressed area*/
lv_indev_get_point(param, &p);
btn_pr = get_button_from_point(btnm, &p);
/*Invalidate to old and the new areas*/;
lv_obj_get_coords(btnm, &btnm_area);
if(btn_pr != ext->btn_id_pressed) {
lv_indev_reset_lpr(param);
if(ext->btn_id_pressed != LV_BTNM_PR_NONE) {
area_cpy(&btn_area, &ext->button_areas[ext->btn_id_pressed]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area);
}
if(btn_pr != LV_BTNM_PR_NONE) {
area_cpy(&btn_area, &ext->button_areas[btn_pr]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area);
}
}
ext->btn_id_pressed = btn_pr;
}
else if(sign == LV_SIGNAL_LONG_PRESS_REP) {
if(ext->action && ext->btn_id_pressed != LV_BTNM_PR_NONE) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pressed);
if(txt_i != LV_BTNM_PR_NONE) {
if(button_is_repeat_disabled(ext->map_p[txt_i]) == false &&
button_is_inactive(ext->map_p[txt_i]) == false) {
ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
}
}
}
}
else if(sign == LV_SIGNAL_RELEASED) {
if(ext->btn_id_pressed != LV_BTNM_PR_NONE) {
if(ext->action) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pressed);
if(txt_i != LV_BTNM_PR_NONE && button_is_inactive(ext->map_p[txt_i]) == false) {
ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
}
}
/*Invalidate to old pressed area*/;
lv_obj_get_coords(btnm, &btnm_area);
area_cpy(&btn_area, &ext->button_areas[ext->btn_id_pressed]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area);
if(ext->toggle != 0) {
/*Invalidate to old toggled area*/;
area_cpy(&btn_area, &ext->button_areas[ext->btn_id_toggled]);
btn_area.x1 += btnm_area.x1;
btn_area.y1 += btnm_area.y1;
btn_area.x2 += btnm_area.x1;
btn_area.y2 += btnm_area.y1;
lv_inv_area(&btn_area);
ext->btn_id_toggled = ext->btn_id_pressed;
}
ext->btn_id_pressed = LV_BTNM_PR_NONE;
}
}
else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) {
ext->btn_id_pressed = LV_BTNM_PR_NONE;
lv_obj_invalidate(btnm);
}
else if(sign == LV_SIGNAL_FOCUS) {
ext->btn_id_pressed = 0;
lv_obj_invalidate(btnm);
}
else if(sign == LV_SIGNAL_CONTROLL) {
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
char c = *((char*)param);
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_UP) {
if(ext->btn_id_pressed == LV_BTNM_PR_NONE) ext->btn_id_pressed = 0;
else ext->btn_id_pressed++;
if(ext->btn_id_pressed >= ext->btn_cnt - 1) ext->btn_id_pressed = ext->btn_cnt - 1;
lv_obj_invalidate(btnm);
} else if(c == LV_GROUP_KEY_LEFT || c == LV_GROUP_KEY_DOWN) {
if(ext->btn_id_pressed == LV_BTNM_PR_NONE) ext->btn_id_pressed = 0;
if(ext->btn_id_pressed > 0) ext->btn_id_pressed--;
lv_obj_invalidate(btnm);
} else if(c == LV_GROUP_KEY_ENTER) {
if(ext->action != NULL) {
uint16_t txt_i = get_button_text(btnm, ext->btn_id_pressed);
if(txt_i != LV_BTNM_PR_NONE) {
ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i]));
}
}
}
}
return res;
}
/**
* Create the required number of buttons according to a map
* @param btnm pointer to button matrix object
@ -549,7 +550,7 @@ static void create_buttons(lv_obj_t * btnm, const char ** map)
}
ext->button_areas = dm_alloc(sizeof(area_t) * btn_cnt);
ext->button_cnt = btn_cnt;
ext->btn_cnt = btn_cnt;
}
/**
@ -621,7 +622,7 @@ static uint16_t get_button_from_point(lv_obj_t * btnm, point_t * p)
uint16_t i;
lv_obj_get_coords(btnm, &btnm_cords);
for(i = 0; i < ext->button_cnt; i++) {
for(i = 0; i < ext->btn_cnt; i++) {
area_cpy(&btn_area, &ext->button_areas[i]);
btn_area.x1 += btnm_cords.x1;
btn_area.y1 += btnm_cords.y1;
@ -632,7 +633,7 @@ static uint16_t get_button_from_point(lv_obj_t * btnm, point_t * p)
}
}
if(i == ext->button_cnt) i = LV_BTNM_PR_NONE;
if(i == ext->btn_cnt) i = LV_BTNM_PR_NONE;
return i;
}
@ -646,7 +647,7 @@ static uint16_t get_button_from_point(lv_obj_t * btnm, point_t * p)
static uint16_t get_button_text(lv_obj_t * btnm, uint16_t btn_id)
{
lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm);
if(btn_id > ext->button_cnt) return LV_BTNM_PR_NONE;
if(btn_id > ext->btn_cnt) return LV_BTNM_PR_NONE;
uint16_t txt_i = 0;
uint16_t btn_i = 0;
@ -659,7 +660,7 @@ static uint16_t get_button_text(lv_obj_t * btnm, uint16_t btn_id)
if(strcmp(ext->map_p[txt_i], "\n") == 0) txt_i ++;
}
if(btn_i == ext->button_cnt) return LV_BTNM_PR_NONE;
if(btn_i == ext->btn_cnt) return LV_BTNM_PR_NONE;
return txt_i;
}

View File

@ -51,9 +51,9 @@ typedef struct
area_t *button_areas; /*Array of areas of buttons*/
lv_btnm_action_t action; /*A function to call when a button is releases*/
lv_style_t *styles_btn[LV_BTN_STATE_NUM]; /*Styles of buttons in each state*/
uint16_t button_cnt; /*Number of button in 'map_p'(Handled by the library)*/
uint16_t button_id_pressed; /*Index of the currently pressed button or LV_BTNM_PR_NONE*/
uint16_t button_id_toggled; /*Index of the currently toggled button or LV_BTNM_PR_NONE */
uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/
uint16_t btn_id_pressed; /*Index of the currently pressed button or LV_BTNM_PR_NONE*/
uint16_t btn_id_toggled; /*Index of the currently toggled button or LV_BTNM_PR_NONE */
uint8_t toggle :1; /*Enable toggling*/
}lv_btnm_ext_t;
@ -61,7 +61,6 @@ typedef struct
* GLOBAL PROTOTYPES
**********************/
/**
* Create a button matrix objects
* @param par pointer to an object, it will be the parent of the new button matrix
@ -70,14 +69,9 @@ typedef struct
*/
lv_obj_t * lv_btnm_create(lv_obj_t * par, lv_obj_t * copy);
/**
* Signal function of the button matrix
* @param btnm pointer to a button matrix 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_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param);
/*=====================
* Setter functions
*====================*/
/**
* Set a new map. Buttons will be created/deleted according to the map.
@ -98,9 +92,9 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map);
/**
* Set a new callback function for the buttons (It will be called when a button is released)
* @param btnm: pointer to button matrix object
* @param cb pointer to a callback function
* @param action pointer to a callback function
*/
void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_action_t cb);
void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_action_t action);
/**
* Enable or disable button toggling
@ -110,19 +104,33 @@ void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_action_t cb);
*/
void lv_btnm_set_toggle(lv_obj_t * btnm, bool en, uint16_t id);
/**
* Set the style of a button matrix's background
* @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_style pointer to a style for releases state
* @param pr_style pointer to a style for pressed state
* @param tgl_rel_style pointer to a style for toggled releases state
* @param tgl_pr_style pointer to a style for toggled pressed state
* @param inactive_style pointer to a style for inactive state
* @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_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);
/*=====================
* Getter functions
*====================*/
/**
* Get the current map of a button matrix
* @param btnm pointer to a button matrix object
@ -137,29 +145,6 @@ 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 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
*/
lv_style_t * lv_btnm_get_style_btn(lv_obj_t * btnm, lv_btn_state_t state);
/****************************
* TRANSPARENT API FUNCTIONS
***************************/
/**
* Set the style of a button matrix's background
* @param btnm pointer to a button matrix object
* @param bg pointer to the background style
*/
static inline void lv_btnm_set_style_bg(lv_obj_t *btnm, lv_style_t * bg)
{
lv_obj_set_style(btnm, bg);
}
/**
* Get the style of a button matrix
* @param btnm pointer to a button matrix object
@ -170,6 +155,14 @@ static inline lv_style_t * lv_btnm_get_style_bg(lv_obj_t *btnm)
return lv_obj_get_style(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
*/
lv_style_t * lv_btnm_get_style_btn(lv_obj_t * btnm, lv_btn_state_t state);
/**********************
* MACROS
**********************/

View File

@ -42,10 +42,6 @@ static lv_signal_func_t ancestor_signal;
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a check box objects
* @param par pointer to an object, it will be the parent of the new check box
@ -80,7 +76,7 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy)
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_bg(new_cb, &lv_style_transp);
lv_cb_set_style(new_cb, &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);
@ -117,7 +113,7 @@ void lv_cb_set_text(lv_obj_t * cb, const char * txt)
}
/**
* Set styles of a checkbox's bullet is each state. Use NULL for any style to leave it unchanged
* Set styles of a checkbox's bullet in 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
@ -149,6 +145,17 @@ 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)
{
lv_cb_ext_t * ext = lv_obj_get_ext_attr(cb);
return lv_btn_get_style(ext->bullet, state);
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@ -58,6 +58,10 @@ typedef struct
*/
lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy);
/*=====================
* Setter functions
*====================*/
/**
* Set the text of a check box
* @param cb pointer to a check box
@ -65,30 +69,6 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, lv_obj_t * copy);
*/
void lv_cb_set_text(lv_obj_t * cb, const char * txt);
/**
* Set styles of a checkbox's bullet is each state. Use NULL for any style to leave it unchanged
* @param cb pointer to checkbox 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);
/**
* Get the text of a check box
* @param cb pointer to check box object
* @return pointer to the text of the check box
*/
const char * lv_cb_get_text(lv_obj_t * cb);
/******************************
* TRANSPARENT API FUNCTIONS
******************************/
/**
* Set the state of the check box
* @param cb pointer to a check box object
@ -126,11 +106,35 @@ static inline void lv_cb_set_action(lv_obj_t * cb, lv_action_t action)
* @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_bg(lv_obj_t *cb, lv_style_t *bg)
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
* @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);
/*=====================
* Getter functions
*====================*/
/**
* Get the text of a check box
* @param cb pointer to check box object
* @return pointer to the text of the check box
*/
const char * lv_cb_get_text(lv_obj_t * cb);
/**
* Get the current state of the check box
* @param cb pointer to a check box object
@ -151,7 +155,6 @@ 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
@ -163,6 +166,12 @@ 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);
/**********************
* MACROS

View File

@ -55,10 +55,6 @@ static lv_signal_func_t ancestor_signal;
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a container objects
* @param par pointer to an object, it will be the parent of the new container
@ -173,7 +169,6 @@ bool lv_cont_get_ver_fit(lv_obj_t * cont)
return ext->ver_fit == 0 ? false : true;
}
/**********************
* STATIC FUNCTIONS
**********************/

View File

@ -62,22 +62,41 @@ typedef struct
*/
lv_obj_t * lv_cont_create(lv_obj_t * par, lv_obj_t * copy);
/*=====================
* Setter functions
*====================*/
/**
* Set the layout on a container
* Set a layout on a container
* @param cont pointer to a container object
* @param layout a layout from 'lv_cont_layout_t'
*/
void lv_cont_set_layout(lv_obj_t * cont, lv_cont_layout_t layout);
/**
* Enable the horizontal or vertical fit.
* The container size will be set to involve the children horizontally or vertically.
* @param cont pointer to a container object
* @param hor_en true: enable the horizontal padding
* @param ver_en true: enable the vertical padding
* @param hor_en true: enable the horizontal fit
* @param ver_en true: enable the vertical fit
*/
void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en);
/**
* Set the style of a container
* @param cont pointer to a container object
* @param style pointer to the new style
*/
static inline void lv_cont_set_style(lv_obj_t *cont, lv_style_t * style)
{
lv_obj_set_style(cont, style);
}
/*=====================
* Getter functions
*====================*/
/**
* Get the layout of a container
* @param cont pointer to container object
@ -93,26 +112,12 @@ lv_cont_layout_t lv_cont_get_layout(lv_obj_t * cont);
bool lv_cont_get_hor_fit(lv_obj_t * cont);
/**
* Get vertical fit enable attribute of a button
* @param btn pointer to a button object
* @return true: vertical padding is enabled; false: disabled
* Get vertical fit enable attribute of a container
* @param cont pointer to a container object
* @return true: vertical fit is enabled; false: disabled
*/
bool lv_cont_get_ver_fit(lv_obj_t * cont);
/****************************
* TRANSPARENT API FUNCTIONS
***************************/
/**
* Set the style of a container
* @param cont pointer to a container object
* @param style pointer to the new style
*/
static inline void lv_cont_set_style(lv_obj_t *cont, lv_style_t * style)
{
lv_obj_set_style(cont, style);
}
/**
* Get the style of a container
* @param cont pointer to a container object

View File

@ -49,10 +49,6 @@ static lv_design_func_t ancestor_design;
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a drop down list objects
* @param par pointer to an object, it will be the parent of the new drop down list
@ -198,32 +194,6 @@ void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time)
ext->anim_time = anim_time;
}
/**
* Open the drop down list with or without animation
* @param ddlist pointer to drop down list object
* @param anim true: use animation; false: not use animations
*/
void lv_ddlist_open(lv_obj_t * ddlist, bool anim)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
ext->opened = 1;
lv_obj_set_drag(lv_page_get_scrl(ddlist), true);
lv_ddlist_refr_size(ddlist, anim ? ext->anim_time : 0);
}
/**
* Close (Collapse) the drop down list
* @param ddlist pointer to drop down list object
* @param anim true: use animation; false: not use animations
*/
void lv_ddlist_close(lv_obj_t * ddlist, bool anim)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
ext->opened = 0;
lv_obj_set_drag(lv_page_get_scrl(ddlist), false);
lv_ddlist_refr_size(ddlist, anim ? ext->anim_time : 0);
}
/**
* Set the style of a drop down list
* @param ddlist pointer to a drop down list object
@ -314,6 +284,17 @@ cord_t lv_ddlist_get_fix_height(lv_obj_t * ddlist)
return ext->fix_height;
}
/**
* Get the open/close animation time.
* @param ddlist pointer to a drop down list
* @return open/close animation time [ms]
*/
uint16_t lv_ddlist_get_anim_time(lv_obj_t * ddlist)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->anim_time;
}
/**
* Get the style of the rectangle on the selected option
* @param ddlist pointer to a drop down list object
@ -327,15 +308,34 @@ lv_style_t * lv_ddlist_get_style_select(lv_obj_t * ddlist)
return ext->selected_style;
}
/*=====================
* Other functions
*====================*/
/**
* Get the open/close animation time.
* @param ddlist pointer to a drop down list
* @return open/close animation time [ms]
* Open the drop down list with or without animation
* @param ddlist pointer to drop down list object
* @param anim true: use animation; false: not use animations
*/
uint16_t lv_ddlist_get_anim_time(lv_obj_t * ddlist)
void lv_ddlist_open(lv_obj_t * ddlist, bool anim)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->anim_time;
ext->opened = 1;
lv_obj_set_drag(lv_page_get_scrl(ddlist), true);
lv_ddlist_refr_size(ddlist, anim ? ext->anim_time : 0);
}
/**
* Close (Collapse) the drop down list
* @param ddlist pointer to drop down list object
* @param anim true: use animation; false: not use animations
*/
void lv_ddlist_close(lv_obj_t * ddlist, bool anim)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
ext->opened = 0;
lv_obj_set_drag(lv_page_get_scrl(ddlist), false);
lv_ddlist_refr_size(ddlist, anim ? ext->anim_time : 0);
}
/**********************

View File

@ -55,7 +55,6 @@ typedef struct
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a drop down list objects
* @param par pointer to an object, it will be the parent of the new drop down list
@ -64,6 +63,10 @@ typedef struct
*/
lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy);
/*=====================
* Setter functions
*====================*/
/**
* Set the options in a drop down list from a string
* @param ddlist pointer to drop down list object
@ -93,6 +96,16 @@ void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t action);
*/
void lv_ddlist_set_fix_height(lv_obj_t * ddlist, cord_t h);
/**
* Set the scroll bar mode of a drop down list
* @param ddlist pointer to a drop down list object
* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
*/
static inline void lv_ddlist_set_sb_mode(lv_obj_t * ddlist, lv_page_sb_mode_t mode)
{
lv_page_set_sb_mode(ddlist, mode);
}
/**
* Set the open/close animation time.
* @param ddlist pointer to a drop down list
@ -100,20 +113,6 @@ void lv_ddlist_set_fix_height(lv_obj_t * ddlist, cord_t h);
*/
void lv_ddlist_set_anim_time(lv_obj_t * ddlist, uint16_t anim_time);
/**
* Open the drop down list with or without animation
* @param ddlist pointer to drop down list object
* @param anim true: use animation; false: not use animations
*/
void lv_ddlist_open(lv_obj_t * ddlist, bool anim);
/**
* Close (Collapse) the drop down list
* @param ddlist pointer to drop down list object
* @param anim true: use animation; false: not use animations
*/
void lv_ddlist_close(lv_obj_t * ddlist, bool anim);
/**
* Set the style of a drop down list
* @param ddlist pointer to a drop down list object
@ -121,7 +120,11 @@ void lv_ddlist_close(lv_obj_t * ddlist, bool anim);
* @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);
void lv_ddlist_set_style(lv_obj_t * ddlist, lv_style_t *bg, lv_style_t *sb, lv_style_t *sel);
/*=====================
* Getter functions
*====================*/
/**
* Get the options of a drop down list
@ -129,7 +132,6 @@ void lv_ddlist_set_style(lv_obj_t * ddlist, lv_style_t * bg, lv_style_t * sb, lv
* @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
@ -143,7 +145,6 @@ 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
@ -158,35 +159,6 @@ lv_action_t lv_ddlist_get_action(lv_obj_t * ddlist);
*/
cord_t lv_ddlist_get_fix_height(lv_obj_t * ddlist);
/**
* Get the style of the rectangle on the selected option
* @param ddlist pointer to a drop down list object
* @return pointer the style of the select rectangle
*/
lv_style_t * lv_ddlist_get_style_select(lv_obj_t * ddlist);
/**
* Get the open/close animation time.
* @param ddlist pointer to a drop down list
* @return open/close animation time [ms]
*/
uint16_t lv_ddlist_get_anim_time(lv_obj_t * ddlist);
/****************************
* TRANSPARENT API FUNCTIONS
***************************/
/**
* Set the scroll bar mode of a drop down list
* @param ddlist pointer to a drop down list object
* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
*/
static inline void lv_ddlist_set_sb_mode(lv_obj_t * ddlist, lv_page_sb_mode_t mode)
{
lv_page_set_sb_mode(ddlist, mode);
}
/**
* Get the scroll bar mode of a drop down list
* @param ddlist pointer to a drop down list object
@ -197,6 +169,13 @@ static inline lv_page_sb_mode_t lv_ddlist_get_sb_mode(lv_obj_t * ddlist)
return lv_page_get_sb_mode(ddlist);
}
/**
* Get the open/close animation time.
* @param ddlist pointer to a drop down list
* @return open/close animation time [ms]
*/
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
@ -217,6 +196,29 @@ 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
* @param ddlist pointer to a drop down list object
* @return pointer the style of the select rectangle
*/
lv_style_t * lv_ddlist_get_style_select(lv_obj_t * ddlist);
/*=====================
* Other functions
*====================*/
/**
* Open the drop down list with or without animation
* @param ddlist pointer to drop down list object
* @param anim true: use animation; false: not use animations
*/
void lv_ddlist_open(lv_obj_t * ddlist, bool anim);
/**
* Close (Collapse) the drop down list
* @param ddlist pointer to drop down list object
* @param anim true: use animation; false: not use animations
*/
void lv_ddlist_close(lv_obj_t * ddlist, bool anim);
/**********************
* MACROS

View File

@ -24,41 +24,40 @@
/**********************
* STATIC PROTOTYPES
**********************/
#if 0 /*Use Button matrix design*/
static bool lv_kb_design(lv_obj_t * kb, const area_t * mask, lv_design_mode_t mode);
#endif
static lv_res_t lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param);
static lv_res_t lv_app_kb_action(lv_obj_t * kb, const char * txt);
/**********************
* STATIC VARIABLES
**********************/
static lv_signal_func_t ancestor_signal;
static const char * kb_map_lc[] = {
"\2051#", "\204q", "\204w", "\204e", "\204r", "\204t", "\204y", "\204u", "\204i", "\204o", "\204p", "\207Del", "\n",
"\206ABC", "\203a", "\203s", "\203d", "\203f", "\203g", "\203h", "\203j", "\203k", "\203l", "\207Enter", "\n",
"_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
"\203Hide", "\203Left", "\206 ", "\203Right", "\203Ok", ""
"\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, ""
};
static const char * kb_map_uc[] = {
"\2051#", "\204Q", "\204W", "\204E", "\204R", "\204T", "\204Y", "\204U", "\204I", "\204O", "\204P", "\207Del", "\n",
"\206abc", "\203A", "\203S", "\203D", "\203F", "\203G", "\203H", "\203J", "\203K", "\203L", "\207Enter", "\n",
"_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n",
"\203Hide", "\203Left", "\206 ", "\203Right", "\203Ok", ""
"\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, ""
};
static const char * kb_map_spec[] = {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "\202Del", "\n",
"\202abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
"\\", "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
"\203Hide", "\203Left", "\206 ", "\203Right", "\203Ok", ""
"\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, ""
};
static const char * kb_map_num[] = {
"1", "2", "3", "\202Hide","\n",
"4", "5", "6", "\202Ok", "\n",
"1", "2", "3", "\202"SYMBOL_CLOSE,"\n",
"4", "5", "6", "\202"SYMBOL_OK, "\n",
"7", "8", "9", "\202Del", "\n",
"+/-", "0", ".", "Left", "Right", ""
"+/-", "0", ".", SYMBOL_LEFT, SYMBOL_RIGHT, ""
};
/**********************
* MACROS
@ -68,10 +67,6 @@ static const char * kb_map_num[] = {
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a keyboard objects
* @param par pointer to an object, it will be the parent of the new keyboard
@ -83,6 +78,7 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, lv_obj_t * copy)
/*Create the ancestor of keyboard*/
lv_obj_t * new_kb = lv_btnm_create(par, copy);
dm_assert(new_kb);
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_func(new_kb);
/*Allocate the keyboard type specific extended data*/
lv_kb_ext_t * ext = lv_obj_allocate_ext_attr(new_kb, sizeof(lv_kb_ext_t));
@ -122,31 +118,6 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, lv_obj_t * copy)
return new_kb;
}
/**
* Signal function of the keyboard
* @param kb pointer to a keyboard 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_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param)
{
bool valid;
/* Include the ancient signal function */
valid = lv_btnm_signal(kb, sign, param);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
if(sign == LV_SIGNAL_CLEANUP) {
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
}
}
return valid;
}
/*=====================
* Setter functions
*====================*/
@ -280,35 +251,27 @@ lv_action_t lv_kb_get_close_action(lv_obj_t * kb, lv_action_t action)
* STATIC FUNCTIONS
**********************/
#if 0 /*Use Button matrix design*/
/**
* Handle the drawing related tasks of the keyboards
* @param kb pointer to an object
* @param mask the object will be drawn only in this area
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
* (return 'true' if yes)
* LV_DESIGN_DRAW: draw the object (always return 'true')
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
* @param return true/false, depends on 'mode'
* Signal function of the keyboard
* @param kb pointer to a keyboard 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 bool lv_kb_design(lv_obj_t * kb, const area_t * mask, lv_design_mode_t mode)
static lv_res_t lv_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param)
{
/*Return false if the object is not covers the mask_p area*/
if(mode == LV_DESIGN_COVER_CHK) {
return false;
}
/*Draw the object*/
else if(mode == LV_DESIGN_DRAW_MAIN) {
lv_res_t res;
}
/*Post draw when the children are drawn*/
else if(mode == LV_DESIGN_DRAW_POST) {
/* Include the ancient signal function */
res = ancestor_signal(kb, sign, param);
if(res != LV_RES_OK) return res;
if(sign == LV_SIGNAL_CLEANUP) {
/*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/
}
return true;
return res;
}
#endif
/**
* Called when a button of 'kb_btnm' is released
@ -319,24 +282,28 @@ static bool lv_kb_design(lv_obj_t * kb, const area_t * mask, lv_design_mode_t mo
static lv_res_t lv_app_kb_action(lv_obj_t * kb, const char * txt)
{
lv_kb_ext_t * ext = lv_obj_get_ext_attr(kb);
if(ext->ta == NULL) return LV_RES_OK;
/*Do the corresponding action according to the text of the button*/
if(strcmp(txt, "abc") == 0) {
lv_btnm_set_map(kb, kb_map_lc);
} else if(strcmp(txt, "ABC") == 0) {
lv_btnm_set_map(kb, kb_map_uc);
} else if(strcmp(txt, "1#") == 0) {
lv_btnm_set_map(kb, kb_map_spec);
} else if(strcmp(txt, "Enter") == 0) {
lv_ta_add_char(ext->ta, '\n');
} else if(strcmp(txt, "Left") == 0) {
lv_ta_cursor_left(ext->ta);
} else if(strcmp(txt, "Right") == 0) {
lv_ta_cursor_right(ext->ta);
} else if(strcmp(txt, "Del") == 0) {
lv_ta_del(ext->ta);
} else if(strcmp(txt, "+/-") == 0) {
if(strcmp(txt, "abc") == 0) lv_btnm_set_map(kb, kb_map_lc);
else if(strcmp(txt, "ABC") == 0) lv_btnm_set_map(kb, kb_map_uc);
else if(strcmp(txt, "1#") == 0) lv_btnm_set_map(kb, kb_map_spec);
else if(strcmp(txt, SYMBOL_CLOSE) == 0) {
if(ext->close_action) ext->close_action(kb);
else lv_obj_del(kb);
return LV_RES_INV;
} else if(strcmp(txt, SYMBOL_OK) == 0) {
if(ext->ok_action) ext->ok_action(kb);
else lv_obj_del(kb);
return LV_RES_INV;
}
if(ext->ta == NULL) return LV_RES_OK;
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, "+/-") == 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] == '-') {
@ -354,12 +321,6 @@ static lv_res_t lv_app_kb_action(lv_obj_t * kb, const char * txt)
lv_ta_add_char(ext->ta, '-');
lv_ta_set_cursor_pos(ext->ta, cur + 1);
}
} else if(strcmp(txt, "Hide") == 0) {
if(ext->close_action) ext->close_action(kb);
return LV_RES_INV;
} else if(strcmp(txt, "Ok") == 0) {
if(ext->ok_action) ext->ok_action(kb);
return LV_RES_INV;
} else {
lv_ta_add_text(ext->ta, txt);
}

View File

@ -48,6 +48,10 @@ typedef struct {
* GLOBAL PROTOTYPES
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a keyboard objects
* @param par pointer to an object, it will be the parent of the new keyboard
@ -56,14 +60,9 @@ typedef struct {
*/
lv_obj_t * lv_kb_create(lv_obj_t * par, lv_obj_t * copy);
/**
* Signal function of the keyboard
* @param kb pointer to a keyboard 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_kb_signal(lv_obj_t * kb, lv_signal_t sign, void * param);
/*=====================
* Setter functions
*====================*/
/**
* Assign a Text Area to the Keyboard. The pressed characters will be put there.
@ -80,7 +79,7 @@ void lv_kb_set_ta(lv_obj_t * kb, lv_obj_t * ta);
void lv_kb_set_mode(lv_obj_t * kb, lv_kb_mode_t mode);
/**
* Automatically hide or show the cursor of Text Area
* Automatically hide or show the cursor of the current Text Area
* @param kb pointer to a Keyboard object
* @param en true: show cursor on the current text area, false: hide cursor
*/
@ -100,12 +99,43 @@ 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
* @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
*/
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);
}
/*=====================
* Getter functions
*====================*/
/**
* Assign a Text Area to the Keyboard. The pressed characters will be put there.
* @param kb pointer to a Keyboard object
* @return pointer to the assigned Text Area object
*/
lv_obj_t * lv_kb_get_ta(lv_obj_t * kb);
/**
* Set a new a mode (text or number map)
* @param kb pointer to a Keyboard object
@ -134,34 +164,14 @@ 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);
/****************************
* TRANSPARENT API FUNCTIONS
***************************/
/**
* 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
*/
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);
}
/**
* Set the style of a keyboards's background
* Get the style of a keyboard
* @param kb pointer to a keyboard object
* @param bg pointer to the background style
* @return pointer to the background style
*/
static inline void lv_kb_set_style_bg(lv_obj_t *kb, lv_style_t * bg)
static inline lv_style_t * lv_kb_get_style_bg(lv_obj_t *kb)
{
lv_btnm_set_style_bg(kb, bg);
return lv_btnm_get_style_bg(kb);
}
/**
@ -175,15 +185,6 @@ 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);
}
/**
* 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);
}
/**********************
* MACROS
**********************/

View File

@ -49,10 +49,6 @@ static lv_signal_func_t ancestor_signal;
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a list objects
* @param par pointer to an object, it will be the parent of the new list
@ -111,6 +107,10 @@ lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy)
return new_list;
}
/*======================
* Add/remove functions
*=====================*/
/**
* Add a list element to the list
* @param list pointer to list object
@ -167,104 +167,21 @@ lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, l
return liste;
}
/**
* Move the list elements up by one
* @param list pointer a to list object
*/
void lv_list_up(lv_obj_t * list)
{
/*Search the first list element which 'y' coordinate is below the parent
* and position the list to show this element on the bottom*/
lv_obj_t * scrl = lv_page_get_scrl(list);
lv_obj_t * e;
lv_obj_t * e_prev = NULL;
e = get_next_btn(list, NULL);
while(e != NULL) {
if(e->coords.y2 <= list->coords.y2) {
if(e_prev != NULL) {
cord_t new_y = lv_obj_get_height(list) - (lv_obj_get_y(e_prev) + lv_obj_get_height(e_prev));
lv_list_ext_t *ext = lv_obj_get_ext_attr(list);
if(ext->anim_time == 0) {
lv_obj_set_y(scrl, new_y);
} else {
anim_t a;
a.var = scrl;
a.start = lv_obj_get_y(scrl);
a.end = new_y;
a.fp = (anim_fp_t)lv_obj_set_y;
a.path = anim_get_path(ANIM_PATH_LIN);
a.end_cb = NULL;
a.act_time = 0;
a.time = LV_LIST_FOCUS_TIME;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
anim_create(&a);
}
}
break;
}
e_prev = e;
e = get_next_btn(list, e);
}
}
/**
* Move the list elements down by one
* @param list pointer to a list object
*/
void lv_list_down(lv_obj_t * list)
{
/*Search the first list element which 'y' coordinate is above the parent
* and position the list to show this element on the top*/
lv_obj_t * scrl = lv_page_get_scrl(list);
lv_obj_t * e;
e = get_next_btn(list, NULL);
while(e != NULL) {
if(e->coords.y1 < list->coords.y1) {
cord_t new_y = -lv_obj_get_y(e);
lv_list_ext_t *ext = lv_obj_get_ext_attr(list);
if(ext->anim_time == 0) {
lv_obj_set_y(scrl, new_y);
} else {
anim_t a;
a.var = scrl;
a.start = lv_obj_get_y(scrl);
a.end = new_y;
a.fp = (anim_fp_t)lv_obj_set_y;
a.path = anim_get_path(ANIM_PATH_LIN);
a.end_cb = NULL;
a.act_time = 0;
a.time = LV_LIST_FOCUS_TIME;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
anim_create(&a);
}
break;
}
e = get_next_btn(list, e);
}
}
/**
* Focus on a list button. It ensures that the button will be visible on the list.
* @param btn pointer to a list button to focus
* @param anim_en true: scroll with animation, false: without animation
*/
void lv_list_focus(lv_obj_t *btn, bool anim_en)
{
lv_obj_t *list = lv_obj_get_parent(lv_obj_get_parent(btn));
lv_page_focus(list, btn, anim_en == false ? 0 :lv_list_get_anim_time(list));
}
/*=====================
* Setter functions
*====================*/
/**
* Set scroll animation duration on 'list_up()' 'list_down()' 'list_focus()'
* @param list pointer to a list object
* @param anim_time duration of animation [ms]
*/
void lv_list_set_anim_time(lv_obj_t *list, uint16_t anim_time)
{
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
ext->anim_time = anim_time;
}
/**
* Set styles of the list elements of a list in each state
* @param list pointer to list object
@ -295,45 +212,34 @@ void lv_list_set_style_btn(lv_obj_t * list, lv_style_t * rel, lv_style_t * pr,
}
}
/**
* Set scroll animation duration on 'list_up()' 'list_down()' 'list_focus()'
* @param list pointer to a list object
* @param anim_time duration of animation [ms]
*/
void lv_list_set_anim_time(lv_obj_t *list, uint16_t anim_time)
{
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
ext->anim_time = anim_time;
}
/*=====================
* Getter functions
*====================*/
/**
* Get the text of a list element
* @param liste pointer to list element
* @param btn pointer to list element
* @return pointer to the text
*/
const char * lv_list_get_btn_text(lv_obj_t * liste)
const char * lv_list_get_btn_text(lv_obj_t * btn)
{
lv_obj_t * label = lv_list_get_btn_label(liste);
lv_obj_t * label = lv_list_get_btn_label(btn);
if(label == NULL) return "";
return lv_label_get_text(label);
}
/**
* Get the label object from a list element
* @param liste pointer to a list element (button)
* @param btn pointer to a list element (button)
* @return pointer to the label from the list element or NULL if not found
*/
lv_obj_t * lv_list_get_btn_label(lv_obj_t * liste)
lv_obj_t * lv_list_get_btn_label(lv_obj_t * btn)
{
lv_obj_t * label = lv_obj_get_child(liste, NULL);
lv_obj_t * label = lv_obj_get_child(btn, NULL);
if(label == NULL) return NULL;
while(label->signal_func != label_signal) {
label = lv_obj_get_child(liste, label);
label = lv_obj_get_child(btn, label);
if(label == NULL) break;
}
@ -342,17 +248,17 @@ lv_obj_t * lv_list_get_btn_label(lv_obj_t * liste)
/**
* Get the image object from a list element
* @param liste pointer to a list element (button)
* @param btn pointer to a list element (button)
* @return pointer to the image from the list element or NULL if not found
*/
lv_obj_t * lv_list_get_btn_img(lv_obj_t * liste)
lv_obj_t * lv_list_get_btn_img(lv_obj_t * btn)
{
#if USE_LV_IMG != 0 && USE_FSINT != 0
lv_obj_t * img = lv_obj_get_child(liste, NULL);
lv_obj_t * img = lv_obj_get_child(btn, NULL);
if(img == NULL) return NULL;
while(img->signal_func != img_signal) {
img = lv_obj_get_child(liste, img);
img = lv_obj_get_child(btn, img);
if(img == NULL) break;
}
@ -362,6 +268,17 @@ lv_obj_t * lv_list_get_btn_img(lv_obj_t * liste)
#endif
}
/**
* Get scroll animation duration
* @param list pointer to a list object
* @return duration of animation [ms]
*/
uint16_t lv_list_get_anim_time(lv_obj_t *list)
{
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
return ext->anim_time;
}
/**
* Get the style of the list elements in a given state
* @param list pointer to a list object
@ -377,22 +294,108 @@ lv_style_t * lv_list_get_style_btn(lv_obj_t * list, lv_btn_state_t state)
return ext->styles_btn[state];
}
/*=====================
* Other functions
*====================*/
/**
* Get scroll animation duration
* @param list pointer to a list object
* @return duration of animation [ms]
* Move the list elements up by one
* @param list pointer a to list object
*/
uint16_t lv_list_get_anim_time(lv_obj_t *list)
void lv_list_up(lv_obj_t * list)
{
lv_list_ext_t * ext = lv_obj_get_ext_attr(list);
return ext->anim_time;
/*Search the first list element which 'y' coordinate is below the parent
* and position the list to show this element on the bottom*/
lv_obj_t * scrl = lv_page_get_scrl(list);
lv_obj_t * e;
lv_obj_t * e_prev = NULL;
e = get_next_btn(list, NULL);
while(e != NULL) {
if(e->coords.y2 <= list->coords.y2) {
if(e_prev != NULL) {
cord_t new_y = lv_obj_get_height(list) - (lv_obj_get_y(e_prev) + lv_obj_get_height(e_prev));
lv_list_ext_t *ext = lv_obj_get_ext_attr(list);
if(ext->anim_time == 0) {
lv_obj_set_y(scrl, new_y);
} else {
anim_t a;
a.var = scrl;
a.start = lv_obj_get_y(scrl);
a.end = new_y;
a.fp = (anim_fp_t)lv_obj_set_y;
a.path = anim_get_path(ANIM_PATH_LIN);
a.end_cb = NULL;
a.act_time = 0;
a.time = LV_LIST_FOCUS_TIME;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
anim_create(&a);
}
}
break;
}
e_prev = e;
e = get_next_btn(list, e);
}
}
/**
* Move the list elements down by one
* @param list pointer to a list object
*/
void lv_list_down(lv_obj_t * list)
{
/*Search the first list element which 'y' coordinate is above the parent
* and position the list to show this element on the top*/
lv_obj_t * scrl = lv_page_get_scrl(list);
lv_obj_t * e;
e = get_next_btn(list, NULL);
while(e != NULL) {
if(e->coords.y1 < list->coords.y1) {
cord_t new_y = -lv_obj_get_y(e);
lv_list_ext_t *ext = lv_obj_get_ext_attr(list);
if(ext->anim_time == 0) {
lv_obj_set_y(scrl, new_y);
} else {
anim_t a;
a.var = scrl;
a.start = lv_obj_get_y(scrl);
a.end = new_y;
a.fp = (anim_fp_t)lv_obj_set_y;
a.path = anim_get_path(ANIM_PATH_LIN);
a.end_cb = NULL;
a.act_time = 0;
a.time = LV_LIST_FOCUS_TIME;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
anim_create(&a);
}
break;
}
e = get_next_btn(list, e);
}
}
/**
* Focus on a list button. It ensures that the button will be visible on the list.
* @param btn pointer to a list button to focus
* @param anim_en true: scroll with animation, false: without animation
*/
void lv_list_focus(lv_obj_t *btn, bool anim_en)
{
lv_obj_t *list = lv_obj_get_parent(lv_obj_get_parent(btn));
lv_page_focus(list, btn, anim_en == false ? 0 :lv_list_get_anim_time(list));
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Signal function of the list
* @param list pointer to a list object

View File

@ -63,7 +63,11 @@ typedef struct
* @param copy pointer to a list object, if not NULL then the new object will be copied from it
* @return pointer to the created list
*/
lv_obj_t * lv_list_create(lv_obj_t *par, lv_obj_t * copy);
lv_obj_t * lv_list_create(lv_obj_t * par, lv_obj_t * copy);
/*======================
* Add/remove functions
*=====================*/
/**
* Add a list element to the list
@ -73,39 +77,11 @@ lv_obj_t * lv_list_create(lv_obj_t *par, lv_obj_t * copy);
* @param rel_action pointer to release action function (like with lv_btn)
* @return pointer to the new list element which can be customized (a button)
*/
lv_obj_t * lv_list_add(lv_obj_t *list, const char * img_fn, const char * txt, lv_action_t rel_action);
lv_obj_t * lv_list_add(lv_obj_t * list, const char * img_fn, const char * txt, lv_action_t rel_action);
/**
* Move the list elements up by one
* @param list pointer a to list object
*/
void lv_list_up(lv_obj_t *list);
/**
* Move the list elements down by one
* @param list pointer to a list object
*/
void lv_list_down(lv_obj_t *list);
/**
* Focus on a list button. It ensures that the button will be visible on the list.
* @param btn pointer to a list button to focus
* @param anim_en true: scroll with animation, false: without animation
*/
void lv_list_focus(lv_obj_t *btn, bool anim_en);
/**
* 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 trel pointer to a style for toggled releases state
* @param tpr pointer to a style for toggled pressed state
* @param ina pointer to a style for inactive state
*/
void lv_list_set_style_btn(lv_obj_t * list, lv_style_t * rel, lv_style_t * pr,
lv_style_t * trel, lv_style_t * tpr,
lv_style_t * ina);
/*=====================
* Setter functions
*====================*/
/**
* Set scroll animation duration on 'list_up()' 'list_down()' 'list_focus()'
@ -115,51 +91,14 @@ void lv_list_set_style_btn(lv_obj_t * list, lv_style_t * rel, lv_style_t * pr,
void lv_list_set_anim_time(lv_obj_t *list, uint16_t anim_time);
/**
* Get the text of a list element
* @param liste pointer to list element
* @return pointer to the text
*/
const char * lv_list_get_element_text(lv_obj_t * liste);
/**
* Get the label object from a list element
* @param liste pointer to a list element (button)
* @return pointer to the label from the list element or NULL if not found
*/
lv_obj_t * lv_list_get_btn_label(lv_obj_t * liste);
/**
* Get the image object from a list element
* @param liste pointer to a list element (button)
* @return pointer to the image from the list element or NULL if not found
*/
lv_obj_t * lv_list_get_btn_img(lv_obj_t * liste);
/**
* Get the scroll bar outside attribute
* @param list pointer to list object
* @param en true: scroll bar outside the buttons, false: scroll bar inside
*/
bool lv_list_get_sb_out(lv_obj_t * list, bool en);
/**
* Get the style of the list elements in a given state
* Set the scroll bar mode of a list
* @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
* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
*/
lv_style_t * lv_list_get_style_btn(lv_obj_t * list, lv_btn_state_t state);
/**
* Get scroll animation duration
* @param list pointer to a list object
* @return duration of animation [ms]
*/
uint16_t lv_list_get_anim_time(lv_obj_t *list);
/****************************
* TRANSPARENT API FUNCTIONS
***************************/
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
@ -174,14 +113,48 @@ static inline void lv_list_set_style(lv_obj_t *list, lv_style_t *bg, lv_style_t
}
/**
* Set the scroll bar mode of a list
* @param list pointer to a list object
* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
* 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
*/
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);
}
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);
/*=====================
* Getter functions
*====================*/
/**
* Get the text of a list element
* @param btn pointer to list element
* @return pointer to the text
*/
const char * lv_list_get_btn_text(lv_obj_t * btn);
/**
* Get the label object from a list element
* @param btn pointer to a list element (button)
* @return pointer to the label from the list element or NULL if not found
*/
lv_obj_t * lv_list_get_btn_label(lv_obj_t * btn);
/**
* Get the image object from a list element
* @param btn pointer to a list element (button)
* @return pointer to the image from the list element or NULL if not found
*/
lv_obj_t * lv_list_get_btn_img(lv_obj_t * btn);
/**
* Get scroll animation duration
* @param list pointer to a list object
* @return duration of animation [ms]
*/
uint16_t lv_list_get_anim_time(lv_obj_t *list);
/**
* Get the scroll bar mode of a list
@ -223,6 +196,36 @@ 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);
/*=====================
* Other functions
*====================*/
/**
* Move the list elements up by one
* @param list pointer a to list object
*/
void lv_list_up(lv_obj_t * list);
/**
* Move the list elements down by one
* @param list pointer to a list object
*/
void lv_list_down(lv_obj_t * list);
/**
* Focus on a list button. It ensures that the button will be visible on the list.
* @param btn pointer to a list button to focus
* @param anim_en true: scroll with animation, false: without animation
*/
void lv_list_focus(lv_obj_t *btn, bool anim_en);
/**********************
* MACROS
**********************/

View File

@ -43,10 +43,6 @@ static lv_signal_func_t ancestor_signal;
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a message box objects
* @param par pointer to an object, it will be the parent of the new message box
@ -207,44 +203,6 @@ void lv_mbox_set_btn_width(lv_obj_t *mbox, cord_t w)
btnh_resize(mbox);
}
/**
* Set the styles 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
*/
void lv_mbox_set_style(lv_obj_t *mbox, lv_style_t *bg, lv_style_t *btnh)
{
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
lv_obj_set_style(ext->btnh, btnh);
lv_obj_set_style(mbox, bg);
}
/**
* 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)
{
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
ext->style_btn_rel = rel;
ext->style_btn_pr = pr;
if(ext->btnh != NULL) {
lv_obj_t * btn = lv_obj_get_child(ext->btnh, NULL);
while(btn != NULL) {
lv_btn_set_style(btn, rel, pr, NULL, NULL, NULL);
btn = lv_obj_get_child(mbox, btn);
}
}
btnh_resize(mbox);
}
/**
* Set animation duration
* @param mbox pointer to a message box object
@ -286,6 +244,44 @@ void lv_mbox_stop_auto_close(lv_obj_t * mbox)
anim_del(mbox, NULL);
}
/**
* Set the styles 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
*/
void lv_mbox_set_style(lv_obj_t *mbox, lv_style_t *bg, lv_style_t *btnh)
{
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
lv_obj_set_style(ext->btnh, btnh);
lv_obj_set_style(mbox, bg);
}
/**
* 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)
{
lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox);
ext->style_btn_rel = rel;
ext->style_btn_pr = pr;
if(ext->btnh != NULL) {
lv_obj_t * btn = lv_obj_get_child(ext->btnh, NULL);
while(btn != NULL) {
lv_btn_set_style(btn, rel, pr, NULL, NULL, NULL);
btn = lv_obj_get_child(mbox, btn);
}
}
btnh_resize(mbox);
}
/*=====================
* Getter functions
*====================*/
@ -349,7 +345,6 @@ lv_style_t * lv_mbox_get_style_btnh(lv_obj_t *mbox)
return lv_obj_get_style(ext->btnh);
}
/**
* Get the style of the buttons on a message box
* @param mbox pointer to a message box object

View File

@ -84,6 +84,10 @@ lv_res_t lv_mbox_close_action(lv_obj_t * btn);
*/
lv_obj_t * lv_mbox_add_btn(lv_obj_t * mbox, const char * btn_txt, lv_action_t rel_action);
/*=====================
* Setter functions
*====================*/
/**
* Set the text of the message box
* @param mbox pointer to a message box
@ -98,6 +102,26 @@ void lv_mbox_set_text(lv_obj_t * mbox, const char * txt);
*/
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)
*/
void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t time);
/**
* Automatically delete the message box after a given time
* @param mbox pointer to a message box object
* @param delay a time (in milliseconds) to wait before delete the message box
*/
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay);
/**
* Stop the auto. closing of message box
* @param mbox pointer to a message box object
*/
void lv_mbox_stop_auto_close(lv_obj_t * mbox);
/**
* Set the styles of a message box
* @param mbox pointer to a message box object
@ -114,25 +138,9 @@ void lv_mbox_set_style(lv_obj_t *mbox, lv_style_t *bg, lv_style_t *btnh);
*/
void lv_mbox_set_style_btn(lv_obj_t * mbox, lv_style_t * rel, lv_style_t * pr);
/**
* Set close animation duration
* @param mbox pointer to a message box object
* @param time animation length in milliseconds (0: no animation)
*/
void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t time);
/**
* Automatically delete the message box after a given time
* @param mbox pointer to a message box object
* @param tout a time (in milliseconds) to wait before delete the message box
*/
void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t tout);
/**
* Stop the auto. closing of message box
* @param mbox pointer to a message box object
*/
void lv_mbox_stop_auto_close(lv_obj_t * mbox);
/*=====================
* Getter functions
*====================*/
/**
* Get the text of the message box
@ -157,30 +165,11 @@ cord_t lv_mbox_get_btn_width(lv_obj_t * mbox);
lv_obj_t * lv_mbox_get_from_btn(lv_obj_t * btn);
/**
* Get the close animation duration
* Get the animation duration (close animation time)
* @param mbox pointer to a message box object
* @return animation length in milliseconds (0: no animation)
*/
uint16_t lv_mbox_get_anim_time(lv_obj_t * mbox );
/**
* Get the style of the buttons on 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
*/
lv_style_t * lv_mbox_get_style_btn(lv_obj_t * mbox, lv_btn_state_t state);
/**
* 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);
/******************************
* TRANSPARENT API FUNCTIONS
******************************/
uint16_t lv_mbox_get_anim_time(lv_obj_t * mbox);
/**
* Get the style of a message box's background
@ -192,6 +181,20 @@ 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
* @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
*/
lv_style_t * lv_mbox_get_style_btn(lv_obj_t * mbox, lv_btn_state_t state);
/**********************
* MACROS

View File

@ -48,10 +48,6 @@ static lv_design_func_t ancestor_design;
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a page objects
* @param par pointer to an object, it will be the parent of the new page

View File

@ -72,6 +72,17 @@ 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
* @return pointer to a container which is the scrollable part of the page
*/
lv_obj_t * lv_page_get_scrl(lv_obj_t * page);
/**
* Set a release action for the page
* @param page pointer to a page object
@ -89,7 +100,7 @@ void lv_page_set_press_action(lv_obj_t * page, lv_action_t pr_action);
/**
* Set the scroll bar mode on a page
* @param page pointer to a page object
* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
* @param sb.mode the new mode from 'lv_page_sb.mode_t' enum
*/
void lv_page_set_sb_mode(lv_obj_t * page, lv_page_sb_mode_t sb_mode);
@ -101,6 +112,7 @@ void lv_page_set_sb_mode(lv_obj_t * page, lv_page_sb_mode_t sb_mode);
* @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
@ -116,38 +128,6 @@ 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);
/**
* Get the scrollable object of a page-
* @param page pointer to 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);
/**
* 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);
/**
* 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);
/**
* 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);
/******************************
* TRANSPARENT API FUNCTIONS
******************************/
/**
* Set the fit attribute of the scrollable part of a page.
* It means it can set its size automatically to involve all children.
@ -192,6 +172,17 @@ 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);
}
/*=====================
* Getter functions
*====================*/
/**
* 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);
/**
* Get width of the scrollable part of a page
* @param page pointer to a page object
@ -202,17 +193,6 @@ static inline cord_t lv_page_get_scrl_width(lv_obj_t *page)
return lv_obj_get_width(lv_page_get_scrl(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 height of the scrollable part of a page
* @param page pointer to a page object
@ -253,6 +233,30 @@ static inline bool lv_page_get_scrl_fit_ver(lv_obj_t * page)
return lv_cont_get_ver_fit(lv_page_get_scrl(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 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);
/**
* 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);
/**********************
* MACROS
**********************/

View File

@ -43,10 +43,6 @@ static lv_signal_func_t ancestor_scrl_signal;
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a roller object
* @param par pointer to an object, it will be the parent of the new roller
@ -97,15 +93,6 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy)
return new_roller;
}
/*======================
* Add/remove functions
*=====================*/
/*
* New object specific "add" or "remove" functions come here
*/
/*=====================
* Setter functions
*====================*/
@ -133,7 +120,6 @@ void lv_roller_set_hor_fit(lv_obj_t *roller, bool fit_en)
lv_cont_set_fit(roller, fit_en ,false);
}
/*=====================
* Getter functions
*====================*/
@ -148,14 +134,6 @@ bool lv_roller_get_hor_fit(lv_obj_t *roller)
return lv_page_get_scrl_hor_fit(roller);
}
/*=====================
* Other functions
*====================*/
/*
* New object specific "other" functions come here
*/
/**********************
* STATIC FUNCTIONS
**********************/

View File

@ -37,38 +37,16 @@ typedef struct {
**********************/
/**
* Create a roller objects
* Create a roller object
* @param par pointer to an object, it will be the parent of the new roller
* @param copy pointer to a roller object, if not NULL then the new object will be copied from it
* @return pointer to the created roller
*/
lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy);
/**
* Set the selected option
* @param roller pointer to a roller object
* @param sel_opt id of the selected option (0 ... number of option - 1);
* @param anim_en true: set with animation; false set immediately
*/
void lv_roller_set_selected(lv_obj_t *roller, uint16_t sel_opt, bool anim_en);
/**
* 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);
/**
* Get the auto width set attribute
* @param roller pointer to a roller object
* @return true: auto size enabled; false: manual width settings enabled
*/
bool lv_roller_get_hor_fit(lv_obj_t *roller);
/****************************
* TRANSPARENT API FUNCTIONS
***************************/
/*=====================
* Setter functions
*====================*/
/**
* Set the options on a roller
@ -80,6 +58,14 @@ static inline void lv_roller_set_options(lv_obj_t * roller, const char * options
lv_ddlist_set_options(roller, options);
}
/**
* Set the selected option
* @param roller pointer to a roller object
* @param sel_opt id of the selected option (0 ... number of option - 1);
* @param anim_en true: set with animation; false set immediately
*/
void lv_roller_set_selected(lv_obj_t *roller, uint16_t sel_opt, bool anim_en);
/**
* Set the open/close animation time.
* @param roller pointer to a roller object
@ -100,6 +86,16 @@ static inline void lv_roller_set_style(lv_obj_t *roller, lv_style_t *bg, lv_styl
{
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);
/*=====================
* Getter functions
*====================*/
/**
* Get the options of a roller
@ -111,7 +107,6 @@ static inline const char * lv_roller_get_options(lv_obj_t *roller)
return lv_ddlist_get_options(roller);
}
/**
* Get the id of the selected option
* @param roller pointer to a roller object
@ -152,6 +147,13 @@ static inline uint16_t lv_roller_get_anim_time(lv_obj_t * roller)
return lv_ddlist_get_anim_time(roller);
}
/**
* Get the auto width set attribute
* @param roller pointer to a roller object
* @return true: auto size enabled; false: manual width settings enabled
*/
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

View File

@ -43,10 +43,6 @@ static lv_signal_func_t ancestor_signal;
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a slider objects
* @param par pointer to an object, it will be the parent of the new slider
@ -109,6 +105,17 @@ void lv_slider_set_action(lv_obj_t * slider, lv_action_t action)
ext->action = action;
}
/**
* Set the 'knob in' attribute of a slider
* @param slider pointer to slider object
* @param in true: the knob is drawn always in the slider;
* false: the knob can be out on the edges
*/
void lv_slider_set_knob_in(lv_obj_t * slider, bool in)
{
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
ext->knob_in = in == false ? 0 : 1;
}
/**
* Set the styles of a slider
@ -129,18 +136,6 @@ void lv_slider_set_style(lv_obj_t * slider, lv_style_t *bg, lv_style_t *indic, l
lv_bar_set_style(slider, bg, indic);
}
/**
* Set the 'knob in' attribute of a slider
* @param slider pointer to slider object
* @param in true: the knob is drawn always in the slider;
* false: the knob can be out on the edges
*/
void lv_slider_set_knob_in(lv_obj_t * slider, bool in)
{
lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider);
ext->knob_in = in == false ? 0 : 1;
}
/*=====================
* Getter functions
*====================*/

View File

@ -55,56 +55,9 @@ typedef enum
*/
lv_obj_t * lv_slider_create(lv_obj_t * par, lv_obj_t * copy);
/**
* Set a function which will be called when a new value is set on the slider
* @param slider pointer to slider object
* @param cb a callback function
*/
void lv_slider_set_action(lv_obj_t * slider, lv_action_t cb);
/**
* Set the styles of a slider
* @param bar pointer to a bar object
* @param bg pointer to the background's style
* @param indic pointer to the indicator's style
* @param knob pointer to the knob's style
*/
void lv_slider_set_style(lv_obj_t * slider, lv_style_t *bg, lv_style_t *indic, lv_style_t *knob);
/**
* Set the 'knob in' attribute of a slider
* @param slider pointer to slider object
* @param in true: the knob is drawn always in the slider;
* false: the knob can be out on the edges
*/
void lv_slider_set_knob_in(lv_obj_t * slider, bool in);
/**
* Get the slider callback function
* @param slider pointer to slider object
* @return the callback function
*/
lv_action_t lv_slider_get_action(lv_obj_t * slider);
/**
* Set the styles of a slider
* @param slider pointer to a bar object
* @return pointer to the knob's style
*/
lv_style_t * lv_slider_get_style_knob(lv_obj_t * slider);
/**
* Get the 'knob in' attribute of a slider
* @param slider pointer to slider object
* @return true: the knob is drawn always in the slider;
* false: the knob can be out on the edges
*/
bool lv_slider_get_knob_in(lv_obj_t * slider);
/******************************
* TRANSPARENT API FUNCTIONS
******************************/
/*=====================
* Setter functions
*====================*/
/**
* Set a new value on the slider
@ -138,6 +91,34 @@ static inline void lv_slider_set_range(lv_obj_t *slider, int16_t min, int16_t ma
lv_bar_set_range(slider, min, max);
}
/**
* Set a function which will be called when a new value is set on the slider
* @param slider pointer to slider object
* @param action a callback function
*/
void lv_slider_set_action(lv_obj_t * slider, lv_action_t action);
/**
* Set the 'knob in' attribute of a slider
* @param slider pointer to slider object
* @param in true: the knob is drawn always in the slider;
* false: the knob can be out on the edges
*/
void lv_slider_set_knob_in(lv_obj_t * slider, bool in);
/**
* Set the styles 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)
*/
void lv_slider_set_style(lv_obj_t * slider, lv_style_t *bg, lv_style_t *indic, lv_style_t *knob);
/*=====================
* Getter functions
*====================*/
/**
* Get the value of a slider
* @param slider pointer to a slider object
@ -168,6 +149,27 @@ static inline int16_t lv_slider_get_max_value(lv_obj_t * slider)
return lv_bar_get_max_value(slider);
}
/**
* Get the slider action function
* @param slider pointer to slider object
* @return the callback function
*/
lv_action_t lv_slider_get_action(lv_obj_t * slider);
/**
* Set the styles of a slider
* @param slider pointer to a slider object
* @return pointer to the knob's style
*/
lv_style_t * lv_slider_get_style_knob(lv_obj_t * slider);
/**
* Get the 'knob in' attribute of a slider
* @param slider pointer to slider object
* @return true: the knob is drawn always in the slider;
* false: the knob can be out on the edges
*/
bool lv_slider_get_knob_in(lv_obj_t * slider);
/**
* Get the style of the slider's background

View File

@ -37,10 +37,6 @@ static lv_signal_func_t ancestor_signal;
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a switch objects
* @param par pointer to an object, it will be the parent of the new switch

View File

@ -53,6 +53,10 @@ typedef struct
*/
lv_obj_t * lv_sw_create(lv_obj_t * par, lv_obj_t * copy);
/*=====================
* Setter functions
*====================*/
/**
* Turn ON the switch
* @param sw pointer to a switch object
@ -64,33 +68,6 @@ void lv_sw_set_on(lv_obj_t *sw);
* @param sw pointer to a switch object
*/
void lv_sw_set_off(lv_obj_t *sw);
/**
* Set the styles 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
*/
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);
/**
* Get the style of the switch's knob when the switch is OFF
* @param sw pointer to a switch object
* @return pointer to the switch's knob OFF 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);
/******************************
* TRANSPARENT API FUNCTIONS
******************************/
/**
* Set a function which will be called when the switch is toggled by the user
@ -102,6 +79,20 @@ static inline void lv_sw_set_action(lv_obj_t * sw, lv_action_t action)
lv_slider_set_action(sw, action);
}
/**
* Set the styles 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
*/
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);
/*=====================
* Getter functions
*====================*/
/**
* Get the state of a switch
* @param sw pointer to a switch object
@ -142,6 +133,21 @@ 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
* @param sw pointer to a switch object
* @return pointer to the switch's knob OFF 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);
/**********************
* MACROS
**********************/

View File

@ -64,10 +64,6 @@ static lv_signal_func_t scrl_signal;
* GLOBAL FUNCTIONS
**********************/
/*-----------------
* Create function
*-----------------*/
/**
* Create a text area objects
* @param par pointer to an object, it will be the parent of the new text area
@ -492,22 +488,6 @@ void lv_ta_set_cursor_type(lv_obj_t * ta, lv_ta_cursor_type_t cur_type)
lv_obj_invalidate(ta);
}
/**
* Set the style of the 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)
*/
void lv_ta_set_style(lv_obj_t * ta, lv_style_t *bg, lv_style_t *sb, lv_style_t *cur)
{
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
ext->cursor_style = cur;
lv_page_set_style(ta, bg, &lv_style_transp_tight, sb);
}
/**
* Enable/Disable password mode
* @param ta pointer to a text area object
@ -575,6 +555,21 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en)
}
}
/**
* Set the style of the 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)
*/
void lv_ta_set_style(lv_obj_t * ta, lv_style_t *bg, lv_style_t *sb, lv_style_t *cur)
{
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
ext->cursor_style = cur;
lv_page_set_style(ta, bg, &lv_style_transp_tight, sb);
}
/*=====================
* Getter functions
*====================*/

View File

@ -74,6 +74,10 @@ typedef struct
*/
lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy);
/*=====================
* Setter functions
*====================*/
/**
* Insert a character to the current cursor position
* @param ta pointer to a text area object
@ -121,7 +125,6 @@ void lv_ta_cursor_right(lv_obj_t * ta);
* @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
@ -135,7 +138,7 @@ void lv_ta_cursor_down(lv_obj_t * ta);
void lv_ta_cursor_up(lv_obj_t * ta);
/**
* Get the current cursor visibility.
* Set the cursor visibility.
* @param ta pointer to a text area object
* @return show true: show the cursor and blink it, false: hide cursor
*/
@ -144,10 +147,34 @@ void lv_ta_set_cursor_show(lv_obj_t * ta, bool show);
/**
* Set the cursor type.
* @param ta pointer to a text area object
* @return cur_type: element of 'lv_ta_cursor_type_t'
* @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
* @param pwd_en true: enable, false: disable
*/
void lv_ta_set_pwd_mode(lv_obj_t * ta, bool pwd_en);
/**
* Configure the text area to one line or back to normal
* @param ta pointer to a Text area object
* @param en true: one line, false: normal
*/
void lv_ta_set_one_line(lv_obj_t * ta, bool en);
/**
* Set the scroll bar mode of a text area
* @param ta pointer to a text area object
* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
*/
static inline void lv_ta_set_sb_mode(lv_obj_t * ta, lv_page_sb_mode_t mode)
{
lv_page_set_sb_mode(ta, mode);
}
/**
* Set the style of the text area
* @param ta pointer to a text area object
@ -157,23 +184,13 @@ void lv_ta_set_cursor_type(lv_obj_t * ta, lv_ta_cursor_type_t cur_type);
*/
void lv_ta_set_style(lv_obj_t * ta, lv_style_t *bg, lv_style_t *sb, lv_style_t *cur);
/**
* Enable/Disable password mode
* @param ta ointer to a text area object
* @param en true: enable, false: disable
*/
void lv_ta_set_pwd_mode(lv_obj_t * ta, bool en);
/*=====================
* Getter functions
*====================*/
/**
* Configure the Text area to one line or back to normal
* Get the text of a text area
* @param ta pointer to a text area object
* @param en true: one line, false: normal
*/
void lv_ta_set_one_line(lv_obj_t * ta, bool en);
/**
* Get the text of the i the text area
* @param ta obj pointer to a text area object
* @return pointer to the text
*/
const char * lv_ta_get_text(lv_obj_t * ta);
@ -185,6 +202,7 @@ 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
@ -207,14 +225,7 @@ bool lv_ta_get_cursor_show(lv_obj_t * ta);
lv_ta_cursor_type_t lv_ta_get_cursor_type(lv_obj_t * ta);
/**
* Get the style of the cursor
* @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);
/**
* Get the password mode
* Get the password mode attribute
* @param ta pointer to a text area object
* @return true: password mode is enabled, false: disabled
*/
@ -227,20 +238,6 @@ bool lv_ta_get_pwd_mode(lv_obj_t * ta);
*/
bool lv_ta_get_one_line(lv_obj_t * ta);
/****************************
* TRANSPARENT API FUNCTIONS
***************************/
/**
* Set the scroll bar mode of a text area
* @param ta pointer to a text area object
* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum
*/
static inline void lv_ta_set_sb_mode(lv_obj_t * ta, lv_page_sb_mode_t mode)
{
lv_page_set_sb_mode(ta, mode);
}
/**
* Get the scroll bar mode of a text area
* @param ta pointer to a text area object
@ -271,6 +268,12 @@ static inline lv_style_t * lv_ta_get_style_sb(lv_obj_t * ta)
return lv_page_get_style_sb(ta);
}
/**
* Get the style of the cursor
* @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);
/**********************
* MACROS