⚠️ Frame now includes stroke width as part of padding (#5575)
* Part of https://github.com/emilk/egui/issues/4019 `Frame` now includes the width of the stroke as part of its size. From the new docs: ### `Frame` docs The total (outer) size of a frame is `content_size + inner_margin + 2*stroke.width + outer_margin`. Everything within the stroke is filled with the fill color (if any). ```text +-----------------^-------------------------------------- -+ | | outer_margin | | +------------v----^------------------------------+ | | | | stroke width | | | | +------------v---^---------------------+ | | | | | | inner_margin | | | | | | +-----------v----------------+ | | | | | | | ^ | | | | | | | | | | | | | | | | |<------ content_size ------>| | | | | | | | | | | | | | | | | v | | | | | | | +------- content_rect -------+ | | | | | | | | | | | +-------------fill_rect ---------------+ | | | | | | | +----------------- widget_rect ------------------+ | | | +---------------------- outer_rect ------------------------+ ``` The four rectangles, from inside to outside, are: * `content_rect`: the rectangle that is made available to the inner [`Ui`] or widget. * `fill_rect`: the rectangle that is filled with the fill color (inside the stroke, if any). * `widget_rect`: is the interactive part of the widget (what sense clicks etc). * `outer_rect`: what is allocated in the outer [`Ui`], and is what is returned by [`Response::rect`]. ### Notes This required rewriting a lot of the layout code for `egui::Window`, which was a massive pain. But now the window margin and stroke width is properly accounted for everywhere.
This commit is contained in:
@@ -7,19 +7,18 @@ pub struct FrameDemo {
|
||||
impl Default for FrameDemo {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
frame: egui::Frame {
|
||||
inner_margin: 12.0.into(),
|
||||
outer_margin: 24.0.into(),
|
||||
rounding: 14.0.into(),
|
||||
shadow: egui::Shadow {
|
||||
frame: egui::Frame::new()
|
||||
.inner_margin(12)
|
||||
.outer_margin(24)
|
||||
.rounding(14)
|
||||
.shadow(egui::Shadow {
|
||||
offset: [8, 12],
|
||||
blur: 16,
|
||||
spread: 0,
|
||||
color: egui::Color32::from_black_alpha(180),
|
||||
},
|
||||
fill: egui::Color32::from_rgba_unmultiplied(97, 0, 255, 128),
|
||||
stroke: egui::Stroke::new(1.0, egui::Color32::GRAY),
|
||||
},
|
||||
})
|
||||
.fill(egui::Color32::from_rgba_unmultiplied(97, 0, 255, 128))
|
||||
.stroke(egui::Stroke::new(1.0, egui::Color32::GRAY)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user