diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index f2252a31e..d3f5cd14e 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -29,4 +29,4 @@ jobs: with: mode: minimum count: 1 - labels: "CI, dependencies, docs and examples, ecolor, eframe, egui_extras, egui_glow, egui_plot, egui-wgpu, egui-winit, egui, epaint, typo" + labels: "CI, dependencies, docs and examples, ecolor, eframe, egui_extras, egui_glow, egui_plot, egui-wgpu, egui-winit, egui, epaint, exclude from changelog, typo" diff --git a/crates/eframe/README.md b/crates/eframe/README.md index 2356af0e0..15cdf72d3 100644 --- a/crates/eframe/README.md +++ b/crates/eframe/README.md @@ -28,6 +28,7 @@ You need to either use `edition = "2021"`, or set `resolver = "2"` in the `[work You can opt-in to the using [`egui_wgpu`](https://github.com/emilk/egui/tree/master/crates/egui_wgpu) for rendering by enabling the `wgpu` feature and setting `NativeOptions::renderer` to `Renderer::Wgpu`. +To get copy-paste working on web, you need to compile with `export RUSTFLAGS=--cfg=web_sys_unstable_apis`. ## Alternatives `eframe` is not the only way to write an app using `egui`! You can also try [`egui-miniquad`](https://github.com/not-fl3/egui-miniquad), [`bevy_egui`](https://github.com/mvlabat/bevy_egui), [`egui_sdl2_gl`](https://github.com/ArjunNair/egui_sdl2_gl), and others. diff --git a/crates/eframe/src/epi/icon_data.rs b/crates/eframe/src/epi/icon_data.rs index c62b6a689..078b57714 100644 --- a/crates/eframe/src/epi/icon_data.rs +++ b/crates/eframe/src/epi/icon_data.rs @@ -14,6 +14,15 @@ pub struct IconData { pub height: u32, } +impl std::fmt::Debug for IconData { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("IconData") + .field("width", &self.width) + .field("height", &self.height) + .finish_non_exhaustive() + } +} + impl IconData { /// Convert into [`image::RgbaImage`] /// diff --git a/crates/eframe/src/epi/mod.rs b/crates/eframe/src/epi/mod.rs index ed2f07654..db0d4686d 100644 --- a/crates/eframe/src/epi/mod.rs +++ b/crates/eframe/src/epi/mod.rs @@ -308,6 +308,7 @@ pub struct NativeOptions { pub resizable: 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, diff --git a/crates/eframe/src/native/file_storage.rs b/crates/eframe/src/native/file_storage.rs index 6b059e817..4c44430f8 100644 --- a/crates/eframe/src/native/file_storage.rs +++ b/crates/eframe/src/native/file_storage.rs @@ -130,6 +130,7 @@ fn save_to_disk(file_path: &PathBuf, kv: &HashMap) { let mut writer = std::io::BufWriter::new(file); let config = Default::default(); + crate::profile_scope!("ron::serialize"); if let Err(err) = ron::ser::to_writer_pretty(&mut writer, &kv, config) .and_then(|_| writer.flush().map_err(|err| err.into())) { diff --git a/crates/egui-wgpu/src/lib.rs b/crates/egui-wgpu/src/lib.rs index 8d9d5912c..a46e185e8 100644 --- a/crates/egui-wgpu/src/lib.rs +++ b/crates/egui-wgpu/src/lib.rs @@ -123,6 +123,16 @@ pub struct WgpuConfiguration { pub on_surface_error: Arc SurfaceErrorAction>, } +impl std::fmt::Debug for WgpuConfiguration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("WgpuConfiguration") + .field("supported_backends", &self.supported_backends) + .field("present_mode", &self.present_mode) + .field("power_preference", &self.power_preference) + .finish_non_exhaustive() + } +} + impl Default for WgpuConfiguration { fn default() -> Self { Self { diff --git a/crates/egui/src/load.rs b/crates/egui/src/load.rs index 6f277cb5e..a70986d4c 100644 --- a/crates/egui/src/load.rs +++ b/crates/egui/src/load.rs @@ -55,17 +55,20 @@ mod bytes_loader; mod texture_loader; -use crate::Context; +use std::borrow::Cow; +use std::fmt::Debug; +use std::ops::Deref; +use std::{error::Error as StdError, fmt::Display, sync::Arc}; + use ahash::HashMap; + use epaint::mutex::Mutex; use epaint::util::FloatOrd; use epaint::util::OrderedFloat; use epaint::TextureHandle; use epaint::{textures::TextureOptions, ColorImage, TextureId, Vec2}; -use std::borrow::Cow; -use std::fmt::Debug; -use std::ops::Deref; -use std::{error::Error as StdError, fmt::Display, sync::Arc}; + +use crate::Context; pub use self::bytes_loader::DefaultBytesLoader; pub use self::texture_loader::DefaultTextureLoader; diff --git a/crates/egui_demo_app/src/wrap_app.rs b/crates/egui_demo_app/src/wrap_app.rs index 2085b2fd3..e5f458874 100644 --- a/crates/egui_demo_app/src/wrap_app.rs +++ b/crates/egui_demo_app/src/wrap_app.rs @@ -165,6 +165,7 @@ pub struct WrapApp { impl WrapApp { pub fn new(cc: &eframe::CreationContext<'_>) -> Self { + // This gives us image support: egui_extras::install_image_loaders(&cc.egui_ctx); #[allow(unused_mut)] diff --git a/crates/epaint/src/shape.rs b/crates/epaint/src/shape.rs index 718da636b..cc4294f6c 100644 --- a/crates/epaint/src/shape.rs +++ b/crates/epaint/src/shape.rs @@ -498,6 +498,8 @@ pub struct RectShape { /// /// To display a texture, set [`Self::fill_texture_id`], /// and set this to `Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0))`. + /// + /// Use [`Rect::ZERO`] to turn off texturing. pub uv: Rect, } diff --git a/crates/epaint/src/text/font.rs b/crates/epaint/src/text/font.rs index 163697d5f..f33ff1cee 100644 --- a/crates/epaint/src/text/font.rs +++ b/crates/epaint/src/text/font.rs @@ -72,7 +72,7 @@ pub struct FontImpl { height_in_points: f32, // move each character by this much (hack) - y_offset: f32, + y_offset_in_points: f32, ascent: f32, pixels_per_point: f32, @@ -111,22 +111,23 @@ impl FontImpl { scale_in_points * tweak.y_offset_factor } + tweak.y_offset; - // center scaled glyphs properly - let y_offset_points = y_offset_points + (tweak.scale - 1.0) * 0.5 * (ascent + descent); + // Center scaled glyphs properly: + let height = ascent + descent; + let y_offset_points = y_offset_points - (1.0 - tweak.scale) * 0.5 * height; // Round to an even number of physical pixels to get even kerning. // See https://github.com/emilk/egui/issues/382 let scale_in_pixels = scale_in_pixels.round() as u32; // Round to closest pixel: - let y_offset = (y_offset_points * pixels_per_point).round() / pixels_per_point; + let y_offset_in_points = (y_offset_points * pixels_per_point).round() / pixels_per_point; Self { name, ab_glyph_font, scale_in_pixels, height_in_points: ascent - descent + line_gap, - y_offset, + y_offset_in_points, ascent: ascent + baseline_offset, pixels_per_point, glyph_info_cache: Default::default(), @@ -283,7 +284,8 @@ impl FontImpl { }); let offset_in_pixels = vec2(bb.min.x, bb.min.y); - let offset = offset_in_pixels / self.pixels_per_point + self.y_offset * Vec2::Y; + let offset = + offset_in_pixels / self.pixels_per_point + self.y_offset_in_points * Vec2::Y; UvRect { offset, size: vec2(glyph_width as f32, glyph_height as f32) / self.pixels_per_point,