summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Gallet <clement.gallet@ens-lyon.org>2024-02-23 16:17:11 +0100
committerClément Gallet <clement.gallet@ens-lyon.org>2024-02-23 16:17:11 +0100
commit218e86aee865e930724d448ac5998b00e25df414 (patch)
tree1becc6b2473c6f16e71f51808136a1a1b28d4c49
parentb7f505a5b6be0130225892fe8938dd269b01df91 (diff)
Use right click + wheel down on input editor to frame advance (#594)
-rw-r--r--src/program/ConcurrentQueue.h5
-rw-r--r--src/program/GameEvents.cpp2
-rw-r--r--src/program/ui/InputEditorView.cpp27
-rw-r--r--src/program/ui/InputEditorView.h1
4 files changed, 34 insertions, 1 deletions
diff --git a/src/program/ConcurrentQueue.h b/src/program/ConcurrentQueue.h
index 591cbc3f..4860ebc5 100644
--- a/src/program/ConcurrentQueue.h
+++ b/src/program/ConcurrentQueue.h
@@ -69,6 +69,11 @@ public:
queue_.push_back(item);
}
+ const T& back(void)
+ {
+ return queue_.back();
+ }
+
ConcurrentQueue()=default;
ConcurrentQueue(const ConcurrentQueue&) = delete; // disable copying
ConcurrentQueue& operator=(const ConcurrentQueue&) = delete; // disable assignment
diff --git a/src/program/GameEvents.cpp b/src/program/GameEvents.cpp
index 4a58921c..436e7ffe 100644
--- a/src/program/GameEvents.cpp
+++ b/src/program/GameEvents.cpp
@@ -397,7 +397,7 @@ int GameEvents::handleEvent()
input_framecount = movie->inputs->processEvent();
}
}
- } while (eventType != EVENT_TYPE_NONE);
+ } while (eventType != EVENT_TYPE_NONE && !(flags & RETURN_FLAG_ADVANCE));
return flags;
}
diff --git a/src/program/ui/InputEditorView.cpp b/src/program/ui/InputEditorView.cpp
index ae3d5b7f..d83487b1 100644
--- a/src/program/ui/InputEditorView.cpp
+++ b/src/program/ui/InputEditorView.cpp
@@ -384,6 +384,22 @@ void InputEditorView::mouseDoubleClickEvent(QMouseEvent *event)
event->accept();
}
+void InputEditorView::wheelEvent(QWheelEvent *event)
+{
+ if (event->buttons() != Qt::RightButton)
+ return QTableView::wheelEvent(event);
+
+ if (event->angleDelta().y() < 0) {
+ /* Push a single frame advance event */
+ if (context->hotkey_pressed_queue.empty() || context->hotkey_pressed_queue.back() != HOTKEY_FRAMEADVANCE) {
+ context->hotkey_pressed_queue.push(HOTKEY_FRAMEADVANCE);
+ context->hotkey_released_queue.push(HOTKEY_FRAMEADVANCE);
+ }
+ }
+
+ event->accept();
+}
+
void InputEditorView::showMarkerToolTip(const QModelIndex &index)
{
/* Hide previous tooltip */
@@ -642,6 +658,17 @@ void InputEditorView::mainMenu(QPoint pos)
/* Storing the index of the section where context menu was shown */
// contextSection = inputEditorView->verticalHeader()->logicalIndexAt(pos);
+ /* Get the table cell under the mouse position */
+ const QModelIndex index = indexAt(pos);
+ if (!index.isValid()) {
+ return;
+ }
+
+ /* Disable context menu for non-frame columns */
+ if (index.column() != InputEditorModel::COLUMN_FRAME) {
+ return;
+ }
+
/* Display the context menu */
menu->popup(viewport()->mapToGlobal(pos));
}
diff --git a/src/program/ui/InputEditorView.h b/src/program/ui/InputEditorView.h
index fa9c6828..90190844 100644
--- a/src/program/ui/InputEditorView.h
+++ b/src/program/ui/InputEditorView.h
@@ -77,6 +77,7 @@ protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
+ void wheelEvent(QWheelEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;
void timerEvent(QTimerEvent* event) override;