Skip to content

Commit

Permalink
Set a default icon for all eframe apps: a white e on black backgrou…
Browse files Browse the repository at this point in the history
…nd (emilk#2996)

As a user you can change this by setting `NativeOptions::icon_data`.
Set it to `None` to get the default icon assigned by the OS.
  • Loading branch information
emilk authored May 17, 2023
1 parent 856afc8 commit 7b76161
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
8 changes: 7 additions & 1 deletion crates/eframe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ readme = "README.md"
repository = "https://github.com/emilk/egui/tree/master/crates/eframe"
categories = ["gui", "game-development"]
keywords = ["egui", "gui", "gamedev"]
include = ["../LICENSE-APACHE", "../LICENSE-MIT", "**/*.rs", "Cargo.toml"]
include = [
"../LICENSE-APACHE",
"../LICENSE-MIT",
"**/*.rs",
"Cargo.toml",
"data/icon.png",
]

[package.metadata.docs.rs]
all-features = true
Expand Down
Binary file added crates/eframe/data/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions crates/eframe/src/epi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ pub struct NativeOptions {
/// [drag_and_drop]: https://docs.rs/winit/latest/x86_64-pc-windows-msvc/winit/platform/windows/trait.WindowBuilderExtWindows.html#tymethod.with_drag_and_drop
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 or the alt-tab menu.
///
/// This doesn't work on Mac and on Wayland.
/// See <https://docs.rs/winit/latest/winit/window/struct.Window.html#method.set_window_icon> for more.
/// The default icon is a white `e` on a black background (for "egui" or "eframe").
/// If you prefer the OS default, set this to `None`.
pub icon_data: Option<IconData>,

/// The initial (inner) position of the native window in points (logical pixels).
Expand Down Expand Up @@ -414,8 +414,12 @@ impl Default for NativeOptions {
#[cfg(target_os = "macos")]
fullsize_content: false,

// We set a default "egui" or "eframe" icon, which is usually more distinctive than the default OS icon.
icon_data: Some(
IconData::try_from_png_bytes(&include_bytes!("../../data/icon.png")[..]).unwrap(),
),

drag_and_drop_support: true,
icon_data: None,
initial_window_pos: None,
initial_window_size: None,
min_window_size: None,
Expand Down
5 changes: 0 additions & 5 deletions crates/egui_demo_app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ fn main() -> Result<(), eframe::Error> {

initial_window_size: Some([1280.0, 1024.0].into()),

icon_data: Some(
eframe::IconData::try_from_png_bytes(&include_bytes!("../../../media/icon.png")[..])
.unwrap(),
),

#[cfg(feature = "wgpu")]
renderer: eframe::Renderer::Wgpu,

Expand Down
Binary file removed media/icon.png
Binary file not shown.

0 comments on commit 7b76161

Please sign in to comment.