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

Add Frame::set_window_title() #828

Merged
merged 2 commits into from
Oct 22, 2021
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
1 change: 1 addition & 0 deletions eframe/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions egui-winit/src/epi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub fn handle_app_output(
let epi::backend::AppOutput {
quit: _,
window_size,
window_title,
decorated,
drag_window,
} = app_output;
Expand All @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion egui_glium/src/epi_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion egui_glow/src/epi_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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 @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion epi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand All @@ -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>,

Expand Down