diff --git a/eframe/CHANGELOG.md b/eframe/CHANGELOG.md index e0b90d1d..0c1a9ede 100644 --- a/eframe/CHANGELOG.md +++ b/eframe/CHANGELOG.md @@ -7,6 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +* You can now set your own app icons. See https://github.com/emilk/egui/pull/193 + for example code. ## 0.9.0 - 2021-02-07 diff --git a/egui_glium/src/backend.rs b/egui_glium/src/backend.rs index a9732dcc..87432690 100644 --- a/egui_glium/src/backend.rs +++ b/egui_glium/src/backend.rs @@ -60,12 +60,14 @@ fn create_display( initial_size_points: Option, window_settings: Option, is_resizable: bool, + window_icon: Option, event_loop: &glutin::event_loop::EventLoop, ) -> glium::Display { let mut window_builder = glutin::window::WindowBuilder::new() .with_decorations(true) .with_resizable(is_resizable) .with_title(title) + .with_window_icon(window_icon) .with_transparent(false); if let Some(window_settings) = &window_settings { @@ -131,6 +133,11 @@ fn integration_info( } } +fn load_icon(icon_data: Option) -> Option { + let icon_data = icon_data?; + glutin::window::Icon::from_rgba(icon_data.rgba, icon_data.width, icon_data.height).ok() +} + /// Run an egui app pub fn run(mut app: Box) -> ! { let mut storage = create_storage(app.name()); @@ -141,11 +148,13 @@ pub fn run(mut app: Box) -> ! { let window_settings = deserialize_window_settings(&storage); let event_loop = glutin::event_loop::EventLoop::with_user_event(); + let icon = load_icon(app.icon_data()); let display = create_display( app.name(), app.initial_window_size(), window_settings, app.is_resizable(), + icon, &event_loop, ); diff --git a/epi/src/lib.rs b/epi/src/lib.rs index b14baf40..e39d092b 100644 --- a/epi/src/lib.rs +++ b/epi/src/lib.rs @@ -114,6 +114,23 @@ pub trait App { // NOTE: a bright gray makes the shadows of the windows look weird. egui::Color32::from_rgb(12, 12, 12).into() } + + /// The application icon, e.g. in the Windows task bar etc. + fn icon_data(&self) -> Option { + None + } +} + +/// Image data for the icon. +pub struct IconData { + /// RGBA pixels. + pub rgba: Vec, + + /// Image width. This should be a multiple of 4. + pub width: u32, + + /// Image height. This should be a multiple of 4. + pub height: u32, } /// Represents the surroundings of your app.