forked from qt-creator/qt-creator
Make sure to neither load nor store invalid qeasing-curves
Remove set-value-spinbox. Do not convert single-segment-qeasing-curves to bezier if they would become invalid. Do not store invalid qeasing-curves in the keyframe ModelNode. Make sure that a conversion does not produce nans Change-Id: I0688de55bf6b0ef6fe69d70d9192d852c8d6b895 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -106,13 +106,6 @@ QToolBar *CurveEditor::createToolBar(CurveEditorModel *model)
|
|||||||
Q_UNUSED(tangentStepAction);
|
Q_UNUSED(tangentStepAction);
|
||||||
Q_UNUSED(tangentDefaultAction);
|
Q_UNUSED(tangentDefaultAction);
|
||||||
|
|
||||||
auto *valueBox = new QHBoxLayout;
|
|
||||||
valueBox->addWidget(new QLabel(tr("Value")));
|
|
||||||
valueBox->addWidget(new QDoubleSpinBox);
|
|
||||||
auto *valueWidget = new QWidget;
|
|
||||||
valueWidget->setLayout(valueBox);
|
|
||||||
bar->addWidget(valueWidget);
|
|
||||||
|
|
||||||
auto *durationBox = new QHBoxLayout;
|
auto *durationBox = new QHBoxLayout;
|
||||||
auto *startSpin = new QSpinBox;
|
auto *startSpin = new QSpinBox;
|
||||||
auto *endSpin = new QSpinBox;
|
auto *endSpin = new QSpinBox;
|
||||||
|
|||||||
@@ -150,7 +150,18 @@ CurveSegment::CurveSegment(const Keyframe &left, const Keyframe &right)
|
|||||||
|
|
||||||
bool CurveSegment::isValid() const
|
bool CurveSegment::isValid() const
|
||||||
{
|
{
|
||||||
return m_left.position() != m_right.position();
|
if (m_left.position() == m_right.position())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (interpolation() == Keyframe::Interpolation::Undefined)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (interpolation() == Keyframe::Interpolation::Easing
|
||||||
|
|| interpolation() == Keyframe::Interpolation::Bezier) {
|
||||||
|
if (qFuzzyCompare(m_left.position().y(), m_right.position().y()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CurveSegment::containsX(double x) const
|
bool CurveSegment::containsX(double x) const
|
||||||
@@ -263,6 +274,10 @@ QEasingCurve CurveSegment::easingCurve() const
|
|||||||
auto mapPosition = [this](const QPointF &position) {
|
auto mapPosition = [this](const QPointF &position) {
|
||||||
QPointF min = m_left.position();
|
QPointF min = m_left.position();
|
||||||
QPointF max = m_right.position();
|
QPointF max = m_right.position();
|
||||||
|
if (qFuzzyCompare(min.y(), max.y()))
|
||||||
|
return QPointF((position.x() - min.x()) / (max.x() - min.x()),
|
||||||
|
(position.y() - min.y()) / (max.y()));
|
||||||
|
|
||||||
return QPointF((position.x() - min.x()) / (max.x() - min.x()),
|
return QPointF((position.x() - min.x()) / (max.x() - min.x()),
|
||||||
(position.y() - min.y()) / (max.y() - min.y()));
|
(position.y() - min.y()) / (max.y() - min.y()));
|
||||||
};
|
};
|
||||||
@@ -270,8 +285,7 @@ QEasingCurve CurveSegment::easingCurve() const
|
|||||||
QEasingCurve curve;
|
QEasingCurve curve;
|
||||||
curve.addCubicBezierSegment(mapPosition(m_left.rightHandle()),
|
curve.addCubicBezierSegment(mapPosition(m_left.rightHandle()),
|
||||||
mapPosition(m_right.leftHandle()),
|
mapPosition(m_right.leftHandle()),
|
||||||
mapPosition(m_right.position()));
|
QPointF(1., 1.));
|
||||||
|
|
||||||
return curve;
|
return curve;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,8 @@
|
|||||||
#include "qmltimeline.h"
|
#include "qmltimeline.h"
|
||||||
|
|
||||||
#include <bindingproperty.h>
|
#include <bindingproperty.h>
|
||||||
#include <variantproperty.h>
|
|
||||||
#include <theme.h>
|
#include <theme.h>
|
||||||
|
#include <variantproperty.h>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -204,6 +204,7 @@ std::vector<DesignTools::Keyframe> resolveSmallCurves(
|
|||||||
for (auto &&frame : frames) {
|
for (auto &&frame : frames) {
|
||||||
if (frame.hasData() && !out.empty()) {
|
if (frame.hasData() && !out.empty()) {
|
||||||
QEasingCurve curve = frame.data().toEasingCurve();
|
QEasingCurve curve = frame.data().toEasingCurve();
|
||||||
|
// One-segment-curve: Since (0,0) is implicit => 3
|
||||||
if (curve.toCubicSpline().count() == 3) {
|
if (curve.toCubicSpline().count() == 3) {
|
||||||
DesignTools::Keyframe &previous = out.back();
|
DesignTools::Keyframe &previous = out.back();
|
||||||
#if 0
|
#if 0
|
||||||
|
|||||||
@@ -355,6 +355,7 @@ void TimelineWidget::updateAnimationCurve(DesignTools::PropertyTreeItem *item)
|
|||||||
if (previous.isValid()) {
|
if (previous.isValid()) {
|
||||||
if (frame.interpolation() == DesignTools::Keyframe::Interpolation::Bezier) {
|
if (frame.interpolation() == DesignTools::Keyframe::Interpolation::Bezier) {
|
||||||
DesignTools::CurveSegment segment(previous, frame);
|
DesignTools::CurveSegment segment(previous, frame);
|
||||||
|
if (segment.isValid())
|
||||||
attachEasingCurve(pos.x(), segment.easingCurve(), group);
|
attachEasingCurve(pos.x(), segment.easingCurve(), group);
|
||||||
} else if (frame.interpolation()
|
} else if (frame.interpolation()
|
||||||
== DesignTools::Keyframe::Interpolation::Easing) {
|
== DesignTools::Keyframe::Interpolation::Easing) {
|
||||||
|
|||||||
Reference in New Issue
Block a user