1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 05:40:03 -04:00

ViewportOutput: only include parent id, as own if is the key of map

This commit is contained in:
Emil Ernerfeldt
2023-11-16 08:35:51 +01:00
parent fb21feecf9
commit 2cb2434e69
3 changed files with 12 additions and 11 deletions

View File

@@ -1165,7 +1165,7 @@ mod glow_integration {
for ( for (
viewport_id, viewport_id,
ViewportOutput { ViewportOutput {
ids, parent,
builder, builder,
viewport_ui_cb, viewport_ui_cb,
commands, commands,
@@ -1173,6 +1173,8 @@ mod glow_integration {
}, },
) in viewport_output ) in viewport_output
{ {
let ids = ViewportIdPair::from_self_and_parent(viewport_id, parent);
initialize_or_update_viewport( initialize_or_update_viewport(
&mut self.viewports, &mut self.viewports,
ids, ids,
@@ -2673,7 +2675,7 @@ mod wgpu_integration {
for ( for (
viewport_id, viewport_id,
ViewportOutput { ViewportOutput {
ids, parent,
builder, builder,
viewport_ui_cb, viewport_ui_cb,
commands, commands,
@@ -2681,6 +2683,8 @@ mod wgpu_integration {
}, },
) in viewport_output ) in viewport_output
{ {
let ids = ViewportIdPair::from_self_and_parent(viewport_id, parent);
initialize_or_update_viewport( initialize_or_update_viewport(
viewports, viewports,
ids, ids,

View File

@@ -1608,7 +1608,7 @@ impl ContextImpl {
( (
id, id,
ViewportOutput { ViewportOutput {
ids: ViewportIdPair::from_self_and_parent(id, parent), parent,
builder: viewport.builder.clone(), builder: viewport.builder.clone(),
viewport_ui_cb: viewport.viewport_ui_cb.clone(), viewport_ui_cb: viewport.viewport_ui_cb.clone(),
commands, commands,

View File

@@ -665,9 +665,10 @@ pub enum ViewportCommand {
/// Describes a viewport, i.e. a native window. /// Describes a viewport, i.e. a native window.
#[derive(Clone)] #[derive(Clone)]
pub struct ViewportOutput { pub struct ViewportOutput {
/// Id of us and our parent. /// Id of our parent viewport.
pub ids: ViewportIdPair, pub parent: ViewportId,
/// The window attrbiutes such as title, position, size, etc.
pub builder: ViewportBuilder, pub builder: ViewportBuilder,
/// The user-code that shows the GUI, used for deferred viewports. /// The user-code that shows the GUI, used for deferred viewports.
@@ -688,21 +689,17 @@ pub struct ViewportOutput {
} }
impl ViewportOutput { impl ViewportOutput {
pub fn id(&self) -> ViewportId {
self.ids.this
}
/// Add on new output. /// Add on new output.
pub fn append(&mut self, newer: Self) { pub fn append(&mut self, newer: Self) {
let Self { let Self {
ids, parent,
builder, builder,
viewport_ui_cb, viewport_ui_cb,
mut commands, mut commands,
repaint_delay, repaint_delay,
} = newer; } = newer;
self.ids = ids; self.parent = parent;
self.builder.patch(&builder); self.builder.patch(&builder);
self.viewport_ui_cb = viewport_ui_cb; self.viewport_ui_cb = viewport_ui_cb;
self.commands.append(&mut commands); self.commands.append(&mut commands);