mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 06:10:06 -04:00
Fix viewports example
This commit is contained in:
@@ -972,8 +972,9 @@ mod glow_integration {
|
|||||||
let _gl = gl.clone();
|
let _gl = gl.clone();
|
||||||
let painter = Arc::new(RwLock::new(painter));
|
let painter = Arc::new(RwLock::new(painter));
|
||||||
let _painter = painter.clone();
|
let _painter = painter.clone();
|
||||||
let time = integration.beagining.clone();
|
let time = integration.beagining;
|
||||||
|
|
||||||
|
// Sync Rendering
|
||||||
integration.egui_ctx.set_render_sync_callback(
|
integration.egui_ctx.set_render_sync_callback(
|
||||||
move |viewport_builder, viewport_id, parent_viewport_id, render| {
|
move |viewport_builder, viewport_id, parent_viewport_id, render| {
|
||||||
let window = glutin.read().windows.get(&viewport_id).cloned();
|
let window = glutin.read().windows.get(&viewport_id).cloned();
|
||||||
@@ -986,7 +987,7 @@ mod glow_integration {
|
|||||||
input.time = Some(time.elapsed().as_secs_f64());
|
input.time = Some(time.elapsed().as_secs_f64());
|
||||||
let output =
|
let output =
|
||||||
egui_ctx.run(input, viewport_id, parent_viewport_id, |ctx| {
|
egui_ctx.run(input, viewport_id, parent_viewport_id, |ctx| {
|
||||||
render(&egui_ctx, viewport_id, parent_viewport_id);
|
render(ctx, viewport_id, parent_viewport_id);
|
||||||
});
|
});
|
||||||
let glutin = &mut *glutin.write();
|
let glutin = &mut *glutin.write();
|
||||||
|
|
||||||
@@ -1017,16 +1018,15 @@ mod glow_integration {
|
|||||||
&clipped_primitives,
|
&clipped_primitives,
|
||||||
&output.textures_delta,
|
&output.textures_delta,
|
||||||
);
|
);
|
||||||
unsafe {
|
crate::profile_scope!("swap_buffers");
|
||||||
crate::profile_scope!("swap_buffers");
|
let _ =
|
||||||
let _ = window
|
window
|
||||||
.gl_surface
|
.gl_surface
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.expect("failed to get surface to swap buffers")
|
.expect("failed to get surface to swap buffers")
|
||||||
.swap_buffers(glutin.current_gl_context.as_ref().expect(
|
.swap_buffers(glutin.current_gl_context.as_ref().expect(
|
||||||
"failed to get current context to swap buffers",
|
"failed to get current context to swap buffers",
|
||||||
));
|
));
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,6 +99,12 @@ fn main() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.add(
|
||||||
|
egui::widgets::DragValue::new(&mut value)
|
||||||
|
.clamp_range(-10..=10)
|
||||||
|
.speed(0.1),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
egui::CollapsingHeader::new("Async Test2").show(ui, |ui| {
|
egui::CollapsingHeader::new("Async Test2").show(ui, |ui| {
|
||||||
@@ -126,10 +132,18 @@ fn main() {
|
|||||||
));
|
));
|
||||||
|
|
||||||
if ui.button("Drag").is_pointer_button_down_on() {
|
if ui.button("Drag").is_pointer_button_down_on() {
|
||||||
ctx.viewport_command(
|
if ctx.get_viewport_id() != ctx.get_parent_viewport_id() {
|
||||||
ctx.get_viewport_id(),
|
ctx.viewport_command(
|
||||||
egui::window::ViewportCommand::Drag,
|
ctx.get_viewport_id(),
|
||||||
)
|
egui::window::ViewportCommand::Drag,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
ctx.memory_mut(|mem| {
|
||||||
|
mem.set_dragged_id(
|
||||||
|
egui::Id::new("Test2").with("frame_resize"),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -154,11 +168,15 @@ fn main() {
|
|||||||
ctx.get_viewport_id()
|
ctx.get_viewport_id()
|
||||||
));
|
));
|
||||||
|
|
||||||
if ui.button("Drag").is_pointer_button_down_on() {
|
if ctx.get_viewport_id() != ctx.get_parent_viewport_id() {
|
||||||
ctx.viewport_command(
|
ctx.viewport_command(
|
||||||
ctx.get_viewport_id(),
|
ctx.get_viewport_id(),
|
||||||
egui::window::ViewportCommand::Drag,
|
egui::window::ViewportCommand::Drag,
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
ctx.memory_mut(|mem| {
|
||||||
|
mem.set_dragged_id(egui::Id::new("Test3").with("frame_resize"))
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user