-
-
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
animate long press latching #12990
animate long press latching #12990
Conversation
I just tested this on Windows11, and the buttons appear fluidly animated and make the long press behavior really easier to understand. |
Great! Happy you like it, and thanks for validating! |
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.
Looking nice and smooth on Linux (PopOs 22.04 Wayland)
Kooha-2024-03-23-22-17-07.mp4
Thanks, Antoine! |
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.
my main note is that this gives every single pushbutton in the UI the latching logic and support objects even if they are never used. Would it be possible to make this a child object of a pushbutton (WPushButtonLatching) that inherits WPushButton and just adds on the new stuff? I think that would also be cleaner from a skin design perspective.
src/widget/wpushbutton.cpp
Outdated
m_preLongPressPixmap.setDevicePixelRatio(devicePixelRatio()); | ||
paintOnDevice(&m_preLongPressPixmap); | ||
// ... and start the long press latching animation | ||
m_animTimer.start(1000 / 60); |
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.
if I understand correctly, this creates an independent 60fps timer to update this animation. Would it be possible / feasible to connect instead to the global UI update timer? or does it not really matter because it's just updating the position data, and the drawing is done elsewhere?
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 doesn't matter. The overhead of the timer is minimal and it doesn't do the actual drawing, it just triggers the drawing when Qt sees fit. This is the recommended way.
These objects / connections can be created only if |
It would be possible but IMO this would lead to added complexity in the code rather than the opposite. Also, WPushButton already implements several modes / behaviours as it is, so why only isolating this one? The added overhead is minimal. Also, as far as I remember, the skin parser is not instantiating different classes based on properties anywhere, so it would be strange to add that only for this particular case. But I see your objection that this does add code to WPushButton that is only used for a very specific use case. What I could do is place the QTimer, the QPixmap, and the latching related code in a class that is a member of WPushButton, reducing the overhead to an std::unique_ptr and some function calls. |
Yes. I have moved the code and objects to nested class @fwcd let me know if this addresses your concerns. |
I think you wanted to ping @ywwg? 😄 |
Indeed! All those 4 letter usernames! 😅 |
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 like this refactor! I agree since wpushbutton already does a lot of things it doesn't make sense to create a subclass. thanks.
One more question, is the animation triggered when someone long-presses on a controller? I am guessing right now it only works when initiated with the UI and a mouse. It seems out of scope for this PR to implement this for controllers but we probably want to do that too
QVector<int> m_align; | ||
|
||
class LongPressLatching { |
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.
please add an explanatory comment for this new class that summarizes the feature
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.
Will do.
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.
Comment added. If you find it's sufficient, could you merge this? Thanks!
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.
@daschuer is the last outstanding reviewer
|
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 can confirm it is working nice after adding the include.
@daschuer Okay to merge? |
After adding the missing include, yes. |
d8ead1e
to
5606c3a
Compare
Animate long press latching (e.g. sync button) by capture the off-state in a pixmap and during the long press latch time, gradually draw less of it.
longpresslatching.mov