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) {
|
if (curve.toCubicSpline().count() == 3) {
|
||||||
DesignTools::Keyframe &previous = out.back();
|
DesignTools::Keyframe &previous = out.back();
|
||||||
DesignTools::AnimationCurve acurve(curve, previous.position(), frame.position());
|
DesignTools::AnimationCurve acurve(curve, previous.position(), frame.position());
|
||||||
previous = acurve.keyframeAt(0);
|
previous.setRightHandle(acurve.keyframeAt(0).rightHandle());
|
||||||
out.push_back(acurve.keyframeAt(1));
|
out.push_back(acurve.keyframeAt(1));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -29,12 +29,14 @@
|
|||||||
#include "timelinegraphicsscene.h"
|
#include "timelinegraphicsscene.h"
|
||||||
#include "timelineicons.h"
|
#include "timelineicons.h"
|
||||||
|
|
||||||
|
#include "timelineview.h"
|
||||||
#include "timelinewidget.h"
|
#include "timelinewidget.h"
|
||||||
|
|
||||||
#include <designeractionmanager.h>
|
#include <designeractionmanager.h>
|
||||||
#include <nodelistproperty.h>
|
#include <nodelistproperty.h>
|
||||||
#include <theme.h>
|
#include <theme.h>
|
||||||
#include <variantproperty.h>
|
#include <variantproperty.h>
|
||||||
|
#include <qmlstate.h>
|
||||||
#include <qmltimeline.h>
|
#include <qmltimeline.h>
|
||||||
#include <qmltimelinekeyframegroup.h>
|
#include <qmltimelinekeyframegroup.h>
|
||||||
|
|
||||||
@@ -125,6 +127,8 @@ void TimelineToolBar::reset()
|
|||||||
{
|
{
|
||||||
if (recording())
|
if (recording())
|
||||||
m_recording->setChecked(false);
|
m_recording->setChecked(false);
|
||||||
|
|
||||||
|
m_curveModel->reset({});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TimelineToolBar::recording() const
|
bool TimelineToolBar::recording() const
|
||||||
@@ -222,6 +226,13 @@ void TimelineToolBar::removeTimeline(const QmlTimeline &timeline)
|
|||||||
|
|
||||||
void TimelineToolBar::openAnimationCurveEditor()
|
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();
|
m_dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -106,6 +106,7 @@ void TimelineView::nodeAboutToBeRemoved(const ModelNode &removedNode)
|
|||||||
m_timelineWidget->graphicsScene()->clearTimeline();
|
m_timelineWidget->graphicsScene()->clearTimeline();
|
||||||
if (lastId != currentId)
|
if (lastId != currentId)
|
||||||
m_timelineWidget->setTimelineId(currentId);
|
m_timelineWidget->setTimelineId(currentId);
|
||||||
|
|
||||||
} else if (removedNode.parentProperty().isValid()
|
} else if (removedNode.parentProperty().isValid()
|
||||||
&& QmlTimeline::isValidQmlTimeline(
|
&& QmlTimeline::isValidQmlTimeline(
|
||||||
removedNode.parentProperty().parentModelNode())) {
|
removedNode.parentProperty().parentModelNode())) {
|
||||||
@@ -136,6 +137,10 @@ void TimelineView::nodeRemoved(const ModelNode & /*removedNode*/,
|
|||||||
parentProperty.parentModelNode())) {
|
parentProperty.parentModelNode())) {
|
||||||
QmlTimelineKeyframeGroup frames(parentProperty.parentModelNode());
|
QmlTimelineKeyframeGroup frames(parentProperty.parentModelNode());
|
||||||
m_timelineWidget->graphicsScene()->invalidateSectionForTarget(frames.target());
|
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());
|
QmlTimelineKeyframeGroup frames(newPropertyParent.parentModelNode());
|
||||||
m_timelineWidget->graphicsScene()->invalidateSectionForTarget(frames.target());
|
m_timelineWidget->graphicsScene()->invalidateSectionForTarget(frames.target());
|
||||||
|
|
||||||
QmlTimeline currentTimeline = m_timelineWidget->graphicsScene()->currentTimeline();
|
if (propertyChange == AbstractView::NoAdditionalChanges)
|
||||||
if (currentTimeline.isValid() && propertyChange == AbstractView::NoAdditionalChanges)
|
updateAnimationCurveEditor();
|
||||||
m_timelineWidget->toolBar()->setCurrentTimeline(currentTimeline);
|
|
||||||
|
|
||||||
} else if (QmlTimelineKeyframeGroup::checkKeyframesType(
|
} else if (QmlTimelineKeyframeGroup::checkKeyframesType(
|
||||||
node)) { /* During copy and paste type info might be incomplete */
|
node)) { /* During copy and paste type info might be incomplete */
|
||||||
QmlTimelineKeyframeGroup frames(node);
|
QmlTimelineKeyframeGroup frames(node);
|
||||||
m_timelineWidget->graphicsScene()->invalidateSectionForTarget(frames.target());
|
m_timelineWidget->graphicsScene()->invalidateSectionForTarget(frames.target());
|
||||||
|
updateAnimationCurveEditor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,10 +199,7 @@ void TimelineView::variantPropertiesChanged(const QList<VariantProperty> &proper
|
|||||||
if (QmlTimelineKeyframeGroup::isValidQmlTimelineKeyframeGroup(framesNode)) {
|
if (QmlTimelineKeyframeGroup::isValidQmlTimelineKeyframeGroup(framesNode)) {
|
||||||
QmlTimelineKeyframeGroup frames(framesNode);
|
QmlTimelineKeyframeGroup frames(framesNode);
|
||||||
m_timelineWidget->graphicsScene()->invalidateKeyframesForTarget(frames.target());
|
m_timelineWidget->graphicsScene()->invalidateKeyframesForTarget(frames.target());
|
||||||
|
updateAnimationCurveEditor();
|
||||||
QmlTimeline currentTimeline = m_timelineWidget->graphicsScene()->currentTimeline();
|
|
||||||
if (currentTimeline.isValid())
|
|
||||||
m_timelineWidget->toolBar()->setCurrentTimeline(currentTimeline);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,9 +211,7 @@ void TimelineView::bindingPropertiesChanged(const QList<BindingProperty> &proper
|
|||||||
Q_UNUSED(propertyChange)
|
Q_UNUSED(propertyChange)
|
||||||
for (const auto &property : propertyList) {
|
for (const auto &property : propertyList) {
|
||||||
if (property.name() == "easing.bezierCurve") {
|
if (property.name() == "easing.bezierCurve") {
|
||||||
QmlTimeline currentTimeline = m_timelineWidget->graphicsScene()->currentTimeline();
|
updateAnimationCurveEditor();
|
||||||
if (currentTimeline.isValid())
|
|
||||||
m_timelineWidget->toolBar()->setCurrentTimeline(currentTimeline);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,8 +242,10 @@ void TimelineView::propertiesRemoved(const QList<AbstractProperty> &propertyList
|
|||||||
property.parentModelNode())) {
|
property.parentModelNode())) {
|
||||||
QmlTimelineKeyframeGroup frames(property.parentModelNode());
|
QmlTimelineKeyframeGroup frames(property.parentModelNode());
|
||||||
m_timelineWidget->graphicsScene()->invalidateSectionForTarget(frames.target());
|
m_timelineWidget->graphicsScene()->invalidateSectionForTarget(frames.target());
|
||||||
|
updateAnimationCurveEditor();
|
||||||
} else if (QmlTimeline::isValidQmlTimeline(property.parentModelNode())) {
|
} else if (QmlTimeline::isValidQmlTimeline(property.parentModelNode())) {
|
||||||
m_timelineWidget->graphicsScene()->invalidateScene();
|
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
|
} // namespace QmlDesigner
|
||||||
|
@@ -95,6 +95,7 @@ public:
|
|||||||
QmlModelState stateForTimeline(const QmlTimeline &timeline);
|
QmlModelState stateForTimeline(const QmlTimeline &timeline);
|
||||||
|
|
||||||
void registerActions();
|
void registerActions();
|
||||||
|
void updateAnimationCurveEditor();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TimelineWidget *createWidget();
|
TimelineWidget *createWidget();
|
||||||
|
@@ -441,7 +441,6 @@ void TimelineWidget::invalidateTimelineDuration(const QmlTimeline &timeline)
|
|||||||
if (timelineView() && timelineView()->model()) {
|
if (timelineView() && timelineView()->model()) {
|
||||||
QmlTimeline currentTimeline = graphicsScene()->currentTimeline();
|
QmlTimeline currentTimeline = graphicsScene()->currentTimeline();
|
||||||
if (currentTimeline.isValid() && currentTimeline == timeline) {
|
if (currentTimeline.isValid() && currentTimeline == timeline) {
|
||||||
m_toolbar->setCurrentTimeline(timeline);
|
|
||||||
graphicsScene()->setTimeline(timeline);
|
graphicsScene()->setTimeline(timeline);
|
||||||
graphicsScene()->setCurrenFrame(timeline, getcurrentFrame(timeline));
|
graphicsScene()->setCurrenFrame(timeline, getcurrentFrame(timeline));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user