Skip to content

Make slider scrollable by mouse wheel#2104

Open
gordonshieh wants to merge 9 commits into
linebender:masterfrom
gordonshieh:scrollable-slider
Open

Make slider scrollable by mouse wheel#2104
gordonshieh wants to merge 9 commits into
linebender:masterfrom
gordonshieh:scrollable-slider

Conversation

@gordonshieh

Copy link
Copy Markdown

When hovered over a slider, and a user scrolls with their mouse wheel, the slider will move

@jneem

jneem commented Jan 4, 2022

Copy link
Copy Markdown
Member

Thanks for the PR! We have a long-standing slider improvement PR that I'd like to get in first, though (#1979). Maybe this can be rebased on that afterwards?

@xarvic xarvic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good! Could you add your changes to the Changelog.

Comment thread druid/src/widget/slider.rs Outdated
let increment = if let Some(step) = self.step {
step
} else {
0.1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In some cases the difference between min and max is smaller than 0.1. This value should depend on min and max.

@gordonshieh

Copy link
Copy Markdown
Author

@jneem Sure. I'm in no rush to get this PR in.
@xarvic Updated the step to be 10% of the min and max range; also updated the changelog

@jneem

jneem commented Jan 5, 2022

Copy link
Copy Markdown
Member

Ok, I merged #1979 so that isn't a blocker anymore. But you will need to rebase, because Slider changed a lot...

@gordonshieh

Copy link
Copy Markdown
Author

Cool. Also planning to add mouse wheel support to the RangeSlider too then.

@gordonshieh
gordonshieh requested a review from xarvic January 10, 2022 05:10
@xarvic

xarvic commented Jan 10, 2022

Copy link
Copy Markdown
Collaborator

Scrolling the RangeSlider feels a little strange. If the knob moves too far away, the slider starts moving the other knob. I think unless the mouse is moved we should always move the same Knob when scrolling.

2022-01-10.20-29-18.mp4

self.mapping
.calculate_value(me.pos, knob_size, ctx.size(), 0.0);

if press_value - data.0 < data.1 - press_value {

@xarvic xarvic Jan 10, 2022

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We need to remember which knob was scrolled last

@xStrom xStrom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the status here? @gordonshieh do you still want to move forward with this PR?

Please rebase on master so that we can resolve the merge conflicts.

Comment thread CHANGELOG.md
- Scope: expose scoped state using state() and state_mut() ([#2082] by [@rjwittams]
- Tabs: allow getting and setting the tab index of a Tabs widget ([#2082] by [@rjwittams]
- `RangeSlider` and `Annotated` ([#1979] by [@xarvic])
- `Slider` widget now scrollable by mouse wheel ([#2104] by [@gordonshieh])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unfortunately the links aren't automatically generated. Please manually define both [#2104] and [@gordonshieh] at the bottom of the file.

@xStrom xStrom added widget concerns a particular widget S-waiting-on-author waits for changes from the submitter labels Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author waits for changes from the submitter widget concerns a particular widget

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants