Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the ScrollBar is set to Visibility::AlwaysVisible, scrolling is always possible & contains pointer #4348

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f0b7737
Update memory.rs
rustbasic Mar 23, 2024
3b98d7f
Update epi_integration.rs
rustbasic Mar 23, 2024
af5a7bb
Update memory.rs
rustbasic Mar 23, 2024
7f66b56
Update memory.rs
rustbasic Mar 23, 2024
6396c4a
Update epi_integration.rs
rustbasic Mar 23, 2024
9fe42ff
Merge branch 'emilk:master' into master
rustbasic Mar 25, 2024
d7673fe
Merge branch 'emilk:master' into master
rustbasic Mar 25, 2024
a7edc53
Merge branch 'emilk:master' into master
rustbasic Mar 26, 2024
2432784
Merge branch 'emilk:master' into master
rustbasic Mar 27, 2024
9b6209b
Merge branch 'emilk:master' into master
rustbasic Mar 27, 2024
f3687f6
Merge branch 'emilk:master' into master
rustbasic Mar 28, 2024
78880de
Merge branch 'emilk:master' into master
rustbasic Mar 29, 2024
01ba2ec
Merge branch 'emilk:master' into master
rustbasic Mar 29, 2024
0ae2451
Merge branch 'emilk:master' into master
rustbasic Mar 29, 2024
e6c84ce
Merge branch 'emilk:master' into master
rustbasic Mar 30, 2024
821dff0
Update epi_integration.rs
rustbasic Mar 30, 2024
eecfafd
Merge branch 'emilk:master' into master
rustbasic Mar 30, 2024
cbb5ac7
Merge branch 'emilk:master' into master
rustbasic Mar 30, 2024
07b5143
Merge branch 'emilk:master' into master
rustbasic Mar 31, 2024
3313633
Update epi_integration.rs
rustbasic Mar 31, 2024
90b968c
Merge branch 'emilk:master' into master
rustbasic Apr 1, 2024
13af44f
Merge branch 'emilk:master' into master
rustbasic Apr 1, 2024
5d95f09
Merge branch 'emilk:master' into master
rustbasic Apr 1, 2024
4be440a
Merge branch 'emilk:master' into master
rustbasic Apr 1, 2024
1ef0e10
Merge branch 'emilk:master' into master
rustbasic Apr 2, 2024
6541324
Merge branch 'emilk:master' into master
rustbasic Apr 2, 2024
8abc161
Merge branch 'emilk:master' into master
rustbasic Apr 3, 2024
1b21742
Merge branch 'emilk:master' into master
rustbasic Apr 4, 2024
052bb68
Merge branch 'emilk:master' into master
rustbasic Apr 5, 2024
a3fc209
Update input_state.rs
rustbasic Apr 11, 2024
9d01bef
Update scroll_area.rs
rustbasic Apr 11, 2024
aff6dd9
Update scroll_area.rs
rustbasic Apr 11, 2024
303ba20
Merge branch 'emilk:master' into patch40
rustbasic Apr 19, 2024
3e49063
Merge branch 'emilk:master' into patch40
rustbasic Apr 21, 2024
1420c26
Merge branch 'emilk:master' into patch40
rustbasic Apr 22, 2024
734e21a
Merge branch 'emilk:master' into patch40
rustbasic Apr 22, 2024
8c1294e
Merge branch 'emilk:master' into patch40
rustbasic Apr 23, 2024
2af3a46
Merge branch 'emilk:master' into patch40
rustbasic Apr 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion crates/egui/src/containers/scroll_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,21 @@ impl Prepared {

let max_offset = content_size - inner_rect.size();
let is_hovering_outer_rect = ui.rect_contains_pointer(outer_rect);
if scrolling_enabled && is_hovering_outer_rect {

if scrolling_enabled
&& (is_hovering_outer_rect
|| scroll_bar_visibility == ScrollBarVisibility::AlwaysVisible)
{
let pointer_position = ui.input(|i| i.pointer.interact_pos().unwrap_or_default());
if inner_rect.contains(pointer_position) {
ui.ctx().input_mut(|input| {
input.smooth_scroll_delta[0] += input.raw_scroll_delta[0];
input.smooth_scroll_delta[1] += input.raw_scroll_delta[1];
input.raw_scroll_delta[0] = 0.0;
input.raw_scroll_delta[1] = 0.0;
});
}

let always_scroll_enabled_direction = ui.style().always_scroll_the_only_direction
&& scroll_enabled[0] != scroll_enabled[1];
for d in 0..2 {
Expand Down
4 changes: 3 additions & 1 deletion crates/egui/src/input_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ impl InputState {
// Mouse wheels often go very large steps.
// A single notch on a logitech mouse wheel connected to a Macbook returns 14.0 raw_scroll_delta.
// So we smooth it out over several frames for a nicer user experience when scrolling in egui.
unprocessed_scroll_delta += raw_scroll_delta;

// unprocessed_scroll_delta += raw_scroll_delta;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a bug

Copy link
Contributor Author

@rustbasic rustbasic Apr 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a bug

There is no problem if I remove this from Windows.
I left it here to hear 'emilk's opinion on whether it can be removed.

If something is wrong or needs to be fixed, please fix it or let me know.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment effectively ignores raw_scroll_delta and all the work that went into smoothing it, breaking the existing smooth scrolling of everything except for ScrollAreas (e.g. scroll-to-zoom in a plot).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment effectively ignores raw_scroll_delta and all the work that went into smoothing it, breaking the existing smooth scrolling of everything except for ScrollAreas (e.g. scroll-to-zoom in a plot).

Edited as #4412


let dt = stable_dt.at_most(0.1);
let t = crate::emath::exponential_smooth_factor(0.90, 0.1, dt); // reach _% in _ seconds. TODO(emilk): parameterize

Expand Down