mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -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_maximized(*maximized)
|
||||||
.with_resizable(*resizable)
|
.with_resizable(*resizable)
|
||||||
.with_transparent(*transparent)
|
.with_transparent(*transparent)
|
||||||
.with_window_icon(
|
.with_window_icon(icon_data.clone().map(|d| {
|
||||||
icon_data
|
Arc::new(egui::ColorImage::from_rgba_premultiplied(
|
||||||
.clone()
|
[d.width as usize, d.height as usize],
|
||||||
.map(|d| Arc::new((d.width, d.height, d.rgba))),
|
&d.rgba,
|
||||||
)
|
))
|
||||||
|
}))
|
||||||
.with_active(*active)
|
.with_active(*active)
|
||||||
// Keep hidden until we've painted something. See https://github.com/emilk/egui/pull/2279
|
// 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.
|
// We must also keep the window hidden until AccessKit is initialized.
|
||||||
|
|||||||
@@ -1050,9 +1050,13 @@ pub fn process_viewport_commands(
|
|||||||
_ => WindowLevel::Normal,
|
_ => WindowLevel::Normal,
|
||||||
}),
|
}),
|
||||||
ViewportCommand::WindowIcon(icon) => {
|
ViewportCommand::WindowIcon(icon) => {
|
||||||
win.set_window_icon(icon.map(|(bytes, width, height)| {
|
win.set_window_icon(icon.map(|icon| {
|
||||||
winit::window::Icon::from_rgba(bytes, width, height)
|
winit::window::Icon::from_rgba(
|
||||||
.expect("Invalid ICON data!")
|
icon.as_raw().to_owned(),
|
||||||
|
icon.width() as u32,
|
||||||
|
icon.height() as u32,
|
||||||
|
)
|
||||||
|
.expect("Invalid ICON data!")
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
ViewportCommand::IMEPosition(pos) => {
|
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() {
|
if let Some(Some(icon)) = builder.icon.clone() {
|
||||||
window_builder = window_builder.with_window_icon(Some(
|
window_builder = window_builder.with_window_icon(Some(
|
||||||
winit::window::Icon::from_rgba(icon.2.clone(), icon.0, icon.1)
|
winit::window::Icon::from_rgba(
|
||||||
.expect("Invalid Icon Data!"),
|
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 {
|
if !eq {
|
||||||
commands.push(ViewportCommand::WindowIcon(
|
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);
|
last.icon = Some(icon);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::{fmt::Display, sync::Arc};
|
use std::{fmt::Display, sync::Arc};
|
||||||
|
|
||||||
use epaint::{Pos2, Vec2};
|
use epaint::{ColorImage, Pos2, Vec2};
|
||||||
|
|
||||||
use crate::{Context, Id};
|
use crate::{Context, Id};
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ pub struct ViewportBuilder {
|
|||||||
pub resizable: Option<bool>,
|
pub resizable: Option<bool>,
|
||||||
pub transparent: Option<bool>,
|
pub transparent: Option<bool>,
|
||||||
pub decorations: 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 active: Option<bool>,
|
||||||
pub visible: Option<bool>,
|
pub visible: Option<bool>,
|
||||||
pub title_hidden: 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
|
/// 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.icon = Some(icon);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@@ -306,7 +306,7 @@ pub enum ViewportCommand {
|
|||||||
|
|
||||||
/// 0 = Normal, 1 = AlwaysOnBottom, 2 = AlwaysOnTop
|
/// 0 = Normal, 1 = AlwaysOnBottom, 2 = AlwaysOnTop
|
||||||
WindowLevel(u8),
|
WindowLevel(u8),
|
||||||
WindowIcon(Option<(Vec<u8>, u32, u32)>),
|
WindowIcon(Option<ColorImage>),
|
||||||
IMEPosition(Pos2),
|
IMEPosition(Pos2),
|
||||||
IMEAllowed(bool),
|
IMEAllowed(bool),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user