forked from qt-creator/qt-creator
Update the animation-curve-editor properly
Change-Id: Idc055c81ecd97f2473594dcf6a45a904d6691436 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
58db759768
commit
6ae410754f
@@ -207,7 +207,7 @@ std::vector<DesignTools::Keyframe> resolveSmallCurves(
|
||||
if (curve.toCubicSpline().count() == 3) {
|
||||
DesignTools::Keyframe &previous = out.back();
|
||||
DesignTools::AnimationCurve acurve(curve, previous.position(), frame.position());
|
||||
previous = acurve.keyframeAt(0);
|
||||
previous.setRightHandle(acurve.keyframeAt(0).rightHandle());
|
||||
out.push_back(acurve.keyframeAt(1));
|
||||
continue;
|
||||
}
|
||||
|
@@ -29,12 +29,14 @@
|
||||
#include "timelinegraphicsscene.h"
|
||||
#include "timelineicons.h"
|
||||
|
||||
#include "timelineview.h"
|
||||
#include "timelinewidget.h"
|
||||
|
||||
#include <designeractionmanager.h>
|
||||
#include <nodelistproperty.h>
|
||||
#include <theme.h>
|
||||
#include <variantproperty.h>
|
||||
#include <qmlstate.h>
|
||||
#include <qmltimeline.h>
|
||||
#include <qmltimelinekeyframegroup.h>
|
||||
|
||||
@@ -125,6 +127,8 @@ void TimelineToolBar::reset()
|
||||
{
|
||||
if (recording())
|
||||
m_recording->setChecked(false);
|
||||
|
||||
m_curveModel->reset({});
|
||||
}
|
||||
|
||||
bool TimelineToolBar::recording() const
|
||||
@@ -222,6 +226,13 @@ void TimelineToolBar::removeTimeline(const QmlTimeline &timeline)
|
||||
|
||||
void TimelineToolBar::openAnimationCurveEditor()
|
||||
{
|
||||
QmlTimeline timeline;
|
||||
if (auto *tlw = qobject_cast<TimelineWidget *>(parent())) {
|
||||
if (auto *tlv = tlw->timelineView())
|
||||
timeline = tlv->timelineForState(tlv->currentState());
|
||||
}
|
||||
|
||||
m_curveModel->setTimeline(timeline);
|
||||
m_dialog.show();
|
||||
}
|
||||
|
||||
|
@@ -106,6 +106,7 @@ void TimelineView::nodeAboutToBeRemoved(const ModelNode &removedNode)
|
||||
m_timelineWidget->graphicsScene()->clearTimeline();
|
||||
if (lastId != currentId)
|
||||
m_timelineWidget->setTimelineId(currentId);
|
||||
|
||||
} else if (removedNode.parentProperty().isValid()
|
||||
&& QmlTimeline::isValidQmlTimeline(
|
||||
removedNode.parentProperty().parentModelNode())) {
|
||||
@@ -136,6 +137,10 @@ void TimelineView::nodeRemoved(const ModelNode & /*removedNode*/,
|
||||
parentProperty.parentModelNode())) {
|
||||
QmlTimelineKeyframeGroup frames(parentProperty.parentModelNode());
|
||||
m_timelineWidget->graphicsScene()->invalidateSectionForTarget(frames.target());
|
||||
updateAnimationCurveEditor();
|
||||
} else if (parentProperty.isValid()
|
||||
&& QmlTimeline::isValidQmlTimeline(parentProperty.parentModelNode())) {
|
||||
updateAnimationCurveEditor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,14 +155,14 @@ void TimelineView::nodeReparented(const ModelNode &node,
|
||||
QmlTimelineKeyframeGroup frames(newPropertyParent.parentModelNode());
|
||||
m_timelineWidget->graphicsScene()->invalidateSectionForTarget(frames.target());
|
||||
|
||||
QmlTimeline currentTimeline = m_timelineWidget->graphicsScene()->currentTimeline();
|
||||
if (currentTimeline.isValid() && propertyChange == AbstractView::NoAdditionalChanges)
|
||||
m_timelineWidget->toolBar()->setCurrentTimeline(currentTimeline);
|
||||
if (propertyChange == AbstractView::NoAdditionalChanges)
|
||||
updateAnimationCurveEditor();
|
||||
|
||||
} else if (QmlTimelineKeyframeGroup::checkKeyframesType(
|
||||
node)) { /* During copy and paste type info might be incomplete */
|
||||
QmlTimelineKeyframeGroup frames(node);
|
||||
m_timelineWidget->graphicsScene()->invalidateSectionForTarget(frames.target());
|
||||
updateAnimationCurveEditor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,10 +199,7 @@ void TimelineView::variantPropertiesChanged(const QList<VariantProperty> &proper
|
||||
if (QmlTimelineKeyframeGroup::isValidQmlTimelineKeyframeGroup(framesNode)) {
|
||||
QmlTimelineKeyframeGroup frames(framesNode);
|
||||
m_timelineWidget->graphicsScene()->invalidateKeyframesForTarget(frames.target());
|
||||
|
||||
QmlTimeline currentTimeline = m_timelineWidget->graphicsScene()->currentTimeline();
|
||||
if (currentTimeline.isValid())
|
||||
m_timelineWidget->toolBar()->setCurrentTimeline(currentTimeline);
|
||||
updateAnimationCurveEditor();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -209,9 +211,7 @@ void TimelineView::bindingPropertiesChanged(const QList<BindingProperty> &proper
|
||||
Q_UNUSED(propertyChange)
|
||||
for (const auto &property : propertyList) {
|
||||
if (property.name() == "easing.bezierCurve") {
|
||||
QmlTimeline currentTimeline = m_timelineWidget->graphicsScene()->currentTimeline();
|
||||
if (currentTimeline.isValid())
|
||||
m_timelineWidget->toolBar()->setCurrentTimeline(currentTimeline);
|
||||
updateAnimationCurveEditor();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,8 +242,10 @@ void TimelineView::propertiesRemoved(const QList<AbstractProperty> &propertyList
|
||||
property.parentModelNode())) {
|
||||
QmlTimelineKeyframeGroup frames(property.parentModelNode());
|
||||
m_timelineWidget->graphicsScene()->invalidateSectionForTarget(frames.target());
|
||||
updateAnimationCurveEditor();
|
||||
} else if (QmlTimeline::isValidQmlTimeline(property.parentModelNode())) {
|
||||
m_timelineWidget->graphicsScene()->invalidateScene();
|
||||
updateAnimationCurveEditor();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -630,4 +632,16 @@ void TimelineView::ensureQtQuickTimelineImport()
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineView::updateAnimationCurveEditor()
|
||||
{
|
||||
if (!m_timelineWidget)
|
||||
return;
|
||||
|
||||
QmlTimeline currentTimeline = timelineForState(currentState());
|
||||
if (currentTimeline.isValid())
|
||||
m_timelineWidget->toolBar()->setCurrentTimeline(currentTimeline);
|
||||
else
|
||||
m_timelineWidget->toolBar()->reset();
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -95,6 +95,7 @@ public:
|
||||
QmlModelState stateForTimeline(const QmlTimeline &timeline);
|
||||
|
||||
void registerActions();
|
||||
void updateAnimationCurveEditor();
|
||||
|
||||
private:
|
||||
TimelineWidget *createWidget();
|
||||
|
@@ -441,7 +441,6 @@ void TimelineWidget::invalidateTimelineDuration(const QmlTimeline &timeline)
|
||||
if (timelineView() && timelineView()->model()) {
|
||||
QmlTimeline currentTimeline = graphicsScene()->currentTimeline();
|
||||
if (currentTimeline.isValid() && currentTimeline == timeline) {
|
||||
m_toolbar->setCurrentTimeline(timeline);
|
||||
graphicsScene()->setTimeline(timeline);
|
||||
graphicsScene()->setCurrenFrame(timeline, getcurrentFrame(timeline));
|
||||
}
|
||||
|
Reference in New Issue
Block a user