-
Notifications
You must be signed in to change notification settings - Fork 49
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
[Gui] Propage Mouse events using Qt signals #848
[Gui] Propage Mouse events using Qt signals #848
Conversation
This trick is already used in some plugins. |
d38c0f4
to
5ee5a11
Compare
Codecov Report
@@ Coverage Diff @@
## release-candidate #848 +/- ##
=====================================================
- Coverage 26.41% 26.41% -0.01%
=====================================================
Files 321 321
Lines 21410 21413 +3
=====================================================
Hits 5656 5656
- Misses 15754 15757 +3
Continue to review full report at Codecov.
|
I do not get the point why do we need two different kinds of behavior, one with callback for keyboard, one with signal for mouse ? |
I do agree. |
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.
Simple, working but questionable :
- how to prevent the needUpdate (or indirecly frameUpdate) to be called twice (or even once) if the listener is implemented such that it asks for update on some cases but do not want to update the frame in another situation.
- how to develop an application/plugin/listener object using this functionality? Please update the demo or propose a simple one.
- this method being Qt specific, it should require to develop more code than needed to have portable component or to share the mouse behavior with keyboard behavior.
Based on this question, I propose you tag the signals as « deprecated » and the PR as « temporary fix(hack) » so that developpers will not use this « hack » too much in their apps
As I understand the functionallity as being important and quite urgent, i do not argue against this PR but it should definitely be replaced as soon as possible by a more robust/general approach based on Qt independant callbacks. (Similar to keyboard évent propagation)
Simple, working but questionable :
Based on this question, I propose you tag the signals as « deprecated » and the PR as « temporary fix(hack) » so that developers will not use this « hack » too much in their apps As I understand the functionality as being important and quite urgent, i do not argue against this PR but it should definitely be replaced as soon as possible by a more robust/general approach based on Qt independent callbacks. (Similar to keyboard event propagation) |
As written is the signal documentation,
This thing is useful only for plugins: currently, anyone writing his own application can override the @dlyr has open an issue to remember that we need a better implementation (#850). So, what I can do:
Does that work for you both ? |
I'm not for deprecated since there is no current alternative. |
One can develop a specific app without inheriting from viewer or something else. All DemoApps do this. Just use the BaseApplication and its Viewer, define a specific window factory (or use the provided ones) and implement application specific logic without worrying about Qt, Viewer ... take a look on, e.g. KeyEventDemoApp the defines its own Qt window to manage events and implement actions on the event (not separated from Qt-related stuff but this can be done quite easily and is a recommandation of all CHI software development workflow). But this is out of topic of this PR even if a simple demo of the usage might be helpfull.
Fine for me. |
Tell me what to do with the deprecated flag. |
@@ -181,6 +181,13 @@ class RA_GUI_API Viewer : public WindowQt, public KeyMappingManageable<Viewer> | |||
|
|||
void needUpdate(); | |||
|
|||
/// Event sent after a mouse press event has been processed, but before emitting needUpdate() | |||
void onMousePress( QMouseEvent* event ); |
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.
void onMousePress( QMouseEvent* event ); | |
[[deprecated]] void onMousePress( QMouseEvent* event ); |
Note that for deprecated method, some IDE will not automatically complement their name from any prefix and will display the available method as strikethrough. This might discourage users to abuse from ready-to-be-removed features ;)
/// Event sent after a mouse press event has been processed, but before emitting needUpdate() | ||
void onMousePress( QMouseEvent* event ); | ||
/// Event sent after a mouse release event has been processed, but before emitting needUpdate() | ||
void onMouseRelease( QMouseEvent* event ); |
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.
void onMouseRelease( QMouseEvent* event ); | |
[[deprecated]] void onMouseRelease( QMouseEvent* event ); |
/// Event sent after a mouse release event has been processed, but before emitting needUpdate() | ||
void onMouseRelease( QMouseEvent* event ); | ||
/// Event sent after a mouse move event has been processed, but before emitting needUpdate() | ||
void onMouseMove( QMouseEvent* event ); |
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.
void onMouseMove( QMouseEvent* event ); | |
[[deprecated]] void onMouseMove( QMouseEvent* event ); |
Sure, but as thereis no demo nor publicly available source code that use this, we need to prevent users to do it until a better solution is implemented (what was requested is a method similar to key-event propagation) but with more questions about how to manage the priority between colliding events (if the client want to manage the same mouse event than the viewer, who takes the priority ?). And for me, deprecated does not mean there is another way to do it right now but that this will be removed without notifications in the future, e.g. when a better alternative is available or when the functionality will become useless. |
[Gui] Propage Mouse events using Qt signals
Be aware that the PR request cannot be accepted if it doesn't pass the Continuous Integration tests.
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Feature
What is the current behavior? (You can also link to an open issue here)
Mouse events are handled by the viewer and its inheriting classes
What is the new behavior (if this is a feature change)?
Mouse events are propagated through QT signals, which allows to use them in plugins
Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
No
Other information: