mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 14:50:03 -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:
@@ -1237,7 +1237,7 @@ mod glow_integration {
|
|||||||
active_viewports_ids.push(id);
|
active_viewports_ids.push(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TODO Make this more efficient
|
// TODO Make this more efficient
|
||||||
for (id, command) in viewport_commands {
|
for (id, command) in viewport_commands {
|
||||||
for window in gl_window.windows.iter() {
|
for window in gl_window.windows.iter() {
|
||||||
if window.window_id == id {
|
if window.window_id == id {
|
||||||
|
|||||||
@@ -468,6 +468,7 @@ impl<'open> Window<'open> {
|
|||||||
|
|
||||||
// let is_explicitly_closed = matches!(open, Some(false));
|
// let is_explicitly_closed = matches!(open, Some(false));
|
||||||
let is_open = is_open || ctx.memory(|mem| mem.everything_is_visible());
|
let is_open = is_open || ctx.memory(|mem| mem.everything_is_visible());
|
||||||
|
'create_viewport: {
|
||||||
if !embedded {
|
if !embedded {
|
||||||
if !is_open {
|
if !is_open {
|
||||||
return;
|
return;
|
||||||
@@ -476,8 +477,12 @@ impl<'open> Window<'open> {
|
|||||||
let size = size.round() + ctx.style().spacing.window_margin.sum();
|
let size = size.round() + ctx.style().spacing.window_margin.sum();
|
||||||
window_builder =
|
window_builder =
|
||||||
window_builder.with_inner_size((size.x as u32 + 1, size.y as u32 + 1));
|
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.close_button = open.is_some();
|
||||||
|
window_builder.resizable = resize.is_resizable();
|
||||||
|
|
||||||
let area_id = area.id;
|
let area_id = area.id;
|
||||||
|
|
||||||
@@ -490,7 +495,8 @@ impl<'open> Window<'open> {
|
|||||||
.events
|
.events
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|event| {
|
.filter(|event| {
|
||||||
if let Event::WindowEvent(WindowEvent::CloseRequested) = **event {
|
if let Event::WindowEvent(WindowEvent::CloseRequested) = **event
|
||||||
|
{
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
@@ -499,15 +505,19 @@ impl<'open> Window<'open> {
|
|||||||
.count()
|
.count()
|
||||||
});
|
});
|
||||||
if count > 0 {
|
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);
|
ctx.request_repaint_viewport(parent_viewport_id);
|
||||||
}
|
}
|
||||||
CentralPanel::default().frame(frame).show(ctx, |ui| {
|
CentralPanel::default().frame(frame).show(ctx, |ui| {
|
||||||
Some(add_contents(ui, viewport_id, parent_viewport_id))
|
Some(add_contents(ui, viewport_id, parent_viewport_id))
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
)
|
);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
let frame = frame.unwrap_or_else(|| Frame::window(&ctx.style()));
|
let frame = frame.unwrap_or_else(|| Frame::window(&ctx.style()));
|
||||||
|
|
||||||
area.show_open_close_animation(ctx, &frame, is_open);
|
area.show_open_close_animation(ctx, &frame, is_open);
|
||||||
@@ -519,11 +529,8 @@ impl<'open> Window<'open> {
|
|||||||
let area_id = area.id;
|
let area_id = area.id;
|
||||||
let area_layer_id = area.layer();
|
let area_layer_id = area.layer();
|
||||||
let resize_id = area_id.with("resize");
|
let resize_id = area_id.with("resize");
|
||||||
let mut collapsing = CollapsingState::load_with_default_open(
|
let mut collapsing =
|
||||||
ctx,
|
CollapsingState::load_with_default_open(ctx, area_id.with("collapsing"), default_open);
|
||||||
area_id.with("collapsing"),
|
|
||||||
default_open,
|
|
||||||
);
|
|
||||||
|
|
||||||
let is_collapsed = with_title_bar && !collapsing.is_open();
|
let is_collapsed = with_title_bar && !collapsing.is_open();
|
||||||
let possible = PossibleInteractions::new(&area, &resize, is_collapsed);
|
let possible = PossibleInteractions::new(&area, &resize, is_collapsed);
|
||||||
@@ -570,8 +577,7 @@ impl<'open> Window<'open> {
|
|||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let hover_interaction =
|
let hover_interaction = resize_hover(ctx, possible, area_layer_id, last_frame_outer_rect);
|
||||||
resize_hover(ctx, possible, area_layer_id, last_frame_outer_rect);
|
|
||||||
|
|
||||||
let mut area_content_ui = area.content_ui(ctx);
|
let mut area_content_ui = area.content_ui(ctx);
|
||||||
|
|
||||||
@@ -668,8 +674,6 @@ impl<'open> Window<'open> {
|
|||||||
inner: content_inner,
|
inner: content_inner,
|
||||||
response: full_response,
|
response: full_response,
|
||||||
};
|
};
|
||||||
// Some(inner_response)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user