From 9a483c87bfec48fa4f84f2e5ef4b4a4b7d2a95fd Mon Sep 17 00:00:00 2001 From: _VIFEXTech Date: Mon, 14 Aug 2023 13:57:19 +0800 Subject: [PATCH] feat(layer): add more efficient widget translucent mode (#4415) Signed-off-by: FASTSHIFT Co-authored-by: pengyiqiang Co-authored-by: Gabor Kiss-Vamosi --- demos/music/lv_demo_music_main.c | 2 +- docs/overview/style-props.md | 838 ++++++++++++++++++++++++ examples/widgets/arc/lv_example_arc_1.c | 4 + scripts/style_api_gen.py | 4 + src/core/lv_obj.c | 7 +- src/core/lv_obj_draw.c | 72 +- src/core/lv_obj_style.c | 36 +- src/core/lv_obj_style.h | 11 + src/core/lv_obj_style_gen.c | 8 + src/core/lv_obj_style_gen.h | 7 + src/core/lv_refr.c | 2 +- src/misc/lv_style.c | 4 +- src/misc/lv_style.h | 33 +- src/misc/lv_style_gen.c | 10 + src/misc/lv_style_gen.h | 7 + src/widgets/meter/lv_meter.c | 4 +- src/widgets/span/lv_span.c | 2 +- tests/src/test_cases/test_draw_layer.c | 16 +- 18 files changed, 986 insertions(+), 81 deletions(-) create mode 100644 docs/overview/style-props.md diff --git a/demos/music/lv_demo_music_main.c b/demos/music/lv_demo_music_main.c index 3e61b319b..72d29866e 100644 --- a/demos/music/lv_demo_music_main.c +++ b/demos/music/lv_demo_music_main.c @@ -775,7 +775,7 @@ static void spectrum_draw_event_cb(lv_event_t * e) lv_obj_t * obj = lv_event_get_target(e); lv_layer_t * layer = lv_event_get_layer(e); - lv_opa_t opa = lv_obj_get_style_opa(obj, LV_PART_MAIN); + lv_opa_t opa = lv_obj_get_style_opa_recursive(obj, LV_PART_MAIN); if(opa < LV_OPA_MIN) return; lv_point_t center; diff --git a/docs/overview/style-props.md b/docs/overview/style-props.md new file mode 100644 index 000000000..7f1275c65 --- /dev/null +++ b/docs/overview/style-props.md @@ -0,0 +1,838 @@ +# Style properties + +## Size and position +Properties related to size, position, alignment and layout of the objects. + +### width +Sets the width of object. Pixel, percentage and `LV_SIZE_CONTENT` values can be used. Percentage values are relative to the width of the parent's content area. +
    +
  • Default Widget dependent
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### min_width +Sets a minimal width. Pixel and percentage values can be used. Percentage values are relative to the width of the parent's content area. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### max_width +Sets a maximal width. Pixel and percentage values can be used. Percentage values are relative to the width of the parent's content area. +
    +
  • Default LV_COORD_MAX
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### height +Sets the height of object. Pixel, percentage and `LV_SIZE_CONTENT` can be used. Percentage values are relative to the height of the parent's content area. +
    +
  • Default Widget dependent
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### min_height +Sets a minimal height. Pixel and percentage values can be used. Percentage values are relative to the width of the parent's content area. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### max_height +Sets a maximal height. Pixel and percentage values can be used. Percentage values are relative to the height of the parent's content area. +
    +
  • Default LV_COORD_MAX
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### x +Set the X coordinate of the object considering the set `align`. Pixel and percentage values can be used. Percentage values are relative to the width of the parent's content area. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### y +Set the Y coordinate of the object considering the set `align`. Pixel and percentage values can be used. Percentage values are relative to the height of the parent's content area. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### align +Set the alignment which tells from which point of the parent the X and Y coordinates should be interpreted. The possible values are: `LV_ALIGN_DEFAULT`, `LV_ALIGN_TOP_LEFT/MID/RIGHT`, `LV_ALIGN_BOTTOM_LEFT/MID/RIGHT`, `LV_ALIGN_LEFT/RIGHT_MID`, `LV_ALIGN_CENTER`. `LV_ALIGN_DEFAULT` means `LV_ALIGN_TOP_LEFT` with LTR base direction and `LV_ALIGN_TOP_RIGHT` with RTL base direction. +
    +
  • Default `LV_ALIGN_DEFAULT`
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### transform_width +Make the object wider on both sides with this value. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's width. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw Yes
  • +
+ +### transform_height +Make the object higher on both sides with this value. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's height. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw Yes
  • +
+ +### translate_x +Move the object with this value in X direction. Applied after layouts, aligns and other positioning. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's width. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### translate_y +Move the object with this value in Y direction. Applied after layouts, aligns and other positioning. Pixel and percentage (with `lv_pct(x)`) values can be used. Percentage values are relative to the object's height. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### transform_zoom +Zoom an objects. The value 256 (or `LV_ZOOM_NONE`) means normal size, 128 half size, 512 double size, and so on +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw Yes
  • +
+ +### transform_angle +Rotate an objects. The value is interpreted in 0.1 degree units. E.g. 450 means 45 deg. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw Yes
  • +
+ +### transform_pivot_x +Set the pivot point's X coordinate for transformations. Relative to the object's top left corner' +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### transform_pivot_y +Set the pivot point's Y coordinate for transformations. Relative to the object's top left corner' +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +## Padding +Properties to describe spacing between the parent's sides and the children and among the children. Very similar to the padding properties in HTML. + +### pad_top +Sets the padding on the top. It makes the content area smaller in this direction. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### pad_bottom +Sets the padding on the bottom. It makes the content area smaller in this direction. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### pad_left +Sets the padding on the left. It makes the content area smaller in this direction. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### pad_right +Sets the padding on the right. It makes the content area smaller in this direction. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### pad_row +Sets the padding between the rows. Used by the layouts. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### pad_column +Sets the padding between the columns. Used by the layouts. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +## Margin +Properties to describe spacing around an object. Very similar to the margin properties in HTML. + +### margin_top +Sets the margin on the top. The object will keep this space from its siblings in layouts. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### margin_bottom +Sets the margin on the bottom. The object will keep this space from its siblings in layouts. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### margin_left +Sets the margin on the left. The object will keep this space from its siblings in layouts. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### margin_right +Sets the margin on the right. The object will keep this space from its siblings in layouts. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +## Background +Properties to describe the background color and image of the objects. + +### bg_color +Set the background color of the object. +
    +
  • Default `0xffffff`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### bg_opa +Set the opacity of the background. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 255, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency. +
    +
  • Default `LV_OPA_TRANSP`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### bg_grad_color +Set the gradient color of the background. Used only if `grad_dir` is not `LV_GRAD_DIR_NONE` +
    +
  • Default `0x000000`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### bg_grad_dir +Set the direction of the gradient of the background. The possible values are `LV_GRAD_DIR_NONE/HOR/VER`. +
    +
  • Default `LV_GRAD_DIR_NONE`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### bg_main_stop +Set the point from which the background color should start for gradients. 0 means to top/left side, 255 the bottom/right side, 128 the center, and so on +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### bg_grad_stop +Set the point from which the background's gradient color should start. 0 means to top/left side, 255 the bottom/right side, 128 the center, and so on +
    +
  • Default 255
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### bg_grad +Set the gradient definition. The pointed instance must exist while the object is alive. NULL to disable. It wraps `BG_GRAD_COLOR`, `BG_GRAD_DIR`, `BG_MAIN_STOP` and `BG_GRAD_STOP` into one descriptor and allows creating gradients with more colors too. +
    +
  • Default `NULL`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### bg_dither_mode +Set the dithering mode of the gradient of the background. The possible values are `LV_DITHER_NONE/ORDERED/ERR_DIFF`. +
    +
  • Default `LV_DITHER_NONE`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### bg_img_src +Set a background image. Can be a pointer to `lv_img_dsc_t`, a path to a file or an `LV_SYMBOL_...` +
    +
  • Default `NULL`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw Yes
  • +
+ +### bg_img_opa +Set the opacity of the background image. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 255, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency. +
    +
  • Default `LV_OPA_COVER`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### bg_img_recolor +Set a color to mix to the background image. +
    +
  • Default `0x000000`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### bg_img_recolor_opa +Set the intensity of background image recoloring. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means no mixing, 255, `LV_OPA_100` or `LV_OPA_COVER` means full recoloring, other values or LV_OPA_10, LV_OPA_20, etc are interpreted proportionally. +
    +
  • Default `LV_OPA_TRANSP`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### bg_img_tiled +If enabled the background image will be tiled. The possible values are `true` or `false`. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +## Border +Properties to describe the borders + +### border_color +Set the color of the border +
    +
  • Default `0x000000`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### border_opa +Set the opacity of the border. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 255, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency. +
    +
  • Default `LV_OPA_COVER`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### border_width +Set hte width of the border. Only pixel values can be used. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### border_side +Set only which side(s) the border should be drawn. The possible values are `LV_BORDER_SIDE_NONE/TOP/BOTTOM/LEFT/RIGHT/INTERNAL`. OR-ed values can be used as well, e.g. `LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_LEFT`. +
    +
  • Default `LV_BORDER_SIDE_NONE`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### border_post +Sets whether the border should be drawn before or after the children are drawn. `true`: after children, `false`: before children +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +## Outline +Properties to describe the outline. It's like a border but drawn outside of the rectangles. + +### outline_width +Set the width of the outline in pixels. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw Yes
  • +
+ +### outline_color +Set the color of the outline. +
    +
  • Default `0x000000`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### outline_opa +Set the opacity of the outline. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 255, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency. +
    +
  • Default `LV_OPA_COVER`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw Yes
  • +
+ +### outline_pad +Set the padding of the outline, i.e. the gap between object and the outline. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw Yes
  • +
+ +## Shadow +Properties to describe the shadow drawn under the rectangles. + +### shadow_width +Set the width of the shadow in pixels. The value should be >= 0. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw Yes
  • +
+ +### shadow_ofs_x +Set an offset on the shadow in pixels in X direction. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw Yes
  • +
+ +### shadow_ofs_y +Set an offset on the shadow in pixels in Y direction. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw Yes
  • +
+ +### shadow_spread +Make the shadow calculation to use a larger or smaller rectangle as base. The value can be in pixel to make the area larger/smaller +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw Yes
  • +
+ +### shadow_color +Set the color of the shadow +
    +
  • Default `0x000000`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### shadow_opa +Set the opacity of the shadow. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 255, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency. +
    +
  • Default `LV_OPA_COVER`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw Yes
  • +
+ +## Image +Properties to describe the images + +### img_opa +Set the opacity of an image. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 255, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency. +
    +
  • Default `LV_OPA_COVER`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### img_recolor +Set color to mixt to the image. +
    +
  • Default `0x000000`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### img_recolor_opa +Set the intensity of the color mixing. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 255, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +## Line +Properties to describe line-like objects + +### line_width +Set the width of the lines in pixel. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw Yes
  • +
+ +### line_dash_width +Set the width of dashes in pixel. Note that dash works only on horizontal and vertical lines +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### line_dash_gap +Set the gap between dashes in pixel. Note that dash works only on horizontal and vertical lines +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### line_rounded +Make the end points of the lines rounded. `true`: rounded, `false`: perpendicular line ending +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### line_color +Set the color fo the lines. +
    +
  • Default `0x000000`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### line_opa +Set the opacity of the lines. +
    +
  • Default `LV_OPA_COVER`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +## Arc +TODO + +### arc_width +Set the width (thickness) of the arcs in pixel. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw Yes
  • +
+ +### arc_rounded +Make the end points of the arcs rounded. `true`: rounded, `false`: perpendicular line ending +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### arc_color +Set the color of the arc. +
    +
  • Default `0x000000`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### arc_opa +Set the opacity of the arcs. +
    +
  • Default `LV_OPA_COVER`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### arc_img_src +Set an image from which the arc will be masked out. It's useful to display complex effects on the arcs. Can be a pointer to `lv_img_dsc_t` or a path to a file +
    +
  • Default `NULL`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +## Text +Properties to describe the properties of text. All these properties are inherited. + +### text_color +Sets the color of the text. +
    +
  • Default `0x000000`
  • +
  • Inherited Yes
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### text_opa +Set the opacity of the text. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 255, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency. +
    +
  • Default `LV_OPA_COVER`
  • +
  • Inherited Yes
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### text_font +Set the font of the text (a pointer `lv_font_t *`). +
    +
  • Default `LV_FONT_DEFAULT`
  • +
  • Inherited Yes
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### text_letter_space +Set the letter space in pixels +
    +
  • Default 0
  • +
  • Inherited Yes
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### text_line_space +Set the line space in pixels. +
    +
  • Default 0
  • +
  • Inherited Yes
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### text_decor +Set decoration for the text. The possible values are `LV_TEXT_DECOR_NONE/UNDERLINE/STRIKETHROUGH`. OR-ed values can be used as well. +
    +
  • Default `LV_TEXT_DECOR_NONE`
  • +
  • Inherited Yes
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### text_align +Set how to align the lines of the text. Note that it doesn't align the object itself, only the lines inside the object. The possible values are `LV_TEXT_ALIGN_LEFT/CENTER/RIGHT/AUTO`. `LV_TEXT_ALIGN_AUTO` detect the text base direction and uses left or right alignment accordingly +
    +
  • Default `LV_TEXT_ALIGN_AUTO`
  • +
  • Inherited Yes
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +## Miscellaneous +Mixed properties for various purposes. + +### radius +Set the radius on every corner. The value is interpreted in pixel (>= 0) or `LV_RADIUS_CIRCLE` for max. radius +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### clip_corner +Enable to clip the overflowed content on the rounded corner. Can be `true` or `false`. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### opa +Scale down all opacity values of the object by this factor. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 255, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency. +
    +
  • Default `LV_OPA_COVER`
  • +
  • Inherited Yes
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### opa_layered +First draw the object on the layer, then scale down layer opacity factor. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 255, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency. +
    +
  • Default `LV_OPA_COVER`
  • +
  • Inherited Yes
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### color_filter_dsc +Mix a color to all colors of the object. +
    +
  • Default `NULL`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### color_filter_opa +The intensity of mixing of color filter. +
    +
  • Default `LV_OPA_TRANSP`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### anim +The animation template for the object's animation. Should be a pointer to `lv_anim_t`. The animation parameters are widget specific, e.g. animation time could be the E.g. blink time of the cursor on the text area or scroll time of a roller. See the widgets' documentation to learn more. +
    +
  • Default `NULL`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### anim_time +The animation time in milliseconds. Its meaning is widget specific. E.g. blink time of the cursor on the text area or scroll time of a roller. See the widgets' documentation to learn more. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### anim_speed +The animation speed in pixel/sec. Its meaning is widget specific. E.g. scroll speed of label. See the widgets' documentation to learn more. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### transition +An initialized `lv_style_transition_dsc_t` to describe a transition. +
    +
  • Default `NULL`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### blend_mode +Describes how to blend the colors to the background. The possible values are `LV_BLEND_MODE_NORMAL/ADDITIVE/SUBTRACTIVE/MULTIPLY` +
    +
  • Default `LV_BLEND_MODE_NORMAL`
  • +
  • Inherited No
  • +
  • Layout No
  • +
  • Ext. draw No
  • +
+ +### layout +Set the layout if the object. The children will be repositioned and resized according to the policies set for the layout. For the possible values see the documentation of the layouts. +
    +
  • Default 0
  • +
  • Inherited No
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
+ +### base_dir +Set the base direction of the object. The possible values are `LV_BIDI_DIR_LTR/RTL/AUTO`. +
    +
  • Default `LV_BASE_DIR_AUTO`
  • +
  • Inherited Yes
  • +
  • Layout Yes
  • +
  • Ext. draw No
  • +
diff --git a/examples/widgets/arc/lv_example_arc_1.c b/examples/widgets/arc/lv_example_arc_1.c index 7e59773aa..f60e18ac2 100644 --- a/examples/widgets/arc/lv_example_arc_1.c +++ b/examples/widgets/arc/lv_example_arc_1.c @@ -19,6 +19,10 @@ void lv_example_arc_1(void) /*Manually update the label for the first time*/ lv_obj_send_event(arc, LV_EVENT_VALUE_CHANGED, NULL); + + lv_obj_set_style_opa_layered(arc, LV_OPA_30, LV_PART_MAIN); + + } static void value_changed_event_cb(lv_event_t * e) diff --git a/scripts/style_api_gen.py b/scripts/style_api_gen.py index 2fbf8dcb8..1f22af430 100755 --- a/scripts/style_api_gen.py +++ b/scripts/style_api_gen.py @@ -333,6 +333,10 @@ props = [ 'style_type': 'num', 'var_type': 'lv_opa_t', 'default':'`LV_OPA_COVER`', 'inherited': 1, 'layout': 0, 'ext_draw': 0, 'dsc': "Scale down all opacity values of the object by this factor. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 255, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency." }, +{'name': 'OPA_LAYERED', + 'style_type': 'num', 'var_type': 'lv_opa_t', 'default':'`LV_OPA_COVER`', 'inherited': 1, 'layout': 0, 'ext_draw': 0, + 'dsc': "First draw the object on the layer, then scale down layer opacity factor. Value 0, `LV_OPA_0` or `LV_OPA_TRANSP` means fully transparent, 255, `LV_OPA_100` or `LV_OPA_COVER` means fully covering, other values or LV_OPA_10, LV_OPA_20, etc means semi transparency." }, + {'name': 'COLOR_FILTER_DSC', 'style_type': 'ptr', 'var_type': 'const lv_color_filter_dsc_t *', 'default':'`NULL`', 'inherited': 0, 'layout': 0, 'ext_draw': 0, 'dsc': "Mix a color to all colors of the object." }, diff --git a/src/core/lv_obj.c b/src/core/lv_obj.c index e5307fc71..c96308a2f 100644 --- a/src/core/lv_obj.c +++ b/src/core/lv_obj.c @@ -373,6 +373,11 @@ static void lv_obj_draw(lv_event_t * e) return; } + if(lv_obj_get_style_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) { + info->res = LV_COVER_RES_NOT_COVER; + return; + } + info->res = LV_COVER_RES_COVER; } @@ -480,7 +485,7 @@ static lv_res_t scrollbar_init_draw_dsc(lv_obj_t * obj, lv_draw_rect_dsc_t * dsc } } - lv_opa_t opa = lv_obj_get_style_opa(obj, LV_PART_SCROLLBAR); + lv_opa_t opa = lv_obj_get_style_opa_recursive(obj, LV_PART_SCROLLBAR); if(opa < LV_OPA_MAX) { lv_opa_t v = LV_OPA_MIX2(dsc->bg_opa, opa); dsc->bg_opa = v; diff --git a/src/core/lv_obj_draw.c b/src/core/lv_obj_draw.c index 70165f052..c779cd0dc 100644 --- a/src/core/lv_obj_draw.c +++ b/src/core/lv_obj_draw.c @@ -42,9 +42,8 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint32_t part, lv_draw_rect_dsc_t draw_dsc->base.obj = obj; draw_dsc->base.part = part; - lv_opa_t opa = LV_OPA_COVER; + lv_opa_t opa = lv_obj_get_style_opa_recursive(obj, part); if(part != LV_PART_MAIN) { - opa = lv_obj_get_style_opa(obj, part); if(opa <= LV_OPA_MIN) { draw_dsc->bg_opa = LV_OPA_TRANSP; draw_dsc->bg_img_opa = LV_OPA_TRANSP; @@ -135,20 +134,15 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint32_t part, lv_draw_rect_dsc_t } } - if(part != LV_PART_MAIN) { - if(opa < LV_OPA_MAX) { - lv_opa_t v = LV_OPA_MIX2(opa, draw_dsc->shadow_opa); - draw_dsc->bg_opa = v; - draw_dsc->bg_img_opa = v; - draw_dsc->border_opa = v; - draw_dsc->outline_opa = v; - draw_dsc->shadow_opa = v; - } + if(opa < LV_OPA_MAX) { + draw_dsc->bg_opa = LV_OPA_MIX2(draw_dsc->bg_opa, opa); + draw_dsc->bg_img_opa = LV_OPA_MIX2(draw_dsc->bg_img_opa, opa); + draw_dsc->border_opa = LV_OPA_MIX2(draw_dsc->border_opa, opa); + draw_dsc->shadow_opa = LV_OPA_MIX2(draw_dsc->shadow_opa, opa); + draw_dsc->outline_opa = LV_OPA_MIX2(draw_dsc->outline_opa, opa); } } - - void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint32_t part, lv_draw_label_dsc_t * draw_dsc) { draw_dsc->base.obj = obj; @@ -157,16 +151,11 @@ void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint32_t part, lv_draw_label_dsc draw_dsc->opa = lv_obj_get_style_text_opa(obj, part); if(draw_dsc->opa <= LV_OPA_MIN) return; - if(part != LV_PART_MAIN) { - lv_opa_t opa = lv_obj_get_style_opa(obj, part); - if(opa <= LV_OPA_MIN) { - draw_dsc->opa = LV_OPA_TRANSP; - return; - } - if(opa < LV_OPA_MAX) { - draw_dsc->opa = LV_OPA_MIX2(opa, draw_dsc->opa); - } + lv_opa_t opa = lv_obj_get_style_opa_recursive(obj, part); + if(opa < LV_OPA_MAX) { + draw_dsc->opa = LV_OPA_MIX2(draw_dsc->opa, opa); } + if(draw_dsc->opa <= LV_OPA_MIN) return; draw_dsc->color = lv_obj_get_style_text_color_filtered(obj, part); draw_dsc->letter_space = lv_obj_get_style_text_letter_space(obj, part); @@ -191,16 +180,11 @@ void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint32_t part, lv_draw_img_dsc_t * draw_dsc->opa = lv_obj_get_style_img_opa(obj, part); if(draw_dsc->opa <= LV_OPA_MIN) return; - if(part != LV_PART_MAIN) { - lv_opa_t opa = lv_obj_get_style_opa(obj, part); - if(opa <= LV_OPA_MIN) { - draw_dsc->opa = LV_OPA_TRANSP; - return; - } - if(opa < LV_OPA_MAX) { - draw_dsc->opa = LV_OPA_MIX2(opa, draw_dsc->opa); - } + lv_opa_t opa = lv_obj_get_style_opa_recursive(obj, part); + if(opa < LV_OPA_MAX) { + draw_dsc->opa = LV_OPA_MIX2(draw_dsc->opa, opa); } + if(draw_dsc->opa <= LV_OPA_MIN) return; draw_dsc->angle = 0; draw_dsc->zoom = LV_ZOOM_NONE; @@ -221,16 +205,11 @@ void lv_obj_init_draw_line_dsc(lv_obj_t * obj, uint32_t part, lv_draw_line_dsc_t draw_dsc->opa = lv_obj_get_style_line_opa(obj, part); if(draw_dsc->opa <= LV_OPA_MIN) return; - if(part != LV_PART_MAIN) { - lv_opa_t opa = lv_obj_get_style_opa(obj, part); - if(opa <= LV_OPA_MIN) { - draw_dsc->opa = LV_OPA_TRANSP; - return; - } - if(opa < LV_OPA_MAX) { - draw_dsc->opa = LV_OPA_MIX2(opa, draw_dsc->opa); - } + lv_opa_t opa = lv_obj_get_style_opa_recursive(obj, part); + if(opa < LV_OPA_MAX) { + draw_dsc->opa = LV_OPA_MIX2(draw_dsc->opa, opa); } + if(draw_dsc->opa <= LV_OPA_MIN) return; draw_dsc->width = lv_obj_get_style_line_width(obj, part); if(draw_dsc->width == 0) return; @@ -259,16 +238,11 @@ void lv_obj_init_draw_arc_dsc(lv_obj_t * obj, uint32_t part, lv_draw_arc_dsc_t * draw_dsc->opa = lv_obj_get_style_arc_opa(obj, part); if(draw_dsc->opa <= LV_OPA_MIN) return; - if(part != LV_PART_MAIN) { - lv_opa_t opa = lv_obj_get_style_opa(obj, part); - if(opa <= LV_OPA_MIN) { - draw_dsc->opa = LV_OPA_TRANSP; - return; - } - if(opa < LV_OPA_MAX) { - draw_dsc->opa = LV_OPA_MIX2(opa, draw_dsc->opa); - } + lv_opa_t opa = lv_obj_get_style_opa_recursive(obj, part); + if(opa < LV_OPA_MAX) { + draw_dsc->opa = LV_OPA_MIX2(draw_dsc->opa, opa); } + if(draw_dsc->opa <= LV_OPA_MIN) return; draw_dsc->color = lv_obj_get_style_arc_color_filtered(obj, part); draw_dsc->img_src = lv_obj_get_style_arc_img_src(obj, part); diff --git a/src/core/lv_obj_style.c b/src/core/lv_obj_style.c index 16e0f637d..15cf79b58 100644 --- a/src/core/lv_obj_style.c +++ b/src/core/lv_obj_style.c @@ -563,6 +563,40 @@ lv_text_align_t lv_obj_calculate_style_text_align(const struct _lv_obj_t * obj, return align; } +lv_opa_t lv_obj_get_style_opa_recursive(const lv_obj_t * obj, lv_part_t part) +{ + + lv_opa_t opa_obj = lv_obj_get_style_opa(obj, part); + if(opa_obj <= LV_OPA_MIN) return LV_OPA_TRANSP; + + lv_opa_t opa_final = LV_OPA_COVER; + if(opa_obj < LV_OPA_MAX) { + opa_final = LV_OPA_MIX2(opa_final, opa_obj); + } + + if(part != LV_PART_MAIN) { + part = LV_PART_MAIN; + } + else { + obj = lv_obj_get_parent(obj); + } + + while(obj) { + opa_obj = lv_obj_get_style_opa(obj, part); + if(opa_obj <= LV_OPA_MIN) return LV_OPA_TRANSP; + if(opa_obj < LV_OPA_MAX) { + opa_final = LV_OPA_MIX2(opa_final, opa_obj); + } + + obj = lv_obj_get_parent(obj); + } + + if(opa_final <= LV_OPA_MIN) return LV_OPA_TRANSP; + if(opa_final >= LV_OPA_MAX) return LV_OPA_COVER; + return opa_final; +} + + /********************** * STATIC FUNCTIONS **********************/ @@ -919,7 +953,7 @@ static lv_layer_type_t calculate_layer_type(lv_obj_t * obj) { if(lv_obj_get_style_transform_angle(obj, 0) != 0) return LV_LAYER_TYPE_TRANSFORM; if(lv_obj_get_style_transform_zoom(obj, 0) != 256) return LV_LAYER_TYPE_TRANSFORM; - if(lv_obj_get_style_opa(obj, 0) != LV_OPA_COVER) return LV_LAYER_TYPE_SIMPLE; + if(lv_obj_get_style_opa_layered(obj, 0) != LV_OPA_COVER) return LV_LAYER_TYPE_SIMPLE; if(lv_obj_get_style_blend_mode(obj, 0) != LV_BLEND_MODE_NORMAL) return LV_LAYER_TYPE_SIMPLE; return LV_LAYER_TYPE_NONE; } diff --git a/src/core/lv_obj_style.h b/src/core/lv_obj_style.h index bc6887d15..532c47ee9 100644 --- a/src/core/lv_obj_style.h +++ b/src/core/lv_obj_style.h @@ -314,6 +314,17 @@ static inline lv_coord_t lv_obj_get_style_transform_zoom_safe(const struct _lv_o int16_t zoom = lv_obj_get_style_transform_zoom(obj, part); return zoom != 0 ? zoom : 1; } + + +/** + * Get the `opa` style property from all parents and multiply and `>> 8` them. + * @param obj the object whose opacity should be get + * @param part the part whose opacity should be get. Non-MAIN parts will consider the `opa` of teh MAIN part too + * @return the final opacity considering the parents' opacity too + */ +lv_opa_t lv_obj_get_style_opa_recursive(const struct _lv_obj_t * obj, lv_part_t part); + + /********************** * MACROS **********************/ diff --git a/src/core/lv_obj_style_gen.c b/src/core/lv_obj_style_gen.c index dc0a480b3..be049a090 100644 --- a/src/core/lv_obj_style_gen.c +++ b/src/core/lv_obj_style_gen.c @@ -632,6 +632,14 @@ void lv_obj_set_style_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selec lv_obj_set_local_style_prop(obj, LV_STYLE_OPA, v, selector); } +void lv_obj_set_style_opa_layered(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_obj_set_local_style_prop(obj, LV_STYLE_OPA_LAYERED, v, selector); +} + void lv_obj_set_style_color_filter_dsc(struct _lv_obj_t * obj, const lv_color_filter_dsc_t * value, lv_style_selector_t selector) { lv_style_value_t v = { diff --git a/src/core/lv_obj_style_gen.h b/src/core/lv_obj_style_gen.h index 13d9e5347..012c0a8ce 100644 --- a/src/core/lv_obj_style_gen.h +++ b/src/core/lv_obj_style_gen.h @@ -535,6 +535,12 @@ static inline lv_opa_t lv_obj_get_style_opa(const struct _lv_obj_t * obj, uint32 return (lv_opa_t)v.num; } +static inline lv_opa_t lv_obj_get_style_opa_layered(const struct _lv_obj_t * obj, uint32_t part) +{ + lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_OPA_LAYERED); + return (lv_opa_t)v.num; +} + static inline const lv_color_filter_dsc_t * lv_obj_get_style_color_filter_dsc(const struct _lv_obj_t * obj, uint32_t part) { lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_COLOR_FILTER_DSC); @@ -668,6 +674,7 @@ void lv_obj_set_style_text_align(struct _lv_obj_t * obj, lv_text_align_t value, void lv_obj_set_style_radius(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector); void lv_obj_set_style_clip_corner(struct _lv_obj_t * obj, bool value, lv_style_selector_t selector); void lv_obj_set_style_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector); +void lv_obj_set_style_opa_layered(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector); void lv_obj_set_style_color_filter_dsc(struct _lv_obj_t * obj, const lv_color_filter_dsc_t * value, lv_style_selector_t selector); void lv_obj_set_style_color_filter_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector); void lv_obj_set_style_anim(struct _lv_obj_t * obj, const lv_anim_t * value, lv_style_selector_t selector); diff --git a/src/core/lv_refr.c b/src/core/lv_refr.c index dd3ba7cc9..9c67e12c0 100644 --- a/src/core/lv_refr.c +++ b/src/core/lv_refr.c @@ -789,7 +789,7 @@ void refr_obj(lv_layer_t * layer, lv_obj_t * obj) lv_obj_redraw(layer, obj); } else { - lv_opa_t opa = lv_obj_get_style_opa(obj, 0); + lv_opa_t opa = lv_obj_get_style_opa_layered(obj, 0); if(opa < LV_OPA_MIN) return; lv_area_t layer_area_full; diff --git a/src/misc/lv_style.c b/src/misc/lv_style.c index a8e4eff1f..07bb135de 100644 --- a/src/misc/lv_style.c +++ b/src/misc/lv_style.c @@ -125,7 +125,8 @@ const uint8_t _lv_style_builtin_prop_flag_lookup_table[_LV_STYLE_NUM_BUILT_IN_PR [LV_STYLE_RADIUS] = 0, [LV_STYLE_CLIP_CORNER] = 0, - [LV_STYLE_OPA] = LV_STYLE_PROP_FLAG_LAYER_UPDATE, + [LV_STYLE_OPA] = 0, + [LV_STYLE_OPA_LAYERED] = LV_STYLE_PROP_FLAG_LAYER_UPDATE, [LV_STYLE_COLOR_FILTER_DSC] = LV_STYLE_PROP_FLAG_INHERITABLE, [LV_STYLE_COLOR_FILTER_OPA] = LV_STYLE_PROP_FLAG_INHERITABLE, [LV_STYLE_ANIM_TIME] = 0, @@ -332,6 +333,7 @@ lv_style_value_t lv_style_prop_get_default(lv_style_prop_t prop) value.color = lv_color_black(); break; case LV_STYLE_OPA: + case LV_STYLE_OPA_LAYERED: case LV_STYLE_BORDER_OPA: case LV_STYLE_TEXT_OPA: case LV_STYLE_IMG_OPA: diff --git a/src/misc/lv_style.h b/src/misc/lv_style.h index 97ec6bb15..a0a8b931c 100644 --- a/src/misc/lv_style.h +++ b/src/misc/lv_style.h @@ -292,23 +292,24 @@ enum _lv_style_prop_t { /*Group 6*/ LV_STYLE_OPA = 96, - LV_STYLE_COLOR_FILTER_DSC = 97, - LV_STYLE_COLOR_FILTER_OPA = 98, - LV_STYLE_ANIM = 99, - LV_STYLE_ANIM_TIME = 100, - LV_STYLE_ANIM_SPEED = 101, - LV_STYLE_TRANSITION = 102, - LV_STYLE_BLEND_MODE = 103, - LV_STYLE_TRANSFORM_WIDTH = 104, - LV_STYLE_TRANSFORM_HEIGHT = 105, - LV_STYLE_TRANSLATE_X = 106, - LV_STYLE_TRANSLATE_Y = 107, - LV_STYLE_TRANSFORM_ZOOM = 108, - LV_STYLE_TRANSFORM_ANGLE = 109, - LV_STYLE_TRANSFORM_PIVOT_X = 110, - LV_STYLE_TRANSFORM_PIVOT_Y = 111, + LV_STYLE_OPA_LAYERED = 97, + LV_STYLE_COLOR_FILTER_DSC = 98, + LV_STYLE_COLOR_FILTER_OPA = 99, + LV_STYLE_ANIM = 100, + LV_STYLE_ANIM_TIME = 101, + LV_STYLE_ANIM_SPEED = 102, + LV_STYLE_TRANSITION = 103, + LV_STYLE_BLEND_MODE = 104, + LV_STYLE_TRANSFORM_WIDTH = 105, + LV_STYLE_TRANSFORM_HEIGHT = 106, + LV_STYLE_TRANSLATE_X = 107, + LV_STYLE_TRANSLATE_Y = 108, + LV_STYLE_TRANSFORM_ZOOM = 109, + LV_STYLE_TRANSFORM_ANGLE = 110, + LV_STYLE_TRANSFORM_PIVOT_X = 111, + LV_STYLE_TRANSFORM_PIVOT_Y = 112, - _LV_STYLE_LAST_BUILT_IN_PROP = 111, + _LV_STYLE_LAST_BUILT_IN_PROP = 112, _LV_STYLE_NUM_BUILT_IN_PROPS = _LV_STYLE_LAST_BUILT_IN_PROP + 1, LV_STYLE_PROP_ANY = 0xFFFF, diff --git a/src/misc/lv_style_gen.c b/src/misc/lv_style_gen.c index c8dfcaa9b..70adbaa9c 100644 --- a/src/misc/lv_style_gen.c +++ b/src/misc/lv_style_gen.c @@ -790,6 +790,16 @@ void lv_style_set_opa(lv_style_t * style, lv_opa_t value) const lv_style_prop_t _lv_style_const_prop_id_OPA = LV_STYLE_OPA; +void lv_style_set_opa_layered(lv_style_t * style, lv_opa_t value) +{ + lv_style_value_t v = { + .num = (int32_t)value + }; + lv_style_set_prop(style, LV_STYLE_OPA_LAYERED, v); +} + +const lv_style_prop_t _lv_style_const_prop_id_OPA_LAYERED = LV_STYLE_OPA_LAYERED; + void lv_style_set_color_filter_dsc(lv_style_t * style, const lv_color_filter_dsc_t * value) { lv_style_value_t v = { diff --git a/src/misc/lv_style_gen.h b/src/misc/lv_style_gen.h index 70829daf9..7bc5c5701 100644 --- a/src/misc/lv_style_gen.h +++ b/src/misc/lv_style_gen.h @@ -156,6 +156,8 @@ void lv_style_set_clip_corner(lv_style_t * style, bool value); extern const lv_style_prop_t _lv_style_const_prop_id_CLIP_CORNER; void lv_style_set_opa(lv_style_t * style, lv_opa_t value); extern const lv_style_prop_t _lv_style_const_prop_id_OPA; +void lv_style_set_opa_layered(lv_style_t * style, lv_opa_t value); +extern const lv_style_prop_t _lv_style_const_prop_id_OPA_LAYERED; void lv_style_set_color_filter_dsc(lv_style_t * style, const lv_color_filter_dsc_t * value); extern const lv_style_prop_t _lv_style_const_prop_id_COLOR_FILTER_DSC; void lv_style_set_color_filter_opa(lv_style_t * style, lv_opa_t value); @@ -570,6 +572,11 @@ extern const lv_style_prop_t _lv_style_const_prop_id_BASE_DIR; .prop_ptr = &_lv_style_const_prop_id_OPA, .value = { .num = (int32_t)val } \ } +#define LV_STYLE_CONST_OPA_LAYERED(val) \ + { \ + .prop_ptr = &_lv_style_const_prop_id_OPA_LAYERED, .value = { .num = (int32_t)val } \ + } + #define LV_STYLE_CONST_COLOR_FILTER_DSC(val) \ { \ .prop_ptr = &_lv_style_const_prop_id_COLOR_FILTER_DSC, .value = { .ptr = val } \ diff --git a/src/widgets/meter/lv_meter.c b/src/widgets/meter/lv_meter.c index 3ce7ddeba..39b7edf74 100644 --- a/src/widgets/meter/lv_meter.c +++ b/src/widgets/meter/lv_meter.c @@ -340,7 +340,7 @@ static void draw_arcs(lv_obj_t * obj, lv_layer_t * layer, const lv_area_t * scal scale_center.x = scale_area->x1 + r_out; scale_center.y = scale_area->y1 + r_out; - lv_opa_t opa_main = lv_obj_get_style_opa(obj, LV_PART_MAIN); + lv_opa_t opa_main = lv_obj_get_style_opa_recursive(obj, LV_PART_MAIN); lv_meter_indicator_t * indic; _LV_LL_READ_BACK(&meter->indicator_ll, indic) { @@ -493,7 +493,7 @@ static void draw_needles(lv_obj_t * obj, lv_layer_t * layer, const lv_area_t * s lv_draw_img_dsc_t img_dsc; lv_draw_img_dsc_init(&img_dsc); lv_obj_init_draw_img_dsc(obj, LV_PART_ITEMS, &img_dsc); - lv_opa_t opa_main = lv_obj_get_style_opa(obj, LV_PART_MAIN); + lv_opa_t opa_main = lv_obj_get_style_opa_recursive(obj, LV_PART_MAIN); lv_meter_indicator_t * indic; _LV_LL_READ_BACK(&meter->indicator_ll, indic) { diff --git a/src/widgets/span/lv_span.c b/src/widgets/span/lv_span.c index bd20c4c9b..f771db80d 100644 --- a/src/widgets/span/lv_span.c +++ b/src/widgets/span/lv_span.c @@ -797,7 +797,7 @@ static void lv_draw_span(lv_obj_t * obj, lv_layer_t * layer) lv_coord_t max_width = lv_area_get_width(&coords); lv_coord_t indent = convert_indent_pct(obj, max_width); lv_coord_t max_w = max_width - indent; /* first line need minus indent */ - lv_opa_t obj_opa = lv_obj_get_style_opa(obj, LV_PART_MAIN); + lv_opa_t obj_opa = lv_obj_get_style_opa_recursive(obj, LV_PART_MAIN); /* coords of draw span-txt */ lv_point_t txt_pos; diff --git a/tests/src/test_cases/test_draw_layer.c b/tests/src/test_cases/test_draw_layer.c index 252e49c13..b166db597 100644 --- a/tests/src/test_cases/test_draw_layer.c +++ b/tests/src/test_cases/test_draw_layer.c @@ -45,13 +45,13 @@ void test_layer_mixed_rgb(void) obj = create_test_obj("Normal", true); obj = create_test_obj("Opa = 50%", true); - lv_obj_set_style_opa(obj, LV_OPA_50, 0); + lv_obj_set_style_opa_layered(obj, LV_OPA_50, 0); obj = create_test_obj("Opa = 20%", true); - lv_obj_set_style_opa(obj, LV_OPA_20, 0); + lv_obj_set_style_opa_layered(obj, LV_OPA_20, 0); obj = create_test_obj("Opa = 90%", true); - lv_obj_set_style_opa(obj, LV_OPA_90, 0); + lv_obj_set_style_opa_layered(obj, LV_OPA_90, 0); obj = create_test_obj("Subtractive", true); lv_obj_set_style_blend_mode(obj, LV_BLEND_MODE_SUBTRACTIVE, 0); @@ -80,13 +80,13 @@ void test_layer_mixed_argb(void) obj = create_test_obj("Normal", false); obj = create_test_obj("Opa = 50%", false); - lv_obj_set_style_opa(obj, LV_OPA_50, 0); + lv_obj_set_style_opa_layered(obj, LV_OPA_50, 0); obj = create_test_obj("Opa = 20%", false); - lv_obj_set_style_opa(obj, LV_OPA_20, 0); + lv_obj_set_style_opa_layered(obj, LV_OPA_20, 0); obj = create_test_obj("Opa = 90%", false); - lv_obj_set_style_opa(obj, LV_OPA_90, 0); + lv_obj_set_style_opa_layered(obj, LV_OPA_90, 0); obj = create_test_obj("Subtractive", false); lv_obj_set_style_blend_mode(obj, LV_BLEND_MODE_SUBTRACTIVE, 0); @@ -114,7 +114,7 @@ void test_layer_large_opa_argb(void) obj = create_test_obj(lorem_ipsum, false); lv_obj_set_width(lv_obj_get_child(obj, 0), lv_pct(100)); lv_obj_set_size(obj, 600, 400); - lv_obj_set_style_opa(obj, LV_OPA_50, 0); + lv_obj_set_style_opa_layered(obj, LV_OPA_50, 0); TEST_ASSERT_EQUAL_SCREENSHOT("draw/layer_large_opa_argb.png"); } @@ -125,7 +125,7 @@ void test_layer_large_opa_rgb(void) obj = create_test_obj(lorem_ipsum, true); lv_obj_set_width(lv_obj_get_child(obj, 0), lv_pct(100)); lv_obj_set_size(obj, 600, 400); - lv_obj_set_style_opa(obj, LV_OPA_50, 0); + lv_obj_set_style_opa_layered(obj, LV_OPA_50, 0); TEST_ASSERT_EQUAL_SCREENSHOT("draw/layer_large_opa_rgb.png"); }