eframe: add always_on_top option (native)
This commit is contained in:
parent
7374ed9d00
commit
a7a36bd313
3 changed files with 19 additions and 12 deletions
|
@ -4,6 +4,7 @@ All notable changes to the `eframe` crate.
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
* Moved options out of `trait App` into new `NativeOptions`.
|
* Moved options out of `trait App` into new `NativeOptions`.
|
||||||
|
* Add option for `always_on_top`.
|
||||||
|
|
||||||
|
|
||||||
## 0.11.0 - 2021-04-05
|
## 0.11.0 - 2021-04-05
|
||||||
|
|
|
@ -82,11 +82,12 @@ fn create_display(
|
||||||
event_loop: &glutin::event_loop::EventLoop<RequestRepaintEvent>,
|
event_loop: &glutin::event_loop::EventLoop<RequestRepaintEvent>,
|
||||||
) -> glium::Display {
|
) -> glium::Display {
|
||||||
let mut window_builder = glutin::window::WindowBuilder::new()
|
let mut window_builder = glutin::window::WindowBuilder::new()
|
||||||
|
.with_always_on_top(native_options.always_on_top)
|
||||||
.with_decorations(native_options.decorated)
|
.with_decorations(native_options.decorated)
|
||||||
.with_resizable(native_options.resizable)
|
.with_resizable(native_options.resizable)
|
||||||
.with_title(app.name())
|
.with_title(app.name())
|
||||||
.with_window_icon(window_icon)
|
.with_transparent(native_options.transparent)
|
||||||
.with_transparent(native_options.transparent);
|
.with_window_icon(window_icon);
|
||||||
|
|
||||||
window_builder =
|
window_builder =
|
||||||
window_builder_drag_and_drop(window_builder, native_options.drag_and_drop_support);
|
window_builder_drag_and_drop(window_builder, native_options.drag_and_drop_support);
|
||||||
|
|
|
@ -132,6 +132,18 @@ pub trait App {
|
||||||
/// Options controlling the behavior of a native window
|
/// Options controlling the behavior of a native window
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct NativeOptions {
|
pub struct NativeOptions {
|
||||||
|
/// Sets whether or not the window will always be on top of other windows.
|
||||||
|
pub always_on_top: bool,
|
||||||
|
|
||||||
|
/// On desktop: add window decorations (i.e. a frame around your app)?
|
||||||
|
/// If false it will be difficult to move and resize the app.
|
||||||
|
pub decorated: bool,
|
||||||
|
|
||||||
|
/// On Windows: enable drag and drop support.
|
||||||
|
/// Set to false to avoid issues with crates such as cpal which
|
||||||
|
/// uses that use multi-threaded COM API <https://github.com/rust-windowing/winit/pull/1524>
|
||||||
|
pub drag_and_drop_support: bool,
|
||||||
|
|
||||||
/// The application icon, e.g. in the Windows task bar etc.
|
/// The application icon, e.g. in the Windows task bar etc.
|
||||||
pub icon_data: Option<IconData>,
|
pub icon_data: Option<IconData>,
|
||||||
|
|
||||||
|
@ -141,29 +153,22 @@ pub struct NativeOptions {
|
||||||
/// Should the app window be resizable?
|
/// Should the app window be resizable?
|
||||||
pub resizable: bool,
|
pub resizable: bool,
|
||||||
|
|
||||||
/// On desktop: add window decorations (i.e. a frame around your app)?
|
|
||||||
/// If false it will be difficult to move and resize the app.
|
|
||||||
pub decorated: bool,
|
|
||||||
|
|
||||||
/// On desktop: make the window transparent.
|
/// On desktop: make the window transparent.
|
||||||
/// You control the transparency with [`App::clear_color()`].
|
/// You control the transparency with [`App::clear_color()`].
|
||||||
/// You should avoid having a [`egui::CentralPanel`], or make sure its frame is also transparent.
|
/// You should avoid having a [`egui::CentralPanel`], or make sure its frame is also transparent.
|
||||||
pub transparent: bool,
|
pub transparent: bool,
|
||||||
|
|
||||||
/// On Windows: enable drag and drop support.
|
|
||||||
/// Set to false to avoid issues with crates such as cpal which uses that use multi-threaded COM API <https://github.com/rust-windowing/winit/pull/1524>
|
|
||||||
pub drag_and_drop_support: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for NativeOptions {
|
impl Default for NativeOptions {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
always_on_top: false,
|
||||||
|
decorated: true,
|
||||||
|
drag_and_drop_support: true,
|
||||||
icon_data: None,
|
icon_data: None,
|
||||||
initial_window_size: None,
|
initial_window_size: None,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
decorated: true,
|
|
||||||
transparent: false,
|
transparent: false,
|
||||||
drag_and_drop_support: true,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue