diff options
author | Gabor Kiss-Vamosi <kisvegabor@gmail.com> | 2023-09-14 20:12:31 +0200 |
---|---|---|
committer | Gabor Kiss-Vamosi <kisvegabor@gmail.com> | 2023-09-14 20:12:31 +0200 |
commit | 09c12d0f9c1e09abec3e58127c9c67cfb958782f (patch) | |
tree | 268fa833b1a29d4a65627ca8b065736603500a11 /src/widgets | |
parent | e91786ce4999eef3f875dee01575ddacfe37c024 (diff) | |
download | lvgl-09c12d0f9c1e09abec3e58127c9c67cfb958782f.tar.gz lvgl-09c12d0f9c1e09abec3e58127c9c67cfb958782f.zip |
refactor(btn, img): rename btn to button and img to image
Diffstat (limited to 'src/widgets')
33 files changed, 624 insertions, 625 deletions
diff --git a/src/widgets/animimg/lv_animimg.c b/src/widgets/animimage/lv_animimage.c index 2b0ab59d2..31665705e 100644 --- a/src/widgets/animimg/lv_animimg.c +++ b/src/widgets/animimage/lv_animimage.c @@ -6,7 +6,7 @@ /********************* * INCLUDES *********************/ -#include "lv_animimg.h" +#include "lv_animimage.h" #if LV_USE_ANIMIMG != 0 /*Testing of dependencies*/ @@ -14,7 +14,7 @@ #error "lv_animimg: lv_img is required. Enable it in lv_conf.h (LV_USE_IMG 1) " #endif -#include "../../draw/lv_img_decoder.h" +#include "../../draw/lv_image_decoder.h" #include "../../misc/lv_assert.h" #include "../../misc/lv_fs.h" #include "../../misc/lv_txt.h" @@ -45,7 +45,7 @@ static void lv_animimg_constructor(const lv_obj_class_t * class_p, lv_obj_t * ob const lv_obj_class_t lv_animimg_class = { .constructor_cb = lv_animimg_constructor, .instance_size = sizeof(lv_animimg_t), - .base_class = &lv_img_class + .base_class = &lv_image_class }; /********************** @@ -161,7 +161,7 @@ static void index_change(lv_obj_t * obj, int32_t index) idx = index % animimg->pic_count; - lv_img_set_src(obj, animimg->dsc[idx]); + lv_image_set_src(obj, animimg->dsc[idx]); } #endif diff --git a/src/widgets/animimg/lv_animimg.h b/src/widgets/animimage/lv_animimage.h index fe802ca7f..cdda39092 100644 --- a/src/widgets/animimg/lv_animimg.h +++ b/src/widgets/animimage/lv_animimage.h @@ -3,8 +3,8 @@ * */ -#ifndef LV_ANIM_IMG_H -#define LV_ANIM_IMG_H +#ifndef LV_ANIM_IMAGE_H +#define LV_ANIM_IMAGE_H #ifdef __cplusplus extern "C" { @@ -13,7 +13,7 @@ extern "C" { /********************* * INCLUDES *********************/ -#include "../img/lv_img.h" +#include "../image/lv_image.h" #if LV_USE_ANIMIMG != 0 @@ -34,7 +34,7 @@ extern const lv_obj_class_t lv_animimg_class; /*Data of image*/ typedef struct { - lv_img_t img; + lv_image_t img; lv_anim_t anim; /*picture sequence */ const void ** dsc; @@ -44,7 +44,7 @@ typedef struct { /*Image parts*/ enum _lv_animimg_part_t { - LV_ANIM_IMG_PART_MAIN, + LV_ANIM_IMAGE_PART_MAIN, }; @@ -136,4 +136,4 @@ uint16_t lv_animimg_get_repeat_count(lv_obj_t * img); } /* extern "C" */ #endif -#endif /*LV_ANIM_IMG_H*/ +#endif /*LV_ANIM_IMAGE_H*/ diff --git a/src/widgets/bar/lv_bar.c b/src/widgets/bar/lv_bar.c index 2f5f9a630..304e51b88 100644 --- a/src/widgets/bar/lv_bar.c +++ b/src/widgets/bar/lv_bar.c @@ -428,16 +428,16 @@ static void draw_indic(lv_event_t * e) if((hor && lv_area_get_width(&bar->indic_area) > indic_radius * 2) || (!hor && lv_area_get_height(&bar->indic_area) > indic_radius * 2)) { lv_opa_t bg_opa = draw_rect_dsc.bg_opa; - lv_opa_t bg_img_opa = draw_rect_dsc.bg_img_opa; + lv_opa_t bg_image_opa = draw_rect_dsc.bg_image_opa; lv_opa_t border_opa = draw_rect_dsc.border_opa; draw_rect_dsc.bg_opa = LV_OPA_TRANSP; - draw_rect_dsc.bg_img_opa = LV_OPA_TRANSP; + draw_rect_dsc.bg_image_opa = LV_OPA_TRANSP; draw_rect_dsc.border_opa = LV_OPA_TRANSP; lv_draw_rect(layer, &draw_rect_dsc, &bar->indic_area); draw_rect_dsc.bg_opa = bg_opa; - draw_rect_dsc.bg_img_opa = bg_img_opa; + draw_rect_dsc.bg_image_opa = bg_image_opa; draw_rect_dsc.border_opa = border_opa; } @@ -477,7 +477,7 @@ static void draw_indic(lv_event_t * e) lv_area_increase(&border2_area, 2, 2); draw_rect_dsc.border_width += 2; draw_rect_dsc.bg_opa = LV_OPA_TRANSP; - draw_rect_dsc.bg_img_opa = LV_OPA_TRANSP; + draw_rect_dsc.bg_image_opa = LV_OPA_TRANSP; draw_rect_dsc.shadow_opa = LV_OPA_TRANSP; lv_draw_rect(layer_indic, &draw_rect_dsc, &border2_area); @@ -490,8 +490,8 @@ static void draw_indic(lv_event_t * e) mask_dsc.area = mask_indic_max_area; lv_draw_mask_rect(layer_indic, &mask_dsc); - lv_draw_img_dsc_t layer_draw_dsc; - lv_draw_img_dsc_init(&layer_draw_dsc); + lv_draw_image_dsc_t layer_draw_dsc; + lv_draw_image_dsc_init(&layer_draw_dsc); layer_draw_dsc.src = layer_indic; lv_draw_layer(layer, &layer_draw_dsc, &indic_area); diff --git a/src/widgets/btn/lv_btn.c b/src/widgets/button/lv_button.c index a126604b8..cb112880e 100644 --- a/src/widgets/btn/lv_btn.c +++ b/src/widgets/button/lv_button.c @@ -7,13 +7,13 @@ * INCLUDES *********************/ -#include "lv_btn.h" +#include "lv_button.h" #if LV_USE_BTN != 0 /********************* * DEFINES *********************/ -#define MY_CLASS &lv_btn_class +#define MY_CLASS &lv_button_class /********************** * TYPEDEFS @@ -22,17 +22,17 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_btn_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj); +static void lv_button_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj); /********************** * STATIC VARIABLES **********************/ -const lv_obj_class_t lv_btn_class = { - .constructor_cb = lv_btn_constructor, +const lv_obj_class_t lv_button_class = { + .constructor_cb = lv_button_constructor, .width_def = LV_SIZE_CONTENT, .height_def = LV_SIZE_CONTENT, .group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE, - .instance_size = sizeof(lv_btn_t), + .instance_size = sizeof(lv_button_t), .base_class = &lv_obj_class }; @@ -44,7 +44,7 @@ const lv_obj_class_t lv_btn_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_btn_create(lv_obj_t * parent) +lv_obj_t * lv_button_create(lv_obj_t * parent) { LV_LOG_INFO("begin"); lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent); @@ -56,7 +56,7 @@ lv_obj_t * lv_btn_create(lv_obj_t * parent) * STATIC FUNCTIONS **********************/ -static void lv_btn_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) +static void lv_button_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) { LV_UNUSED(class_p); LV_TRACE_OBJ_CREATE("begin"); diff --git a/src/widgets/btn/lv_btn.h b/src/widgets/button/lv_button.h index 473577776..669945d06 100644 --- a/src/widgets/btn/lv_btn.h +++ b/src/widgets/button/lv_button.h @@ -3,8 +3,8 @@ * */ -#ifndef LV_BTN_H -#define LV_BTN_H +#ifndef LV_BUTTON_H +#define LV_BUTTON_H #ifdef __cplusplus extern "C" { @@ -28,9 +28,9 @@ extern "C" { typedef struct { lv_obj_t obj; -} lv_btn_t; +} lv_button_t; -extern const lv_obj_class_t lv_btn_class; +extern const lv_obj_class_t lv_button_class; /********************** * GLOBAL PROTOTYPES @@ -41,7 +41,7 @@ extern const lv_obj_class_t lv_btn_class; * @param parent pointer to an object, it will be the parent of the new button * @return pointer to the created button */ -lv_obj_t * lv_btn_create(lv_obj_t * parent); +lv_obj_t * lv_button_create(lv_obj_t * parent); /********************** * MACROS @@ -53,4 +53,4 @@ lv_obj_t * lv_btn_create(lv_obj_t * parent); } /*extern "C"*/ #endif -#endif /*LV_BTN_H*/ +#endif /*LV_BUTTON_H*/ diff --git a/src/widgets/btnmatrix/lv_btnmatrix.c b/src/widgets/buttonmatrix/lv_buttonmatrix.c index aeaaaf97a..f83768a53 100644 --- a/src/widgets/btnmatrix/lv_btnmatrix.c +++ b/src/widgets/buttonmatrix/lv_buttonmatrix.c @@ -6,7 +6,7 @@ /********************* * INCLUDES *********************/ -#include "lv_btnmatrix.h" +#include "lv_buttonmatrix.h" #if LV_USE_BTNMATRIX != 0 #include "../../misc/lv_assert.h" @@ -21,10 +21,10 @@ /********************* * DEFINES *********************/ -#define MY_CLASS &lv_btnmatrix_class +#define MY_CLASS &lv_buttonmatrix_class #define BTN_EXTRA_CLICK_AREA_MAX (LV_DPI_DEF / 10) -#define LV_BTNMATRIX_WIDTH_MASK 0x000F +#define LV_BUTTONMATRIX_WIDTH_MASK 0x000F /********************** * TYPEDEFS @@ -33,23 +33,23 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_btnmatrix_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj); -static void lv_btnmatrix_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj); -static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e); +static void lv_buttonmatrix_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj); +static void lv_buttonmatrix_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj); +static void lv_buttonmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e); static void draw_main(lv_event_t * e); -static uint8_t get_button_width(lv_btnmatrix_ctrl_t ctrl_bits); -static bool button_is_hidden(lv_btnmatrix_ctrl_t ctrl_bits); -static bool button_is_checked(lv_btnmatrix_ctrl_t ctrl_bits); -static bool button_is_repeat_disabled(lv_btnmatrix_ctrl_t ctrl_bits); -static bool button_is_inactive(lv_btnmatrix_ctrl_t ctrl_bits); -static bool button_is_click_trig(lv_btnmatrix_ctrl_t ctrl_bits); -static bool button_is_popover(lv_btnmatrix_ctrl_t ctrl_bits); -static bool button_is_checkable(lv_btnmatrix_ctrl_t ctrl_bits); -static bool button_is_recolor(lv_btnmatrix_ctrl_t ctrl_bits); -static bool button_get_checked(lv_btnmatrix_ctrl_t ctrl_bits); +static uint8_t get_button_width(lv_buttonmatrix_ctrl_t ctrl_bits); +static bool button_is_hidden(lv_buttonmatrix_ctrl_t ctrl_bits); +static bool button_is_checked(lv_buttonmatrix_ctrl_t ctrl_bits); +static bool button_is_repeat_disabled(lv_buttonmatrix_ctrl_t ctrl_bits); +static bool button_is_inactive(lv_buttonmatrix_ctrl_t ctrl_bits); +static bool button_is_click_trig(lv_buttonmatrix_ctrl_t ctrl_bits); +static bool button_is_popover(lv_buttonmatrix_ctrl_t ctrl_bits); +static bool button_is_checkable(lv_buttonmatrix_ctrl_t ctrl_bits); +static bool button_is_recolor(lv_buttonmatrix_ctrl_t ctrl_bits); +static bool button_get_checked(lv_buttonmatrix_ctrl_t ctrl_bits); static uint16_t get_button_from_point(lv_obj_t * obj, lv_point_t * p); -static void allocate_btn_areas_and_controls(const lv_obj_t * obj, const char ** map); +static void allocate_button_areas_and_controls(const lv_obj_t * obj, const char ** map); static void invalidate_button_area(const lv_obj_t * obj, uint16_t btn_idx); static void make_one_button_checked(lv_obj_t * obj, uint16_t btn_idx); static bool has_popovers_in_top_row(lv_obj_t * obj); @@ -58,16 +58,16 @@ static bool has_popovers_in_top_row(lv_obj_t * obj); * STATIC VARIABLES **********************/ #if LV_WIDGETS_HAS_DEFAULT_VALUE -static const char * lv_btnmatrix_def_map[] = {"Btn1", "Btn2", "Btn3", "\n", "Btn4", "Btn5", ""}; +static const char * lv_buttonmatrix_def_map[] = {"Btn1", "Btn2", "Btn3", "\n", "Btn4", "Btn5", ""}; #endif -const lv_obj_class_t lv_btnmatrix_class = { - .constructor_cb = lv_btnmatrix_constructor, - .destructor_cb = lv_btnmatrix_destructor, - .event_cb = lv_btnmatrix_event, +const lv_obj_class_t lv_buttonmatrix_class = { + .constructor_cb = lv_buttonmatrix_constructor, + .destructor_cb = lv_buttonmatrix_destructor, + .event_cb = lv_buttonmatrix_event, .width_def = LV_DPI_DEF * 2, .height_def = LV_DPI_DEF, - .instance_size = sizeof(lv_btnmatrix_t), + .instance_size = sizeof(lv_buttonmatrix_t), .editable = LV_OBJ_CLASS_EDITABLE_TRUE, .group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE, .base_class = &lv_obj_class @@ -81,7 +81,7 @@ const lv_obj_class_t lv_btnmatrix_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_btnmatrix_create(lv_obj_t * parent) +lv_obj_t * lv_buttonmatrix_create(lv_obj_t * parent) { LV_LOG_INFO("begin"); lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent); @@ -93,15 +93,15 @@ lv_obj_t * lv_btnmatrix_create(lv_obj_t * parent) * Setter functions *====================*/ -void lv_btnmatrix_set_map(lv_obj_t * obj, const char * map[]) +void lv_buttonmatrix_set_map(lv_obj_t * obj, const char * map[]) { LV_ASSERT_OBJ(obj, MY_CLASS); if(map == NULL) return; - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj; /*Analyze the map and create the required number of buttons*/ - allocate_btn_areas_and_controls(obj, map); + allocate_button_areas_and_controls(obj, map); btnm->map_p = map; lv_base_dir_t base_dir = lv_obj_get_style_base_dir(obj, LV_PART_MAIN); @@ -184,104 +184,104 @@ void lv_btnmatrix_set_map(lv_obj_t * obj, const char * map[]) lv_obj_invalidate(obj); } -void lv_btnmatrix_set_ctrl_map(lv_obj_t * obj, const lv_btnmatrix_ctrl_t ctrl_map[]) +void lv_buttonmatrix_set_ctrl_map(lv_obj_t * obj, const lv_buttonmatrix_ctrl_t ctrl_map[]) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; - lv_memcpy(btnm->ctrl_bits, ctrl_map, sizeof(lv_btnmatrix_ctrl_t) * btnm->btn_cnt); + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj; + lv_memcpy(btnm->ctrl_bits, ctrl_map, sizeof(lv_buttonmatrix_ctrl_t) * btnm->btn_cnt); - lv_btnmatrix_set_map(obj, btnm->map_p); + lv_buttonmatrix_set_map(obj, btnm->map_p); } -void lv_btnmatrix_set_selected_btn(lv_obj_t * obj, uint16_t btn_id) +void lv_buttonmatrix_set_selected_button(lv_obj_t * obj, uint16_t btn_id) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj; - if(btn_id >= btnm->btn_cnt && btn_id != LV_BTNMATRIX_BTN_NONE) return; + if(btn_id >= btnm->btn_cnt && btn_id != LV_BUTTONMATRIX_BUTTON_NONE) return; invalidate_button_area(obj, btnm->btn_id_sel); btnm->btn_id_sel = btn_id; invalidate_button_area(obj, btn_id); } -void lv_btnmatrix_set_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl) +void lv_buttonmatrix_set_button_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_buttonmatrix_ctrl_t ctrl) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj;; if(btn_id >= btnm->btn_cnt) return; - if(btnm->one_check && (ctrl & LV_BTNMATRIX_CTRL_CHECKED)) { - lv_btnmatrix_clear_btn_ctrl_all(obj, LV_BTNMATRIX_CTRL_CHECKED); + if(btnm->one_check && (ctrl & LV_BUTTONMATRIX_CTRL_CHECKED)) { + lv_buttonmatrix_clear_button_ctrl_all(obj, LV_BUTTONMATRIX_CTRL_CHECKED); } btnm->ctrl_bits[btn_id] |= ctrl; invalidate_button_area(obj, btn_id); - if(ctrl & LV_BTNMATRIX_CTRL_POPOVER) { + if(ctrl & LV_BUTTONMATRIX_CTRL_POPOVER) { lv_obj_refresh_ext_draw_size(obj); } } -void lv_btnmatrix_clear_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl) +void lv_buttonmatrix_clear_button_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_buttonmatrix_ctrl_t ctrl) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj;; if(btn_id >= btnm->btn_cnt) return; btnm->ctrl_bits[btn_id] &= (~ctrl); invalidate_button_area(obj, btn_id); - if(ctrl & LV_BTNMATRIX_CTRL_POPOVER) { + if(ctrl & LV_BUTTONMATRIX_CTRL_POPOVER) { lv_obj_refresh_ext_draw_size(obj); } } -void lv_btnmatrix_set_btn_ctrl_all(lv_obj_t * obj, lv_btnmatrix_ctrl_t ctrl) +void lv_buttonmatrix_set_button_ctrl_all(lv_obj_t * obj, lv_buttonmatrix_ctrl_t ctrl) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj;; uint16_t i; for(i = 0; i < btnm->btn_cnt; i++) { - lv_btnmatrix_set_btn_ctrl(obj, i, ctrl); + lv_buttonmatrix_set_button_ctrl(obj, i, ctrl); } } -void lv_btnmatrix_clear_btn_ctrl_all(lv_obj_t * obj, lv_btnmatrix_ctrl_t ctrl) +void lv_buttonmatrix_clear_button_ctrl_all(lv_obj_t * obj, lv_buttonmatrix_ctrl_t ctrl) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj;; uint16_t i; for(i = 0; i < btnm->btn_cnt; i++) { - lv_btnmatrix_clear_btn_ctrl(obj, i, ctrl); + lv_buttonmatrix_clear_button_ctrl(obj, i, ctrl); } } -void lv_btnmatrix_set_btn_width(lv_obj_t * obj, uint16_t btn_id, uint8_t width) +void lv_buttonmatrix_set_button_width(lv_obj_t * obj, uint16_t btn_id, uint8_t width) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj;; if(btn_id >= btnm->btn_cnt) return; - btnm->ctrl_bits[btn_id] &= (~LV_BTNMATRIX_WIDTH_MASK); - btnm->ctrl_bits[btn_id] |= (LV_BTNMATRIX_WIDTH_MASK & width); + btnm->ctrl_bits[btn_id] &= (~LV_BUTTONMATRIX_WIDTH_MASK); + btnm->ctrl_bits[btn_id] |= (LV_BUTTONMATRIX_WIDTH_MASK & width); - lv_btnmatrix_set_map(obj, btnm->map_p); + lv_buttonmatrix_set_map(obj, btnm->map_p); } -void lv_btnmatrix_set_one_checked(lv_obj_t * obj, bool en) +void lv_buttonmatrix_set_one_checked(lv_obj_t * obj, bool en) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj;; btnm->one_check = en; /*If more than one button is toggled only the first one should be*/ @@ -292,29 +292,29 @@ void lv_btnmatrix_set_one_checked(lv_obj_t * obj, bool en) * Getter functions *====================*/ -const char ** lv_btnmatrix_get_map(const lv_obj_t * obj) +const char ** lv_buttonmatrix_get_map(const lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj;; return btnm->map_p; } -uint16_t lv_btnmatrix_get_selected_btn(const lv_obj_t * obj) +uint16_t lv_buttonmatrix_get_selected_button(const lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj;; return btnm->btn_id_sel; } -const char * lv_btnmatrix_get_btn_text(const lv_obj_t * obj, uint16_t btn_id) +const char * lv_buttonmatrix_get_button_text(const lv_obj_t * obj, uint16_t btn_id) { LV_ASSERT_OBJ(obj, MY_CLASS); - if(btn_id == LV_BTNMATRIX_BTN_NONE) return NULL; + if(btn_id == LV_BUTTONMATRIX_BUTTON_NONE) return NULL; - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj; if(btn_id > btnm->btn_cnt) return NULL; uint16_t txt_i = 0; @@ -333,21 +333,21 @@ const char * lv_btnmatrix_get_btn_text(const lv_obj_t * obj, uint16_t btn_id) return btnm->map_p[txt_i]; } -bool lv_btnmatrix_has_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl) +bool lv_buttonmatrix_has_button_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_buttonmatrix_ctrl_t ctrl) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj;; if(btn_id >= btnm->btn_cnt) return false; return (btnm->ctrl_bits[btn_id] & ctrl) == ctrl; } -bool lv_btnmatrix_get_one_checked(const lv_obj_t * obj) +bool lv_buttonmatrix_get_one_checked(const lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj;; return btnm->one_check; } @@ -356,31 +356,31 @@ bool lv_btnmatrix_get_one_checked(const lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_btnmatrix_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) +static void lv_buttonmatrix_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) { LV_UNUSED(class_p); LV_TRACE_OBJ_CREATE("begin"); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj; btnm->btn_cnt = 0; btnm->row_cnt = 0; - btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE; + btnm->btn_id_sel = LV_BUTTONMATRIX_BUTTON_NONE; btnm->button_areas = NULL; btnm->ctrl_bits = NULL; btnm->map_p = NULL; btnm->one_check = 0; #if LV_WIDGETS_HAS_DEFAULT_VALUE - lv_btnmatrix_set_map(obj, lv_btnmatrix_def_map); + lv_buttonmatrix_set_map(obj, lv_buttonmatrix_def_map); #endif LV_TRACE_OBJ_CREATE("finished"); } -static void lv_btnmatrix_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj) +static void lv_buttonmatrix_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj) { LV_TRACE_OBJ_CREATE("begin"); LV_UNUSED(class_p); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj; lv_free(btnm->button_areas); lv_free(btnm->ctrl_bits); btnm->button_areas = NULL; @@ -388,7 +388,7 @@ static void lv_btnmatrix_destructor(const lv_obj_class_t * class_p, lv_obj_t * o LV_TRACE_OBJ_CREATE("finished"); } -static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) +static void lv_buttonmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) { LV_UNUSED(class_p); @@ -400,7 +400,7 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) lv_event_code_t code = lv_event_get_code(e); lv_obj_t * obj = lv_event_get_target(e); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj; lv_point_t p; if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) { @@ -411,10 +411,10 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) } } if(code == LV_EVENT_STYLE_CHANGED) { - lv_btnmatrix_set_map(obj, btnm->map_p); + lv_buttonmatrix_set_map(obj, btnm->map_p); } else if(code == LV_EVENT_SIZE_CHANGED) { - lv_btnmatrix_set_map(obj, btnm->map_p); + lv_buttonmatrix_set_map(obj, btnm->map_p); } else if(code == LV_EVENT_PRESSED) { lv_indev_t * indev = lv_event_get_indev(e); @@ -427,8 +427,8 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) lv_indev_get_point(indev, &p); btn_pr = get_button_from_point(obj, &p); /*Handle the case where there is no button there*/ - btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE; - if(btn_pr != LV_BTNMATRIX_BTN_NONE) { + btnm->btn_id_sel = LV_BUTTONMATRIX_BUTTON_NONE; + if(btn_pr != LV_BUTTONMATRIX_BUTTON_NONE) { if(button_is_inactive(btnm->ctrl_bits[btn_pr]) == false && button_is_hidden(btnm->ctrl_bits[btn_pr]) == false) { btnm->btn_id_sel = btn_pr; @@ -437,7 +437,7 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) } } - if(btnm->btn_id_sel != LV_BTNMATRIX_BTN_NONE) { + if(btnm->btn_id_sel != LV_BUTTONMATRIX_BUTTON_NONE) { if(button_is_click_trig(btnm->ctrl_bits[btnm->btn_id_sel]) == false && button_is_popover(btnm->ctrl_bits[btnm->btn_id_sel]) == false && button_is_inactive(btnm->ctrl_bits[btnm->btn_id_sel]) == false && @@ -450,26 +450,26 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) } else if(code == LV_EVENT_PRESSING) { /*If a slid to a new button, discard the current button and don't press any buttons*/ - if(btnm->btn_id_sel != LV_BTNMATRIX_BTN_NONE) { + if(btnm->btn_id_sel != LV_BUTTONMATRIX_BUTTON_NONE) { lv_indev_t * indev = lv_event_get_indev(e); lv_indev_get_point(indev, &p); uint16_t btn_pr = get_button_from_point(obj, &p); if(btn_pr != btnm->btn_id_sel) { invalidate_button_area(obj, btnm->btn_id_sel); /*Invalidate the old area*/ - btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE; + btnm->btn_id_sel = LV_BUTTONMATRIX_BUTTON_NONE; } } } else if(code == LV_EVENT_RELEASED) { - if(btnm->btn_id_sel != LV_BTNMATRIX_BTN_NONE) { + if(btnm->btn_id_sel != LV_BUTTONMATRIX_BUTTON_NONE) { /*Toggle the button if enabled*/ if(button_is_checkable(btnm->ctrl_bits[btnm->btn_id_sel]) && !button_is_inactive(btnm->ctrl_bits[btnm->btn_id_sel])) { if(button_get_checked(btnm->ctrl_bits[btnm->btn_id_sel]) && !btnm->one_check) { - btnm->ctrl_bits[btnm->btn_id_sel] &= (~LV_BTNMATRIX_CTRL_CHECKED); + btnm->ctrl_bits[btnm->btn_id_sel] &= (~LV_BUTTONMATRIX_CTRL_CHECKED); } else { - btnm->ctrl_bits[btnm->btn_id_sel] |= LV_BTNMATRIX_CTRL_CHECKED; + btnm->ctrl_bits[btnm->btn_id_sel] |= LV_BUTTONMATRIX_CTRL_CHECKED; } if(btnm->one_check) make_one_button_checked(obj, btnm->btn_id_sel); } @@ -490,7 +490,7 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) } else if(code == LV_EVENT_LONG_PRESSED_REPEAT) { - if(btnm->btn_id_sel != LV_BTNMATRIX_BTN_NONE) { + if(btnm->btn_id_sel != LV_BUTTONMATRIX_BUTTON_NONE) { if(button_is_repeat_disabled(btnm->ctrl_bits[btnm->btn_id_sel]) == false && button_is_inactive(btnm->ctrl_bits[btnm->btn_id_sel]) == false && button_is_hidden(btnm->ctrl_bits[btnm->btn_id_sel]) == false) { @@ -502,7 +502,7 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) } else if(code == LV_EVENT_PRESS_LOST) { invalidate_button_area(obj, btnm->btn_id_sel); - btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE; + btnm->btn_id_sel = LV_BUTTONMATRIX_BUTTON_NONE; } else if(code == LV_EVENT_FOCUSED) { if(btnm->btn_cnt == 0) return; @@ -518,7 +518,7 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) bool editing = lv_group_get_editing(lv_obj_get_group(obj)); /*Focus the first button if there is not selected button*/ - if(btnm->btn_id_sel == LV_BTNMATRIX_BTN_NONE) { + if(btnm->btn_id_sel == LV_BUTTONMATRIX_BUTTON_NONE) { if(indev_type == LV_INDEV_TYPE_KEYPAD || (indev_type == LV_INDEV_TYPE_ENCODER && editing)) { uint32_t b = 0; if(btnm->one_check) { @@ -540,14 +540,14 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) btnm->btn_id_sel = b; } else { - btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE; + btnm->btn_id_sel = LV_BUTTONMATRIX_BUTTON_NONE; } } } else if(code == LV_EVENT_DEFOCUSED || code == LV_EVENT_LEAVE) { // TODO - // if(btnm->btn_id_sel != LV_BTNMATRIX_BTN_NONE) invalidate_button_area(obj, btnm->btn_id_sel); - // btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE; + // if(btnm->btn_id_sel != LV_BUTTONMATRIX_BUTTON_NONE) invalidate_button_area(obj, btnm->btn_id_sel); + // btnm->btn_id_sel = LV_BUTTONMATRIX_BUTTON_NONE; } else if(code == LV_EVENT_KEY) { @@ -555,7 +555,7 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) char c = *((char *)lv_event_get_param(e)); if(c == LV_KEY_RIGHT) { - if(btnm->btn_id_sel == LV_BTNMATRIX_BTN_NONE) btnm->btn_id_sel = 0; + if(btnm->btn_id_sel == LV_BUTTONMATRIX_BUTTON_NONE) btnm->btn_id_sel = 0; else btnm->btn_id_sel++; if(btnm->btn_id_sel >= btnm->btn_cnt) btnm->btn_id_sel = 0; @@ -565,13 +565,13 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) if(btnm->btn_id_sel >= btnm->btn_cnt) btnm->btn_id_sel = 0; if(btnm->btn_id_sel == btn_id_start) { - btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE; + btnm->btn_id_sel = LV_BUTTONMATRIX_BUTTON_NONE; break; } } } else if(c == LV_KEY_LEFT) { - if(btnm->btn_id_sel == LV_BTNMATRIX_BTN_NONE) btnm->btn_id_sel = 0; + if(btnm->btn_id_sel == LV_BUTTONMATRIX_BUTTON_NONE) btnm->btn_id_sel = 0; if(btnm->btn_id_sel == 0) btnm->btn_id_sel = btnm->btn_cnt - 1; else if(btnm->btn_id_sel > 0) btnm->btn_id_sel--; @@ -582,7 +582,7 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) else btnm->btn_id_sel = btnm->btn_cnt - 1; if(btnm->btn_id_sel == btn_id_start) { - btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE; + btnm->btn_id_sel = LV_BUTTONMATRIX_BUTTON_NONE; break; } } @@ -590,12 +590,12 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) else if(c == LV_KEY_DOWN) { lv_coord_t col_gap = lv_obj_get_style_pad_column(obj, LV_PART_MAIN); /*Find the area below the current*/ - if(btnm->btn_id_sel == LV_BTNMATRIX_BTN_NONE) { + if(btnm->btn_id_sel == LV_BUTTONMATRIX_BUTTON_NONE) { btnm->btn_id_sel = 0; while(button_is_hidden(btnm->ctrl_bits[btnm->btn_id_sel]) || button_is_inactive(btnm->ctrl_bits[btnm->btn_id_sel])) { btnm->btn_id_sel++; if(btnm->btn_id_sel >= btnm->btn_cnt) { - btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE; + btnm->btn_id_sel = LV_BUTTONMATRIX_BUTTON_NONE; break; } } @@ -621,12 +621,12 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) else if(c == LV_KEY_UP) { lv_coord_t col_gap = lv_obj_get_style_pad_column(obj, LV_PART_MAIN); /*Find the area below the current*/ - if(btnm->btn_id_sel == LV_BTNMATRIX_BTN_NONE) { + if(btnm->btn_id_sel == LV_BUTTONMATRIX_BUTTON_NONE) { btnm->btn_id_sel = 0; while(button_is_hidden(btnm->ctrl_bits[btnm->btn_id_sel]) || button_is_inactive(btnm->ctrl_bits[btnm->btn_id_sel])) { btnm->btn_id_sel++; if(btnm->btn_id_sel >= btnm->btn_cnt) { - btnm->btn_id_sel = LV_BTNMATRIX_BTN_NONE; + btnm->btn_id_sel = LV_BUTTONMATRIX_BUTTON_NONE; break; } } @@ -660,7 +660,7 @@ static void lv_btnmatrix_event(const lv_obj_class_t * class_p, lv_event_t * e) static void draw_main(lv_event_t * e) { lv_obj_t * obj = lv_event_get_target(e); - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj; if(btnm->btn_cnt == 0) return; lv_layer_t * layer = lv_event_get_layer(e); @@ -761,7 +761,7 @@ static void draw_main(lv_event_t * e) lv_coord_t btn_height = lv_area_get_height(&btn_area); - if((btn_state & LV_STATE_PRESSED) && (btnm->ctrl_bits[btn_i] & LV_BTNMATRIX_CTRL_POPOVER)) { + if((btn_state & LV_STATE_PRESSED) && (btnm->ctrl_bits[btn_i] & LV_BUTTONMATRIX_CTRL_POPOVER)) { /*Push up the upper boundary of the btn area to create the popover*/ btn_area.y1 -= btn_height; } @@ -792,7 +792,7 @@ static void draw_main(lv_event_t * e) btn_area.x2 = btn_area.x1 + txt_size.x; btn_area.y2 = btn_area.y1 + txt_size.y; - if((btn_state & LV_STATE_PRESSED) && (btnm->ctrl_bits[btn_i] & LV_BTNMATRIX_CTRL_POPOVER)) { + if((btn_state & LV_STATE_PRESSED) && (btnm->ctrl_bits[btn_i] & LV_BUTTONMATRIX_CTRL_POPOVER)) { /*Push up the button text into the popover*/ btn_area.y1 -= btn_height / 2; btn_area.y2 -= btn_height / 2; @@ -812,9 +812,9 @@ static void draw_main(lv_event_t * e) * @param obj pointer to button matrix object * @param map_p pointer to a string array */ -static void allocate_btn_areas_and_controls(const lv_obj_t * obj, const char ** map) +static void allocate_button_areas_and_controls(const lv_obj_t * obj, const char ** map) { - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj; btnm->row_cnt = 1; /*Count the buttons in the map*/ uint16_t btn_cnt = 0; @@ -843,11 +843,11 @@ static void allocate_btn_areas_and_controls(const lv_obj_t * obj, const char ** btnm->button_areas = lv_malloc(sizeof(lv_area_t) * btn_cnt); LV_ASSERT_MALLOC(btnm->button_areas); - btnm->ctrl_bits = lv_malloc(sizeof(lv_btnmatrix_ctrl_t) * btn_cnt); + btnm->ctrl_bits = lv_malloc(sizeof(lv_buttonmatrix_ctrl_t) * btn_cnt); LV_ASSERT_MALLOC(btnm->ctrl_bits); if(btnm->button_areas == NULL || btnm->ctrl_bits == NULL) btn_cnt = 0; - lv_memzero(btnm->ctrl_bits, sizeof(lv_btnmatrix_ctrl_t) * btn_cnt); + lv_memzero(btnm->ctrl_bits, sizeof(lv_buttonmatrix_ctrl_t) * btn_cnt); btnm->btn_cnt = btn_cnt; } @@ -857,67 +857,67 @@ static void allocate_btn_areas_and_controls(const lv_obj_t * obj, const char ** * @param ctrl_bits least significant 3 bits used (1..7 valid values) * @return the width of the button in units */ -static uint8_t get_button_width(lv_btnmatrix_ctrl_t ctrl_bits) +static uint8_t get_button_width(lv_buttonmatrix_ctrl_t ctrl_bits) { - uint8_t w = ctrl_bits & LV_BTNMATRIX_WIDTH_MASK; + uint8_t w = ctrl_bits & LV_BUTTONMATRIX_WIDTH_MASK; return w != 0 ? w : 1; } -static bool button_is_hidden(lv_btnmatrix_ctrl_t ctrl_bits) +static bool button_is_hidden(lv_buttonmatrix_ctrl_t ctrl_bits) { - return ctrl_bits & LV_BTNMATRIX_CTRL_HIDDEN; + return ctrl_bits & LV_BUTTONMATRIX_CTRL_HIDDEN; } -static bool button_is_checked(lv_btnmatrix_ctrl_t ctrl_bits) +static bool button_is_checked(lv_buttonmatrix_ctrl_t ctrl_bits) { - return ctrl_bits & LV_BTNMATRIX_CTRL_CHECKED; + return ctrl_bits & LV_BUTTONMATRIX_CTRL_CHECKED; } -static bool button_is_repeat_disabled(lv_btnmatrix_ctrl_t ctrl_bits) +static bool button_is_repeat_disabled(lv_buttonmatrix_ctrl_t ctrl_bits) { - return ctrl_bits & LV_BTNMATRIX_CTRL_NO_REPEAT; + return ctrl_bits & LV_BUTTONMATRIX_CTRL_NO_REPEAT; } -static bool button_is_inactive(lv_btnmatrix_ctrl_t ctrl_bits) +static bool button_is_inactive(lv_buttonmatrix_ctrl_t ctrl_bits) { - return ctrl_bits & LV_BTNMATRIX_CTRL_DISABLED; + return ctrl_bits & LV_BUTTONMATRIX_CTRL_DISABLED; } -static bool button_is_click_trig(lv_btnmatrix_ctrl_t ctrl_bits) +static bool button_is_click_trig(lv_buttonmatrix_ctrl_t ctrl_bits) { - return ctrl_bits & LV_BTNMATRIX_CTRL_CLICK_TRIG; + return ctrl_bits & LV_BUTTONMATRIX_CTRL_CLICK_TRIG; } -static bool button_is_popover(lv_btnmatrix_ctrl_t ctrl_bits) +static bool button_is_popover(lv_buttonmatrix_ctrl_t ctrl_bits) { - return ctrl_bits & LV_BTNMATRIX_CTRL_POPOVER; + return ctrl_bits & LV_BUTTONMATRIX_CTRL_POPOVER; } -static bool button_is_checkable(lv_btnmatrix_ctrl_t ctrl_bits) +static bool button_is_checkable(lv_buttonmatrix_ctrl_t ctrl_bits) { - return ctrl_bits & LV_BTNMATRIX_CTRL_CHECKABLE; + return ctrl_bits & LV_BUTTONMATRIX_CTRL_CHECKABLE; } -static bool button_get_checked(lv_btnmatrix_ctrl_t ctrl_bits) +static bool button_get_checked(lv_buttonmatrix_ctrl_t ctrl_bits) { - return ctrl_bits & LV_BTNMATRIX_CTRL_CHECKED; + return ctrl_bits & LV_BUTTONMATRIX_CTRL_CHECKED; } -static bool button_is_recolor(lv_btnmatrix_ctrl_t ctrl_bits) +static bool button_is_recolor(lv_buttonmatrix_ctrl_t ctrl_bits) { - return ctrl_bits & LV_BTNMATRIX_CTRL_RECOLOR; + return ctrl_bits & LV_BUTTONMATRIX_CTRL_RECOLOR; } /** * Gives the button id of a button under a given point * @param obj pointer to a button matrix object * @param p a point with absolute coordinates - * @return the id of the button or LV_BTNMATRIX_BTN_NONE. + * @return the id of the button or LV_BUTTONMATRIX_BUTTON_NONE. */ static uint16_t get_button_from_point(lv_obj_t * obj, lv_point_t * p) { lv_area_t obj_cords; lv_area_t btn_area; - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj;; uint16_t i; lv_obj_get_coords(obj, &obj_cords); @@ -961,19 +961,19 @@ static uint16_t get_button_from_point(lv_obj_t * obj, lv_point_t * p) } } - if(i == btnm->btn_cnt) i = LV_BTNMATRIX_BTN_NONE; + if(i == btnm->btn_cnt) i = LV_BUTTONMATRIX_BUTTON_NONE; return i; } static void invalidate_button_area(const lv_obj_t * obj, uint16_t btn_idx) { - if(btn_idx == LV_BTNMATRIX_BTN_NONE) return; + if(btn_idx == LV_BUTTONMATRIX_BUTTON_NONE) return; lv_area_t btn_area; lv_area_t obj_area; - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj;; if(btn_idx >= btnm->btn_cnt) return; lv_area_copy(&btn_area, &btnm->button_areas[btn_idx]); @@ -995,7 +995,7 @@ static void invalidate_button_area(const lv_obj_t * obj, uint16_t btn_idx) btn_area.x2 += obj_area.x1 + row_gap; btn_area.y2 += obj_area.y1 + col_gap; - if((btn_idx == btnm->btn_id_sel) && (btnm->ctrl_bits[btn_idx] & LV_BTNMATRIX_CTRL_POPOVER)) { + if((btn_idx == btnm->btn_id_sel) && (btnm->ctrl_bits[btn_idx] & LV_BUTTONMATRIX_CTRL_POPOVER)) { /*Push up the upper boundary of the btn area to also invalidate the popover*/ btn_area.y1 -= lv_area_get_height(&btn_area); } @@ -1012,21 +1012,21 @@ static void invalidate_button_area(const lv_obj_t * obj, uint16_t btn_idx) static void make_one_button_checked(lv_obj_t * obj, uint16_t btn_idx) { /*Save whether the button was toggled*/ - bool was_toggled = lv_btnmatrix_has_btn_ctrl(obj, btn_idx, LV_BTNMATRIX_CTRL_CHECKED); + bool was_toggled = lv_buttonmatrix_has_button_ctrl(obj, btn_idx, LV_BUTTONMATRIX_CTRL_CHECKED); - lv_btnmatrix_clear_btn_ctrl_all(obj, LV_BTNMATRIX_CTRL_CHECKED); + lv_buttonmatrix_clear_button_ctrl_all(obj, LV_BUTTONMATRIX_CTRL_CHECKED); - if(was_toggled) lv_btnmatrix_set_btn_ctrl(obj, btn_idx, LV_BTNMATRIX_CTRL_CHECKED); + if(was_toggled) lv_buttonmatrix_set_button_ctrl(obj, btn_idx, LV_BUTTONMATRIX_CTRL_CHECKED); } /** - * Check if any of the buttons in the first row has the LV_BTNMATRIX_CTRL_POPOVER control flag set. + * Check if any of the buttons in the first row has the LV_BUTTONMATRIX_CTRL_POPOVER control flag set. * @param obj Button matrix object * @return true if at least one button has the flag, false otherwise */ static bool has_popovers_in_top_row(lv_obj_t * obj) { - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj; if(btnm->row_cnt <= 0) { return false; diff --git a/src/widgets/btnmatrix/lv_btnmatrix.h b/src/widgets/buttonmatrix/lv_buttonmatrix.h index 26271d0db..3a907e5e0 100644 --- a/src/widgets/btnmatrix/lv_btnmatrix.h +++ b/src/widgets/buttonmatrix/lv_buttonmatrix.h @@ -3,8 +3,8 @@ * */ -#ifndef LV_BTNMATRIX_H -#define LV_BTNMATRIX_H +#ifndef LV_BUTTONMATRIX_H +#define LV_BUTTONMATRIX_H #ifdef __cplusplus extern "C" { @@ -22,8 +22,8 @@ extern "C" { /********************* * DEFINES *********************/ -#define LV_BTNMATRIX_BTN_NONE 0xFFFF -LV_EXPORT_CONST_INT(LV_BTNMATRIX_BTN_NONE); +#define LV_BUTTONMATRIX_BUTTON_NONE 0xFFFF +LV_EXPORT_CONST_INT(LV_BUTTONMATRIX_BUTTON_NONE); /********************** * TYPEDEFS @@ -31,45 +31,45 @@ LV_EXPORT_CONST_INT(LV_BTNMATRIX_BTN_NONE); /** Type to store button control bits (disabled, hidden etc.) * The first 3 bits are used to store the width*/ -enum _lv_btnmatrix_ctrl_t { - _LV_BTNMATRIX_WIDTH = 0x000F, /**< Reserved to store the size units*/ - LV_BTNMATRIX_CTRL_HIDDEN = 0x0010, /**< Button hidden*/ - LV_BTNMATRIX_CTRL_NO_REPEAT = 0x0020, /**< Do not repeat press this button.*/ - LV_BTNMATRIX_CTRL_DISABLED = 0x0040, /**< Disable this button.*/ - LV_BTNMATRIX_CTRL_CHECKABLE = 0x0080, /**< The button can be toggled.*/ - LV_BTNMATRIX_CTRL_CHECKED = 0x0100, /**< Button is currently toggled (e.g. checked).*/ - LV_BTNMATRIX_CTRL_CLICK_TRIG = 0x0200, /**< 1: Send LV_EVENT_VALUE_CHANGE on CLICK, 0: Send LV_EVENT_VALUE_CHANGE on PRESS*/ - LV_BTNMATRIX_CTRL_POPOVER = 0x0400, /**< Show a popover when pressing this key*/ - LV_BTNMATRIX_CTRL_RECOLOR = 0x0800, /**< Enable text recoloring with `#color`*/ - _LV_BTNMATRIX_CTRL_RESERVED_1 = 0x1000, /**< Reserved for later use*/ - _LV_BTNMATRIX_CTRL_RESERVED_2 = 0x2000, /**< Reserved for later use*/ - LV_BTNMATRIX_CTRL_CUSTOM_1 = 0x4000, /**< Custom free to use flag*/ - LV_BTNMATRIX_CTRL_CUSTOM_2 = 0x8000, /**< Custom free to use flag*/ +enum _lv_buttonmatrix_ctrl_t { + _LV_BUTTONMATRIX_WIDTH = 0x000F, /**< Reserved to store the size units*/ + LV_BUTTONMATRIX_CTRL_HIDDEN = 0x0010, /**< Button hidden*/ + LV_BUTTONMATRIX_CTRL_NO_REPEAT = 0x0020, /**< Do not repeat press this button.*/ + LV_BUTTONMATRIX_CTRL_DISABLED = 0x0040, /**< Disable this button.*/ + LV_BUTTONMATRIX_CTRL_CHECKABLE = 0x0080, /**< The button can be toggled.*/ + LV_BUTTONMATRIX_CTRL_CHECKED = 0x0100, /**< Button is currently toggled (e.g. checked).*/ + LV_BUTTONMATRIX_CTRL_CLICK_TRIG = 0x0200, /**< 1: Send LV_EVENT_VALUE_CHANGE on CLICK, 0: Send LV_EVENT_VALUE_CHANGE on PRESS*/ + LV_BUTTONMATRIX_CTRL_POPOVER = 0x0400, /**< Show a popover when pressing this key*/ + LV_BUTTONMATRIX_CTRL_RECOLOR = 0x0800, /**< Enable text recoloring with `#color`*/ + _LV_BUTTONMATRIX_CTRL_RESERVED_1 = 0x1000, /**< Reserved for later use*/ + _LV_BUTTONMATRIX_CTRL_RESERVED_2 = 0x2000, /**< Reserved for later use*/ + LV_BUTTONMATRIX_CTRL_CUSTOM_1 = 0x4000, /**< Custom free to use flag*/ + LV_BUTTONMATRIX_CTRL_CUSTOM_2 = 0x8000, /**< Custom free to use flag*/ }; #ifdef DOXYGEN -typedef _lv_btnmatrix_ctrl_t lv_btnmatrix_ctrl_t; +typedef _lv_buttonmatrix_ctrl_t lv_buttonmatrix_ctrl_t; #else -typedef uint16_t lv_btnmatrix_ctrl_t; +typedef uint16_t lv_buttonmatrix_ctrl_t; #endif /*DOXYGEN*/ -typedef bool (*lv_btnmatrix_btn_draw_cb_t)(lv_obj_t * btnm, uint32_t btn_id, const lv_area_t * draw_area, - const lv_area_t * clip_area); +typedef bool (*lv_buttonmatrix_button_draw_cb_t)(lv_obj_t * btnm, uint32_t btn_id, const lv_area_t * draw_area, + const lv_area_t * clip_area); /*Data of button matrix*/ typedef struct { lv_obj_t obj; const char ** map_p; /*Pointer to the current map*/ lv_area_t * button_areas; /*Array of areas of buttons*/ - lv_btnmatrix_ctrl_t * ctrl_bits; /*Array of control bytes*/ + lv_buttonmatrix_ctrl_t * ctrl_bits; /*Array of control bytes*/ uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/ uint16_t row_cnt; /*Number of rows in 'map_p'(Handled by the library)*/ - uint16_t btn_id_sel; /*Index of the active button (being pressed/released etc) or LV_BTNMATRIX_BTN_NONE*/ + uint16_t btn_id_sel; /*Index of the active button (being pressed/released etc) or LV_BUTTONMATRIX_BUTTON_NONE*/ uint8_t one_check : 1; /*Single button toggled at once*/ -} lv_btnmatrix_t; +} lv_buttonmatrix_t; -extern const lv_obj_class_t lv_btnmatrix_class; +extern const lv_obj_class_t lv_buttonmatrix_class; /********************** @@ -81,7 +81,7 @@ extern const lv_obj_class_t lv_btnmatrix_class; * @param parent pointer to an object, it will be the parent of the new button matrix * @return pointer to the created button matrix */ -lv_obj_t * lv_btnmatrix_create(lv_obj_t * parent); +lv_obj_t * lv_buttonmatrix_create(lv_obj_t * parent); /*===================== * Setter functions @@ -94,79 +94,79 @@ lv_obj_t * lv_btnmatrix_create(lv_obj_t * parent); * @param obj pointer to a button matrix object * @param map pointer a string array. The last string has to be: "". Use "\n" to make a line break. */ -void lv_btnmatrix_set_map(lv_obj_t * obj, const char * map[]); +void lv_buttonmatrix_set_map(lv_obj_t * obj, const char * map[]); /** * Set the button control map (hidden, disabled etc.) for a button matrix. * The control map array will be copied and so may be deallocated after this * function returns. * @param obj pointer to a button matrix object - * @param ctrl_map pointer to an array of `lv_btn_ctrl_t` control bytes. The + * @param ctrl_map pointer to an array of `lv_button_ctrl_t` control bytes. The * length of the array and position of the elements must match * the number and order of the individual buttons (i.e. excludes * newline entries). * An element of the map should look like e.g.: - * `ctrl_map[0] = width | LV_BTNMATRIX_CTRL_NO_REPEAT | LV_BTNMATRIX_CTRL_TGL_ENABLE` + * `ctrl_map[0] = width | LV_BUTTONMATRIX_CTRL_NO_REPEAT | LV_BUTTONMATRIX_CTRL_TGL_ENABLE` */ -void lv_btnmatrix_set_ctrl_map(lv_obj_t * obj, const lv_btnmatrix_ctrl_t ctrl_map[]); +void lv_buttonmatrix_set_ctrl_map(lv_obj_t * obj, const lv_buttonmatrix_ctrl_t ctrl_map[]); /** * Set the selected buttons * @param obj pointer to button matrix object * @param btn_id 0 based index of the button to modify. (Not counting new lines) */ -void lv_btnmatrix_set_selected_btn(lv_obj_t * obj, uint16_t btn_id); +void lv_buttonmatrix_set_selected_button(lv_obj_t * obj, uint16_t btn_id); /** * Set the attributes of a button of the button matrix * @param obj pointer to button matrix object * @param btn_id 0 based index of the button to modify. (Not counting new lines) - * @param ctrl OR-ed attributes. E.g. `LV_BTNMATRIX_CTRL_NO_REPEAT | LV_BTNMATRIX_CTRL_CHECKABLE` + * @param ctrl OR-ed attributes. E.g. `LV_BUTTONMATRIX_CTRL_NO_REPEAT | LV_BUTTONMATRIX_CTRL_CHECKABLE` */ -void lv_btnmatrix_set_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl); +void lv_buttonmatrix_set_button_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_buttonmatrix_ctrl_t ctrl); /** * Clear the attributes of a button of the button matrix * @param obj pointer to button matrix object * @param btn_id 0 based index of the button to modify. (Not counting new lines) - * @param ctrl OR-ed attributes. E.g. `LV_BTNMATRIX_CTRL_NO_REPEAT | LV_BTNMATRIX_CTRL_CHECKABLE` + * @param ctrl OR-ed attributes. E.g. `LV_BUTTONMATRIX_CTRL_NO_REPEAT | LV_BUTTONMATRIX_CTRL_CHECKABLE` */ -void lv_btnmatrix_clear_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl); +void lv_buttonmatrix_clear_button_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_buttonmatrix_ctrl_t ctrl); /** * Set attributes of all buttons of a button matrix * @param obj pointer to a button matrix object - * @param ctrl attribute(s) to set from `lv_btnmatrix_ctrl_t`. Values can be ORed. + * @param ctrl attribute(s) to set from `lv_buttonmatrix_ctrl_t`. Values can be ORed. */ -void lv_btnmatrix_set_btn_ctrl_all(lv_obj_t * obj, lv_btnmatrix_ctrl_t ctrl); +void lv_buttonmatrix_set_button_ctrl_all(lv_obj_t * obj, lv_buttonmatrix_ctrl_t ctrl); /** * Clear the attributes of all buttons of a button matrix * @param obj pointer to a button matrix object - * @param ctrl attribute(s) to set from `lv_btnmatrix_ctrl_t`. Values can be ORed. + * @param ctrl attribute(s) to set from `lv_buttonmatrix_ctrl_t`. Values can be ORed. * @param en true: set the attributes; false: clear the attributes */ -void lv_btnmatrix_clear_btn_ctrl_all(lv_obj_t * obj, lv_btnmatrix_ctrl_t ctrl); +void lv_buttonmatrix_clear_button_ctrl_all(lv_obj_t * obj, lv_buttonmatrix_ctrl_t ctrl); /** * Set a single button's relative width. * This method will cause the matrix be regenerated and is a relatively * expensive operation. It is recommended that initial width be specified using - * `lv_btnmatrix_set_ctrl_map` and this method only be used for dynamic changes. + * `lv_buttonmatrix_set_ctrl_map` and this method only be used for dynamic changes. * @param obj pointer to button matrix object * @param btn_id 0 based index of the button to modify. * @param width relative width compared to the buttons in the same row. [1..7] */ -void lv_btnmatrix_set_btn_width(lv_obj_t * obj, uint16_t btn_id, uint8_t width); +void lv_buttonmatrix_set_button_width(lv_obj_t * obj, uint16_t btn_id, uint8_t width); /** * Make the button matrix like a selector widget (only one button may be checked at a time). - * `LV_BTNMATRIX_CTRL_CHECKABLE` must be enabled on the buttons to be selected using - * `lv_btnmatrix_set_ctrl()` or `lv_btnmatrix_set_btn_ctrl_all()`. + * `LV_BUTTONMATRIX_CTRL_CHECKABLE` must be enabled on the buttons to be selected using + * `lv_buttonmatrix_set_ctrl()` or `lv_buttonmatrix_set_button_ctrl_all()`. * @param obj pointer to a button matrix object * @param en whether "one check" mode is enabled */ -void lv_btnmatrix_set_one_checked(lv_obj_t * obj, bool en); +void lv_buttonmatrix_set_one_checked(lv_obj_t * obj, bool en); /*===================== * Getter functions @@ -177,15 +177,15 @@ void lv_btnmatrix_set_one_checked(lv_obj_t * obj, bool en); * @param obj pointer to a button matrix object * @return the current map */ -const char ** lv_btnmatrix_get_map(const lv_obj_t * obj); +const char ** lv_buttonmatrix_get_map(const lv_obj_t * obj); /** * Get the index of the lastly "activated" button by the user (pressed, released, focused etc) * Useful in the `event_cb` to get the text of the button, check if hidden etc. * @param obj pointer to button matrix object - * @return index of the last released button (LV_BTNMATRIX_BTN_NONE: if unset) + * @return index of the last released button (LV_BUTTONMATRIX_BUTTON_NONE: if unset) */ -uint16_t lv_btnmatrix_get_selected_btn(const lv_obj_t * obj); +uint16_t lv_buttonmatrix_get_selected_button(const lv_obj_t * obj); /** * Get the button's text @@ -193,7 +193,7 @@ uint16_t lv_btnmatrix_get_selected_btn(const lv_obj_t * obj); * @param btn_id the index a button not counting new line characters. * @return text of btn_index` button */ -const char * lv_btnmatrix_get_btn_text(const lv_obj_t * obj, uint16_t btn_id); +const char * lv_buttonmatrix_get_button_text(const lv_obj_t * obj, uint16_t btn_id); /** * Get the whether a control value is enabled or disabled for button of a button matrix @@ -202,14 +202,14 @@ const char * lv_btnmatrix_get_btn_text(const lv_obj_t * obj, uint16_t btn_id); * @param ctrl control values to check (ORed value can be used) * @return true: the control attribute is enabled false: disabled */ -bool lv_btnmatrix_has_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl); +bool lv_buttonmatrix_has_button_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_buttonmatrix_ctrl_t ctrl); /** * Tell whether "one check" mode is enabled or not. * @param obj Button matrix object * @return true: "one check" mode is enabled; false: disabled */ -bool lv_btnmatrix_get_one_checked(const lv_obj_t * obj); +bool lv_buttonmatrix_get_one_checked(const lv_obj_t * obj); /********************** * MACROS @@ -221,4 +221,4 @@ bool lv_btnmatrix_get_one_checked(const lv_obj_t * obj); } /*extern "C"*/ #endif -#endif /*LV_BTNMATRIX_H*/ +#endif /*LV_BUTTONMATRIX_H*/ diff --git a/src/widgets/calendar/lv_calendar.c b/src/widgets/calendar/lv_calendar.c index 96c9439c6..f425686c5 100644 --- a/src/widgets/calendar/lv_calendar.c +++ b/src/widgets/calendar/lv_calendar.c @@ -15,8 +15,8 @@ /********************* * DEFINES *********************/ -#define LV_CALENDAR_CTRL_TODAY LV_BTNMATRIX_CTRL_CUSTOM_1 -#define LV_CALENDAR_CTRL_HIGHLIGHT LV_BTNMATRIX_CTRL_CUSTOM_2 +#define LV_CALENDAR_CTRL_TODAY LV_BUTTONMATRIX_CTRL_CUSTOM_1 +#define LV_CALENDAR_CTRL_HIGHLIGHT LV_BUTTONMATRIX_CTRL_CUSTOM_2 #define MY_CLASS &lv_calendar_class @@ -123,9 +123,9 @@ void lv_calendar_set_showed_date(lv_obj_t * obj, uint32_t year, uint32_t month) uint32_t i; /*Remove the disabled state but revert it for day names*/ - lv_btnmatrix_clear_btn_ctrl_all(calendar->btnm, LV_BTNMATRIX_CTRL_DISABLED); + lv_buttonmatrix_clear_button_ctrl_all(calendar->btnm, LV_BUTTONMATRIX_CTRL_DISABLED); for(i = 0; i < 7; i++) { - lv_btnmatrix_set_btn_ctrl(calendar->btnm, i, LV_BTNMATRIX_CTRL_DISABLED); + lv_buttonmatrix_set_button_ctrl(calendar->btnm, i, LV_BUTTONMATRIX_CTRL_DISABLED); } uint8_t act_mo_len = get_month_length(d.year, d.month); @@ -138,19 +138,19 @@ void lv_calendar_set_showed_date(lv_obj_t * obj, uint32_t year, uint32_t month) uint8_t prev_mo_len = get_month_length(d.year, d.month - 1); for(i = 0, c = prev_mo_len - day_first + 1; i < day_first; i++, c++) { lv_snprintf(calendar->nums[i], sizeof(calendar->nums[0]), "%d", c); - lv_btnmatrix_set_btn_ctrl(calendar->btnm, i + 7, LV_BTNMATRIX_CTRL_DISABLED); + lv_buttonmatrix_set_button_ctrl(calendar->btnm, i + 7, LV_BUTTONMATRIX_CTRL_DISABLED); } for(i = day_first + act_mo_len, c = 1; i < 6 * 7; i++, c++) { lv_snprintf(calendar->nums[i], sizeof(calendar->nums[0]), "%d", c); - lv_btnmatrix_set_btn_ctrl(calendar->btnm, i + 7, LV_BTNMATRIX_CTRL_DISABLED); + lv_buttonmatrix_set_button_ctrl(calendar->btnm, i + 7, LV_BUTTONMATRIX_CTRL_DISABLED); } highlight_update(obj); /*Reset the focused button if the days changes*/ - if(lv_btnmatrix_get_selected_btn(calendar->btnm) != LV_BTNMATRIX_BTN_NONE) { - lv_btnmatrix_set_selected_btn(calendar->btnm, day_first + 7); + if(lv_buttonmatrix_get_selected_button(calendar->btnm) != LV_BUTTONMATRIX_BUTTON_NONE) { + lv_buttonmatrix_set_selected_button(calendar->btnm, day_first + 7); } lv_obj_invalidate(obj); @@ -213,15 +213,15 @@ lv_res_t lv_calendar_get_pressed_date(const lv_obj_t * obj, lv_calendar_date_t * LV_ASSERT_OBJ(obj, MY_CLASS); lv_calendar_t * calendar = (lv_calendar_t *)obj; - uint16_t d = lv_btnmatrix_get_selected_btn(calendar->btnm); - if(d == LV_BTNMATRIX_BTN_NONE) { + uint16_t d = lv_buttonmatrix_get_selected_button(calendar->btnm); + if(d == LV_BUTTONMATRIX_BUTTON_NONE) { date->year = 0; date->month = 0; date->day = 0; return LV_RES_INV; } - const char * txt = lv_btnmatrix_get_btn_text(calendar->btnm, lv_btnmatrix_get_selected_btn(calendar->btnm)); + const char * txt = lv_buttonmatrix_get_button_text(calendar->btnm, lv_buttonmatrix_get_selected_button(calendar->btnm)); if(txt[1] == 0) date->day = txt[0] - '0'; else date->day = (txt[0] - '0') * 10 + (txt[1] - '0'); @@ -276,9 +276,9 @@ static void lv_calendar_constructor(const lv_obj_class_t * class_p, lv_obj_t * o } calendar->map[8 * 7 - 1] = ""; - calendar->btnm = lv_btnmatrix_create(obj); - lv_btnmatrix_set_map(calendar->btnm, calendar->map); - lv_btnmatrix_set_btn_ctrl_all(calendar->btnm, LV_BTNMATRIX_CTRL_CLICK_TRIG | LV_BTNMATRIX_CTRL_NO_REPEAT); + calendar->btnm = lv_buttonmatrix_create(obj); + lv_buttonmatrix_set_map(calendar->btnm, calendar->map); + lv_buttonmatrix_set_button_ctrl_all(calendar->btnm, LV_BUTTONMATRIX_CTRL_CLICK_TRIG | LV_BUTTONMATRIX_CTRL_NO_REPEAT); lv_obj_add_event(calendar->btnm, draw_part_begin_event_cb, LV_EVENT_DRAW_TASK_ADDED, NULL); lv_obj_set_width(calendar->btnm, lv_pct(100)); @@ -308,20 +308,20 @@ static void draw_part_begin_event_cb(lv_event_t * e) rect_draw_dsc->bg_opa = LV_OPA_TRANSP; rect_draw_dsc->border_opa = LV_OPA_TRANSP; } - else if(lv_btnmatrix_has_btn_ctrl(obj, rect_draw_dsc->base.id1, LV_BTNMATRIX_CTRL_DISABLED)) { + else if(lv_buttonmatrix_has_button_ctrl(obj, rect_draw_dsc->base.id1, LV_BUTTONMATRIX_CTRL_DISABLED)) { rect_draw_dsc->bg_opa = LV_OPA_TRANSP; rect_draw_dsc->border_opa = LV_OPA_TRANSP; } - if(lv_btnmatrix_has_btn_ctrl(obj, rect_draw_dsc->base.id1, LV_CALENDAR_CTRL_HIGHLIGHT)) { + if(lv_buttonmatrix_has_button_ctrl(obj, rect_draw_dsc->base.id1, LV_CALENDAR_CTRL_HIGHLIGHT)) { rect_draw_dsc->bg_opa = LV_OPA_40; rect_draw_dsc->bg_color = lv_theme_get_color_primary(obj); - if(lv_btnmatrix_get_selected_btn(obj) == rect_draw_dsc->base.id1) { + if(lv_buttonmatrix_get_selected_button(obj) == rect_draw_dsc->base.id1) { rect_draw_dsc->bg_opa = LV_OPA_70; } } - if(lv_btnmatrix_has_btn_ctrl(obj, rect_draw_dsc->base.id1, LV_CALENDAR_CTRL_TODAY)) { + if(lv_buttonmatrix_has_button_ctrl(obj, rect_draw_dsc->base.id1, LV_CALENDAR_CTRL_TODAY)) { rect_draw_dsc->border_opa = LV_OPA_COVER; rect_draw_dsc->border_color = lv_theme_get_color_primary(obj); rect_draw_dsc->border_width += 1; @@ -389,21 +389,21 @@ static void highlight_update(lv_obj_t * obj) uint16_t i; /*Clear all kind of selection*/ - lv_btnmatrix_clear_btn_ctrl_all(calendar->btnm, LV_CALENDAR_CTRL_TODAY | LV_CALENDAR_CTRL_HIGHLIGHT); + lv_buttonmatrix_clear_button_ctrl_all(calendar->btnm, LV_CALENDAR_CTRL_TODAY | LV_CALENDAR_CTRL_HIGHLIGHT); uint8_t day_first = get_day_of_week(calendar->showed_date.year, calendar->showed_date.month, 1); if(calendar->highlighted_dates) { for(i = 0; i < calendar->highlighted_dates_num; i++) { if(calendar->highlighted_dates[i].year == calendar->showed_date.year && calendar->highlighted_dates[i].month == calendar->showed_date.month) { - lv_btnmatrix_set_btn_ctrl(calendar->btnm, calendar->highlighted_dates[i].day - 1 + day_first + 7, - LV_CALENDAR_CTRL_HIGHLIGHT); + lv_buttonmatrix_set_button_ctrl(calendar->btnm, calendar->highlighted_dates[i].day - 1 + day_first + 7, + LV_CALENDAR_CTRL_HIGHLIGHT); } } } if(calendar->showed_date.year == calendar->today.year && calendar->showed_date.month == calendar->today.month) { - lv_btnmatrix_set_btn_ctrl(calendar->btnm, calendar->today.day - 1 + day_first + 7, LV_CALENDAR_CTRL_TODAY); + lv_buttonmatrix_set_button_ctrl(calendar->btnm, calendar->today.day - 1 + day_first + 7, LV_CALENDAR_CTRL_TODAY); } } diff --git a/src/widgets/calendar/lv_calendar.h b/src/widgets/calendar/lv_calendar.h index 961106819..c3e170404 100644 --- a/src/widgets/calendar/lv_calendar.h +++ b/src/widgets/calendar/lv_calendar.h @@ -13,7 +13,7 @@ extern "C" { /********************* * INCLUDES *********************/ -#include "../btnmatrix/lv_btnmatrix.h" +#include "../buttonmatrix/lv_buttonmatrix.h" #if LV_USE_CALENDAR diff --git a/src/widgets/calendar/lv_calendar_header_arrow.c b/src/widgets/calendar/lv_calendar_header_arrow.c index ceeeebbcc..d66d3a032 100644 --- a/src/widgets/calendar/lv_calendar_header_arrow.c +++ b/src/widgets/calendar/lv_calendar_header_arrow.c @@ -10,7 +10,7 @@ #if LV_USE_CALENDAR && LV_USE_CALENDAR_HEADER_ARROW #include "lv_calendar.h" -#include "../btn/lv_btn.h" +#include "../button/lv_button.h" #include "../label/lv_label.h" #include "../../layouts/flex/lv_flex.h" @@ -71,8 +71,8 @@ static void my_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_ROW); lv_obj_set_flex_align(obj, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START); - lv_obj_t * mo_prev = lv_btn_create(obj); - lv_obj_set_style_bg_img_src(mo_prev, LV_SYMBOL_LEFT, 0); + lv_obj_t * mo_prev = lv_button_create(obj); + lv_obj_set_style_bg_image_src(mo_prev, LV_SYMBOL_LEFT, 0); lv_obj_set_height(mo_prev, lv_pct(100)); lv_obj_update_layout(mo_prev); lv_coord_t btn_size = lv_obj_get_height(mo_prev); @@ -86,8 +86,8 @@ static void my_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0); lv_obj_set_flex_grow(label, 1); - lv_obj_t * mo_next = lv_btn_create(obj); - lv_obj_set_style_bg_img_src(mo_next, LV_SYMBOL_RIGHT, 0); + lv_obj_t * mo_next = lv_button_create(obj); + lv_obj_set_style_bg_image_src(mo_next, LV_SYMBOL_RIGHT, 0); lv_obj_set_size(mo_next, btn_size, btn_size); lv_obj_add_event(mo_next, month_event_cb, LV_EVENT_CLICKED, NULL); diff --git a/src/widgets/canvas/lv_canvas.c b/src/widgets/canvas/lv_canvas.c index bcce03ecb..666bd5a20 100644 --- a/src/widgets/canvas/lv_canvas.c +++ b/src/widgets/canvas/lv_canvas.c @@ -38,7 +38,7 @@ const lv_obj_class_t lv_canvas_class = { .constructor_cb = lv_canvas_constructor, .destructor_cb = lv_canvas_destructor, .instance_size = sizeof(lv_canvas_t), - .base_class = &lv_img_class + .base_class = &lv_image_class }; /********************** @@ -75,8 +75,8 @@ void lv_canvas_set_buffer(lv_obj_t * obj, void * buf, lv_coord_t w, lv_coord_t h canvas->dsc.data = buf; canvas->dsc.data_size = w * h * lv_color_format_get_size(cf); - lv_img_set_src(obj, &canvas->dsc); - lv_img_cache_invalidate_src(&canvas->dsc); + lv_image_set_src(obj, &canvas->dsc); + lv_image_cache_invalidate_src(&canvas->dsc); } void lv_canvas_set_px(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa) @@ -140,7 +140,7 @@ void lv_canvas_set_palette(lv_obj_t * obj, uint8_t id, lv_color32_t c) lv_canvas_t * canvas = (lv_canvas_t *)obj; - lv_img_buf_set_palette(&canvas->dsc, id, c); + lv_image_buf_set_palette(&canvas->dsc, id, c); lv_obj_invalidate(obj); } @@ -180,7 +180,7 @@ lv_color32_t lv_canvas_get_px(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) break; } case LV_COLOR_FORMAT_A8: { - lv_color_t alpha_color = lv_obj_get_style_img_recolor(obj, LV_PART_MAIN); + lv_color_t alpha_color = lv_obj_get_style_image_recolor(obj, LV_PART_MAIN); ret.red = alpha_color.red; ret.green = alpha_color.green; ret.blue = alpha_color.blue; @@ -195,7 +195,7 @@ lv_color32_t lv_canvas_get_px(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) return ret; } -lv_img_dsc_t * lv_canvas_get_img(lv_obj_t * obj) +lv_image_dsc_t * lv_canvas_get_image(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); @@ -234,7 +234,7 @@ void lv_canvas_fill_bg(lv_obj_t * obj, lv_color_t color, lv_opa_t opa) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_img_dsc_t * dsc = lv_canvas_get_img(obj); + lv_image_dsc_t * dsc = lv_canvas_get_image(obj); uint32_t x; uint32_t y; @@ -289,7 +289,7 @@ void lv_canvas_init_layer(lv_obj_t * canvas, lv_layer_t * layer) LV_ASSERT_NULL(canvas); LV_ASSERT_NULL(layer); - lv_img_dsc_t * dsc = lv_canvas_get_img(canvas); + lv_image_dsc_t * dsc = lv_canvas_get_image(canvas); lv_area_t canvas_area = {0, 0, dsc->header.w - 1, dsc->header.h - 1}; lv_memzero(layer, sizeof(*layer)); @@ -325,7 +325,7 @@ static void lv_canvas_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj canvas->dsc.data_size = 0; canvas->dsc.data = NULL; - lv_img_set_src(obj, &canvas->dsc); + lv_image_set_src(obj, &canvas->dsc); LV_TRACE_OBJ_CREATE("finished"); } @@ -336,7 +336,7 @@ static void lv_canvas_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj) LV_TRACE_OBJ_CREATE("begin"); lv_canvas_t * canvas = (lv_canvas_t *)obj; - lv_img_cache_invalidate_src(&canvas->dsc); + lv_image_cache_invalidate_src(&canvas->dsc); } diff --git a/src/widgets/canvas/lv_canvas.h b/src/widgets/canvas/lv_canvas.h index f1d247a71..250ed5eac 100644 --- a/src/widgets/canvas/lv_canvas.h +++ b/src/widgets/canvas/lv_canvas.h @@ -17,8 +17,8 @@ extern "C" { #if LV_USE_CANVAS != 0 -#include "../img/lv_img.h" -#include "../../draw/lv_draw_img.h" +#include "../image/lv_image.h" +#include "../../draw/lv_draw_image.h" /********************* * DEFINES @@ -31,8 +31,8 @@ extern const lv_obj_class_t lv_canvas_class; /*Data of canvas*/ typedef struct { - lv_img_t img; - lv_img_dsc_t dsc; + lv_image_t img; + lv_image_dsc_t dsc; } lv_canvas_t; /********************** @@ -53,27 +53,27 @@ lv_obj_t * lv_canvas_create(lv_obj_t * parent); /** * Set a buffer for the canvas. * @param buf a buffer where the content of the canvas will be. - * The required size is (lv_img_color_format_get_px_size(cf) * w) / 8 * h) + * The required size is (lv_image_color_format_get_px_size(cf) * w) / 8 * h) * It can be allocated with `lv_malloc()` or * it can be statically allocated array (e.g. static lv_color_t buf[100*50]) or * it can be an address in RAM or external SRAM * @param canvas pointer to a canvas object * @param w width of the canvas * @param h height of the canvas - * @param cf color format. `LV_IMG_CF_...` + * @param cf color format. `LV_IMAGE_CF_...` */ void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_t h, lv_color_format_t cf); void lv_canvas_set_px(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa); /** - * Set the palette color of a canvas with index format. Valid only for `LV_IMG_CF_INDEXED1/2/4/8` + * Set the palette color of a canvas with index format. Valid only for `LV_IMAGE_CF_INDEXED1/2/4/8` * @param canvas pointer to canvas object * @param id the palette color to set: - * - for `LV_IMG_CF_INDEXED1`: 0..1 - * - for `LV_IMG_CF_INDEXED2`: 0..3 - * - for `LV_IMG_CF_INDEXED4`: 0..15 - * - for `LV_IMG_CF_INDEXED8`: 0..255 + * - for `LV_IMAGE_CF_INDEXED1`: 0..1 + * - for `LV_IMAGE_CF_INDEXED2`: 0..3 + * - for `LV_IMAGE_CF_INDEXED4`: 0..15 + * - for `LV_IMAGE_CF_INDEXED8`: 0..255 * @param c the color to set */ void lv_canvas_set_palette(lv_obj_t * canvas, uint8_t id, lv_color32_t c); @@ -86,11 +86,11 @@ void lv_canvas_set_palette(lv_obj_t * canvas, uint8_t id, lv_color32_t c); lv_color32_t lv_canvas_get_px(lv_obj_t * obj, lv_coord_t x, lv_coord_t y); /** - * Get the image of the canvas as a pointer to an `lv_img_dsc_t` variable. + * Get the image of the canvas as a pointer to an `lv_image_dsc_t` variable. * @param canvas pointer to a canvas object * @return pointer to the image descriptor. */ -lv_img_dsc_t * lv_canvas_get_img(lv_obj_t * canvas); +lv_image_dsc_t * lv_canvas_get_image(lv_obj_t * canvas); /*===================== * Other functions @@ -123,21 +123,21 @@ void lv_canvas_finish_layer(lv_obj_t * canvas, lv_layer_t * layer); /********************** * MACROS **********************/ -#define LV_CANVAS_BUF_SIZE_TRUE_COLOR(w, h) LV_IMG_BUF_SIZE_TRUE_COLOR(w, h) -#define LV_CANVAS_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h) LV_IMG_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h) -#define LV_CANVAS_BUF_SIZE_TRUE_COLOR_ALPHA(w, h) LV_IMG_BUF_SIZE_TRUE_COLOR_ALPHA(w, h) +#define LV_CANVAS_BUF_SIZE_TRUE_COLOR(w, h) LV_IMAGE_BUF_SIZE_TRUE_COLOR(w, h) +#define LV_CANVAS_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h) LV_IMAGE_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h) +#define LV_CANVAS_BUF_SIZE_TRUE_COLOR_ALPHA(w, h) LV_IMAGE_BUF_SIZE_TRUE_COLOR_ALPHA(w, h) /*+ 1: to be sure no fractional row*/ -#define LV_CANVAS_BUF_SIZE_ALPHA_1BIT(w, h) LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h) -#define LV_CANVAS_BUF_SIZE_ALPHA_2BIT(w, h) LV_IMG_BUF_SIZE_ALPHA_2BIT(w, h) -#define LV_CANVAS_BUF_SIZE_ALPHA_4BIT(w, h) LV_IMG_BUF_SIZE_ALPHA_4BIT(w, h) -#define LV_CANVAS_BUF_SIZE_ALPHA_8BIT(w, h) LV_IMG_BUF_SIZE_ALPHA_8BIT(w, h) +#define LV_CANVAS_BUF_SIZE_ALPHA_1BIT(w, h) LV_IMAGE_BUF_SIZE_ALPHA_1BIT(w, h) +#define LV_CANVAS_BUF_SIZE_ALPHA_2BIT(w, h) LV_IMAGE_BUF_SIZE_ALPHA_2BIT(w, h) +#define LV_CANVAS_BUF_SIZE_ALPHA_4BIT(w, h) LV_IMAGE_BUF_SIZE_ALPHA_4BIT(w, h) +#define LV_CANVAS_BUF_SIZE_ALPHA_8BIT(w, h) LV_IMAGE_BUF_SIZE_ALPHA_8BIT(w, h) /*4 * X: for palette*/ -#define LV_CANVAS_BUF_SIZE_INDEXED_1BIT(w, h) LV_IMG_BUF_SIZE_INDEXED_1BIT(w, h) -#define LV_CANVAS_BUF_SIZE_INDEXED_2BIT(w, h) LV_IMG_BUF_SIZE_INDEXED_2BIT(w, h) -#define LV_CANVAS_BUF_SIZE_INDEXED_4BIT(w, h) LV_IMG_BUF_SIZE_INDEXED_4BIT(w, h) -#define LV_CANVAS_BUF_SIZE_INDEXED_8BIT(w, h) LV_IMG_BUF_SIZE_INDEXED_8BIT(w, h) +#define LV_CANVAS_BUF_SIZE_INDEXED_1BIT(w, h) LV_IMAGE_BUF_SIZE_INDEXED_1BIT(w, h) +#define LV_CANVAS_BUF_SIZE_INDEXED_2BIT(w, h) LV_IMAGE_BUF_SIZE_INDEXED_2BIT(w, h) +#define LV_CANVAS_BUF_SIZE_INDEXED_4BIT(w, h) LV_IMAGE_BUF_SIZE_INDEXED_4BIT(w, h) +#define LV_CANVAS_BUF_SIZE_INDEXED_8BIT(w, h) LV_IMAGE_BUF_SIZE_INDEXED_8BIT(w, h) #endif /*LV_USE_CANVAS*/ diff --git a/src/widgets/dropdown/lv_dropdown.c b/src/widgets/dropdown/lv_dropdown.c index 5cff946fd..a3c889238 100644 --- a/src/widgets/dropdown/lv_dropdown.c +++ b/src/widgets/dropdown/lv_dropdown.c @@ -804,10 +804,10 @@ static void draw_main(lv_event_t * e) if(lv_obj_get_style_base_dir(obj, LV_PART_MAIN) == LV_BASE_DIR_RTL) symbol_to_left = true; if(dropdown->symbol) { - lv_img_src_t symbol_type = lv_img_src_get_type(dropdown->symbol); + lv_image_src_t symbol_type = lv_image_src_get_type(dropdown->symbol); lv_coord_t symbol_w; lv_coord_t symbol_h; - if(symbol_type == LV_IMG_SRC_SYMBOL) { + if(symbol_type == LV_IMAGE_SRC_SYMBOL) { lv_point_t size; lv_txt_get_size(&size, dropdown->symbol, symbol_dsc.font, symbol_dsc.letter_space, symbol_dsc.line_space, LV_COORD_MAX, symbol_dsc.flag); @@ -815,8 +815,8 @@ static void draw_main(lv_event_t * e) symbol_h = size.y; } else { - lv_img_header_t header; - lv_res_t res = lv_img_decoder_get_info(dropdown->symbol, &header); + lv_image_header_t header; + lv_res_t res = lv_image_decoder_get_info(dropdown->symbol, &header); if(res == LV_RES_OK) { symbol_w = header.w; symbol_h = header.h; @@ -837,7 +837,7 @@ static void draw_main(lv_event_t * e) symbol_area.x2 = symbol_area.x1 + symbol_w - 1; } - if(symbol_type == LV_IMG_SRC_SYMBOL) { + if(symbol_type == LV_IMAGE_SRC_SYMBOL) { symbol_area.y1 = obj->coords.y1 + top; symbol_area.y2 = symbol_area.y1 + symbol_h - 1; symbol_dsc.text = dropdown->symbol; @@ -846,14 +846,14 @@ static void draw_main(lv_event_t * e) else { symbol_area.y1 = obj->coords.y1 + (lv_obj_get_height(obj) - symbol_h) / 2; symbol_area.y2 = symbol_area.y1 + symbol_h - 1; - lv_draw_img_dsc_t img_dsc; - lv_draw_img_dsc_init(&img_dsc); - lv_obj_init_draw_img_dsc(obj, LV_PART_INDICATOR, &img_dsc); + lv_draw_image_dsc_t img_dsc; + lv_draw_image_dsc_init(&img_dsc); + lv_obj_init_draw_image_dsc(obj, LV_PART_INDICATOR, &img_dsc); img_dsc.pivot.x = symbol_w / 2; img_dsc.pivot.y = symbol_h / 2; img_dsc.angle = lv_obj_get_style_transform_angle(obj, LV_PART_INDICATOR); img_dsc.src = dropdown->symbol; - lv_draw_img(layer, &img_dsc, &symbol_area); + lv_draw_image(layer, &img_dsc, &symbol_area); } } diff --git a/src/widgets/img/lv_img.c b/src/widgets/image/lv_image.c index fbced5c6b..52ccf999b 100644 --- a/src/widgets/img/lv_img.c +++ b/src/widgets/image/lv_image.c @@ -6,7 +6,7 @@ /********************* * INCLUDES *********************/ -#include "lv_img.h" +#include "lv_image.h" #if LV_USE_IMG != 0 #include "../../stdlib/lv_string.h" @@ -14,7 +14,7 @@ /********************* * DEFINES *********************/ -#define MY_CLASS &lv_img_class +#define MY_CLASS &lv_image_class /********************** * TYPEDEFS @@ -23,21 +23,21 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_img_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj); -static void lv_img_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj); -static void lv_img_event(const lv_obj_class_t * class_p, lv_event_t * e); -static void draw_img(lv_event_t * e); +static void lv_image_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj); +static void lv_image_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj); +static void lv_image_event(const lv_obj_class_t * class_p, lv_event_t * e); +static void draw_image(lv_event_t * e); /********************** * STATIC VARIABLES **********************/ -const lv_obj_class_t lv_img_class = { - .constructor_cb = lv_img_constructor, - .destructor_cb = lv_img_destructor, - .event_cb = lv_img_event, +const lv_obj_class_t lv_image_class = { + .constructor_cb = lv_image_constructor, + .destructor_cb = lv_image_destructor, + .event_cb = lv_image_event, .width_def = LV_SIZE_CONTENT, .height_def = LV_SIZE_CONTENT, - .instance_size = sizeof(lv_img_t), + .instance_size = sizeof(lv_image_t), .base_class = &lv_obj_class }; @@ -49,7 +49,7 @@ const lv_obj_class_t lv_img_class = { * GLOBAL FUNCTIONS **********************/ -lv_obj_t * lv_img_create(lv_obj_t * parent) +lv_obj_t * lv_image_create(lv_obj_t * parent) { LV_LOG_INFO("begin"); lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent); @@ -61,25 +61,25 @@ lv_obj_t * lv_img_create(lv_obj_t * parent) * Setter functions *====================*/ -void lv_img_set_src(lv_obj_t * obj, const void * src) +void lv_image_set_src(lv_obj_t * obj, const void * src) { LV_ASSERT_OBJ(obj, MY_CLASS); lv_obj_invalidate(obj); - lv_img_src_t src_type = lv_img_src_get_type(src); - lv_img_t * img = (lv_img_t *)obj; + lv_image_src_t src_type = lv_image_src_get_type(src); + lv_image_t * img = (lv_image_t *)obj; #if LV_USE_LOG && LV_LOG_LEVEL >= LV_LOG_LEVEL_INFO switch(src_type) { - case LV_IMG_SRC_FILE: - LV_LOG_TRACE("`LV_IMG_SRC_FILE` type found"); + case LV_IMAGE_SRC_FILE: + LV_LOG_TRACE("`LV_IMAGE_SRC_FILE` type found"); break; - case LV_IMG_SRC_VARIABLE: - LV_LOG_TRACE("`LV_IMG_SRC_VARIABLE` type found"); + case LV_IMAGE_SRC_VARIABLE: + LV_LOG_TRACE("`LV_IMAGE_SRC_VARIABLE` type found"); break; - case LV_IMG_SRC_SYMBOL: - LV_LOG_TRACE("`LV_IMG_SRC_SYMBOL` type found"); + case LV_IMAGE_SRC_SYMBOL: + LV_LOG_TRACE("`LV_IMAGE_SRC_SYMBOL` type found"); break; default: LV_LOG_WARN("unknown type"); @@ -87,35 +87,35 @@ void lv_img_set_src(lv_obj_t * obj, const void * src) #endif /*If the new source type is unknown free the memories of the old source*/ - if(src_type == LV_IMG_SRC_UNKNOWN) { + if(src_type == LV_IMAGE_SRC_UNKNOWN) { LV_LOG_WARN("unknown image type"); - if(img->src_type == LV_IMG_SRC_SYMBOL || img->src_type == LV_IMG_SRC_FILE) { + if(img->src_type == LV_IMAGE_SRC_SYMBOL || img->src_type == LV_IMAGE_SRC_FILE) { lv_free((void *)img->src); } img->src = NULL; - img->src_type = LV_IMG_SRC_UNKNOWN; + img->src_type = LV_IMAGE_SRC_UNKNOWN; return; } - lv_img_header_t header; - lv_img_decoder_get_info(src, &header); + lv_image_header_t header; + lv_image_decoder_get_info(src, &header); /*Save the source*/ - if(src_type == LV_IMG_SRC_VARIABLE) { + if(src_type == LV_IMAGE_SRC_VARIABLE) { /*If memory was allocated because of the previous `src_type` then free it*/ - if(img->src_type == LV_IMG_SRC_FILE || img->src_type == LV_IMG_SRC_SYMBOL) { + if(img->src_type == LV_IMAGE_SRC_FILE || img->src_type == LV_IMAGE_SRC_SYMBOL) { lv_free((void *)img->src); } img->src = src; } - else if(src_type == LV_IMG_SRC_FILE || src_type == LV_IMG_SRC_SYMBOL) { + else if(src_type == LV_IMAGE_SRC_FILE || src_type == LV_IMAGE_SRC_SYMBOL) { /*If the new and the old src are the same then it was only a refresh.*/ if(img->src != src) { const void * old_src = NULL; /*If memory was allocated because of the previous `src_type` then save its pointer and free after allocation. *It's important to allocate first to be sure the new data will be on a new address. *Else `img_cache` wouldn't see the change in source.*/ - if(img->src_type == LV_IMG_SRC_FILE || img->src_type == LV_IMG_SRC_SYMBOL) { + if(img->src_type == LV_IMAGE_SRC_FILE || img->src_type == LV_IMAGE_SRC_SYMBOL) { old_src = img->src; } char * new_str = lv_strdup(src); @@ -127,8 +127,8 @@ void lv_img_set_src(lv_obj_t * obj, const void * src) } } - if(src_type == LV_IMG_SRC_SYMBOL) { - /*`lv_img_dsc_get_info` couldn't set the width and height of a font so set it here*/ + if(src_type == LV_IMAGE_SRC_SYMBOL) { + /*`lv_image_dsc_get_info` couldn't set the width and height of a font so set it here*/ const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN); lv_coord_t letter_space = lv_obj_get_style_text_letter_space(obj, LV_PART_MAIN); lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN); @@ -151,35 +151,35 @@ void lv_img_set_src(lv_obj_t * obj, const void * src) lv_obj_invalidate(obj); } -void lv_img_set_offset_x(lv_obj_t * obj, lv_coord_t x) +void lv_image_set_offset_x(lv_obj_t * obj, lv_coord_t x) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; img->offset.x = x; lv_obj_invalidate(obj); } -void lv_img_set_offset_y(lv_obj_t * obj, lv_coord_t y) +void lv_image_set_offset_y(lv_obj_t * obj, lv_coord_t y) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; img->offset.y = y; lv_obj_invalidate(obj); } -void lv_img_set_angle(lv_obj_t * obj, int16_t angle) +void lv_image_set_angle(lv_obj_t * obj, int16_t angle) { while(angle >= 3600) angle -= 3600; while(angle < 0) angle += 3600; - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; if(angle == img->angle) return; - if(img->obj_size_mode == LV_IMG_SIZE_MODE_REAL) { + if(img->obj_size_mode == LV_IMAGE_SIZE_MODE_REAL) { img->angle = angle; lv_obj_invalidate_area(obj, &obj->coords); return; @@ -190,8 +190,8 @@ void lv_img_set_angle(lv_obj_t * obj, int16_t angle) lv_coord_t h = lv_obj_get_height(obj); lv_area_t a; lv_point_t pivot_px; - lv_img_get_pivot(obj, &pivot_px); - _lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &pivot_px); + lv_image_get_pivot(obj, &pivot_px); + _lv_image_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &pivot_px); a.x1 += obj->coords.x1; a.y1 += obj->coords.y1; a.x2 += obj->coords.x1; @@ -207,7 +207,7 @@ void lv_img_set_angle(lv_obj_t * obj, int16_t angle) lv_obj_refresh_ext_draw_size(obj); lv_disp_enable_invalidation(disp, true); - _lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &pivot_px); + _lv_image_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &pivot_px); a.x1 += obj->coords.x1; a.y1 += obj->coords.y1; a.x2 += obj->coords.x1; @@ -215,12 +215,12 @@ void lv_img_set_angle(lv_obj_t * obj, int16_t angle) lv_obj_invalidate_area(obj, &a); } -void lv_img_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) +void lv_image_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) { - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; if(img->pivot.x == x && img->pivot.y == y) return; - if(img->obj_size_mode == LV_IMG_SIZE_MODE_REAL) { + if(img->obj_size_mode == LV_IMAGE_SIZE_MODE_REAL) { img->pivot.x = x; img->pivot.y = y; lv_obj_invalidate_area(obj, &obj->coords); @@ -232,8 +232,8 @@ void lv_img_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) lv_coord_t h = lv_obj_get_height(obj); lv_area_t a; lv_point_t pivot_px; - lv_img_get_pivot(obj, &pivot_px); - _lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &pivot_px); + lv_image_get_pivot(obj, &pivot_px); + _lv_image_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &pivot_px); a.x1 += obj->coords.x1; a.y1 += obj->coords.y1; a.x2 += obj->coords.x1; @@ -250,8 +250,8 @@ void lv_img_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) lv_obj_refresh_ext_draw_size(obj); lv_disp_enable_invalidation(disp, true); - lv_img_get_pivot(obj, &pivot_px); - _lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &pivot_px); + lv_image_get_pivot(obj, &pivot_px); + _lv_image_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &pivot_px); a.x1 += obj->coords.x1; a.y1 += obj->coords.y1; a.x2 += obj->coords.x1; @@ -259,14 +259,14 @@ void lv_img_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) lv_obj_invalidate_area(obj, &a); } -void lv_img_set_zoom(lv_obj_t * obj, uint16_t zoom) +void lv_image_set_zoom(lv_obj_t * obj, uint16_t zoom) { - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; if(zoom == img->zoom) return; if(zoom == 0) zoom = 1; - if(img->obj_size_mode == LV_IMG_SIZE_MODE_REAL) { + if(img->obj_size_mode == LV_IMAGE_SIZE_MODE_REAL) { img->zoom = zoom; lv_obj_invalidate_area(obj, &obj->coords); return; @@ -277,8 +277,8 @@ void lv_img_set_zoom(lv_obj_t * obj, uint16_t zoom) lv_coord_t h = lv_obj_get_height(obj); lv_area_t a; lv_point_t pivot_px; - lv_img_get_pivot(obj, &pivot_px); - _lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &pivot_px); + lv_image_get_pivot(obj, &pivot_px); + _lv_image_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &pivot_px); a.x1 += obj->coords.x1 - 1; a.y1 += obj->coords.y1 - 1; a.x2 += obj->coords.x1 + 1; @@ -294,7 +294,7 @@ void lv_img_set_zoom(lv_obj_t * obj, uint16_t zoom) lv_obj_refresh_ext_draw_size(obj); lv_disp_enable_invalidation(disp, true); - _lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &pivot_px); + _lv_image_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &pivot_px); a.x1 += obj->coords.x1 - 1; a.y1 += obj->coords.y1 - 1; a.x2 += obj->coords.x1 + 1; @@ -302,19 +302,19 @@ void lv_img_set_zoom(lv_obj_t * obj, uint16_t zoom) lv_obj_invalidate_area(obj, &a); } -void lv_img_set_antialias(lv_obj_t * obj, bool antialias) +void lv_image_set_antialias(lv_obj_t * obj, bool antialias) { - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; if(antialias == img->antialias) return; img->antialias = antialias; lv_obj_invalidate(obj); } -void lv_img_set_size_mode(lv_obj_t * obj, lv_img_size_mode_t mode) +void lv_image_set_size_mode(lv_obj_t * obj, lv_image_size_mode_t mode) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; if(mode == img->obj_size_mode) return; img->obj_size_mode = mode; @@ -325,74 +325,74 @@ void lv_img_set_size_mode(lv_obj_t * obj, lv_img_size_mode_t mode) * Getter functions *====================*/ -const void * lv_img_get_src(lv_obj_t * obj) +const void * lv_image_get_src(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; return img->src; } -lv_coord_t lv_img_get_offset_x(lv_obj_t * obj) +lv_coord_t lv_image_get_offset_x(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; return img->offset.x; } -lv_coord_t lv_img_get_offset_y(lv_obj_t * obj) +lv_coord_t lv_image_get_offset_y(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; return img->offset.y; } -lv_coord_t lv_img_get_angle(lv_obj_t * obj) +lv_coord_t lv_image_get_angle(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; return img->angle; } -void lv_img_get_pivot(lv_obj_t * obj, lv_point_t * pivot) +void lv_image_get_pivot(lv_obj_t * obj, lv_point_t * pivot) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; pivot->x = lv_pct_to_px(img->pivot.x, img->w); pivot->y = lv_pct_to_px(img->pivot.y, img->h); } -lv_coord_t lv_img_get_zoom(lv_obj_t * obj) +lv_coord_t lv_image_get_zoom(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; return img->zoom; } -bool lv_img_get_antialias(lv_obj_t * obj) +bool lv_image_get_antialias(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; return img->antialias ? true : false; } -lv_img_size_mode_t lv_img_get_size_mode(lv_obj_t * obj) +lv_image_size_mode_t lv_image_get_size_mode(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; return img->obj_size_mode; } @@ -400,15 +400,15 @@ lv_img_size_mode_t lv_img_get_size_mode(lv_obj_t * obj) * STATIC FUNCTIONS **********************/ -static void lv_img_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) +static void lv_image_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) { LV_UNUSED(class_p); LV_TRACE_OBJ_CREATE("begin"); - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; img->src = NULL; - img->src_type = LV_IMG_SRC_UNKNOWN; + img->src_type = LV_IMAGE_SRC_UNKNOWN; img->cf = LV_COLOR_FORMAT_UNKNOWN; img->w = lv_obj_get_width(obj); img->h = lv_obj_get_height(obj); @@ -419,7 +419,7 @@ static void lv_img_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) img->offset.y = 0; img->pivot.x = LV_PCT(50); /*Default pivot to image center*/ img->pivot.y = LV_PCT(50); - img->obj_size_mode = LV_IMG_SIZE_MODE_VIRTUAL; + img->obj_size_mode = LV_IMAGE_SIZE_MODE_VIRTUAL; lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICKABLE); lv_obj_add_flag(obj, LV_OBJ_FLAG_ADV_HITTEST); @@ -427,35 +427,35 @@ static void lv_img_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) LV_TRACE_OBJ_CREATE("finished"); } -static void lv_img_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj) +static void lv_image_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj) { LV_UNUSED(class_p); - lv_img_t * img = (lv_img_t *)obj; - if(img->src_type == LV_IMG_SRC_FILE || img->src_type == LV_IMG_SRC_SYMBOL) { + lv_image_t * img = (lv_image_t *)obj; + if(img->src_type == LV_IMAGE_SRC_FILE || img->src_type == LV_IMAGE_SRC_SYMBOL) { lv_free((void *)img->src); img->src = NULL; - img->src_type = LV_IMG_SRC_UNKNOWN; + img->src_type = LV_IMAGE_SRC_UNKNOWN; } } -static lv_point_t lv_img_get_transformed_size(lv_obj_t * obj) +static lv_point_t lv_image_get_transformed_size(lv_obj_t * obj) { - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; lv_area_t area_transform; lv_point_t pivot_px; - lv_img_get_pivot(obj, &pivot_px); - _lv_img_buf_get_transformed_area(&area_transform, img->w, img->h, - img->angle, img->zoom, &pivot_px); + lv_image_get_pivot(obj, &pivot_px); + _lv_image_buf_get_transformed_area(&area_transform, img->w, img->h, + img->angle, img->zoom, &pivot_px); return (lv_point_t) { lv_area_get_width(&area_transform), lv_area_get_height(&area_transform) }; } -static void lv_img_event(const lv_obj_class_t * class_p, lv_event_t * e) +static void lv_image_event(const lv_obj_class_t * class_p, lv_event_t * e) { LV_UNUSED(class_p); @@ -469,14 +469,14 @@ static void lv_img_event(const lv_obj_class_t * class_p, lv_event_t * e) } lv_obj_t * obj = lv_event_get_target(e); - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; lv_point_t pivot_px; - lv_img_get_pivot(obj, &pivot_px); + lv_image_get_pivot(obj, &pivot_px); if(code == LV_EVENT_STYLE_CHANGED) { /*Refresh the file name to refresh the symbol text size*/ - if(img->src_type == LV_IMG_SRC_SYMBOL) { - lv_img_set_src(obj, img->src); + if(img->src_type == LV_IMAGE_SRC_SYMBOL) { + lv_image_set_src(obj, img->src); } else { /*With transformation it might change*/ @@ -492,7 +492,7 @@ static void lv_img_event(const lv_obj_class_t * class_p, lv_event_t * e) lv_area_t a; lv_coord_t w = lv_obj_get_width(obj); lv_coord_t h = lv_obj_get_height(obj); - _lv_img_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &pivot_px); + _lv_image_buf_get_transformed_area(&a, w, h, img->angle, img->zoom, &pivot_px); *s = LV_MAX(*s, -a.x1); *s = LV_MAX(*s, -a.y1); *s = LV_MAX(*s, a.x2 - w); @@ -510,7 +510,7 @@ static void lv_img_event(const lv_obj_class_t * class_p, lv_event_t * e) lv_coord_t w = lv_obj_get_width(obj); lv_coord_t h = lv_obj_get_height(obj); lv_area_t coords; - _lv_img_buf_get_transformed_area(&coords, w, h, img->angle, img->zoom, &pivot_px); + _lv_image_buf_get_transformed_area(&coords, w, h, img->angle, img->zoom, &pivot_px); coords.x1 += obj->coords.x1; coords.y1 += obj->coords.y1; coords.x2 += obj->coords.x1; @@ -526,8 +526,8 @@ static void lv_img_event(const lv_obj_class_t * class_p, lv_event_t * e) } else if(code == LV_EVENT_GET_SELF_SIZE) { lv_point_t * p = lv_event_get_param(e); - if(img->obj_size_mode == LV_IMG_SIZE_MODE_REAL) { - *p = lv_img_get_transformed_size(obj); + if(img->obj_size_mode == LV_IMAGE_SIZE_MODE_REAL) { + *p = lv_image_get_transformed_size(obj); } else { p->x = img->w; @@ -535,19 +535,19 @@ static void lv_img_event(const lv_obj_class_t * class_p, lv_event_t * e) } } else if(code == LV_EVENT_DRAW_MAIN || code == LV_EVENT_DRAW_POST || code == LV_EVENT_COVER_CHECK) { - draw_img(e); + draw_image(e); } } -static void draw_img(lv_event_t * e) +static void draw_image(lv_event_t * e) { lv_event_code_t code = lv_event_get_code(e); lv_obj_t * obj = lv_event_get_target(e); - lv_img_t * img = (lv_img_t *)obj; + lv_image_t * img = (lv_image_t *)obj; if(code == LV_EVENT_COVER_CHECK) { lv_cover_check_info_t * info = lv_event_get_param(e); if(info->res == LV_COVER_RES_MASKED) return; - if(img->src_type == LV_IMG_SRC_UNKNOWN || img->src_type == LV_IMG_SRC_SYMBOL) { + if(img->src_type == LV_IMAGE_SRC_UNKNOWN || img->src_type == LV_IMAGE_SRC_SYMBOL) { info->res = LV_COVER_RES_NOT_COVER; return; } @@ -559,7 +559,7 @@ static void draw_img(lv_event_t * e) } /*With not LV_OPA_COVER images can't cover an area */ - if(lv_obj_get_style_img_opa(obj, LV_PART_MAIN) != LV_OPA_COVER) { + if(lv_obj_get_style_image_opa(obj, LV_PART_MAIN) != LV_OPA_COVER) { info->res = LV_COVER_RES_NOT_COVER; return; } @@ -579,8 +579,8 @@ static void draw_img(lv_event_t * e) else { lv_area_t a; lv_point_t pivot_px; - lv_img_get_pivot(obj, &pivot_px); - _lv_img_buf_get_transformed_area(&a, lv_obj_get_width(obj), lv_obj_get_height(obj), 0, img->zoom, &pivot_px); + lv_image_get_pivot(obj, &pivot_px); + _lv_image_buf_get_transformed_area(&a, lv_obj_get_width(obj), lv_obj_get_height(obj), 0, img->zoom, &pivot_px); a.x1 += obj->coords.x1; a.y1 += obj->coords.y1; a.x2 += obj->coords.x1; @@ -605,19 +605,19 @@ static void draw_img(lv_event_t * e) lv_point_t bg_pivot; lv_point_t pivot_px; - lv_img_get_pivot(obj, &pivot_px); + lv_image_get_pivot(obj, &pivot_px); bg_pivot.x = pivot_px.x + pleft; bg_pivot.y = pivot_px.y + ptop; lv_area_t bg_coords; - if(img->obj_size_mode == LV_IMG_SIZE_MODE_REAL) { + if(img->obj_size_mode == LV_IMAGE_SIZE_MODE_REAL) { /*Object size equals to transformed image size*/ lv_obj_get_coords(obj, &bg_coords); } else { - _lv_img_buf_get_transformed_area(&bg_coords, obj_w, obj_h, - img->angle, img->zoom, &bg_pivot); + _lv_image_buf_get_transformed_area(&bg_coords, obj_w, obj_h, + img->angle, img->zoom, &bg_pivot); /*Modify the coordinates to draw the background for the rotated and scaled coordinates*/ bg_coords.x1 += obj->coords.x1; @@ -644,9 +644,9 @@ static void draw_img(lv_event_t * e) lv_area_t img_max_area; lv_area_copy(&img_max_area, &obj->coords); - lv_point_t img_size_final = lv_img_get_transformed_size(obj); + lv_point_t img_size_final = lv_image_get_transformed_size(obj); - if(img->obj_size_mode == LV_IMG_SIZE_MODE_REAL) { + if(img->obj_size_mode == LV_IMAGE_SIZE_MODE_REAL) { img_max_area.x1 -= ((img->w - img_size_final.x) + 1) / 2; img_max_area.x2 -= ((img->w - img_size_final.x) + 1) / 2; img_max_area.y1 -= ((img->h - img_size_final.y) + 1) / 2; @@ -662,10 +662,10 @@ static void draw_img(lv_event_t * e) img_max_area.x2 -= pright; img_max_area.y2 -= pbottom; - if(img->src_type == LV_IMG_SRC_FILE || img->src_type == LV_IMG_SRC_VARIABLE) { - lv_draw_img_dsc_t img_dsc; - lv_draw_img_dsc_init(&img_dsc); - lv_obj_init_draw_img_dsc(obj, LV_PART_MAIN, &img_dsc); + if(img->src_type == LV_IMAGE_SRC_FILE || img->src_type == LV_IMAGE_SRC_VARIABLE) { + lv_draw_image_dsc_t img_dsc; + lv_draw_image_dsc_init(&img_dsc); + lv_obj_init_draw_image_dsc(obj, LV_PART_MAIN, &img_dsc); img_dsc.zoom = img->zoom; img_dsc.angle = img->angle; @@ -697,12 +697,12 @@ static void draw_img(lv_event_t * e) coords_tmp.x2 = coords_tmp.x1 + img->w - 1; for(; coords_tmp.x1 < img_max_area.x2; coords_tmp.x1 += img_size_final.x, coords_tmp.x2 += img_size_final.x) { - lv_draw_img(layer, &img_dsc, &coords_tmp); + lv_draw_image(layer, &img_dsc, &coords_tmp); } } layer->clip_area = clip_area_ori; } - else if(img->src_type == LV_IMG_SRC_SYMBOL) { + else if(img->src_type == LV_IMAGE_SRC_SYMBOL) { lv_draw_label_dsc_t label_dsc; lv_draw_label_dsc_init(&label_dsc); lv_obj_init_draw_label_dsc(obj, LV_PART_MAIN, &label_dsc); diff --git a/src/widgets/img/lv_img.h b/src/widgets/image/lv_image.h index e075bac13..371db3b9e 100644 --- a/src/widgets/img/lv_img.h +++ b/src/widgets/image/lv_image.h @@ -3,8 +3,8 @@ * */ -#ifndef LV_IMG_H -#define LV_IMG_H +#ifndef LV_IMAGE_H +#define LV_IMAGE_H #ifdef __cplusplus extern "C" { @@ -46,33 +46,33 @@ typedef struct { lv_coord_t angle; /*rotation angle of the image*/ lv_point_t pivot; /*rotation center of the image*/ lv_coord_t zoom; /*256 means no zoom, 512 double size, 128 half size*/ - uint8_t src_type : 2; /*See: lv_img_src_t*/ + uint8_t src_type : 2; /*See: lv_image_src_t*/ uint8_t cf : 5; /*Color format from `lv_color_format_t`*/ uint8_t antialias : 1; /*Apply anti-aliasing in transformations (rotate, zoom)*/ uint8_t obj_size_mode: 2; /*Image size mode when image size and object size is different.*/ -} lv_img_t; +} lv_image_t; -extern const lv_obj_class_t lv_img_class; +extern const lv_obj_class_t lv_image_class; /** * Image size mode, when image size and object size is different */ -enum _lv_img_size_mode_t { +enum _lv_image_size_mode_t { /** Zoom doesn't affect the coordinates of the object, * however if zoomed in the image is drawn out of the its coordinates. * The layout's won't change on zoom */ - LV_IMG_SIZE_MODE_VIRTUAL = 0, + LV_IMAGE_SIZE_MODE_VIRTUAL = 0, /** If the object size is set to SIZE_CONTENT, then object size equals zoomed image size. * It causes layout recalculation. * If the object size is set explicitly, the image will be cropped when zoomed in.*/ - LV_IMG_SIZE_MODE_REAL, + LV_IMAGE_SIZE_MODE_REAL, }; #ifdef DOXYGEN -typedef _lv_img_size_mode_t lv_img_size_mode_t; +typedef _lv_image_size_mode_t lv_image_size_mode_t; #else -typedef uint8_t lv_img_size_mode_t; +typedef uint8_t lv_image_size_mode_t; #endif /*DOXYGEN*/ /********************** @@ -84,7 +84,7 @@ typedef uint8_t lv_img_size_mode_t; * @param parent pointer to an object, it will be the parent of the new image * @return pointer to the created image */ -lv_obj_t * lv_img_create(lv_obj_t * parent); +lv_obj_t * lv_image_create(lv_obj_t * parent); /*===================== * Setter functions @@ -93,18 +93,18 @@ lv_obj_t * lv_img_create(lv_obj_t * parent); /** * Set the image data to display on the object * @param obj pointer to an image object - * @param src 1) pointer to an ::lv_img_dsc_t descriptor (converted by LVGL's image converter) (e.g. &my_img) or + * @param src 1) pointer to an ::lv_image_dsc_t descriptor (converted by LVGL's image converter) (e.g. &my_img) or * 2) path to an image file (e.g. "S:/dir/img.bin")or * 3) a SYMBOL (e.g. LV_SYMBOL_OK) */ -void lv_img_set_src(lv_obj_t * obj, const void * src); +void lv_image_set_src(lv_obj_t * obj, const void * src); /** * Set an offset for the source of an image so the image will be displayed from the new origin. * @param obj pointer to an image * @param x the new offset along x axis. */ -void lv_img_set_offset_x(lv_obj_t * obj, lv_coord_t x); +void lv_image_set_offset_x(lv_obj_t * obj, lv_coord_t x); /** * Set an offset for the source of an image. @@ -112,27 +112,27 @@ void lv_img_set_offset_x(lv_obj_t * obj, lv_coord_t x); * @param obj pointer to an image * @param y the new offset along y axis. */ -void lv_img_set_offset_y(lv_obj_t * obj, lv_coord_t y); +void lv_image_set_offset_y(lv_obj_t * obj, lv_coord_t y); /** * Set the rotation angle of the image. - * The image will be rotated around the set pivot set by `lv_img_set_pivot()` + * The image will be rotated around the set pivot set by `lv_image_set_pivot()` * Note that indexed and alpha only images can't be transformed. * @param obj pointer to an image object * @param angle rotation angle in degree with 0.1 degree resolution (0..3600: clock wise) */ -void lv_img_set_angle(lv_obj_t * obj, int16_t angle); +void lv_image_set_angle(lv_obj_t * obj, int16_t angle); /** * Set the rotation center of the image. * The image will be rotated around this point. - * x, y can be set with value of LV_PCT, lv_img_get_pivot will return the true pixel coordinate of pivot in this case. + * x, y can be set with value of LV_PCT, lv_image_get_pivot will return the true pixel coordinate of pivot in this case. * @param obj pointer to an image object * @param x rotation center x of the image * @param y rotation center y of the image */ -void lv_img_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_t y); +void lv_image_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_t y); /** @@ -140,13 +140,13 @@ void lv_img_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_t y); * Note that indexed and alpha only images can't be transformed. * @param img pointer to an image object * @param zoom the zoom factor. - * @example 256 or LV_ZOOM_IMG_NONE for no zoom + * @example 256 or LV_ZOOM_IMAGE_NONE for no zoom * @example <256: scale down * @example >256 scale up * @example 128 half size * @example 512 double size */ -void lv_img_set_zoom(lv_obj_t * obj, uint16_t zoom); +void lv_image_set_zoom(lv_obj_t * obj, uint16_t zoom); /** * Enable/disable anti-aliasing for the transformations (rotate, zoom) or not. @@ -154,7 +154,7 @@ void lv_img_set_zoom(lv_obj_t * obj, uint16_t zoom); * @param obj pointer to an image object * @param antialias true: anti-aliased; false: not anti-aliased */ -void lv_img_set_antialias(lv_obj_t * obj, bool antialias); +void lv_image_set_antialias(lv_obj_t * obj, bool antialias); /** * Set the image object size mode. @@ -162,7 +162,7 @@ void lv_img_set_antialias(lv_obj_t * obj, bool antialias); * @param obj pointer to an image object * @param mode the new size mode. */ -void lv_img_set_size_mode(lv_obj_t * obj, lv_img_size_mode_t mode); +void lv_image_set_size_mode(lv_obj_t * obj, lv_image_size_mode_t mode); /*===================== * Getter functions *====================*/ @@ -172,28 +172,28 @@ void lv_img_set_size_mode(lv_obj_t * obj, lv_img_size_mode_t mode); * @param obj pointer to an image object * @return the image source (symbol, file name or ::lv-img_dsc_t for C arrays) */ -const void * lv_img_get_src(lv_obj_t * obj); +const void * lv_image_get_src(lv_obj_t * obj); /** * Get the offset's x attribute of the image object. * @param obj pointer to an image * @return offset X value. */ -lv_coord_t lv_img_get_offset_x(lv_obj_t * obj); +lv_coord_t lv_image_get_offset_x(lv_obj_t * obj); /** * Get the offset's y attribute of the image object. * @param obj pointer to an image * @return offset Y value. */ -lv_coord_t lv_img_get_offset_y(lv_obj_t * obj); +lv_coord_t lv_image_get_offset_y(lv_obj_t * obj); /** * Get the rotation angle of the image. * @param obj pointer to an image object * @return rotation angle in 0.1 degrees (0..3600) */ -lv_coord_t lv_img_get_angle(lv_obj_t * obj); +lv_coord_t lv_image_get_angle(lv_obj_t * obj); /** * Get the pivot (rotation center) of the image. @@ -201,35 +201,35 @@ lv_coord_t lv_img_get_angle(lv_obj_t * obj); * @param obj pointer to an image object * @param pivot store the rotation center here */ -void lv_img_get_pivot(lv_obj_t * obj, lv_point_t * pivot); +void lv_image_get_pivot(lv_obj_t * obj, lv_point_t * pivot); /** * Get the zoom factor of the image. * @param obj pointer to an image object * @return zoom factor (256: no zoom) */ -lv_coord_t lv_img_get_zoom(lv_obj_t * obj); +lv_coord_t lv_image_get_zoom(lv_obj_t * obj); /** * Get whether the transformations (rotate, zoom) are anti-aliased or not * @param obj pointer to an image object * @return true: anti-aliased; false: not anti-aliased */ -bool lv_img_get_antialias(lv_obj_t * obj); +bool lv_image_get_antialias(lv_obj_t * obj); /** * Get the size mode of the image * @param obj pointer to an image object - * @return element of @ref lv_img_size_mode_t + * @return element of @ref lv_image_size_mode_t */ -lv_img_size_mode_t lv_img_get_size_mode(lv_obj_t * obj); +lv_image_size_mode_t lv_image_get_size_mode(lv_obj_t * obj); /********************** * MACROS **********************/ /** Use this macro to declare an image in a C file*/ -#define LV_IMG_DECLARE(var_name) extern const lv_img_dsc_t var_name; +#define LV_IMAGE_DECLARE(var_name) extern const lv_image_dsc_t var_name; #endif /*LV_USE_IMG*/ @@ -237,4 +237,4 @@ lv_img_size_mode_t lv_img_get_size_mode(lv_obj_t * obj); } /*extern "C"*/ #endif -#endif /*LV_IMG_H*/ +#endif /*LV_IMAGE_H*/ diff --git a/src/widgets/imgbtn/lv_imgbtn.c b/src/widgets/imgbtn/lv_imgbtn.c index 21540dcef..de37cf783 100644 --- a/src/widgets/imgbtn/lv_imgbtn.c +++ b/src/widgets/imgbtn/lv_imgbtn.c @@ -28,7 +28,7 @@ static void lv_imgbtn_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj); static void draw_main(lv_event_t * e); static void lv_imgbtn_event(const lv_obj_class_t * class_p, lv_event_t * e); -static void refr_img(lv_obj_t * imgbtn); +static void refr_image(lv_obj_t * imgbtn); static lv_imgbtn_state_t suggest_state(lv_obj_t * imgbtn, lv_imgbtn_state_t state); static lv_imgbtn_state_t get_state(const lv_obj_t * imgbtn); static void update_src_info(lv_imgbtn_src_info_t * info, const void * src); @@ -90,7 +90,7 @@ void lv_imgbtn_set_src(lv_obj_t * obj, lv_imgbtn_state_t state, const void * src update_src_info(&imgbtn->src_mid[state], src_mid); update_src_info(&imgbtn->src_right[state], src_right); - refr_img(obj); + refr_image(obj); } void lv_imgbtn_set_state(lv_obj_t * obj, lv_imgbtn_state_t state) @@ -108,7 +108,7 @@ void lv_imgbtn_set_state(lv_obj_t * obj, lv_imgbtn_state_t state) lv_obj_clear_state(obj, LV_STATE_CHECKED | LV_STATE_PRESSED | LV_STATE_DISABLED); lv_obj_add_state(obj, obj_state); - refr_img(obj); + refr_image(obj); } /*===================== @@ -119,7 +119,7 @@ void lv_imgbtn_set_state(lv_obj_t * obj, lv_imgbtn_state_t state) /** * Get the left image in a given state * @param obj pointer to an image button object - * @param state the state where to get the image (from `lv_btn_state_t`) ` + * @param state the state where to get the image (from `lv_button_state_t`) ` * @return pointer to the left image source (a C array or path to a file) */ const void * lv_imgbtn_get_src_left(lv_obj_t * obj, lv_imgbtn_state_t state) @@ -134,7 +134,7 @@ const void * lv_imgbtn_get_src_left(lv_obj_t * obj, lv_imgbtn_state_t state) /** * Get the middle image in a given state * @param obj pointer to an image button object - * @param state the state where to get the image (from `lv_btn_state_t`) ` + * @param state the state where to get the image (from `lv_button_state_t`) ` * @return pointer to the middle image source (a C array or path to a file) */ const void * lv_imgbtn_get_src_middle(lv_obj_t * obj, lv_imgbtn_state_t state) @@ -148,7 +148,7 @@ const void * lv_imgbtn_get_src_middle(lv_obj_t * obj, lv_imgbtn_state_t state) /** * Get the right image in a given state * @param obj pointer to an image button object - * @param state the state where to get the image (from `lv_btn_state_t`) ` + * @param state the state where to get the image (from `lv_button_state_t`) ` * @return pointer to the left image source (a C array or path to a file) */ const void * lv_imgbtn_get_src_right(lv_obj_t * obj, lv_imgbtn_state_t state) @@ -186,7 +186,7 @@ static void lv_imgbtn_event(const lv_obj_class_t * class_p, lv_event_t * e) lv_event_code_t code = lv_event_get_code(e); lv_obj_t * obj = lv_event_get_target(e); if(code == LV_EVENT_PRESSED || code == LV_EVENT_RELEASED || code == LV_EVENT_PRESS_LOST) { - refr_img(obj); + refr_image(obj); } else if(code == LV_EVENT_DRAW_MAIN) { draw_main(e); @@ -225,9 +225,9 @@ static void draw_main(lv_event_t * e) lv_area_copy(&coords, &obj->coords); lv_area_increase(&coords, tw, th); - lv_draw_img_dsc_t img_dsc; - lv_draw_img_dsc_init(&img_dsc); - lv_obj_init_draw_img_dsc(obj, LV_PART_MAIN, &img_dsc); + lv_draw_image_dsc_t img_dsc; + lv_draw_image_dsc_init(&img_dsc); + lv_obj_init_draw_image_dsc(obj, LV_PART_MAIN, &img_dsc); lv_area_t coords_part; lv_coord_t left_w = 0; @@ -240,7 +240,7 @@ static void draw_main(lv_event_t * e) coords_part.x2 = coords.x1 + src_info->header.w - 1; coords_part.y2 = coords.y1 + src_info->header.h - 1; img_dsc.src = src_info->img_src; - lv_draw_img(layer, &img_dsc, &coords_part); + lv_draw_image(layer, &img_dsc, &coords_part); } src_info = &imgbtn->src_right[state]; @@ -251,7 +251,7 @@ static void draw_main(lv_event_t * e) coords_part.x2 = coords.x2; coords_part.y2 = coords.y1 + src_info->header.h - 1; img_dsc.src = src_info->img_src; - lv_draw_img(layer, &img_dsc, &coords_part); + lv_draw_image(layer, &img_dsc, &coords_part); } src_info = &imgbtn->src_mid[state]; @@ -277,7 +277,7 @@ static void draw_main(lv_event_t * e) for(i = coords_part.x1; i < (lv_coord_t)(clip_area_center.x2 + src_info->header.w - 1); i += src_info->header.w) { img_dsc.src = src_info->img_src; - lv_draw_img(layer, &img_dsc, &coords_part); + lv_draw_image(layer, &img_dsc, &coords_part); coords_part.x1 = coords_part.x2 + 1; coords_part.x2 += src_info->header.w; } @@ -286,7 +286,7 @@ static void draw_main(lv_event_t * e) } } -static void refr_img(lv_obj_t * obj) +static void refr_image(lv_obj_t * obj) { lv_imgbtn_t * imgbtn = (lv_imgbtn_t *)obj; lv_imgbtn_state_t state = suggest_state(obj, get_state(obj)); @@ -366,7 +366,7 @@ static void update_src_info(lv_imgbtn_src_info_t * info, const void * src) return; } - lv_res_t res = lv_img_decoder_get_info(src, &info->header); + lv_res_t res = lv_image_decoder_get_info(src, &info->header); if(res != LV_RES_OK) { LV_LOG_WARN("can't get info"); return; diff --git a/src/widgets/imgbtn/lv_imgbtn.h b/src/widgets/imgbtn/lv_imgbtn.h index d57357bda..8c6ebe206 100644 --- a/src/widgets/imgbtn/lv_imgbtn.h +++ b/src/widgets/imgbtn/lv_imgbtn.h @@ -32,7 +32,7 @@ typedef enum { typedef struct { const void * img_src; - lv_img_header_t header; + lv_image_header_t header; } lv_imgbtn_src_info_t; /********************** @@ -96,7 +96,7 @@ void lv_imgbtn_set_state(lv_obj_t * imgbtn, lv_imgbtn_state_t state); /** * Get the left image in a given state * @param imgbtn pointer to an image button object - * @param state the state where to get the image (from `lv_btn_state_t`) ` + * @param state the state where to get the image (from `lv_button_state_t`) ` * @return pointer to the left image source (a C array or path to a file) */ const void * lv_imgbtn_get_src_left(lv_obj_t * imgbtn, lv_imgbtn_state_t state); @@ -104,7 +104,7 @@ const void * lv_imgbtn_get_src_left(lv_obj_t * imgbtn, lv_imgbtn_state_t state); /** * Get the middle image in a given state * @param imgbtn pointer to an image button object - * @param state the state where to get the image (from `lv_btn_state_t`) ` + * @param state the state where to get the image (from `lv_button_state_t`) ` * @return pointer to the middle image source (a C array or path to a file) */ const void * lv_imgbtn_get_src_middle(lv_obj_t * imgbtn, lv_imgbtn_state_t state); @@ -112,7 +112,7 @@ const void * lv_imgbtn_get_src_middle(lv_obj_t * imgbtn, lv_imgbtn_state_t state /** * Get the right image in a given state * @param imgbtn pointer to an image button object - * @param state the state where to get the image (from `lv_btn_state_t`) ` + * @param state the state where to get the image (from `lv_button_state_t`) ` * @return pointer to the left image source (a C array or path to a file) */ const void * lv_imgbtn_get_src_right(lv_obj_t * imgbtn, lv_imgbtn_state_t state); diff --git a/src/widgets/keyboard/lv_keyboard.c b/src/widgets/keyboard/lv_keyboard.c index a74830e19..765323291 100644 --- a/src/widgets/keyboard/lv_keyboard.c +++ b/src/widgets/keyboard/lv_keyboard.c @@ -20,7 +20,7 @@ * DEFINES *********************/ #define MY_CLASS &lv_keyboard_class -#define LV_KB_BTN(width) LV_BTNMATRIX_CTRL_POPOVER | width +#define LV_KB_BTN(width) LV_BUTTONMATRIX_CTRL_POPOVER | width /********************** * TYPEDEFS @@ -44,7 +44,7 @@ const lv_obj_class_t lv_keyboard_class = { .height_def = LV_PCT(50), .instance_size = sizeof(lv_keyboard_t), .editable = 1, - .base_class = &lv_btnmatrix_class + .base_class = &lv_buttonmatrix_class }; static const char * const default_kb_map_lc[] = {"1#", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", LV_SYMBOL_BACKSPACE, "\n", @@ -57,15 +57,15 @@ static const char * const default_kb_map_lc[] = {"1#", "q", "w", "e", "r", "t", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, "" }; -static const lv_btnmatrix_ctrl_t default_kb_ctrl_lc_map[] = { - LV_KEYBOARD_CTRL_BTN_FLAGS | 5, LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_BTNMATRIX_CTRL_CHECKED | 7, - LV_KEYBOARD_CTRL_BTN_FLAGS | 6, LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_BTNMATRIX_CTRL_CHECKED | 7, - LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), - LV_KEYBOARD_CTRL_BTN_FLAGS | 2, +static const lv_buttonmatrix_ctrl_t default_kb_ctrl_lc_map[] = { + LV_KEYBOARD_CTRL_BUTTON_FLAGS | 5, LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_BUTTONMATRIX_CTRL_CHECKED | 7, + LV_KEYBOARD_CTRL_BUTTON_FLAGS | 6, LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_BUTTONMATRIX_CTRL_CHECKED | 7, + LV_BUTTONMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BUTTONMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_BUTTONMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BUTTONMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BUTTONMATRIX_CTRL_CHECKED | LV_KB_BTN(1), + LV_KEYBOARD_CTRL_BUTTON_FLAGS | 2, #if LV_USE_ARABIC_PERSIAN_CHARS == 1 - LV_KEYBOARD_CTRL_BTN_FLAGS | 2, + LV_KEYBOARD_CTRL_BUTTON_FLAGS | 2, #endif - LV_BTNMATRIX_CTRL_CHECKED | 2, 6, LV_BTNMATRIX_CTRL_CHECKED | 2, LV_KEYBOARD_CTRL_BTN_FLAGS | 2 + LV_BUTTONMATRIX_CTRL_CHECKED | 2, 6, LV_BUTTONMATRIX_CTRL_CHECKED | 2, LV_KEYBOARD_CTRL_BUTTON_FLAGS | 2 }; static const char * const default_kb_map_uc[] = {"1#", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", LV_SYMBOL_BACKSPACE, "\n", @@ -78,15 +78,15 @@ static const char * const default_kb_map_uc[] = {"1#", "Q", "W", "E", "R", "T", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, "" }; -static const lv_btnmatrix_ctrl_t default_kb_ctrl_uc_map[] = { - LV_KEYBOARD_CTRL_BTN_FLAGS | 5, LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_BTNMATRIX_CTRL_CHECKED | 7, - LV_KEYBOARD_CTRL_BTN_FLAGS | 6, LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_BTNMATRIX_CTRL_CHECKED | 7, - LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), - LV_KEYBOARD_CTRL_BTN_FLAGS | 2, +static const lv_buttonmatrix_ctrl_t default_kb_ctrl_uc_map[] = { + LV_KEYBOARD_CTRL_BUTTON_FLAGS | 5, LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_BUTTONMATRIX_CTRL_CHECKED | 7, + LV_KEYBOARD_CTRL_BUTTON_FLAGS | 6, LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_BUTTONMATRIX_CTRL_CHECKED | 7, + LV_BUTTONMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BUTTONMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_BUTTONMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BUTTONMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BUTTONMATRIX_CTRL_CHECKED | LV_KB_BTN(1), + LV_KEYBOARD_CTRL_BUTTON_FLAGS | 2, #if LV_USE_ARABIC_PERSIAN_CHARS == 1 - LV_KEYBOARD_CTRL_BTN_FLAGS | 2, + LV_KEYBOARD_CTRL_BUTTON_FLAGS | 2, #endif - LV_BTNMATRIX_CTRL_CHECKED | 2, 6, LV_BTNMATRIX_CTRL_CHECKED | 2, LV_KEYBOARD_CTRL_BTN_FLAGS | 2 + LV_BUTTONMATRIX_CTRL_CHECKED | 2, 6, LV_BUTTONMATRIX_CTRL_CHECKED | 2, LV_KEYBOARD_CTRL_BUTTON_FLAGS | 2 }; #if LV_USE_ARABIC_PERSIAN_CHARS == 1 static const char * const default_kb_map_ar[] = { @@ -96,11 +96,11 @@ static const char * const default_kb_map_ar[] = { LV_SYMBOL_CLOSE, "abc", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_NEW_LINE, LV_SYMBOL_OK, "" }; -static const lv_btnmatrix_ctrl_t default_kb_ctrl_ar_map[] = { - LV_KEYBOARD_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, +static const lv_buttonmatrix_ctrl_t default_kb_ctrl_ar_map[] = { + LV_KEYBOARD_CTRL_BUTTON_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - LV_KEYBOARD_CTRL_BTN_FLAGS | 2, LV_KEYBOARD_CTRL_BTN_FLAGS | 2, 2, 6, 2, 3, LV_KEYBOARD_CTRL_BTN_FLAGS | 2 + LV_KEYBOARD_CTRL_BUTTON_FLAGS | 2, LV_KEYBOARD_CTRL_BUTTON_FLAGS | 2, 2, 6, 2, 3, LV_KEYBOARD_CTRL_BUTTON_FLAGS | 2 }; #endif @@ -114,15 +114,15 @@ static const char * const default_kb_map_spec[] = {"1", "2", "3", "4", "5", "6", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, "" }; -static const lv_btnmatrix_ctrl_t default_kb_ctrl_spec_map[] = { - LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | 2, - LV_KEYBOARD_CTRL_BTN_FLAGS | 2, LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), +static const lv_buttonmatrix_ctrl_t default_kb_ctrl_spec_map[] = { + LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_BUTTONMATRIX_CTRL_CHECKED | 2, + LV_KEYBOARD_CTRL_BUTTON_FLAGS | 2, LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), - LV_KEYBOARD_CTRL_BTN_FLAGS | 2, + LV_KEYBOARD_CTRL_BUTTON_FLAGS | 2, #if LV_USE_ARABIC_PERSIAN_CHARS == 1 - LV_KEYBOARD_CTRL_BTN_FLAGS | 2, + LV_KEYBOARD_CTRL_BUTTON_FLAGS | 2, #endif - LV_BTNMATRIX_CTRL_CHECKED | 2, 6, LV_BTNMATRIX_CTRL_CHECKED | 2, LV_KEYBOARD_CTRL_BTN_FLAGS | 2 + LV_BUTTONMATRIX_CTRL_CHECKED | 2, 6, LV_BUTTONMATRIX_CTRL_CHECKED | 2, LV_KEYBOARD_CTRL_BUTTON_FLAGS | 2 }; static const char * const default_kb_map_num[] = {"1", "2", "3", LV_SYMBOL_KEYBOARD, "\n", @@ -131,9 +131,9 @@ static const char * const default_kb_map_num[] = {"1", "2", "3", LV_SYMBOL_KEYBO "+/-", "0", ".", LV_SYMBOL_LEFT, LV_SYMBOL_RIGHT, "" }; -static const lv_btnmatrix_ctrl_t default_kb_ctrl_num_map[] = { - 1, 1, 1, LV_KEYBOARD_CTRL_BTN_FLAGS | 2, - 1, 1, 1, LV_KEYBOARD_CTRL_BTN_FLAGS | 2, +static const lv_buttonmatrix_ctrl_t default_kb_ctrl_num_map[] = { + 1, 1, 1, LV_KEYBOARD_CTRL_BUTTON_FLAGS | 2, + 1, 1, 1, LV_KEYBOARD_CTRL_BUTTON_FLAGS | 2, 1, 1, 1, 2, 1, 1, 1, 1, 1 }; @@ -152,7 +152,7 @@ static const char * * kb_map[10] = { #endif (const char * *)NULL }; -static const lv_btnmatrix_ctrl_t * kb_ctrl[10] = { +static const lv_buttonmatrix_ctrl_t * kb_ctrl[10] = { default_kb_ctrl_lc_map, default_kb_ctrl_uc_map, default_kb_ctrl_spec_map, @@ -256,10 +256,10 @@ void lv_keyboard_set_popovers(lv_obj_t * obj, bool en) * @param kb pointer to a Keyboard object * @param mode keyboard map to alter 'lv_keyboard_mode_t' * @param map pointer to a string array to describe the map. - * See 'lv_btnmatrix_set_map()' for more info. + * See 'lv_buttonmatrix_set_map()' for more info. */ void lv_keyboard_set_map(lv_obj_t * obj, lv_keyboard_mode_t mode, const char * map[], - const lv_btnmatrix_ctrl_t ctrl_map[]) + const lv_buttonmatrix_ctrl_t ctrl_map[]) { kb_map[mode] = map; kb_ctrl[mode] = ctrl_map; @@ -299,7 +299,7 @@ lv_keyboard_mode_t lv_keyboard_get_mode(const lv_obj_t * obj) * @param kb pointer to a Keyboard object * @return true: "popovers" mode is enabled; false: disabled */ -bool lv_btnmatrix_get_popovers(const lv_obj_t * obj) +bool lv_buttonmatrix_get_popovers(const lv_obj_t * obj) { lv_keyboard_t * keyboard = (lv_keyboard_t *)obj; return keyboard->popovers; @@ -322,35 +322,35 @@ void lv_keyboard_def_event_cb(lv_event_t * e) LV_ASSERT_OBJ(obj, MY_CLASS); lv_keyboard_t * keyboard = (lv_keyboard_t *)obj; - uint16_t btn_id = lv_btnmatrix_get_selected_btn(obj); - if(btn_id == LV_BTNMATRIX_BTN_NONE) return; + uint16_t btn_id = lv_buttonmatrix_get_selected_button(obj); + if(btn_id == LV_BUTTONMATRIX_BUTTON_NONE) return; - const char * txt = lv_btnmatrix_get_btn_text(obj, btn_id); + const char * txt = lv_buttonmatrix_get_button_text(obj, btn_id); if(txt == NULL) return; if(strcmp(txt, "abc") == 0) { keyboard->mode = LV_KEYBOARD_MODE_TEXT_LOWER; - lv_btnmatrix_set_map(obj, kb_map[LV_KEYBOARD_MODE_TEXT_LOWER]); + lv_buttonmatrix_set_map(obj, kb_map[LV_KEYBOARD_MODE_TEXT_LOWER]); lv_keyboard_update_ctrl_map(obj); return; } #if LV_USE_ARABIC_PERSIAN_CHARS == 1 else if(strcmp(txt, "أب") == 0) { keyboard->mode = LV_KEYBOARD_MODE_TEXT_ARABIC; - lv_btnmatrix_set_map(obj, kb_map[LV_KEYBOARD_MODE_TEXT_ARABIC]); + lv_buttonmatrix_set_map(obj, kb_map[LV_KEYBOARD_MODE_TEXT_ARABIC]); lv_keyboard_update_ctrl_map(obj); return; } #endif else if(strcmp(txt, "ABC") == 0) { keyboard->mode = LV_KEYBOARD_MODE_TEXT_UPPER; - lv_btnmatrix_set_map(obj, kb_map[LV_KEYBOARD_MODE_TEXT_UPPER]); + lv_buttonmatrix_set_map(obj, kb_map[LV_KEYBOARD_MODE_TEXT_UPPER]); lv_keyboard_update_ctrl_map(obj); return; } else if(strcmp(txt, "1#") == 0) { keyboard->mode = LV_KEYBOARD_MODE_SPECIAL; - lv_btnmatrix_set_map(obj, kb_map[LV_KEYBOARD_MODE_SPECIAL]); + lv_buttonmatrix_set_map(obj, kb_map[LV_KEYBOARD_MODE_SPECIAL]); lv_keyboard_update_ctrl_map(obj); return; } @@ -448,7 +448,7 @@ static void lv_keyboard_constructor(const lv_obj_class_t * class_p, lv_obj_t * o static void lv_keyboard_update_map(lv_obj_t * obj) { lv_keyboard_t * keyboard = (lv_keyboard_t *)obj; - lv_btnmatrix_set_map(obj, kb_map[keyboard->mode]); + lv_buttonmatrix_set_map(obj, kb_map[keyboard->mode]); lv_keyboard_update_ctrl_map(obj); } @@ -461,22 +461,22 @@ static void lv_keyboard_update_ctrl_map(lv_obj_t * obj) lv_keyboard_t * keyboard = (lv_keyboard_t *)obj; if(keyboard->popovers) { - /*Apply the current control map (already includes LV_BTNMATRIX_CTRL_POPOVER flags)*/ - lv_btnmatrix_set_ctrl_map(obj, kb_ctrl[keyboard->mode]); + /*Apply the current control map (already includes LV_BUTTONMATRIX_CTRL_POPOVER flags)*/ + lv_buttonmatrix_set_ctrl_map(obj, kb_ctrl[keyboard->mode]); } else { /*Make a copy of the current control map*/ - lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj; - lv_btnmatrix_ctrl_t * ctrl_map = lv_malloc(btnm->btn_cnt * sizeof(lv_btnmatrix_ctrl_t)); - lv_memcpy(ctrl_map, kb_ctrl[keyboard->mode], sizeof(lv_btnmatrix_ctrl_t) * btnm->btn_cnt); + lv_buttonmatrix_t * btnm = (lv_buttonmatrix_t *)obj; + lv_buttonmatrix_ctrl_t * ctrl_map = lv_malloc(btnm->btn_cnt * sizeof(lv_buttonmatrix_ctrl_t)); + lv_memcpy(ctrl_map, kb_ctrl[keyboard->mode], sizeof(lv_buttonmatrix_ctrl_t) * btnm->btn_cnt); - /*Remove all LV_BTNMATRIX_CTRL_POPOVER flags*/ + /*Remove all LV_BUTTONMATRIX_CTRL_POPOVER flags*/ for(uint16_t i = 0; i < btnm->btn_cnt; i++) { - ctrl_map[i] &= (~LV_BTNMATRIX_CTRL_POPOVER); + ctrl_map[i] &= (~LV_BUTTONMATRIX_CTRL_POPOVER); } /*Apply new control map and clean up*/ - lv_btnmatrix_set_ctrl_map(obj, ctrl_map); + lv_buttonmatrix_set_ctrl_map(obj, ctrl_map); lv_free(ctrl_map); } } diff --git a/src/widgets/keyboard/lv_keyboard.h b/src/widgets/keyboard/lv_keyboard.h index 565ed9357..0cd2165aa 100644 --- a/src/widgets/keyboard/lv_keyboard.h +++ b/src/widgets/keyboard/lv_keyboard.h @@ -13,7 +13,7 @@ extern "C" { /********************* * INCLUDES *********************/ -#include "../btnmatrix/lv_btnmatrix.h" +#include "../buttonmatrix/lv_buttonmatrix.h" #if LV_USE_KEYBOARD @@ -29,7 +29,7 @@ extern "C" { /********************* * DEFINES *********************/ -#define LV_KEYBOARD_CTRL_BTN_FLAGS (LV_BTNMATRIX_CTRL_NO_REPEAT | LV_BTNMATRIX_CTRL_CLICK_TRIG | LV_BTNMATRIX_CTRL_CHECKED) +#define LV_KEYBOARD_CTRL_BUTTON_FLAGS (LV_BUTTONMATRIX_CTRL_NO_REPEAT | LV_BUTTONMATRIX_CTRL_CLICK_TRIG | LV_BUTTONMATRIX_CTRL_CHECKED) /********************** * TYPEDEFS @@ -59,7 +59,7 @@ typedef uint8_t lv_keyboard_mode_t; /*Data of keyboard*/ typedef struct { - lv_btnmatrix_t btnm; + lv_buttonmatrix_t btnm; lv_obj_t * ta; /*Pointer to the assigned text area*/ lv_keyboard_mode_t mode; /*Key map type*/ uint8_t popovers : 1; /*Show button titles in popovers on press*/ @@ -108,12 +108,12 @@ void lv_keyboard_set_popovers(lv_obj_t * kb, bool en); * @param kb pointer to a Keyboard object * @param mode keyboard map to alter 'lv_keyboard_mode_t' * @param map pointer to a string array to describe the map. - * See 'lv_btnmatrix_set_map()' for more info. + * See 'lv_buttonmatrix_set_map()' for more info. * @param ctrl_map */ void lv_keyboard_set_map(lv_obj_t * kb, lv_keyboard_mode_t mode, const char * map[], - const lv_btnmatrix_ctrl_t ctrl_map[]); + const lv_buttonmatrix_ctrl_t ctrl_map[]); /*===================== * Getter functions @@ -138,7 +138,7 @@ lv_keyboard_mode_t lv_keyboard_get_mode(const lv_obj_t * kb); * @param obj pointer to a Keyboard object * @return true: "popovers" mode is enabled; false: disabled */ -bool lv_btnmatrix_get_popovers(const lv_obj_t * obj); +bool lv_buttonmatrix_get_popovers(const lv_obj_t * obj); /** * Get the current map of a keyboard @@ -147,18 +147,18 @@ bool lv_btnmatrix_get_popovers(const lv_obj_t * obj); */ static inline const char ** lv_keyboard_get_map_array(const lv_obj_t * kb) { - return lv_btnmatrix_get_map(kb); + return lv_buttonmatrix_get_map(kb); } /** * Get the index of the lastly "activated" button by the user (pressed, released, focused etc) * Useful in the `event_cb` to get the text of the button, check if hidden etc. * @param obj pointer to button matrix object - * @return index of the last released button (LV_BTNMATRIX_BTN_NONE: if unset) + * @return index of the last released button (LV_BUTTONMATRIX_BUTTON_NONE: if unset) */ -static inline uint16_t lv_keyboard_get_selected_btn(const lv_obj_t * obj) +static inline uint16_t lv_keyboard_get_selected_button(const lv_obj_t * obj) { - return lv_btnmatrix_get_selected_btn(obj); + return lv_buttonmatrix_get_selected_button(obj); } /** @@ -167,9 +167,9 @@ static inline uint16_t lv_keyboard_get_selected_btn(const lv_obj_t * obj) * @param btn_id the index a button not counting new line characters. * @return text of btn_index` button */ -static inline const char * lv_keyboard_get_btn_text(const lv_obj_t * obj, uint16_t btn_id) +static inline const char * lv_keyboard_get_button_text(const lv_obj_t * obj, uint16_t btn_id) { - return lv_btnmatrix_get_btn_text(obj, btn_id); + return lv_buttonmatrix_get_button_text(obj, btn_id); } /*===================== diff --git a/src/widgets/list/lv_list.c b/src/widgets/list/lv_list.c index 8fa520c9e..61abe8177 100644 --- a/src/widgets/list/lv_list.c +++ b/src/widgets/list/lv_list.c @@ -10,8 +10,8 @@ #include "../../layouts/flex/lv_flex.h" #include "../../disp/lv_disp.h" #include "../label/lv_label.h" -#include "../img/lv_img.h" -#include "../btn/lv_btn.h" +#include "../image/lv_image.h" +#include "../button/lv_button.h" #if LV_USE_LIST @@ -34,8 +34,8 @@ const lv_obj_class_t lv_list_class = { .height_def = LV_DPI_DEF * 2 }; -const lv_obj_class_t lv_list_btn_class = { - .base_class = &lv_btn_class, +const lv_obj_class_t lv_list_button_class = { + .base_class = &lv_button_class, }; const lv_obj_class_t lv_list_text_class = { @@ -71,18 +71,18 @@ lv_obj_t * lv_list_add_text(lv_obj_t * list, const char * txt) return obj; } -lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * icon, const char * txt) +lv_obj_t * lv_list_add_button(lv_obj_t * list, const void * icon, const char * txt) { LV_LOG_INFO("begin"); - lv_obj_t * obj = lv_obj_class_create_obj(&lv_list_btn_class, list); + lv_obj_t * obj = lv_obj_class_create_obj(&lv_list_button_class, list); lv_obj_class_init_obj(obj); lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT); lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_ROW); #if LV_USE_IMG == 1 if(icon) { - lv_obj_t * img = lv_img_create(obj); - lv_img_set_src(img, icon); + lv_obj_t * img = lv_image_create(obj); + lv_image_set_src(img, icon); } #endif @@ -96,7 +96,7 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * icon, const char * txt) return obj; } -const char * lv_list_get_btn_text(lv_obj_t * list, lv_obj_t * btn) +const char * lv_list_get_button_text(lv_obj_t * list, lv_obj_t * btn) { LV_UNUSED(list); uint32_t i; @@ -111,7 +111,7 @@ const char * lv_list_get_btn_text(lv_obj_t * list, lv_obj_t * btn) return ""; } -void lv_list_set_btn_text(lv_obj_t * list, lv_obj_t * btn, const char * txt) +void lv_list_set_button_text(lv_obj_t * list, lv_obj_t * btn, const char * txt) { LV_UNUSED(list); uint32_t i; diff --git a/src/widgets/list/lv_list.h b/src/widgets/list/lv_list.h index aa8f2512a..fdf7e9a50 100644 --- a/src/widgets/list/lv_list.h +++ b/src/widgets/list/lv_list.h @@ -27,7 +27,7 @@ extern "C" { extern const lv_obj_class_t lv_list_class; extern const lv_obj_class_t lv_list_text_class; -extern const lv_obj_class_t lv_list_btn_class; +extern const lv_obj_class_t lv_list_button_class; /********************** * GLOBAL PROTOTYPES **********************/ @@ -54,7 +54,7 @@ lv_obj_t * lv_list_add_text(lv_obj_t * list, const char * txt); * @param txt Text of the new button, when NULL no text will be added * @return pointer to the created button */ -lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * icon, const char * txt); +lv_obj_t * lv_list_add_button(lv_obj_t * list, const void * icon, const char * txt); /** * Get text of a given list button @@ -62,7 +62,7 @@ lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * icon, const char * txt) * @param btn pointer to the button * @return Text of btn, if btn doesn't have text "" will be returned */ -const char * lv_list_get_btn_text(lv_obj_t * list, lv_obj_t * btn); +const char * lv_list_get_button_text(lv_obj_t * list, lv_obj_t * btn); /** * Set text of a given list button @@ -71,7 +71,7 @@ const char * lv_list_get_btn_text(lv_obj_t * list, lv_obj_t * btn); * @param txt pointer to the text * @return Text of btn, if btn doesn't have text "" will be returned */ -void lv_list_set_btn_text(lv_obj_t * list, lv_obj_t * btn, const char * txt); +void lv_list_set_button_text(lv_obj_t * list, lv_obj_t * btn, const char * txt); /********************** * MACROS diff --git a/src/widgets/menu/lv_menu.c b/src/widgets/menu/lv_menu.c index 6a6fa821d..fc8052d36 100644 --- a/src/widgets/menu/lv_menu.c +++ b/src/widgets/menu/lv_menu.c @@ -19,8 +19,8 @@ #include "../../layouts/lv_layout.h" #include "../../stdlib/lv_string.h" #include "../label/lv_label.h" -#include "../btn/lv_btn.h" -#include "../img/lv_img.h" +#include "../button/lv_button.h" +#include "../image/lv_image.h" /********************** * TYPEDEFS @@ -107,7 +107,7 @@ static void lv_menu_value_changed_event_cb(lv_event_t * e); /********************** * GLOBAL FUNCTIONS **********************/ -bool lv_menu_item_back_btn_is_root(lv_obj_t * menu, lv_obj_t * obj); +bool lv_menu_item_back_button_is_root(lv_obj_t * menu, lv_obj_t * obj); void lv_menu_clear_history(lv_obj_t * obj); lv_obj_t * lv_menu_create(lv_obj_t * parent) @@ -228,7 +228,7 @@ void lv_menu_set_page(lv_obj_t * obj, lv_obj_t * page) if(menu->sidebar_page != NULL) { /* With sidebar enabled */ if(menu->sidebar_generated) { - if(menu->mode_root_back_btn == LV_MENU_ROOT_BACK_BTN_ENABLED) { + if(menu->mode_root_back_btn == LV_MENU_ROOT_BACK_BUTTON_ENABLED) { /* Root back btn is always shown if enabled*/ lv_obj_clear_flag(menu->sidebar_header_back_btn, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(menu->sidebar_header_back_btn, LV_OBJ_FLAG_CLICKABLE); @@ -250,7 +250,7 @@ void lv_menu_set_page(lv_obj_t * obj, lv_obj_t * page) } else { /* With sidebar disabled */ - if(menu->cur_depth >= 2 || menu->mode_root_back_btn == LV_MENU_ROOT_BACK_BTN_ENABLED) { + if(menu->cur_depth >= 2 || menu->mode_root_back_btn == LV_MENU_ROOT_BACK_BUTTON_ENABLED) { lv_obj_clear_flag(menu->main_header_back_btn, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(menu->main_header_back_btn, LV_OBJ_FLAG_CLICKABLE); } @@ -294,14 +294,14 @@ void lv_menu_set_sidebar_page(lv_obj_t * obj, lv_obj_t * page) lv_obj_add_flag(sidebar_header, LV_OBJ_FLAG_EVENT_BUBBLE); menu->sidebar_header = sidebar_header; - lv_obj_t * sidebar_header_back_btn = lv_btn_create(menu->sidebar_header); + lv_obj_t * sidebar_header_back_btn = lv_button_create(menu->sidebar_header); lv_obj_add_event(sidebar_header_back_btn, lv_menu_back_event_cb, LV_EVENT_CLICKED, menu); lv_obj_add_flag(sidebar_header_back_btn, LV_OBJ_FLAG_EVENT_BUBBLE); lv_obj_set_flex_flow(sidebar_header_back_btn, LV_FLEX_FLOW_ROW); menu->sidebar_header_back_btn = sidebar_header_back_btn; - lv_obj_t * sidebar_header_back_icon = lv_img_create(menu->sidebar_header_back_btn); - lv_img_set_src(sidebar_header_back_icon, LV_SYMBOL_LEFT); + lv_obj_t * sidebar_header_back_icon = lv_image_create(menu->sidebar_header_back_btn); + lv_image_set_src(sidebar_header_back_icon, LV_SYMBOL_LEFT); lv_obj_t * sidebar_header_title = lv_label_create(menu->sidebar_header); lv_obj_add_flag(sidebar_header_title, LV_OBJ_FLAG_HIDDEN); @@ -341,7 +341,7 @@ void lv_menu_set_mode_header(lv_obj_t * obj, lv_menu_mode_header_t mode_header) } } -void lv_menu_set_mode_root_back_btn(lv_obj_t * obj, lv_menu_mode_root_back_btn_t mode_root_back_btn) +void lv_menu_set_mode_root_back_button(lv_obj_t * obj, lv_menu_mode_root_back_button_t mode_root_back_btn) { LV_ASSERT_OBJ(obj, MY_CLASS); @@ -456,7 +456,7 @@ lv_obj_t * lv_menu_get_main_header(lv_obj_t * obj) return menu->main_header; } -lv_obj_t * lv_menu_get_main_header_back_btn(lv_obj_t * obj) +lv_obj_t * lv_menu_get_main_header_back_button(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); @@ -472,7 +472,7 @@ lv_obj_t * lv_menu_get_sidebar_header(lv_obj_t * obj) return menu->sidebar_header; } -lv_obj_t * lv_menu_get_sidebar_header_back_btn(lv_obj_t * obj) +lv_obj_t * lv_menu_get_sidebar_header_back_button(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); @@ -480,7 +480,7 @@ lv_obj_t * lv_menu_get_sidebar_header_back_btn(lv_obj_t * obj) return menu->sidebar_header_back_btn; } -bool lv_menu_back_btn_is_root(lv_obj_t * menu, lv_obj_t * obj) +bool lv_menu_back_button_is_root(lv_obj_t * menu, lv_obj_t * obj) { LV_ASSERT_OBJ(menu, MY_CLASS); @@ -522,7 +522,7 @@ static void lv_menu_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) lv_menu_t * menu = (lv_menu_t *)obj; menu->mode_header = LV_MENU_HEADER_TOP_FIXED; - menu->mode_root_back_btn = LV_MENU_ROOT_BACK_BTN_DISABLED; + menu->mode_root_back_btn = LV_MENU_ROOT_BACK_BUTTON_DISABLED; menu->cur_depth = 0; menu->prev_depth = 0; menu->sidebar_generated = false; @@ -557,14 +557,14 @@ static void lv_menu_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj) menu->main_header = main_header; /* Create the default simple back btn and title */ - lv_obj_t * main_header_back_btn = lv_btn_create(menu->main_header); + lv_obj_t * main_header_back_btn = lv_button_create(menu->main_header); lv_obj_add_event(main_header_back_btn, lv_menu_back_event_cb, LV_EVENT_CLICKED, menu); lv_obj_add_flag(main_header_back_btn, LV_OBJ_FLAG_EVENT_BUBBLE); lv_obj_set_flex_flow(main_header_back_btn, LV_FLEX_FLOW_ROW); menu->main_header_back_btn = main_header_back_btn; - lv_obj_t * main_header_back_icon = lv_img_create(menu->main_header_back_btn); - lv_img_set_src(main_header_back_icon, LV_SYMBOL_LEFT); + lv_obj_t * main_header_back_icon = lv_image_create(menu->main_header_back_btn); + lv_image_set_src(main_header_back_icon, LV_SYMBOL_LEFT); lv_obj_t * main_header_title = lv_label_create(menu->main_header); lv_obj_add_flag(main_header_title, LV_OBJ_FLAG_HIDDEN); @@ -761,7 +761,7 @@ static void lv_menu_back_event_cb(lv_event_t * e) menu->prev_depth = menu->cur_depth; /* Save the previous value for user event handler */ - if(lv_menu_back_btn_is_root((lv_obj_t *)menu, obj)) return; + if(lv_menu_back_button_is_root((lv_obj_t *)menu, obj)) return; lv_ll_t * history_ll = &(menu->history_ll); diff --git a/src/widgets/menu/lv_menu.h b/src/widgets/menu/lv_menu.h index 0ed2d70bb..ba6939a50 100644 --- a/src/widgets/menu/lv_menu.h +++ b/src/widgets/menu/lv_menu.h @@ -37,15 +37,15 @@ typedef uint8_t lv_menu_mode_header_t; #endif /*DOXYGEN*/ -enum _lv_menu_mode_root_back_btn_t { - LV_MENU_ROOT_BACK_BTN_DISABLED, - LV_MENU_ROOT_BACK_BTN_ENABLED +enum _lv_menu_mode_root_back_button_t { + LV_MENU_ROOT_BACK_BUTTON_DISABLED, + LV_MENU_ROOT_BACK_BUTTON_ENABLED }; #ifdef DOXYGEN -typedef _lv_menu_mode_root_back_btn_t lv_menu_mode_root_back_btn_t; +typedef _lv_menu_mode_root_back_button_t lv_menu_mode_root_back_button_t; #else -typedef uint8_t lv_menu_mode_root_back_btn_t; +typedef uint8_t lv_menu_mode_root_back_button_t; #endif /*DOXYGEN*/ typedef struct /// @cond @@ -84,7 +84,7 @@ typedef struct { uint8_t prev_depth; uint8_t sidebar_generated : 1; lv_menu_mode_header_t mode_header : 2; - lv_menu_mode_root_back_btn_t mode_root_back_btn : 1; + lv_menu_mode_root_back_button_t mode_root_back_btn : 1; } lv_menu_t; typedef struct { @@ -185,7 +185,7 @@ void lv_menu_set_mode_header(lv_obj_t * obj, lv_menu_mode_header_t mode_header); * @param obj pointer to a menu * @param mode_root_back_btn */ -void lv_menu_set_mode_root_back_btn(lv_obj_t * obj, lv_menu_mode_root_back_btn_t mode_root_back_btn); +void lv_menu_set_mode_root_back_button(lv_obj_t * obj, lv_menu_mode_root_back_button_t mode_root_back_btn); /** * Add menu to the menu item @@ -224,7 +224,7 @@ lv_obj_t * lv_menu_get_main_header(lv_obj_t * obj); * @param obj pointer to the menu * @return pointer to main header back btn obj */ -lv_obj_t * lv_menu_get_main_header_back_btn(lv_obj_t * obj); +lv_obj_t * lv_menu_get_main_header_back_button(lv_obj_t * obj); /** * Get a pointer to sidebar header obj @@ -238,7 +238,7 @@ lv_obj_t * lv_menu_get_sidebar_header(lv_obj_t * obj); * @param obj pointer to the menu * @return pointer to sidebar header back btn obj */ -lv_obj_t * lv_menu_get_sidebar_header_back_btn(lv_obj_t * obj); +lv_obj_t * lv_menu_get_sidebar_header_back_button(lv_obj_t * obj); /** * Check if an obj is a root back btn @@ -246,7 +246,7 @@ lv_obj_t * lv_menu_get_sidebar_header_back_btn(lv_obj_t * obj); * @param obj pointer to the back button * @return true if it is a root back btn */ -bool lv_menu_back_btn_is_root(lv_obj_t * menu, lv_obj_t * obj); +bool lv_menu_back_button_is_root(lv_obj_t * menu, lv_obj_t * obj); /** * Clear menu history diff --git a/src/widgets/meter/lv_meter.c b/src/widgets/meter/lv_meter.c index ed15a724e..2eb6b2483 100644 --- a/src/widgets/meter/lv_meter.c +++ b/src/widgets/meter/lv_meter.c @@ -126,8 +126,8 @@ lv_meter_indicator_t * lv_meter_add_needle_line(lv_obj_t * obj, uint16_t width, return indic; } -lv_meter_indicator_t * lv_meter_add_needle_img(lv_obj_t * obj, const void * src, - lv_coord_t pivot_x, lv_coord_t pivot_y) +lv_meter_indicator_t * lv_meter_add_needle_image(lv_obj_t * obj, const void * src, + lv_coord_t pivot_x, lv_coord_t pivot_y) { LV_ASSERT_OBJ(obj, MY_CLASS); lv_meter_t * meter = (lv_meter_t *)obj; @@ -495,9 +495,9 @@ static void draw_needles(lv_obj_t * obj, lv_layer_t * layer, const lv_area_t * s lv_draw_line_dsc_init(&line_dsc); lv_obj_init_draw_line_dsc(obj, LV_PART_ITEMS, &line_dsc); - lv_draw_img_dsc_t img_dsc; - lv_draw_img_dsc_init(&img_dsc); - lv_obj_init_draw_img_dsc(obj, LV_PART_ITEMS, &img_dsc); + lv_draw_image_dsc_t img_dsc; + lv_draw_image_dsc_init(&img_dsc); + lv_obj_init_draw_image_dsc(obj, LV_PART_ITEMS, &img_dsc); lv_opa_t opa_main = lv_obj_get_style_opa_recursive(obj, LV_PART_MAIN); lv_meter_indicator_t * indic; @@ -522,8 +522,8 @@ static void draw_needles(lv_obj_t * obj, lv_layer_t * layer, const lv_area_t * s int32_t angle = lv_map(indic->end_value, meter->scale.min, meter->scale.max, meter->scale.rotation, meter->scale.rotation + meter->scale.angle_range); - lv_img_header_t info; - lv_img_decoder_get_info(indic->type_data.needle_img.src, &info); + lv_image_header_t info; + lv_image_decoder_get_info(indic->type_data.needle_img.src, &info); lv_area_t a; a.x1 = scale_center.x - indic->type_data.needle_img.pivot.x; a.y1 = scale_center.y - indic->type_data.needle_img.pivot.y; @@ -538,7 +538,7 @@ static void draw_needles(lv_obj_t * obj, lv_layer_t * layer, const lv_area_t * s img_dsc.angle = angle; img_dsc.src = indic->type_data.needle_img.src; - lv_draw_img(layer, &img_dsc, &a); + lv_draw_image(layer, &img_dsc, &a); } } } @@ -602,8 +602,8 @@ static void inv_line(lv_obj_t * obj, lv_meter_indicator_t * indic, int32_t value else if(indic->type == LV_METER_INDICATOR_TYPE_NEEDLE_IMG) { int32_t angle = lv_map(value, meter->scale.min, meter->scale.max, meter->scale.rotation, meter->scale.rotation + meter->scale.angle_range); - lv_img_header_t info; - lv_img_decoder_get_info(indic->type_data.needle_img.src, &info); + lv_image_header_t info; + lv_image_decoder_get_info(indic->type_data.needle_img.src, &info); angle = angle * 10; if(angle > 3600) angle -= 3600; @@ -611,7 +611,7 @@ static void inv_line(lv_obj_t * obj, lv_meter_indicator_t * indic, int32_t value scale_center.x -= indic->type_data.needle_img.pivot.x; scale_center.y -= indic->type_data.needle_img.pivot.y; lv_area_t a; - _lv_img_buf_get_transformed_area(&a, info.w, info.h, angle, LV_ZOOM_NONE, &indic->type_data.needle_img.pivot); + _lv_image_buf_get_transformed_area(&a, info.w, info.h, angle, LV_ZOOM_NONE, &indic->type_data.needle_img.pivot); a.x1 += scale_center.x - 2; a.y1 += scale_center.y - 2; a.x2 += scale_center.x + 2; diff --git a/src/widgets/meter/lv_meter.h b/src/widgets/meter/lv_meter.h index 54e211521..a9e7d96a7 100644 --- a/src/widgets/meter/lv_meter.h +++ b/src/widgets/meter/lv_meter.h @@ -161,14 +161,14 @@ lv_meter_indicator_t * lv_meter_add_needle_line(lv_obj_t * obj, uint16_t width, /** * Add a needle image indicator the scale * @param obj pointer to a meter object - * @param src the image source of the indicator. path or pointer to ::lv_img_dsc_t + * @param src the image source of the indicator. path or pointer to ::lv_image_dsc_t * @param pivot_x the X pivot point of the needle * @param pivot_y the Y pivot point of the needle * @return the new indicator or NULL on allocation failure. * @note the needle image should point to the right, like -O-----> */ -lv_meter_indicator_t * lv_meter_add_needle_img(lv_obj_t * obj, const void * src, - lv_coord_t pivot_x, lv_coord_t pivot_y); +lv_meter_indicator_t * lv_meter_add_needle_image(lv_obj_t * obj, const void * src, + lv_coord_t pivot_x, lv_coord_t pivot_y); /** * Add an arc indicator the scale diff --git a/src/widgets/msgbox/lv_msgbox.c b/src/widgets/msgbox/lv_msgbox.c index 33b2d1059..403f47685 100644 --- a/src/widgets/msgbox/lv_msgbox.c +++ b/src/widgets/msgbox/lv_msgbox.c @@ -10,8 +10,8 @@ #if LV_USE_MSGBOX #include "../label/lv_label.h" -#include "../btn/lv_btn.h" -#include "../btnmatrix/lv_btnmatrix.h" +#include "../button/lv_button.h" +#include "../buttonmatrix/lv_buttonmatrix.h" #include "../../misc/lv_assert.h" #include "../../disp/lv_disp.h" #include "../../layouts/flex/lv_flex.h" @@ -100,14 +100,14 @@ lv_obj_t * lv_msgbox_create(lv_obj_t * parent, const char * title, const char * } if(add_close_btn) { - mbox->close_btn = lv_btn_create(obj); + mbox->close_btn = lv_button_create(obj); lv_obj_set_ext_click_area(mbox->close_btn, LV_DPX(10)); lv_obj_add_event(mbox->close_btn, msgbox_close_click_event_cb, LV_EVENT_CLICKED, NULL); lv_obj_t * label = lv_label_create(mbox->close_btn); lv_label_set_text(label, LV_SYMBOL_CLOSE); const lv_font_t * font = lv_obj_get_style_text_font(mbox->close_btn, LV_PART_MAIN); - lv_coord_t close_btn_size = lv_font_get_line_height(font) + LV_DPX(10); - lv_obj_set_size(mbox->close_btn, close_btn_size, close_btn_size); + lv_coord_t close_button_size = lv_font_get_line_height(font) + LV_DPX(10); + lv_obj_set_size(mbox->close_btn, close_button_size, close_button_size); lv_obj_align(label, LV_ALIGN_CENTER, 0, 0); } @@ -125,20 +125,20 @@ lv_obj_t * lv_msgbox_create(lv_obj_t * parent, const char * title, const char * } if(btn_txts) { - mbox->btns = lv_btnmatrix_create(obj); - lv_btnmatrix_set_map(mbox->btns, btn_txts); - lv_btnmatrix_set_btn_ctrl_all(mbox->btns, LV_BTNMATRIX_CTRL_CLICK_TRIG | LV_BTNMATRIX_CTRL_NO_REPEAT); + mbox->buttons = lv_buttonmatrix_create(obj); + lv_buttonmatrix_set_map(mbox->buttons, btn_txts); + lv_buttonmatrix_set_button_ctrl_all(mbox->buttons, LV_BUTTONMATRIX_CTRL_CLICK_TRIG | LV_BUTTONMATRIX_CTRL_NO_REPEAT); uint32_t btn_cnt = 0; while(btn_txts[btn_cnt] && btn_txts[btn_cnt][0] != '\0') { btn_cnt++; } - const lv_font_t * font = lv_obj_get_style_text_font(mbox->btns, LV_PART_ITEMS); + const lv_font_t * font = lv_obj_get_style_text_font(mbox->buttons, LV_PART_ITEMS); lv_coord_t btn_h = lv_font_get_line_height(font) + LV_DPI_DEF / 10; - lv_obj_set_size(mbox->btns, btn_cnt * (2 * LV_DPI_DEF / 3), btn_h); - lv_obj_set_style_max_width(mbox->btns, lv_pct(100), 0); - lv_obj_add_flag(mbox->btns, LV_OBJ_FLAG_EVENT_BUBBLE); /*To see the event directly on the message box*/ + lv_obj_set_size(mbox->buttons, btn_cnt * (2 * LV_DPI_DEF / 3), btn_h); + lv_obj_set_style_max_width(mbox->buttons, lv_pct(100), 0); + lv_obj_add_flag(mbox->buttons, LV_OBJ_FLAG_EVENT_BUBBLE); /*To see the event directly on the message box*/ } return obj; @@ -152,7 +152,7 @@ lv_obj_t * lv_msgbox_get_title(lv_obj_t * obj) return mbox->title; } -lv_obj_t * lv_msgbox_get_close_btn(lv_obj_t * obj) +lv_obj_t * lv_msgbox_get_close_button(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); lv_msgbox_t * mbox = (lv_msgbox_t *)obj; @@ -173,23 +173,23 @@ lv_obj_t * lv_msgbox_get_content(lv_obj_t * obj) return mbox->content; } -lv_obj_t * lv_msgbox_get_btns(lv_obj_t * obj) +lv_obj_t * lv_msgbox_get_buttons(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); lv_msgbox_t * mbox = (lv_msgbox_t *)obj; - return mbox->btns; + return mbox->buttons; } -uint16_t lv_msgbox_get_active_btn(lv_obj_t * mbox) +uint16_t lv_msgbox_get_active_button(lv_obj_t * mbox) { - lv_obj_t * btnm = lv_msgbox_get_btns(mbox); - return lv_btnmatrix_get_selected_btn(btnm); + lv_obj_t * btnm = lv_msgbox_get_buttons(mbox); + return lv_buttonmatrix_get_selected_button(btnm); } -const char * lv_msgbox_get_active_btn_text(lv_obj_t * mbox) +const char * lv_msgbox_get_active_button_text(lv_obj_t * mbox) { - lv_obj_t * btnm = lv_msgbox_get_btns(mbox); - return lv_btnmatrix_get_btn_text(btnm, lv_btnmatrix_get_selected_btn(btnm)); + lv_obj_t * btnm = lv_msgbox_get_buttons(mbox); + return lv_buttonmatrix_get_button_text(btnm, lv_buttonmatrix_get_selected_button(btnm)); } void lv_msgbox_close(lv_obj_t * mbox) diff --git a/src/widgets/msgbox/lv_msgbox.h b/src/widgets/msgbox/lv_msgbox.h index 7872d0e69..50f2cbfd7 100644 --- a/src/widgets/msgbox/lv_msgbox.h +++ b/src/widgets/msgbox/lv_msgbox.h @@ -40,7 +40,7 @@ typedef struct { lv_obj_t * close_btn; lv_obj_t * content; lv_obj_t * text; - lv_obj_t * btns; + lv_obj_t * buttons; } lv_msgbox_t; extern const lv_obj_class_t lv_msgbox_class; @@ -65,22 +65,22 @@ lv_obj_t * lv_msgbox_create(lv_obj_t * parent, const char * title, const char * lv_obj_t * lv_msgbox_get_title(lv_obj_t * obj); -lv_obj_t * lv_msgbox_get_close_btn(lv_obj_t * obj); +lv_obj_t * lv_msgbox_get_close_button(lv_obj_t * obj); lv_obj_t * lv_msgbox_get_text(lv_obj_t * obj); lv_obj_t * lv_msgbox_get_content(lv_obj_t * obj); -lv_obj_t * lv_msgbox_get_btns(lv_obj_t * obj); +lv_obj_t * lv_msgbox_get_buttons(lv_obj_t * obj); /** * Get the index of the selected button * @param mbox message box object - * @return index of the button (LV_BTNMATRIX_BTN_NONE: if unset) + * @return index of the button (LV_BUTTONMATRIX_BUTTON_NONE: if unset) */ -uint16_t lv_msgbox_get_active_btn(lv_obj_t * mbox); +uint16_t lv_msgbox_get_active_button(lv_obj_t * mbox); -const char * lv_msgbox_get_active_btn_text(lv_obj_t * mbox); +const char * lv_msgbox_get_active_button_text(lv_obj_t * mbox); void lv_msgbox_close(lv_obj_t * mbox); diff --git a/src/widgets/slider/lv_slider.c b/src/widgets/slider/lv_slider.c index 30de69ff7..15308c9c7 100644 --- a/src/widgets/slider/lv_slider.c +++ b/src/widgets/slider/lv_slider.c @@ -17,7 +17,7 @@ #include "../../draw/lv_draw.h" #include "../../stdlib/lv_string.h" #include "../../misc/lv_math.h" -#include "../img/lv_img.h" +#include "../image/lv_image.h" /********************* * DEFINES diff --git a/src/widgets/switch/lv_switch.c b/src/widgets/switch/lv_switch.c index 378205dbd..c94a7299a 100644 --- a/src/widgets/switch/lv_switch.c +++ b/src/widgets/switch/lv_switch.c @@ -15,7 +15,6 @@ #include "../../misc/lv_anim.h" #include "../../indev/lv_indev.h" #include "../../disp/lv_disp.h" -#include "../img/lv_img.h" /********************* * DEFINES diff --git a/src/widgets/tabview/lv_tabview.c b/src/widgets/tabview/lv_tabview.c index 26b34dab5..8697d74d6 100644 --- a/src/widgets/tabview/lv_tabview.c +++ b/src/widgets/tabview/lv_tabview.c @@ -27,7 +27,7 @@ static void lv_tabview_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj); static void lv_tabview_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj); static void lv_tabview_event(const lv_obj_class_t * class_p, lv_event_t * e); -static void btns_value_changed_event_cb(lv_event_t * e); +static void buttons_value_changed_event_cb(lv_event_t * e); static void cont_scroll_end_event_cb(lv_event_t * e); /********************** @@ -80,7 +80,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * obj, const char * name) lv_obj_set_size(page, LV_PCT(100), LV_PCT(100)); uint32_t tab_id = lv_obj_get_child_cnt(cont); - lv_obj_t * btns = lv_tabview_get_tab_btns(obj); + lv_obj_t * buttons = lv_tabview_get_tab_buttons(obj); char ** old_map = tabview->map; char ** new_map; @@ -109,18 +109,18 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * obj, const char * name) } } tabview->map = new_map; - lv_btnmatrix_set_map(btns, (const char **)new_map); + lv_buttonmatrix_set_map(buttons, (const char **)new_map); lv_free(old_map); - lv_btnmatrix_set_btn_ctrl_all(btns, LV_BTNMATRIX_CTRL_CHECKABLE | LV_BTNMATRIX_CTRL_CLICK_TRIG | - LV_BTNMATRIX_CTRL_NO_REPEAT); + lv_buttonmatrix_set_button_ctrl_all(buttons, LV_BUTTONMATRIX_CTRL_CHECKABLE | LV_BUTTONMATRIX_CTRL_CLICK_TRIG | + LV_BUTTONMATRIX_CTRL_NO_REPEAT); tabview->tab_cnt++; if(tabview->tab_cnt == 1) { lv_tabview_set_act(obj, 0, LV_ANIM_OFF); } - lv_btnmatrix_set_btn_ctrl(btns, tabview->tab_cur, LV_BTNMATRIX_CTRL_CHECKED); + lv_buttonmatrix_set_button_ctrl(buttons, tabview->tab_cur, LV_BUTTONMATRIX_CTRL_CHECKED); return page; } @@ -171,8 +171,8 @@ void lv_tabview_set_act(lv_obj_t * obj, uint32_t id, lv_anim_enable_t anim_en) lv_obj_scroll_to_y(cont, id * (gap + h), anim_en); } - lv_obj_t * btns = lv_tabview_get_tab_btns(obj); - lv_btnmatrix_set_btn_ctrl(btns, id, LV_BTNMATRIX_CTRL_CHECKED); + lv_obj_t * buttons = lv_tabview_get_tab_buttons(obj); + lv_buttonmatrix_set_button_ctrl(buttons, id, LV_BUTTONMATRIX_CTRL_CHECKED); tabview->tab_cur = id; } @@ -188,7 +188,7 @@ lv_obj_t * lv_tabview_get_content(lv_obj_t * tv) return lv_obj_get_child(tv, 1); } -lv_obj_t * lv_tabview_get_tab_btns(lv_obj_t * tv) +lv_obj_t * lv_tabview_get_tab_buttons(lv_obj_t * tv) { return lv_obj_get_child(tv, 0); } @@ -224,14 +224,14 @@ static void lv_tabview_constructor(const lv_obj_class_t * class_p, lv_obj_t * ob lv_obj_t * btnm; lv_obj_t * cont; - btnm = lv_btnmatrix_create(obj); + btnm = lv_buttonmatrix_create(obj); cont = lv_obj_create(obj); - lv_btnmatrix_set_one_checked(btnm, true); + lv_buttonmatrix_set_one_checked(btnm, true); tabview->map = lv_malloc(sizeof(const char *)); tabview->map[0] = (char *)""; - lv_btnmatrix_set_map(btnm, (const char **)tabview->map); - lv_obj_add_event(btnm, btns_value_changed_event_cb, LV_EVENT_VALUE_CHANGED, NULL); + lv_buttonmatrix_set_map(btnm, (const char **)tabview->map); + lv_obj_add_event(btnm, buttons_value_changed_event_cb, LV_EVENT_VALUE_CHANGED, NULL); lv_obj_add_flag(btnm, LV_OBJ_FLAG_EVENT_BUBBLE); lv_obj_add_event(cont, cont_scroll_end_event_cb, LV_EVENT_ALL, NULL); @@ -306,12 +306,12 @@ static void lv_tabview_event(const lv_obj_class_t * class_p, lv_event_t * e) } -static void btns_value_changed_event_cb(lv_event_t * e) +static void buttons_value_changed_event_cb(lv_event_t * e) { - lv_obj_t * btns = lv_event_get_target(e); + lv_obj_t * buttons = lv_event_get_target(e); - lv_obj_t * tv = lv_obj_get_parent(btns); - uint32_t id = lv_btnmatrix_get_selected_btn(btns); + lv_obj_t * tv = lv_obj_get_parent(buttons); + uint32_t id = lv_buttonmatrix_get_selected_button(buttons); lv_tabview_set_act(tv, id, LV_ANIM_OFF); } diff --git a/src/widgets/tabview/lv_tabview.h b/src/widgets/tabview/lv_tabview.h index 388c65477..9a5278870 100644 --- a/src/widgets/tabview/lv_tabview.h +++ b/src/widgets/tabview/lv_tabview.h @@ -46,7 +46,7 @@ void lv_tabview_rename_tab(lv_obj_t * obj, uint32_t tab_id, const char * new_nam lv_obj_t * lv_tabview_get_content(lv_obj_t * tv); -lv_obj_t * lv_tabview_get_tab_btns(lv_obj_t * tv); +lv_obj_t * lv_tabview_get_tab_buttons(lv_obj_t * tv); void lv_tabview_set_act(lv_obj_t * obj, uint32_t id, lv_anim_enable_t anim_en); diff --git a/src/widgets/win/lv_win.c b/src/widgets/win/lv_win.c index 1c8ab6b2e..640df1d71 100644 --- a/src/widgets/win/lv_win.c +++ b/src/widgets/win/lv_win.c @@ -59,14 +59,14 @@ lv_obj_t * lv_win_add_title(lv_obj_t * win, const char * txt) return title; } -lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * icon, lv_coord_t btn_w) +lv_obj_t * lv_win_add_button(lv_obj_t * win, const void * icon, lv_coord_t btn_w) { lv_obj_t * header = lv_win_get_header(win); - lv_obj_t * btn = lv_btn_create(header); + lv_obj_t * btn = lv_button_create(header); lv_obj_set_size(btn, btn_w, LV_PCT(100)); - lv_obj_t * img = lv_img_create(btn); - lv_img_set_src(img, icon); + lv_obj_t * img = lv_image_create(btn); + lv_image_set_src(img, icon); lv_obj_align(img, LV_ALIGN_CENTER, 0, 0); return btn; diff --git a/src/widgets/win/lv_win.h b/src/widgets/win/lv_win.h index c67ce8afc..b47e9306b 100644 --- a/src/widgets/win/lv_win.h +++ b/src/widgets/win/lv_win.h @@ -36,7 +36,7 @@ lv_obj_t * lv_win_create(lv_obj_t * parent); lv_obj_t * lv_win_add_title(lv_obj_t * win, const char * txt); -lv_obj_t * lv_win_add_btn(lv_obj_t * win, const void * icon, lv_coord_t btn_w); +lv_obj_t * lv_win_add_button(lv_obj_t * win, const void * icon, lv_coord_t btn_w); lv_obj_t * lv_win_get_header(lv_obj_t * win); lv_obj_t * lv_win_get_content(lv_obj_t * win); |