Browse Source

Final image API doc tweaks

pull/3421/head
Emil Ernerfeldt 1 year ago
parent
commit
9a947e5547
  1. 6
      crates/eframe/src/native/run.rs
  2. 3
      crates/egui/src/lib.rs
  3. 3
      crates/egui/src/ui.rs
  4. 3
      crates/egui_extras/Cargo.toml
  5. 2
      crates/egui_extras/README.md
  6. 2
      crates/egui_extras/src/loaders.rs
  7. 3
      examples/images/src/main.rs

6
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()
}

3
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");

3
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),
/// );
/// # });
/// ```

3
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"]

2
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

2
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

3
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),
);
});
});

Loading…
Cancel
Save