-
Notifications
You must be signed in to change notification settings - Fork 100
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
Allow zoom with trackpad #1540
Allow zoom with trackpad #1540
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1540 +/- ##
===========================================
- Coverage 73.39% 73.39% -0.01%
===========================================
Files 134 134
Lines 23961 23961
===========================================
- Hits 17586 17585 -1
- Misses 6375 6376 +1
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
WalkthroughThe proposed changes primarily focus on refining the user interface and improving the user experience. They include minor adjustments such as removing empty lines and unnecessary conditions, as well as significant modifications related to zoom behavior, event handling, and graphical element manipulation. Changes
TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 0
Files selected for processing (2)
- sleap/gui/app.py (1 hunks)
- sleap/gui/widgets/video.py (11 hunks)
Files skipped from review due to trivial changes (1)
- sleap/gui/app.py
Additional comments (Suppressed): 3
sleap/gui/widgets/video.py (3)
- 1147-1152: The zoom factor limit has been changed from 1 to 8 and 0.2. Ensure that this change does not cause any unexpected behavior in the zoom functionality. Also, the condition for zooming has been changed from
event.buttons() == Qt.NoButton
toevent.modifiers() != Qt.AltModifier
. Verify that this change does not interfere with other functionalities that use the Alt key.- if event.buttons() == Qt.NoButton: + if event.modifiers() != Qt.AltModifier: angle = event.angleDelta().y() factor = 1.1 if angle > 0 else 0.9 - self.zoomFactor = max(factor * self.zoomFactor, 1) + self.zoomFactor = max(min(factor * self.zoomFactor, 8), 0.2) self.updateViewer()
- 1848-1851: The tuple unpacking in the for loop has been changed from parentheses to commas. This change is stylistic and does not affect the functionality of the code.
- for (node, point) in self.instance.nodes_points: + for node, point in self.instance.nodes_points: if point.visible or self.show_non_visible: node_item = QtNode( parent=self,
- 1863-1866: The tuple unpacking in the for loop has been changed from parentheses to commas. This change is stylistic and does not affect the functionality of the code.
- for (src, dst) in self.skeleton.edge_names: + for src, dst in self.skeleton.edge_names: # Make sure that both nodes are present in this instance before drawing edge if src in self.nodes and dst in self.nodes: edge_item = QtEdge(
@@ -1149,11 +1144,11 @@ def mouseDoubleClickEvent(self, event: QMouseEvent): | |||
def wheelEvent(self, event): | |||
"""Custom event handler. Zoom in/out based on scroll wheel change.""" | |||
# zoom on wheel when no mouse buttons are pressed | |||
if event.buttons() == Qt.NoButton: | |||
if event.modifiers() != Qt.AltModifier: |
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.
Maybe also check for Ctrl and Shift not being pressed so we don't have to rediscover this later if we add those shortcuts?
This needs to be revisited with a different approach |
Description
This PR allows zooming with the trackpad on a laptop. Zooming with the trackpad actually passes a MouseButton into the events.buttons(), so previously this was being passed over in the wheelEvent.
Now, we just check that the event modifier is not the Alt key (which is the only other action that uses the wheelEvent - for rotating an instance about a node).
Types of changes
Does this address any currently open issues?
Outside contributors checklist
Thank you for contributing to SLEAP!
❤️
Summary by CodeRabbit
sleap/gui/widgets/video.py
for improved code readability and maintainability.sleap/gui/widgets/video.py
to streamline the code.sleap/gui/widgets/video.py
for a more intuitive user experience.sleap/gui/widgets/video.py
for better UI consistency.