mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Polish image API (#3338)
* Imoprove docs for callback shapes * Improve docs for loader traits * Use snake_case for feature `all_loaders` * Make loaders publix * Slightly better error message on image load failure * Improve image loading error messages * Use `bytes://` schema for included bytes loader * Try user loaders first * Move `image_loading_spinners` to `Visuals` * Unify and simplify code * Make the main text of `Button` optional This largely makes ImageButton obsolete * Fix docstrings * Better docs * typos * Use the more explicit `egui_extras::install_image_loaders` * Simplify `Image::paint_at` function
This commit is contained in:
@@ -12,7 +12,7 @@ publish = false
|
||||
eframe = { path = "../../crates/eframe", features = [
|
||||
"__screenshot", # __screenshot is so we can dump a screenshot using EFRAME_SCREENSHOT_TO
|
||||
] }
|
||||
egui_extras = { path = "../../crates/egui_extras", features = ["all-loaders"] }
|
||||
egui_extras = { path = "../../crates/egui_extras", features = ["all_loaders"] }
|
||||
env_logger = "0.10"
|
||||
image = { version = "0.24", default-features = false, features = [
|
||||
"jpeg",
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::egui;
|
||||
use eframe::epaint::vec2;
|
||||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
||||
let options = eframe::NativeOptions {
|
||||
drag_and_drop_support: true,
|
||||
initial_window_size: Some(egui::vec2(600.0, 800.0)),
|
||||
..Default::default()
|
||||
};
|
||||
eframe::run_native(
|
||||
@@ -14,7 +13,7 @@ fn main() -> Result<(), eframe::Error> {
|
||||
options,
|
||||
Box::new(|cc| {
|
||||
// The following call is needed to load images when using `ui.image` and `egui::Image`:
|
||||
egui_extras::loaders::install(&cc.egui_ctx);
|
||||
egui_extras::install_image_loaders(&cc.egui_ctx);
|
||||
Box::<MyApp>::default()
|
||||
}),
|
||||
)
|
||||
@@ -27,10 +26,8 @@ impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
egui::ScrollArea::new([true, true]).show(ui, |ui| {
|
||||
ui.add(
|
||||
egui::Image::new(egui::include_image!("ferris.svg"))
|
||||
.fit_to_fraction(vec2(1.0, 0.5)),
|
||||
);
|
||||
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)),
|
||||
|
||||
Reference in New Issue
Block a user