[button] Implement paint culling for buttons
This commit is contained in:
parent
02b1e82a6e
commit
4db9b82435
1 changed files with 21 additions and 19 deletions
|
@ -389,28 +389,30 @@ impl Widget for Button {
|
||||||
let id = ui.make_position_id();
|
let id = ui.make_position_id();
|
||||||
let response = ui.interact(rect, id, sense);
|
let response = ui.interact(rect, id, sense);
|
||||||
|
|
||||||
let visuals = ui.style().interact(&response);
|
if ui.clip_rect().intersects(rect) {
|
||||||
let text_cursor = ui
|
let visuals = ui.style().interact(&response);
|
||||||
.layout()
|
let text_cursor = ui
|
||||||
.align_size_within_rect(galley.size, response.rect.shrink2(button_padding))
|
.layout()
|
||||||
.min;
|
.align_size_within_rect(galley.size, response.rect.shrink2(button_padding))
|
||||||
|
.min;
|
||||||
|
|
||||||
if frame {
|
if frame {
|
||||||
let fill = fill.unwrap_or(visuals.bg_fill);
|
let fill = fill.unwrap_or(visuals.bg_fill);
|
||||||
ui.painter().rect(
|
ui.painter().rect(
|
||||||
response.rect,
|
response.rect,
|
||||||
visuals.corner_radius,
|
visuals.corner_radius,
|
||||||
fill,
|
fill,
|
||||||
visuals.bg_stroke,
|
visuals.bg_stroke,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let text_color = text_color
|
||||||
|
.or(ui.style().visuals.override_text_color)
|
||||||
|
.unwrap_or_else(|| visuals.text_color());
|
||||||
|
ui.painter()
|
||||||
|
.galley(text_cursor, galley, text_style, text_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
let text_color = text_color
|
|
||||||
.or(ui.style().visuals.override_text_color)
|
|
||||||
.unwrap_or_else(|| visuals.text_color());
|
|
||||||
ui.painter()
|
|
||||||
.galley(text_cursor, galley, text_style, text_color);
|
|
||||||
|
|
||||||
response
|
response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue