From 7e86fd84f6496b39af4a150b0281155e61ad54f3 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:28:15 +0900 Subject: [PATCH 1/4] Update scroll_area.rs --- crates/egui/src/containers/scroll_area.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/crates/egui/src/containers/scroll_area.rs b/crates/egui/src/containers/scroll_area.rs index 3f0e3a2df35..875ea55eb2d 100644 --- a/crates/egui/src/containers/scroll_area.rs +++ b/crates/egui/src/containers/scroll_area.rs @@ -793,15 +793,7 @@ impl Prepared { let content_size = content_ui.min_size(); - let scroll_delta = content_ui - .ctx() - .frame_state_mut(|state| std::mem::take(&mut state.scroll_delta)); - for d in 0..2 { - // FrameState::scroll_delta is inverted from the way we apply the delta, so we need to negate it. - let mut delta = -scroll_delta.0[d]; - let mut animation = scroll_delta.1; - // We always take both scroll targets regardless of which scroll axes are enabled. This // is to avoid them leaking to other scroll areas. let scroll_target = content_ui @@ -809,6 +801,17 @@ impl Prepared { .frame_state_mut(|state| state.scroll_target[d].take()); if scroll_enabled[d] { + let scroll_delta_0 = content_ui + .ctx() + .frame_state_mut(|state| std::mem::take(&mut state.scroll_delta.0[d])); + let scroll_delta_1 = content_ui + .ctx() + .frame_state_mut(|state| std::mem::take(&mut state.scroll_delta.1)); + + // FrameState::scroll_delta is inverted from the way we apply the delta, so we need to negate it. + let mut delta = -scroll_delta_0; + let mut animation = scroll_delta_1; + if let Some(target) = scroll_target { let frame_state::ScrollTarget { range, From e6211300ad71e14addc256f88447b6c3478b3976 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:17:20 +0900 Subject: [PATCH 2/4] Update scroll_area.rs --- crates/egui/src/containers/scroll_area.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/egui/src/containers/scroll_area.rs b/crates/egui/src/containers/scroll_area.rs index 875ea55eb2d..610b52fdad1 100644 --- a/crates/egui/src/containers/scroll_area.rs +++ b/crates/egui/src/containers/scroll_area.rs @@ -801,12 +801,12 @@ impl Prepared { .frame_state_mut(|state| state.scroll_target[d].take()); if scroll_enabled[d] { - let scroll_delta_0 = content_ui - .ctx() - .frame_state_mut(|state| std::mem::take(&mut state.scroll_delta.0[d])); - let scroll_delta_1 = content_ui - .ctx() - .frame_state_mut(|state| std::mem::take(&mut state.scroll_delta.1)); + let (scroll_delta_0, scroll_delta_1) = content_ui.ctx().frame_state_mut(|state| { + ( + std::mem::take(&mut state.scroll_delta.0[d]), + std::mem::take(&mut state.scroll_delta.1), + ) + }); // FrameState::scroll_delta is inverted from the way we apply the delta, so we need to negate it. let mut delta = -scroll_delta_0; From 506e07cd60fee89698d4e14318bfb9a1975e6c1d Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:42:10 +0900 Subject: [PATCH 3/4] Update scroll_area.rs --- crates/egui/src/containers/scroll_area.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/egui/src/containers/scroll_area.rs b/crates/egui/src/containers/scroll_area.rs index 610b52fdad1..c57696c7203 100644 --- a/crates/egui/src/containers/scroll_area.rs +++ b/crates/egui/src/containers/scroll_area.rs @@ -793,6 +793,10 @@ impl Prepared { let content_size = content_ui.min_size(); + let scroll_delta_1 = content_ui + .ctx() + .frame_state_mut(|state| std::mem::take(&mut state.scroll_delta.1)); + for d in 0..2 { // We always take both scroll targets regardless of which scroll axes are enabled. This // is to avoid them leaking to other scroll areas. @@ -801,12 +805,9 @@ impl Prepared { .frame_state_mut(|state| state.scroll_target[d].take()); if scroll_enabled[d] { - let (scroll_delta_0, scroll_delta_1) = content_ui.ctx().frame_state_mut(|state| { - ( - std::mem::take(&mut state.scroll_delta.0[d]), - std::mem::take(&mut state.scroll_delta.1), - ) - }); + let scroll_delta_0 = content_ui + .ctx() + .frame_state_mut(|state| std::mem::take(&mut state.scroll_delta.0[d])); // FrameState::scroll_delta is inverted from the way we apply the delta, so we need to negate it. let mut delta = -scroll_delta_0; From 05d5fe676b8c23af269cf29f16962074b3f15bde Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:52:21 +0900 Subject: [PATCH 4/4] Update scroll_area.rs --- crates/egui/src/containers/scroll_area.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/egui/src/containers/scroll_area.rs b/crates/egui/src/containers/scroll_area.rs index c57696c7203..610b52fdad1 100644 --- a/crates/egui/src/containers/scroll_area.rs +++ b/crates/egui/src/containers/scroll_area.rs @@ -793,10 +793,6 @@ impl Prepared { let content_size = content_ui.min_size(); - let scroll_delta_1 = content_ui - .ctx() - .frame_state_mut(|state| std::mem::take(&mut state.scroll_delta.1)); - for d in 0..2 { // We always take both scroll targets regardless of which scroll axes are enabled. This // is to avoid them leaking to other scroll areas. @@ -805,9 +801,12 @@ impl Prepared { .frame_state_mut(|state| state.scroll_target[d].take()); if scroll_enabled[d] { - let scroll_delta_0 = content_ui - .ctx() - .frame_state_mut(|state| std::mem::take(&mut state.scroll_delta.0[d])); + let (scroll_delta_0, scroll_delta_1) = content_ui.ctx().frame_state_mut(|state| { + ( + std::mem::take(&mut state.scroll_delta.0[d]), + std::mem::take(&mut state.scroll_delta.1), + ) + }); // FrameState::scroll_delta is inverted from the way we apply the delta, so we need to negate it. let mut delta = -scroll_delta_0;