Browse Source

Add `Frame::set_window_title()` (#828)

* Add `Frame::set_window_title()`

* Changelog and fmt for `Frame::set_window_title()`

Co-authored-by: Caleb Smith <caleb@myrvmail.com>
pull/973/head
Caleb Smith 3 years ago
committed by GitHub
parent
commit
79d1ede496
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      eframe/CHANGELOG.md
  2. 5
      egui-winit/src/epi.rs
  3. 2
      egui_glium/src/epi_backend.rs
  4. 2
      egui_glow/src/epi_backend.rs
  5. 1
      egui_web/src/backend.rs
  6. 10
      epi/src/lib.rs

1
eframe/CHANGELOG.md

@ -5,6 +5,7 @@ NOTE: [`egui_web`](egui_web/CHANGELOG.md), [`egui-winit`](egui-winit/CHANGELOG.m
## Unreleased ## Unreleased
* `Frame` now provides `set_window_title` to set window title dynamically
* `Frame` now provides `set_decorations` to set whether to show window decorations. * `Frame` now provides `set_decorations` to set whether to show window decorations.
* Remove "http" feature (use https://github.com/emilk/ehttp instead!). * Remove "http" feature (use https://github.com/emilk/ehttp instead!).
* Increase native scroll speed. * Increase native scroll speed.

5
egui-winit/src/epi.rs

@ -59,6 +59,7 @@ pub fn handle_app_output(
let epi::backend::AppOutput { let epi::backend::AppOutput {
quit: _, quit: _,
window_size, window_size,
window_title,
decorated, decorated,
drag_window, drag_window,
} = app_output; } = 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 { if drag_window {
let _ = window.drag_window(); let _ = window.drag_window();
} }

2
egui_glium/src/epi_backend.rs

@ -166,7 +166,7 @@ pub fn run(mut app: Box<dyn epi::App>, native_options: &epi::NativeOptions) -> !
egui_winit::epi::handle_app_output( egui_winit::epi::handle_app_output(
display.gl_window().window(), display.gl_window().window(),
egui.ctx().pixels_per_point(), egui.ctx().pixels_per_point(),
app_output, app_output.clone(),
); );
*control_flow = if app_output.quit { *control_flow = if app_output.quit {

2
egui_glow/src/epi_backend.rs

@ -183,7 +183,7 @@ pub fn run(mut app: Box<dyn epi::App>, native_options: &epi::NativeOptions) -> !
egui_winit::epi::handle_app_output( egui_winit::epi::handle_app_output(
gl_window.window(), gl_window.window(),
egui.ctx().pixels_per_point(), egui.ctx().pixels_per_point(),
app_output, app_output.clone(),
); );
*control_flow = if app_output.quit { *control_flow = if app_output.quit {

1
egui_web/src/backend.rs

@ -260,6 +260,7 @@ impl AppRunner {
let epi::backend::AppOutput { let epi::backend::AppOutput {
quit: _, // Can't quit a web page quit: _, // Can't quit a web page
window_size: _, // Can't resize a web page window_size: _, // Can't resize a web page
window_title: _,
decorated: _, // Can't show decorations decorated: _, // Can't show decorations
drag_window: _, // Can't be dragged drag_window: _, // Can't be dragged
} = app_output; } = app_output;

10
epi/src/lib.rs

@ -279,6 +279,11 @@ impl<'a> Frame<'a> {
self.0.output.window_size = Some(size); 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). /// 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. /// If false it will be difficult to move and resize the app.
pub fn set_decorations(&mut self, decorated: bool) { pub fn set_decorations(&mut self, decorated: bool) {
@ -439,7 +444,7 @@ pub mod backend {
} }
/// Action that can be taken by the user app. /// Action that can be taken by the user app.
#[derive(Clone, Copy, Debug, Default, PartialEq)] #[derive(Clone, Debug, Default, PartialEq)]
pub struct AppOutput { pub struct AppOutput {
/// Set to `true` to stop the app. /// Set to `true` to stop the app.
/// This does nothing for web apps. /// 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. /// Set to some size to resize the outer window (e.g. glium window) to this size.
pub window_size: Option<egui::Vec2>, pub window_size: Option<egui::Vec2>,
/// Set to some string to rename the outer window (e.g. glium window) to this title.
pub window_title: Option<String>,
/// Set to some bool to change window decorations /// Set to some bool to change window decorations
pub decorated: Option<bool>, pub decorated: Option<bool>,

Loading…
Cancel
Save