Clip frame contents to frame border

This commit is contained in:
Emil Ernerfeldt 2020-11-27 15:33:14 +01:00
parent 8c6ccd1f7c
commit d8aeaa4b49

View file

@ -98,10 +98,11 @@ pub struct Prepared {
impl Frame { impl Frame {
pub fn begin(self, ui: &mut Ui) -> Prepared { pub fn begin(self, ui: &mut Ui) -> Prepared {
let where_to_put_background = ui.painter().add(PaintCmd::Noop);
let outer_rect_bounds = ui.available(); let outer_rect_bounds = ui.available();
let inner_rect = outer_rect_bounds.shrink2(self.margin); let inner_rect = outer_rect_bounds.shrink2(self.margin);
let where_to_put_background = ui.painter().add(PaintCmd::Noop); let mut content_ui = ui.child_ui(inner_rect, *ui.layout());
let content_ui = ui.child_ui(inner_rect, *ui.layout()); content_ui.set_clip_rect(outer_rect_bounds.shrink(self.stroke.width * 0.5)); // Don't color outside the lines
Prepared { Prepared {
frame: self, frame: self,
outer_rect_bounds, outer_rect_bounds,