Skip to content

Commit

Permalink
ViewportOutput: only include parent id, as own if is the key of map
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Nov 16, 2023
1 parent fb21fee commit 2cb2434
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
8 changes: 6 additions & 2 deletions crates/eframe/src/native/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,14 +1165,16 @@ mod glow_integration {
for (
viewport_id,
ViewportOutput {
ids,
parent,
builder,
viewport_ui_cb,
commands,
repaint_delay: _, // ignored - we listend to the repaint callback instead
},
) in viewport_output
{
let ids = ViewportIdPair::from_self_and_parent(viewport_id, parent);

initialize_or_update_viewport(
&mut self.viewports,
ids,
Expand Down Expand Up @@ -2673,14 +2675,16 @@ mod wgpu_integration {
for (
viewport_id,
ViewportOutput {
ids,
parent,
builder,
viewport_ui_cb,
commands,
repaint_delay: _, // ignored - we listend to the repaint callback instead
},
) in viewport_output
{
let ids = ViewportIdPair::from_self_and_parent(viewport_id, parent);

initialize_or_update_viewport(
viewports,
ids,
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ impl ContextImpl {
(
id,
ViewportOutput {
ids: ViewportIdPair::from_self_and_parent(id, parent),
parent,
builder: viewport.builder.clone(),
viewport_ui_cb: viewport.viewport_ui_cb.clone(),
commands,
Expand Down
13 changes: 5 additions & 8 deletions crates/egui/src/viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,10 @@ pub enum ViewportCommand {
/// Describes a viewport, i.e. a native window.
#[derive(Clone)]
pub struct ViewportOutput {
/// Id of us and our parent.
pub ids: ViewportIdPair,
/// Id of our parent viewport.
pub parent: ViewportId,

/// The window attrbiutes such as title, position, size, etc.
pub builder: ViewportBuilder,

/// The user-code that shows the GUI, used for deferred viewports.
Expand All @@ -688,21 +689,17 @@ pub struct ViewportOutput {
}

impl ViewportOutput {
pub fn id(&self) -> ViewportId {
self.ids.this
}

/// Add on new output.
pub fn append(&mut self, newer: Self) {
let Self {
ids,
parent,
builder,
viewport_ui_cb,
mut commands,
repaint_delay,
} = newer;

self.ids = ids;
self.parent = parent;
self.builder.patch(&builder);
self.viewport_ui_cb = viewport_ui_cb;
self.commands.append(&mut commands);
Expand Down

0 comments on commit 2cb2434

Please sign in to comment.