Skip to content

Commit

Permalink
Show another column preview
Browse files Browse the repository at this point in the history
  • Loading branch information
clementgallet committed Nov 13, 2023
1 parent ac21475 commit 426f971
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions src/program/ui/InputEditorModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);

Expand Down Expand Up @@ -1094,9 +1107,12 @@ void InputEditorModel::setScrollFreeze(bool state)

void InputEditorModel::setHoveredCell(const QModelIndex &i)
{
QVector<int> 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<int>(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<int>(1, Qt::BackgroundRole));
emit headerDataChanged(Qt::Horizontal, old.column(), old.column());
emit headerDataChanged(Qt::Horizontal, hoveredIndex.column(), hoveredIndex.column());
Expand Down

0 comments on commit 426f971

Please sign in to comment.