Fix image button padding on hover (#1595)

This commit is contained in:
Luke Newcomb 2022-05-11 05:58:15 -04:00 committed by GitHub
parent 7b18fab7a4
commit e44c9b8e54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View file

@ -7,7 +7,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui-w
## Unreleased
* Add `*_released` & `*_clicked` methods for `PointerState` ([#1582](https://github.com/emilk/egui/pull/1582)).
* Optimize painting of filled circles (e.g. for scatter plots) by 10x or more ([#1616](https://github.com/emilk/egui/pull/1616)).
* Fixed `ImageButton`'s changing background padding on hover ([#1595](https://github.com/emilk/egui/pull/1595)).
## 0.18.1 - 2022-05-01
* Change `Shape::Callback` from `&dyn Any` to `&mut dyn Any` to support more backends.

View file

@ -489,18 +489,14 @@ impl Widget for ImageButton {
let (expansion, rounding, fill, stroke) = if selected {
let selection = ui.visuals().selection;
(
-padding,
Vec2::ZERO,
Rounding::none(),
selection.bg_fill,
selection.stroke,
)
} else if frame {
let visuals = ui.style().interact(&response);
let expansion = if response.hovered {
Vec2::splat(visuals.expansion) - padding
} else {
Vec2::splat(visuals.expansion)
};
let expansion = Vec2::splat(visuals.expansion);
(
expansion,
visuals.rounding,