mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -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:
@@ -445,6 +445,13 @@ impl Renderer {
|
||||
|
||||
needs_reset = true;
|
||||
|
||||
let info = PaintCallbackInfo {
|
||||
viewport: callback.rect,
|
||||
clip_rect: *clip_rect,
|
||||
pixels_per_point,
|
||||
screen_size_px: size_in_pixels,
|
||||
};
|
||||
|
||||
{
|
||||
// We're setting a default viewport for the render pass as a
|
||||
// courtesy for the user, so that they don't have to think about
|
||||
@@ -455,29 +462,19 @@ impl Renderer {
|
||||
// viewport during the paint callback, effectively overriding this
|
||||
// one.
|
||||
|
||||
let min = (callback.rect.min.to_vec2() * pixels_per_point).round();
|
||||
let max = (callback.rect.max.to_vec2() * pixels_per_point).round();
|
||||
let viewport_px = info.viewport_in_pixels();
|
||||
|
||||
render_pass.set_viewport(
|
||||
min.x,
|
||||
min.y,
|
||||
max.x - min.x,
|
||||
max.y - min.y,
|
||||
viewport_px.left_px,
|
||||
viewport_px.top_px,
|
||||
viewport_px.width_px,
|
||||
viewport_px.height_px,
|
||||
0.0,
|
||||
1.0,
|
||||
);
|
||||
}
|
||||
|
||||
cbfn.0.paint(
|
||||
PaintCallbackInfo {
|
||||
viewport: callback.rect,
|
||||
clip_rect: *clip_rect,
|
||||
pixels_per_point,
|
||||
screen_size_px: size_in_pixels,
|
||||
},
|
||||
render_pass,
|
||||
&self.callback_resources,
|
||||
);
|
||||
cbfn.0.paint(info, render_pass, &self.callback_resources);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user