From de0a03f20eefc571f7554a8fc3e659083c4d9437 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 15 Sep 2023 10:04:12 +0200 Subject: [PATCH] calculate -> calc --- crates/egui/src/widgets/button.rs | 4 ++-- crates/egui/src/widgets/image.rs | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/egui/src/widgets/button.rs b/crates/egui/src/widgets/button.rs index 30d658313a3..4c94cc9d4ac 100644 --- a/crates/egui/src/widgets/button.rs +++ b/crates/egui/src/widgets/button.rs @@ -187,7 +187,7 @@ impl Widget for Button<'_> { let image_size = if let Some(image) = &image { image - .load_and_calculate_size(ui, space_available_for_image) + .load_and_calc_size(ui, space_available_for_image) .unwrap_or(space_available_for_image) } else { Vec2::ZERO @@ -610,7 +610,7 @@ impl<'a> Widget for ImageButton<'a> { let original_image_size = tlr.as_ref().ok().and_then(|t| t.size()); let image_size = self .image - .calculate_size(available_size_for_image, original_image_size); + .calc_size(available_size_for_image, original_image_size); let padded_size = image_size + 2.0 * padding; let (rect, response) = ui.allocate_exact_size(padded_size, self.sense); diff --git a/crates/egui/src/widgets/image.rs b/crates/egui/src/widgets/image.rs index f5c36d1cc7a..6951f8c8961 100644 --- a/crates/egui/src/widgets/image.rs +++ b/crates/egui/src/widgets/image.rs @@ -239,15 +239,14 @@ impl<'a, T: Into>> From for Image<'a> { impl<'a> Image<'a> { /// Returns the size the image will occupy in the final UI. #[inline] - pub fn calculate_size(&self, available_size: Vec2, original_image_size: Option) -> Vec2 { + pub fn calc_size(&self, available_size: Vec2, original_image_size: Option) -> Vec2 { let original_image_size = original_image_size.unwrap_or(Vec2::splat(24.0)); // Fallback for still-loading textures, or failure to load. - self.size - .calculate_size(available_size, original_image_size) + self.size.calc_size(available_size, original_image_size) } - pub fn load_and_calculate_size(&self, ui: &mut Ui, available_size: Vec2) -> Option { + pub fn load_and_calc_size(&self, ui: &mut Ui, available_size: Vec2) -> Option { let image_size = self.load_for_size(ui.ctx(), available_size).ok()?.size()?; - Some(self.size.calculate_size(available_size, image_size)) + Some(self.size.calc_size(available_size, image_size)) } #[inline] @@ -298,7 +297,7 @@ impl<'a> Widget for Image<'a> { fn ui(self, ui: &mut Ui) -> Response { let tlr = self.load_for_size(ui.ctx(), ui.available_size()); let original_image_size = tlr.as_ref().ok().and_then(|t| t.size()); - let ui_size = self.calculate_size(ui.available_size(), original_image_size); + let ui_size = self.calc_size(ui.available_size(), original_image_size); let (rect, response) = ui.allocate_exact_size(ui_size, self.sense); paint_texture_load_result( @@ -389,7 +388,7 @@ impl ImageSize { } /// Calculate the final on-screen size in points. - pub fn calculate_size(&self, available_size: Vec2, original_image_size: Vec2) -> Vec2 { + pub fn calc_size(&self, available_size: Vec2, original_image_size: Vec2) -> Vec2 { let Self { maintain_aspect_ratio, max_size,