From 426f971dd22e6263aaff6e65b3aee16d6c2e49a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Gallet?= Date: Mon, 13 Nov 2023 21:24:29 +0100 Subject: [PATCH] Show another column preview --- src/program/ui/InputEditorModel.cpp | 38 ++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/program/ui/InputEditorModel.cpp b/src/program/ui/InputEditorModel.cpp index 7fecee28..5dde206e 100644 --- a/src/program/ui/InputEditorModel.cpp +++ b/src/program/ui/InputEditorModel.cpp @@ -143,13 +143,31 @@ QVariant InputEditorModel::data(const QModelIndex &index, int role) const } QColor color = QGuiApplication::palette().text().color(); + const SingleInput si = movie->editor->input_set[index.column()-COLUMN_SPECIAL_SIZE]; + + /* If hovering on the cell, show a preview of the input for the + * following: the cell is blank and not analog input */ + if (index.column() == hoveredIndex.column()) { + if (!si.isAnalog()) { + AllInputs ai; + movie->inputs->getInputs(ai, row); + int value = ai.getInput(si); + if (!value) { + if (index.row() == hoveredIndex.row()) + color.setAlpha(128); + else + color.setAlpha(32); + return QBrush(color); + } + } + } /* Show inputs with transparancy when they are pending due to rewind */ movie->inputs->input_event_queue.lock(); for (auto it = movie->inputs->input_event_queue.begin(); it != movie->inputs->input_event_queue.end(); it++) { if (it->framecount != row) continue; - const SingleInput si = movie->editor->input_set[index.column()-COLUMN_SPECIAL_SIZE]; + if (si == it->si) { /* For analog, use half-transparancy. Otherwise, * use strong/weak transparancy of set/clear input */ @@ -258,15 +276,6 @@ QVariant InputEditorModel::data(const QModelIndex &index, int role) const if (row < invalid_frame) color = color.darker(120); - /* Highlight current column */ - if (index.column() >= COLUMN_SPECIAL_SIZE && hoveredIndex.isValid() - && (index.column() == hoveredIndex.column())) { - if (lightTheme) - color = color.darker(105); - else - color = color.lighter(105); - } - return QBrush(color); } @@ -292,6 +301,10 @@ QVariant InputEditorModel::data(const QModelIndex &index, int role) const movie->inputs->getInputs(ai, row); const SingleInput si = movie->editor->input_set[index.column()-COLUMN_SPECIAL_SIZE]; + /* If hovering on the cell, show a preview of the input */ + if (index.column() == hoveredIndex.column() && (!si.isAnalog())) + return QString(si.description.c_str()); + /* Get the value of the single input in movie inputs */ int value = ai.getInput(si); @@ -1094,9 +1107,12 @@ void InputEditorModel::setScrollFreeze(bool state) void InputEditorModel::setHoveredCell(const QModelIndex &i) { + QVector roles(2, Qt::DisplayRole); + roles[1] = Qt::ForegroundRole; + const QModelIndex old = hoveredIndex; hoveredIndex = i; - emit dataChanged(index(0,old.column()), index(rowCount(),old.column()), QVector(1, Qt::BackgroundRole)); + emit dataChanged(index(0,old.column()), index(rowCount(),old.column()), roles); emit dataChanged(index(0,hoveredIndex.column()), index(rowCount(),hoveredIndex.column()), QVector(1, Qt::BackgroundRole)); emit headerDataChanged(Qt::Horizontal, old.column(), old.column()); emit headerDataChanged(Qt::Horizontal, hoveredIndex.column(), hoveredIndex.column());