Skip to content

Commit 0fdd954

Browse files
committed
Align razor icon with mouse position hotspot in QCursor (qwidget timeline backend). It was offset incorrectly, so the dotted line was not aligned with the actual cursor position, thus cutting in the wrong place.
1 parent ff1362d commit 0fdd954

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/tests/test_timeline_helpers.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
sys.path.append(PATH)
4343

4444
from PyQt5.QtCore import QCoreApplication, QPointF, QRectF, Qt
45-
from PyQt5.QtGui import QColor
45+
from PyQt5.QtGui import QColor, QCursor
4646
from PyQt5.QtWidgets import QApplication
4747
from classes import info
4848
from classes.updates import UpdateAction
@@ -1804,6 +1804,15 @@ def test_qwidget_cursor_uses_razor_cursor_for_items_when_enabled(self):
18041804
self.assertIs(helper.cursor_value, helper.cursors["razor"])
18051805
self.assertFalse(helper.unset_cursor_called)
18061806

1807+
def test_qwidget_razor_cursor_hotspot_matches_web_alignment(self):
1808+
helper = types.SimpleNamespace()
1809+
1810+
cursor = self.qwidget_base_module.TimelineWidgetBase._load_razor_cursor(helper)
1811+
1812+
self.assertIsInstance(cursor, QCursor)
1813+
self.assertEqual(cursor.hotSpot().x(), 0)
1814+
self.assertEqual(cursor.hotSpot().y(), 2)
1815+
18071816
def test_qwidget_cursor_keeps_hand_cursor_for_items_when_razor_disabled(self):
18081817
helper = self.make_qwidget_cursor_helper()
18091818
helper.geometry.items = [(QRectF(0.0, 0.0, 100.0, 20.0), object(), False, "clip")]

src/windows/views/timeline_backend/qwidget/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,9 @@ def _load_razor_cursor(self):
731731
pixmap = QPixmap(asset_path)
732732
if pixmap.isNull():
733733
return QCursor(Qt.CrossCursor)
734-
hot_x = min(max(pixmap.width() // 2, 0), max(0, pixmap.width() - 1))
734+
# Match the web timeline hotspot, which uses the asset's top-left
735+
# corner as the active cursor position.
736+
hot_x = 0
735737
hot_y = min(2, max(0, pixmap.height() - 1))
736738
return QCursor(pixmap, hot_x, hot_y)
737739

0 commit comments

Comments
 (0)