From 9a947e55479e1b9259e219a14c8dc3e01b1b85be Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 27 Sep 2023 16:40:26 +0200 Subject: [PATCH] Final image API doc tweaks --- crates/eframe/src/native/run.rs | 6 ++---- crates/egui/src/lib.rs | 3 ++- crates/egui/src/ui.rs | 3 ++- crates/egui_extras/Cargo.toml | 3 ++- crates/egui_extras/README.md | 2 +- crates/egui_extras/src/loaders.rs | 2 +- examples/images/src/main.rs | 3 +-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/eframe/src/native/run.rs b/crates/eframe/src/native/run.rs index ff6aff70..cb85a303 100644 --- a/crates/eframe/src/native/run.rs +++ b/crates/eframe/src/native/run.rs @@ -160,13 +160,11 @@ fn run_and_return( // Platform-dependent event handlers to workaround a winit bug // See: https://github.com/rust-windowing/winit/issues/987 // See: https://github.com/rust-windowing/winit/issues/1619 - #[cfg(target_os = "windows")] - winit::event::Event::RedrawEventsCleared => { + winit::event::Event::RedrawEventsCleared if cfg!(target_os = "windows") => { next_repaint_time = extremely_far_future(); winit_app.run_ui_and_paint() } - #[cfg(not(target_os = "windows"))] - winit::event::Event::RedrawRequested(_) => { + winit::event::Event::RedrawRequested(_) if !cfg!(target_os = "windows") => { next_repaint_time = extremely_far_future(); winit_app.run_ui_and_paint() } diff --git a/crates/egui/src/lib.rs b/crates/egui/src/lib.rs index ea9e7fdc..1cd7273e 100644 --- a/crates/egui/src/lib.rs +++ b/crates/egui/src/lib.rs @@ -448,7 +448,8 @@ pub fn warn_if_debug_build(ui: &mut crate::Ui) { /// ui.image(egui::include_image!("../assets/ferris.png")); /// ui.add( /// egui::Image::new(egui::include_image!("../assets/ferris.png")) -/// .rounding(egui::Rounding::same(6.0)) +/// .max_width(200.0) +/// .rounding(10.0), /// ); /// /// let image_source: egui::ImageSource = egui::include_image!("../assets/ferris.png"); diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index b2a828c9..2b3b8ff5 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -1560,7 +1560,8 @@ impl Ui { /// ui.image(egui::include_image!("../assets/ferris.png")); /// ui.add( /// egui::Image::new(egui::include_image!("../assets/ferris.png")) - /// .rounding(egui::Rounding::same(6.0)) + /// .max_width(200.0) + /// .rounding(10.0), /// ); /// # }); /// ``` diff --git a/crates/egui_extras/Cargo.toml b/crates/egui_extras/Cargo.toml index 98785306..d2673885 100644 --- a/crates/egui_extras/Cargo.toml +++ b/crates/egui_extras/Cargo.toml @@ -42,7 +42,8 @@ http = ["dep:ehttp"] ## ## You also need to ALSO opt-in to the image formats you want to support, like so: ## ```toml -## image = { version = "0.24", features = ["jpeg", "png"] } +## image = { version = "0.24", features = ["jpeg", "png"] } # Add the types you want support for + ## ``` image = ["dep:image"] diff --git a/crates/egui_extras/README.md b/crates/egui_extras/README.md index e46176c9..0ccb1de2 100644 --- a/crates/egui_extras/README.md +++ b/crates/egui_extras/README.md @@ -13,7 +13,7 @@ One thing `egui_extras` is commonly used for is to install image loaders for `eg ```toml egui_extras = { version = "*", features = ["all_loaders"] } -image = { version = "0.24", features = ["jpeg", "png"] } +image = { version = "0.24", features = ["jpeg", "png"] } # Add the types you want support for ``` ```rs diff --git a/crates/egui_extras/src/loaders.rs b/crates/egui_extras/src/loaders.rs index 0342fcab..cc775a2c 100644 --- a/crates/egui_extras/src/loaders.rs +++ b/crates/egui_extras/src/loaders.rs @@ -20,7 +20,7 @@ /// /// ```toml,ignore /// egui_extras = { version = "*", features = ["all_loaders"] } -/// image = { version = "0.24", features = ["jpeg", "png"] } +/// image = { version = "0.24", features = ["jpeg", "png"] } # Add the types you want support for /// ``` /// /// ⚠ You have to configure both the supported loaders in `egui_extras` _and_ the supported image formats diff --git a/examples/images/src/main.rs b/examples/images/src/main.rs index 5c1c6a4e..d942a21c 100644 --- a/examples/images/src/main.rs +++ b/examples/images/src/main.rs @@ -29,8 +29,7 @@ impl eframe::App for MyApp { ui.image(egui::include_image!("ferris.svg")); ui.add( - egui::Image::new("https://picsum.photos/seed/1.759706314/1024") - .rounding(egui::Rounding::same(10.0)), + egui::Image::new("https://picsum.photos/seed/1.759706314/1024").rounding(10.0), ); }); });