From 02ff040b74cef45876fb8cc7534474351a48a8d6 Mon Sep 17 00:00:00 2001 From: eason <85663565+mango766@users.noreply.github.com> Date: Wed, 25 Mar 2026 21:48:22 +0800 Subject: [PATCH 1/2] Fix: `Visuals::interact_cursor` support in `Button` (#7986) Closes #7947 ## Problem `Visuals::interact_cursor` stopped working for buttons after the `AtomLayout` refactor in commit 6eb7bb6e. Setting `interact_cursor` to e.g. `CursorIcon::PointingHand` no longer changes the cursor when hovering over a `Button`. ## Root Cause When `Button` was rewritten to use `AtomLayout` in #5830, the cursor-override block at the end of the old `Button::ui` was not carried over to the new `Button::atom_ui` method. The old code had: ```rust if let Some(cursor) = ui.visuals().interact_cursor { if response.hovered() { ui.ctx().set_cursor_icon(cursor); } } ``` This was the only place `interact_cursor` was checked, so the setting became entirely non-functional. ## Fix Re-add the same `interact_cursor` check in `Button::atom_ui`, right after painting and before `widget_info`, matching the original behavior. --------- Co-authored-by: easonysliu Co-authored-by: Emil Ernerfeldt --- crates/egui/src/widgets/button.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/egui/src/widgets/button.rs b/crates/egui/src/widgets/button.rs index 7d9dddf0d..8ef047002 100644 --- a/crates/egui/src/widgets/button.rs +++ b/crates/egui/src/widgets/button.rs @@ -371,6 +371,12 @@ impl<'a> Button<'a> { AtomLayoutResponse::empty(prepared.response) }; + if let Some(cursor) = ui.visuals().interact_cursor + && response.response.hovered() + { + ui.ctx().set_cursor_icon(cursor); + } + response.response.widget_info(|| { if let Some(text) = &text { WidgetInfo::labeled(WidgetType::Button, ui.is_enabled(), text) From 048f8ccd2af21a0074ac2a2f62b2d08f917bbb44 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 25 Mar 2026 15:44:41 +0100 Subject: [PATCH 2/2] Tweak `ScrollArea` fade effect (#8023) * Follow-up to https://github.com/emilk/egui/pull/8018 --- crates/egui/src/containers/scroll_area.rs | 13 ++++++------- crates/egui/src/style.rs | 15 +++++++++------ .../tests/snapshots/easymarkeditor.png | 4 ++-- .../tests/snapshots/demos/Font Book.png | 4 ++-- .../tests/snapshots/demos/Panels.png | 4 ++-- .../tests/snapshots/demos/Scrolling.png | 4 ++-- .../egui_demo_lib/tests/snapshots/demos/Table.png | 4 ++-- .../tests/snapshots/demos/Tooltips.png | 4 ++-- .../tests/snapshots/demos/Window Resize Test.png | 4 ++-- .../tests/snapshots/test_scroll_initial.png | 4 ++-- .../tests/snapshots/test_scroll_scrolled.png | 4 ++-- .../tests/snapshots/text_edit_scroll_0_focus.png | 4 ++-- .../tests/snapshots/text_edit_scroll_1_5.png | 4 ++-- 13 files changed, 37 insertions(+), 35 deletions(-) diff --git a/crates/egui/src/containers/scroll_area.rs b/crates/egui/src/containers/scroll_area.rs index 6dc264a0a..b99bcf5da 100644 --- a/crates/egui/src/containers/scroll_area.rs +++ b/crates/egui/src/containers/scroll_area.rs @@ -1513,11 +1513,11 @@ impl Prepared { /// indicate that more content is available beyond the visible region. fn paint_fade_areas(ui: &Ui, scroll_output: &ScrollAreaOutput) { let crate::style::ScrollFadeStyle { - enabled, + strength, size: fade_size, } = ui.spacing().scroll.fade; - if !enabled { + if strength <= 0.0 { return; } @@ -1533,7 +1533,7 @@ fn paint_fade_areas(ui: &Ui, scroll_output: &ScrollAreaOutput) { // Top fade: animate opacity based on how far we've scrolled down. if 0.0 < offset.y { - let t = (offset.y / fade_size).clamp(0.0, 1.0); + let t = (offset.y / fade_size).clamp(0.0, 1.0) * strength; let bg_faded = bg.gamma_multiply(t); let rect = Rect::from_min_max( paint_rect.left_top(), @@ -1549,7 +1549,7 @@ fn paint_fade_areas(ui: &Ui, scroll_output: &ScrollAreaOutput) { // Bottom fade: animate opacity based on distance from the bottom. let distance_from_bottom = overflow.y - offset.y; if 0.0 < distance_from_bottom { - let t = (distance_from_bottom / fade_size).clamp(0.0, 1.0); + let t = (distance_from_bottom / fade_size).clamp(0.0, 1.0) * strength; let bg_faded = bg.gamma_multiply(t); let rect = Rect::from_min_max( pos2(paint_rect.left(), paint_rect.bottom() - fade_size), @@ -1563,9 +1563,8 @@ fn paint_fade_areas(ui: &Ui, scroll_output: &ScrollAreaOutput) { } // Left fade: animate opacity based on how far we've scrolled right. - if 0.0 < offset.x { - let t = (offset.x / fade_size).clamp(0.0, 1.0); + let t = (offset.x / fade_size).clamp(0.0, 1.0) * strength; let bg_faded = bg.gamma_multiply(t); let rect = Rect::from_min_max( paint_rect.left_top(), @@ -1581,7 +1580,7 @@ fn paint_fade_areas(ui: &Ui, scroll_output: &ScrollAreaOutput) { // Right fade: animate opacity based on distance from the right edge. let distance_from_right = overflow.x - offset.x; if 0.0 < distance_from_right { - let t = (distance_from_right / fade_size).clamp(0.0, 1.0); + let t = (distance_from_right / fade_size).clamp(0.0, 1.0) * strength; let bg_faded = bg.gamma_multiply(t); let rect = Rect::from_min_max( pos2(paint_rect.right() - fade_size, paint_rect.top()), diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index 5549cdbc3..f7b889506 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -790,8 +790,10 @@ impl ScrollStyle { #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", serde(default))] pub struct ScrollFadeStyle { - /// Show fade areas? - pub enabled: bool, + /// Opacity of the fade effect at the outer edge, in 0.0-1.0. + /// + /// Set to 0.0 to disable the fade effect. + pub strength: f32, /// Size of the fade-area (height for vertical scrolling, /// width for horizontal scrolling). @@ -801,7 +803,7 @@ pub struct ScrollFadeStyle { impl Default for ScrollFadeStyle { fn default() -> Self { Self { - enabled: true, + strength: 0.5, size: 20.0, } } @@ -809,13 +811,14 @@ impl Default for ScrollFadeStyle { impl ScrollFadeStyle { pub fn ui(&mut self, ui: &mut Ui) { - let Self { enabled, size } = self; + let Self { strength, size } = self; ui.horizontal(|ui| { - ui.checkbox(enabled, "Fade edges"); + ui.add(DragValue::new(strength).speed(0.01).range(0.0..=1.0)); + ui.label("Fade strength"); }); - if *enabled { + if 0.0 < *strength { ui.horizontal(|ui| { ui.add(DragValue::new(size).range(0.0..=64.0)); ui.label("Fade size"); diff --git a/crates/egui_demo_app/tests/snapshots/easymarkeditor.png b/crates/egui_demo_app/tests/snapshots/easymarkeditor.png index c90dcc918..5118065c4 100644 --- a/crates/egui_demo_app/tests/snapshots/easymarkeditor.png +++ b/crates/egui_demo_app/tests/snapshots/easymarkeditor.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:65776e4d9e31e7163117166915a0cfaaece98b1dd69695533655dee889ac5597 -size 169277 +oid sha256:84f0e72ce337d56f3767ebed1ab6a47f3d27c9fbcce4d8a19aeab358e12920f5 +size 169664 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Font Book.png b/crates/egui_demo_lib/tests/snapshots/demos/Font Book.png index af2bb0a0f..ac85845f9 100644 --- a/crates/egui_demo_lib/tests/snapshots/demos/Font Book.png +++ b/crates/egui_demo_lib/tests/snapshots/demos/Font Book.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:583003c59f40515a5de435ee1eea2ee6fceae409c7881456401b004c6409896a -size 114575 +oid sha256:deff441cd1d9142352f8759dff4b759f4572f0ddf93752349314da77abe4b254 +size 115028 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Panels.png b/crates/egui_demo_lib/tests/snapshots/demos/Panels.png index 67e44c14e..70e7ce90e 100644 --- a/crates/egui_demo_lib/tests/snapshots/demos/Panels.png +++ b/crates/egui_demo_lib/tests/snapshots/demos/Panels.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8815473873602211a95e0a077dc77560de154a0a1a2f9c1418d90746670075f7 -size 248630 +oid sha256:a46457b23b7b32694564d03b42bccac2f017a756225bc54b508bb6fe2ad8ee7b +size 249548 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Scrolling.png b/crates/egui_demo_lib/tests/snapshots/demos/Scrolling.png index aa354bb0a..0924d3aa9 100644 --- a/crates/egui_demo_lib/tests/snapshots/demos/Scrolling.png +++ b/crates/egui_demo_lib/tests/snapshots/demos/Scrolling.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2881255fa694b713a3c3049f30143ee60a20b68105fb724fbba188f81d34e572 -size 171778 +oid sha256:927a497e8b6f9ce3b71dcb67086f477e19d327c163b2b8ad868af10009c2faf2 +size 172981 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Table.png b/crates/egui_demo_lib/tests/snapshots/demos/Table.png index f9c8f991e..727c01434 100644 --- a/crates/egui_demo_lib/tests/snapshots/demos/Table.png +++ b/crates/egui_demo_lib/tests/snapshots/demos/Table.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:63fb9d15956efa69818cfd5398b4dfaa796dfbe1df3fb171b8ae413a6f641c9f -size 76049 +oid sha256:db4c0cf1c4cdae3d416afce5c58efd1cc382be86431e547fa66bcc95a0a17ddb +size 76364 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Tooltips.png b/crates/egui_demo_lib/tests/snapshots/demos/Tooltips.png index 3441b6896..e7ed07b04 100644 --- a/crates/egui_demo_lib/tests/snapshots/demos/Tooltips.png +++ b/crates/egui_demo_lib/tests/snapshots/demos/Tooltips.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4ac837d03e3e8959196942d030a8511d00cdd0d5ac9bfe761d80b59d32e73581 -size 63967 +oid sha256:57018beba5e4fb4f1e6de9c58bf898560b3a7669159d5bad91a4e2382ef57ce0 +size 64004 diff --git a/crates/egui_demo_lib/tests/snapshots/demos/Window Resize Test.png b/crates/egui_demo_lib/tests/snapshots/demos/Window Resize Test.png index 2e5e8c717..c769f61bd 100644 --- a/crates/egui_demo_lib/tests/snapshots/demos/Window Resize Test.png +++ b/crates/egui_demo_lib/tests/snapshots/demos/Window Resize Test.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4107ba4569b3e37ce6720595cfc4de60aec11dcfdb835720442b244e121209fc -size 482862 +oid sha256:999f9cc006302b8951d97b510a02f1209969c376ecc7909ed5d7b46da27c0637 +size 483753 diff --git a/crates/egui_kittest/tests/snapshots/test_scroll_initial.png b/crates/egui_kittest/tests/snapshots/test_scroll_initial.png index 1eda6d278..64ed153a6 100644 --- a/crates/egui_kittest/tests/snapshots/test_scroll_initial.png +++ b/crates/egui_kittest/tests/snapshots/test_scroll_initial.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6f6d516cc3d1439256a19f72153468125bac1647e2e211e841579545570faef7 -size 7366 +oid sha256:6154c8bb550575bcb9fa0bba06da4d47079a00dffc5754b62ef2a6e7529e2090 +size 7489 diff --git a/crates/egui_kittest/tests/snapshots/test_scroll_scrolled.png b/crates/egui_kittest/tests/snapshots/test_scroll_scrolled.png index 87367951c..a87f09545 100644 --- a/crates/egui_kittest/tests/snapshots/test_scroll_scrolled.png +++ b/crates/egui_kittest/tests/snapshots/test_scroll_scrolled.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2e05d28e5541eb5926b4758e611f5c340311269fcd8b63055ff3a6793abbb140 -size 8279 +oid sha256:df2578c198b29950254ec62c6cc615a4b1c003e7ae3ea027da22fc868b392c74 +size 8342 diff --git a/tests/egui_tests/tests/snapshots/text_edit_scroll_0_focus.png b/tests/egui_tests/tests/snapshots/text_edit_scroll_0_focus.png index da3039325..019154ba6 100644 --- a/tests/egui_tests/tests/snapshots/text_edit_scroll_0_focus.png +++ b/tests/egui_tests/tests/snapshots/text_edit_scroll_0_focus.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5dfd9b576e0ab4b47a0f8c8acfc2664f92faa88cc7fb088409bff359fa1dfadd -size 1861 +oid sha256:6f2a57ad8dbdd121cb181e74d76db68d800aba8fdc980d8de4e962e1e85fe8f6 +size 1803 diff --git a/tests/egui_tests/tests/snapshots/text_edit_scroll_1_5.png b/tests/egui_tests/tests/snapshots/text_edit_scroll_1_5.png index ecba0fcc1..6c1ee1d81 100644 --- a/tests/egui_tests/tests/snapshots/text_edit_scroll_1_5.png +++ b/tests/egui_tests/tests/snapshots/text_edit_scroll_1_5.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4529530bb46af68260ca910a91f888e8b296790be2b976b450cec884799f53b4 -size 1953 +oid sha256:43dc457cac18107772dbb7e5773961cf502dd685ce1cb4e94338e6b7daedaa77 +size 1861