Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added epi::Frame::set_window_pos #1505

Merged
merged 1 commit into from
Apr 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions egui-winit/src/epi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ pub fn handle_app_output(
window_title,
decorated,
drag_window,
window_pos,
} = app_output;

if let Some(decorated) = decorated {
Expand All @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions egui_web/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions epi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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>,
}
}