forked from qt-creator/qt-creator
Improve stability of the curve editor
- Clear the CurveEditor when deleting a timeline - Prevent value-axis computation with invalid values - Prevent invalid values when animation curves contain one keyframe only - Set the dirty flag when deleting a keyframe in order to properly delete it - Fix autoscrolling for the timeline editor Fixes: QDS-4115 Fixes: QDS-4081 Fixes: QDS-4080 Fixes: QDS-3251 Change-Id: I3bc8406ac57f30b16bccc2e1c164a84502de7750 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -93,6 +93,11 @@ AnimationCurve::AnimationCurve(const QEasingCurve &easing, const QPointF &start,
|
||||
analyze();
|
||||
}
|
||||
|
||||
bool AnimationCurve::isEmpty() const
|
||||
{
|
||||
return m_frames.empty();
|
||||
}
|
||||
|
||||
bool AnimationCurve::isValid() const
|
||||
{
|
||||
return m_frames.size() >= 2;
|
||||
@@ -352,45 +357,43 @@ void AnimationCurve::insert(double time)
|
||||
|
||||
void AnimationCurve::analyze()
|
||||
{
|
||||
if (isValid()) {
|
||||
m_minY = std::numeric_limits<double>::max();
|
||||
m_maxY = std::numeric_limits<double>::lowest();
|
||||
m_minY = std::numeric_limits<double>::max();
|
||||
m_maxY = std::numeric_limits<double>::lowest();
|
||||
|
||||
auto byTime = [](const auto &a, const auto &b) {
|
||||
return a.position().x() < b.position().x();
|
||||
};
|
||||
std::sort(m_frames.begin(), m_frames.end(), byTime);
|
||||
auto byTime = [](const auto &a, const auto &b) {
|
||||
return a.position().x() < b.position().x();
|
||||
};
|
||||
std::sort(m_frames.begin(), m_frames.end(), byTime);
|
||||
|
||||
for (auto e : extrema()) {
|
||||
if (m_minY > e.y())
|
||||
m_minY = e.y();
|
||||
for (auto e : extrema()) {
|
||||
if (m_minY > e.y())
|
||||
m_minY = e.y();
|
||||
|
||||
if (m_maxY < e.y())
|
||||
m_maxY = e.y();
|
||||
if (m_maxY < e.y())
|
||||
m_maxY = e.y();
|
||||
}
|
||||
|
||||
for (auto &frame : qAsConst(m_frames)) {
|
||||
if (frame.position().y() < m_minY)
|
||||
m_minY = frame.position().y();
|
||||
|
||||
if (frame.position().y() > m_maxY)
|
||||
m_maxY = frame.position().y();
|
||||
|
||||
if (frame.hasLeftHandle()) {
|
||||
if (frame.leftHandle().y() < m_minY)
|
||||
m_minY = frame.leftHandle().y();
|
||||
|
||||
if (frame.leftHandle().y() > m_maxY)
|
||||
m_maxY = frame.leftHandle().y();
|
||||
}
|
||||
|
||||
for (auto &frame : qAsConst(m_frames)) {
|
||||
if (frame.position().y() < m_minY)
|
||||
m_minY = frame.position().y();
|
||||
if (frame.hasRightHandle()) {
|
||||
if (frame.rightHandle().y() < m_minY)
|
||||
m_minY = frame.rightHandle().y();
|
||||
|
||||
if (frame.position().y() > m_maxY)
|
||||
m_maxY = frame.position().y();
|
||||
|
||||
if (frame.hasLeftHandle()) {
|
||||
if (frame.leftHandle().y() < m_minY)
|
||||
m_minY = frame.leftHandle().y();
|
||||
|
||||
if (frame.leftHandle().y() > m_maxY)
|
||||
m_maxY = frame.leftHandle().y();
|
||||
}
|
||||
|
||||
if (frame.hasRightHandle()) {
|
||||
if (frame.rightHandle().y() < m_minY)
|
||||
m_minY = frame.rightHandle().y();
|
||||
|
||||
if (frame.rightHandle().y() > m_maxY)
|
||||
m_maxY = frame.rightHandle().y();
|
||||
}
|
||||
if (frame.rightHandle().y() > m_maxY)
|
||||
m_maxY = frame.rightHandle().y();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user