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>
This commit is contained in:
parent
26c6cea117
commit
79d1ede496
|
@ -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.
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ pub fn run(mut app: Box<dyn epi::App>, 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 {
|
||||
|
|
|
@ -183,7 +183,7 @@ pub fn run(mut app: Box<dyn epi::App>, 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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<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
|
||||
pub decorated: Option<bool>,
|
||||
|
||||
|
|
Loading…
Reference in New Issue