Skip to content

Commit

Permalink
Make sure contents of a panel don't overflow (#4676)
Browse files Browse the repository at this point in the history
* Closes #4475
  • Loading branch information
emilk authored Jun 19, 2024
1 parent 598dd53 commit d23742c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crates/egui/src/containers/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ impl SidePanel {
})),
);
panel_ui.expand_to_include_rect(panel_rect);
panel_ui.set_clip_rect(panel_rect); // If we overflow, don't do so visibly (#4475)

let frame = frame.unwrap_or_else(|| Frame::side_top_panel(ui.style()));
let inner_response = frame.show(&mut panel_ui, |ui| {
ui.set_min_height(ui.max_rect().height()); // Make sure the frame fills the full height
Expand Down Expand Up @@ -335,7 +337,7 @@ impl SidePanel {
// (hence the shrink).
let resize_x = side.opposite().side_x(rect.shrink(1.0));
let resize_x = ui.painter().round_to_pixel(resize_x);
ui.painter().vline(resize_x, rect.y_range(), stroke);
ui.painter().vline(resize_x, panel_rect.y_range(), stroke);
}

inner_response
Expand Down Expand Up @@ -749,6 +751,8 @@ impl TopBottomPanel {
})),
);
panel_ui.expand_to_include_rect(panel_rect);
panel_ui.set_clip_rect(panel_rect); // If we overflow, don't do so visibly (#4475)

let frame = frame.unwrap_or_else(|| Frame::side_top_panel(ui.style()));
let inner_response = frame.show(&mut panel_ui, |ui| {
ui.set_min_width(ui.max_rect().width()); // Make the frame fill full width
Expand Down Expand Up @@ -814,7 +818,7 @@ impl TopBottomPanel {
// (hence the shrink).
let resize_y = side.opposite().side_y(rect.shrink(1.0));
let resize_y = ui.painter().round_to_pixel(resize_y);
ui.painter().hline(rect.x_range(), resize_y, stroke);
ui.painter().hline(panel_rect.x_range(), resize_y, stroke);
}

inner_response
Expand Down Expand Up @@ -1078,6 +1082,7 @@ impl CentralPanel {
Layout::top_down(Align::Min),
Some(UiStackInfo::new(UiKind::CentralPanel)),
);
panel_ui.set_clip_rect(panel_rect); // If we overflow, don't do so visibly (#4475)

let frame = frame.unwrap_or_else(|| Frame::central_panel(ui.style()));
frame.show(&mut panel_ui, |ui| {
Expand Down

0 comments on commit d23742c

Please sign in to comment.