From b7bf769bc09ae01b694aab5ea180f5e775c37047 Mon Sep 17 00:00:00 2001 From: Chris Cate Date: Sat, 4 Nov 2023 22:53:04 -0500 Subject: [PATCH 1/5] ImageButton rounding fix --- crates/egui/src/widgets/button.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/egui/src/widgets/button.rs b/crates/egui/src/widgets/button.rs index 4c94cc9d4ac9..72a559f4bf6b 100644 --- a/crates/egui/src/widgets/button.rs +++ b/crates/egui/src/widgets/button.rs @@ -621,7 +621,7 @@ impl<'a> Widget for ImageButton<'a> { let selection = ui.visuals().selection; ( Vec2::ZERO, - Rounding::ZERO, + self.image.image_options().rounding, selection.bg_fill, selection.stroke, ) @@ -630,7 +630,7 @@ impl<'a> Widget for ImageButton<'a> { let expansion = Vec2::splat(visuals.expansion); ( expansion, - visuals.rounding, + self.image.image_options().rounding, visuals.weak_bg_fill, visuals.bg_stroke, ) @@ -647,7 +647,6 @@ impl<'a> Widget for ImageButton<'a> { .align_size_within_rect(image_size, rect.shrink2(padding)); // let image_rect = image_rect.expand2(expansion); // can make it blurry, so let's not let image_options = ImageOptions { - rounding, // apply rounding to the image ..self.image.image_options().clone() }; widgets::image::paint_texture_load_result(ui, &tlr, image_rect, None, &image_options); From 90bdfbc43f759be5bb19622a3fb8fbfd311551c9 Mon Sep 17 00:00:00 2001 From: Chris Cate Date: Sat, 4 Nov 2023 23:16:59 -0500 Subject: [PATCH 2/5] remove unnecessary struct creation --- crates/egui/src/widgets/button.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/egui/src/widgets/button.rs b/crates/egui/src/widgets/button.rs index 72a559f4bf6b..0b239224208a 100644 --- a/crates/egui/src/widgets/button.rs +++ b/crates/egui/src/widgets/button.rs @@ -646,9 +646,8 @@ impl<'a> Widget for ImageButton<'a> { .layout() .align_size_within_rect(image_size, rect.shrink2(padding)); // let image_rect = image_rect.expand2(expansion); // can make it blurry, so let's not - let image_options = ImageOptions { - ..self.image.image_options().clone() - }; + let image_options = self.image.image_options().clone(); + widgets::image::paint_texture_load_result(ui, &tlr, image_rect, None, &image_options); // Draw frame outline: From 5ca68f58f7e5580eea9c91fcaf843d39a509e58f Mon Sep 17 00:00:00 2001 From: Chris Cate Date: Sun, 5 Nov 2023 22:33:56 -0600 Subject: [PATCH 3/5] added rounding method for ImageButton --- crates/egui/src/widgets/button.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/egui/src/widgets/button.rs b/crates/egui/src/widgets/button.rs index 0b239224208a..7fc95f4533f3 100644 --- a/crates/egui/src/widgets/button.rs +++ b/crates/egui/src/widgets/button.rs @@ -594,6 +594,15 @@ impl<'a> ImageButton<'a> { self.sense = sense; self } + + /// Set rounding for the `ImageButton`. + /// If the underlying image already had rounding, this + /// will override that value. + pub fn rounding(mut self, rounding: impl Into) -> Self { + let image = self.image.rounding(rounding.into()); + self.image = image; + self + } } impl<'a> Widget for ImageButton<'a> { From 5cd8faa2ae43c3d9704fde907bc384e9d8790dec Mon Sep 17 00:00:00 2001 From: Chris Cate Date: Sun, 5 Nov 2023 22:40:34 -0600 Subject: [PATCH 4/5] grammar fix --- crates/egui/src/widgets/button.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/button.rs b/crates/egui/src/widgets/button.rs index 7fc95f4533f3..d9ac298bbfcd 100644 --- a/crates/egui/src/widgets/button.rs +++ b/crates/egui/src/widgets/button.rs @@ -596,7 +596,7 @@ impl<'a> ImageButton<'a> { } /// Set rounding for the `ImageButton`. - /// If the underlying image already had rounding, this + /// If the underlying image already has rounding, this /// will override that value. pub fn rounding(mut self, rounding: impl Into) -> Self { let image = self.image.rounding(rounding.into()); From 78fd2ab2e62010dbfd78dc05422a9b3ce76cce61 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 10 Nov 2023 11:23:19 +0100 Subject: [PATCH 5/5] simplify the code slightly --- crates/egui/src/widgets/button.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/egui/src/widgets/button.rs b/crates/egui/src/widgets/button.rs index d9ac298bbfcd..e11a33b1905f 100644 --- a/crates/egui/src/widgets/button.rs +++ b/crates/egui/src/widgets/button.rs @@ -599,8 +599,7 @@ impl<'a> ImageButton<'a> { /// If the underlying image already has rounding, this /// will override that value. pub fn rounding(mut self, rounding: impl Into) -> Self { - let image = self.image.rounding(rounding.into()); - self.image = image; + self.image = self.image.rounding(rounding.into()); self } }