Browse Source

[window] prevent trying to shrink window smaller than title bar width

pull/20/head
Emil Ernerfeldt 4 years ago
parent
commit
8c03f6a90f
  1. 2
      egui/src/containers/resize.rs
  2. 6
      egui/src/containers/window.rs

2
egui/src/containers/resize.rs

@ -24,7 +24,7 @@ pub struct Resize {
/// If false, we are no enabled
resizable: bool,
min_size: Vec2,
pub(crate) min_size: Vec2,
default_size: Vec2,

6
egui/src/containers/window.rs

@ -195,8 +195,7 @@ impl<'open> Window<'open> {
let area = area.movable(false); // We move it manually
let resize = resize.resizable(false); // We move it manually
let resize = resize.id(resize_id);
let mut resize = resize.id(resize_id);
let frame = frame.unwrap_or_else(|| Frame::window(&ctx.style()));
@ -253,6 +252,7 @@ impl<'open> Window<'open> {
&mut collapsing,
collapsible,
);
resize.min_size.x = resize.min_size.x.max(title_bar.rect.width()); // Prevent making window smaller than title bar width
let content_rect = collapsing
.add_contents(&mut frame.content_ui, |ui| {
@ -613,7 +613,7 @@ fn show_title_bar(
let title_rect = ui.allocate_space(title_galley.size);
if show_close_button {
// Reserve space for close button which will be added later:
// Reserve space for close button which will be added later (once we know our full width):
let close_max_x = title_rect.right() + item_spacing.x + button_size + item_spacing.x;
let close_max_x = close_max_x.max(ui.rect_finite().right());
let close_rect = Rect::from_min_size(

Loading…
Cancel
Save