mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 15:13:12 -04:00
Now we use egui::ColorImage insted of (u32, u32, Vec<u8>)
This commit is contained in:
@@ -99,11 +99,12 @@ pub fn window_builder<E>(
|
||||
.with_maximized(*maximized)
|
||||
.with_resizable(*resizable)
|
||||
.with_transparent(*transparent)
|
||||
.with_window_icon(
|
||||
icon_data
|
||||
.clone()
|
||||
.map(|d| Arc::new((d.width, d.height, d.rgba))),
|
||||
)
|
||||
.with_window_icon(icon_data.clone().map(|d| {
|
||||
Arc::new(egui::ColorImage::from_rgba_premultiplied(
|
||||
[d.width as usize, d.height as usize],
|
||||
&d.rgba,
|
||||
))
|
||||
}))
|
||||
.with_active(*active)
|
||||
// Keep hidden until we've painted something. See https://github.com/emilk/egui/pull/2279
|
||||
// We must also keep the window hidden until AccessKit is initialized.
|
||||
|
||||
@@ -1050,9 +1050,13 @@ pub fn process_viewport_commands(
|
||||
_ => WindowLevel::Normal,
|
||||
}),
|
||||
ViewportCommand::WindowIcon(icon) => {
|
||||
win.set_window_icon(icon.map(|(bytes, width, height)| {
|
||||
winit::window::Icon::from_rgba(bytes, width, height)
|
||||
.expect("Invalid ICON data!")
|
||||
win.set_window_icon(icon.map(|icon| {
|
||||
winit::window::Icon::from_rgba(
|
||||
icon.as_raw().to_owned(),
|
||||
icon.width() as u32,
|
||||
icon.height() as u32,
|
||||
)
|
||||
.expect("Invalid ICON data!")
|
||||
}));
|
||||
}
|
||||
ViewportCommand::IMEPosition(pos) => {
|
||||
@@ -1171,8 +1175,12 @@ pub fn create_winit_window_builder(builder: &ViewportBuilder) -> winit::window::
|
||||
|
||||
if let Some(Some(icon)) = builder.icon.clone() {
|
||||
window_builder = window_builder.with_window_icon(Some(
|
||||
winit::window::Icon::from_rgba(icon.2.clone(), icon.0, icon.1)
|
||||
.expect("Invalid Icon Data!"),
|
||||
winit::window::Icon::from_rgba(
|
||||
icon.as_raw().to_owned(),
|
||||
icon.width() as u32,
|
||||
icon.height() as u32,
|
||||
)
|
||||
.expect("Invalid Icon Data!"),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1291,7 +1299,7 @@ pub fn changes_between_builders(
|
||||
|
||||
if !eq {
|
||||
commands.push(ViewportCommand::WindowIcon(
|
||||
icon.as_ref().map(|i| (i.2.clone(), i.0, i.1)),
|
||||
icon.as_ref().map(|i| i.as_ref().clone()),
|
||||
));
|
||||
last.icon = Some(icon);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::{fmt::Display, sync::Arc};
|
||||
|
||||
use epaint::{Pos2, Vec2};
|
||||
use epaint::{ColorImage, Pos2, Vec2};
|
||||
|
||||
use crate::{Context, Id};
|
||||
|
||||
@@ -70,7 +70,7 @@ pub struct ViewportBuilder {
|
||||
pub resizable: Option<bool>,
|
||||
pub transparent: Option<bool>,
|
||||
pub decorations: Option<bool>,
|
||||
pub icon: Option<Option<Arc<(u32, u32, Vec<u8>)>>>,
|
||||
pub icon: Option<Option<Arc<ColorImage>>>,
|
||||
pub active: Option<bool>,
|
||||
pub visible: Option<bool>,
|
||||
pub title_hidden: Option<bool>,
|
||||
@@ -184,7 +184,7 @@ impl ViewportBuilder {
|
||||
}
|
||||
|
||||
/// The icon needs to be wrapped in Arc because will be copied every frame
|
||||
pub fn with_window_icon(mut self, icon: Option<Arc<(u32, u32, Vec<u8>)>>) -> Self {
|
||||
pub fn with_window_icon(mut self, icon: Option<Arc<ColorImage>>) -> Self {
|
||||
self.icon = Some(icon);
|
||||
self
|
||||
}
|
||||
@@ -306,7 +306,7 @@ pub enum ViewportCommand {
|
||||
|
||||
/// 0 = Normal, 1 = AlwaysOnBottom, 2 = AlwaysOnTop
|
||||
WindowLevel(u8),
|
||||
WindowIcon(Option<(Vec<u8>, u32, u32)>),
|
||||
WindowIcon(Option<ColorImage>),
|
||||
IMEPosition(Pos2),
|
||||
IMEAllowed(bool),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user