Skip to content

Commit

Permalink
Simplify Image::paint_at function
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Sep 14, 2023
1 parent 10fd9f6 commit b5745db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions crates/egui/src/widgets/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ impl<'a> Image<'a> {
/// Load the image from its [`Image::source`], returning the resulting [`SizedTexture`].
///
/// # Errors
///
/// May fail if they underlying [`Context::try_load_texture`] call fails.
pub fn load(&self, ui: &Ui) -> TextureLoadResult {
let size_hint = self.size.hint(ui.available_size());
Expand All @@ -279,9 +278,16 @@ impl<'a> Image<'a> {
.load(ui.ctx(), self.texture_options, size_hint)
}

/// Paint the image in the given rectangle.
#[inline]
pub fn paint_at(&self, ui: &mut Ui, rect: Rect, texture: &SizedTexture) {
paint_image_at(ui, rect, &self.image_options, texture);
pub fn paint_at(&self, ui: &mut Ui, rect: Rect) {
paint_texture_load_result(
ui,
&self.load(ui),
rect,
self.show_loading_spinner,
&self.image_options,
);
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/egui/src/widgets/spinner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl Spinner {
self
}

/// Paint the spinner in the given rectangle.
pub fn paint_at(&self, ui: &Ui, rect: Rect) {
if ui.is_rect_visible(rect) {
ui.ctx().request_repaint();
Expand Down

0 comments on commit b5745db

Please sign in to comment.