From 79885c70fc9b7658a324e5d4596d28e67937a726 Mon Sep 17 00:00:00 2001 From: Kiss-Vamosi Gabor Date: Sat, 14 Jan 2017 23:54:16 +0100 Subject: [PATCH] lv_objx: header file documentation updates --- lv_objx/lv_btn.h | 60 ++++++++++++------------ lv_objx/lv_btnm.h | 33 ++++++------- lv_objx/lv_cb.h | 18 +++---- lv_objx/lv_chart.h | 30 ++++++------ lv_objx/lv_gauge.c | 53 ++++++++++++--------- lv_objx/lv_gauge.h | 27 +++++------ lv_objx/lv_img.c | 4 +- lv_objx/lv_img.h | 101 +++++++++++++++++++++++++++++++--------- lv_objx/lv_label.h | 46 +++++++++--------- lv_objx/lv_led.h | 16 +++---- lv_objx/lv_line.h | 23 ++++----- lv_objx/lv_list.h | 25 +++++----- lv_objx/lv_mbox.c | 1 - lv_objx/lv_mbox.h | 32 ++++++------- lv_objx/lv_objx_templ.h | 13 +++--- lv_objx/lv_page.h | 50 ++++++++++---------- lv_objx/lv_pb.h | 30 ++++++------ lv_objx/lv_rect.h | 29 ++++++------ lv_objx/lv_ta.h | 22 ++++----- lv_objx/lv_win.c | 5 +- lv_objx/lv_win.h | 43 ++++++++--------- 21 files changed, 362 insertions(+), 299 deletions(-) diff --git a/lv_objx/lv_btn.h b/lv_objx/lv_btn.h index 2dae06e79..5d5b99060 100644 --- a/lv_objx/lv_btn.h +++ b/lv_objx/lv_btn.h @@ -38,48 +38,50 @@ typedef enum LV_BTN_STATE_NUM, }lv_btn_state_t; -typedef struct -{ - uint8_t light_en :1; - uint8_t transp :1; - uint8_t empty :1; -}lv_btns_bits_t; - -/*Style of button*/ -typedef struct -{ - lv_rects_t rects; /*Style of ancestor*/ - /*New style element for this type */ - color_t mcolor[LV_BTN_STATE_NUM]; - color_t gcolor[LV_BTN_STATE_NUM]; - color_t bcolor[LV_BTN_STATE_NUM]; - color_t lcolor[LV_BTN_STATE_NUM]; - lv_btns_bits_t flags[LV_BTN_STATE_NUM]; -}lv_btns_t; - -/*Built-in styles of button*/ -typedef enum -{ - LV_BTNS_DEF, - LV_BTNS_TRANSP, - LV_BTNS_BORDER, -}lv_btns_builtin_t; - /*Data of button*/ typedef struct -{ +{ lv_rect_ext_t rect_ext; /*Ext. of ancestor*/ /*New data for this type */ lv_action_t pr_action; lv_action_t rel_action; lv_action_t lpr_action; lv_action_t lpr_rep_action; - + lv_btn_state_t state; uint8_t tgl :1; /*1: Toggle enabled*/ uint8_t lpr_exec :1; /*1: long press action executed (Not for user)*/ }lv_btn_ext_t; +/*Bits of 'flag' in 'lv_btns_t'*/ +typedef struct +{ + uint8_t light_en :1; + uint8_t transp :1; + uint8_t empty :1; +}lv_btns_bits_t; + +/*Style of button*/ +typedef struct +{ + lv_rects_t rects; /*Style of ancestor*/ + /*New style element for this type */ + color_t mcolor[LV_BTN_STATE_NUM]; + color_t gcolor[LV_BTN_STATE_NUM]; + color_t bcolor[LV_BTN_STATE_NUM]; + color_t lcolor[LV_BTN_STATE_NUM]; + lv_btns_bits_t flags[LV_BTN_STATE_NUM]; +}lv_btns_t; + +/*Built-in styles of button*/ +typedef enum +{ + LV_BTNS_DEF, + LV_BTNS_TRANSP, + LV_BTNS_BORDER, +}lv_btns_builtin_t; + + /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/lv_objx/lv_btnm.h b/lv_objx/lv_btnm.h index 6d00bf918..b07e74d9c 100644 --- a/lv_objx/lv_btnm.h +++ b/lv_objx/lv_btnm.h @@ -35,6 +35,23 @@ * TYPEDEFS **********************/ +/* Type of callback function which is called when a button is released + * Parameters: button matrix, released button index in the map string + * return LV_ACTION_RES_INV: the button matrix is deleted else LV_ACTION_RES_OK*/ +typedef lv_action_res_t (*lv_btnm_callback_t) (lv_obj_t *, uint16_t); + +/*Data of button matrix*/ +typedef struct +{ + lv_rect_ext_t rect; /*Ext. of ancestor*/ + /*New data for this type */ + const char ** map_p; /*Pointer to the current map*/ + area_t * btn_areas; + uint16_t btn_cnt; + uint16_t btn_pr; + lv_btnm_callback_t cb; +}lv_btnm_ext_t; + /*Style of button matrix*/ typedef struct { @@ -50,22 +67,6 @@ typedef enum LV_BTNMS_DEF, }lv_btnms_builtin_t; -/* Type of callback function which is called when a button is released - * Parameters: button matrix, released button index in the map string - * return LV_ACTION_RES_INV: the button matrix is deleted else LV_ACTION_RES_OK*/ -typedef lv_action_res_t (*lv_btnm_callback_t) (lv_obj_t *, uint16_t); - -/*Data of button matrix*/ -typedef struct -{ - lv_rect_ext_t rect; /*Ext. of ancestor*/ - /*New data for this type */ - const char ** map_p; /*Pointer to the current map*/ - area_t * btn_areas; - uint16_t btn_cnt; - uint16_t btn_pr; - lv_btnm_callback_t cb; -}lv_btnm_ext_t; /********************** * GLOBAL PROTOTYPES diff --git a/lv_objx/lv_cb.h b/lv_objx/lv_cb.h index 3928abd46..524a9216b 100644 --- a/lv_objx/lv_cb.h +++ b/lv_objx/lv_cb.h @@ -32,6 +32,15 @@ * TYPEDEFS **********************/ +/*Data of check box*/ +typedef struct +{ + lv_btn_ext_t bg_btn; /*Ext. of ancestor*/ + /*New data for this type */ + lv_obj_t * bullet; + lv_obj_t * label; +}lv_cb_ext_t; + /*Style of check box*/ typedef struct { @@ -48,15 +57,6 @@ typedef enum LV_CBS_DEF, }lv_cbs_builtin_t; -/*Data of check box*/ -typedef struct -{ - lv_btn_ext_t bg_btn; /*Ext. of ancestor*/ - /*New data for this type */ - lv_obj_t * bullet; - lv_obj_t * label; -}lv_cb_ext_t; - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/lv_objx/lv_chart.h b/lv_objx/lv_chart.h index b45f74ce0..d782dc81a 100644 --- a/lv_objx/lv_chart.h +++ b/lv_objx/lv_chart.h @@ -33,7 +33,22 @@ /********************** * TYPEDEFS **********************/ +/*Data of chart background*/ +typedef struct +{ + lv_rect_ext_t bg_rects; /*Ext. of ancestor*/ + /*New data for this type */ + cord_t ymin; + cord_t ymax; + uint8_t hdiv_num; /*Number of horizontal division lines*/ + uint8_t vdiv_num; /*Number of vertical division lines*/ + ll_dsc_t dl_ll; /*Linked list for the data line pointers (stores cord_t * )*/ + uint16_t pnum; /*Point number in a data line*/ + uint8_t type :2; /*Line, column or point chart (from 'lv_chart_type_t')*/ + uint8_t dl_num; /*Data line number in dl_ll*/ +}lv_chart_ext_t; +/*Chart types*/ typedef enum { LV_CHART_LINE, @@ -61,21 +76,6 @@ typedef enum LV_CHARTS_TRANSP, }lv_charts_builtin_t; -/*Data of chart background*/ -typedef struct -{ - lv_rect_ext_t bg_rects; /*Ext. of ancestor*/ - /*New data for this type */ - cord_t ymin; - cord_t ymax; - uint8_t hdiv_num; - uint8_t vdiv_num; - ll_dsc_t dl_ll; /*Linked list for the data line pointers (stores cord_t * )*/ - uint16_t pnum; /*Point number in a data line*/ - uint8_t type :2; /*Line, column or point chart*/ - uint8_t dl_num; /*Data line number in dl_ll*/ -}lv_chart_ext_t; - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/lv_objx/lv_gauge.c b/lv_objx/lv_gauge.c index 77bd1ab45..6adfbd6e2 100644 --- a/lv_objx/lv_gauge.c +++ b/lv_objx/lv_gauge.c @@ -346,7 +346,7 @@ static bool lv_gauge_design(lv_obj_t * gauge, const area_t * mask, lv_design_mod lv_gauge_ext_t * ext = lv_obj_get_ext(gauge); /* Draw the background - * Re-color the gauge according to the greatest value*/ + * Re-color the gauge according to the critical value*/ color_t mcolor_min = style->rects.objs.color; color_t gcolor_min = style->rects.gcolor; @@ -425,6 +425,33 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const area_t * mask) lv_draw_label(&label_cord, mask, &style->scale_labels, OPA_COVER, scale_txt); } + /*Calculate the critical value*/ + int16_t critical_value = ext->low_critical == 0 ? ext->min : ext->max;; + for(i = 0; i < ext->needle_num; i++) { + critical_value = ext->low_critical == 0 ? + MATH_MAX(critical_value, ext->values[i]) : MATH_MIN(critical_value, ext->values[i]); + } + + /*Write the critical value if enabled*/ + if(ext->txt[0] != '\0') { + char value_txt[16]; + sprintf(value_txt, ext->txt, critical_value); + + area_t label_cord; + point_t label_size; + txt_get_size(&label_size, value_txt, font_get(style->value_labels.font), + style->value_labels.letter_space, style->value_labels.line_space, LV_CORD_MAX); + + /*Draw the label*/ + label_cord.x1 = gauge->cords.x1 + lv_obj_get_width(gauge) / 2 - label_size.x / 2; + label_cord.y1 = gauge->cords.y1 + + (cord_t)style->value_pos * lv_obj_get_height(gauge) / 100 - label_size.y / 2; + + label_cord.x2 = label_cord.x1 + label_size.x; + label_cord.y2 = label_cord.y1 + label_size.y; + + lv_draw_label(&label_cord, mask, &style->value_labels, OPA_COVER, value_txt); + } } /** @@ -441,7 +468,6 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask) cord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->cords.x1; cord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->cords.y1; int16_t angle_ofs = 90 + (360 - style->scale_angle) / 2; - int16_t critical_value = ext->low_critical == 0 ? ext->min : ext->max; point_t p_mid; point_t p_end; uint8_t i; @@ -460,9 +486,6 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask) lv_draw_line(&p_mid, &p_end, mask, &style->needle_lines, style->needle_opa); - /*Calculate the critical value*/ - critical_value = ext->low_critical == 0 ? - MATH_MAX(critical_value, ext->values[i]) : MATH_MIN(critical_value, ext->values[i]); } /*Draw the needle middle area*/ @@ -481,24 +504,6 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const area_t * mask) lv_draw_rect(&nm_cord, mask, &nm, OPA_100); - /*Write the critical value if enabled*/ - if(ext->txt[0] != '\0') { - char value_txt[16]; - sprintf(value_txt, ext->txt, critical_value); - - area_t label_cord; - point_t label_size; - txt_get_size(&label_size, value_txt, font_get(style->value_labels.font), - style->value_labels.letter_space, style->value_labels.line_space, LV_CORD_MAX); - - /*Draw the label*/ - label_cord.x1 = gauge->cords.x1 + lv_obj_get_width(gauge) / 2 - label_size.x / 2; - label_cord.y1 = gauge->cords.y1 + 3 * lv_obj_get_height(gauge) / 4 - label_size.y / 2; - label_cord.x2 = label_cord.x1 + label_size.x; - label_cord.y2 = label_cord.y1 + label_size.y; - - lv_draw_label(&label_cord, mask, &style->value_labels, OPA_COVER, value_txt); - } } /** @@ -525,6 +530,8 @@ static void lv_gauges_init(void) lv_gauges_def.value_labels.letter_space = 3 * LV_DOWNSCALE; lv_gauges_def.value_labels.mid = 1; + lv_gauges_def.value_pos = 75; + lv_lines_get(LV_LINES_DEF, &lv_gauges_def.needle_lines); lv_gauges_def.needle_lines.objs.color = COLOR_WHITE; lv_gauges_def.needle_lines.width = 3 * LV_DOWNSCALE; diff --git a/lv_objx/lv_gauge.h b/lv_objx/lv_gauge.h index 9d4136c44..3fce08ac3 100644 --- a/lv_objx/lv_gauge.h +++ b/lv_objx/lv_gauge.h @@ -26,6 +26,19 @@ * TYPEDEFS **********************/ +/*Data of gauge*/ +typedef struct +{ + lv_rect_ext_t rect; /*Ext. of ancestor*/ + /*New data for this type */ + int16_t min; /*Minimum value of the scale*/ + int16_t max; /*Maximum value of the scale*/ + int16_t * values; /*Array of the set values (for needles) */ + char * txt; /*Printf-like text to display with the most critical value (e.g. "Value: %d")*/ + uint8_t needle_num; /*Number of needles*/ + uint8_t low_critical :1; /*0: the higher value is more critical, 1: the lower value is more critical*/ +}lv_gauge_ext_t; + /*Style of gauge*/ typedef struct { @@ -46,6 +59,7 @@ typedef struct opa_t needle_opa; /*Opacity of the needles*/ /*Value text settings*/ lv_labels_t value_labels; /*Style of the value label*/ + uint8_t value_pos; /*Vertical position of the value label in percentage of object height (0..100 %)*/ }lv_gauges_t; /*Built-in styles of gauge*/ @@ -54,19 +68,6 @@ typedef enum LV_GAUGES_DEF, }lv_gauges_builtin_t; -/*Data of gauge*/ -typedef struct -{ - lv_rect_ext_t rect; /*Ext. of ancestor*/ - /*New data for this type */ - int16_t min; - int16_t max; - int16_t * values; - char * txt; - uint8_t needle_num; - uint8_t low_critical :1; /*0: the higher value is more critical, 1: the lower value is more critical*/ -}lv_gauge_ext_t; - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/lv_objx/lv_img.c b/lv_objx/lv_img.c index f9ff7b21d..658afda33 100644 --- a/lv_objx/lv_img.c +++ b/lv_objx/lv_img.c @@ -210,8 +210,8 @@ void lv_img_set_file(lv_obj_t * img, const char * fn) ext->transp = header.transp; if(ext->upscale != 0) { - ext->w *= 2; - ext->h *= 2; + ext->w *= LV_DOWNSCALE; + ext->h *= LV_DOWNSCALE; } if(fn != NULL) { diff --git a/lv_objx/lv_img.h b/lv_objx/lv_img.h index 138546da6..1efe16114 100644 --- a/lv_objx/lv_img.h +++ b/lv_objx/lv_img.h @@ -23,16 +23,28 @@ /********************** * TYPEDEFS **********************/ +/*Data of image*/ +typedef struct +{ + /*No inherited ext. because inherited from the base object*/ /*Ext. of ancestor*/ + /*New data for this type */ + char* fn; /*Image file name. E.g. "U:/my_image"*/ + cord_t w; /*Width of the image (doubled when upscaled)*/ + cord_t h; /*Height of the image (doubled when upscaled)*/ + uint8_t auto_size :1; /*1: automatically set the object size to the image size*/ + uint8_t upscale :1; /*1: upscale to double size*/ + uint8_t transp :1; /*Transp. bit in the image header (library handles this)*/ +}lv_img_ext_t; -/*Style of template*/ +/*Style of image*/ typedef struct { lv_objs_t objs; /*Style of ancestor*/ /*New style element for this type */ - opa_t recolor_opa; + opa_t recolor_opa; /*Intensity of recoloring (OPA_TRANSP, OPA_10 ... OPA_COVER)*/ }lv_imgs_t; -/*Built-in styles of template*/ +/*Built-in styles of image*/ typedef enum { LV_IMGS_DEF, @@ -40,20 +52,8 @@ typedef enum LV_IMGS_DARK, }lv_imgs_builtin_t; -/*Data of template*/ -typedef struct -{ - /*No ext. because inherited from the base object*/ /*Ext. of ancestor*/ - /*New data for this type */ - char* fn; /*Image file name. E.g. "U:/my_image"*/ - cord_t w; /*Width of the image (doubled when upscaled)*/ - cord_t h; /*Height of the image (doubled when upscaled)*/ - uint8_t auto_size :1; /*1: automatically set the object size to the image size*/ - uint8_t upscale :1; /*1: upscale to double size*/ - uint8_t transp :1; /*Transp. bit in the images header (library handles this)*/ -}lv_img_ext_t; - -/*Image header*/ +/* Image header it is compatible with + * the result image converter utility*/ typedef struct { uint16_t w; /*Width of the image map*/ @@ -62,26 +62,85 @@ typedef struct uint16_t transp :1; /*1: Do not draw LV_IMG_TRANSP_COLOR pixels*/ }lv_img_raw_header_t; - /********************** * GLOBAL PROTOTYPES **********************/ -/*Create function*/ + + +/** + * Create an image objects + * @param par pointer to an object, it will be the parent of the new button + * @param copy pointer to a rectangle object, if not NULL then the new object will be copied from it + * @return pointer to the created image + */ lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy); +/** + * Signal function of the image + * @param img pointer to animage object + * @param sign a signal type from lv_signal_t enum + * @param param pointer to a signal specific variable + */ bool lv_img_signal(lv_obj_t * img, lv_signal_t sign, void * param); + +/** + * Return with a pointer to built-in style and/or copy it to a variable + * @param style a style name from lv_imgs_builtin_t enum + * @param copy copy the style to this variable. (NULL if unused) + * @return pointer to an lv_imgs_t style + */ +lv_imgs_t * lv_imgs_get(lv_imgs_builtin_t style, lv_imgs_t * copy); + +/** + * Create a file to the RAMFS from a picture data + * @param fn file name of the new file (e.g. "pic1", will be available at "U:/pic1") + * @param data pointer to a color map with lv_img_raw_header_t header + * @return result of the file operation. FS_RES_OK or any error from fs_res_t + */ +fs_res_t lv_img_create_file(const char * fn, const color_int_t * data); + +/** + * Set a file to the image + * @param img pointer to an image object + * @param fn file name in the RAMFS to set as picture (e.g. "U:/pic1"). + */ void lv_img_set_file(lv_obj_t * img, const char * fn); -fs_res_t lv_img_create_file(const char * fn, const color_int_t * data_p); + +/** + * Enable the auto size feature. + * If enabled the object size will be same as the picture size. + * @param img pointer to an image + * @param en true: auto size enable, false: auto size disable + */ void lv_img_set_auto_size(lv_obj_t * img, bool en); + +/** + * Enable the upscaling with LV_DOWNSCALE. + * If enabled the object size will be same as the picture size. + * @param img pointer to an image + * @param en true: upscale enable, false: upscale disable + */ void lv_img_set_upscale(lv_obj_t * img, bool en); +/** + * Get the auto size enable attribute + * @param img pointer to an image + * @return true: auto size is enabled, false: auto size is disabled + */ bool lv_img_get_auto_size(lv_obj_t * img); + +/** + * Get the upscale enable attribute + * @param img pointer to an image + * @return true: upscale is enabled, false: upscale is disabled + */ bool lv_img_get_upscale(lv_obj_t * img); -lv_imgs_t * lv_imgs_get(lv_imgs_builtin_t style, lv_imgs_t * copy); /********************** * MACROS **********************/ + +/*Use this macro to declare an image in a c file*/ #define LV_IMG_DECLARE(var_name) extern const color_int_t var_name[]; #endif diff --git a/lv_objx/lv_label.h b/lv_objx/lv_label.h index ba9655b97..0dbdb2aff 100644 --- a/lv_objx/lv_label.h +++ b/lv_objx/lv_label.h @@ -24,15 +24,36 @@ * TYPEDEFS **********************/ +/*Long mode behaviors. Used in 'lv_label_ext_t' */ +typedef enum +{ + LV_LABEL_LONG_EXPAND, /*Expand the object size to the text size*/ + LV_LABEL_LONG_BREAK, /*Keep the width and break the text and expand the object height*/ + LV_LABEL_LONG_DOTS, /*Keep the size, break the text and write dots in the last line*/ + LV_LABEL_LONG_SCROLL, /*Expand the object size and scroll the text on the parent (move the label object)*/ +}lv_label_long_mode_t; + +/*Data of label*/ +typedef struct +{ + /*Inherited from 'base_obj' so no inherited ext.*/ /*Ext. of ancestor*/ + /*New data for this type */ + char * txt; /*Text of the label*/ + lv_label_long_mode_t long_mode; /*Determinate what to do with the long texts*/ + char dot_tmp[LV_LABEL_DOT_NUM]; /*Store character which are replaced with dots*/ + uint16_t dot_end; /* The text end position in dot mode*/ + uint8_t static_txt :1; /* Flag to indicate the text is static*/ +}lv_label_ext_t; + /*Style of label*/ typedef struct { lv_objs_t objs; /*Style of ancestor*/ /*New style element for this type */ - font_types_t font; + font_types_t font; /*Name of the font. E.g: FONT_DEJAVU_20*/ uint16_t letter_space; uint16_t line_space; - uint8_t mid :1; + uint8_t mid :1; /*1: Align the lines into the middle*/ }lv_labels_t; /*Built-in styles of label*/ @@ -44,27 +65,6 @@ typedef enum LV_LABELS_TITLE, }lv_labels_builtin_t; - -typedef enum -{ - LV_LABEL_LONG_EXPAND, /*Expand the object size to the text size*/ - LV_LABEL_LONG_BREAK, /*Keep the width and break the text and expand the object height*/ - LV_LABEL_LONG_DOTS, /*Keep the size, break the text and write dots in the last line*/ - LV_LABEL_LONG_SCROLL, /*Expand the object size and scroll the text (move the label object)*/ -}lv_label_long_mode_t; - -/*Data of label*/ -typedef struct -{ - /*Inherited from 'base_obj' so no inherited ext.*/ /*Ext. of ancestor*/ - /*New data for this type */ - char * txt; - lv_label_long_mode_t long_mode; - char dot_tmp[LV_LABEL_DOT_NUM]; /*Store character which are replaced with dots*/ - uint16_t dot_end; /* The text end in dot mode*/ - uint8_t static_txt :1; /* Flag to indicate the text is static*/ -}lv_label_ext_t; - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/lv_objx/lv_led.h b/lv_objx/lv_led.h index 780956f9e..939bebdf4 100644 --- a/lv_objx/lv_led.h +++ b/lv_objx/lv_led.h @@ -27,6 +27,14 @@ * TYPEDEFS **********************/ +/*Data of led*/ +typedef struct +{ + lv_rect_ext_t rect_ext; /*Ext. of ancestor*/ + /*New data for this type */ + uint8_t bright; /*Current brightness of the LED*/ +}lv_led_ext_t; + /*Style of led*/ typedef struct { @@ -42,14 +50,6 @@ typedef enum LV_LEDS_GREEN, }lv_leds_builtin_t; -/*Data of led*/ -typedef struct -{ - lv_rect_ext_t rect_ext; /*Ext. of ancestor*/ - /*New data for this type */ - uint8_t bright; /*Current brightness of the LED*/ -}lv_led_ext_t; - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/lv_objx/lv_line.h b/lv_objx/lv_line.h index 0f817c1ff..bb1819630 100644 --- a/lv_objx/lv_line.h +++ b/lv_objx/lv_line.h @@ -21,6 +21,18 @@ /********************** * TYPEDEFS **********************/ + +/*Data of line*/ +typedef struct +{ + /*Inherited from 'base_obj' so no inherited ext.*/ /*Ext. of ancestor*/ + const point_t * point_array; /*Pointer to an array with the points of the line*/ + uint16_t point_num; /*Number of points in 'point_array' */ + uint8_t auto_size :1; /*1: set obj. width to x max and obj. height to y max */ + uint8_t y_inv :1; /*1: y == 0 will be on the bottom*/ + uint8_t upscale :1; /*1: upscale coordinates with LV_DOWNSCALE*/ +}lv_line_ext_t; + /*Style of line*/ typedef struct { @@ -37,17 +49,6 @@ typedef enum LV_LINES_CHART, }lv_lines_builtin_t; -/*Data of line*/ -typedef struct -{ - /*Inherited from 'base_obj' so inherited ext.*/ /*Ext. of ancestor*/ - const point_t * point_array; - uint16_t point_num; - uint8_t auto_size :1; - uint8_t y_inv :1; - uint8_t upscale :1; -}lv_line_ext_t; - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/lv_objx/lv_list.h b/lv_objx/lv_list.h index a3a65109b..8125c7542 100644 --- a/lv_objx/lv_list.h +++ b/lv_objx/lv_list.h @@ -38,17 +38,24 @@ /********************** * TYPEDEFS **********************/ +/*Data of list*/ +typedef struct +{ + lv_page_ext_t page_ext; /*Ext. of ancestor*/ + /*New data for this type */ + /*No new data*/ +}lv_list_ext_t; /*Style of list*/ typedef struct { lv_pages_t bg_pages; /*Style of ancestor*/ /*New style element for this type */ - lv_btns_t liste_btns; - lv_labels_t liste_labels; - lv_imgs_t liste_imgs; - lv_rect_layout_t liste_layout; - uint8_t widthe_sb :1; /*Keep space for the scrollbar*/ + lv_btns_t liste_btns; /*List element button style*/ + lv_labels_t liste_labels; /*List element label style*/ + lv_imgs_t liste_imgs; /*List element image style*/ + lv_rect_layout_t liste_layout; /*List element layout (will be removed)*/ + uint8_t widthe_sb :1; /*1: Keep space for the scrollbar*/ }lv_lists_t; /*Built-in styles of list*/ @@ -59,14 +66,6 @@ typedef enum LV_LISTS_TRANSP, }lv_lists_builtin_t; -/*Data of list*/ -typedef struct -{ - lv_page_ext_t page_ext; /*Ext. of ancestor*/ - /*New data for this type */ - /*No new data*/ -}lv_list_ext_t; - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/lv_objx/lv_mbox.c b/lv_objx/lv_mbox.c index dc7a5eed2..5f5684881 100644 --- a/lv_objx/lv_mbox.c +++ b/lv_objx/lv_mbox.c @@ -371,7 +371,6 @@ lv_mboxs_t * lv_mboxs_get(lv_mboxs_builtin_t style, lv_mboxs_t * copy) case LV_MBOXS_DEF: style_p = &lv_mboxs_def; break; - case LV_MBOXS_BUBBLE: case LV_MBOXS_INFO: style_p = &lv_mboxs_info; break; diff --git a/lv_objx/lv_mbox.h b/lv_objx/lv_mbox.h index 5b67cfe87..67d926c28 100644 --- a/lv_objx/lv_mbox.h +++ b/lv_objx/lv_mbox.h @@ -39,38 +39,38 @@ * TYPEDEFS **********************/ +/*Data of message box*/ +typedef struct +{ + lv_rect_ext_t rect; /*Ext. of ancestor*/ + /*New data for this type */ + lv_obj_t * title; /*Title of the message box*/ + lv_obj_t * txt; /*Text of the message box*/ + lv_obj_t * btnh; /*Holder of the buttons*/ +}lv_mbox_ext_t; + + /*Style of message box*/ typedef struct { lv_rects_t bg; /*Style of ancestor*/ /*New style element for this type */ - lv_labels_t title; - lv_labels_t txt; - lv_rects_t btnh; - lv_btns_t btn; - lv_labels_t btn_label; + lv_labels_t title; /*Style of the title*/ + lv_labels_t txt; /*Style of the text*/ + lv_rects_t btnh; /*Style of the button holder*/ + lv_btns_t btn; /*Style of the buttons*/ + lv_labels_t btn_label; /*Style of the label on the buttons*/ }lv_mboxs_t; /*Built-in styles of message box*/ typedef enum { LV_MBOXS_DEF, - LV_MBOXS_BUBBLE, /*Will be removed (use LV_MBOXS_INFO instead)*/ LV_MBOXS_INFO, LV_MBOXS_WARN, LV_MBOXS_ERR, }lv_mboxs_builtin_t; -/*Data of message box*/ -typedef struct -{ - lv_rect_ext_t rect; /*Ext. of ancestor*/ - /*New data for this type */ - lv_obj_t * title; - lv_obj_t * txt; - lv_obj_t * btnh; -}lv_mbox_ext_t; - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/lv_objx/lv_objx_templ.h b/lv_objx/lv_objx_templ.h index 7a704fabb..039c85f9d 100644 --- a/lv_objx/lv_objx_templ.h +++ b/lv_objx/lv_objx_templ.h @@ -28,6 +28,12 @@ /********************** * TYPEDEFS **********************/ +/*Data of template*/ +typedef struct +{ + /*Ext. of ancestor*/ + /*New data for this type */ +}lv_templ_ext_t; /*Style of template*/ typedef struct @@ -42,13 +48,6 @@ typedef enum LV_TEMPLS_DEF, }lv_templs_builtin_t; -/*Data of template*/ -typedef struct -{ - /*Ext. of ancestor*/ - /*New data for this type */ -}lv_templ_ext_t; - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/lv_objx/lv_page.h b/lv_objx/lv_page.h index bdf738cf8..9ad5149fd 100644 --- a/lv_objx/lv_page.h +++ b/lv_objx/lv_page.h @@ -27,25 +27,40 @@ /********************** * TYPEDEFS **********************/ + +/*Data of page*/ +typedef struct +{ + lv_rect_ext_t rect_ext; /*Ext. of ancestor*/ + /*New data for this type */ + lv_obj_t * scrl; /*The scrollable object on the background*/ + lv_action_t rel_action; /*Release action*/ + lv_action_t pr_action; /*Press action*/ + area_t sbh; /*Horizontal scrollbar area (relative to the page) */ + area_t sbv; /*Vertical scrollbar area (relative to the page)*/ + uint8_t sbh_draw :1; /*1: horizontal scrollbar is visible now*/ + uint8_t sbv_draw :1; /*1: vertical scrollbar is visible now*/ +}lv_page_ext_t; + +/*Scrollbar modes: shows when should the scrollbars be visible*/ typedef enum { - LV_PAGE_SB_MODE_OFF, - LV_PAGE_SB_MODE_ON, - LV_PAGE_SB_MODE_DRAG, - LV_PAGE_SB_MODE_AUTO, + LV_PAGE_SB_MODE_OFF, /*Never show scrollbars*/ + LV_PAGE_SB_MODE_ON, /*Always show scrollbars*/ + LV_PAGE_SB_MODE_DRAG, /*Show scrollbars when page is being dragged*/ + LV_PAGE_SB_MODE_AUTO, /*Show scrollbars when the scrollable rect. is large enough to be scrolled*/ }lv_page_sb_mode_t; - /*Style of page*/ typedef struct { lv_rects_t bg_rects; /*Style of ancestor*/ /*New style element for this type */ - lv_rects_t scrl_rects; - lv_rects_t sb_rects; - cord_t sb_width; - lv_page_sb_mode_t sb_mode; - uint8_t sb_opa; + lv_rects_t scrl_rects; /*Style of the scrollable rectangle*/ + lv_rects_t sb_rects; /*Style of scrollbars*/ + cord_t sb_width; /*Width of the scrollbars*/ + lv_page_sb_mode_t sb_mode; /*Scrollbar visibility from 'lv_page_sb_mode_t'*/ + uint8_t sb_opa; /*Opacity of scrollbars in percentage of object opacity (0..100)*/ }lv_pages_t; /*Built-in styles of page*/ @@ -56,21 +71,6 @@ typedef enum LV_PAGES_TRANSP, }lv_pages_builtin_t; -/*Data of page*/ -typedef struct -{ - lv_rect_ext_t rect_ext; /*Ext. of ancestor*/ - /*New data for this type */ - lv_obj_t * scrl; /*The scrollable object on the background*/ - lv_action_t rel_action; - lv_action_t pr_action; - area_t sbh; /*Horizontal scrollbar*/ - area_t sbv; /*Vertical scrollbar*/ - uint8_t sbh_draw :1; /*1: horizontal scrollbar is visible now*/ - uint8_t sbv_draw :1; /*1: vertical scrollbar is visible now*/ -}lv_page_ext_t; - - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/lv_objx/lv_pb.h b/lv_objx/lv_pb.h index 8c4a04eba..20f0f8d28 100644 --- a/lv_objx/lv_pb.h +++ b/lv_objx/lv_pb.h @@ -33,12 +33,24 @@ * TYPEDEFS **********************/ +/*Data of progress bar*/ +typedef struct +{ + lv_rect_ext_t rect_ext; /*Ext. of ancestor*/ + /*New data for this type */ + lv_obj_t * label; /*Pointer to the label on the progress bar*/ + uint16_t act_value; /*Current value of the progress bar*/ + uint16_t min_value; /*Minimum value of the progress bar*/ + uint16_t max_value; /*Maximum value of the progress bar*/ + char * format_str; /*Format string of the label. E.g. "Progress: %d"*/ +}lv_pb_ext_t; + /*Style of progress bar*/ typedef struct { - lv_rects_t bg; - lv_rects_t bar; - lv_labels_t label; + lv_rects_t bg; /*Style of the background (inherited)*/ + lv_rects_t bar; /*Style of the bar*/ + lv_labels_t label; /*Style of the label*/ }lv_pbs_t; /*Built-in styles of progress bar*/ @@ -47,18 +59,6 @@ typedef enum LV_PBS_DEF, }lv_pbs_builtin_t; -/*Data of progress bar*/ -typedef struct -{ - lv_rect_ext_t rect_ext; /*Ext. of ancestor*/ - /*New data for this type */ - lv_obj_t * label; - uint16_t act_value; - uint16_t min_value; - uint16_t max_value; - char * format_str; /*Format string of the label*/ -}lv_pb_ext_t; - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/lv_objx/lv_rect.h b/lv_objx/lv_rect.h index cc154dd23..a38954886 100644 --- a/lv_objx/lv_rect.h +++ b/lv_objx/lv_rect.h @@ -24,6 +24,7 @@ * TYPEDEFS **********************/ +/*Layout options*/ typedef enum { LV_RECT_LAYOUT_OFF = 0, @@ -38,6 +39,16 @@ typedef enum LV_RECT_LAYOUT_GRID, /*Align same-sized object into a grid*/ }lv_rect_layout_t; +typedef struct +{ + /*Inherited from 'base_obj' so no inherited ext. */ /*Ext. of ancestor*/ + /*New data for this type */ + uint8_t layout :5; + uint8_t hfit_en :1; + uint8_t vfit_en :1; +}lv_rect_ext_t; + + /*Style of rectangle*/ typedef struct { @@ -48,11 +59,11 @@ typedef struct color_t lcolor; /*Light color*/ uint16_t bwidth;/*Border width*/ uint16_t round; /*Radius on the corners*/ - cord_t hpad; /*Horizontal padding when horizontal fit is enabled*/ - cord_t vpad; /*Vertical padding when vertical fit is enabled*/ - cord_t opad; /*Object padding with fit*/ + cord_t hpad; /*Horizontal padding. Used by fit and layout.*/ + cord_t vpad; /*Vertical padding. Used by fit and layout.*/ + cord_t opad; /*Object padding. Used by fit */ cord_t light; /*Light size*/ - uint8_t bopa; /*Border opacity*/ + uint8_t bopa; /*Border opacity in percentage of object opacity (0..100)*/ uint8_t empty :1; /*1: Do not draw the body of the rectangle*/ }lv_rects_t; @@ -64,16 +75,6 @@ typedef enum LV_RECTS_BORDER, }lv_rects_builtin_t; - -typedef struct -{ - /*Inherited from 'base_obj' so no inherited ext. */ /*Ext. of ancestor*/ - /*New data for this type */ - uint8_t layout :5; - uint8_t hfit_en :1; - uint8_t vfit_en :1; -}lv_rect_ext_t; - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/lv_objx/lv_ta.h b/lv_objx/lv_ta.h index f5a1f3535..4a8bbc55c 100644 --- a/lv_objx/lv_ta.h +++ b/lv_objx/lv_ta.h @@ -34,6 +34,17 @@ * TYPEDEFS **********************/ +/*Data of text area*/ +typedef struct +{ + lv_page_ext_t page; /*Ext. of ancestor*/ + /*New data for this type */ + lv_obj_t * label; /*Label of the text area*/ + cord_t cursor_valid_x; /*Used when stepping up/down in text area. Handled by the library*/ + uint16_t cursor_pos; /*The current cursor position (0: before 1. letter, 1: before 2. letter etc.)*/ + uint8_t cur_hide :1; /*Indicates that the cursor is visible now or not*/ +}lv_ta_ext_t; + /*Style of text area*/ typedef struct { @@ -53,17 +64,6 @@ typedef enum LV_TAS_TRANSP, }lv_tas_builtin_t; -/*Data of text area*/ -typedef struct -{ - lv_page_ext_t page; /*Ext. of ancestor*/ - /*New data for this type */ - lv_obj_t * label; - cord_t cursor_valid_x; - uint16_t cursor_pos; - uint8_t cur_hide :1; /*Indicates that the cursor is visible now or not*/ -}lv_ta_ext_t; - /********************** * GLOBAL PROTOTYPES **********************/ diff --git a/lv_objx/lv_win.c b/lv_objx/lv_win.c index f21e53be6..577e883f0 100644 --- a/lv_objx/lv_win.c +++ b/lv_objx/lv_win.c @@ -48,10 +48,7 @@ static lv_wins_t lv_wins_def; /** * Create a window objects * @param par pointer to an object, it will be the parent of the new window - * @param copy pointer to a window object, if not NULL then - lv_win_add_ctrl_btn(app->win, "U:/close", lv_app_win_close_action); - lv_win_add_ctrl_btn(app->win, "U:/close", lv_app_win_close_action); - lv_win_add_ctrl_btn(app->win, "U:/close", lv_app_win_close_action);the new object will be copied from it + * @param copy pointer to a window object, if not NULL then the new object will be copied from it * @return pointer to the created window */ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy) diff --git a/lv_objx/lv_win.h b/lv_objx/lv_win.h index 362ad8664..c7b615c7d 100644 --- a/lv_objx/lv_win.h +++ b/lv_objx/lv_win.h @@ -52,21 +52,31 @@ * TYPEDEFS **********************/ +/*Data of window*/ +typedef struct +{ + lv_page_ext_t page; /*Ext. of ancestor*/ + /*New data for this type */ + lv_obj_t * header; /*Pointer to the header rectangle of the window*/ + lv_obj_t * title; /*Pointer to the title label of the window*/ + lv_obj_t * ctrl_holder; /*Pointer to the control button holder rectangle of the window*/ +}lv_win_ext_t; + /*Style of window*/ typedef struct { lv_pages_t pages; /*Style of ancestor*/ /*New style element for this type */ /*Header settings*/ - lv_rects_t header; - lv_labels_t title; - lv_rects_t ctrl_holder; - lv_btns_t ctrl_btn; - lv_imgs_t ctrl_img; - cord_t ctrl_btn_w; - cord_t ctrl_btn_h; - opa_t ctrl_btn_opa; - opa_t header_opa; + lv_rects_t header; /*Style of the header rectangle*/ + lv_labels_t title; /*Style of the window title*/ + lv_rects_t ctrl_holder; /*Style of holder of the control buttons*/ + lv_btns_t ctrl_btn; /*Style of the control buttons*/ + lv_imgs_t ctrl_img; /*Style of the image on the control buttons*/ + cord_t ctrl_btn_w; /*Width of the control buttons*/ + cord_t ctrl_btn_h; /*Height of the control buttons*/ + opa_t ctrl_btn_opa; /*Width of the control buttons in the percentage of object opacity (0..100)*/ + opa_t header_opa; /*Opacity of the header in the percentage of object opacity (0..100)*/ }lv_wins_t; /*Built-in styles of window*/ @@ -75,16 +85,6 @@ typedef enum LV_WINS_DEF, }lv_wins_builtin_t; -/*Data of window*/ -typedef struct -{ - lv_page_ext_t page; /*Ext. of ancestor*/ - /*New data for this type */ - lv_obj_t * header; - lv_obj_t * title; - lv_obj_t * ctrl_holder; -}lv_win_ext_t; - /********************** * GLOBAL PROTOTYPES **********************/ @@ -92,10 +92,7 @@ typedef struct /** * Create a window objects * @param par pointer to an object, it will be the parent of the new window - * @param copy pointer to a window object, if not NULL then -lv_win_add_ctrl_btn(app->win, "U:/close", lv_app_win_close_action); -lv_win_add_ctrl_btn(app->win, "U:/close", lv_app_win_close_action); -lv_win_add_ctrl_btn(app->win, "U:/close", lv_app_win_close_action);the new object will be copied from it + * @param copy pointer to a window object, if not NULL then the new object will be copied from it * @return pointer to the created window */ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy);