QmlDesigner: Improve usability of boolean animation curves

Boolean animation curves are now painted from min to max of the value range
instead of from 0 to 1. This allows to see value changes when the curve is
loaded together with other animation curves of different value ranges.

Boolean curves are now forced to be step interpolated.
If the user tries other interpolation types the request is denied and an
error message is written in the new status line.

Added a status line that displays the current frame number by default and
an informative text in case the user did something forbidden.

Respect the current state when populating the curve editor.

Fixes: QDS-6950
Fixes: QDS-6889
Change-Id: Ia5fa1c1c55ee93eda5a39fd83987b54fb41d54db
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Knud Dollereder
2022-07-01 13:22:32 +02:00
parent b1975da9f7
commit 1df1a065de
18 changed files with 219 additions and 84 deletions

View File

@@ -42,6 +42,7 @@ namespace QmlDesigner {
CurveEditor::CurveEditor(CurveEditorModel *model, QWidget *parent)
: QWidget(parent)
, m_infoText(nullptr)
, m_statusLine(nullptr)
, m_toolbar(new CurveEditorToolBar(model, this))
, m_tree(new TreeView(model, this))
, m_view(new GraphicsView(model, this))
@@ -61,10 +62,13 @@ CurveEditor::CurveEditor(CurveEditorModel *model, QWidget *parent)
area->setWidget(splitter);
area->setWidgetResizable(true);
m_statusLine = new QLabel();
auto *box = new QVBoxLayout;
box->addWidget(m_infoText);
box->addWidget(m_toolbar);
box->addWidget(area);
box->addWidget(m_statusLine);
setLayout(box);
connect(m_toolbar, &CurveEditorToolBar::defaultClicked, [this]() {
@@ -89,9 +93,11 @@ CurveEditor::CurveEditor(CurveEditorModel *model, QWidget *parent)
m_view->viewport()->update();
});
connect(
m_toolbar, &CurveEditorToolBar::currentFrameChanged,
model, &CurveEditorModel::commitCurrentFrame);
connect(m_toolbar, &CurveEditorToolBar::currentFrameChanged, [this, model](int frame) {
model->setCurrentFrame(frame);
updateStatusLine();
m_view->viewport()->update();
});
connect(
m_view, &GraphicsView::currentFrameChanged,
@@ -106,6 +112,8 @@ CurveEditor::CurveEditor(CurveEditorModel *model, QWidget *parent)
auto updateTimeline = [this, model](bool validTimeline) {
if (validTimeline) {
updateStatusLine();
m_view->setCurrentFrame(m_view->model()->currentFrame(), false);
m_toolbar->updateBoundsSilent(model->minimumTime(), model->maximumTime());
m_toolbar->show();
m_tree->show();
@@ -119,6 +127,8 @@ CurveEditor::CurveEditor(CurveEditorModel *model, QWidget *parent)
}
};
connect(model, &CurveEditorModel::timelineChanged, this, updateTimeline);
connect(model, &CurveEditorModel::setStatusLineMsg, m_statusLine, &QLabel::setText);
}
bool CurveEditor::dragging() const
@@ -153,4 +163,11 @@ void CurveEditor::hideEvent(QHideEvent *event)
QWidget::hideEvent(event);
}
void CurveEditor::updateStatusLine()
{
int currentFrame = m_view->model()->currentFrame();
QString currentText = QString("Playhead frame %1").arg(currentFrame);
m_statusLine->setText(currentText);
}
} // End namespace QmlDesigner.