[Request Dev7.0] Any child-drawing is automatically round-croped/masked by parent's style.body.radius too

When a parent is set style with style.body.radius > 0.
and if a child is placed near the parent’s conner,
at any version, the child doen’t be round-croped/masked by the parent’ conner.

Like this simple code example :
a label (child) in a rounded-rect (parent)

Code

  static lv_style_t style; lv_style_copy(&style, &lv_style_plain);
    style.body.main_color   = LV_COLOR_WHITE;
    style.body.grad_color   = style.body.main_color;
    style.body.radius       = 30;
    style.body.border.width = 0;
    style.text.color        = LV_COLOR_RED;

  lv_obj_t* rounded_rect = lv_obj_create(lv_scr_act(), NULL);
    lv_obj_set_style(rounded_rect, &style);
    lv_obj_set_size(rounded_rect, 100, 80);
    lv_obj_align(rounded_rect, NULL, LV_ALIGN_CENTER, 0,0);
  lv_obj_t* label = lv_label_create(rounded_rect, NULL);
    lv_obj_set_style(label, &style);
    lv_label_set_text( label, "Hello World");
    lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, -20);

Result

capture_00075

Wish any child is automatically rounded-croped/masked
by parent’s style.body.radius like this.
capture_00076

If lvgl has this figture automatically, it maybe useful and more beautiful
for any parent such as lv_cont, lv_page with style.body.radius > 0
that it has any child when be scrolled/placed near the parent’s rounded-conner.

Thank you.

It’s automatic but in dev-7.0 you can control it with style.body.corner_mask = 0/1

1 Like

Is this style.body.corner_mask not set to 1 in lv_style_plain by default ?

It’s set 0 by default because it has a performance impact. E.g. if there is a label in the middle of a button, the corners are not affected by the label, but the mask still needs to be calculated.

1 Like