Skip to content

Commit

Permalink
eframe: add always_on_top option (native)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed May 8, 2021
1 parent 7374ed9 commit a7a36bd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions eframe/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to the `eframe` crate.

## Unreleased
* Moved options out of `trait App` into new `NativeOptions`.
* Add option for `always_on_top`.


## 0.11.0 - 2021-04-05
Expand Down
5 changes: 3 additions & 2 deletions egui_glium/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ fn create_display(
event_loop: &glutin::event_loop::EventLoop<RequestRepaintEvent>,
) -> glium::Display {
let mut window_builder = glutin::window::WindowBuilder::new()
.with_always_on_top(native_options.always_on_top)
.with_decorations(native_options.decorated)
.with_resizable(native_options.resizable)
.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_drag_and_drop(window_builder, native_options.drag_and_drop_support);
Expand Down
25 changes: 15 additions & 10 deletions epi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,18 @@ pub trait App {
/// Options controlling the behavior of a native window
#[derive(Clone)]
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.
pub icon_data: Option<IconData>,

Expand All @@ -141,29 +153,22 @@ pub struct NativeOptions {
/// Should the app window be resizable?
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.
/// You control the transparency with [`App::clear_color()`].
/// You should avoid having a [`egui::CentralPanel`], or make sure its frame is also transparent.
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 {
fn default() -> Self {
Self {
always_on_top: false,
decorated: true,
drag_and_drop_support: true,
icon_data: None,
initial_window_size: None,
resizable: true,
decorated: true,
transparent: false,
drag_and_drop_support: true,
}
}
}
Expand Down

0 comments on commit a7a36bd

Please sign in to comment.