Inset container contents to account for container border
This commit is contained in:
parent
e487aa5cbd
commit
995acefce5
2 changed files with 19 additions and 1 deletions
|
@ -168,7 +168,9 @@ impl Element for Container {
|
|||
corner_radius: self.corner_radius,
|
||||
});
|
||||
|
||||
let child_origin = quad_bounds.origin() + vec2f(self.padding.left, self.padding.top);
|
||||
let child_origin = quad_bounds.origin()
|
||||
+ vec2f(self.padding.left, self.padding.top)
|
||||
+ vec2f(self.border.left_width(), self.border.top_width());
|
||||
self.child.paint(child_origin, ctx);
|
||||
}
|
||||
|
||||
|
|
|
@ -222,4 +222,20 @@ impl Border {
|
|||
fn all_sides(&self) -> bool {
|
||||
self.top && self.left && self.bottom && self.right
|
||||
}
|
||||
|
||||
pub fn top_width(&self) -> f32 {
|
||||
if self.top {
|
||||
self.width
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
}
|
||||
|
||||
pub fn left_width(&self) -> f32 {
|
||||
if self.left {
|
||||
self.width
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue