Merge pull request #33678 from nekomatata/stylebox-flat-width-zero

StyleBoxFlat doesn't draw content when width or height is zero
This commit is contained in:
Rémi Verschelde 2019-11-17 16:09:26 +01:00 committed by GitHub
commit d75b43e961
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -694,6 +694,11 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
return;
}
Rect2 style_rect = p_rect.grow_individual(expand_margin[MARGIN_LEFT], expand_margin[MARGIN_TOP], expand_margin[MARGIN_RIGHT], expand_margin[MARGIN_BOTTOM]);
if (Math::is_zero_approx(style_rect.size.width) || Math::is_zero_approx(style_rect.size.height)) {
return;
}
bool rounded_corners = (corner_radius[0] > 0) || (corner_radius[1] > 0) || (corner_radius[2] > 0) || (corner_radius[3] > 0);
bool aa_on = rounded_corners && anti_aliased;
@ -701,7 +706,6 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
bool blend_on = blend_border && draw_border;
Rect2 style_rect = p_rect.grow_individual(expand_margin[MARGIN_LEFT], expand_margin[MARGIN_TOP], expand_margin[MARGIN_RIGHT], expand_margin[MARGIN_BOTTOM]);
Rect2 border_style_rect = style_rect;
if (aa_on && !blend_on) {
float aa_size_grow = 0.5 * ((aa_size + 1) / 2);