Skip to content

Commit

Permalink
Overview: simply handling QMouseEvent position
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Oct 9, 2024
1 parent e2abcf9 commit 9a78a30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
24 changes: 4 additions & 20 deletions src/widget/woverview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,17 +488,9 @@ void WOverview::receiveCuesUpdated() {
void WOverview::mouseMoveEvent(QMouseEvent* e) {
if (m_bLeftClickDragging) {
if (m_orientation == Qt::Horizontal) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
m_iPickupPos = math_clamp(static_cast<int>(e->position().x()), 0, width() - 1);
#else
m_iPickupPos = math_clamp(e->x(), 0, width() - 1);
#endif
m_iPickupPos = math_clamp(e->pos().x(), 0, width() - 1);
} else {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
m_iPickupPos = math_clamp(static_cast<int>(e->position().y()), 0, height() - 1);
#else
m_iPickupPos = math_clamp(e->y(), 0, height() - 1);
#endif
m_iPickupPos = math_clamp(e->pos().y(), 0, height() - 1);
}
}

Expand Down Expand Up @@ -555,17 +547,9 @@ void WOverview::mousePressEvent(QMouseEvent* e) {
}
if (e->button() == Qt::LeftButton) {
if (m_orientation == Qt::Horizontal) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
m_iPickupPos = math_clamp(static_cast<int>(e->position().x()), 0, width() - 1);
#else
m_iPickupPos = math_clamp(e->x(), 0, width() - 1);
#endif
m_iPickupPos = math_clamp(e->pos().x(), 0, width() - 1);
} else {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
m_iPickupPos = math_clamp(static_cast<int>(e->position().y()), 0, height() - 1);
#else
m_iPickupPos = math_clamp(e->y(), 0, height() - 1);
#endif
m_iPickupPos = math_clamp(e->pos().y(), 0, height() - 1);
}

if (m_pHoveredMark != nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion src/widget/woverview.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ class WOverview : public WWidget, public TrackDropTarget {
QColor m_lowColor;
int m_dimBrightThreshold;
parented_ptr<QLabel> m_pPassthroughLabel;
QCursor m_dragAbortCursor;

WaveformMarkSet m_marks;
std::vector<WaveformMarkRange> m_markRanges;
WaveformMarkLabel m_cuePositionLabel;
WaveformMarkLabel m_cueTimeDistanceLabel;

};

0 comments on commit 9a78a30

Please sign in to comment.