forked from qt-creator/qt-creator
QmlDesigner: Add the ability to modify the animation range
Add the ability to modify the animation range from the curve editor Fix a synchronization issue between timeline and curve editor when the animation contains pinned curves Change-Id: I89dda234063259f41d662749d696f5fc8a04f988 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
0f60f120d2
commit
5b000d17cb
@@ -48,15 +48,18 @@ CurveEditor::CurveEditor(CurveEditorModel *model, QWidget *parent)
|
||||
splitter->setStretchFactor(1, 2);
|
||||
|
||||
auto *box = new QVBoxLayout;
|
||||
box->addWidget(createToolBar());
|
||||
box->addWidget(createToolBar(model));
|
||||
box->addWidget(splitter);
|
||||
setLayout(box);
|
||||
|
||||
connect(m_tree, &TreeView::treeItemLocked, m_view, &GraphicsView::setLocked);
|
||||
connect(m_tree->selectionModel(), &SelectionModel::curvesSelected, m_view, &GraphicsView::reset);
|
||||
|
||||
connect(m_tree, &TreeView::treeItemLocked, model, &CurveEditorModel::curveChanged);
|
||||
connect(m_tree, &TreeView::treeItemPinned, model, &CurveEditorModel::curveChanged);
|
||||
|
||||
connect(m_tree, &TreeView::treeItemLocked, m_view, &GraphicsView::setLocked);
|
||||
connect(m_tree->selectionModel(),
|
||||
&SelectionModel::curvesSelected,
|
||||
m_view,
|
||||
&GraphicsView::updateSelection);
|
||||
}
|
||||
|
||||
void CurveEditor::zoomX(double zoom)
|
||||
@@ -74,7 +77,7 @@ void CurveEditor::clearCanvas()
|
||||
m_view->reset({});
|
||||
}
|
||||
|
||||
QToolBar *CurveEditor::createToolBar()
|
||||
QToolBar *CurveEditor::createToolBar(CurveEditorModel *model)
|
||||
{
|
||||
auto *bar = new QToolBar;
|
||||
bar->setFloatable(false);
|
||||
@@ -111,8 +114,38 @@ QToolBar *CurveEditor::createToolBar()
|
||||
bar->addWidget(valueWidget);
|
||||
|
||||
auto *durationBox = new QHBoxLayout;
|
||||
durationBox->addWidget(new QLabel(tr("Duration")));
|
||||
durationBox->addWidget(new QSpinBox);
|
||||
auto *startSpin = new QSpinBox;
|
||||
auto *endSpin = new QSpinBox;
|
||||
|
||||
startSpin->setRange(std::numeric_limits<int>::lowest(), std::numeric_limits<int>::max());
|
||||
startSpin->setValue(model->minimumTime());
|
||||
|
||||
auto updateStartFrame = [this, model](int frame) {
|
||||
model->setMinimumTime(frame, false);
|
||||
m_view->viewport()->update();
|
||||
};
|
||||
connect(startSpin, QOverload<int>::of(&QSpinBox::valueChanged), updateStartFrame);
|
||||
|
||||
endSpin->setRange(std::numeric_limits<int>::lowest(), std::numeric_limits<int>::max());
|
||||
endSpin->setValue(model->maximumTime());
|
||||
|
||||
auto updateEndFrame = [this, model](int frame) {
|
||||
model->setMaximumTime(frame, false);
|
||||
m_view->viewport()->update();
|
||||
};
|
||||
connect(endSpin, QOverload<int>::of(&QSpinBox::valueChanged), updateEndFrame);
|
||||
|
||||
auto setStartSlot = [startSpin](int frame) { startSpin->setValue(frame); };
|
||||
connect(model, &CurveEditorModel::updateStartFrame, setStartSlot);
|
||||
|
||||
auto setEndSlot = [endSpin](int frame) { endSpin->setValue(frame); };
|
||||
connect(model, &CurveEditorModel::updateEndFrame, setEndSlot);
|
||||
|
||||
durationBox->addWidget(new QLabel(tr("Start Frame")));
|
||||
durationBox->addWidget(startSpin);
|
||||
durationBox->addWidget(new QLabel(tr("End Frame")));
|
||||
durationBox->addWidget(endSpin);
|
||||
|
||||
auto *durationWidget = new QWidget;
|
||||
durationWidget->setLayout(durationBox);
|
||||
bar->addWidget(durationWidget);
|
||||
|
||||
Reference in New Issue
Block a user