mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 21:00:03 -04:00
[window] prevent trying to shrink window smaller than title bar width
This commit is contained in:
@@ -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,
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user