diff --git a/eframe/CHANGELOG.md b/eframe/CHANGELOG.md index 6b9eea7d8..93b7aa7f5 100644 --- a/eframe/CHANGELOG.md +++ b/eframe/CHANGELOG.md @@ -5,6 +5,7 @@ NOTE: [`egui_web`](egui_web/CHANGELOG.md), [`egui-winit`](egui-winit/CHANGELOG.m ## Unreleased +* `Frame` now provides `set_window_title` to set window title dynamically * `Frame` now provides `set_decorations` to set whether to show window decorations. * Remove "http" feature (use https://github.com/emilk/ehttp instead!). * Increase native scroll speed. diff --git a/egui-winit/src/epi.rs b/egui-winit/src/epi.rs index 27511c2a6..bd8127b13 100644 --- a/egui-winit/src/epi.rs +++ b/egui-winit/src/epi.rs @@ -59,6 +59,7 @@ pub fn handle_app_output( let epi::backend::AppOutput { quit: _, window_size, + window_title, decorated, drag_window, } = app_output; @@ -77,6 +78,10 @@ pub fn handle_app_output( ); } + if let Some(window_title) = window_title { + window.set_title(&window_title); + } + if drag_window { let _ = window.drag_window(); } diff --git a/egui_glium/src/epi_backend.rs b/egui_glium/src/epi_backend.rs index e6c4ed3d0..e92d28700 100644 --- a/egui_glium/src/epi_backend.rs +++ b/egui_glium/src/epi_backend.rs @@ -166,7 +166,7 @@ pub fn run(mut app: Box, native_options: &epi::NativeOptions) -> ! egui_winit::epi::handle_app_output( display.gl_window().window(), egui.ctx().pixels_per_point(), - app_output, + app_output.clone(), ); *control_flow = if app_output.quit { diff --git a/egui_glow/src/epi_backend.rs b/egui_glow/src/epi_backend.rs index 90812b0bd..86c867618 100644 --- a/egui_glow/src/epi_backend.rs +++ b/egui_glow/src/epi_backend.rs @@ -183,7 +183,7 @@ pub fn run(mut app: Box, native_options: &epi::NativeOptions) -> ! egui_winit::epi::handle_app_output( gl_window.window(), egui.ctx().pixels_per_point(), - app_output, + app_output.clone(), ); *control_flow = if app_output.quit { diff --git a/egui_web/src/backend.rs b/egui_web/src/backend.rs index f310a123d..08996853f 100644 --- a/egui_web/src/backend.rs +++ b/egui_web/src/backend.rs @@ -260,6 +260,7 @@ impl AppRunner { let epi::backend::AppOutput { quit: _, // Can't quit a web page window_size: _, // Can't resize a web page + window_title: _, decorated: _, // Can't show decorations drag_window: _, // Can't be dragged } = app_output; diff --git a/epi/src/lib.rs b/epi/src/lib.rs index 6cfcb743a..d30312548 100644 --- a/epi/src/lib.rs +++ b/epi/src/lib.rs @@ -279,6 +279,11 @@ impl<'a> Frame<'a> { self.0.output.window_size = Some(size); } + /// Set the desired title of the window. + pub fn set_window_title(&mut self, title: &str) { + self.0.output.window_title = Some(title.to_owned()); + } + /// Set whether to show window decorations (i.e. a frame around you app). /// If false it will be difficult to move and resize the app. pub fn set_decorations(&mut self, decorated: bool) { @@ -439,7 +444,7 @@ pub mod backend { } /// Action that can be taken by the user app. - #[derive(Clone, Copy, Debug, Default, PartialEq)] + #[derive(Clone, Debug, Default, PartialEq)] pub struct AppOutput { /// Set to `true` to stop the app. /// This does nothing for web apps. @@ -448,6 +453,9 @@ pub mod backend { /// Set to some size to resize the outer window (e.g. glium window) to this size. pub window_size: Option, + /// Set to some string to rename the outer window (e.g. glium window) to this title. + pub window_title: Option, + /// Set to some bool to change window decorations pub decorated: Option,