diff --git a/README.md b/README.md index 0bcff697..c1d25f91 100644 --- a/README.md +++ b/README.md @@ -143,14 +143,7 @@ Light Theme: ## Dependencies -`egui` has a minimal set of default dependencies: - -* [`ab_glyph`](https://crates.io/crates/ab_glyph) -* [`ahash`](https://crates.io/crates/ahash) -* [`bitflags`](https://crates.io/crates/bitflags) -* [`nohash-hasher`](https://crates.io/crates/nohash-hasher) -* [`parking_lot`](https://crates.io/crates/parking_lot) - +`egui` has a minimal set of default dependencies. Heavier dependencies are kept out of `egui`, even as opt-in. All code in `egui` is Wasm-friendly (even outside a browser). diff --git a/crates/eframe/Cargo.toml b/crates/eframe/Cargo.toml index b37a1989..7fd3b9e3 100644 --- a/crates/eframe/Cargo.toml +++ b/crates/eframe/Cargo.toml @@ -124,10 +124,7 @@ x11 = [ __screenshot = [] [dependencies] -egui = { workspace = true, default-features = false, features = [ - "bytemuck", - "log", -] } +egui = { workspace = true, default-features = false, features = ["bytemuck"] } ahash.workspace = true document-features.workspace = true diff --git a/crates/egui-winit/Cargo.toml b/crates/egui-winit/Cargo.toml index f2932ab5..3f4891f9 100644 --- a/crates/egui-winit/Cargo.toml +++ b/crates/egui-winit/Cargo.toml @@ -55,7 +55,7 @@ wayland = ["winit/wayland", "bytemuck"] x11 = ["winit/x11", "bytemuck"] [dependencies] -egui = { workspace = true, default-features = false, features = ["log"] } +egui = { workspace = true, default-features = false } log.workspace = true profiling.workspace = true diff --git a/crates/egui/Cargo.toml b/crates/egui/Cargo.toml index 32951c05..c82ae561 100644 --- a/crates/egui/Cargo.toml +++ b/crates/egui/Cargo.toml @@ -48,9 +48,6 @@ color-hex = ["epaint/color-hex"] ## If you plan on specifying your own fonts you may disable this feature. default_fonts = ["epaint/default_fonts"] -## Turn on the `log` feature, that makes egui log some errors using the [`log`](https://docs.rs/log) crate. -log = ["dep:log", "epaint/log"] - ## [`mint`](https://docs.rs/mint) enables interoperability with other math libraries such as [`glam`](https://docs.rs/glam) and [`nalgebra`](https://docs.rs/nalgebra). mint = ["epaint/mint"] @@ -80,6 +77,7 @@ epaint = { workspace = true, default-features = false } ahash.workspace = true bitflags.workspace = true +log.workspace = true nohash-hasher.workspace = true profiling.workspace = true smallvec.workspace = true @@ -93,6 +91,5 @@ backtrace = { workspace = true, optional = true } ## Enable this when generating docs. document-features = { workspace = true, optional = true } -log = { workspace = true, optional = true } ron = { workspace = true, optional = true } serde = { workspace = true, optional = true, features = ["derive", "rc"] } diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index b496612e..b037ce7d 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -535,7 +535,7 @@ impl ContextImpl { // New font definition loaded, so we need to reload all fonts. self.fonts = None; self.font_definitions = font_definitions; - #[cfg(feature = "log")] + log::trace!("Loading new font definitions"); } @@ -559,7 +559,6 @@ impl ContextImpl { .insert(font.name, Arc::new(font.data)); } - #[cfg(feature = "log")] log::trace!("Adding new fonts"); } @@ -568,7 +567,6 @@ impl ContextImpl { let mut is_new = false; let fonts = self.fonts.get_or_insert_with(|| { - #[cfg(feature = "log")] log::trace!("Creating new Fonts"); is_new = true; @@ -806,7 +804,6 @@ impl Context { } if max_passes <= output.platform_output.num_completed_passes { - #[cfg(feature = "log")] log::debug!( "Ignoring call request_discard, because max_passes={max_passes}. Requested from {:?}", output.platform_output.request_discard_reasons @@ -1819,7 +1816,6 @@ impl Context { let cause = RepaintCause::new_reason(reason); self.output_mut(|o| o.request_discard_reasons.push(cause)); - #[cfg(feature = "log")] log::trace!( "request_discard: {}", if self.will_discard() { @@ -2525,7 +2521,6 @@ impl ContextImpl { let parent = *self.viewport_parents.entry(id).or_default(); if !all_viewport_ids.contains(&parent) { - #[cfg(feature = "log")] log::debug!( "Removing viewport {:?} ({:?}): the parent is gone", id, @@ -2538,7 +2533,6 @@ impl ContextImpl { let is_our_child = parent == ended_viewport_id && id != ViewportId::ROOT; if is_our_child { if !viewport.used { - #[cfg(feature = "log")] log::debug!( "Removing viewport {:?} ({:?}): it was never used this pass", id, @@ -2637,7 +2631,6 @@ impl Context { let texture_atlas = if let Some(fonts) = ctx.fonts.as_ref() { fonts.texture_atlas() } else { - #[cfg(feature = "log")] log::warn!("No font size matching {pixels_per_point} pixels per point found."); ctx.fonts .iter() diff --git a/crates/egui/src/layers.rs b/crates/egui/src/layers.rs index 4aadff87..96ce4648 100644 --- a/crates/egui/src/layers.rs +++ b/crates/egui/src/layers.rs @@ -154,7 +154,6 @@ impl PaintList { #[inline(always)] pub fn set(&mut self, idx: ShapeIdx, clip_rect: Rect, shape: Shape) { if self.0.len() <= idx.0 { - #[cfg(feature = "log")] log::warn!("Index {} is out of bounds for PaintList", idx.0); return; } diff --git a/crates/egui/src/load/bytes_loader.rs b/crates/egui/src/load/bytes_loader.rs index 9f0c6035..6547a1e1 100644 --- a/crates/egui/src/load/bytes_loader.rs +++ b/crates/egui/src/load/bytes_loader.rs @@ -19,7 +19,6 @@ impl DefaultBytesLoader { .or_insert_with_key(|_uri| { let bytes: Bytes = bytes.into(); - #[cfg(feature = "log")] log::trace!("loaded {} bytes for uri {_uri:?}", bytes.len()); bytes @@ -53,14 +52,12 @@ impl BytesLoader for DefaultBytesLoader { } fn forget(&self, uri: &str) { - #[cfg(feature = "log")] log::trace!("forget {uri:?}"); self.cache.lock().remove(uri); } fn forget_all(&self) { - #[cfg(feature = "log")] log::trace!("forget all"); self.cache.lock().clear(); diff --git a/crates/egui/src/load/texture_loader.rs b/crates/egui/src/load/texture_loader.rs index 39d8ff94..e75b0507 100644 --- a/crates/egui/src/load/texture_loader.rs +++ b/crates/egui/src/load/texture_loader.rs @@ -102,14 +102,12 @@ impl TextureLoader for DefaultTextureLoader { } fn forget(&self, uri: &str) { - #[cfg(feature = "log")] log::trace!("forget {uri:?}"); self.cache.lock().retain(|key, _value| key.uri != uri); } fn forget_all(&self) { - #[cfg(feature = "log")] log::trace!("forget all"); self.cache.lock().clear(); diff --git a/crates/egui/src/os.rs b/crates/egui/src/os.rs index a9b4a874..bc76ff0d 100644 --- a/crates/egui/src/os.rs +++ b/crates/egui/src/os.rs @@ -68,7 +68,6 @@ impl OperatingSystem { { Self::Nix } else { - #[cfg(feature = "log")] log::warn!( "egui: Failed to guess operating system from User-Agent {:?}. Please file an issue at https://github.com/emilk/egui/issues", user_agent diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index 553be6f1..a08148a8 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -1248,7 +1248,6 @@ impl Ui { if let Some(tag) = tag { tag.set_close(); } else { - #[cfg(feature = "log")] log::warn!("Called ui.close() on a Ui that has no closable parent."); } } @@ -1277,7 +1276,6 @@ impl Ui { if let Some(tag) = tag { tag.set_close(); } else { - #[cfg(feature = "log")] log::warn!("Called ui.close_kind({ui_kind:?}) on ui with no such closable parent."); } } diff --git a/crates/egui/src/util/id_type_map.rs b/crates/egui/src/util/id_type_map.rs index 366ad519..395d1b6c 100644 --- a/crates/egui/src/util/id_type_map.rs +++ b/crates/egui/src/util/id_type_map.rs @@ -291,7 +291,6 @@ fn from_ron_str(ron: &str) -> Option { match ron::from_str::(ron) { Ok(value) => Some(value), Err(_err) => { - #[cfg(feature = "log")] log::warn!( "egui: Failed to deserialize {} from memory: {}, ron error: {:?}", std::any::type_name::(), diff --git a/crates/egui_demo_app/Cargo.toml b/crates/egui_demo_app/Cargo.toml index ff441af8..97e6806f 100644 --- a/crates/egui_demo_app/Cargo.toml +++ b/crates/egui_demo_app/Cargo.toml @@ -53,7 +53,7 @@ chrono = { version = "0.4", default-features = false, features = [ eframe = { workspace = true, default-features = false, features = [ "web_screen_reader", ] } -egui = { workspace = true, features = ["callstack", "default", "log"] } +egui = { workspace = true, features = ["callstack", "default"] } egui_demo_lib = { workspace = true, features = ["default", "chrono"] } egui_extras = { workspace = true, features = ["default", "image"] } image = { workspace = true, default-features = false, features = [ @@ -70,7 +70,11 @@ puffin = { workspace = true, optional = true } puffin_http = { workspace = true, optional = true } # Enable both WebGL & WebGPU when targeting the web (these features have no effect when not targeting wasm32) # Also enable the default features so we have a supported backend for every platform. -wgpu = { workspace = true, features = ["default", "webgpu", "webgl"], optional = true } +wgpu = { workspace = true, features = [ + "default", + "webgpu", + "webgl", +], optional = true } # feature "http": diff --git a/crates/epaint/Cargo.toml b/crates/epaint/Cargo.toml index 3cbb4f47..49806be8 100644 --- a/crates/epaint/Cargo.toml +++ b/crates/epaint/Cargo.toml @@ -44,9 +44,6 @@ color-hex = ["ecolor/color-hex"] ## If you plan on specifying your own fonts you may disable this feature. default_fonts = ["epaint_default_fonts"] -## Turn on the `log` feature, that makes egui log some errors using the [`log`](https://docs.rs/log) crate. -log = ["dep:log"] - ## [`mint`](https://docs.rs/mint) enables interoperability with other math libraries such as [`glam`](https://docs.rs/glam) and [`nalgebra`](https://docs.rs/nalgebra). mint = ["emath/mint"] @@ -71,6 +68,7 @@ ecolor.workspace = true ab_glyph = "0.2.11" ahash.workspace = true +log.workspace = true nohash-hasher.workspace = true parking_lot.workspace = true # Using parking_lot over std::sync::Mutex gives 50% speedups in some real-world scenarios. profiling = { workspace = true} @@ -81,7 +79,6 @@ bytemuck = { workspace = true, optional = true, features = ["derive"] } ## Enable this when generating docs. document-features = { workspace = true, optional = true } -log = { workspace = true, optional = true } rayon = { version = "1.7", optional = true } ## Allow serialization using [`serde`](https://docs.rs/serde) . diff --git a/crates/epaint/src/tessellator.rs b/crates/epaint/src/tessellator.rs index 4670d0b2..0c4da74d 100644 --- a/crates/epaint/src/tessellator.rs +++ b/crates/epaint/src/tessellator.rs @@ -2000,12 +2000,10 @@ impl Tessellator { } if galley.pixels_per_point != self.pixels_per_point { - let warn = "epaint: WARNING: pixels_per_point (dpi scale) have changed between text layout and tessellation. \ - You must recreate your text shapes if pixels_per_point changes."; - #[cfg(feature = "log")] - log::warn!("{warn}"); - #[cfg(not(feature = "log"))] - println!("{warn}"); + log::warn!( + "epaint: WARNING: pixels_per_point (dpi scale) have changed between text layout and tessellation. \ + You must recreate your text shapes if pixels_per_point changes." + ); } out.vertices.reserve(galley.num_vertices); diff --git a/crates/epaint/src/text/fonts.rs b/crates/epaint/src/text/fonts.rs index 3efcbe8e..7f7be2ff 100644 --- a/crates/epaint/src/text/fonts.rs +++ b/crates/epaint/src/text/fonts.rs @@ -463,7 +463,6 @@ impl CachedFamily { .glyph_info_no_cache_or_fallback(PRIMARY_REPLACEMENT_CHAR, fonts_by_id) .or_else(|| slf.glyph_info_no_cache_or_fallback(FALLBACK_REPLACEMENT_CHAR, fonts_by_id)) .unwrap_or_else(|| { - #[cfg(feature = "log")] log::warn!( "Failed to find replacement characters {PRIMARY_REPLACEMENT_CHAR:?} or {FALLBACK_REPLACEMENT_CHAR:?}. Will use empty glyph." ); diff --git a/crates/epaint/src/texture_atlas.rs b/crates/epaint/src/texture_atlas.rs index 36dd1b48..6488d907 100644 --- a/crates/epaint/src/texture_atlas.rs +++ b/crates/epaint/src/texture_atlas.rs @@ -238,7 +238,6 @@ impl TextureAtlas { if required_height > self.max_height() { // This is a bad place to be - we need to start reusing space :/ - #[cfg(feature = "log")] log::warn!("epaint texture atlas overflowed!"); self.cursor = (0, self.image.height() / 3); // Restart a bit down - the top of the atlas has too many important things in it