diff --git a/README.md b/README.md index aa82ed46e..e9b613726 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ LittlevGL provides everything you need to create a Graphical User Interface (GUI * **OS, External memory and GPU** supported but not required * **Single frame buffer** operation even with advances graphical effects * **Written in C** for maximal compatibility +* **Micropython Binding** exposes [LittlevGL API in Micropython](https://blog.littlevgl.com/2019-02-20/micropython-bindings) * **Simulator** to develop on PC without embedded hardware * **Tutorials, examples, themes** for rapid development * **Documentation** and API references online @@ -186,6 +187,22 @@ lv_btn_set_ink_out_time(btn, 300); ![Simple button with LittelvGL](https://littlevgl.com/github/btn3.gif) +#### Use LittlevGL from Micropython +```python + +# Create a Button and a Label + +scr = lv.obj() +btn = lv.btn(scr) +btn.align(lv.scr_act(), lv.ALIGN.CENTER, 0, 0) +label = lv.label(btn) +label.set_text("Button") + +# Load the screen + +lv.scr_load(scr) +``` + Check out the [Documentation](https://docs.littlevgl.com/) for more! ### Contributing diff --git a/lv_core/lv_disp.h b/lv_core/lv_disp.h index e304fc43e..b291213ed 100644 --- a/lv_core/lv_disp.h +++ b/lv_core/lv_disp.h @@ -81,7 +81,7 @@ static inline lv_obj_t * lv_scr_act(void) * Get the top layer of the default display * @return pointer to the top layer */ -static inline lv_obj_t * lv_top_layer(void) +static inline lv_obj_t * lv_layer_top(void) { return lv_disp_get_layer_top(lv_disp_get_default()); } @@ -90,11 +90,17 @@ static inline lv_obj_t * lv_top_layer(void) * Get the active screen of the deafult display * @return pointer to the sys layer */ -static inline lv_obj_t * lv_sys_layer(void) +static inline lv_obj_t * lv_layer_sys(void) { return lv_disp_get_layer_sys(lv_disp_get_default()); } +static inline void lv_scr_load(lv_obj_t * scr) +{ + lv_disp_set_scr_act(scr); +} + + /********************** * MACROS **********************/ @@ -104,8 +110,8 @@ static inline lv_obj_t * lv_sys_layer(void) * Recommended only if you have one display *------------------------------------------------*/ -#define LV_HOR_RES (lv_disp_get_hor_res(lv_disp_get_default());) -#define LV_VER_RES (lv_disp_get_ver_res(lv_disp_get_default());) +#define LV_HOR_RES lv_disp_get_hor_res(lv_disp_get_default()) +#define LV_VER_RES lv_disp_get_ver_res(lv_disp_get_default()) #ifdef __cplusplus } /* extern "C" */ diff --git a/lv_core/lv_i18n.c b/lv_core/lv_i18n.c index c7fdb647d..f1816c0f2 100644 --- a/lv_core/lv_i18n.c +++ b/lv_core/lv_i18n.c @@ -163,17 +163,17 @@ const char * lv_i18n_get_text_plural(const char * msg_id, int32_t num) const lv_i18n_lang_t * lang = local_lang; - if(lang->plurals == NULL || lang->plural_rule == NULL) { + if(lang->plural_rule == NULL) { if(lang == languages[0]) { - LV_LOG_WARN("lv_i18n_get_text_plural: No plurals or plural rule has defined even on the default language"); + LV_LOG_WARN("lv_i18n_get_text_plural: No plural rule has defined even on the default language"); return msg_id; } else { - LV_LOG_WARN("lv_i18n_get_text_plural: o plurals or plural rule has defined for the language. Fallback to the default language"); + LV_LOG_WARN("lv_i18n_get_text_plural: No plural rule has defined for the language. Fallback to the default language"); lang = languages[0]; } - if(lang->plurals == NULL) { - LV_LOG_WARN("lv_i18n_get_text_plural: o plurals or plural rule has defined even on the default language"); + if(lang->plural_rule == NULL) { + LV_LOG_WARN("lv_i18n_get_text_plural: No plural rule has defined even on the default language"); return msg_id; } } diff --git a/lv_core/lv_indev.c b/lv_core/lv_indev.c index a5f2c9a0d..6cff598c3 100644 --- a/lv_core/lv_indev.c +++ b/lv_core/lv_indev.c @@ -143,9 +143,9 @@ void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj) { if(indev->driver.type != LV_INDEV_TYPE_POINTER) return; - indev->cursor = cur_obj; - lv_obj_set_parent(indev->cursor, lv_disp_get_layer_sys(indev->driver.disp)); - lv_obj_set_pos(indev->cursor, indev->proc.types.pointer.act_point.x, indev->proc.types.pointer.act_point.y); + indev->custom_data.cursor = cur_obj; + lv_obj_set_parent(indev->custom_data.cursor, lv_disp_get_layer_sys(indev->driver.disp)); + lv_obj_set_pos(indev->custom_data.cursor, indev->proc.types.pointer.act_point.x, indev->proc.types.pointer.act_point.y); } #if USE_LV_GROUP @@ -156,7 +156,9 @@ void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj) */ void lv_indev_set_group(lv_indev_t * indev, lv_group_t * group) { - if(indev->driver.type == LV_INDEV_TYPE_KEYPAD || indev->driver.type == LV_INDEV_TYPE_ENCODER) indev->group = group; + if(indev->driver.type == LV_INDEV_TYPE_KEYPAD || indev->driver.type == LV_INDEV_TYPE_ENCODER) { + indev->custom_data.group = group; + } } #endif @@ -168,7 +170,9 @@ void lv_indev_set_group(lv_indev_t * indev, lv_group_t * group) */ void lv_indev_set_button_points(lv_indev_t * indev, const lv_point_t * points) { - if(indev->driver.type == LV_INDEV_TYPE_BUTTON) indev->btn_points = points; + if(indev->driver.type == LV_INDEV_TYPE_BUTTON) { + indev->custom_data.btn_points = points; + } } /** @@ -353,10 +357,10 @@ static void indev_proc_task(void * param) static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data) { /*Move the cursor if set and moved*/ - if(i->cursor != NULL && + if(i->custom_data.cursor != NULL && (i->proc.types.pointer.last_point.x != data->point.x || i->proc.types.pointer.last_point.y != data->point.y)) { - lv_obj_set_pos(i->cursor, data->point.x, data->point.y); + lv_obj_set_pos(i->custom_data.cursor, data->point.x, data->point.y); } i->proc.types.pointer.act_point.x = data->point.x; @@ -380,14 +384,17 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data) static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) { #if USE_LV_GROUP - if(i->group == NULL) return; + lv_group_t * g = i->custom_data.group; + if(g == NULL) return; - lv_obj_t * focused = lv_group_get_focused(i->group); + lv_obj_t * focused = lv_group_get_focused(g); /*Key press happened*/ if(data->state == LV_INDEV_STATE_PR && i->proc.types.keypad.last_state == LV_INDEV_STATE_REL) { i->proc.pr_timestamp = lv_tick_get(); + + lv_obj_t * focused = lv_group_get_focused(g); if(focused && data->key == LV_GROUP_KEY_ENTER) { focused->signal_cb(focused, LV_SIGNAL_PRESSED, indev_act); lv_obj_send_event(focused, LV_EVENT_PRESSED); @@ -399,7 +406,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > LV_INDEV_LONG_PRESS_TIME) { /*On enter long press leave edit mode.*/ - lv_obj_t * focused = lv_group_get_focused(i->group); + lv_obj_t * focused = lv_group_get_focused(g); if(focused) { focused->signal_cb(focused, LV_SIGNAL_LONG_PRESS, indev_act); i->proc.long_pr_sent = 1; @@ -415,20 +422,20 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) /* Edit mode is not used by KEYPAD devices. * So leave edit mode if we are in it before focusing on the next/prev object*/ if(data->key == LV_GROUP_KEY_NEXT || data->key == LV_GROUP_KEY_PREV) { - lv_group_set_editing(i->group, false); + lv_group_set_editing(g, false); } if(data->key == LV_GROUP_KEY_NEXT) { - lv_group_focus_next(i->group); + lv_group_focus_next(g); } else if(data->key == LV_GROUP_KEY_PREV) { - lv_group_focus_prev(i->group); + lv_group_focus_prev(g); } else if(data->key == LV_GROUP_KEY_ENTER) { if(!i->proc.long_pr_sent) { focused->signal_cb(focused, LV_SIGNAL_RELEASED, indev_act); lv_obj_send_event(focused, LV_EVENT_CLICKED); } } else { - lv_group_send_data(i->group, data->key); + lv_group_send_data(g, data->key); } if(i->proc.reset_query) return; /*The object might be deleted in `focus_cb` or due to any other user event*/ @@ -453,26 +460,28 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) { #if USE_LV_GROUP - if(i->group == NULL) return; + lv_group_t * g = i->custom_data.group; + + if(g == NULL) return; /*Process the steps first. They are valid only with released button*/ if(data->state == LV_INDEV_STATE_REL) { /*In edit mode send LEFT/RIGHT keys*/ - if(lv_group_get_editing(i->group)) { + if(lv_group_get_editing(g)) { int32_t s; if(data->enc_diff < 0) { - for(s = 0; s < -data->enc_diff; s++) lv_group_send_data(i->group, LV_GROUP_KEY_LEFT); + for(s = 0; s < -data->enc_diff; s++) lv_group_send_data(g, LV_GROUP_KEY_LEFT); } else if(data->enc_diff > 0) { - for(s = 0; s < data->enc_diff; s++) lv_group_send_data(i->group, LV_GROUP_KEY_RIGHT); + for(s = 0; s < data->enc_diff; s++) lv_group_send_data(g, LV_GROUP_KEY_RIGHT); } } /*In navigate mode focus on the next/prev objects*/ else { int32_t s; if(data->enc_diff < 0) { - for(s = 0; s < -data->enc_diff; s++) lv_group_focus_prev(i->group); + for(s = 0; s < -data->enc_diff; s++) lv_group_focus_prev(g); } else if(data->enc_diff > 0) { - for(s = 0; s < data->enc_diff; s++) lv_group_focus_next(i->group); + for(s = 0; s < data->enc_diff; s++) lv_group_focus_next(g); } } } @@ -487,14 +496,14 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) if(i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > LV_INDEV_LONG_PRESS_TIME) { /*On enter long press leave edit mode.*/ - lv_obj_t * focused = lv_group_get_focused(i->group); + lv_obj_t * focused = lv_group_get_focused(g); bool editable = false; if(focused) focused->signal_cb(focused, LV_SIGNAL_GET_EDITABLE, &editable); if(editable) { - if(i->group->obj_ll.head != i->group->obj_ll.tail) - lv_group_set_editing(i->group, lv_group_get_editing(i->group) ? false : true); /*Toggle edit mode on long press*/ + if(g->obj_ll.head != g->obj_ll.tail) + lv_group_set_editing(g, lv_group_get_editing(g) ? false : true); /*Toggle edit mode on long press*/ else if(focused) focused->signal_cb(focused, LV_SIGNAL_LONG_PRESS, indev_act); } @@ -508,22 +517,22 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) } /*Release happened*/ else if(data->state == LV_INDEV_STATE_REL && i->proc.types.keypad.last_state == LV_INDEV_STATE_PR) { - lv_obj_t * focused = lv_group_get_focused(i->group); + lv_obj_t * focused = lv_group_get_focused(g); bool editable = false; if(focused) focused->signal_cb(focused, LV_SIGNAL_GET_EDITABLE, &editable); /*The button was released on a non-editable object. Just send enter*/ if(!editable) { - lv_group_send_data(i->group, LV_GROUP_KEY_ENTER); + lv_group_send_data(g, LV_GROUP_KEY_ENTER); } /*An object is being edited and the button is releases. Just send enter */ - else if(i->group->editing) { - if(!i->proc.long_pr_sent || i->group->obj_ll.head == i->group->obj_ll.tail) - lv_group_send_data(i->group, LV_GROUP_KEY_ENTER); /*Ignore long pressed enter release because it comes from mode switch*/ + else if(g->editing) { + if(!i->proc.long_pr_sent || g->obj_ll.head == g->obj_ll.tail) + lv_group_send_data(g, LV_GROUP_KEY_ENTER); /*Ignore long pressed enter release because it comes from mode switch*/ } /*If the focused object is editable and now in navigate mode then enter edit mode*/ - else if(editable && !i->group->editing && !i->proc.long_pr_sent) { - lv_group_set_editing(i->group, lv_group_get_editing(i->group) ? false : true); /*Toggle edit mode on long press*/ + else if(editable && !g->editing && !i->proc.long_pr_sent) { + lv_group_set_editing(g, lv_group_get_editing(g) ? false : true); /*Toggle edit mode on long press*/ } if(i->proc.reset_query) return; /*The object might be deleted in `focus_cb` or due to any other user event*/ @@ -548,8 +557,8 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) */ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data) { - i->proc.types.pointer.act_point.x = i->btn_points[data->btn_id].x; - i->proc.types.pointer.act_point.y = i->btn_points[data->btn_id].y; + i->proc.types.pointer.act_point.x = i->custom_data.btn_points[data->btn_id].x; + i->proc.types.pointer.act_point.y = i->custom_data.btn_points[data->btn_id].y; /*Still the same point is pressed*/ if(i->proc.types.pointer.last_point.x == i->proc.types.pointer.act_point.x && @@ -663,9 +672,6 @@ static void indev_proc_press(lv_indev_proc_t * proc) proc->types.pointer.drag_throw_vect.x += (proc->types.pointer.vect.x * 4) >> 3; proc->types.pointer.drag_throw_vect.y += (proc->types.pointer.vect.y * 4) >> 3; - printf("dtv:%d\n", proc->types.pointer.drag_throw_vect.y); - - /*If there is active object and it can be dragged run the drag*/ if(proc->types.pointer.act_obj != NULL) { proc->types.pointer.act_obj->signal_cb(proc->types.pointer.act_obj, LV_SIGNAL_PRESSING, indev_act); diff --git a/lv_core/lv_style.h b/lv_core/lv_style.h index 62cea3615..38f714d26 100644 --- a/lv_core/lv_style.h +++ b/lv_core/lv_style.h @@ -77,8 +77,6 @@ typedef struct lv_coord_t hor; lv_coord_t inner; } padding; - - uint8_t empty :1; /*Transparent background (border still drawn)*/ } body; diff --git a/lv_draw/lv_draw_img.c b/lv_draw/lv_draw_img.c index 369fbb761..f3d73c0b8 100644 --- a/lv_draw/lv_draw_img.c +++ b/lv_draw/lv_draw_img.c @@ -439,7 +439,7 @@ static const uint8_t * lv_img_decoder_open(const void * src, const lv_style_t * uint32_t i; for(i = 0; i < palette_size; i++) { - decoder_index_map[i] = LV_COLOR_MAKE(palette_p[i].red, palette_p[i].green, palette_p[i].blue); + decoder_index_map[i] = LV_COLOR_MAKE(palette_p[i].ch.red, palette_p[i].ch.green, palette_p[i].ch.blue); } return NULL; #else diff --git a/lv_hal/lv_hal_disp.h b/lv_hal/lv_hal_disp.h index a7e337a70..6725c854c 100644 --- a/lv_hal/lv_hal_disp.h +++ b/lv_hal/lv_hal_disp.h @@ -50,7 +50,7 @@ typedef struct void * buf_act; uint32_t size; /*In pixel count*/ lv_area_t area; - uint32_t flushing :1; + volatile uint32_t flushing :1; }lv_disp_buf_t; diff --git a/lv_hal/lv_hal_indev.c b/lv_hal/lv_hal_indev.c index 7ee8530e3..5026f7f65 100644 --- a/lv_hal/lv_hal_indev.c +++ b/lv_hal/lv_hal_indev.c @@ -80,9 +80,9 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver) memcpy(&node->driver, driver, sizeof(lv_indev_drv_t)); node->proc.reset_query = 1; - node->cursor = NULL; - node->group = NULL; - node->btn_points = NULL; + node->custom_data.cursor = NULL; + node->custom_data.group = NULL; + node->custom_data.btn_points = NULL; return node; } diff --git a/lv_hal/lv_hal_indev.h b/lv_hal/lv_hal_indev.h index 6c8101cf8..11b903891 100644 --- a/lv_hal/lv_hal_indev.h +++ b/lv_hal/lv_hal_indev.h @@ -57,12 +57,10 @@ typedef uint8_t lv_indev_state_t; /*Data type when an input device is read */ typedef struct { - union { - lv_point_t point; /*For LV_INDEV_TYPE_POINTER the currently pressed point*/ - uint32_t key; /*For LV_INDEV_TYPE_KEYPAD the currently pressed key*/ - uint32_t btn_id; /*For LV_INDEV_TYPE_BUTTON the currently pressed button*/ - int16_t enc_diff; /*For LV_INDEV_TYPE_ENCODER number of steps since the previous read*/ - }; + lv_point_t point; /*For LV_INDEV_TYPE_POINTER the currently pressed point*/ + uint32_t key; /*For LV_INDEV_TYPE_KEYPAD the currently pressed key*/ + uint32_t btn_id; /*For LV_INDEV_TYPE_BUTTON the currently pressed button*/ + int16_t enc_diff; /*For LV_INDEV_TYPE_ENCODER number of steps since the previous read*/ lv_indev_state_t state; /*LV_INDEV_STATE_REL or LV_INDEV_STATE_PR*/ @@ -133,7 +131,7 @@ typedef struct _lv_indev_t { struct _lv_group_t *group; /*Keypad destination group*/ const lv_point_t * btn_points; /*Array points assigned to the button ()screen will be pressed here by the buttons*/ - }; + }custom_data; } lv_indev_t; /********************** diff --git a/lv_misc/lv_color.h b/lv_misc/lv_color.h index 6afdc06b0..1774f2790 100644 --- a/lv_misc/lv_color.h +++ b/lv_misc/lv_color.h @@ -107,7 +107,7 @@ typedef union uint8_t blue :2; uint8_t green :3; uint8_t red :3; - }; + }ch; uint8_t full; } lv_color8_t; @@ -125,7 +125,7 @@ typedef union uint16_t blue :5; uint16_t green_l :3; #endif - }; + }ch; uint16_t full; } lv_color16_t; @@ -137,7 +137,7 @@ typedef union uint8_t green; uint8_t red; uint8_t alpha; - }; + }ch; uint32_t full; } lv_color32_t; @@ -189,32 +189,32 @@ static inline uint8_t lv_color_to1(lv_color_t color) #if LV_COLOR_DEPTH == 1 return color.full; #elif LV_COLOR_DEPTH == 8 - if((color.red & 0x4) || - (color.green & 0x4) || - (color.blue & 0x2)) { + if((color.ch.red & 0x4) || + (color.ch.green & 0x4) || + (color.ch.blue & 0x2)) { return 1; } else { return 0; } #elif LV_COLOR_DEPTH == 16 # if LV_COLOR_16_SWAP == 0 - if((color.red & 0x10) || - (color.green & 0x20) || - (color.blue & 0x10)) { + if((color.ch.red & 0x10) || + (color.ch.green & 0x20) || + (color.ch.blue & 0x10)) { return 1; # else - if((color.red & 0x10) || - (color.green_h & 0x20) || - (color.blue & 0x10)) { + if((color.ch.red & 0x10) || + (color.ch.green_h & 0x20) || + (color.ch.blue & 0x10)) { return 1; # endif } else { return 0; } #elif LV_COLOR_DEPTH == 32 - if((color.red & 0x80) || - (color.green & 0x80) || - (color.blue & 0x80)) { + if((color.ch.red & 0x80) || + (color.ch.green & 0x80) || + (color.ch.blue & 0x80)) { return 1; } else { return 0; @@ -233,22 +233,22 @@ static inline uint8_t lv_color_to8(lv_color_t color) # if LV_COLOR_16_SWAP == 0 lv_color8_t ret; - ret.red = color.red >> 2; /* 5 - 3 = 2*/ - ret.green = color.green >> 3; /* 6 - 3 = 3*/ - ret.blue = color.blue >> 3; /* 5 - 2 = 3*/ + ret.ch.red = color.ch.red >> 2; /* 5 - 3 = 2*/ + ret.ch.green = color.ch.green >> 3; /* 6 - 3 = 3*/ + ret.ch.blue = color.ch.blue >> 3; /* 5 - 2 = 3*/ return ret.full; # else lv_color8_t ret; - ret.red = color.red >> 2; /* 5 - 3 = 2*/ - ret.green = color.green_h; /* 6 - 3 = 3*/ - ret.blue = color.blue >> 3; /* 5 - 2 = 3*/ + ret.ch.red = color.ch.red >> 2; /* 5 - 3 = 2*/ + ret.ch.green = color.ch.green_h; /* 6 - 3 = 3*/ + ret.ch.blue = color.ch.blue >> 3; /* 5 - 2 = 3*/ return ret.full; # endif #elif LV_COLOR_DEPTH == 32 lv_color8_t ret; - ret.red = color.red >> 5; /* 8 - 3 = 5*/ - ret.green = color.green >> 5; /* 8 - 3 = 5*/ - ret.blue = color.blue >> 6; /* 8 - 2 = 6*/ + ret.ch.red = color.ch.red >> 5; /* 8 - 3 = 5*/ + ret.ch.green = color.ch.green >> 5; /* 8 - 3 = 5*/ + ret.ch.blue = color.ch.blue >> 6; /* 8 - 2 = 6*/ return ret.full; #endif } @@ -261,15 +261,15 @@ static inline uint16_t lv_color_to16(lv_color_t color) #elif LV_COLOR_DEPTH == 8 lv_color16_t ret; # if LV_COLOR_16_SWAP == 0 - ret.red = color.red * 4; /*(2^5 - 1)/(2^3 - 1) = 31/7 = 4*/ - ret.green = color.green * 9; /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/ - ret.blue = color.blue * 10; /*(2^5 - 1)/(2^2 - 1) = 31/3 = 10*/ + ret.ch.red = color.ch.red * 4; /*(2^5 - 1)/(2^3 - 1) = 31/7 = 4*/ + ret.ch.green = color.ch.green * 9; /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/ + ret.ch.blue = color.ch.blue * 10; /*(2^5 - 1)/(2^2 - 1) = 31/3 = 10*/ # else - ret.red = color.red * 4; - uint8_t g_tmp = color.green * 9; - ret.green_h = (g_tmp & 0x1F) >> 3; - ret.green_l = g_tmp & 0x07; - ret.blue = color.blue * 10; + ret.red = color.ch.red * 4; + uint8_t g_tmp = color.ch.green * 9; + ret.ch.green_h = (g_tmp & 0x1F) >> 3; + ret.ch.green_l = g_tmp & 0x07; + ret.ch.blue = color.ch.blue * 10; # endif return ret.full; #elif LV_COLOR_DEPTH == 16 @@ -277,14 +277,14 @@ static inline uint16_t lv_color_to16(lv_color_t color) #elif LV_COLOR_DEPTH == 32 lv_color16_t ret; # if LV_COLOR_16_SWAP == 0 - ret.red = color.red >> 3; /* 8 - 5 = 3*/ - ret.green = color.green >> 2; /* 8 - 6 = 2*/ - ret.blue = color.blue >> 3; /* 8 - 5 = 3*/ + ret.ch.red = color.ch.red >> 3; /* 8 - 5 = 3*/ + ret.ch.green = color.ch.green >> 2; /* 8 - 6 = 2*/ + ret.ch.blue = color.ch.blue >> 3; /* 8 - 5 = 3*/ # else - ret.red = color.red >> 3; - ret.green_h = (color.green & 0xE0) >> 5; - ret.green_l = (color.green & 0x1C) >> 2; - ret.blue = color.blue >> 3; + ret.ch.red = color.ch.red >> 3; + ret.ch.green_h = (color.ch.green & 0xE0) >> 5; + ret.ch.green_l = (color.ch.green & 0x1C) >> 2; + ret.ch.blue = color.ch.blue >> 3; # endif return ret.full; #endif @@ -297,25 +297,25 @@ static inline uint32_t lv_color_to32(lv_color_t color) else return 0xFFFFFFFF; #elif LV_COLOR_DEPTH == 8 lv_color32_t ret; - ret.red = color.red * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/ - ret.green = color.green * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/ - ret.blue = color.blue * 85; /*(2^8 - 1)/(2^2 - 1) = 255/3 = 85*/ - ret.alpha = 0xFF; + ret.ch.red = color.ch.red * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/ + ret.ch.green = color.ch.green * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/ + ret.ch.blue = color.ch.blue * 85; /*(2^8 - 1)/(2^2 - 1) = 255/3 = 85*/ + ret.ch.alpha = 0xFF; return ret.full; #elif LV_COLOR_DEPTH == 16 # if LV_COLOR_16_SWAP == 0 lv_color32_t ret; - ret.red = color.red * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/ - ret.green = color.green * 4; /*(2^8 - 1)/(2^6 - 1) = 255/63 = 4*/ - ret.blue = color.blue * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/ - ret.alpha = 0xFF; + ret.ch.red = color.ch.red * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/ + ret.ch.green = color.ch.green * 4; /*(2^8 - 1)/(2^6 - 1) = 255/63 = 4*/ + ret.ch.blue = color.ch.blue * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/ + ret.ch.alpha = 0xFF; return ret.full; # else lv_color32_t ret; - ret.red = color.red * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/ - ret.green = ((color.green_h << 3) + color.green_l) * 4; /*(2^8 - 1)/(2^6 - 1) = 255/63 = 4*/ - ret.blue = color.blue * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/ - ret.alpha = 0xFF; + ret.ch.red = color.ch.red * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/ + ret.ch.green = ((color.ch.green_h << 3) + color.ch.green_l) * 4; /*(2^8 - 1)/(2^6 - 1) = 255/63 = 4*/ + ret.ch.blue = color.ch.blue * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/ + ret.ch.alpha = 0xFF; return ret.full; # endif #elif LV_COLOR_DEPTH == 32 @@ -328,20 +328,20 @@ static inline lv_color_t lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix) lv_color_t ret; #if LV_COLOR_DEPTH != 1 /*LV_COLOR_DEPTH == 8, 16 or 32*/ - ret.red = (uint16_t)((uint16_t) c1.red * mix + (c2.red * (255 - mix))) >> 8; + ret.ch.red = (uint16_t)((uint16_t) c1.ch.red * mix + (c2.ch.red * (255 - mix))) >> 8; # if LV_COLOR_DEPTH == 16 && LV_COLOR_16_SWAP /*If swapped Green is in 2 parts*/ - uint16_t g_1 = (c1.green_h << 3) + c1.green_l; - uint16_t g_2 = (c2.green_h << 3) + c2.green_l; + uint16_t g_1 = (c1.ch.green_h << 3) + c1.ch.green_l; + uint16_t g_2 = (c2.ch.green_h << 3) + c2.ch.green_l; uint16_t g_out = (uint16_t)((uint16_t) g_1 * mix + (g_2 * (255 - mix))) >> 8; - ret.green_h = g_out >> 3; - ret.green_l = g_out & 0x7; + ret.ch.green_h = g_out >> 3; + ret.ch.green_l = g_out & 0x7; # else - ret.green = (uint16_t)((uint16_t) c1.green * mix + (c2.green * (255 - mix))) >> 8; + ret.ch.green = (uint16_t)((uint16_t) c1.ch.green * mix + (c2.ch.green * (255 - mix))) >> 8; # endif - ret.blue = (uint16_t)((uint16_t) c1.blue * mix + (c2.blue * (255 - mix))) >> 8; + ret.ch.blue = (uint16_t)((uint16_t) c1.ch.blue * mix + (c2.ch.blue * (255 - mix))) >> 8; # if LV_COLOR_DEPTH == 32 - ret.alpha = 0xFF; + ret.ch.alpha = 0xFF; # endif #else /*LV_COLOR_DEPTH == 1*/ @@ -360,7 +360,7 @@ static inline uint8_t lv_color_brightness(lv_color_t color) { lv_color32_t c32; c32.full = lv_color_to32(color); - uint16_t bright = 3 * c32.red + c32.blue + 4 * c32.green; + uint16_t bright = 3 * c32.ch.red + c32.ch.blue + 4 * c32.ch.green; return (uint16_t) bright >> 3; } diff --git a/lv_objx/lv_btnm.c b/lv_objx/lv_btnm.c index 16d910a57..cba525c34 100644 --- a/lv_objx/lv_btnm.c +++ b/lv_objx/lv_btnm.c @@ -28,14 +28,17 @@ **********************/ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param); static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mode_t mode); -static uint8_t get_button_width(const char * btn_str); -static bool button_is_hidden(const char * btn_str); -static bool button_is_repeat_disabled(const char * btn_str); -static bool button_is_inactive(const char * btn_str); +static uint8_t get_button_width(lv_btnm_ctrl_t ctrl_bits); +static bool button_is_hidden(lv_btnm_ctrl_t ctrl_bits); +static bool button_is_repeat_disabled(lv_btnm_ctrl_t ctrl_bits); +static bool button_is_inactive(lv_btnm_ctrl_t ctrl_bits); const char * cut_ctrl_byte(const char * btn_str); static uint16_t get_button_from_point(lv_obj_t * btnm, lv_point_t * p); static uint16_t get_button_text(lv_obj_t * btnm, uint16_t btn_id); -static void allocate_btn_areas(lv_obj_t * btnm, const char ** map); +static void parse_control_bytes(const lv_obj_t * btnm, const char ** map); +static void allocate_btn_areas_and_controls(const lv_obj_t * btnm, const char ** map); +static void invalidate_button_area(const lv_obj_t * btnm, uint16_t btn_idx); +static bool maps_are_identical(const char ** map1, const char ** map2); /********************** * STATIC VARIABLES @@ -81,6 +84,7 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy) ext->btn_id_pr = LV_BTNM_PR_NONE; ext->btn_id_tgl = LV_BTNM_PR_NONE; ext->button_areas = NULL; + ext->ctrl_bits = NULL; ext->action = NULL; ext->map_p = NULL; ext->toggle = 0; @@ -133,7 +137,9 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy) *====================*/ /** - * Set a new map. Buttons will be created/deleted according to the map. + * Set a new map. Buttons will be created/deleted according to the map. The + * button matrix keeps a reference to the map and so the string array must not + * be deallocated during the life of the matrix. * @param btnm pointer to a button matrix object * @param map pointer a string array. The last string has to be: "". * Use "\n" to begin a new line. @@ -144,17 +150,34 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy) * - bit 4: no repeat (on long press) (\22x) * - bit 3: hidden (\21x) * - bit 2..0: button relative width - * Example (practically use octal numbers): "\224abc": "abc" text with 4 width and no long press + * Example (practically use octal numbers): "\224abc": "abc" text + * with 4 width and no long press. */ -void lv_btnm_set_map(lv_obj_t * btnm, const char ** map) +void lv_btnm_set_map(const lv_obj_t * btnm, const char ** map) { if(map == NULL) return; + /* + * lv_btnm_set_map is called on receipt of signals such as + * LV_SIGNAL_CORD_CHG regardless of whether the map has changed (e.g. + * calling lv_obj_align on the map will trigger this). + * + * We check if the map has changed here to avoid overwriting changes made + * to hidden/longpress/disabled states after the map was originally set. + * + * TODO: separate all map set/allocation from layout code below and skip + * set/allocation when map hasn't changed. + */ lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); - ext->map_p = map; + if (!maps_are_identical(ext->map_p, map)) { - /*Analyze the map and create the required number of buttons*/ - allocate_btn_areas(btnm, map); + /*Analyze the map and create the required number of buttons*/ + allocate_btn_areas_and_controls(btnm, map); + + /*Set the control bytes*/ + parse_control_bytes(btnm, map); + } + ext->map_p = map; /*Set size and positions of the buttons*/ lv_style_t * style_bg = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG); @@ -189,7 +212,7 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map) /*Count the buttons in a line*/ while(strcmp(map_p_tmp[btn_cnt], "\n") != 0 && strlen(map_p_tmp[btn_cnt]) != 0) { /*Check a line*/ - unit_cnt += get_button_width(map_p_tmp[btn_cnt]); + unit_cnt += get_button_width(ext->ctrl_bits[btn_i + btn_cnt]); btn_cnt ++; } @@ -212,7 +235,7 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map) /* one_unit_w = all_unit_w / unit_cnt * act_unit_w = one_unit_w * button_width * do this two operations but the multiply first to divide a greater number */ - act_unit_w = (all_unit_w * get_button_width(map_p_tmp[i])) / unit_cnt; + act_unit_w = (all_unit_w * get_button_width(ext->ctrl_bits[btn_i])) / unit_cnt; act_unit_w --; /*-1 because e.g. width = 100 means 101 pixels (0..100)*/ /*Always recalculate act_x because of rounding errors */ @@ -228,7 +251,7 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map) act_x + act_unit_w, act_y + btn_h); } - unit_act_cnt += get_button_width(map_p_tmp[i]); + unit_act_cnt += get_button_width(ext->ctrl_bits[btn_i]); i_tot ++; btn_i ++; @@ -245,6 +268,30 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map) lv_obj_invalidate(btnm); } +/** + * Set the button control map (hidden, disabled etc.) for a button matrix. The + * control map array will be copied and so may be deallocated after this + * function returns. + * @param btnm pointer to a button matrix object + * @param ctrl_map pointer to an array of `lv_btn_ctrl_t` control bytes. The + * length of the array and position of the elements must match + * that when the map was set via `lv_btnm_set_map` (i.e. one + * element for each button AND new line). + * The control bits are: + * - bit 5 : 1 = inactive (disabled) + * - bit 4 : 1 = no repeat (on long press) + * - bit 3 : 1 = hidden + * - bit 2..0: Relative width compared to the buttons in the + * same row. [1..7] + */ +void lv_btnm_set_ctrl_map(const lv_obj_t * btnm, const lv_btnm_ctrl_t * ctrl_map) +{ + lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); + memcpy(ext->ctrl_bits, ctrl_map, sizeof(lv_btnm_ctrl_t) * ext->btn_cnt); + + lv_btnm_set_map(btnm, ext->map_p); +} + /** * Set a new callback function for the buttons (It will be called when a button is released) * @param btnm: pointer to button matrix object @@ -322,6 +369,105 @@ void lv_btnm_set_recolor(const lv_obj_t * btnm, bool en) lv_obj_invalidate(btnm); } +/** + * Show/hide a single button in the matrix + * @param btnm pointer to button matrix object + * @param btn_idx 0 based index of the button to modify. + * @param hidden true: hide the button + */ +void lv_btnm_set_btn_hidden(const lv_obj_t * btnm, uint16_t btn_idx, bool hidden) +{ + lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); + if (btn_idx >= ext->btn_cnt) return; + if (hidden) + ext->ctrl_bits[btn_idx] |= LV_BTNM_HIDE_MASK; + else + ext->ctrl_bits[btn_idx] &= (~LV_BTNM_HIDE_MASK); + + invalidate_button_area(btnm, btn_idx); +} + +/** + * Enable/disable a single button in the matrix + * @param btnm pointer to button matrix object + * @param btn_idx 0 based index of the button to modify. + * @param disabled true: disable the button + */ +void lv_btnm_set_btn_disabled(const lv_obj_t * btnm, uint16_t btn_idx, bool disabled) +{ + lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); + if (btn_idx >= ext->btn_cnt) return; + if (disabled) + ext->ctrl_bits[btn_idx] |= LV_BTNM_INACTIVE_MASK; + else + ext->ctrl_bits[btn_idx] &= (~LV_BTNM_INACTIVE_MASK); + + invalidate_button_area(btnm, btn_idx); +} + +/** + * Enable/disable long press for a single button in the matrix + * @param btnm pointer to button matrix object + * @param btn_idx 0 based index of the button to modify. + * @param disabled true: disable repeat + */ +void lv_btnm_set_btn_disable_repeat(const lv_obj_t * btnm, uint16_t btn_idx, bool disabled) +{ + lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); + if (btn_idx >= ext->btn_cnt) return; + if (disabled) + ext->ctrl_bits[btn_idx] |= LV_BTNM_REPEAT_DISABLE_MASK; + else + ext->ctrl_bits[btn_idx] &= (~LV_BTNM_REPEAT_DISABLE_MASK); + + invalidate_button_area(btnm, btn_idx); +} + +/*** + * Set hidden/disabled/repeat flags for a single button. + * @param btnm pointer to button matrix object + * @param btn_idx 0 based index of the button to modify. + * @param hidden true: hide the button + * @param disabled true: disable the button + * @param disable_repeat true: disable repeat + */ +void lv_btnm_set_btn_flags(const lv_obj_t * btnm, uint16_t btn_idx, bool hidden, bool disabled, bool disable_repeat) +{ + lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); + if (btn_idx >= ext->btn_cnt) return; + + uint8_t flags = ext->ctrl_bits[btn_idx]; + + flags = hidden ? flags | LV_BTNM_HIDE_MASK : flags & (~LV_BTNM_HIDE_MASK); + flags = disabled ? flags | LV_BTNM_INACTIVE_MASK : flags & (~LV_BTNM_INACTIVE_MASK); + flags = disable_repeat ? flags | LV_BTNM_REPEAT_DISABLE_MASK : flags & (~LV_BTNM_REPEAT_DISABLE_MASK); + + ext->ctrl_bits[btn_idx] = flags; + invalidate_button_area(btnm, btn_idx); +} + + +/** + * Set a single buttons relative width. + * This method will cause the matrix be regenerated and is a relatively + * expensive operation. It is recommended that initial width be specified using + * the control characters when calling `lv_btnm_set_map` or via + * `lv_btnm_set_ctrl_map` and this method only be used for dynamic changes. + * @param btnm pointer to button matrix object + * @param btn_idx 0 based index of the button to modify. + * @param width Relative width compared to the buttons in the same row. [1..7] + */ +void lv_btnm_set_btn_width(const lv_obj_t * btnm, uint16_t btn_idx, uint8_t width) { + + lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); + if (btn_idx >= ext->btn_cnt) return; + ext->ctrl_bits[btn_idx] &= (~LV_BTNM_WIDTH_MASK); + ext->ctrl_bits[btn_idx] |= (LV_BTNM_WIDTH_MASK & width); + + lv_btnm_set_map(btnm, ext->map_p); +} + + /*===================== * Getter functions *====================*/ @@ -468,7 +614,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo } /*Skip hidden buttons*/ - if(button_is_hidden(ext->map_p[txt_i])) continue; + if(button_is_hidden(ext->ctrl_bits[btn_i])) continue; lv_area_copy(&area_tmp, &ext->button_areas[btn_i]); area_tmp.x1 += area_btnm.x1; @@ -480,7 +626,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo btn_h = lv_area_get_height(&area_tmp); /*Load the style*/ - if(button_is_inactive(ext->map_p[txt_i])) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_INA); + if(button_is_inactive(ext->ctrl_bits[btn_i])) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_INA); else if(btn_i != ext->btn_id_pr && btn_i != ext->btn_id_tgl) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_REL); else if(btn_i == ext->btn_id_pr && btn_i != ext->btn_id_tgl) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_PR); else if(btn_i != ext->btn_id_pr && btn_i == ext->btn_id_tgl) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_REL); @@ -546,11 +692,10 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) if(res != LV_RES_OK) return res; lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); - lv_area_t btnm_area; - lv_area_t btn_area; lv_point_t p; if(sign == LV_SIGNAL_CLEANUP) { lv_mem_free(ext->button_areas); + lv_mem_free(ext->ctrl_bits); } else if(sign == LV_SIGNAL_STYLE_CHG || sign == LV_SIGNAL_CORD_CHG) { lv_btnm_set_map(btnm, ext->map_p); } else if(sign == LV_SIGNAL_PRESSING) { @@ -559,25 +704,14 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) lv_indev_get_point(param, &p); btn_pr = get_button_from_point(btnm, &p); /*Invalidate to old and the new areas*/; - lv_obj_get_coords(btnm, &btnm_area); + //lv_obj_get_coords(btnm, &btnm_area); if(btn_pr != ext->btn_id_pr) { - lv_disp_t * disp = lv_obj_get_disp(btnm); lv_indev_reset_lpr(param); if(ext->btn_id_pr != LV_BTNM_PR_NONE) { - lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_pr]); - btn_area.x1 += btnm_area.x1; - btn_area.y1 += btnm_area.y1; - btn_area.x2 += btnm_area.x1; - btn_area.y2 += btnm_area.y1; - lv_inv_area(disp, &btn_area); + invalidate_button_area(btnm, ext->btn_id_pr); } if(btn_pr != LV_BTNM_PR_NONE) { - lv_area_copy(&btn_area, &ext->button_areas[btn_pr]); - btn_area.x1 += btnm_area.x1; - btn_area.y1 += btnm_area.y1; - btn_area.x2 += btnm_area.x1; - btn_area.y2 += btnm_area.y1; - lv_inv_area(disp, &btn_area); + invalidate_button_area(btnm, btn_pr); } } @@ -588,8 +722,8 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) if(ext->action && ext->btn_id_pr != LV_BTNM_PR_NONE) { uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr); if(txt_i != LV_BTNM_PR_NONE) { - if(button_is_repeat_disabled(ext->map_p[txt_i]) == false && - button_is_inactive(ext->map_p[txt_i]) == false) { + if(button_is_repeat_disabled(ext->ctrl_bits[ext->btn_id_pr]) == false && + button_is_inactive(ext->ctrl_bits[ext->btn_id_pr]) == false) { res = ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i])); } } @@ -597,28 +731,16 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) } else if(sign == LV_SIGNAL_RELEASED) { if(ext->btn_id_pr != LV_BTNM_PR_NONE) { uint16_t txt_i = get_button_text(btnm, ext->btn_id_pr); - if(button_is_inactive(ext->map_p[txt_i]) == false && txt_i != LV_BTNM_PR_NONE) { /*Ignore the inactive buttons anf click between the buttons*/ + if(button_is_inactive(ext->ctrl_bits[ext->btn_id_pr]) == false && txt_i != LV_BTNM_PR_NONE) { /*Ignore the inactive buttons and clicks between the buttons*/ if(ext->action) res = ext->action(btnm, cut_ctrl_byte(ext->map_p[txt_i])); if(res == LV_RES_OK) { - lv_disp_t * disp = lv_obj_get_disp(btnm); - /*Invalidate to old pressed area*/; - lv_obj_get_coords(btnm, &btnm_area); - lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_pr]); - btn_area.x1 += btnm_area.x1; - btn_area.y1 += btnm_area.y1; - btn_area.x2 += btnm_area.x1; - btn_area.y2 += btnm_area.y1; - lv_inv_area(disp, &btn_area); + invalidate_button_area(btnm, ext->btn_id_pr); if(ext->toggle != 0) { /*Invalidate to old toggled area*/; - lv_area_copy(&btn_area, &ext->button_areas[ext->btn_id_tgl]); - btn_area.x1 += btnm_area.x1; - btn_area.y1 += btnm_area.y1; - btn_area.x2 += btnm_area.x1; - btn_area.y2 += btnm_area.y1; - lv_inv_area(disp, &btn_area); + invalidate_button_area(btnm, ext->btn_id_tgl); + ext->btn_id_tgl = ext->btn_id_pr; } @@ -736,11 +858,11 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) } /** - * Create the required number of buttons according to a map + * Create the required number of buttons and control bytes according to a map * @param btnm pointer to button matrix object * @param map_p pointer to a string array */ -static void allocate_btn_areas(lv_obj_t * btnm, const char ** map) +static void allocate_btn_areas_and_controls(const lv_obj_t * btnm, const char ** map) { /*Count the buttons in the map*/ uint16_t btn_cnt = 0; @@ -758,59 +880,60 @@ static void allocate_btn_areas(lv_obj_t * btnm, const char ** map) lv_mem_free(ext->button_areas); ext->button_areas = NULL; } + if(ext->ctrl_bits != NULL) { + lv_mem_free(ext->ctrl_bits); + ext->ctrl_bits = NULL; + } ext->button_areas = lv_mem_alloc(sizeof(lv_area_t) * btn_cnt); lv_mem_assert(ext->button_areas); - if(ext->button_areas == NULL) btn_cnt = 0; + ext->ctrl_bits = lv_mem_alloc(sizeof(lv_btnm_ctrl_t) * btn_cnt); + lv_mem_assert(ext->ctrl_bits); + if(ext->button_areas == NULL || ext->ctrl_bits == NULL) btn_cnt = 0; ext->btn_cnt = btn_cnt; } /** - * Get the width of a button in units. It comes from the first "letter". - * @param btn_str The descriptor string of a button. E.g. "apple" or "\004banana" + * Set the control bytes as provided in the map strings + * @param btnm pointer to button matrix object + * @param map_p pointer to a string array + */ +static void parse_control_bytes(const lv_obj_t * btnm, const char ** map) +{ + lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); + + for (uint16_t i = 0; i < ext->btn_cnt; i++) { + ext->ctrl_bits[i] = ((map[i][0] & LV_BTNM_CTRL_MASK) == LV_BTNM_CTRL_CODE) + ? map[i][0] + : 0; + } +} + + +/** + * Get the width of a button in units (default is 1). + * @param ctrl_bits least significant 3 bits used (1..7 valid values) * @return the width of the button in units */ -static uint8_t get_button_width(const char * btn_str) +static uint8_t get_button_width(lv_btnm_ctrl_t ctrl_bits) { - if((btn_str[0] & LV_BTNM_CTRL_MASK) == LV_BTNM_CTRL_CODE) { - return btn_str[0] & LV_BTNM_WIDTH_MASK; - } - - return 1; /*Default width is 1*/ + return ctrl_bits ? ctrl_bits & LV_BTNM_WIDTH_MASK : 1; } -static bool button_is_hidden(const char * btn_str) +static bool button_is_hidden(lv_btnm_ctrl_t ctrl_bits) { - /*If control byte presents and hidden bit is '1' then the button is hidden*/ - if(((btn_str[0] & LV_BTNM_CTRL_MASK) == LV_BTNM_CTRL_CODE) && - (btn_str[0] & LV_BTNM_HIDE_MASK)) { - return true; - } - - return false; + return ctrl_bits & LV_BTNM_HIDE_MASK; } -static bool button_is_repeat_disabled(const char * btn_str) +static bool button_is_repeat_disabled(lv_btnm_ctrl_t ctrl_bits) { - /*If control byte presents and hidden bit is '1' then the button is hidden*/ - if(((btn_str[0] & LV_BTNM_CTRL_MASK) == LV_BTNM_CTRL_CODE) && - (btn_str[0] & LV_BTNM_REPEAT_DISABLE_MASK)) { - return true; - } - - return false; + return ctrl_bits & LV_BTNM_REPEAT_DISABLE_MASK; } -static bool button_is_inactive(const char * btn_str) +static bool button_is_inactive(lv_btnm_ctrl_t ctrl_bits) { - /*If control byte presents and hidden bit is '1' then the button is hidden*/ - if(((btn_str[0] & LV_BTNM_CTRL_MASK) == LV_BTNM_CTRL_CODE) && - (btn_str[0] & LV_BTNM_INACTIVE_MASK)) { - return true; - } - - return false; + return ctrl_bits & LV_BTNM_INACTIVE_MASK; } @@ -878,5 +1001,45 @@ static uint16_t get_button_text(lv_obj_t * btnm, uint16_t btn_id) return txt_i; } +static void invalidate_button_area(const lv_obj_t * btnm, uint16_t btn_idx) +{ + lv_area_t btn_area; + lv_area_t btnm_area; + + lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); + lv_area_copy(&btn_area, &ext->button_areas[btn_idx]); + lv_obj_get_coords(btnm, &btnm_area); + + /* Convert relative coordinates to absolute */ + btn_area.x1 += btnm_area.x1; + btn_area.y1 += btnm_area.y1; + btn_area.x2 += btnm_area.x1; + btn_area.y2 += btnm_area.y1; + + lv_inv_area(lv_obj_get_disp(btnm), &btn_area); +} + +/** + * Compares two button matrix maps for equality + * @param map1 map to compare + * @param map2 map to compare + * @return true if maps are identical in length and content + */ +static bool maps_are_identical(const char ** map1, const char ** map2) +{ + if (map1 == map2) + return true; + if (map1 == NULL || map2 == NULL) + return map1 == map2; + + uint16_t i = 0; + while (map1[i][0] != '\0' && map2[i][0] != '\0') { + if (strcmp(map1[i], map2[i]) !=0 ) + return false; + i++; + } + return map1[i][0] == '\0' && map2[i][0] == '\0'; +} + #endif diff --git a/lv_objx/lv_btnm.h b/lv_objx/lv_btnm.h index de334b753..36f3241d5 100644 --- a/lv_objx/lv_btnm.h +++ b/lv_objx/lv_btnm.h @@ -32,6 +32,9 @@ extern "C" { /*Control byte*/ #define LV_BTNM_CTRL_CODE 0x80 /*The control byte has to begin (if present) with 0b10xxxxxx*/ + /*This is only true when using control chars in calls to */ + /*`lv_btnm_set_map`. These bits are ignored in when calling */ + /*`lv_btnm_set_ctrl_map` */ #define LV_BTNM_CTRL_MASK 0xC0 #define LV_BTNM_WIDTH_MASK 0x07 #define LV_BTNM_HIDE_MASK 0x08 @@ -49,6 +52,9 @@ extern "C" { * return LV_ACTION_RES_INV if the button matrix is deleted else LV_ACTION_RES_OK*/ typedef lv_res_t (*lv_btnm_action_t) (lv_obj_t *, const char *txt); +/* Type to store button control bits (disabled, hidden etc.) */ +typedef uint8_t lv_btnm_ctrl_t; + /*Data of button matrix*/ typedef struct { @@ -56,6 +62,7 @@ typedef struct /*New data for this type */ const char ** map_p; /*Pointer to the current map*/ lv_area_t *button_areas; /*Array of areas of buttons*/ + lv_btnm_ctrl_t *ctrl_bits; /*Array of control bytes*/ lv_btnm_action_t action; /*A function to call when a button is releases*/ lv_style_t *styles_btn[LV_BTN_STATE_NUM]; /*Styles of buttons in each state*/ uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/ @@ -92,7 +99,9 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy); *====================*/ /** - * Set a new map. Buttons will be created/deleted according to the map. + * Set a new map. Buttons will be created/deleted according to the map. The + * button matrix keeps a reference to the map and so the string array must not + * be deallocated during the life of the matrix. * @param btnm pointer to a button matrix object * @param map pointer a string array. The last string has to be: "". * Use "\n" to begin a new line. @@ -105,7 +114,25 @@ lv_obj_t * lv_btnm_create(lv_obj_t * par, const lv_obj_t * copy); * - bit 2..0: button relative width * Example (practically use octal numbers): "\224abc": "abc" text with 4 width and no long press */ -void lv_btnm_set_map(lv_obj_t * btnm, const char ** map); +void lv_btnm_set_map(const lv_obj_t * btnm, const char ** map); + +/** + * Set the button control map (hidden, disabled etc.) for a button matrix. The + * control map array will be copied and so may be deallocated after this + * function returns. + * @param btnm pointer to a button matrix object + * @param ctrl_map pointer to an array of `lv_btn_ctrl_t` control bytes. The + * length of the array and position of the elements must match + * that when the map was set via `lv_btnm_set_map` (i.e. one + * element for each button AND new line). + * The control bits are: + * - bit 5 : 1 = inactive (disabled) + * - bit 4 : 1 = no repeat (on long press) + * - bit 3 : 1 = hidden + * - bit 2..0: Relative width compared to the buttons in the + * same row. [1..7] + */ +void lv_btnm_set_ctrl_map(const lv_obj_t * btnm, const lv_btnm_ctrl_t * ctrl_map); /** * Set a new callback function for the buttons (It will be called when a button is released) @@ -137,6 +164,53 @@ void lv_btnm_set_style(lv_obj_t *btnm, lv_btnm_style_t type, lv_style_t *style); */ void lv_btnm_set_recolor(const lv_obj_t * btnm, bool en); +/** + * Show/hide a single button in the matrix + * @param btnm pointer to button matrix object + * @param btn_idx 0 based index of the button to modify. + * @param hidden true: hide the button + */ +void lv_btnm_set_btn_hidden(const lv_obj_t * btnm, uint16_t btn_idx, bool hidden); + +/** + * Enable/disable a single button in the matrix + * @param btnm pointer to button matrix object + * @param btn_idx 0 based index of the button to modify. + * @param disabled true: disable the button + */ +void lv_btnm_set_btn_disabled(const lv_obj_t * btnm, uint16_t btn_idx, bool disabled); + +/** + * Enable/disable long press for a single button in the matrix + * @param btnm pointer to button matrix object + * @param btn_idx 0 based index of the button to modify. + * @param disabled true: disable repeat + */ +void lv_btnm_set_btn_disable_repeat(const lv_obj_t * btnm, uint16_t btn_idx, bool disabled); + +/*** + * Set hidden/disabled/repeat flags for a single button. + * @param btnm pointer to button matrix object + * @param btn_idx 0 based index of the button to modify. + * @param hidden true: hide the button + * @param disabled true: disable the button + * @param disable_repeat true: disable repeat + */ +void lv_btnm_set_btn_flags(const lv_obj_t * btnm, uint16_t btn_idx, bool hidden, bool disabled, bool disable_repeat); + +/** + * Set a single buttons relative width. + * This method will cause the matrix be regenerated and is a relatively + * expensive operation. It is recommended that initial width be specified using + * the control characters when calling `lv_btnm_set_map` or via + * `lv_btnm_set_ctrl_map` and this method only be used for dynamic changes. + * @param btnm pointer to button matrix object + * @param btn_idx 0 based index of the button to modify. + * @param width Relative width compared to the buttons in the same row. [1..7] + */ +void lv_btnm_set_btn_width(const lv_obj_t * btnm, uint16_t btn_idx, uint8_t width); + + /*===================== * Getter functions *====================*/ diff --git a/lv_objx/lv_canvas.c b/lv_objx/lv_canvas.c index 83f0b9bac..3c0ab20a3 100644 --- a/lv_objx/lv_canvas.c +++ b/lv_objx/lv_canvas.c @@ -341,25 +341,25 @@ void lv_canvas_mult_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coor for(i = 0; i < h; i++) { for(j = 0; j < w; j++) { #if LV_COLOR_DEPTH == 32 - canvas_buf_color[j].red = (uint16_t) ((uint16_t) canvas_buf_color[j].red * copy_buf_color[j].red) >> 8; - canvas_buf_color[j].green = (uint16_t) ((uint16_t) canvas_buf_color[j].green * copy_buf_color[j].green) >> 8; - canvas_buf_color[j].blue = (uint16_t) ((uint16_t) canvas_buf_color[j].blue * copy_buf_color[j].blue) >> 8; + canvas_buf_color[j].ch.red = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.red * copy_buf_color[j].ch.red) >> 8; + canvas_buf_color[j].ch.green = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.green * copy_buf_color[j].ch.green) >> 8; + canvas_buf_color[j].ch.blue = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.blue * copy_buf_color[j].ch.blue) >> 8; #elif LV_COLOR_DEPTH == 16 - canvas_buf_color[j].red = (uint16_t) ((uint16_t) canvas_buf_color[j].red * copy_buf_color[j].red) >> 5; - canvas_buf_color[j].blue = (uint16_t) ((uint16_t) canvas_buf_color[j].blue * copy_buf_color[j].blue) >> 5; + canvas_buf_color[j].ch.red = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.red * copy_buf_color[j].ch.red) >> 5; + canvas_buf_color[j].ch.blue = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.blue * copy_buf_color[j].ch.blue) >> 5; # if LV_COLOR_16_SWAP == 0 - canvas_buf_color[j].green = (uint16_t) ((uint16_t) canvas_buf_color[j].green * copy_buf_color[j].green) >> 6; + canvas_buf_color[j].ch.green = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.green * copy_buf_color[j].ch.green) >> 6; # else - canvas_buf_color[j].red = (uint16_t) ((uint16_t) canvas_buf_color[j].red * copy_buf_color[j].red) >> 6; - canvas_buf_color[j].blue = (uint16_t) ((uint16_t) canvas_buf_color[j].blue * copy_buf_color[j].blue) >> 6; - canvas_buf_color[j].red = (uint16_t) ((uint16_t) canvas_buf_color[j].red * copy_buf_color[j].red) >> 6; + canvas_buf_color[j].ch.red = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.red * copy_buf_color[j].ch.red) >> 6; + canvas_buf_color[j].ch.blue = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.blue * copy_buf_color[j].ch.blue) >> 6; + canvas_buf_color[j].ch.red = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.red * copy_buf_color[j].ch.red) >> 6; # endif /*LV_COLOR_16_SWAP*/ #elif LV_COLOR_DEPTH == 8 - canvas_buf_color[j].red = (uint16_t) ((uint16_t) canvas_buf_color[j].red * copy_buf_color[j].red) >> 3; - canvas_buf_color[j].green = (uint16_t) ((uint16_t) canvas_buf_color[j].green * copy_buf_color[j].green) >> 3; - canvas_buf_color[j].blue = (uint16_t) ((uint16_t) canvas_buf_color[j].blue * copy_buf_color[j].blue) >> 2; + canvas_buf_color[j].ch.red = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.red * copy_buf_color[j].ch.red) >> 3; + canvas_buf_color[j].ch.green = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.green * copy_buf_color[j].ch.green) >> 3; + canvas_buf_color[j].ch.blue = (uint16_t) ((uint16_t) canvas_buf_color[j].ch.blue * copy_buf_color[j].ch.blue) >> 2; #endif } copy_buf_color += w; diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index 62c95c1be..c7be66ad4 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -104,7 +104,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy) if(copy == NULL) { lv_obj_t * scrl = lv_page_get_scrl(new_ddlist); lv_obj_set_drag(scrl, false); - lv_page_set_scrl_fit2(new_ddlist, LV_FIT_FLOOD, LV_FIT_TIGHT); + lv_page_set_scrl_fit2(new_ddlist, LV_FIT_FILL, LV_FIT_TIGHT); ext->label = lv_label_create(new_ddlist, NULL); lv_cont_set_fit2(new_ddlist, LV_FIT_TIGHT, LV_FIT_NONE); diff --git a/lv_objx/lv_kb.c b/lv_objx/lv_kb.c index e39f1eb1d..961c098df 100644 --- a/lv_objx/lv_kb.c +++ b/lv_objx/lv_kb.c @@ -39,6 +39,13 @@ static const char * kb_map_lc[] = { "\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, "" }; +static const lv_btnm_ctrl_t kb_ctrl_lc_map[] = { + 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, + (6 | LV_BTNM_REPEAT_DISABLE_MASK), 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 6, 2, 2 +}; + static const char * kb_map_uc[] = { "\2051#", "\204Q", "\204W", "\204E", "\204R", "\204T", "\204Y", "\204U", "\204I", "\204O", "\204P", "\207Bksp", "\n", "\226abc", "\203A", "\203S", "\203D", "\203F", "\203G", "\203H", "\203J", "\203K", "\203L", "\207Enter", "\n", @@ -46,6 +53,13 @@ static const char * kb_map_uc[] = { "\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, "" }; +static const lv_btnm_ctrl_t kb_ctrl_uc_map[] = { + 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, + (6 | LV_BTNM_REPEAT_DISABLE_MASK), 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 6, 2, 2 +}; + static const char * kb_map_spec[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "\202Bksp", "\n", "\222abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n", @@ -53,12 +67,25 @@ static const char * kb_map_spec[] = { "\202"SYMBOL_CLOSE, "\202"SYMBOL_LEFT, "\206 ", "\202"SYMBOL_RIGHT, "\202"SYMBOL_OK, "" }; +static const lv_btnm_ctrl_t kb_ctrl_spec_map[] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + (2 | LV_BTNM_REPEAT_DISABLE_MASK), 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 6, 2, 2 +}; + static const char * kb_map_num[] = { "1", "2", "3", "\202"SYMBOL_CLOSE, "\n", "4", "5", "6", "\202"SYMBOL_OK, "\n", "7", "8", "9", "\202Bksp", "\n", "+/-", "0", ".", SYMBOL_LEFT, SYMBOL_RIGHT, "" }; + +static const lv_btnm_ctrl_t kb_ctrl_num_map[] = { + 1, 1, 1, 2, + 1, 1, 1, 2, + 1, 1, 1, 1, 1 +}; /********************** * MACROS **********************/ @@ -104,6 +131,7 @@ lv_obj_t * lv_kb_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_align(new_kb, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0); lv_btnm_set_action(new_kb, lv_kb_def_action); lv_btnm_set_map(new_kb, kb_map_lc); + lv_btnm_set_ctrl_map(new_kb, kb_ctrl_lc_map); /*Set the default styles*/ lv_theme_t * th = lv_theme_get_current(); @@ -177,8 +205,14 @@ void lv_kb_set_mode(lv_obj_t * kb, lv_kb_mode_t mode) if(ext->mode == mode) return; ext->mode = mode; - if(mode == LV_KB_MODE_TEXT) lv_btnm_set_map(kb, kb_map_lc); - else if(mode == LV_KB_MODE_NUM) lv_btnm_set_map(kb, kb_map_num); + if(mode == LV_KB_MODE_TEXT) { + lv_btnm_set_map(kb, kb_map_lc); + lv_btnm_set_ctrl_map(kb, kb_ctrl_lc_map); + } + else if(mode == LV_KB_MODE_NUM) { + lv_btnm_set_map(kb, kb_map_num); + lv_btnm_set_ctrl_map(kb, kb_ctrl_num_map); + } } @@ -358,12 +392,15 @@ static lv_res_t lv_kb_def_action(lv_obj_t * kb, const char * txt) /*Do the corresponding action according to the text of the button*/ if(strcmp(txt, "abc") == 0) { lv_btnm_set_map(kb, kb_map_lc); + lv_btnm_set_ctrl_map(kb, kb_ctrl_lc_map); return LV_RES_OK; } else if(strcmp(txt, "ABC") == 0) { lv_btnm_set_map(kb, kb_map_uc); + lv_btnm_set_ctrl_map(kb, kb_ctrl_uc_map); return LV_RES_OK; } else if(strcmp(txt, "1#") == 0) { lv_btnm_set_map(kb, kb_map_spec); + lv_btnm_set_ctrl_map(kb, kb_ctrl_spec_map); return LV_RES_OK; } else if(strcmp(txt, SYMBOL_CLOSE) == 0) { if(kb->event_cb) lv_obj_send_event(kb, LV_EVENT_CANCEL); diff --git a/lv_objx/lv_preload.c b/lv_objx/lv_preload.c index 8106c496a..20cd2a4f2 100644 --- a/lv_objx/lv_preload.c +++ b/lv_objx/lv_preload.c @@ -354,7 +354,7 @@ static bool lv_preload_design(lv_obj_t * preload, const lv_area_t * mask, lv_des lv_style_t bg_style; lv_style_copy(&bg_style, &lv_style_plain); - bg_style.body.empty = 1; + bg_style.body.opa = LV_OPA_TRANSP; bg_style.body.radius = LV_RADIUS_CIRCLE; bg_style.body.border.color = style->body.border.color; bg_style.body.border.width = style->body.border.width; diff --git a/lv_objx/lv_slider.c b/lv_objx/lv_slider.c index ab73362df..077bd0b94 100644 --- a/lv_objx/lv_slider.c +++ b/lv_objx/lv_slider.c @@ -342,7 +342,7 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig if(lv_obj_is_focused(slider)) { lv_style_t style_tmp; lv_style_copy(&style_tmp, style_bg); - style_tmp.body.empty = 1; + style_tmp.body.opa = LV_OPA_TRANSP; style_tmp.body.shadow.width = 0; lv_draw_rect(&area_bg, mask, &style_tmp, opa_scale); } diff --git a/lv_objx/lv_ta.c b/lv_objx/lv_ta.c index b2e69bdbd..289383876 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -1059,7 +1059,7 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_ lv_draw_label(&cur_area, mask, &cur_style, opa_scale, letter_buf, LV_TXT_FLAG_NONE, 0); } else if(ext->cursor.type == LV_CURSOR_OUTLINE) { - cur_style.body.empty = 1; + cur_style.body.opa = LV_OPA_TRANSP; if(cur_style.body.border.width == 0) cur_style.body.border.width = 1; /*Be sure the border will be drawn*/ lv_draw_rect(&cur_area, mask, &cur_style, opa_scale); } else if(ext->cursor.type == LV_CURSOR_UNDERLINE) { @@ -1214,6 +1214,21 @@ static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void lv_coord_t font_h = lv_font_get_height(style_label->text.font); scrl->ext_size = LV_MATH_MAX(scrl->ext_size, style_label->text.line_space + font_h); } + else if(sign == LV_SIGNAL_CORD_CHG) { + /*Set the label width according to the text area width*/ + if(ext->label) { + if(lv_obj_get_width(ta) != lv_area_get_width(param) || + lv_obj_get_height(ta) != lv_area_get_height(param)) { + lv_obj_t * scrl = lv_page_get_scrl(ta); + lv_style_t * style_scrl = lv_obj_get_style(scrl); + lv_obj_set_width(ext->label, lv_obj_get_width(scrl) - 2 * style_scrl->body.padding.hor); + lv_obj_set_pos(ext->label, style_scrl->body.padding.hor, style_scrl->body.padding.ver); + lv_label_set_text(ext->label, NULL); /*Refresh the label*/ + + refr_cursor_area(ta); + } + } + } else if(sign == LV_SIGNAL_PRESSED) { update_cursor_position_on_click(ta, (lv_indev_t *)param); } @@ -1342,7 +1357,7 @@ static void get_cursor_style(lv_obj_t * ta, lv_style_t * style_res) style_res->body.border.width = 1; style_res->body.shadow.width = 0; style_res->body.radius = 0; - style_res->body.empty = 0; + style_res->body.opa = LV_OPA_COVER; style_res->body.padding.hor = 0; style_res->body.padding.ver = 0; style_res->line.width = 1; diff --git a/lv_themes/lv_theme_alien.c b/lv_themes/lv_theme_alien.c index 45f706ee4..c4efff0b3 100644 --- a/lv_themes/lv_theme_alien.c +++ b/lv_themes/lv_theme_alien.c @@ -72,7 +72,6 @@ static void basic_init(void) def.body.opa = LV_OPA_COVER; def.glass = 0; - def.body.empty = 0; def.body.main_color = LV_COLOR_HEX3(0x222); def.body.grad_color = LV_COLOR_HEX3(0x222); def.body.radius = 0; @@ -147,7 +146,7 @@ static void btn_init(void) #if USE_LV_BTN != 0 lv_style_copy(&btn_rel, &def); btn_rel.glass = 0; - btn_rel.body.empty = 1; + btn_rel.body.opa = LV_OPA_TRANSP; btn_rel.body.radius = LV_RADIUS_CIRCLE; btn_rel.body.border.width = 2; btn_rel.body.border.color = lv_color_hsv_to_rgb(_hue, 70, 90); @@ -161,7 +160,6 @@ static void btn_init(void) lv_style_copy(&btn_pr, &btn_rel); btn_pr.body.opa = LV_OPA_COVER; - btn_pr.body.empty = 0; btn_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 50); btn_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 50); btn_pr.body.border.opa = LV_OPA_60; @@ -171,7 +169,6 @@ static void btn_init(void) lv_style_copy(&btn_trel, &btn_pr); btn_trel.body.opa = LV_OPA_COVER; - btn_trel.body.empty = 0; btn_trel.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 60); btn_trel.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 60); btn_trel.body.border.opa = LV_OPA_60; @@ -182,7 +179,6 @@ static void btn_init(void) lv_style_copy(&btn_tpr, &btn_trel); btn_tpr.body.opa = LV_OPA_COVER; - btn_tpr.body.empty = 0; btn_tpr.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 50); btn_tpr.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 50); btn_tpr.body.border.opa = LV_OPA_60; @@ -446,7 +442,7 @@ static void calendar_init(void) lv_style_copy(&today_box, &header); today_box.body.main_color = lv_color_hsv_to_rgb(_hue, 40, 70); today_box.body.grad_color = today_box.body.main_color; - today_box.body.empty = 1; + today_box.body.opa = LV_OPA_TRANSP; lv_style_copy(&color_text, &def); color_text.text.color = lv_color_hsv_to_rgb(_hue, 30, 80); @@ -476,7 +472,7 @@ static void cb_init(void) cb_rel.body.grad_color = LV_COLOR_SILVER; lv_style_copy(&cb_bg, &bg); - cb_bg.body.empty = 1; + cb_bg.body.opa = LV_OPA_TRANSP; cb_bg.body.border.width = 0; cb_bg.body.padding.inner = LV_DPI / 8; cb_bg.body.padding.hor = 0; @@ -526,7 +522,7 @@ static void btnm_init(void) btnm_bg.body.radius = LV_DPI / 8; lv_style_copy(&btnm_rel, &lv_style_plain); - btnm_rel.body.empty = 1; + btnm_rel.body.opa = LV_OPA_TRANSP; btnm_rel.body.radius = LV_DPI / 8; btnm_rel.text.color = lv_color_hsv_to_rgb(_hue, 60, 80); btnm_rel.text.font = _font; @@ -614,7 +610,7 @@ static void list_init(void) #if USE_LV_LIST != 0 static lv_style_t list_bg, list_rel, list_pr, list_trel, list_tpr, list_ina; lv_style_copy(&list_rel, &def); - list_rel.body.empty = 1; + list_rel.body.opa = LV_OPA_TRANSP; list_rel.body.border.width = 1; list_rel.body.border.color = lv_color_hsv_to_rgb(_hue, 50, 85); list_rel.body.border.opa = LV_OPA_COVER; @@ -623,7 +619,6 @@ static void list_init(void) list_rel.image.color = lv_color_hsv_to_rgb(_hue, 10, 94); lv_style_copy(&list_pr, &list_rel); - list_pr.body.empty = 0; list_pr.body.opa = LV_OPA_COVER; list_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 34, 41); list_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 34, 41); @@ -684,7 +679,7 @@ static void roller_init(void) roller_bg.body.shadow.width = 0; lv_style_copy(&roller_sel, &panel); - roller_sel.body.empty = 1; + roller_sel.body.opa = LV_OPA_TRANSP; roller_sel.body.radius = 0; roller_sel.text.opa = LV_OPA_COVER; roller_sel.text.color = lv_color_hsv_to_rgb(_hue, 70, 95); @@ -715,7 +710,7 @@ static void tabview_init(void) tab_pr.body.grad_color = LV_COLOR_HEX3(0x444); lv_style_copy(&tab_trel, &def); - tab_trel.body.empty = 1; + tab_trel.body.opa = LV_OPA_TRANSP; tab_trel.body.padding.hor = 0; tab_trel.body.padding.ver = LV_DPI / 6; tab_trel.body.padding.inner = 0; @@ -829,7 +824,7 @@ static void style_mod_edit(lv_style_t * style) style->body.border.color = LV_COLOR_GREEN; /*If not empty or has border then emphasis the border*/ - if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + if (style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); diff --git a/lv_themes/lv_theme_default.c b/lv_themes/lv_theme_default.c index 3a65455d4..fe87a6a6b 100644 --- a/lv_themes/lv_theme_default.c +++ b/lv_themes/lv_theme_default.c @@ -365,7 +365,7 @@ static void style_mod(lv_style_t * style) style->body.border.color = LV_COLOR_ORANGE; /*If not empty or has border then emphasis the border*/ - if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + if (style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); @@ -387,7 +387,7 @@ static void style_mod_edit(lv_style_t * style) style->body.border.color = LV_COLOR_GREEN; /*If not empty or has border then emphasis the border*/ - if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + if (style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); diff --git a/lv_themes/lv_theme_material.c b/lv_themes/lv_theme_material.c index 812dfd362..aab198013 100644 --- a/lv_themes/lv_theme_material.c +++ b/lv_themes/lv_theme_material.c @@ -440,7 +440,7 @@ static void btnm_init(void) rel.body.border.part = LV_BORDER_FULL | LV_BORDER_INTERNAL; rel.body.border.width = 1; rel.body.border.color = LV_COLOR_HEX3(0xbbb); - rel.body.empty = 1; + rel.body.opa = LV_OPA_TRANSP; rel.body.shadow.width = 0; lv_style_copy(&pr, &rel); @@ -448,7 +448,7 @@ static void btnm_init(void) pr.body.main_color = LV_COLOR_HEX3(0xddd); pr.body.grad_color = pr.body.main_color; pr.body.border.width = 0; - pr.body.empty = 0; + pr.body.opa = LV_OPA_COVER; lv_style_copy(&tgl_rel, &pr); tgl_rel.body.main_color = lv_color_hsv_to_rgb(_hue, 90, 70); @@ -529,7 +529,7 @@ static void ta_init(void) static lv_style_t oneline; lv_style_copy(&oneline, &def); - oneline.body.empty = 1; + oneline.body.opa = LV_OPA_TRANSP; oneline.body.radius = 0; oneline.body.border.part = LV_BORDER_BOTTOM; oneline.body.border.width = 3; @@ -577,7 +577,7 @@ static void list_init(void) pr.body.main_color = LV_COLOR_HEX3(0xddd); pr.body.grad_color = pr.body.main_color; pr.body.border.width = 0; - pr.body.empty = 0; + pr.body.opa = LV_OPA_COVER; pr.body.radius = DEF_RADIUS; pr.text.font = _font; @@ -617,7 +617,6 @@ static void ddlist_init(void) bg.body.padding.ver = LV_DPI / 6; bg.text.line_space = LV_DPI / 8; - lv_style_copy(&sel, &bg); sel.body.main_color = lv_color_hsv_to_rgb(_hue, 90, 70); sel.body.grad_color = sel.body.main_color; @@ -690,7 +689,7 @@ static void tabview_init(void) pr.body.main_color = LV_COLOR_HEX3(0xbbb); pr.body.grad_color = pr.body.main_color; pr.body.border.width = 0; - pr.body.empty = 0; + pr.body.opa = LV_OPA_COVER; pr.body.radius = 0; pr.body.border.width = 1; pr.body.border.color = LV_COLOR_HEX3(0x888); @@ -707,7 +706,7 @@ static void tabview_init(void) tgl_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 15, 85); tgl_pr.body.grad_color = tgl_pr.body.main_color; tgl_pr.body.border.width = 0; - tgl_pr.body.empty = 0; + tgl_pr.body.opa = LV_OPA_COVER; tgl_pr.body.radius = 0; tgl_pr.text.color = lv_color_hsv_to_rgb(_hue, 90, 60); @@ -769,7 +768,7 @@ static void win_init(void) pr.body.main_color = LV_COLOR_HEX3(0xbbb); pr.body.grad_color = pr.body.main_color; pr.body.border.width = 0; - pr.body.empty = 0; + pr.body.opa = LV_OPA_COVER; pr.body.radius = 0; pr.text.color = LV_COLOR_HEX3(0x111); pr.image.color = LV_COLOR_HEX3(0x111); @@ -795,7 +794,7 @@ static void style_mod(lv_style_t * style) style->body.border.color = lv_color_hsv_to_rgb(_hue, 90, 70); /*If not empty or has border then emphasis the border*/ - if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + if (style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; style->body.main_color = lv_color_mix(style->body.main_color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_70); style->body.grad_color = lv_color_mix(style->body.grad_color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_70); @@ -817,7 +816,7 @@ static void style_mod_edit(lv_style_t * style) style->body.border.color = LV_COLOR_GREEN; /*If not empty or has border then emphasis the border*/ - if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + if (style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); diff --git a/lv_themes/lv_theme_mono.c b/lv_themes/lv_theme_mono.c index 25ce93f89..b498db514 100644 --- a/lv_themes/lv_theme_mono.c +++ b/lv_themes/lv_theme_mono.c @@ -215,7 +215,7 @@ static void lmeter_init(void) #if USE_LV_LMETER != 0 static lv_style_t lmeter_bg; lv_style_copy(&lmeter_bg, &light_frame); - lmeter_bg.body.empty = 1; + lmeter_bg.body.opa = LV_OPA_TRANSP; lmeter_bg.body.main_color = LV_COLOR_BLACK; lmeter_bg.body.grad_color = LV_COLOR_BLACK; lmeter_bg.body.padding.hor = LV_DPI / 20; @@ -422,7 +422,7 @@ static void style_mod(lv_style_t * style) style->body.border.color = LV_COLOR_BLACK; /*If not empty or has border then emphasis the border*/ - if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + if (style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; @@ -438,7 +438,7 @@ static void style_mod_edit(lv_style_t * style) style->body.border.color = LV_COLOR_BLACK; /*If not empty or has border then emphasis the border*/ - if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + if (style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; diff --git a/lv_themes/lv_theme_nemo.c b/lv_themes/lv_theme_nemo.c index 5550a5352..c2204c234 100644 --- a/lv_themes/lv_theme_nemo.c +++ b/lv_themes/lv_theme_nemo.c @@ -75,7 +75,6 @@ static void basic_init(void) def.body.opa = LV_OPA_COVER; def.glass = 0; - def.body.empty = 0; def.body.main_color = LV_COLOR_HEX3(0x222); def.body.grad_color = LV_COLOR_HEX3(0x222); def.body.radius = 0; @@ -142,7 +141,7 @@ static void btn_init(void) #if USE_LV_BTN != 0 lv_style_copy(&btn_rel, &def); btn_rel.glass = 0; - btn_rel.body.empty = 1; + btn_rel.body.opa = LV_OPA_TRANSP; btn_rel.body.radius = LV_RADIUS_CIRCLE; btn_rel.body.border.width = 2; btn_rel.body.border.color = lv_color_hsv_to_rgb(_hue, 70, 90); @@ -155,7 +154,6 @@ static void btn_init(void) lv_style_copy(&btn_pr, &btn_rel); btn_pr.body.opa = LV_OPA_COVER; - btn_pr.body.empty = 0; btn_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 50); btn_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 50); btn_pr.body.border.opa = LV_OPA_60; @@ -164,7 +162,6 @@ static void btn_init(void) lv_style_copy(&btn_trel, &btn_pr); btn_trel.body.opa = LV_OPA_COVER; - btn_trel.body.empty = 0; btn_trel.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 60); btn_trel.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 60); btn_trel.body.border.opa = LV_OPA_60; @@ -174,7 +171,6 @@ static void btn_init(void) lv_style_copy(&btn_tpr, &btn_trel); btn_tpr.body.opa = LV_OPA_COVER; - btn_tpr.body.empty = 0; btn_tpr.body.main_color = lv_color_hsv_to_rgb(_hue, 50, 50); btn_tpr.body.grad_color = lv_color_hsv_to_rgb(_hue, 50, 50); btn_tpr.body.border.opa = LV_OPA_60; @@ -205,8 +201,6 @@ static void label_init(void) lv_style_copy(&label_prim, &def); label_prim.text.font = _font; label_prim.text.color = lv_color_hsv_to_rgb(_hue, 5, 96); - label_prim.body.empty = 1; - label_prim.body.border.width = 0; lv_style_copy(&label_sec, &label_prim); label_sec.text.color = lv_color_hsv_to_rgb(_hue, 40, 85); @@ -427,7 +421,7 @@ static void calendar_init(void) static lv_style_t week_box; lv_style_copy(&week_box, &def); - week_box.body.empty = 1; + week_box.body.opa = LV_OPA_TRANSP; week_box.body.border.color = theme.style.panel->body.border.color; week_box.body.padding.ver = LV_DPI / 20; @@ -460,7 +454,7 @@ static void cb_init(void) cb_rel.body.grad_color = LV_COLOR_SILVER; lv_style_copy(&cb_bg, &bg); - cb_bg.body.empty = 1; + cb_bg.body.opa = LV_OPA_TRANSP; cb_bg.body.border.width = 0; cb_bg.body.padding.inner = LV_DPI / 8; cb_bg.body.padding.hor = 0; @@ -510,7 +504,7 @@ static void btnm_init(void) btnm_bg.body.radius = LV_DPI / 8; lv_style_copy(&btnm_rel, &lv_style_plain); - btnm_rel.body.empty = 1; + btnm_rel.body.opa = LV_OPA_TRANSP; btnm_rel.body.radius = LV_DPI / 8; btnm_rel.text.color = lv_color_hsv_to_rgb(_hue, 60, 80); btnm_rel.text.font = _font; @@ -598,7 +592,7 @@ static void list_init(void) #if USE_LV_LIST != 0 static lv_style_t list_bg, list_rel, list_pr, list_trel, list_tpr, list_ina; lv_style_copy(&list_rel, &def); - list_rel.body.empty = 1; + list_rel.body.opa = LV_OPA_TRANSP; list_rel.body.border.width = 1; list_rel.body.border.color = lv_color_hsv_to_rgb(_hue, 50, 85); list_rel.body.border.opa = LV_OPA_COVER; @@ -606,7 +600,7 @@ static void list_init(void) list_rel.text.font = _font; lv_style_copy(&list_pr, &list_rel); - list_pr.body.empty = 0; + list_pr.body.opa = LV_OPA_TRANSP; list_pr.body.opa = LV_OPA_COVER; list_pr.body.main_color = lv_color_hsv_to_rgb(_hue, 34, 41); list_pr.body.grad_color = lv_color_hsv_to_rgb(_hue, 34, 41); @@ -666,7 +660,7 @@ static void roller_init(void) roller_bg.body.shadow.width = 0; lv_style_copy(&roller_sel, &panel); - roller_sel.body.empty = 1; + roller_sel.body.opa = LV_OPA_TRANSP; roller_sel.body.radius = 0; roller_sel.text.opa = LV_OPA_COVER; roller_sel.text.color = lv_color_hsv_to_rgb(_hue, 70, 95); @@ -697,7 +691,7 @@ static void tabview_init(void) tab_pr.body.grad_color = LV_COLOR_HEX3(0x500); lv_style_copy(&tab_trel, &def); - tab_trel.body.empty = 1; + tab_trel.body.opa = LV_OPA_TRANSP; tab_trel.body.padding.hor = 0; tab_trel.body.padding.ver = LV_DPI / 6; tab_trel.body.padding.inner = 0; diff --git a/lv_themes/lv_theme_night.c b/lv_themes/lv_theme_night.c index 047c811a6..ef01ed4b0 100644 --- a/lv_themes/lv_theme_night.c +++ b/lv_themes/lv_theme_night.c @@ -547,7 +547,7 @@ static void list_init(void) list_bg.body.padding.inner = 0; lv_style_copy(&list_btn_rel, &bg); - list_btn_rel.body.empty = 1; + list_btn_rel.body.opa = LV_OPA_TRANSP; list_btn_rel.body.border.part = LV_BORDER_BOTTOM; list_btn_rel.body.border.color = lv_color_hsv_to_rgb(_hue, 10, 5); list_btn_rel.body.border.width = 1; @@ -568,7 +568,7 @@ static void list_init(void) list_btn_pr.image.color = lv_color_hsv_to_rgb(_hue, 5, 80); lv_style_copy(&list_btn_tgl_rel, &list_btn_rel); - list_btn_tgl_rel.body.empty = 0; + list_btn_tgl_rel.body.opa = LV_OPA_COVER; list_btn_tgl_rel.body.main_color = lv_color_hsv_to_rgb(_hue, 10, 8); list_btn_tgl_rel.body.grad_color = lv_color_hsv_to_rgb(_hue, 10, 8); @@ -705,7 +705,7 @@ static void style_mod(lv_style_t * style) style->body.border.color = lv_color_hsv_to_rgb(_hue, 80, 70); /*If not empty or has border then emphasis the border*/ - if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + if (style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; @@ -721,7 +721,7 @@ static void style_mod_edit(lv_style_t * style) style->body.border.color = LV_COLOR_GREEN; /*If not empty or has border then emphasis the border*/ - if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + if (style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; diff --git a/lv_themes/lv_theme_zen.c b/lv_themes/lv_theme_zen.c index c55e8c8de..522b1c6d5 100644 --- a/lv_themes/lv_theme_zen.c +++ b/lv_themes/lv_theme_zen.c @@ -97,7 +97,7 @@ static void btn_init(void) #if USE_LV_BTN != 0 static lv_style_t rel, pr, tgl_pr, ina; lv_style_copy(&rel, &def); - rel.body.empty = 1; + rel.body.opa = LV_OPA_TRANSP; rel.body.radius = LV_RADIUS_CIRCLE; rel.body.border.width = 2; rel.body.border.color = lv_color_hsv_to_rgb(_hue, 40, 90); @@ -202,7 +202,7 @@ static void bar_init(void) static lv_style_t bg, indic; lv_style_copy(&bg, &def); - bg.body.empty = 1; + bg.body.opa = LV_OPA_TRANSP; bg.body.radius = LV_RADIUS_CIRCLE; bg.body.border.width = 2; bg.body.border.opa = LV_OPA_COVER; @@ -342,7 +342,7 @@ static void calendar_init(void) static lv_style_t today_box; lv_style_copy(&today_box, &def); - today_box.body.empty = 1; + today_box.body.opa = LV_OPA_TRANSP; today_box.body.border.color = theme.style.panel->body.border.color; today_box.body.padding.ver = LV_DPI / 20; today_box.body.radius = LV_RADIUS_CIRCLE; @@ -412,11 +412,11 @@ static void btnm_init(void) bg.text.font = _font; lv_style_copy(&rel, &def); - rel.body.empty = 1; + rel.body.opa = LV_OPA_TRANSP; rel.body.border.width = 0; lv_style_copy(&pr, &def); - pr.body.empty = 1; + pr.body.opa = LV_OPA_TRANSP; pr.body.radius = LV_DPI / 1; pr.body.border.width = 2; pr.body.border.color = lv_color_hsv_to_rgb(_hue, 40, 60); @@ -424,7 +424,7 @@ static void btnm_init(void) pr.text.color = lv_color_hsv_to_rgb(_hue, 40, 60); lv_style_copy(&tgl_rel, &pr); - tgl_rel.body.empty = 0; + tgl_rel.body.opa = LV_OPA_COVER; tgl_rel.body.main_color = lv_color_hsv_to_rgb(_hue, 15, 95); tgl_rel.body.grad_color = tgl_rel.body.main_color; tgl_rel.body.border.width = 0; @@ -462,7 +462,7 @@ static void kb_init(void) bg.body.border.width = 0; lv_style_copy(&rel, &def); - rel.body.empty = 1; + rel.body.opa = LV_OPA_COVER; rel.body.radius = 0; rel.body.border.width = 1; rel.body.border.color = LV_COLOR_HEX3(0x888); @@ -584,7 +584,7 @@ static void list_init(void) bg.body.padding.ver = 0; lv_style_copy(&rel, &def); - rel.body.empty = 1; + rel.body.opa = LV_OPA_TRANSP; rel.body.border.width = 0; rel.body.padding.hor = LV_DPI / 8; rel.body.padding.ver = LV_DPI / 8; @@ -628,7 +628,7 @@ static void ddlist_init(void) bg.text.color = LV_COLOR_HEX3(0x666); lv_style_copy(&sel, &def); - sel.body.empty = 1; + sel.body.opa = LV_OPA_TRANSP; sel.body.border.width = 0; sel.text.color = lv_color_hsv_to_rgb(_hue, 50, 80); @@ -644,13 +644,13 @@ static void roller_init(void) static lv_style_t bg, sel; lv_style_copy(&bg, &def); bg.body.border.width = 0; - bg.body.empty = 1; + bg.body.opa = LV_OPA_TRANSP; bg.text.line_space = LV_DPI / 6; bg.text.color = LV_COLOR_HEX3(0x999); lv_style_copy(&sel, theme.style.panel); sel.body.radius = LV_RADIUS_CIRCLE; - sel.body.empty = 1; + sel.body.opa = LV_OPA_TRANSP; theme.style.roller.bg = &bg; theme.style.roller.sel = &sel; @@ -663,7 +663,7 @@ static void tabview_init(void) static lv_style_t btn_bg, indic, rel, pr, tgl_rel, tgl_pr; lv_style_copy(&btn_bg, &def); - btn_bg.body.empty = 1; + btn_bg.body.opa = LV_OPA_TRANSP; btn_bg.body.border.width = 2; btn_bg.body.border.part = LV_BORDER_BOTTOM; btn_bg.body.border.color = lv_color_hsv_to_rgb(_hue, 10, 90); @@ -676,7 +676,7 @@ static void tabview_init(void) indic.body.grad_color = indic.body.main_color; lv_style_copy(&rel, &def); - rel.body.empty = 1; + rel.body.opa = LV_OPA_TRANSP; rel.body.border.width = 0; rel.text.color = LV_COLOR_HEX3(0x999); @@ -731,7 +731,7 @@ static void win_init(void) static lv_style_t header, rel, pr; lv_style_copy(&header, &def); - header.body.empty = 1; + header.body.opa = LV_OPA_TRANSP; header.body.border.width = 2; header.body.border.part = LV_BORDER_BOTTOM; header.body.border.color = lv_color_hsv_to_rgb(_hue, 10, 90); @@ -739,7 +739,7 @@ static void win_init(void) header.image.color = LV_COLOR_HEX3(0x666); lv_style_copy(&rel, &def); - rel.body.empty = 1; + rel.body.opa = LV_OPA_TRANSP; rel.body.border.width = 0; rel.text.color = LV_COLOR_HEX3(0x666); rel.image.color = LV_COLOR_HEX3(0x666); @@ -768,7 +768,7 @@ static void style_mod(lv_style_t * style) style->body.border.color = lv_color_hsv_to_rgb(_hue, 40, 50); /*If not empty or has border then emphasis the border*/ - if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + if (style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; @@ -784,7 +784,7 @@ static void style_mod_edit(lv_style_t * style) style->body.border.color = LV_COLOR_GREEN; /*If not empty or has border then emphasis the border*/ - if (style->body.empty == 0 || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; + if (style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70);