From e0fb0db735db12fcbeb81c5ae01d9c645845abc2 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Wed, 10 Feb 2021 22:59:53 +0100 Subject: [PATCH] add all widgets and widget examples --- examples/assets/imgbtn_left.c | 262 +++++ examples/assets/imgbtn_left.png | Bin 0 -> 699 bytes examples/assets/imgbtn_mid.c | 234 +++++ examples/assets/imgbtn_mid.png | Bin 0 -> 301 bytes examples/assets/imgbtn_right.c | 239 +++++ examples/assets/imgbtn_right.png | Bin 0 -> 734 bytes examples/widgets/imgbtn/index.rst | 13 + examples/widgets/imgbtn/lv_example_imgbtn_1.c | 43 + .../widgets/tabview/lv_example_tabview_1.c | 2 +- src/extra/layouts/flex/lv_flex.c | 19 +- src/extra/themes/default/lv_theme_default.c | 67 +- src/extra/widgets/calendar/lv_calendar.c | 2 +- src/extra/widgets/imgbtn/lv_imgbtn.c | 958 +++++++----------- src/extra/widgets/imgbtn/lv_imgbtn.h | 46 +- src/extra/widgets/keyboard/lv_keyboard.c | 4 +- src/extra/widgets/led/lv_led.c | 140 ++- src/extra/widgets/led/lv_led.h | 23 +- src/extra/widgets/lv_widgets.h | 2 + src/extra/widgets/msgbox/lv_msgbox.c | 3 + src/extra/widgets/spinbox/lv_spinbox.c | 1 + src/extra/widgets/tabview/lv_tabview.c | 41 +- src/extra/widgets/tabview/lv_tabview.h | 3 +- src/extra/widgets/tileview/lv_tileview.h | 2 + src/lv_core/lv_group.c | 6 +- src/lv_core/lv_indev.c | 20 +- src/lv_core/lv_obj.c | 93 +- src/lv_core/lv_obj.h | 2 +- src/lv_core/lv_obj_class.c | 19 +- src/lv_core/lv_obj_scroll.c | 4 + src/lv_core/lv_obj_style.c | 2 +- src/lv_core/lv_obj_tree.c | 24 +- src/lv_core/lv_refr.c | 2 - src/lv_core/lv_theme.c | 6 +- src/lv_draw/lv_draw_blend.c | 4 - src/lv_draw/lv_draw_mask.c | 4 +- src/lv_draw/lv_draw_rect.c | 5 + src/lv_misc/lv_mem.c | 8 + src/lv_misc/lv_style.c | 3 +- src/lv_misc/lv_style.h | 80 +- src/lv_widgets/lv_btnmatrix.c | 3 +- src/lv_widgets/lv_checkbox.c | 15 +- src/lv_widgets/lv_dropdown.c | 72 +- src/lv_widgets/lv_img.c | 11 +- src/lv_widgets/lv_meter.c | 27 +- src/lv_widgets/lv_roller.c | 5 +- src/lv_widgets/lv_switch.c | 4 +- src/lv_widgets/lv_textarea.c | 24 +- 47 files changed, 1625 insertions(+), 922 deletions(-) create mode 100644 examples/assets/imgbtn_left.c create mode 100644 examples/assets/imgbtn_left.png create mode 100644 examples/assets/imgbtn_mid.c create mode 100644 examples/assets/imgbtn_mid.png create mode 100644 examples/assets/imgbtn_right.c create mode 100644 examples/assets/imgbtn_right.png create mode 100644 examples/widgets/imgbtn/index.rst create mode 100644 examples/widgets/imgbtn/lv_example_imgbtn_1.c diff --git a/examples/assets/imgbtn_left.c b/examples/assets/imgbtn_left.c new file mode 100644 index 000000000..1a1463c9c --- /dev/null +++ b/examples/assets/imgbtn_left.c @@ -0,0 +1,262 @@ +#if defined(LV_LVGL_H_INCLUDE_SIMPLE) +#include "lvgl.h" +#else +#include "lvgl/lvgl.h" +#endif + + +#ifndef LV_ATTRIBUTE_MEM_ALIGN +#define LV_ATTRIBUTE_MEM_ALIGN +#endif + +#ifndef LV_ATTRIBUTE_IMG_IMGBTN_LEFT +#define LV_ATTRIBUTE_IMG_IMGBTN_LEFT +#endif + +const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_IMGBTN_LEFT uint8_t imgbtn_left_map[] = { +#if LV_COLOR_DEPTH == 1 || LV_COLOR_DEPTH == 8 + /*Pixel format: Blue: 2 bit, Green: 3 bit, Red: 3 bit, Alpha 8 bit */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x68, 0x03, 0x68, 0x14, 0x68, 0x23, + 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x68, 0x40, 0x68, 0xb0, 0x64, 0xe0, 0x64, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x70, 0x68, 0xfc, 0x68, 0xff, 0xd6, 0xff, 0xff, 0xff, + 0x68, 0x00, 0x00, 0x00, 0x68, 0x73, 0x68, 0xff, 0xb1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x68, 0x40, 0x68, 0xfc, 0xb2, 0xff, 0xff, 0xff, 0xfa, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x03, 0x68, 0xb0, 0x68, 0xff, 0xff, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x14, 0x64, 0xe0, 0xd6, 0xff, 0xfa, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x24, 0x64, 0xff, 0xfa, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x64, 0xff, 0xf9, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x64, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x64, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xd1, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0xac, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x27, 0x68, 0xff, 0x8c, 0xff, 0xd1, 0xff, 0xf9, 0xff, 0xf5, 0xff, 0xf5, 0xff, 0xf5, 0xff, + 0x68, 0x23, 0x68, 0xff, 0xac, 0xff, 0x8c, 0xff, 0xd1, 0xff, 0xf9, 0xff, 0xf9, 0xff, 0xf5, 0xff, + 0x68, 0x17, 0x68, 0xe4, 0x8c, 0xff, 0xac, 0xff, 0x8c, 0xff, 0xac, 0xff, 0xd1, 0xff, 0xf5, 0xff, + 0x68, 0x07, 0x68, 0xb8, 0x68, 0xff, 0xac, 0xff, 0xac, 0xff, 0xac, 0xff, 0x8c, 0xff, 0x8c, 0xff, + 0x00, 0x00, 0x44, 0x5f, 0x44, 0xff, 0x68, 0xff, 0xac, 0xff, 0xac, 0xff, 0xac, 0xff, 0xac, 0xff, + 0x00, 0x00, 0x00, 0x04, 0x44, 0xc8, 0x44, 0xff, 0x8c, 0xff, 0xac, 0xff, 0xac, 0xff, 0xac, 0xff, + 0x00, 0x00, 0x00, 0x0c, 0x00, 0x40, 0x44, 0xc4, 0x44, 0xff, 0x68, 0xff, 0x8c, 0xff, 0xac, 0xff, + 0x00, 0x00, 0x00, 0x08, 0x00, 0x34, 0x00, 0x54, 0x24, 0x9b, 0x44, 0xfc, 0x44, 0xff, 0x44, 0xff, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x24, 0x00, 0x4f, 0x00, 0x54, 0x00, 0x5b, 0x24, 0x8b, 0x24, 0xb0, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x3b, 0x00, 0x57, 0x00, 0x58, 0x00, 0x58, 0x00, 0x57, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x1b, 0x00, 0x40, 0x00, 0x54, 0x00, 0x58, 0x00, 0x58, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x18, 0x00, 0x34, 0x00, 0x48, 0x00, 0x50, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0b, 0x00, 0x1b, 0x00, 0x27, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +#endif +#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP == 0 + /*Pixel format: Blue: 5 bit, Green: 6 bit, Red: 5 bit, Alpha 8 bit*/ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x61, 0x03, 0xc0, 0x61, 0x14, 0xc0, 0x61, 0x23, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x61, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x61, 0x40, 0xc0, 0x61, 0xb0, 0x80, 0x59, 0xe0, 0x60, 0x59, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x61, 0x70, 0xc0, 0x61, 0xfc, 0x01, 0x6a, 0xff, 0xf0, 0xb4, 0xff, 0x3b, 0xf7, 0xff, + 0x80, 0x69, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x61, 0x73, 0xc0, 0x61, 0xff, 0x2c, 0xa4, 0xff, 0xff, 0xff, 0xff, 0xdc, 0xff, 0xff, 0x17, 0xff, 0xff, + 0x00, 0x00, 0x00, 0xc0, 0x61, 0x40, 0xc0, 0x61, 0xfc, 0x2c, 0xa4, 0xff, 0xde, 0xff, 0xff, 0xcc, 0xed, 0xff, 0x47, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xa0, 0x61, 0x03, 0xc0, 0x61, 0xb0, 0x01, 0x6a, 0xff, 0x7b, 0xff, 0xff, 0x47, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x14, 0x80, 0x59, 0xe0, 0x10, 0xb5, 0xff, 0xec, 0xf5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x24, 0x60, 0x59, 0xff, 0x53, 0xe6, 0xff, 0x04, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0xab, 0xed, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x26, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x25, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x26, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x28, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0x80, 0x59, 0xff, 0x66, 0xc4, 0xff, 0x47, 0xed, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0xa0, 0x59, 0xff, 0x02, 0x93, 0xff, 0x89, 0xe5, 0xff, 0x26, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x27, 0xa0, 0x59, 0xff, 0xe2, 0x92, 0xff, 0x05, 0xb4, 0xff, 0x8a, 0xed, 0xff, 0x47, 0xe5, 0xff, 0x25, 0xe5, 0xff, 0x05, 0xe5, 0xff, + 0xc0, 0x61, 0x23, 0x80, 0x51, 0xff, 0x42, 0x9b, 0xff, 0xe1, 0x92, 0xff, 0x05, 0xb4, 0xff, 0x8a, 0xed, 0xff, 0xa9, 0xed, 0xff, 0x68, 0xed, 0xff, + 0xc0, 0x61, 0x17, 0x80, 0x51, 0xe4, 0xe2, 0x8a, 0xff, 0x43, 0x9b, 0xff, 0xe2, 0x92, 0xff, 0x02, 0x93, 0xff, 0x66, 0xc4, 0xff, 0x49, 0xe5, 0xff, + 0xa0, 0x61, 0x07, 0xa0, 0x59, 0xb8, 0xa0, 0x59, 0xff, 0x63, 0x9b, 0xff, 0x43, 0x9b, 0xff, 0x02, 0x93, 0xff, 0xe1, 0x92, 0xff, 0xc1, 0x8a, 0xff, + 0x00, 0x00, 0x00, 0x80, 0x51, 0x5f, 0x40, 0x49, 0xff, 0x62, 0x72, 0xff, 0x63, 0x9b, 0xff, 0x43, 0x9b, 0xff, 0x43, 0x9b, 0xff, 0x43, 0x9b, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x20, 0x41, 0xc8, 0x20, 0x41, 0xff, 0xc2, 0x82, 0xff, 0x43, 0x9b, 0xff, 0x63, 0x9b, 0xff, 0x43, 0x9b, 0xff, + 0x40, 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x40, 0xe0, 0x30, 0xc4, 0x20, 0x41, 0xff, 0xe1, 0x59, 0xff, 0xc2, 0x82, 0xff, 0x43, 0x9b, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x34, 0x00, 0x00, 0x54, 0xc0, 0x28, 0x9b, 0x20, 0x41, 0xfc, 0x20, 0x41, 0xff, 0x20, 0x41, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x24, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x54, 0x00, 0x00, 0x5b, 0xa0, 0x20, 0x8b, 0xe0, 0x30, 0xb0, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x57, 0x00, 0x00, 0x58, 0x00, 0x00, 0x58, 0x00, 0x00, 0x57, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x40, 0x00, 0x00, 0x54, 0x00, 0x00, 0x58, 0x00, 0x00, 0x58, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x18, 0x00, 0x00, 0x34, 0x00, 0x00, 0x48, 0x00, 0x00, 0x50, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x27, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +#endif +#if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP != 0 + /*Pixel format: Blue: 5 bit Green: 6 bit, Red: 5 bit, Alpha 8 bit BUT the 2 color bytes are swapped*/ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0xc0, 0x03, 0x61, 0xc0, 0x14, 0x61, 0xc0, 0x23, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x61, 0xc0, 0x40, 0x61, 0xc0, 0xb0, 0x59, 0x80, 0xe0, 0x59, 0x60, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0xc0, 0x70, 0x61, 0xc0, 0xfc, 0x6a, 0x01, 0xff, 0xb4, 0xf0, 0xff, 0xf7, 0x3b, 0xff, + 0x69, 0x80, 0x00, 0x00, 0x00, 0x00, 0x61, 0xc0, 0x73, 0x61, 0xc0, 0xff, 0xa4, 0x2c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdc, 0xff, 0xff, 0x17, 0xff, + 0x00, 0x00, 0x00, 0x61, 0xc0, 0x40, 0x61, 0xc0, 0xfc, 0xa4, 0x2c, 0xff, 0xff, 0xde, 0xff, 0xed, 0xcc, 0xff, 0xe5, 0x47, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xa0, 0x03, 0x61, 0xc0, 0xb0, 0x6a, 0x01, 0xff, 0xff, 0x7b, 0xff, 0xe5, 0x47, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x14, 0x59, 0x80, 0xe0, 0xb5, 0x10, 0xff, 0xf5, 0xec, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x24, 0x59, 0x60, 0xff, 0xe6, 0x53, 0xff, 0xe5, 0x04, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xed, 0xab, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x26, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x25, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x26, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xe5, 0x28, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0x80, 0xff, 0xc4, 0x66, 0xff, 0xed, 0x47, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0xa0, 0xff, 0x93, 0x02, 0xff, 0xe5, 0x89, 0xff, 0xe5, 0x26, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x27, 0x59, 0xa0, 0xff, 0x92, 0xe2, 0xff, 0xb4, 0x05, 0xff, 0xed, 0x8a, 0xff, 0xe5, 0x47, 0xff, 0xe5, 0x25, 0xff, 0xe5, 0x05, 0xff, + 0x61, 0xc0, 0x23, 0x51, 0x80, 0xff, 0x9b, 0x42, 0xff, 0x92, 0xe1, 0xff, 0xb4, 0x05, 0xff, 0xed, 0x8a, 0xff, 0xed, 0xa9, 0xff, 0xed, 0x68, 0xff, + 0x61, 0xc0, 0x17, 0x51, 0x80, 0xe4, 0x8a, 0xe2, 0xff, 0x9b, 0x43, 0xff, 0x92, 0xe2, 0xff, 0x93, 0x02, 0xff, 0xc4, 0x66, 0xff, 0xe5, 0x49, 0xff, + 0x61, 0xa0, 0x07, 0x59, 0xa0, 0xb8, 0x59, 0xa0, 0xff, 0x9b, 0x63, 0xff, 0x9b, 0x43, 0xff, 0x93, 0x02, 0xff, 0x92, 0xe1, 0xff, 0x8a, 0xc1, 0xff, + 0x00, 0x00, 0x00, 0x51, 0x80, 0x5f, 0x49, 0x40, 0xff, 0x72, 0x62, 0xff, 0x9b, 0x63, 0xff, 0x9b, 0x43, 0xff, 0x9b, 0x43, 0xff, 0x9b, 0x43, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x41, 0x20, 0xc8, 0x41, 0x20, 0xff, 0x82, 0xc2, 0xff, 0x9b, 0x43, 0xff, 0x9b, 0x63, 0xff, 0x9b, 0x43, 0xff, + 0x08, 0x40, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x40, 0x30, 0xe0, 0xc4, 0x41, 0x20, 0xff, 0x59, 0xe1, 0xff, 0x82, 0xc2, 0xff, 0x9b, 0x43, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x34, 0x00, 0x00, 0x54, 0x28, 0xc0, 0x9b, 0x41, 0x20, 0xfc, 0x41, 0x20, 0xff, 0x41, 0x20, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x24, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x54, 0x00, 0x00, 0x5b, 0x20, 0xa0, 0x8b, 0x30, 0xe0, 0xb0, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x57, 0x00, 0x00, 0x58, 0x00, 0x00, 0x58, 0x00, 0x00, 0x57, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x40, 0x00, 0x00, 0x54, 0x00, 0x00, 0x58, 0x00, 0x00, 0x58, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x18, 0x00, 0x00, 0x34, 0x00, 0x00, 0x48, 0x00, 0x00, 0x50, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x27, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +#endif +#if LV_COLOR_DEPTH == 32 + /*Pixel format: Blue: 8 bit, Green: 8 bit, Red: 8 bit, Alpha: 8 bit*/ + + + + + + + + + + + + + + + + + + + + + + + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x61, 0x03, 0x00, 0x38, 0x5f, 0x14, 0x00, 0x38, 0x5f, 0x23, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x5f, 0x40, 0x00, 0x37, 0x5e, 0xb0, 0x00, 0x30, 0x58, 0xe0, 0x00, 0x2c, 0x55, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x5f, 0x70, 0x00, 0x38, 0x5f, 0xfc, 0x0a, 0x40, 0x66, 0xff, 0x7f, 0x9e, 0xb3, 0xff, 0xdc, 0xe6, 0xee, 0xff, + 0x00, 0x32, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x5f, 0x73, 0x00, 0x38, 0x5f, 0xff, 0x60, 0x84, 0x9e, 0xff, 0xfb, 0xfc, 0xfc, 0xff, 0xe3, 0xf7, 0xff, 0xff, 0xba, 0xe1, 0xf6, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x5f, 0x40, 0x00, 0x38, 0x5f, 0xfc, 0x62, 0x85, 0x9e, 0xff, 0xf1, 0xf9, 0xfd, 0xff, 0x61, 0xba, 0xe9, 0xff, 0x35, 0xa7, 0xe3, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x36, 0x5d, 0x03, 0x00, 0x37, 0x5e, 0xb0, 0x0a, 0x40, 0x65, 0xff, 0xda, 0xed, 0xf8, 0xff, 0x3a, 0xa9, 0xe4, 0xff, 0x28, 0xa1, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x14, 0x00, 0x2f, 0x58, 0xe0, 0x84, 0xa0, 0xb4, 0xff, 0x63, 0xbe, 0xee, 0xff, 0x27, 0xa1, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x24, 0x00, 0x2e, 0x56, 0xff, 0x97, 0xc9, 0xe4, 0xff, 0x22, 0x9f, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x2f, 0x56, 0xff, 0x56, 0xb5, 0xe7, 0xff, 0x27, 0xa1, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2f, 0xa4, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x31, 0x56, 0xff, 0x2b, 0xa3, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x30, 0x56, 0xff, 0x34, 0xa6, 0xe2, 0xff, 0x29, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x30, 0x56, 0xff, 0x3d, 0xa6, 0xdd, 0xff, 0x29, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5f, 0x27, 0x00, 0x32, 0x58, 0xff, 0x31, 0x8c, 0xbe, 0xff, 0x36, 0xaa, 0xe5, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5e, 0x27, 0x00, 0x35, 0x5b, 0xff, 0x0f, 0x61, 0x94, 0xff, 0x4a, 0xaf, 0xe4, 0xff, 0x2e, 0xa4, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x38, 0x5e, 0x27, 0x00, 0x34, 0x58, 0xff, 0x0d, 0x5d, 0x8f, 0xff, 0x27, 0x7f, 0xb2, 0xff, 0x4d, 0xb2, 0xe6, 0xff, 0x35, 0xa7, 0xe3, 0xff, 0x2c, 0xa3, 0xe1, 0xff, 0x2a, 0xa2, 0xe1, 0xff, + 0x00, 0x37, 0x5f, 0x23, 0x00, 0x31, 0x54, 0xff, 0x14, 0x69, 0x9b, 0xff, 0x0c, 0x5c, 0x8e, 0xff, 0x27, 0x7f, 0xb2, 0xff, 0x4f, 0xb1, 0xe5, 0xff, 0x4c, 0xb3, 0xe9, 0xff, 0x44, 0xad, 0xe5, 0xff, + 0x00, 0x38, 0x5e, 0x17, 0x00, 0x31, 0x54, 0xe4, 0x12, 0x5c, 0x87, 0xff, 0x15, 0x67, 0x97, 0xff, 0x0d, 0x5d, 0x8f, 0xff, 0x0f, 0x61, 0x94, 0xff, 0x30, 0x8b, 0xbe, 0xff, 0x48, 0xaa, 0xde, 0xff, + 0x00, 0x36, 0x60, 0x07, 0x00, 0x33, 0x57, 0xb8, 0x04, 0x36, 0x56, 0xff, 0x1a, 0x6d, 0x9c, 0xff, 0x16, 0x68, 0x97, 0xff, 0x11, 0x61, 0x92, 0xff, 0x0c, 0x5c, 0x8d, 0xff, 0x09, 0x58, 0x89, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x50, 0x5f, 0x00, 0x2a, 0x48, 0xff, 0x0d, 0x4b, 0x70, 0xff, 0x18, 0x6b, 0x99, 0xff, 0x18, 0x6a, 0x98, 0xff, 0x17, 0x69, 0x97, 0xff, 0x17, 0x68, 0x97, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x26, 0x41, 0xc8, 0x01, 0x26, 0x41, 0xff, 0x11, 0x57, 0x7e, 0xff, 0x18, 0x6a, 0x97, 0xff, 0x18, 0x6b, 0x99, 0xff, 0x18, 0x6a, 0x98, 0xff, + 0x00, 0x07, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x02, 0x04, 0x40, 0x00, 0x1e, 0x34, 0xc4, 0x00, 0x24, 0x3f, 0xff, 0x08, 0x3c, 0x5c, 0xff, 0x11, 0x57, 0x7f, 0xff, 0x18, 0x69, 0x96, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x54, 0x00, 0x18, 0x29, 0x9b, 0x00, 0x23, 0x3e, 0xfc, 0x00, 0x24, 0x3e, 0xff, 0x00, 0x24, 0x3e, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x54, 0x00, 0x01, 0x02, 0x5b, 0x00, 0x14, 0x22, 0x8b, 0x00, 0x1b, 0x2f, 0xb0, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x57, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x58, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x50, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x27, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +#endif +}; + +const lv_img_dsc_t imgbtn_left = { + .header.always_zero = 0, + .header.w = 8, + .header.h = 50, + .data_size = 400 * LV_IMG_PX_SIZE_ALPHA_BYTE, + .header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA, + .data = imgbtn_left_map, +}; + diff --git a/examples/assets/imgbtn_left.png b/examples/assets/imgbtn_left.png new file mode 100644 index 0000000000000000000000000000000000000000..d42208ef2afc57238aa5089296262468cef55c3d GIT binary patch literal 699 zcmV;s0!00ZP)WFU8GbZ8()Nlj2>E@cM*00JLLL_t(I%k7lSYg0iK z#eXyNUS7UqQ@>C{3SzJ*7%NE7MZ1vVrWChAO)KcSif&xH5d;_RTnPRF{Rc!T-MNwo zZO~$spp9D72GO)J@68(*c`326)s4HJ)rE8B+zaQ<6?EbHFg%)rsdFgbCk-S;hb$K0 z$qOhJ7%_(F)=%=p`=Nhx|!K_!F z8WE5q!1Lj;tFn0O0kyelTC4N;ZUZrK79|8TP9!@1aHd4<*(AET20{WLr6k>Ik{_SE z!}_ax=;rDs2_S)#Z^-5c`}tm(1);j3Q7|wBft_36j5H zSFkJiUjiX^5Eu|D(k`}haEWa1ASG0)Kd{1yUV#CWg7U&UjJ+46)#G5a0oU_+Sz5wQ zW|4Mm^8;JLpgj%oxWn6}WdP0$9Va9;UaN^Zl_BJ6F7HW&6Ny-euPb#H7b_qXiDVLW z`Vg*$3!m!l(Ofo(R0^#P%hek53-3{-W%RKF$i{|$$p`kQ9h7BZhisg%g93Q{nR2F& z(JyQ6k-n5oJZd4O03lFu2U?ow$2#S7lw5VCnfcc6uq{C>V$lg80-OW}1`jg2FUAz2 z?cNbszyNRpu%*Bm=qI0W$aP1U3S15YDoDn hWnApAZQ@^6l3&d!qjA5L~c#`DCC7XMsm# zF#`j)FbFd;%$g$s6l5>)^mS!_%ETpV%*!wSx)~@Wn;8;O;+&tGo0?YwJw^RAjy7=zZc_qs~PwY#|sWF@q@YzOH^U102kK2On*2f0T z)O20W6Oz`*{YTuyL+)7F`@{^hf0Ok8-ujul`?FW@2i7%_oD0`9`?23Yd5phY;kOiH mZK`q-Z=LsUMrYm2UO$*mbc-JkE)w1ZaWFU8GbZ8()Nlj2>E@cM*00KfuL_t(I%k7lCPm@s; z#((#|x8%%4cOpEBggH7e43RLZ1~@~}*p(f-c5a^@e}Ax4DxL4$hrTz=i@JrIcqX!vkW#5A zcdqu^Ge?lfF?9(b(g(x`dSv!~pJbk&6Y*E%!Ho-Y`Y?W^k4^v$V7)AEYKY|Hlbq_m z%>D!24sabn#Rqz%)=sQXu&s-c%psoKy#~;rStX?nem24G;5Qr-1URt<01&ZgcM^pK z*!Bki;Jay%a>aBb0Bh@p8v|-p)NGWis2`duba@1oZ?S31a2 zP9av-1A@{4bf}$pB8`;_U@Eo_+B9K8d-(8iiiMw9tbn7yn3i@N(||7yBcorKh$U%k z4gy6)$&x9S4Dncs@y|09J)fpf6WL`SD?+2@t$FzLCB`@e0s$IZn$cPlpUYCVjNE=h z&a}3*f&!%!#!A1hMrnmoAObVr3%nXz!f_ZJjWGsbtcA>?$7ISSnJ(a! z86Hn@)AjHH)bXxLXaZjP7q`AJfGWdx6m3_QP3ww*FJU0b_3UKVqla QyZ`_I07*qoM6N<$g6Aw_set : item->h_set); if(_LV_FLEX_GET_GROW(main_size)) { grow_sum += _LV_FLEX_GET_GROW(main_size); grow_item_cnt++; } else { - lv_coord_t item_size = get_main_size(item) + item_gap; - if(wrap && t->track_main_size + item_size > max_main_size + item_gap) break; - t->track_main_size += item_size; + lv_coord_t item_size = get_main_size(item); + if(wrap && t->track_main_size + item_size > max_main_size) break; + t->track_main_size += item_size + item_gap; } t->track_cross_size = LV_MAX(get_cross_size(item), t->track_cross_size); t->item_cnt++; @@ -291,7 +291,8 @@ static int32_t find_track_end(lv_obj_t * cont, int32_t item_start_id, lv_coord_t /*Have at least one item in a row*/ if(item && item_id == item_start_id) { - item = get_next_item(cont, f->rev, &item_id); + item = cont->spec_attr->children[item_id]; + get_next_item(cont, f->rev, &item_id); if(item) { t->track_cross_size = get_cross_size(item); t->track_main_size = get_main_size(item); @@ -327,7 +328,7 @@ static void children_repos(lv_obj_t * cont, int32_t item_first_id, int32_t item_ lv_obj_t * item = lv_obj_get_child(cont, item_first_id); /*Reposition the children*/ while(item && item_first_id != item_last_id) { - if(lv_obj_has_flag(item, LV_OBJ_FLAG_LAYOUTABLE) == false) { + if(!lv_obj_has_flag(item, LV_OBJ_FLAG_LAYOUTABLE) || lv_obj_has_flag(item, LV_OBJ_FLAG_HIDDEN)) { item = get_next_item(cont, f->rev, &item_first_id); continue; } @@ -349,7 +350,9 @@ static void children_repos(lv_obj_t * cont, int32_t item_first_id, int32_t item_ lv_coord_t cross_pos = 0; switch(f->item_cross_place) { case LV_FLEX_PLACE_CENTER: - cross_pos = (t->track_cross_size - area_get_cross_size(&item->coords)) / 2; + /* Round the up the cross size to avoid rounding error when dividing by 2 + * The issue comes up e,g, with column direction with center cross direction if an element's width changes*/ + cross_pos = (((t->track_cross_size + 1) & (~1)) - area_get_cross_size(&item->coords)) / 2; break; case LV_FLEX_PLACE_END: cross_pos = t->track_cross_size - area_get_cross_size(&item->coords); @@ -364,10 +367,12 @@ static void children_repos(lv_obj_t * cont, int32_t item_first_id, int32_t item_ diff_y += row ? cross_pos : main_pos; if(diff_x || diff_y) { + lv_obj_invalidate(item); item->coords.x1 += diff_x; item->coords.x2 += diff_x; item->coords.y1 += diff_y; item->coords.y2 += diff_y; + lv_obj_invalidate(item); lv_obj_move_children_by(item, diff_x, diff_y); } diff --git a/src/extra/themes/default/lv_theme_default.c b/src/extra/themes/default/lv_theme_default.c index 1d5b89de6..7db84a4b5 100644 --- a/src/extra/themes/default/lv_theme_default.c +++ b/src/extra/themes/default/lv_theme_default.c @@ -124,7 +124,7 @@ typedef struct { #endif #if LV_USE_CHECKBOX - lv_style_t cb_marker, cb_marker_checked; + lv_style_t cb_marker, cb_marker_checked, cb_bg_outline_pad; #endif #if LV_USE_DROPDOWN @@ -147,9 +147,17 @@ typedef struct { lv_style_t calendar_day; #endif +#if LV_USE_MSGBOX + lv_style_t msgbox_btns_bg; +#endif + #if LV_USE_LIST lv_style_t list_bg, list_btn, list_item_grow, list_label; #endif + +#if LV_USE_LED + lv_style_t led; +#endif } my_theme_styles_t; typedef struct { @@ -244,6 +252,7 @@ static void style_init(void) style_init_reset(&styles->edit_outline); lv_style_set_outline_color(&styles->edit_outline, theme.color_secondary); + lv_style_set_outline_width(&styles->edit_outline, OUTLINE_WIDTH); lv_style_set_outline_opa(&styles->edit_outline, LV_OPA_50); style_init_reset(&styles->btn); @@ -366,6 +375,9 @@ static void style_init(void) lv_style_set_content_text(&styles->cb_marker_checked, LV_SYMBOL_OK); lv_style_set_content_color(&styles->cb_marker_checked, LV_COLOR_WHITE); lv_style_set_content_font(&styles->cb_marker_checked, theme.font_small); + + style_init_reset(&styles->cb_bg_outline_pad); + lv_style_set_outline_pad(&styles->cb_bg_outline_pad, LV_DPX(5)); #endif #if LV_USE_CHART @@ -425,6 +437,12 @@ static void style_init(void) lv_style_set_bg_opa(&styles->calendar_day, LV_OPA_COVER); #endif +#if LV_USE_MSGBOX + /*To add space for the buttons outline*/ + style_init_reset(&styles->msgbox_btns_bg); + lv_style_set_pad_all(&styles->msgbox_btns_bg, OUTLINE_WIDTH); +#endif + #if LV_USE_LIST style_init_reset(&styles->list_bg); lv_style_set_pad_hor(&styles->list_bg, PAD_DEF); @@ -441,7 +459,18 @@ static void style_init(void) style_init_reset(&styles->list_item_grow); lv_style_set_transform_width(&styles->list_item_grow, PAD_DEF); +#endif + +#if LV_USE_LED + lv_style_init(&styles->led); + lv_style_set_bg_opa(&styles->led, LV_OPA_COVER); + lv_style_set_bg_color(&styles->led, LV_COLOR_WHITE); + lv_style_set_bg_grad_color(&styles->led, LV_COLOR_GRAY); + lv_style_set_radius(&styles->led, LV_RADIUS_CIRCLE); + lv_style_set_shadow_width(&styles->led, LV_DPX(15)); + lv_style_set_shadow_color(&styles->led, LV_COLOR_WHITE); + lv_style_set_shadow_spread(&styles->led, LV_DPX(5)); #endif } @@ -537,9 +566,10 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_list_class)) { lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->bg_color_panel); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->list_btn); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->bg_color_primary); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->list_item_grow); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->list_item_grow); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->pressed); - lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_CHECKED, &styles->bg_color_primary); return; } #endif @@ -550,6 +580,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->transition_normal); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->grow); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_CHECKED, &styles->bg_color_secondary); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DISABLED, &styles->disabled); } #endif @@ -557,10 +588,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) else if(lv_obj_check_type(obj, &lv_btnmatrix_class)) { #if LV_USE_MSGBOX if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class)) { + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->msgbox_btns_bg); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->pad_gap); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->btn); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_PRESSED, &styles->pressed); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_CHECKED, &styles->bg_color_primary); + lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_CHECKED, &styles->bg_color_primary); + lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_FOCUSED, &styles->focus_outline); return; } #endif @@ -584,6 +618,8 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) else if(lv_obj_check_type(obj, &lv_bar_class)) { lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->bg_color_gray); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->circle); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->focus_outline); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_EDITED, &styles->edit_outline); lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->bg_color_primary); lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->circle); } @@ -595,6 +631,8 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->circle); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->transition_delayed); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->transition_normal); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->focus_outline); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_EDITED, &styles->edit_outline); lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->bg_color_primary); lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->circle); lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->knob); @@ -620,6 +658,8 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) #if LV_USE_CHECKBOX else if(lv_obj_check_type(obj, &lv_checkbox_class)) { lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->pad_gap); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->focus_outline); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->cb_bg_outline_pad); lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_DISABLED, &styles->disabled); lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_DEFAULT, &styles->cb_marker); lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_CHECKED, &styles->bg_color_primary); @@ -636,6 +676,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->bg_color_gray); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->circle); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DISABLED, &styles->disabled); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->focus_outline); lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->bg_color_primary); lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DEFAULT, &styles->circle); lv_obj_add_style(obj, LV_PART_INDICATOR, LV_STATE_DISABLED, &styles->disabled); @@ -665,6 +706,8 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->anim); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->line_space_large); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->text_align_center); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->focus_outline); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_EDITED, &styles->edit_outline); lv_obj_add_style(obj, LV_PART_SELECTED, LV_STATE_DEFAULT, &styles->bg_color_primary); } #endif @@ -679,6 +722,8 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_PRESSED, &styles->grow); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_CHECKED, &styles->ddlist_flip); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->transition_normal); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->focus_outline); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_EDITED, &styles->edit_outline); } else if(lv_obj_check_type(obj, &lv_dropdown_list_class)) { lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card); @@ -721,6 +766,8 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) #if LV_USE_TEXTAREA else if(lv_obj_check_type(obj, &lv_textarea_class)) { lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->focus_outline); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_EDITED, &styles->edit_outline); lv_obj_add_style(obj, LV_PART_SCROLLBAR, LV_STATE_DEFAULT, &styles->scrollbar); lv_obj_add_style(obj, LV_PART_SCROLLBAR, LV_STATE_SCROLLED, &styles->scrollbar_scrolled); lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_FOCUSED, &styles->ta_cursor); @@ -732,9 +779,12 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) else if(lv_obj_check_type(obj, &lv_calendar_class)) { lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->pad_small); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->focus_outline); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_EDITED, &styles->edit_outline); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->calendar_day); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_PRESSED, &styles->pressed); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DISABLED, &styles->disabled); + lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_FOCUSED, &styles->focus_outline); } #endif @@ -742,10 +792,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) else if(lv_obj_check_type(obj, &lv_keyboard_class)) { lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->scr); lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->pad_small); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->focus_outline); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_EDITED, &styles->edit_outline); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->btn); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_DEFAULT, &styles->bg_color_panel); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_PRESSED, &styles->pressed); lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_CHECKED, &styles->bg_color_gray); + lv_obj_add_style(obj, LV_PART_ITEMS, LV_STATE_FOCUSED, &styles->focus_outline); } #endif #if LV_USE_LIST @@ -766,6 +819,8 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) #if LV_USE_SPINBOX else if(lv_obj_check_type(obj, &lv_spinbox_class)) { lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->card); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_FOCUS_KEY, &styles->focus_outline); + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_EDITED, &styles->edit_outline); lv_obj_add_style(obj, LV_PART_MARKER, LV_STATE_DEFAULT, &styles->bg_color_gray); } #endif @@ -785,8 +840,16 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) else if(lv_obj_check_type(obj, &lv_colorwheel_class)) { lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->pad_normal); lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->bg_color_panel); + lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->pad_normal); + lv_obj_add_style(obj, LV_PART_KNOB, LV_STATE_DEFAULT, &styles->bg_color_panel); } #endif + +#if LV_USE_LED + else if(lv_obj_check_type(obj, &lv_led_class)) { + lv_obj_add_style(obj, LV_PART_MAIN, LV_STATE_DEFAULT, &styles->led); + } +#endif } /********************** diff --git a/src/extra/widgets/calendar/lv_calendar.c b/src/extra/widgets/calendar/lv_calendar.c index 9a65699f9..a544d068c 100644 --- a/src/extra/widgets/calendar/lv_calendar.c +++ b/src/extra/widgets/calendar/lv_calendar.c @@ -41,7 +41,7 @@ const lv_obj_class_t lv_calendar_class = { }; -static const char * day_names_def[7] = LV_CALENDAR_DEFAULT_MONTH_NAMES; +static const char * day_names_def[7] = LV_CALENDAR_DEFAULT_DAY_NAMES; /********************** * MACROS diff --git a/src/extra/widgets/imgbtn/lv_imgbtn.c b/src/extra/widgets/imgbtn/lv_imgbtn.c index 20cb76170..d7af625c6 100644 --- a/src/extra/widgets/imgbtn/lv_imgbtn.c +++ b/src/extra/widgets/imgbtn/lv_imgbtn.c @@ -1,574 +1,384 @@ -///** -// * @file lv_imgbtn.c -// * -// */ -// -///********************* -// * INCLUDES -// *********************/ -// -//#include "../lv_misc/lv_assert.h" -//#include "lv_imgbtn.h" -//#include "lv_label.h" -// -//#if LV_USE_IMGBTN != 0 -// -///********************* -// * DEFINES -// *********************/ -//#define MY_CLASS "lv_imgbtn" -// -///********************** -// * TYPEDEFS -// **********************/ -// -///********************** -// * STATIC PROTOTYPES -// **********************/ -//static lv_draw_res_t lv_imgbtn_draw(lv_obj_t * imgbtn, const lv_area_t * clip_area, lv_draw_mode_t mode); -//static lv_res_t lv_imgbtn_signal(lv_obj_t * imgbtn, lv_signal_t sign, void * param); -//static void refr_img(lv_obj_t * imgbtn); -//static lv_imgbtn_state_t suggest_state(lv_obj_t * imgbtn, lv_imgbtn_state_t state); -//lv_imgbtn_state_t get_state(const lv_obj_t * imgbtn); -// -///********************** -// * STATIC VARIABLES -// **********************/ -//static lv_signal_cb_t ancestor_signal; -//static lv_draw_cb_t ancestor_draw; -// -///********************** -// * MACROS -// **********************/ -// -///********************** -// * GLOBAL FUNCTIONS -// **********************/ -// -///** -// * Create a image button object -// * @param par pointer to an object, it will be the parent of the new image button -// * @param copy pointer to a image button object, if not NULL then the new object will be copied from -// * it -// * @return pointer to the created image button -// */ -//lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy) -//{ -// LV_LOG_TRACE("image button create started"); -// -// /*Create the ancestor of image button*/ -// lv_obj_t * imgbtn = lv_btn_create(par, copy); -// LV_ASSERT_MALLOC(imgbtn); -// if(imgbtn == NULL) return NULL; -// -// /*Allocate the image button type specific extended data*/ -// lv_imgbtn_ext_t * ext = lv_obj_allocate_ext_attr(imgbtn, sizeof(lv_imgbtn_ext_t)); -// LV_ASSERT_MALLOC(ext); -// if(ext == NULL) { -// lv_obj_del(imgbtn); -// return NULL; -// } -// -// if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(imgbtn); -// if(ancestor_draw == NULL) ancestor_draw = lv_obj_get_draw_cb(imgbtn); -// -// /*Initialize the allocated 'ext' */ -// lv_memset_00((void *)ext->img_src_mid, sizeof(ext->img_src_mid)); -//#if LV_IMGBTN_TILED -// lv_memset_00(ext->img_src_left, sizeof(ext->img_src_left)); -// lv_memset_00(ext->img_src_right, sizeof(ext->img_src_right)); -//#endif -// ext->tiled = 0; -// -// ext->act_cf = LV_IMG_CF_UNKNOWN; -// -// /*The signal and draw functions are not copied so set them here*/ -// lv_obj_set_signal_cb(imgbtn, lv_imgbtn_signal); -// lv_obj_set_draw_cb(imgbtn, lv_imgbtn_draw); -// -// /*Init the new image button image button*/ -// if(copy == NULL) { -// lv_theme_apply(imgbtn, LV_THEME_IMGBTN); -// } -// /*Copy an existing image button*/ -// else { -// lv_imgbtn_ext_t * copy_ext = lv_obj_get_ext_attr(copy); -// lv_memcpy((void *)ext->img_src_mid, copy_ext->img_src_mid, sizeof(ext->img_src_mid)); -//#if LV_IMGBTN_TILED -// lv_memcpy((void *)ext->img_src_left, copy_ext->img_src_left, sizeof(ext->img_src_left)); -// lv_memcpy((void *)ext->img_src_right, copy_ext->img_src_right, sizeof(ext->img_src_right)); -//#endif -// ext->tiled = copy_ext->tiled; -// /*Refresh the style with new signal function*/ -// lv_obj_refresh_style(imgbtn, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); -// } -// -// LV_LOG_INFO("image button created"); -// -// return imgbtn; -//} -// -///*===================== -// * Setter functions -// *====================*/ -// -///** -// * Set images for a state of the image button -// * @param imgbtn pointer to an image button object -// * @param state for which state set the new image -// * @param src pointer to an image source (a C array or path to a file) -// */ -//void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_imgbtn_state_t state, const void * src) -//{ -// LV_ASSERT_OBJ(imgbtn, MY_CLASS); -// -// lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn); -// -// ext->img_src_mid[state] = src; -//#if LV_IMGBTN_TILED -// ext->img_src_left[state] = NULL; -// ext->img_src_right[state] = NULL; -//#endif -// ext->tiled = 0; -// refr_img(imgbtn); -//} -// -//#if LV_IMGBTN_TILED -///** -// * Set images for a state of the image button -// * @param imgbtn pointer to an image button object -// * @param state for which state set the new image -// * @param src_left pointer to an image source for the left side of the button (a C array or path to -// * a file) -// * @param src_mid pointer to an image source for the middle of the button (ideally 1px wide) (a C -// * array or path to a file) -// * @param src_right pointer to an image source for the right side of the button (a C array or path -// * to a file) -// */ -//void lv_imgbtn_set_src_tiled(lv_obj_t * imgbtn, lv_imgbtn_state_t state, const void * src_left, const void * src_mid, -// const void * src_right) -//{ -// LV_ASSERT_OBJ(imgbtn, MY_CLASS); -// -// if(lv_img_src_get_type(src_left) == LV_IMG_SRC_SYMBOL || -// lv_img_src_get_type(src_mid) == LV_IMG_SRC_SYMBOL || -// lv_img_src_get_type(src_right) == LV_IMG_SRC_SYMBOL) { -// LV_LOG_WARN("lv_imgbtn_set_src: symbols are not supported in tiled mode"); -// return; -// } -// -// lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn); -// -// ext->img_src_left[state] = src_left; -// ext->img_src_mid[state] = src_mid; -// ext->img_src_right[state] = src_right; -// -// ext->tiled = 1; -// -// refr_img(imgbtn); -//} -// -//#endif -// -///*===================== -// * Getter functions -// *====================*/ -// -///** -// * Get the images 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`) ` -// * @return pointer to an image source (a C array or path to a file) -// */ -//const void * lv_imgbtn_get_src(lv_obj_t * imgbtn, lv_imgbtn_state_t state) -//{ -// LV_ASSERT_OBJ(imgbtn, MY_CLASS); -// -// lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn); -// -// return ext->img_src_mid[state]; -//} -//#if LV_IMGBTN_TILED -// -///** -// * 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`) ` -// * @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) -//{ -// LV_ASSERT_OBJ(imgbtn, MY_CLASS); -// -// lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn); -// -// return ext->img_src_left[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`) ` -// * @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) -//{ -// LV_ASSERT_OBJ(imgbtn, MY_CLASS); -// -// lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn); -// -// return ext->img_src_mid[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`) ` -// * @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) -//{ -// LV_ASSERT_OBJ(imgbtn, MY_CLASS); -// -// lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn); -// -// return ext->img_src_right[state]; -//} -// -//#endif -// -///*===================== -// * Other functions -// *====================*/ -// -///* -// * New object specific "other" functions come here -// */ -// -///********************** -// * STATIC FUNCTIONS -// **********************/ -// -///** -// * Handle the drawing related tasks of the image buttons -// * @param imgbtn pointer to an object -// * @param clip_area the object will be drawn only in this area -// * @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area -// * (return 'true' if yes) -// * LV_DRAW_DRAW: draw the object (always return 'true') -// * LV_DRAW_DRAW_POST: drawing after every children are drawn -// * @param return an element of `lv_draw_res_t` -// */ -//static lv_draw_res_t lv_imgbtn_draw(lv_obj_t * imgbtn, const lv_area_t * clip_area, lv_draw_mode_t mode) -//{ -// /*Return false if the object is not covers the mask_p area*/ -// if(mode == LV_DRAW_COVER_CHK) { -// lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn); -// lv_draw_res_t cover = LV_DRAW_RES_NOT_COVER; -// if(ext->act_cf == LV_IMG_CF_TRUE_COLOR || ext->act_cf == LV_IMG_CF_RAW) { -// cover = _lv_area_is_in(clip_area, &imgbtn->coords, 0) ? LV_DRAW_RES_COVER : LV_DRAW_RES_NOT_COVER; -// } -// -// return cover; -// } -// /*Draw the object*/ -// else if(mode == LV_DRAW_DRAW_MAIN) { -// lv_area_t img_coords; -// -// lv_obj_get_coords(imgbtn, &img_coords); -// -// lv_draw_rect_dsc_t bg_dsc; -// lv_draw_rect_dsc_init(&bg_dsc); -// lv_obj_init_draw_rect_dsc(imgbtn, LV_IMGBTN_PART_MAIN, &bg_dsc); -// -// /*If the border is drawn later disable loading its properties*/ -// if(lv_obj_get_style_border_post(imgbtn, LV_OBJ_PART_MAIN)) { -// bg_dsc.border_opa = LV_OPA_TRANSP; -// } -// -// lv_area_t bg_coords; -// lv_area_copy(&bg_coords, &img_coords); -// bg_coords.x1 -= lv_obj_get_style_pad_left(imgbtn, LV_IMGBTN_PART_MAIN); -// bg_coords.x2 += lv_obj_get_style_pad_right(imgbtn, LV_IMGBTN_PART_MAIN); -// bg_coords.y1 -= lv_obj_get_style_pad_top(imgbtn, LV_IMGBTN_PART_MAIN); -// bg_coords.y2 += lv_obj_get_style_pad_bottom(imgbtn, LV_IMGBTN_PART_MAIN); -// -// lv_draw_rect(&bg_coords, clip_area, &bg_dsc); -// -// if(lv_obj_get_style_clip_corner(imgbtn, LV_OBJ_PART_MAIN)) { -// lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t)); -// -// lv_coord_t r = lv_obj_get_style_radius(imgbtn, LV_OBJ_PART_MAIN); -// -// lv_draw_mask_radius_init(mp, &bg_coords, r, false); -// /*Add the mask and use `img+8` as custom id. Don't use `obj` directly because it might be used by the user*/ -// lv_draw_mask_add(mp, imgbtn + 8); -// } -// -// /*Just draw an image*/ -// lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn); -// lv_imgbtn_state_t state = suggest_state(imgbtn, get_state(imgbtn)); -// -// /*Simply draw the middle src if no tiled*/ -// if(!ext->tiled) { -// const void * src = ext->img_src_mid[state]; -// if(lv_img_src_get_type(src) == LV_IMG_SRC_SYMBOL) { -// lv_draw_label_dsc_t label_dsc; -// lv_draw_label_dsc_init(&label_dsc); -// lv_obj_init_draw_label_dsc(imgbtn, LV_IMGBTN_PART_MAIN, &label_dsc); -// lv_draw_label(&imgbtn->coords, clip_area, &label_dsc, src, NULL); -// } -// else { -// lv_draw_img_dsc_t img_dsc; -// lv_draw_img_dsc_init(&img_dsc); -// lv_obj_init_draw_img_dsc(imgbtn, LV_IMGBTN_PART_MAIN, &img_dsc); -// lv_draw_img(&imgbtn->coords, clip_area, src, &img_dsc); -// } -// } -// else { -//#if LV_IMGBTN_TILED -// const void * src = ext->img_src_left[state]; -// if(lv_img_src_get_type(src) == LV_IMG_SRC_SYMBOL) { -// LV_LOG_WARN("lv_imgbtn_draw: SYMBOLS are not supported in tiled mode") -// return LV_DRAW_RES_OK; -// } -// -// lv_coord_t w = lv_obj_get_style_transform_width(imgbtn, LV_OBJ_PART_MAIN); -// lv_coord_t h = lv_obj_get_style_transform_height(imgbtn, LV_OBJ_PART_MAIN); -// lv_area_t coords; -// lv_area_copy(&coords, &imgbtn->coords); -// coords.x1 -= w; -// coords.x2 += w; -// coords.y1 -= h; -// coords.y2 += h; -// -// lv_draw_img_dsc_t img_dsc; -// lv_draw_img_dsc_init(&img_dsc); -// lv_obj_init_draw_img_dsc(imgbtn, LV_IMGBTN_PART_MAIN, &img_dsc); -// -// lv_img_header_t header; -// lv_area_t coords_part; -// lv_coord_t left_w = 0; -// lv_coord_t right_w = 0; -// -// if(src) { -// lv_img_decoder_get_info(src, &header); -// left_w = header.w; -// coords_part.x1 = coords.x1; -// coords_part.y1 = coords.y1; -// coords_part.x2 = coords.x1 + header.w - 1; -// coords_part.y2 = coords.y1 + header.h - 1; -// lv_draw_img(&coords_part, clip_area, src, &img_dsc); -// } -// -// src = ext->img_src_right[state]; -// if(src) { -// lv_img_decoder_get_info(src, &header); -// right_w = header.w; -// coords_part.x1 = coords.x2 - header.w + 1; -// coords_part.y1 = coords.y1; -// coords_part.x2 = coords.x2; -// coords_part.y2 = coords.y1 + header.h - 1; -// lv_draw_img(&coords_part, clip_area, src, &img_dsc); -// } -// -// src = ext->img_src_mid[state]; -// if(src) { -// lv_area_t clip_center_area; -// clip_center_area.x1 = coords.x1 + left_w; -// clip_center_area.x2 = coords.x2 - right_w; -// clip_center_area.y1 = coords.y1; -// clip_center_area.y2 = coords.y2; -// -// bool comm_res; -// comm_res = _lv_area_intersect(&clip_center_area, &clip_center_area, clip_area); -// if(comm_res) { -// lv_coord_t obj_w = lv_obj_get_width(imgbtn); -// lv_coord_t i; -// lv_img_decoder_get_info(src, &header); -// -// coords_part.x1 = coords.x1 + left_w; -// coords_part.y1 = coords.y1; -// coords_part.x2 = coords_part.x1 + header.w - 1; -// coords_part.y2 = coords_part.y1 + header.h - 1; -// -// for(i = 0; i < obj_w - right_w - left_w; i += header.w) { -// -// lv_draw_img(&coords_part, &clip_center_area, src, &img_dsc); -// coords_part.x1 = coords_part.x2 + 1; -// coords_part.x2 += header.w; -// } -// } -// } -//#endif -// } -// } -// /*Post draw when the children are drawn*/ -// else if(mode == LV_DRAW_DRAW_POST) { -// if(lv_obj_get_style_clip_corner(imgbtn, LV_OBJ_PART_MAIN)) { -// lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(imgbtn + 8); -// lv_mem_buf_release(param); -// } -// -// lv_draw_rect_dsc_t draw_dsc; -// lv_draw_rect_dsc_init(&draw_dsc); -// -// /*If the border is drawn later disable loading other properties*/ -// if(lv_obj_get_style_border_post(imgbtn, LV_OBJ_PART_MAIN)) { -// draw_dsc.bg_opa = LV_OPA_TRANSP; -// draw_dsc.pattern_opa = LV_OPA_TRANSP; -// draw_dsc.shadow_opa = LV_OPA_TRANSP; -// lv_obj_init_draw_rect_dsc(imgbtn, LV_OBJ_PART_MAIN, &draw_dsc); -// -// lv_area_t bg_coords; -// lv_area_copy(&bg_coords, &imgbtn->coords); -// bg_coords.x1 -= lv_obj_get_style_pad_left(imgbtn, LV_IMGBTN_PART_MAIN); -// bg_coords.x2 += lv_obj_get_style_pad_right(imgbtn, LV_IMGBTN_PART_MAIN); -// bg_coords.y1 -= lv_obj_get_style_pad_top(imgbtn, LV_IMGBTN_PART_MAIN); -// bg_coords.y2 += lv_obj_get_style_pad_bottom(imgbtn, LV_IMGBTN_PART_MAIN); -// -// lv_draw_rect(&bg_coords, clip_area, &draw_dsc); -// } -// } -// -// return LV_DRAW_RES_OK; -//} -// -///** -// * Signal function of the image button -// * @param imgbtn pointer to a image button object -// * @param sign a signal type from lv_signal_t enum -// * @param param pointer to a signal specific variable -// * @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted -// */ -//static lv_res_t lv_imgbtn_signal(lv_obj_t * imgbtn, lv_signal_t sign, void * param) -//{ -// lv_res_t res; -// -// /* Include the ancient signal function */ -// res = ancestor_signal(imgbtn, sign, param); -// if(res != LV_RES_OK) return res; -// if(sign == LV_SIGNAL_GET_TYPE) { -// return _lv_obj_handle_get_type_signal(param, MY_CLASS); -// } -// else if(sign == LV_SIGNAL_STYLE_CHG) { -// /* If the style changed then the button was clicked, released etc. so probably the state was -// * changed as well Set the new image for the new state.*/ -// refr_img(imgbtn); -// } -// else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { -// /*Handle the padding of the background*/ -// lv_coord_t left = lv_obj_get_style_pad_left(imgbtn, LV_IMGBTN_PART_MAIN); -// lv_coord_t right = lv_obj_get_style_pad_right(imgbtn, LV_IMGBTN_PART_MAIN); -// lv_coord_t top = lv_obj_get_style_pad_top(imgbtn, LV_IMGBTN_PART_MAIN); -// lv_coord_t bottom = lv_obj_get_style_pad_bottom(imgbtn, LV_IMGBTN_PART_MAIN); -// -// lv_coord_t * s = param; -// *s = LV_MAX(*s, left); -// *s = LV_MAX(*s, right); -// *s = LV_MAX(*s, top); -// *s = LV_MAX(*s, bottom); -// } -// else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) { -// refr_img(imgbtn); -// } -// else if(sign == LV_SIGNAL_CLEANUP) { -// /*Nothing to cleanup. (No dynamically allocated memory in 'ext')*/ -// } -// -// return res; -//} -// -//static void refr_img(lv_obj_t * imgbtn) -//{ -// lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn); -// lv_imgbtn_state_t state = suggest_state(imgbtn, get_state(imgbtn)); -// lv_img_header_t header; -// -// const void * src = ext->img_src_mid[state]; -// if(src == NULL) return; -// -// lv_res_t info_res = LV_RES_OK; -// if(lv_img_src_get_type(src) == LV_IMG_SRC_SYMBOL) { -// const lv_font_t * font = lv_obj_get_style_text_font(imgbtn, LV_IMGBTN_PART_MAIN); -// header.h = lv_font_get_line_height(font); -// header.w = _lv_txt_get_width(src, (uint16_t)strlen(src), font, 0, LV_TEXT_FLAG_NONE); -// header.always_zero = 0; -// header.cf = LV_IMG_CF_ALPHA_1BIT; -// } -// else { -// info_res = lv_img_decoder_get_info(src, &header); -// } -// -// if(info_res == LV_RES_OK) { -// ext->act_cf = header.cf; -// if(ext->tiled) lv_obj_set_height(imgbtn, header.h); /*Keep the sure defined width*/ -// else lv_obj_set_size(imgbtn, header.w, header.h); -// } -// else { -// ext->act_cf = LV_IMG_CF_UNKNOWN; -// } -// -// lv_obj_invalidate(imgbtn); -//} -// -///** -// * If `src` is not defined for the current state try to get a state which is related to the current but has `src`. -// * E.g. if the PRESSED src is not set but the RELEASED does, use the RELEASED. -// * @param imgbtn pointer to an image button -// * @param state the state to convert -// * @return the suggested state -// */ -//static lv_imgbtn_state_t suggest_state(lv_obj_t * imgbtn, lv_imgbtn_state_t state) -//{ -// lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn); -// if(ext->img_src_mid[state] == NULL) { -// switch(state) { -// case LV_IMGBTN_STATE_PRESSED: -// if(ext->img_src_mid[LV_IMGBTN_STATE_RELEASED]) return LV_IMGBTN_STATE_RELEASED; -// break; -// case LV_IMGBTN_STATE_CHECKED_RELEASED: -// if(ext->img_src_mid[LV_IMGBTN_STATE_RELEASED]) return LV_IMGBTN_STATE_RELEASED; -// break; -// case LV_IMGBTN_STATE_CHECKED_PRESSED: -// if(ext->img_src_mid[LV_IMGBTN_STATE_CHECKED_RELEASED]) return LV_IMGBTN_STATE_CHECKED_RELEASED; -// if(ext->img_src_mid[LV_IMGBTN_STATE_PRESSED]) return LV_IMGBTN_STATE_PRESSED; -// if(ext->img_src_mid[LV_IMGBTN_STATE_RELEASED]) return LV_IMGBTN_STATE_RELEASED; -// break; -// case LV_IMGBTN_STATE_DISABLED: -// if(ext->img_src_mid[LV_IMGBTN_STATE_RELEASED]) return LV_IMGBTN_STATE_RELEASED; -// break; -// case LV_IMGBTN_STATE_CHECKED_DISABLED: -// if(ext->img_src_mid[LV_IMGBTN_STATE_CHECKED_RELEASED]) return LV_IMGBTN_STATE_CHECKED_RELEASED; -// if(ext->img_src_mid[LV_IMGBTN_STATE_RELEASED]) return LV_IMGBTN_STATE_RELEASED; -// break; -// default: -// break; -// } -// } -// -// return state; -//} -// -//lv_imgbtn_state_t get_state(const lv_obj_t * imgbtn) -//{ -// LV_ASSERT_OBJ(imgbtn, MY_CLASS); -// -// lv_state_t obj_state = lv_obj_get_state(imgbtn); -// -// if(obj_state & LV_STATE_DISABLED) { -// if(obj_state & LV_STATE_CHECKED) return LV_IMGBTN_STATE_CHECKED_DISABLED; -// else return LV_IMGBTN_STATE_DISABLED; -// } -// -// if(obj_state & LV_STATE_CHECKED) { -// if(obj_state & LV_STATE_PRESSED) return LV_IMGBTN_STATE_CHECKED_PRESSED; -// else return LV_IMGBTN_STATE_CHECKED_RELEASED; -// } -// else { -// if(obj_state & LV_STATE_PRESSED) return LV_IMGBTN_STATE_PRESSED; -// else return LV_IMGBTN_STATE_RELEASED; -// } -//} -// -//#endif +/** + * @file lv_imgbtn.c + * + */ + +/********************* + * INCLUDES + *********************/ + +#include "lv_imgbtn.h" + +#if LV_USE_IMGBTN != 0 + +/********************* + * DEFINES + *********************/ +#define MY_CLASS &lv_imgbtn_class + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * STATIC PROTOTYPES + **********************/ +static void lv_imgbtn_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static lv_draw_res_t lv_imgbtn_draw(lv_obj_t * imgbtn, const lv_area_t * clip_area, lv_draw_mode_t mode); +static lv_res_t lv_imgbtn_signal(lv_obj_t * imgbtn, lv_signal_t sign, void * param); +static void refr_img(lv_obj_t * imgbtn); +static lv_imgbtn_state_t suggest_state(lv_obj_t * imgbtn, lv_imgbtn_state_t state); +lv_imgbtn_state_t get_state(const lv_obj_t * imgbtn); + +/********************** + * STATIC VARIABLES + **********************/ +const lv_obj_class_t lv_imgbtn_class = { + .base_class = &lv_obj_class, + .instance_size = sizeof(lv_imgbtn_t), + .constructor_cb = lv_imgbtn_constructor, + .signal_cb = lv_imgbtn_signal, + .draw_cb = lv_imgbtn_draw, +}; + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +/** + * Create a image button object + * @param par pointer to an object, it will be the parent of the new image button + * @param copy pointer to a image button object, if not NULL then the new object will be copied from + * it + * @return pointer to the created image button + */ +lv_obj_t * lv_imgbtn_create(lv_obj_t * parent) +{ + return lv_obj_create_from_class(&lv_imgbtn_class, parent, NULL); +} + +/*===================== + * Setter functions + *====================*/ + +/** + * Set images for a state of the image button + * @param imgbtn pointer to an image button object + * @param state for which state set the new image + * @param src_left pointer to an image source for the left side of the button (a C array or path to + * a file) + * @param src_mid pointer to an image source for the middle of the button (ideally 1px wide) (a C + * array or path to a file) + * @param src_right pointer to an image source for the right side of the button (a C array or path + * to a file) + */ +void lv_imgbtn_set_src(lv_obj_t * obj, lv_imgbtn_state_t state, const void * src_left, const void * src_mid, + const void * src_right) +{ + LV_ASSERT_OBJ(obj, MY_CLASS); + + if(lv_img_src_get_type(src_left) == LV_IMG_SRC_SYMBOL || + lv_img_src_get_type(src_mid) == LV_IMG_SRC_SYMBOL || + lv_img_src_get_type(src_right) == LV_IMG_SRC_SYMBOL) { + LV_LOG_WARN("lv_imgbtn_set_src: symbols are not supported in tiled mode"); + return; + } + + lv_imgbtn_t * imgbtn = (lv_imgbtn_t *) obj; + + imgbtn->img_src_left[state] = src_left; + imgbtn->img_src_mid[state] = src_mid; + imgbtn->img_src_right[state] = src_right; + + refr_img(obj); +} + +/*===================== + * Getter functions + *====================*/ + + +/** + * 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`) ` + * @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) +{ + LV_ASSERT_OBJ(obj, MY_CLASS); + + lv_imgbtn_t * imgbtn = (lv_imgbtn_t *) obj; + + return imgbtn->img_src_left[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`) ` + * @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) +{ + LV_ASSERT_OBJ(obj, MY_CLASS); + lv_imgbtn_t * imgbtn = (lv_imgbtn_t *) obj; + + return imgbtn->img_src_mid[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`) ` + * @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) +{ + LV_ASSERT_OBJ(obj, MY_CLASS); + lv_imgbtn_t * imgbtn = (lv_imgbtn_t *) obj; + + return imgbtn->img_src_right[state]; +} + + +/********************** + * STATIC FUNCTIONS + **********************/ + +static void lv_imgbtn_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) +{ + lv_imgbtn_t * imgbtn = (lv_imgbtn_t *) obj; + /*Initialize the allocated 'ext' */ + lv_memset_00((void *)imgbtn->img_src_mid, sizeof(imgbtn->img_src_mid)); + lv_memset_00(imgbtn->img_src_left, sizeof(imgbtn->img_src_left)); + lv_memset_00(imgbtn->img_src_right, sizeof(imgbtn->img_src_right)); + + imgbtn->act_cf = LV_IMG_CF_UNKNOWN; +} + + +static lv_draw_res_t lv_imgbtn_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode) +{ + lv_imgbtn_t * imgbtn = (lv_imgbtn_t *) obj; + /*Return false if the object is not covers the mask_p area*/ + if(mode == LV_DRAW_MODE_COVER_CHECK) { + return LV_DRAW_RES_NOT_COVER; + + lv_draw_res_t cover = lv_obj_draw_base(&lv_imgbtn_class, obj, clip_area, mode); + if(cover != LV_DRAW_RES_COVER) return cover; + + if(imgbtn->act_cf == LV_IMG_CF_TRUE_COLOR || imgbtn->act_cf == LV_IMG_CF_RAW) { + cover = _lv_area_is_in(clip_area, &obj->coords, 0) ? LV_DRAW_RES_COVER : LV_DRAW_RES_NOT_COVER; + } else { + cover = LV_DRAW_RES_NOT_COVER; + } + + return cover; + } + /*Draw the object*/ + else if(mode == LV_DRAW_MODE_MAIN_DRAW) { + + lv_obj_draw_base(&lv_imgbtn_class, obj, clip_area, mode); + + /*Just draw an image*/ + lv_imgbtn_t * imgbtn = (lv_imgbtn_t *) obj; + lv_imgbtn_state_t state = suggest_state(obj, get_state(obj)); + + /*Simply draw the middle src if no tiled*/ + const void * src = imgbtn->img_src_left[state]; + if(lv_img_src_get_type(src) == LV_IMG_SRC_SYMBOL) { + LV_LOG_WARN("lv_imgbtn_draw: SYMBOLS are not supported in tiled mode") + return LV_DRAW_RES_OK; + } + + lv_coord_t tw = lv_obj_get_style_transform_width(obj, LV_PART_MAIN); + lv_coord_t th = lv_obj_get_style_transform_height(obj, LV_PART_MAIN); + lv_area_t coords; + lv_area_copy(&coords, &obj->coords); + coords.x1 -= tw; + coords.x2 += tw; + coords.y1 -= th; + coords.y2 += 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_img_header_t header; + lv_area_t coords_part; + lv_coord_t left_w = 0; + lv_coord_t right_w = 0; + + if(src) { + lv_img_decoder_get_info(src, &header); + left_w = header.w; + coords_part.x1 = coords.x1; + coords_part.y1 = coords.y1; + coords_part.x2 = coords.x1 + header.w - 1; + coords_part.y2 = coords.y1 + header.h - 1; + lv_draw_img(&coords_part, clip_area, src, &img_dsc); + } + + src = imgbtn->img_src_right[state]; + if(src) { + lv_img_decoder_get_info(src, &header); + right_w = header.w; + coords_part.x1 = coords.x2 - header.w + 1; + coords_part.y1 = coords.y1; + coords_part.x2 = coords.x2; + coords_part.y2 = coords.y1 + header.h - 1; + lv_draw_img(&coords_part, clip_area, src, &img_dsc); + } + + src = imgbtn->img_src_mid[state]; + if(src) { + lv_area_t clip_center_area; + clip_center_area.x1 = coords.x1 + left_w; + clip_center_area.x2 = coords.x2 - right_w; + clip_center_area.y1 = coords.y1; + clip_center_area.y2 = coords.y2; + + bool comm_res; + comm_res = _lv_area_intersect(&clip_center_area, &clip_center_area, clip_area); + if(comm_res) { + lv_coord_t i; + lv_img_decoder_get_info(src, &header); + + coords_part.x1 = coords.x1 + left_w; + coords_part.y1 = coords.y1; + coords_part.x2 = coords_part.x1 + header.w - 1; + coords_part.y2 = coords_part.y1 + header.h - 1; + + for(i = 0; i < clip_center_area.x2 + header.w - 1; i += header.w) { + + lv_draw_img(&coords_part, &clip_center_area, src, &img_dsc); + coords_part.x1 = coords_part.x2 + 1; + coords_part.x2 += header.w; + } + } + } + } + /*Post draw when the children are drawn*/ + else if(mode == LV_DRAW_MODE_POST_DRAW) { + lv_obj_draw_base(&lv_imgbtn_class, obj, clip_area, mode); + } + + return LV_DRAW_RES_OK; +} + +/** + * Signal function of the image button + * @param imgbtn pointer to a image button object + * @param sign a signal type from lv_signal_t enum + * @param param pointer to a signal specific variable + * @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted + */ +static lv_res_t lv_imgbtn_signal(lv_obj_t * obj, lv_signal_t sign, void * param) +{ + lv_res_t res = lv_obj_signal_base(&lv_imgbtn_class, obj, sign, param); + if(res != LV_RES_OK) return res; + + if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) { + refr_img(obj); + } + + return res; +} + +static void refr_img(lv_obj_t * obj) +{ + lv_imgbtn_t * imgbtn = (lv_imgbtn_t *) obj; + lv_imgbtn_state_t state = suggest_state(obj, get_state(obj)); + lv_img_header_t header; + + const void * src = imgbtn->img_src_mid[state]; + if(src == NULL) return; + + lv_res_t info_res = LV_RES_OK; + if(lv_img_src_get_type(src) == LV_IMG_SRC_SYMBOL) { + const lv_font_t * font = lv_obj_get_style_text_font(obj, LV_PART_MAIN); + header.h = lv_font_get_line_height(font); + header.w = _lv_txt_get_width(src, (uint16_t)strlen(src), font, 0, LV_TEXT_FLAG_NONE); + header.always_zero = 0; + header.cf = LV_IMG_CF_ALPHA_1BIT; + } + else { + info_res = lv_img_decoder_get_info(src, &header); + } + + if(info_res == LV_RES_OK) { + imgbtn->act_cf = header.cf; + lv_obj_set_height(obj, header.h); /*Keep the user defined width*/ + } + else { + imgbtn->act_cf = LV_IMG_CF_UNKNOWN; + } + + lv_obj_invalidate(obj); +} + +/** + * If `src` is not defined for the current state try to get a state which is related to the current but has `src`. + * E.g. if the PRESSED src is not set but the RELEASED does, use the RELEASED. + * @param imgbtn pointer to an image button + * @param state the state to convert + * @return the suggested state + */ +static lv_imgbtn_state_t suggest_state(lv_obj_t * obj, lv_imgbtn_state_t state) +{ + lv_imgbtn_t * imgbtn = (lv_imgbtn_t *) obj; + if(imgbtn->img_src_mid[state] == NULL) { + switch(state) { + case LV_IMGBTN_STATE_PRESSED: + if(imgbtn->img_src_mid[LV_IMGBTN_STATE_RELEASED]) return LV_IMGBTN_STATE_RELEASED; + break; + case LV_IMGBTN_STATE_CHECKED_RELEASED: + if(imgbtn->img_src_mid[LV_IMGBTN_STATE_RELEASED]) return LV_IMGBTN_STATE_RELEASED; + break; + case LV_IMGBTN_STATE_CHECKED_PRESSED: + if(imgbtn->img_src_mid[LV_IMGBTN_STATE_CHECKED_RELEASED]) return LV_IMGBTN_STATE_CHECKED_RELEASED; + if(imgbtn->img_src_mid[LV_IMGBTN_STATE_PRESSED]) return LV_IMGBTN_STATE_PRESSED; + if(imgbtn->img_src_mid[LV_IMGBTN_STATE_RELEASED]) return LV_IMGBTN_STATE_RELEASED; + break; + case LV_IMGBTN_STATE_DISABLED: + if(imgbtn->img_src_mid[LV_IMGBTN_STATE_RELEASED]) return LV_IMGBTN_STATE_RELEASED; + break; + case LV_IMGBTN_STATE_CHECKED_DISABLED: + if(imgbtn->img_src_mid[LV_IMGBTN_STATE_CHECKED_RELEASED]) return LV_IMGBTN_STATE_CHECKED_RELEASED; + if(imgbtn->img_src_mid[LV_IMGBTN_STATE_RELEASED]) return LV_IMGBTN_STATE_RELEASED; + break; + default: + break; + } + } + + return state; +} + +lv_imgbtn_state_t get_state(const lv_obj_t * imgbtn) +{ + LV_ASSERT_OBJ(imgbtn, MY_CLASS); + + lv_state_t obj_state = lv_obj_get_state(imgbtn); + + if(obj_state & LV_STATE_DISABLED) { + if(obj_state & LV_STATE_CHECKED) return LV_IMGBTN_STATE_CHECKED_DISABLED; + else return LV_IMGBTN_STATE_DISABLED; + } + + if(obj_state & LV_STATE_CHECKED) { + if(obj_state & LV_STATE_PRESSED) return LV_IMGBTN_STATE_CHECKED_PRESSED; + else return LV_IMGBTN_STATE_CHECKED_RELEASED; + } + else { + if(obj_state & LV_STATE_PRESSED) return LV_IMGBTN_STATE_PRESSED; + else return LV_IMGBTN_STATE_RELEASED; + } +} + +#endif diff --git a/src/extra/widgets/imgbtn/lv_imgbtn.h b/src/extra/widgets/imgbtn/lv_imgbtn.h index 59019e316..6ab3fe5e0 100644 --- a/src/extra/widgets/imgbtn/lv_imgbtn.h +++ b/src/extra/widgets/imgbtn/lv_imgbtn.h @@ -13,14 +13,10 @@ extern "C" { /********************* * INCLUDES *********************/ -#include "../lv_conf_internal.h" +#include "../../../lvgl.h" #if LV_USE_IMGBTN != 0 -#include "../lv_core/lv_obj.h" -#include "lv_btn.h" -#include "../lv_draw/lv_draw_img.h" - /********************* * DEFINES *********************/ @@ -39,21 +35,14 @@ typedef enum { **********************/ /*Data of image button*/ typedef struct { - /*New data for this type */ + lv_obj_t obj; const void * img_src_mid[_LV_IMGBTN_STATE_NUM]; /*Store center images to each state*/ -#if LV_IMGBTN_TILED const void * img_src_left[_LV_IMGBTN_STATE_NUM]; /*Store left side images to each state*/ const void * img_src_right[_LV_IMGBTN_STATE_NUM]; /*Store right side images to each state*/ -#endif lv_img_cf_t act_cf; /*Color format of the currently active image*/ - uint8_t tiled : 1; /*1: the middle src will be repeated to fill the user defined width*/ -} lv_imgbtn_ext_t; +} lv_imgbtn_t; -/*Parts of the image button*/ -enum { - LV_IMGBTN_PART_MAIN = LV_BTN_PART_MAIN, -}; -typedef uint8_t lv_imgbtn_part_t; +extern const lv_obj_class_t lv_imgbtn_class; /********************** * GLOBAL PROTOTYPES @@ -66,7 +55,7 @@ typedef uint8_t lv_imgbtn_part_t; * it * @return pointer to the created image button */ -lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy); +lv_obj_t * lv_imgbtn_create(lv_obj_t * parent); /*====================== * Add/remove functions @@ -76,15 +65,6 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * par, const lv_obj_t * copy); * Setter functions *====================*/ -/** - * Set images for a state of the image button - * @param imgbtn pointer to an image button object - * @param state for which state set the new image - * @param src pointer to an image source (a C array or path to a file) - */ -void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_imgbtn_state_t state, const void * src); - -#if LV_IMGBTN_TILED /** * Set images for a state of the image button * @param imgbtn pointer to an image button object @@ -96,26 +76,14 @@ void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_imgbtn_state_t state, const void * * @param src_right pointer to an image source for the right side of the button (a C array or path * to a file) */ -void lv_imgbtn_set_src_tiled(lv_obj_t * imgbtn, lv_imgbtn_state_t state, const void * src_left, const void * src_mid, +void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_imgbtn_state_t state, const void * src_left, const void * src_mid, const void * src_right); -#endif /*===================== * Getter functions *====================*/ -#if LV_IMGBTN_TILED == 0 -/** - * Get the images 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`) ` - * @return pointer to an image source (a C array or path to a file) - */ -const void * lv_imgbtn_get_src(lv_obj_t * imgbtn, lv_imgbtn_state_t state); - -#else - /** * Get the left image in a given state * @param imgbtn pointer to an image button object @@ -140,8 +108,6 @@ const void * lv_imgbtn_get_src_middle(lv_obj_t * imgbtn, lv_imgbtn_state_t state */ const void * lv_imgbtn_get_src_right(lv_obj_t * imgbtn, lv_imgbtn_state_t state); -#endif - /*===================== * Other functions diff --git a/src/extra/widgets/keyboard/lv_keyboard.c b/src/extra/widgets/keyboard/lv_keyboard.c index f5593f501..389f9a7dd 100644 --- a/src/extra/widgets/keyboard/lv_keyboard.c +++ b/src/extra/widgets/keyboard/lv_keyboard.c @@ -135,7 +135,7 @@ lv_obj_t * lv_keyboard_create(lv_obj_t * parent) void lv_keyboard_set_textarea(lv_obj_t * obj, lv_obj_t * ta) { if(ta) { - LV_ASSERT_OBJ(ta, "lv_textarea"); + LV_ASSERT_OBJ(ta, &lv_textarea_class); } lv_keyboard_t * keyboard = (lv_keyboard_t *) obj; @@ -259,7 +259,6 @@ void lv_keyboard_def_event_cb(lv_obj_t * obj, lv_event_t event) if(res != LV_RES_OK) return; } lv_keyboard_set_textarea(obj, NULL); /*De-assign the text area to hide it cursor if needed*/ - lv_obj_del(obj); return; } else if(strcmp(txt, LV_SYMBOL_OK) == 0) { @@ -272,7 +271,6 @@ void lv_keyboard_def_event_cb(lv_obj_t * obj, lv_event_t event) } lv_keyboard_set_textarea(obj, NULL); /*De-assign the text area to hide it cursor if needed*/ - lv_obj_del(obj); return; } diff --git a/src/extra/widgets/led/lv_led.c b/src/extra/widgets/led/lv_led.c index bec201a15..2fa827cba 100644 --- a/src/extra/widgets/led/lv_led.c +++ b/src/extra/widgets/led/lv_led.c @@ -13,8 +13,8 @@ * DEFINES *********************/ -#define LV_LED_WIDTH_DEF (LV_DPI / 3) -#define LV_LED_HEIGHT_DEF (LV_DPI / 3) +#define LV_LED_WIDTH_DEF (LV_DPI_DEF / 5) +#define LV_LED_HEIGHT_DEF (LV_DPI_DEF / 5) #ifndef LV_LED_BRIGHT_MIN # define LV_LED_BRIGHT_MIN 80 @@ -31,13 +31,18 @@ /********************** * STATIC PROTOTYPES **********************/ +static void lv_led_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); static lv_draw_res_t lv_led_draw(lv_obj_t * led, const lv_area_t * clip_area, lv_draw_mode_t mode); /********************** * STATIC VARIABLES **********************/ -static bool inited; -static lv_draw_cb_t ancestor_draw; +const lv_obj_class_t lv_led_class = { + .base_class = &lv_obj_class, + .constructor_cb = lv_led_constructor, + .draw_cb = lv_led_draw, + .instance_size = sizeof(lv_led_t), +}; /********************** * MACROS @@ -55,67 +60,40 @@ static lv_draw_cb_t ancestor_draw; */ lv_obj_t * lv_led_create(lv_obj_t * parent) { - static lv_style_t style_main; - if(!inited) { - lv_style_init(&style_main); - lv_style_set_bg_opa(&style_main, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&style_main, LV_STATE_DEFAULT, lv_theme_get_color_primary()); - lv_style_set_border_width(&style_main, LV_STATE_DEFAULT, 0); - lv_style_set_radius(&style_main, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); -#if LV_USE_SHADOW - lv_style_set_shadow_width(&style_main, LV_STATE_DEFAULT, LV_DPX(15)); - lv_style_set_shadow_color(&style_main, LV_STATE_DEFAULT, lv_theme_get_color_primary()); - lv_style_set_shadow_spread(&style_main, LV_STATE_DEFAULT, LV_DPX(5)); -#endif - } - - /*Create the ancestor basic object*/ - lv_obj_t * led = lv_obj_create(parent, NULL); - LV_ASSERT_MALLOC(led); - if(led == NULL) return NULL; - - if(ancestor_draw == NULL) ancestor_draw = lv_obj_get_draw_cb(led); - - /*Allocate the object type specific extended data*/ - lv_led_ext_t * ext = lv_obj_allocate_ext_attr(led, sizeof(lv_led_ext_t)); - LV_ASSERT_MALLOC(ext); - if(ext == NULL) { - lv_obj_del(led); - return NULL; - } - - ext->bright = LV_LED_BRIGHT_MAX; - - lv_obj_set_draw_cb(led, lv_led_draw); - lv_obj_set_size(led, LV_LED_WIDTH_DEF, LV_LED_HEIGHT_DEF); - lv_obj_add_style(led, LV_OBJ_PART_MAIN, &style_main); - LV_LOG_INFO("led created"); - - return led; + return lv_obj_create_from_class(&lv_led_class, parent, NULL); } /*===================== * Setter functions *====================*/ +/** + * Set the color of the LED + * @param led pointer to a LED object + * @param color the color of the the LED + */ +void lv_led_set_color(lv_obj_t * led, lv_color_t color) +{ + +} /** * Set the brightness of a LED object * @param led pointer to a LED object * @param bright LV_LED_BRIGHT_MIN (max. dark) ... LV_LED_BRIGHT_MAX (max. light) */ -void lv_led_set_bright(lv_obj_t * led, uint8_t bright) +void lv_led_set_bright(lv_obj_t * obj, uint8_t bright) { /*Set the brightness*/ - lv_led_ext_t * ext = lv_obj_get_ext_attr(led); - if(ext->bright == bright) return; + lv_led_t * led = (lv_led_t *) obj; + if(led->bright == bright) return; if(bright <= LV_LED_BRIGHT_MIN) bright = LV_LED_BRIGHT_MIN; if(bright >= LV_LED_BRIGHT_MAX) bright = LV_LED_BRIGHT_MAX; - ext->bright = bright; + led->bright = bright; /*Invalidate the object there fore it will be redrawn*/ - lv_obj_invalidate(led); + lv_obj_invalidate(obj); } /** @@ -140,13 +118,13 @@ void lv_led_off(lv_obj_t * led) * Toggle the state of a LED * @param led pointer to a LED object */ -void lv_led_toggle(lv_obj_t * led) +void lv_led_toggle(lv_obj_t * obj) { - uint8_t bright = lv_led_get_bright(led); + uint8_t bright = lv_led_get_brightness(obj); if(bright > (LV_LED_BRIGHT_MIN + LV_LED_BRIGHT_MAX) >> 1) - lv_led_off(led); + lv_led_off(obj); else - lv_led_on(led); + lv_led_on(obj); } /*===================== @@ -158,54 +136,64 @@ void lv_led_toggle(lv_obj_t * led) * @param led pointer to LED object * @return bright 0 (max. dark) ... 255 (max. light) */ -uint8_t lv_led_get_bright(const lv_obj_t * led) +uint8_t lv_led_get_brightness(const lv_obj_t * obj) { - lv_led_ext_t * ext = lv_obj_get_ext_attr(led); - return ext->bright; + lv_led_t * led = (lv_led_t *) obj; + return led->bright; } /********************** * STATIC FUNCTIONS **********************/ -/** - * Handle the drawing related tasks of the leds - * @param led pointer to an object - * @param clip_area the object will be drawn only in this area - * @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area - * (return 'true' if yes) - * LV_DRAW_DRAW: draw the object (always return 'true') - * LV_DRAW_DRAW_POST: drawing after every children are drawn - * @param return an element of `lv_draw_res_t` - */ -static lv_draw_res_t lv_led_draw(lv_obj_t * led, const lv_area_t * clip_area, lv_draw_mode_t mode) +static void lv_led_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy) { - if(mode == LV_DRAW_COVER_CHK) { + + lv_led_t * led = (lv_led_t *) obj; + led->color = lv_theme_get_color_primary(); + led->bright = LV_LED_BRIGHT_MAX; + led->bright = LV_LED_BRIGHT_MAX; + + lv_obj_set_size(obj, LV_LED_WIDTH_DEF, LV_LED_HEIGHT_DEF); +} + + +static lv_draw_res_t lv_led_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode) +{ + if(mode == LV_DRAW_MODE_COVER_CHECK) { /*Return false if the object is not covers the clip_area area*/ - return ancestor_draw(led, clip_area, mode); + return lv_obj_draw_base(&lv_led_class, obj, clip_area, mode); } - else if(mode == LV_DRAW_DRAW_MAIN) { + else if(mode == LV_DRAW_MODE_MAIN_DRAW) { /*Make darker colors in a temporary style according to the brightness*/ - lv_led_ext_t * ext = lv_obj_get_ext_attr(led); + lv_led_t * led = (lv_led_t *) obj; lv_draw_rect_dsc_t rect_dsc; lv_draw_rect_dsc_init(&rect_dsc); - lv_obj_init_draw_rect_dsc(led, LV_OBJ_PART_MAIN, &rect_dsc); + lv_obj_init_draw_rect_dsc(obj, LV_PART_MAIN, &rect_dsc); + + /*Use the original colors brightness to modify color->led*/ + rect_dsc.bg_color = lv_color_mix(led->color, LV_COLOR_BLACK, lv_color_brightness(rect_dsc.bg_color)); + rect_dsc.bg_grad_color = lv_color_mix(led->color, LV_COLOR_BLACK, lv_color_brightness(rect_dsc.bg_grad_color)); + rect_dsc.shadow_color = lv_color_mix(led->color, LV_COLOR_BLACK, lv_color_brightness(rect_dsc.shadow_color)); + rect_dsc.border_color = lv_color_mix(led->color, LV_COLOR_BLACK, lv_color_brightness(rect_dsc.border_color)); + rect_dsc.outline_color = lv_color_mix(led->color, LV_COLOR_BLACK, lv_color_brightness(rect_dsc.outline_color)); /*Mix. the color with black proportionally with brightness*/ - rect_dsc.bg_color = lv_color_mix(rect_dsc.bg_color, LV_COLOR_BLACK, ext->bright); - rect_dsc.bg_grad_color = lv_color_mix(rect_dsc.bg_grad_color, LV_COLOR_BLACK, ext->bright); - rect_dsc.border_color = lv_color_mix(rect_dsc.border_color, LV_COLOR_BLACK, ext->bright); - rect_dsc.shadow_color = lv_color_mix(rect_dsc.shadow_color, LV_COLOR_BLACK, ext->bright); + rect_dsc.bg_color = lv_color_mix(rect_dsc.bg_color, LV_COLOR_BLACK, led->bright); + rect_dsc.bg_grad_color = lv_color_mix(rect_dsc.bg_grad_color, LV_COLOR_BLACK, led->bright); + rect_dsc.border_color = lv_color_mix(rect_dsc.border_color, LV_COLOR_BLACK, led->bright); + rect_dsc.shadow_color = lv_color_mix(rect_dsc.shadow_color, LV_COLOR_BLACK, led->bright); + rect_dsc.outline_color = lv_color_mix(rect_dsc.outline_color, LV_COLOR_BLACK, led->bright); /*Set the current shadow width according to brightness proportionally between LV_LED_BRIGHT_OFF * and LV_LED_BRIGHT_ON*/ - rect_dsc.shadow_width = ((ext->bright - LV_LED_BRIGHT_MIN) * rect_dsc.shadow_width) / + rect_dsc.shadow_width = ((led->bright - LV_LED_BRIGHT_MIN) * rect_dsc.shadow_width) / (LV_LED_BRIGHT_MAX - LV_LED_BRIGHT_MIN); - rect_dsc.shadow_spread = ((ext->bright - LV_LED_BRIGHT_MIN) * rect_dsc.shadow_spread) / + rect_dsc.shadow_spread = ((led->bright - LV_LED_BRIGHT_MIN) * rect_dsc.shadow_spread) / (LV_LED_BRIGHT_MAX - LV_LED_BRIGHT_MIN); - lv_draw_rect(&led->coords, clip_area, &rect_dsc); + lv_draw_rect(&obj->coords, clip_area, &rect_dsc); } return LV_DRAW_RES_OK; } diff --git a/src/extra/widgets/led/lv_led.h b/src/extra/widgets/led/lv_led.h index aedb2790f..2a1960a27 100644 --- a/src/extra/widgets/led/lv_led.h +++ b/src/extra/widgets/led/lv_led.h @@ -13,7 +13,7 @@ extern "C" { /********************* * INCLUDES *********************/ -#include "../../../lv_core/lv_obj.h" +#include "../../../lvgl.h" #if LV_USE_LED @@ -28,10 +28,12 @@ extern "C" { /*Data of led*/ typedef struct { - /*No inherited ext.*/ - /*New data for this type */ - uint8_t bright; /*Current brightness of the LED (0..255)*/ -} lv_led_ext_t; + lv_obj_t obj; + lv_color_t color; + uint8_t bright; /**< Current brightness of the LED (0..255)*/ +} lv_led_t; + +extern const lv_obj_class_t lv_led_class; /********************** * GLOBAL PROTOTYPES @@ -45,12 +47,19 @@ typedef struct { */ lv_obj_t * lv_led_create(lv_obj_t * parent); +/** + * Set the color of the LED + * @param led pointer to a LED object + * @param color the color of the the LED + */ +void lv_led_set_color(lv_obj_t * led, lv_color_t color); + /** * Set the brightness of a LED object * @param led pointer to a LED object * @param bright LV_LED_BRIGHT_MIN (max. dark) ... LV_LED_BRIGHT_MAX (max. light) */ -void lv_led_set_bright(lv_obj_t * led, uint8_t bright); +void lv_led_set_brightness(lv_obj_t * led, uint8_t bright); /** * Light on a LED @@ -75,7 +84,7 @@ void lv_led_toggle(lv_obj_t * led); * @param led pointer to LED object * @return bright 0 (max. dark) ... 255 (max. light) */ -uint8_t lv_led_get_bright(const lv_obj_t * led); +uint8_t lv_led_get_brightness(const lv_obj_t * obj); /********************** * MACROS diff --git a/src/extra/widgets/lv_widgets.h b/src/extra/widgets/lv_widgets.h index 706986c99..b167bb2b5 100644 --- a/src/extra/widgets/lv_widgets.h +++ b/src/extra/widgets/lv_widgets.h @@ -24,6 +24,8 @@ extern "C" { #include "tileview/lv_tileview.h" #include "win/lv_win.h" #include "colorwheel/lv_colorwheel.h" +#include "led/lv_led.h" +#include "imgbtn/lv_imgbtn.h" /********************* diff --git a/src/extra/widgets/msgbox/lv_msgbox.c b/src/extra/widgets/msgbox/lv_msgbox.c index 667122130..e2f883e59 100644 --- a/src/extra/widgets/msgbox/lv_msgbox.c +++ b/src/extra/widgets/msgbox/lv_msgbox.c @@ -47,7 +47,10 @@ lv_obj_t * lv_msgbox_create(const char * title, const char * txt, const char * b { lv_obj_t * parent = lv_obj_create(lv_layer_top(), NULL); lv_obj_set_size(parent, LV_COORD_PCT(100), LV_COORD_PCT(100)); + lv_obj_remove_style(parent, LV_PART_ANY, LV_STATE_ANY, NULL); + lv_obj_set_style_bg_color(parent, LV_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + lv_obj_set_style_bg_opa(parent, LV_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); lv_obj_t * mbox = lv_obj_create_from_class(&lv_msgbox_class, parent, NULL); LV_ASSERT_MALLOC(mbox); diff --git a/src/extra/widgets/spinbox/lv_spinbox.c b/src/extra/widgets/spinbox/lv_spinbox.c index 348f5d012..fac783135 100644 --- a/src/extra/widgets/spinbox/lv_spinbox.c +++ b/src/extra/widgets/spinbox/lv_spinbox.c @@ -35,6 +35,7 @@ const lv_obj_class_t lv_spinbox_class = { .destructor_cb = lv_spinbox_destructor, .signal_cb = lv_spinbox_signal, .instance_size = sizeof(lv_spinbox_t), + .editable = LV_OBJ_CLASS_EDITABLE_TRUE, .base_class = &lv_textarea_class }; /********************** diff --git a/src/extra/widgets/tabview/lv_tabview.c b/src/extra/widgets/tabview/lv_tabview.c index ed501e7be..013644ffe 100644 --- a/src/extra/widgets/tabview/lv_tabview.c +++ b/src/extra/widgets/tabview/lv_tabview.c @@ -21,6 +21,7 @@ * STATIC PROTOTYPES **********************/ static void lv_tabview_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_tabview_destructor(lv_obj_t * obj); static void btns_event_cb(lv_obj_t * btns, lv_event_t e); static void cont_event_cb(lv_obj_t * cont, lv_event_t e); @@ -29,6 +30,7 @@ static void cont_event_cb(lv_obj_t * cont, lv_event_t e); **********************/ const lv_obj_class_t lv_tabview_class = { .constructor_cb = lv_tabview_constructor, + .destructor_cb = lv_tabview_destructor, .base_class = &lv_obj_class, .instance_size = sizeof(lv_tabview_t)}; @@ -63,8 +65,8 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * obj, const char * name) lv_obj_t * btns = lv_tabview_get_tab_btns(obj); - const char ** old_map = lv_btnmatrix_get_map(btns); - const char ** new_map; + char ** old_map = tabview->map; + char ** new_map; /*top or bottom dir*/ if(tabview->tab_pos & LV_DIR_VER) { @@ -89,7 +91,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * obj, const char * name) strcpy((char *)new_map[(tab_id * 2) - 2], name); } } - + tabview->map = new_map; lv_btnmatrix_set_map(btns, new_map); lv_mem_free(old_map); @@ -97,7 +99,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * obj, const char * name) tabview->tab_cnt++; if(tabview->tab_cnt == 1) { - lv_tabview_set_act(obj, 0); + lv_tabview_set_act(obj, 0, LV_ANIM_OFF); } lv_btnmatrix_set_btn_ctrl(btns, tabview->tab_cur, LV_BTNMATRIX_CTRL_CHECKED); @@ -105,7 +107,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * obj, const char * name) return page; } -void lv_tabview_set_act(lv_obj_t * obj, uint32_t id) +void lv_tabview_set_act(lv_obj_t * obj, uint32_t id, lv_anim_enable_t anim_en) { lv_tabview_t * tabview = (lv_tabview_t *) obj; @@ -116,7 +118,7 @@ void lv_tabview_set_act(lv_obj_t * obj, uint32_t id) lv_obj_t * cont = lv_tabview_get_content(obj); lv_obj_t * tab = lv_obj_get_child(cont, 0); lv_coord_t gap = lv_obj_get_style_pad_column(cont, LV_PART_MAIN); - lv_obj_scroll_to_x(cont, id * (gap + lv_obj_get_width(tab)), LV_ANIM_ON); + lv_obj_scroll_to_x(cont, id * (gap + lv_obj_get_width(tab)), anim_en); lv_obj_t * btns = lv_tabview_get_tab_btns(obj); lv_btnmatrix_set_btn_ctrl(btns, id, LV_BTNMATRIX_CTRL_CHECKED); @@ -175,9 +177,9 @@ static void lv_tabview_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_o cont = lv_obj_create(obj, NULL); lv_btnmatrix_set_one_checked(btnm, true); - const char ** map = lv_mem_alloc(sizeof(const char *)); - map[0] = ""; - lv_btnmatrix_set_map(btnm, map); + tabview->map = lv_mem_alloc(sizeof(const char *)); + tabview->map[0] = ""; + lv_btnmatrix_set_map(btnm, tabview->map); lv_obj_add_event_cb(btnm, btns_event_cb, NULL); lv_obj_add_flag(btnm, LV_OBJ_FLAG_EVENT_BUBBLE); @@ -205,12 +207,29 @@ static void lv_tabview_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_o lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLL_ON_FOCUS); } +static void lv_tabview_destructor(lv_obj_t * obj) +{ + lv_tabview_t * tabview = (lv_tabview_t *) obj; + + uint32_t i; + if(tabview->tab_pos & LV_DIR_VER) { + for(i = 0; i < tabview->tab_cnt; i++) { + lv_mem_free(tabview->map[i]); + tabview->map[i] = NULL; + } + } + + + lv_mem_free(tabview->map); + tabview->map = NULL; +} + static void btns_event_cb(lv_obj_t * btns, lv_event_t e) { if(e == LV_EVENT_VALUE_CHANGED) { lv_obj_t * tv = lv_obj_get_parent(btns); uint32_t id = lv_btnmatrix_get_active_btn(btns); - lv_tabview_set_act(tv, id); + lv_tabview_set_act(tv, id, LV_ANIM_ON); } } static void cont_event_cb(lv_obj_t * cont, lv_event_t e) @@ -224,7 +243,7 @@ static void cont_event_cb(lv_obj_t * cont, lv_event_t e) lv_coord_t w = lv_obj_get_width_fit(cont); lv_coord_t t = (p.x + w/ 2) / w; if(t < 0) t = 0; - lv_tabview_set_act(tv, t); + lv_tabview_set_act(tv, t, LV_ANIM_ON); } } #endif /*LV_USE_TABVIEW*/ diff --git a/src/extra/widgets/tabview/lv_tabview.h b/src/extra/widgets/tabview/lv_tabview.h index a08914a25..98b7670c9 100644 --- a/src/extra/widgets/tabview/lv_tabview.h +++ b/src/extra/widgets/tabview/lv_tabview.h @@ -28,6 +28,7 @@ extern "C" { typedef struct { lv_obj_t obj; + char ** map; lv_flex_t flex; uint16_t tab_cnt; uint16_t tab_cur; @@ -48,7 +49,7 @@ lv_obj_t * lv_tabview_get_content(lv_obj_t * tv); lv_obj_t * lv_tabview_get_tab_btns(lv_obj_t * tv); -void lv_tabview_set_act(lv_obj_t * tv, uint32_t id); +void lv_tabview_set_act(lv_obj_t * obj, uint32_t id, lv_anim_enable_t anim_en); uint16_t lv_tabview_get_tab_act(lv_obj_t * tv); diff --git a/src/extra/widgets/tileview/lv_tileview.h b/src/extra/widgets/tileview/lv_tileview.h index e3ad58d9b..1e31ac06b 100644 --- a/src/extra/widgets/tileview/lv_tileview.h +++ b/src/extra/widgets/tileview/lv_tileview.h @@ -50,6 +50,8 @@ lv_obj_t * lv_tileview_create(lv_obj_t * parent); lv_obj_t * lv_tileview_add_tile(lv_obj_t * tv, uint8_t row_id, uint8_t col_id, lv_dir_t dir); +void lv_obj_set_tile(lv_obj_t * tv, lv_obj_t * tile_obj, lv_anim_enable_t anim_en); +void lv_obj_set_tile_id(lv_obj_t * tv, uint32_t col_id, uint32_t row_id, lv_anim_enable_t anim_en); /*===================== diff --git a/src/lv_core/lv_group.c b/src/lv_core/lv_group.c index c4113fa5a..3f0ed0584 100644 --- a/src/lv_core/lv_group.c +++ b/src/lv_core/lv_group.c @@ -498,8 +498,10 @@ static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *) group->obj_focus = obj_next; - lv_signal_send(*group->obj_focus, LV_SIGNAL_FOCUS, NULL); - lv_res_t res = lv_event_send(*group->obj_focus, LV_EVENT_FOCUSED, NULL); + lv_res_t res; + res = lv_signal_send(*group->obj_focus, LV_SIGNAL_FOCUS, NULL); + if(res != LV_RES_OK) return; + res = lv_event_send(*group->obj_focus, LV_EVENT_FOCUSED, NULL); if(res != LV_RES_OK) return; lv_obj_invalidate(*group->obj_focus); diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index d84708839..d38b8389e 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -378,7 +378,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) /*Send the ENTER as a normal KEY*/ lv_group_send_data(g, LV_KEY_ENTER); - indev_obj_act->class_p->signal_cb(indev_obj_act, LV_SIGNAL_PRESSED, NULL); + lv_signal_send(indev_obj_act, LV_SIGNAL_PRESSED, NULL); if(indev_reset_check(&i->proc)) return; lv_event_send(indev_obj_act, LV_EVENT_PRESSED, NULL); if(indev_reset_check(&i->proc)) return; @@ -411,7 +411,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) else if(data->state == LV_INDEV_STATE_PR && prev_state == LV_INDEV_STATE_PR) { if(data->key == LV_KEY_ENTER) { - indev_obj_act->class_p->signal_cb(indev_obj_act, LV_SIGNAL_PRESSING, NULL); + lv_signal_send(indev_obj_act, LV_SIGNAL_PRESSING, NULL); if(indev_reset_check(&i->proc)) return; lv_event_send(indev_obj_act, LV_EVENT_PRESSING, NULL); if(indev_reset_check(&i->proc)) return; @@ -422,7 +422,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) i->proc.long_pr_sent = 1; if(data->key == LV_KEY_ENTER) { i->proc.longpr_rep_timestamp = lv_tick_get(); - indev_obj_act->class_p->signal_cb(indev_obj_act, LV_SIGNAL_LONG_PRESS, NULL); + lv_signal_send(indev_obj_act, LV_SIGNAL_LONG_PRESS, NULL); if(indev_reset_check(&i->proc)) return; lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, NULL); if(indev_reset_check(&i->proc)) return; @@ -436,7 +436,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) /*Send LONG_PRESS_REP on ENTER*/ if(data->key == LV_KEY_ENTER) { - indev_obj_act->class_p->signal_cb(indev_obj_act, LV_SIGNAL_LONG_PRESS_REP, NULL); + lv_signal_send(indev_obj_act, LV_SIGNAL_LONG_PRESS_REP, NULL); if(indev_reset_check(&i->proc)) return; lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED_REPEAT, NULL); if(indev_reset_check(&i->proc)) return; @@ -466,7 +466,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) data->key = prev_key; if(data->key == LV_KEY_ENTER) { - indev_obj_act->class_p->signal_cb(indev_obj_act, LV_SIGNAL_RELEASED, NULL); + lv_signal_send(indev_obj_act, LV_SIGNAL_RELEASED, NULL); if(indev_reset_check(&i->proc)) return; if(i->proc.long_pr_sent == 0) { @@ -532,7 +532,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) bool editable = lv_obj_is_editable(indev_obj_act); if(lv_group_get_editing(g) == true || editable == false) { - indev_obj_act->class_p->signal_cb(indev_obj_act, LV_SIGNAL_PRESSED, NULL); + lv_signal_send(indev_obj_act, LV_SIGNAL_PRESSED, NULL); if(indev_reset_check(&i->proc)) return; lv_event_send(indev_obj_act, LV_EVENT_PRESSED, NULL); @@ -579,7 +579,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) } /*If not editable then just send a long press signal*/ else { - indev_obj_act->class_p->signal_cb(indev_obj_act, LV_SIGNAL_LONG_PRESS, NULL); + lv_signal_send(indev_obj_act, LV_SIGNAL_LONG_PRESS, NULL); if(indev_reset_check(&i->proc)) return; lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, NULL); if(indev_reset_check(&i->proc)) return; @@ -594,7 +594,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) i->proc.longpr_rep_timestamp = lv_tick_get(); if(data->key == LV_KEY_ENTER) { - indev_obj_act->class_p->signal_cb(indev_obj_act, LV_SIGNAL_LONG_PRESS_REP, NULL); + lv_signal_send(indev_obj_act, LV_SIGNAL_LONG_PRESS_REP, NULL); if(indev_reset_check(&i->proc)) return; lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED_REPEAT, NULL); if(indev_reset_check(&i->proc)) return; @@ -623,7 +623,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) /*The button was released on a non-editable object. Just send enter*/ if(editable == false) { - indev_obj_act->class_p->signal_cb(indev_obj_act, LV_SIGNAL_RELEASED, NULL); + lv_signal_send(indev_obj_act, LV_SIGNAL_RELEASED, NULL); if(indev_reset_check(&i->proc)) return; if(i->proc.long_pr_sent == 0) lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL); @@ -639,7 +639,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) else if(g->editing) { /*Ignore long pressed enter release because it comes from mode switch*/ if(!i->proc.long_pr_sent || _lv_ll_get_len(&g->obj_ll) <= 1) { - indev_obj_act->class_p->signal_cb(indev_obj_act, LV_SIGNAL_RELEASED, NULL); + lv_signal_send(indev_obj_act, LV_SIGNAL_RELEASED, NULL); if(indev_reset_check(&i->proc)) return; lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL); diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index ed259d3d9..cd4027b8f 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -207,6 +207,8 @@ lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, void * param) } event_temp_data_head = &event_temp_data; + /* There could be nested event sending with different param. + * It needs to be saved for the current event context because `lv_event_get_data` returns a global param. */ void * event_act_param_save = event_act_param; event_act_param = param; @@ -232,11 +234,6 @@ lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, void * param) res = LV_RES_INV; break; } - - if(lv_obj_has_flag(obj, LV_OBJ_FLAG_EVENT_BUBBLE) && obj->parent) { - lv_res_t res = lv_event_send(obj->parent, event, param); - if(res != LV_RES_OK) return LV_RES_INV; - } } i++; @@ -249,6 +246,13 @@ lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, void * param) /*Remove this element from the list*/ event_temp_data_head = event_temp_data_head->prev; + if(res == LV_RES_OK) { + if(lv_obj_has_flag(obj, LV_OBJ_FLAG_EVENT_BUBBLE) && obj->parent) { + lv_res_t res = lv_event_send(obj->parent, event, param); + if(res != LV_RES_OK) return LV_RES_INV; + } + } + return res; } @@ -293,9 +297,7 @@ lv_res_t lv_signal_send(lv_obj_t * obj, lv_signal_t signal, void * param) if(class_p == NULL) return LV_RES_OK; - lv_res_t res = LV_RES_OK; - if(class_p->signal_cb) res = class_p->signal_cb(obj, signal, param); return res; @@ -341,12 +343,8 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) obj->state = new_state; _lv_style_state_cmp_t cmp_res = lv_obj_style_state_compare(obj, prev_state, new_state); - /*If there is no difference in styles there is nothing else to do*/ - if(cmp_res == _LV_STYLE_STATE_CMP_SAME) { - lv_obj_invalidate(obj); - return; - } + if(cmp_res == _LV_STYLE_STATE_CMP_SAME) return; trans_set_t * ts = lv_mem_buf_get(sizeof(trans_set_t) * STYLE_TRANSITION_MAX); lv_memset_00(ts, sizeof(sizeof(trans_set_t) * 64)); @@ -388,9 +386,10 @@ void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state) lv_mem_buf_release(ts); + lv_obj_invalidate(obj); + if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_LAYOUT) lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); else if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD) lv_obj_refresh_ext_draw_size(obj); - else if(cmp_res == _LV_STYLE_STATE_CMP_DIFF_REDRAW) lv_obj_invalidate(obj); } void lv_obj_add_state(lv_obj_t * obj, lv_state_t state) @@ -557,7 +556,7 @@ bool lv_obj_check_type(const lv_obj_t * obj, const lv_obj_class_t * class_p) bool lv_obj_has_class(const lv_obj_t * obj, const lv_obj_class_t * class_p) { - lv_obj_class_t * obj_class = obj->class_p; + const lv_obj_class_t * obj_class = obj->class_p; while(obj_class) { if(obj_class == class_p) return true; obj_class = obj_class->base_class; @@ -623,7 +622,7 @@ static void lv_obj_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t } if(parent->spec_attr->children == NULL) { - parent->spec_attr->children = lv_mem_alloc(sizeof(lv_obj_t *) * 2); + parent->spec_attr->children = lv_mem_alloc(sizeof(lv_obj_t *)); parent->spec_attr->children[0] = obj; parent->spec_attr->child_cnt = 1; } else { @@ -634,15 +633,18 @@ static void lv_obj_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t obj->parent = parent; - obj->coords.y1 = parent->coords.y1; - obj->coords.y2 = parent->coords.y1 + LV_OBJ_DEF_HEIGHT; + lv_coord_t sl = lv_obj_get_scroll_left(parent); + lv_coord_t st = lv_obj_get_scroll_top(parent); + + obj->coords.y1 = parent->coords.y1 + lv_obj_get_style_pad_top(parent, LV_PART_MAIN) - st; + obj->coords.y2 = obj->coords.y1 + LV_OBJ_DEF_HEIGHT; if(lv_obj_get_base_dir(obj) == LV_BIDI_DIR_RTL) { - obj->coords.x2 = parent->coords.x2; - obj->coords.x1 = parent->coords.x2 - LV_OBJ_DEF_WIDTH; + obj->coords.x2 = parent->coords.x2 - lv_obj_get_style_pad_right(parent, LV_PART_MAIN) - sl; + obj->coords.x1 = obj->coords.x2 - LV_OBJ_DEF_WIDTH; } else { - obj->coords.x1 = parent->coords.x1; - obj->coords.x2 = parent->coords.x1 + LV_OBJ_DEF_WIDTH; + obj->coords.x1 = parent->coords.x1 + lv_obj_get_style_pad_left(parent, LV_PART_MAIN) - sl; + obj->coords.x2 = obj->coords.x1 + LV_OBJ_DEF_WIDTH; } obj->w_set = lv_area_get_width(&obj->coords); obj->h_set = lv_area_get_height(&obj->coords); @@ -685,17 +687,6 @@ static void lv_obj_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t lv_obj_set_size(obj, lv_obj_get_width(copy), lv_obj_get_height(copy)); } - } else { - lv_obj_set_pos(obj, 0, 0); - } - - if(parent) { - /* Send a signal to the parent to notify it about the new child. - * Also triggers layout update*/ - lv_signal_send(parent, LV_SIGNAL_CHILD_CHG, obj); - - /*Invalidate the area if not screen created*/ - lv_obj_invalidate(obj); } LV_LOG_INFO("Object create ready"); @@ -704,8 +695,19 @@ static void lv_obj_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t static void lv_obj_destructor(lv_obj_t * p) { lv_obj_t * obj = p; -// lv_obj_remove_all_styles(obj); - if(obj->spec_attr) lv_mem_free(obj->spec_attr); + if(obj->spec_attr) { + if(obj->spec_attr->children) { + lv_mem_free(obj->spec_attr->children); + obj->spec_attr->children = NULL; + } + if(obj->spec_attr->event_dsc) { + lv_mem_free(obj->spec_attr->event_dsc); + obj->spec_attr->event_dsc = NULL; + } + + lv_mem_free(obj->spec_attr); + obj->spec_attr = NULL; + } } @@ -868,8 +870,8 @@ static void draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area) area.x1 = area.x2 - tickness; /*Draw horizontal scrollbar if the mode is ON or can be scrolled in this direction*/ - if(ver_draw && _lv_area_is_on(&area, clip_area)) { - lv_coord_t content_h = obj_h + st + sb; + lv_coord_t content_h = obj_h + st + sb; + if(ver_draw && content_h && _lv_area_is_on(&area, clip_area)) { lv_coord_t sb_h = ((obj_h - end_space * 2 - hor_req_space) * obj_h) / content_h; sb_h = LV_MAX(sb_h, SCROLLBAR_MIN_SIZE); rem = (obj_h - end_space * 2 - hor_req_space) - sb_h; /*Remaining size from the scrollbar track that is not the scrollbar itself*/ @@ -904,8 +906,8 @@ static void draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area) area.x1 = obj->coords.x1; area.x2 = obj->coords.x2; /*Draw horizontal scrollbar if the mode is ON or can be scrolled in this direction*/ - if(hor_draw && _lv_area_is_on(&area, clip_area)) { - lv_coord_t content_w = obj_w + sl + sr; + lv_coord_t content_w = obj_w + sl + sr; + if(hor_draw && content_w && _lv_area_is_on(&area, clip_area)) { lv_coord_t sb_w = ((obj_w - end_space * 2 - ver_reg_space) * obj_w) / content_w; sb_w = LV_MAX(sb_w, SCROLLBAR_MIN_SIZE); rem = (obj_w - end_space * 2 - ver_reg_space) - sb_w; /*Remaining size from the scrollbar track that is not the scrollbar itself*/ @@ -1027,9 +1029,10 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) bool editing = false; editing = lv_group_get_editing(lv_obj_get_group(obj)); lv_state_t state = LV_STATE_FOCUSED; + lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); + if(indev_type == LV_INDEV_TYPE_KEYPAD || indev_type == LV_INDEV_TYPE_ENCODER) state |= LV_STATE_FOCUS_KEY; if(editing) { state |= LV_STATE_EDITED; - if(lv_obj_get_group(obj)) state |= LV_STATE_FOCUS_GROUP; /*if using focus mode, change target to parent*/ obj = lv_obj_get_focused_obj(obj); @@ -1054,7 +1057,7 @@ static lv_res_t lv_obj_signal(lv_obj_t * obj, lv_signal_t sign, void * param) /*if using focus mode, change target to parent*/ obj = lv_obj_get_focused_obj(obj); - lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED); + lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED | LV_STATE_FOCUS_KEY); } else if(sign == LV_SIGNAL_COORD_CHG) { bool w_new = true; @@ -1139,18 +1142,22 @@ static void base_dir_refr_children(lv_obj_t * obj) static bool obj_valid_child(const lv_obj_t * parent, const lv_obj_t * obj_to_find) { + /*Check all children of `parent`*/ uint32_t child_cnt = 0; if(parent->spec_attr) child_cnt = parent->spec_attr->child_cnt; uint32_t i; for(i = 0; i < child_cnt; i++) { lv_obj_t * child = parent->spec_attr->children[i]; - if(child == obj_to_find) return true; + if(child == obj_to_find) { + return true; + } /*Check the children*/ bool found = obj_valid_child(child, obj_to_find); - if(found) return true; + if(found) { + return true; + } } - return false; } diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index a6ec8579d..80743a307 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -143,7 +143,7 @@ enum { LV_STATE_DEFAULT = 0x00, LV_STATE_CHECKED = 0x01, LV_STATE_FOCUSED = 0x02, - LV_STATE_FOCUS_GROUP = 0x04, + LV_STATE_FOCUS_KEY = 0x04, LV_STATE_EDITED = 0x08, LV_STATE_HOVERED = 0x10, LV_STATE_PRESSED = 0x20, diff --git a/src/lv_core/lv_obj_class.c b/src/lv_core/lv_obj_class.c index 2a084cfbe..4cbbaa2c4 100644 --- a/src/lv_core/lv_obj_class.c +++ b/src/lv_core/lv_obj_class.c @@ -52,6 +52,18 @@ lv_obj_t * lv_obj_create_from_class(const lv_obj_class_t * class_p, lv_obj_t * p // class_start->constructor_cb(obj, parent, copy); lv_obj_construct(obj, parent, copy); + +// lv_obj_set_pos(obj, 0, 0); + + if(parent) { + /* Send a signal to the parent to notify it about the new child. + * Also triggers layout update*/ + lv_signal_send(parent, LV_SIGNAL_CHILD_CHG, obj); + + /*Invalidate the area if not screen created*/ + lv_obj_invalidate(obj); + } + if(!copy) lv_theme_apply(obj); // else lv_style_list_copy(&checkbox->style_indic, &checkbox_copy->style_indic); @@ -105,12 +117,11 @@ bool lv_obj_is_editable(struct _lv_obj_t * obj) const lv_obj_class_t * class_p = obj->class_p; /*Find a base in which editable is set*/ - const lv_obj_class_t * base = class_p->base_class; - while(base && base->editable != LV_OBJ_CLASS_EDITABLE_INHERIT) base = base->base_class; + while(class_p && class_p->editable == LV_OBJ_CLASS_EDITABLE_INHERIT) class_p = class_p->base_class; - if(base == NULL) return false; + if(class_p == NULL) return false; - return base->editable == LV_OBJ_CLASS_EDITABLE_TRUE ? true : false; + return class_p->editable == LV_OBJ_CLASS_EDITABLE_TRUE ? true : false; } /********************** diff --git a/src/lv_core/lv_obj_scroll.c b/src/lv_core/lv_obj_scroll.c index 8a6461208..ac73998f8 100644 --- a/src/lv_core/lv_obj_scroll.c +++ b/src/lv_core/lv_obj_scroll.c @@ -369,6 +369,10 @@ void lv_obj_scroll_to_view(lv_obj_t * obj, lv_anim_enable_t anim_en) else x_scroll = -right_diff; } + /* Remove any pending scroll animations.*/ + lv_anim_del(parent, (lv_anim_exec_xcb_t)scroll_anim_x_cb); + lv_anim_del(parent, (lv_anim_exec_xcb_t)scroll_anim_y_cb); + lv_obj_scroll_by(parent, x_scroll, y_scroll, anim_en); } diff --git a/src/lv_core/lv_obj_style.c b/src/lv_core/lv_obj_style.c index 7ff8d3e34..777c985f0 100644 --- a/src/lv_core/lv_obj_style.c +++ b/src/lv_core/lv_obj_style.c @@ -762,7 +762,7 @@ static cache_t read_cache(const lv_obj_t * obj, lv_part_t part, lv_style_prop_t break; case LV_STYLE_IMG_OPA: if(list->cache_img_opa_cover) return CACHE_255; - else return CACHE_ZERO; + else return CACHE_NEED_CHECK; break; default: return CACHE_NEED_CHECK; diff --git a/src/lv_core/lv_obj_tree.c b/src/lv_core/lv_obj_tree.c index 7e18d41f5..bf0574a30 100644 --- a/src/lv_core/lv_obj_tree.c +++ b/src/lv_core/lv_obj_tree.c @@ -67,6 +67,12 @@ void lv_obj_del(lv_obj_t * obj) /*Send a signal to the parent to notify it about the child delete*/ if(par) { + /*Just to remove scroll animations if any*/ + lv_obj_scroll_to(par, 0, 0, LV_ANIM_OFF); + if(par->spec_attr) { + par->spec_attr->scroll.x = 0; + par->spec_attr->scroll.y = 0; + } lv_signal_send(par, LV_SIGNAL_CHILD_CHG, NULL); } @@ -80,10 +86,20 @@ void lv_obj_clean(lv_obj_t * obj) { LV_ASSERT_OBJ(obj, MY_CLASS); - while(1) { - lv_obj_t * child = lv_obj_get_child(obj, 0); + lv_obj_invalidate(obj); + + lv_obj_t * child = lv_obj_get_child(obj, 0); + while(child) { obj_del_core(child); + child = lv_obj_get_child(obj, 0); } + /*Just to remove scroll animations if any*/ + lv_obj_scroll_to(obj, 0, 0, LV_ANIM_OFF); + if(obj->spec_attr) { + obj->spec_attr->scroll.x = 0; + obj->spec_attr->scroll.y = 0; + } + } void lv_obj_del_anim_ready_cb(lv_anim_t * a) @@ -318,7 +334,9 @@ static void obj_del_core(lv_obj_t * obj) lv_event_mark_deleted(obj); /*Remove all style*/ + lv_obj_enable_style_refresh(false); /*No need to refresh the style because the object will be deleted*/ lv_obj_remove_style(obj, LV_PART_ANY, LV_STATE_ANY, NULL); + lv_obj_enable_style_refresh(true); /* Reset all input devices if the object to delete is used*/ lv_indev_t * indev = lv_indev_get_next(NULL); @@ -346,7 +364,7 @@ static void obj_del_core(lv_obj_t * obj) obj->parent->spec_attr->children[i] = obj->parent->spec_attr->children[i + 1]; } obj->parent->spec_attr->child_cnt--; - lv_mem_realloc(obj->parent->spec_attr->children, obj->parent->spec_attr->child_cnt * sizeof(lv_obj_t *)); + obj->parent->spec_attr->children = lv_mem_realloc(obj->parent->spec_attr->children, obj->parent->spec_attr->child_cnt * sizeof(lv_obj_t *)); /*Free the object itself*/ lv_mem_free(obj); diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index 4ee494d55..486fed1fd 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -591,11 +591,9 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj) lv_draw_res_t draw_res = call_draw_cb(obj, area_p, LV_DRAW_MODE_COVER_CHECK); if(draw_res == LV_DRAW_RES_MASKED) return NULL; -#if LV_USE_OPA_SCALE if(draw_res == LV_DRAW_RES_COVER && lv_obj_get_style_opa(obj, LV_PART_MAIN) != LV_OPA_COVER) { draw_res = LV_DRAW_RES_NOT_COVER; } -#endif uint32_t i; for(i = 0; i < lv_obj_get_child_cnt(obj); i++) { diff --git a/src/lv_core/lv_theme.c b/src/lv_core/lv_theme.c index e78cf85f6..1c370fc60 100644 --- a/src/lv_core/lv_theme.c +++ b/src/lv_core/lv_theme.c @@ -60,11 +60,13 @@ lv_theme_t * lv_theme_get_act(void) */ void lv_theme_apply(lv_obj_t * obj) { + lv_obj_enable_style_refresh(false); + lv_obj_remove_style(obj, LV_PART_ANY, LV_STATE_ANY, NULL); - /*Apply the theme including the base theme(s)*/ - apply_theme(act_theme, obj); + apply_theme(act_theme, obj); /*Apply the theme including the base theme(s)*/ + lv_obj_enable_style_refresh(true); lv_obj_refresh_style(obj, LV_STYLE_PROP_ALL); } diff --git a/src/lv_draw/lv_draw_blend.c b/src/lv_draw/lv_draw_blend.c index e111f2449..bd1787956 100644 --- a/src/lv_draw/lv_draw_blend.c +++ b/src/lv_draw/lv_draw_blend.c @@ -220,11 +220,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_blend_map(const lv_area_t * clip_area, const lv_a draw_area.y2 -= disp_area->y1; /*Round the values in the mask if anti-aliasing is disabled*/ -#if LV_ANTIALIAS if(mask && disp->driver.antialiasing == 0) -#else - if(mask) -#endif { int32_t mask_w = lv_area_get_width(&draw_area); int32_t i; diff --git a/src/lv_draw/lv_draw_mask.c b/src/lv_draw/lv_draw_mask.c index 94a145fb8..3b8e0a64e 100644 --- a/src/lv_draw/lv_draw_mask.c +++ b/src/lv_draw/lv_draw_mask.c @@ -331,7 +331,7 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert param->dsc.cb = (lv_draw_mask_xcb_t)lv_draw_mask_angle; param->dsc.type = LV_DRAW_MASK_TYPE_ANGLE; - LV_ASSERT_MSG(start_angle < 0 && start_angle >= 360, "Unexpected start angle"); + LV_ASSERT_MSG(start_angle >= 0 && start_angle <= 360, "Unexpected start angle"); if(start_angle >= 0 && start_angle < 180) { start_side = LV_DRAW_MASK_LINE_SIDE_LEFT; @@ -340,7 +340,7 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert start_side = LV_DRAW_MASK_LINE_SIDE_RIGHT; } - LV_ASSERT_MSG(end_angle < 0 && start_angle >= 360, "Unexpected end angle"); + LV_ASSERT_MSG(end_angle >= 0 && start_angle <= 360, "Unexpected end angle"); if(end_angle >= 0 && end_angle < 180) { end_side = LV_DRAW_MASK_LINE_SIDE_RIGHT; diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index a4ea15196..6d1d58dab 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -343,6 +343,11 @@ LV_ATTRIBUTE_FAST_MEM static void draw_bg_img(const lv_area_t * coords, const lv if(dsc->bg_img_src == NULL) return; if(dsc->bg_img_opa <= LV_OPA_MIN) return; + lv_img_src_t src_type = lv_img_src_get_type(dsc->bg_img_src); + if(src_type != LV_IMG_SRC_VARIABLE && src_type != LV_IMG_SRC_FILE) { + LV_LOG_WARN("bg_img_src must be variable or path"); + return; + } lv_img_header_t header; lv_res_t res = lv_img_decoder_get_info(dsc->bg_img_src, &header); if(res != LV_RES_OK) { diff --git a/src/lv_misc/lv_mem.c b/src/lv_misc/lv_mem.c index d83e01010..b8f48f922 100644 --- a/src/lv_misc/lv_mem.c +++ b/src/lv_misc/lv_mem.c @@ -153,6 +153,8 @@ void lv_mem_deinit(void) */ void * lv_mem_alloc(size_t size) { + // printf("alloc: %d\n", size); + if(size == 0) return &zero_mem; /*Round the size up to ALIGN_MASK*/ @@ -215,6 +217,7 @@ void * lv_mem_alloc(size_t size) */ void lv_mem_free(const void * data) { + if(data == &zero_mem) return; if(data == NULL) return; @@ -226,6 +229,7 @@ void lv_mem_free(const void * data) lv_memset((void *)data, 0xbb, lv_mem_get_size(data)); # endif #endif +// printf("free: %d\n", lv_mem_get_size(data)); #if LV_MEM_CUSTOM == 0 e->header.s.used = 0; @@ -273,6 +277,10 @@ void * lv_mem_realloc(void * data_p, size_t new_size) if(old_size == new_size) return data_p; /*Also avoid reallocating the same memory*/ #if LV_MEM_CUSTOM == 0 + if(new_size == 0) { + lv_mem_free(data_p); + return &zero_mem; + } /* Truncate the memory if the new size is smaller. */ if(new_size < old_size) { lv_mem_ent_t * e = (lv_mem_ent_t *)((uint8_t *)data_p - sizeof(lv_mem_header_t)); diff --git a/src/lv_misc/lv_style.c b/src/lv_misc/lv_style.c index 7da8e5cb8..75d54a567 100644 --- a/src/lv_misc/lv_style.c +++ b/src/lv_misc/lv_style.c @@ -58,7 +58,8 @@ void lv_style_reset(lv_style_t * style) LV_ASSERT_STYLE(style); if(style->allocated) lv_mem_free(style->values_and_props); - lv_style_init(style); + lv_memset_00(style, sizeof(lv_style_t)); + } lv_style_prop_t lv_style_register_prop(void) diff --git a/src/lv_misc/lv_style.h b/src/lv_misc/lv_style.h index 84fa0b228..4c81c7716 100644 --- a/src/lv_misc/lv_style.h +++ b/src/lv_misc/lv_style.h @@ -154,59 +154,59 @@ typedef enum { LV_STYLE_BG_IMG_RECOLOR_OPA = 41, LV_STYLE_BG_IMG_TILED = 42, - LV_STYLE_BORDER_COLOR = 43, - LV_STYLE_BORDER_COLOR_FILTERED = 43 | LV_STYLE_PROP_FILTER, - LV_STYLE_BORDER_OPA = 44, - LV_STYLE_BORDER_WIDTH = 45, - LV_STYLE_BORDER_SIDE = 46, - LV_STYLE_BORDER_POST = 47, /*Group 3*/ + LV_STYLE_BORDER_COLOR = 48, + LV_STYLE_BORDER_COLOR_FILTERED = 48 | LV_STYLE_PROP_FILTER, + LV_STYLE_BORDER_OPA = 49, + LV_STYLE_BORDER_WIDTH = 50, + LV_STYLE_BORDER_SIDE = 51, + LV_STYLE_BORDER_POST = 52, + LV_STYLE_OUTLINE_WIDTH = 48 | LV_STYLE_PROP_EXT_DRAW, LV_STYLE_OUTLINE_COLOR = 49, LV_STYLE_OUTLINE_COLOR_FILTERED = 49 | LV_STYLE_PROP_FILTER, LV_STYLE_OUTLINE_OPA = 50 | LV_STYLE_PROP_EXT_DRAW, LV_STYLE_OUTLINE_PAD = 51 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_SHADOW_WIDTH = 55 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_SHADOW_OFS_X = 56 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_SHADOW_OFS_Y = 57 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_SHADOW_SPREAD = 58 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_SHADOW_COLOR = 59, - LV_STYLE_SHADOW_COLOR_FILTERED = 59 | LV_STYLE_PROP_FILTER, - LV_STYLE_SHADOW_OPA = 60 | LV_STYLE_PROP_EXT_DRAW, - - /*Group 4*/ - LV_STYLE_IMG_OPA = 64, - LV_STYLE_IMG_RECOLOR = 65, - LV_STYLE_IMG_RECOLOR_FILTERED = 65 | LV_STYLE_PROP_FILTER, - LV_STYLE_IMG_RECOLOR_OPA = 66, + LV_STYLE_SHADOW_WIDTH = 64 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_SHADOW_OFS_X = 65 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_SHADOW_OFS_Y = 66 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_SHADOW_SPREAD = 67 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_SHADOW_COLOR = 68, + LV_STYLE_SHADOW_COLOR_FILTERED = 68 | LV_STYLE_PROP_FILTER, + LV_STYLE_SHADOW_OPA = 69 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_LINE_WIDTH = 68 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_LINE_DASH_WIDTH = 69, - LV_STYLE_LINE_DASH_GAP = 70, - LV_STYLE_LINE_ROUNDED = 71, - LV_STYLE_LINE_COLOR = 72, - LV_STYLE_LINE_COLOR_FILTERED = 72 | LV_STYLE_PROP_FILTER, - LV_STYLE_LINE_OPA = 73, + LV_STYLE_IMG_OPA = 70, + LV_STYLE_IMG_RECOLOR = 71, + LV_STYLE_IMG_RECOLOR_FILTERED = 71 | LV_STYLE_PROP_FILTER, + LV_STYLE_IMG_RECOLOR_OPA = 72, - LV_STYLE_ARC_WIDTH = 75 | LV_STYLE_PROP_EXT_DRAW, - LV_STYLE_ARC_ROUNDED = 76, - LV_STYLE_ARC_COLOR = 77, - LV_STYLE_ARC_COLOR_FILTERED = 77 | LV_STYLE_PROP_FILTER, - LV_STYLE_ARC_OPA = 78, - LV_STYLE_ARC_IMG_SRC = 79, + LV_STYLE_LINE_WIDTH = 73 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_LINE_DASH_WIDTH = 74, + LV_STYLE_LINE_DASH_GAP = 75, + LV_STYLE_LINE_ROUNDED = 76, + LV_STYLE_LINE_COLOR = 77, + LV_STYLE_LINE_COLOR_FILTERED = 77 | LV_STYLE_PROP_FILTER, + LV_STYLE_LINE_OPA = 78, /*Group 5*/ - LV_STYLE_TEXT_COLOR = 80 | LV_STYLE_PROP_INHERIT, - LV_STYLE_TEXT_COLOR_FILTERED = 80 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_FILTER, - LV_STYLE_TEXT_OPA = 81 | LV_STYLE_PROP_INHERIT, - LV_STYLE_TEXT_FONT = 82 | LV_STYLE_PROP_INHERIT, - LV_STYLE_TEXT_LETTER_SPACE = 83 | LV_STYLE_PROP_INHERIT, - LV_STYLE_TEXT_LINE_SPACE = 84 | LV_STYLE_PROP_INHERIT, - LV_STYLE_TEXT_DECOR = 85 | LV_STYLE_PROP_INHERIT, - LV_STYLE_TEXT_ALIGN = 86 | LV_STYLE_PROP_INHERIT, + LV_STYLE_ARC_WIDTH = 80 | LV_STYLE_PROP_EXT_DRAW, + LV_STYLE_ARC_ROUNDED = 81, + LV_STYLE_ARC_COLOR = 82, + LV_STYLE_ARC_COLOR_FILTERED = 82 | LV_STYLE_PROP_FILTER, + LV_STYLE_ARC_OPA = 83, + LV_STYLE_ARC_IMG_SRC = 84, + + LV_STYLE_TEXT_COLOR = 87 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_COLOR_FILTERED = 87 | LV_STYLE_PROP_INHERIT | LV_STYLE_PROP_FILTER, + LV_STYLE_TEXT_OPA = 88 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_FONT = 89 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_LETTER_SPACE = 90 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_LINE_SPACE = 91 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_DECOR = 92 | LV_STYLE_PROP_INHERIT, + LV_STYLE_TEXT_ALIGN = 93 | LV_STYLE_PROP_INHERIT, /*Group 6*/ LV_STYLE_CONTENT_TEXT = 96 | LV_STYLE_PROP_EXT_DRAW, diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index bc430528e..9697f4e0b 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -22,7 +22,7 @@ *********************/ #define MY_CLASS &lv_btnmatrix_class -#define BTN_EXTRA_CLICK_AREA_MAX (LV_DPI_DEF / 4) +#define BTN_EXTRA_CLICK_AREA_MAX (LV_DPI_DEF / 10) #define LV_BTNMATRIX_WIDTH_MASK 0x0007 /********************** @@ -34,7 +34,6 @@ **********************/ static void lv_btnmatrix_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); static void lv_btnmatrix_destructor(lv_obj_t * obj); - static lv_res_t lv_btnmatrix_signal(lv_obj_t * obj, lv_signal_t sign, void * param); static lv_draw_res_t lv_btnmatrix_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); diff --git a/src/lv_widgets/lv_checkbox.c b/src/lv_widgets/lv_checkbox.c index 69a68d296..e474702c0 100644 --- a/src/lv_widgets/lv_checkbox.c +++ b/src/lv_widgets/lv_checkbox.c @@ -112,7 +112,6 @@ static void lv_checkbox_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ LV_LOG_TRACE("lv_checkbox create started"); lv_checkbox_t * cb = (lv_checkbox_t *) obj; - /*Create the ancestor basic object*/ /*Init the new checkbox object*/ if(copy == NULL) { @@ -131,15 +130,11 @@ static void lv_checkbox_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ static void lv_checkbox_destructor(lv_obj_t * obj) { -// lv_checkbox_t * bar = obj; -// -// _lv_obj_reset_style_list_no_refr(obj, LV_PART_INDICATOR); -//#if LV_USE_ANIMATION -// lv_anim_del(&bar->cur_value_anim, NULL); -// lv_anim_del(&bar->start_value_anim, NULL); -//#endif - -// bar->class_p->base_p->destructor(obj); + lv_checkbox_t * cb = (lv_checkbox_t *) obj; + if(!cb->static_txt) { + lv_mem_free(cb->txt); + cb->txt = NULL; + } } static lv_draw_res_t lv_checkbox_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode) diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index ede6b1c1f..0b65cef96 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -35,12 +35,14 @@ /********************** * STATIC PROTOTYPES **********************/ +static lv_obj_t * lv_dropdown_list_create(lv_obj_t * parent, const lv_obj_t * copy); static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); static void lv_dropdown_destructor(lv_obj_t * obj); static lv_draw_res_t lv_dropdown_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_dropdown_signal(lv_obj_t * obj, lv_signal_t sign, void * param); static void lv_dropdown_list_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t * copy); +static void lv_dropdown_list_destructor(lv_obj_t * list_obj); static lv_draw_res_t lv_dropdown_list_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode); static lv_res_t lv_dropdown_list_signal(lv_obj_t * list, lv_signal_t sign, void * param); @@ -67,6 +69,7 @@ const lv_obj_class_t lv_dropdown_class = { const lv_obj_class_t lv_dropdown_list_class = { .constructor_cb = lv_dropdown_list_constructor, + .destructor_cb = lv_dropdown_list_destructor, .signal_cb = lv_dropdown_list_signal, .draw_cb = lv_dropdown_list_draw, .instance_size = sizeof(lv_dropdown_list_t), @@ -411,9 +414,13 @@ void lv_dropdown_open(lv_obj_t * dropdown_obj) lv_obj_add_state(dropdown_obj, LV_STATE_CHECKED); - lv_obj_clear_flag(dropdown->list, LV_OBJ_FLAG_HIDDEN); - lv_obj_clear_flag(dropdown->list, LV_OBJ_FLAG_CLICK_FOCUSABLE); - lv_obj_set_parent(dropdown->list, lv_obj_get_screen(dropdown_obj)); + if(dropdown->list == NULL) { + lv_obj_t * list_obj = lv_dropdown_list_create(lv_obj_get_screen(dropdown_obj), NULL); + ((lv_dropdown_list_t*) list_obj)->dropdown = dropdown_obj; + dropdown->list = list_obj; + lv_obj_clear_flag(dropdown->list, LV_OBJ_FLAG_CLICK_FOCUSABLE); + } + /*Set smaller width to the width of the button*/ if(lv_obj_get_width(dropdown->list) <= lv_obj_get_width(dropdown_obj) && (dropdown->dir == LV_DIR_TOP || dropdown->dir == LV_DIR_BOTTOM)) { @@ -501,21 +508,14 @@ void lv_dropdown_close(lv_obj_t * obj) lv_dropdown_t * dropdown = (lv_dropdown_t *) obj; dropdown->pr_opt_id = LV_DROPDOWN_PR_NONE; - lv_obj_add_flag(dropdown->list, LV_OBJ_FLAG_HIDDEN); + if(dropdown->list) lv_obj_del(dropdown->list); } /********************** * STATIC FUNCTIONS **********************/ -/** - * Create a switch objects - * @param parent pointer to an object, it will be the parent of the new switch - * @param copy DEPRECATED, will be removed in v9. - * Pointer to an other switch to copy. - * @return pointer to the created switch - */ -lv_obj_t * lv_dropdown_list_create(lv_obj_t * parent, const lv_obj_t * copy) +static lv_obj_t * lv_dropdown_list_create(lv_obj_t * parent, const lv_obj_t * copy) { return lv_obj_create_from_class(&lv_dropdown_list_class, parent, copy); } @@ -539,10 +539,6 @@ static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ dropdown->dir = LV_DIR_BOTTOM; dropdown->max_height = (3 * lv_disp_get_ver_res(NULL)) / 4; - lv_obj_t * list_obj = lv_dropdown_list_create(parent, copy); - ((lv_dropdown_list_t*)list_obj)->dropdown = (lv_obj_t *) dropdown; - dropdown->list = list_obj; - lv_obj_add_flag(dropdown->list, LV_OBJ_FLAG_HIDDEN); if(copy == NULL) { lv_obj_set_width(obj, LV_DPX(150)); @@ -569,24 +565,19 @@ static void lv_dropdown_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ static void lv_dropdown_destructor(lv_obj_t * obj) { -// lv_bar_t * bar = obj; -// -// _lv_obj_reset_style_list_no_refr(obj, LV_BAR_PART_INDIC); -// _lv_obj_reset_style_list_no_refr(sw, LV_PART_KNOB); -// -// bar->class_p->base_p->destructor(obj); + lv_dropdown_t * dropdown = (lv_dropdown_t *) obj; + + if(dropdown->list) { + lv_obj_del(dropdown->list); + dropdown->list = NULL; + } + + if(!dropdown->static_txt) { + lv_mem_free(dropdown->options); + dropdown->options = NULL; + } } -/** - * Handle the drawing related tasks of the drop down list - * @param ddlist pointer to an object - * @param clip_area the object will be drawn only in this area - * @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area - * (return 'true' if yes) - * LV_DRAW_DRAW: draw the object (always return 'true') - * LV_DRAW_DRAW_POST: drawing after every children are drawn - * @param return an element of `lv_draw_res_t` - */ static lv_draw_res_t lv_dropdown_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode) { /*Return false if the object is not covers the mask_p area*/ @@ -775,13 +766,14 @@ static void lv_dropdown_list_constructor(lv_obj_t * obj, lv_obj_t * parent, cons lv_label_create(obj, NULL); } -/** - * Signal function of the drop down list - * @param ddlist pointer to a drop down list object - * @param sign a signal type from lv_signal_t enum - * @param param pointer to a signal specific variable - * @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted - */ +static void lv_dropdown_list_destructor(lv_obj_t * list_obj) +{ + lv_dropdown_list_t * list = (lv_dropdown_list_t *)list_obj; + lv_obj_t * dropdown_obj = list->dropdown; + lv_dropdown_t * dropdown = (lv_dropdown_t *) dropdown_obj; + dropdown->list = NULL; +} + static lv_res_t lv_dropdown_signal(lv_obj_t * obj, lv_signal_t sign, void * param) { lv_res_t res; @@ -812,7 +804,7 @@ static lv_res_t lv_dropdown_signal(lv_obj_t * obj, lv_signal_t sign, void * para else if(sign == LV_SIGNAL_RELEASED) { lv_indev_t * indev = lv_indev_get_act(); if(lv_indev_get_scroll_obj(indev) == NULL) { - if(!lv_obj_has_flag(dropdown->list, LV_OBJ_FLAG_HIDDEN)) { + if(dropdown->list) { lv_dropdown_close(obj); if(dropdown->sel_opt_id_orig != dropdown->sel_opt_id) { dropdown->sel_opt_id_orig = dropdown->sel_opt_id; diff --git a/src/lv_widgets/lv_img.c b/src/lv_widgets/lv_img.c index 2ac010419..f6cfa1f80 100644 --- a/src/lv_widgets/lv_img.c +++ b/src/lv_widgets/lv_img.c @@ -401,11 +401,12 @@ static void lv_img_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj_t static void lv_img_destructor(lv_obj_t * obj) { -// if(img->src_type == LV_IMG_SRC_FILE || img->src_type == LV_IMG_SRC_SYMBOL) { -// lv_mem_free(img->src); -// img->src = NULL; -// img->src_type = LV_IMG_SRC_UNKNOWN; -// } + lv_img_t * img = (lv_img_t *)obj; + if(img->src_type == LV_IMG_SRC_FILE || img->src_type == LV_IMG_SRC_SYMBOL) { + lv_mem_free(img->src); + img->src = NULL; + img->src_type = LV_IMG_SRC_UNKNOWN; + } } static lv_draw_res_t lv_img_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode) diff --git a/src/lv_widgets/lv_meter.c b/src/lv_widgets/lv_meter.c index 3873807c8..feb5f9da3 100644 --- a/src/lv_widgets/lv_meter.c +++ b/src/lv_widgets/lv_meter.c @@ -234,18 +234,23 @@ static void lv_meter_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_obj static void lv_meter_destructor(lv_obj_t * obj) { + lv_meter_t * meter = (lv_meter_t *)obj; + lv_meter_scale_t * scale; + scale = _lv_ll_get_head(&meter->scale_ll); + while(scale) { + lv_meter_indicator_t * indicator = _lv_ll_get_head(&scale->indicator_ll); + while(indicator) { + _lv_ll_remove(&scale->indicator_ll, indicator); + lv_mem_free(indicator); + indicator = _lv_ll_get_head(&scale->indicator_ll); + } + _lv_ll_remove(&meter->scale_ll, scale); + lv_mem_free(scale); + scale = _lv_ll_get_head(&meter->scale_ll); + } } -/** - * Handle the drawing related tasks of the line meters - * @param lmeter pointer to an object - * @param clip_area the object will be drawn only in this area - * @param mode LV_DRAW_COVER_CHK: only check if the object fully covers the 'mask_p' area - * (return 'true' if yes) - * LV_DRAW_DRAW: draw the object (always return 'true') - * LV_DRAW_DRAW_POST: drawing after every children are drawn - * @param return an element of `lv_draw_res_t` - */ + static lv_draw_res_t lv_meter_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode) { /*Return false if the object is not covers the mask_p area*/ @@ -294,7 +299,7 @@ static lv_draw_res_t lv_meter_draw(lv_obj_t * obj, const lv_area_t * clip_area, static void draw_arcs(lv_obj_t * obj, const lv_area_t * clip_area, const lv_area_t * scale_area) { - lv_meter_t * meter = (lv_meter_t *)obj; + lv_meter_t * meter = (lv_meter_t *)obj; lv_draw_arc_dsc_t arc_dsc; lv_draw_arc_dsc_init(&arc_dsc); diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index 21045582a..823dca4fe 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -48,6 +48,7 @@ const lv_obj_class_t lv_roller_class = { .signal_cb = lv_roller_signal, .draw_cb = lv_roller_draw, .instance_size = sizeof(lv_roller_t), + .editable = LV_OBJ_CLASS_EDITABLE_TRUE, .base_class = &lv_obj_class }; @@ -56,7 +57,7 @@ const lv_obj_class_t lv_roller_label_class = { .draw_cb = lv_roller_label_draw, .instance_size = sizeof(lv_label_t), .base_class = &lv_label_class - };; + }; /********************** * MACROS @@ -299,7 +300,7 @@ static void lv_roller_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ob lv_obj_create_from_class(&lv_roller_label_class, obj, NULL); lv_roller_set_options(obj, "Option 1\nOption 2\nOption 3\nOption 4\nOption 5", LV_ROLLER_MODE_NORMAL); - lv_roller_set_visible_row_count(obj, 3); + lv_obj_set_height(obj, LV_DPI_DEF); } else { lv_obj_create_from_class(&lv_roller_label_class, obj, NULL); diff --git a/src/lv_widgets/lv_switch.c b/src/lv_widgets/lv_switch.c index 8391756f4..ffd43fa33 100644 --- a/src/lv_widgets/lv_switch.c +++ b/src/lv_widgets/lv_switch.c @@ -186,7 +186,7 @@ static lv_res_t lv_switch_signal(lv_obj_t * obj, lv_signal_t sign, void * param) if(res != LV_RES_OK) return res; - else if(sign == LV_SIGNAL_REFR_EXT_DRAW_SIZE) { + if(sign == LV_SIGNAL_REFR_EXT_DRAW_SIZE) { lv_coord_t knob_left = lv_obj_get_style_pad_left(obj, LV_PART_KNOB); lv_coord_t knob_right = lv_obj_get_style_pad_right(obj, LV_PART_KNOB); lv_coord_t knob_top = lv_obj_get_style_pad_top(obj, LV_PART_KNOB); @@ -199,6 +199,8 @@ static lv_res_t lv_switch_signal(lv_obj_t * obj, lv_signal_t sign, void * param) knob_size += lv_obj_calculate_ext_draw_size(obj, LV_PART_KNOB); + knob_size = (knob_size - lv_obj_get_height(obj)) / 2; + lv_coord_t * s = param; *s = LV_MAX(*s, knob_size); *s = LV_MAX(*s, lv_obj_calculate_ext_draw_size(obj, LV_PART_INDICATOR)); diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index 66ba47530..f1f12cac1 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -69,7 +69,6 @@ const lv_obj_class_t lv_textarea_class = { .destructor_cb = lv_textarea_destructor, .signal_cb = lv_textarea_signal, .draw_cb = lv_textarea_draw, - .editable = LV_OBJ_CLASS_EDITABLE_TRUE, .instance_size = sizeof(lv_textarea_t), .base_class = &lv_obj_class }; @@ -992,7 +991,7 @@ static void lv_textarea_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ } if(copy_ta->pwd_tmp) { - uint32_t len = lv_mem_get_size(copy_ta->pwd_tmp); + uint32_t len = strlen(copy_ta->pwd_tmp) + 1; ta->pwd_tmp = lv_mem_alloc(len); LV_ASSERT_MALLOC(ta->pwd_tmp); if(ta->pwd_tmp == NULL) return; @@ -1010,17 +1009,16 @@ static void lv_textarea_constructor(lv_obj_t * obj, lv_obj_t * parent, const lv_ static void lv_textarea_destructor(lv_obj_t * obj) { -// else if(sign == LV_SIGNAL_CLEANUP) { -// if(ta->pwd_tmp != NULL) lv_mem_free(ta->pwd_tmp); -// if(ta->placeholder_txt != NULL) lv_mem_free(ta->placeholder_txt); -// -// ta->pwd_tmp = NULL; -// ta->placeholder_txt = NULL; -// -// _lv_obj_reset_style_list_no_refr(obj, LV_PART_MARKER); -// _lv_obj_reset_style_list_no_refr(obj, LV_TEXTAREA_PART_PLACEHOLDER); -// -// /* (The created label will be deleted automatically) */ + + lv_textarea_t * ta = (lv_textarea_t *) obj; + if(ta->pwd_tmp != NULL) { + lv_mem_free(ta->pwd_tmp); + ta->pwd_tmp = NULL; + } + if(ta->placeholder_txt != NULL) { + lv_mem_free(ta->placeholder_txt); + ta->placeholder_txt = NULL; + } } static lv_draw_res_t lv_textarea_draw(lv_obj_t * obj, const lv_area_t * clip_area, lv_draw_mode_t mode)