-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
QMLDemo: improve OrientationToggleButton touch friendlyness #3934
QMLDemo: improve OrientationToggleButton touch friendlyness #3934
Conversation
12957af
to
f54c1ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, but this does not work. If I play deck 1, move the crossfader to the right and change the channel orientation, I still can't hear the deck. This is because you never actually set a value on the control proxy, just read it.
stepSize: 1 | ||
value: control.value | ||
orientation: Qt.Horizontal | ||
snapMode: Slider.SnapOnRelease |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obviously, you can't add value: orientationSlider.value
to the control proxy because that would create an endless binding loop.
Instead, you only want to update the CO value when the slider was moved by the user, not on every value change.
Try this:
snapMode: Slider.SnapOnRelease | |
snapMode: Slider.SnapOnRelease | |
onMoved: control.value = value |
Didn't test this, but it should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I thought I had figured it out but it seems like I didn't. Not sure onMoved will work because it might fire before releasing the control, but I'll try to figure something out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out using onMoved causes some weird issues where the visualposition and the value of the slider get out of sync. I'll have to think of another workaround...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I investigated a bit (using console.warn(value)
😉), and this should work.
snapMode: Slider.SnapOnRelease | |
snapMode: Slider.SnapOnRelease | |
onMoved: { | |
// The slider's `value` is not updated until after the move ended, | |
// so we need to calculate the value position ourselves here. | |
control.value = Math.round(visualPosition * (to - from)); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I don't know when I'll be able to get back on this though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should work now.
5c0dfc9
to
49d4d6c
Compare
Pull Request Test Coverage Report for Build 1033210008
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it works. But IMHO util.js
makes the much more complicated than it needs to be.
res/skins/QMLDemo/util.mjs
Outdated
export function hasChanged(value) { | ||
const changed = value != previous; | ||
previous = value; | ||
return changed; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a utility function? If I use this function for two unrelated values, the result is wrong, so it's not reusable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is very primitive, I'm aware. It's not supposed to be perfect but just generally make sure that code that gets called repeatedly can debounce a bit so to speak.
onMoved: { | ||
// The slider's `value` is not updated until after the move ended. | ||
const val = valueAt(visualPosition); | ||
if (Util.hasChanged(val)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just val != control.value
? This utility function makes it harder to understand what happens. It's also not reusable because it uses a global mutable variable (evil!).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats a good idea actually. How did I not think of that.
The previous implementation was hard to use on a touchscreen because the surface where it was touching was very small. The new version makes use of a slider internally which allows the control to be changed more intiutively by swiping.
49d4d6c
to
18b7e69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
The previous implementation was hard to use on a touchscreen
because the surface where it was touching was very small.
The new version makes use of a slider internally which allows
the control to be changed more intiutively by swiping.