added epi::Frame::set_window_pos
(#1505)
this allows setting the position of window at runtime
This commit is contained in:
parent
2b861f86e8
commit
96335d5f45
3 changed files with 17 additions and 0 deletions
|
@ -96,6 +96,7 @@ pub fn handle_app_output(
|
|||
window_title,
|
||||
decorated,
|
||||
drag_window,
|
||||
window_pos,
|
||||
} = app_output;
|
||||
|
||||
if let Some(decorated) = decorated {
|
||||
|
@ -116,6 +117,13 @@ pub fn handle_app_output(
|
|||
window.set_title(&window_title);
|
||||
}
|
||||
|
||||
if let Some(window_pos) = window_pos {
|
||||
window.set_outer_position(winit::dpi::PhysicalPosition {
|
||||
x: window_pos.x as f64,
|
||||
y: window_pos.y as f64,
|
||||
});
|
||||
}
|
||||
|
||||
if drag_window {
|
||||
let _ = window.drag_window();
|
||||
}
|
||||
|
|
|
@ -268,6 +268,7 @@ impl AppRunner {
|
|||
window_title: _, // TODO: change title of window
|
||||
decorated: _, // Can't toggle decorations
|
||||
drag_window: _, // Can't be dragged
|
||||
window_pos: _, // Can't set position of a web page
|
||||
} = app_output;
|
||||
}
|
||||
|
||||
|
|
|
@ -323,6 +323,11 @@ impl Frame {
|
|||
self.output.decorated = Some(decorated);
|
||||
}
|
||||
|
||||
/// set the position of the outer window
|
||||
pub fn set_window_pos(&mut self, pos: egui::Pos2) {
|
||||
self.output.window_pos = Some(pos);
|
||||
}
|
||||
|
||||
/// When called, the native window will follow the
|
||||
/// movement of the cursor while the primary mouse button is down.
|
||||
///
|
||||
|
@ -503,5 +508,8 @@ pub mod backend {
|
|||
|
||||
/// Set to true to drag window while primary mouse button is down.
|
||||
pub drag_window: bool,
|
||||
|
||||
/// Set to some position to move the outer window (e.g. glium window) to this position
|
||||
pub window_pos: Option<egui::Pos2>,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue