Skip to content

Initial creation of the range slider and testbed#114

Draft
Tiomat85 wants to merge 9 commits intonion-software:masterfrom
Tiomat85:Range_Slider
Draft

Initial creation of the range slider and testbed#114
Tiomat85 wants to merge 9 commits intonion-software:masterfrom
Tiomat85:Range_Slider

Conversation

@Tiomat85
Copy link
Contributor

Creation of a new Range Slider control and widget.

A range slider has two 'handles' which are adjustable as a minimum and maximum of the value. It should also provide the ability to drag them both together.

@Tiomat85 Tiomat85 requested review from KRLango and lisham2000 June 24, 2025 15:15
@Tiomat85 Tiomat85 added the sprint issue is part of an active sprint label Jun 25, 2025
Copy link

@KRLango KRLango left a comment

Choose a reason for hiding this comment

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

Minor formatting issue - but otherwise looks good to me.

@KRLango KRLango removed their assignment Jun 25, 2025
@KRLango
Copy link

KRLango commented Jun 25, 2025

After reviewing this I started reviewing nion-software/nionswift#1582 and realised the range slider is currently hard-coded to be 0-1. This means all usages will have to handle the conversion to min/max themselves. Wouldn't that be better in this class so it is done in a single place?

@Tiomat85
Copy link
Contributor Author

After reviewing this I started reviewing nion-software/nionswift#1582 and realised the range slider is currently hard-coded to be 0-1. This means all usages will have to handle the conversion to min/max themselves. Wouldn't that be better in this class so it is done in a single place?

You are correct, this is to match the behaviour to that of the existing SliderCanvasItem. I would not be opposed to adding an extra block of work migrating both of those over to a dynamic min/max and roll some of that boiler plate code down.

@cmeyer
Copy link
Collaborator

cmeyer commented Jun 25, 2025

You are correct, this is to match the behaviour to that of the existing SliderCanvasItem. I would not be opposed to adding an extra block of work migrating both of those over to a dynamic min/max and roll some of that boiler plate code down.

Let's push that to a future PR, if at all.

Copy link
Collaborator

@cmeyer cmeyer left a comment

Choose a reason for hiding this comment

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

Not a full review - just some initial comments:

  • the "handles" are different (wider) from the slider canvas item. why?
  • the handles seem to work fundamentally differently from the slider - is the range defined by the center of the handle or the left/right edges? if the center, then it is impossible to get the interval to be 0. if the edges, then can they be shaped like triangles to be more like bookends?
  • do we want to define/enforce an optional minimum interval? IIRC this is required for one of the display item situations
  • I'm going back and forth whether we want to make this part of nionui yet or just a custom canvas item in nionswift. there are still some usage details to work out and it may be better to try this first on the nionswift side. I know I'm the one who suggested putting it in nionui but it's more intrusive (i.e. modifying the UserInterface class) than I was expecting.

@KRLango
Copy link

KRLango commented Jun 26, 2025

Some odd behaviour that I observed while testing the range slider:

  • Set the minimum value to 0, and the maximum to the maximum possible.
  • Grab the maximum bar and quickly move it to the minimum location.
  • The minimum bar will jump to a higher value. I have observed it moving up to 1/3 of the bar.
  • Even with a fairly slow movement, the minimum will jump from 0 to 1

Similar things happen if you move the minimum bar towards the maximum as well.

Tiomat85 added 2 commits June 27, 2025 16:39
A collection of fixes for slider motion.
One fix of making sure that the same maths is used for conversion from min/max to center/width.
Multiple fixes for making sure event propagation did not cause undesired additional changes, mostly around the inclusion of the __suppress_updates flag which limits the updates to only a single event driven update.This removed most of the 'wobbly' effect where events triggered as part of the partial update caused other side-effects.

Also changed the handle style to be a trial of a bookend style handle to see whether that works better.
@Tiomat85 Tiomat85 assigned Ion-e and unassigned Tiomat85 Jul 2, 2025
@Ion-e Ion-e removed their assignment Sep 2, 2025
@KRLango
Copy link

KRLango commented Sep 3, 2025

Note for testing: This will not cause any range sliders to show up. The test case for this is in nion-software/nionswift#1582

@Ion-e Ion-e removed their assignment Sep 3, 2025
@Ion-e Ion-e removed their assignment Sep 9, 2025
@jamesrussell216 jamesrussell216 assigned Ion-e and unassigned Tiomat85 Sep 30, 2025
@Ion-e Ion-e assigned Tiomat85 and unassigned Ion-e Oct 2, 2025
Tighten range calculation.

Adjusting the way the min/max are adjusted together to maintain absolute width rather than applying the delta independantly which could lead to odd rounding behaviour.
@cmeyer
Copy link
Collaborator

cmeyer commented Oct 7, 2025

As discussed in meeting, can we put this code at the point of use in nionswift for now until we work out the details of what we want?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sprint issue is part of an active sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants