1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-03 07:10:04 -04:00

Now the window will have the correct size

Now window will not be resizable if is set to false
This commit is contained in:
Konkitoman
2023-07-25 12:10:56 +03:00
parent 19d1fecb99
commit 08b3afdc5e
2 changed files with 175 additions and 171 deletions

View File

@@ -1237,7 +1237,7 @@ mod glow_integration {
active_viewports_ids.push(id);
}
/// TODO Make this more efficient
// TODO Make this more efficient
for (id, command) in viewport_commands {
for window in gl_window.windows.iter() {
if window.window_id == id {

View File

@@ -468,6 +468,7 @@ impl<'open> Window<'open> {
// let is_explicitly_closed = matches!(open, Some(false));
let is_open = is_open || ctx.memory(|mem| mem.everything_is_visible());
'create_viewport: {
if !embedded {
if !is_open {
return;
@@ -476,8 +477,12 @@ impl<'open> Window<'open> {
let size = size.round() + ctx.style().spacing.window_margin.sum();
window_builder =
window_builder.with_inner_size((size.x as u32 + 1, size.y as u32 + 1));
} else {
ctx.request_repaint();
break 'create_viewport;
}
window_builder.close_button = open.is_some();
window_builder.resizable = resize.is_resizable();
let area_id = area.id;
@@ -490,7 +495,8 @@ impl<'open> Window<'open> {
.events
.iter()
.filter(|event| {
if let Event::WindowEvent(WindowEvent::CloseRequested) = **event {
if let Event::WindowEvent(WindowEvent::CloseRequested) = **event
{
true
} else {
false
@@ -499,15 +505,19 @@ impl<'open> Window<'open> {
.count()
});
if count > 0 {
ctx.data_mut(|data| data.insert_persisted(area_id.with("_open"), false));
ctx.data_mut(|data| {
data.insert_persisted(area_id.with("_open"), false)
});
ctx.request_repaint_viewport(parent_viewport_id);
}
CentralPanel::default().frame(frame).show(ctx, |ui| {
Some(add_contents(ui, viewport_id, parent_viewport_id))
});
},
)
} else {
);
return;
}
}
let frame = frame.unwrap_or_else(|| Frame::window(&ctx.style()));
area.show_open_close_animation(ctx, &frame, is_open);
@@ -519,11 +529,8 @@ impl<'open> Window<'open> {
let area_id = area.id;
let area_layer_id = area.layer();
let resize_id = area_id.with("resize");
let mut collapsing = CollapsingState::load_with_default_open(
ctx,
area_id.with("collapsing"),
default_open,
);
let mut collapsing =
CollapsingState::load_with_default_open(ctx, area_id.with("collapsing"), default_open);
let is_collapsed = with_title_bar && !collapsing.is_open();
let possible = PossibleInteractions::new(&area, &resize, is_collapsed);
@@ -570,8 +577,7 @@ impl<'open> Window<'open> {
} else {
None
};
let hover_interaction =
resize_hover(ctx, possible, area_layer_id, last_frame_outer_rect);
let hover_interaction = resize_hover(ctx, possible, area_layer_id, last_frame_outer_rect);
let mut area_content_ui = area.content_ui(ctx);
@@ -668,8 +674,6 @@ impl<'open> Window<'open> {
inner: content_inner,
response: full_response,
};
// Some(inner_response)
}
}
}