From 431a98cf33045614942a63e7656133e99ef66f80 Mon Sep 17 00:00:00 2001 From: Rodney Date: Jan 28 2020 13:24:15 +0000 Subject: Merge pull request #3071 from shun-iwasawa/fix_curvefx_crash Fix CurveFx Crash --- diff --git a/stuff/config/qss/Blue/Blue.qss b/stuff/config/qss/Blue/Blue.qss index 47c282a..4028b67 100644 --- a/stuff/config/qss/Blue/Blue.qss +++ b/stuff/config/qss/Blue/Blue.qss @@ -1630,6 +1630,9 @@ FxSettings QToolBar QToolBar { #FxSettingsHelpButton:hover { background-color: #a8bee7; } +ChannelBar { + qproperty-TextColor: #d6d8dd; +} /* ----------------------------------------------------------------------------- Script Console ----------------------------------------------------------------------------- */ diff --git a/stuff/config/qss/Dark/Dark.qss b/stuff/config/qss/Dark/Dark.qss index ef3d4f4..e266321 100644 --- a/stuff/config/qss/Dark/Dark.qss +++ b/stuff/config/qss/Dark/Dark.qss @@ -1630,6 +1630,9 @@ FxSettings QToolBar QToolBar { #FxSettingsHelpButton:hover { background-color: #a8bee7; } +ChannelBar { + qproperty-TextColor: #e9e9e9; +} /* ----------------------------------------------------------------------------- Script Console ----------------------------------------------------------------------------- */ diff --git a/stuff/config/qss/Default/Default.qss b/stuff/config/qss/Default/Default.qss index ca571b0..3e4834f 100644 --- a/stuff/config/qss/Default/Default.qss +++ b/stuff/config/qss/Default/Default.qss @@ -1630,6 +1630,9 @@ FxSettings QToolBar QToolBar { #FxSettingsHelpButton:hover { background-color: #a8bee7; } +ChannelBar { + qproperty-TextColor: #e6e6e6; +} /* ----------------------------------------------------------------------------- Script Console ----------------------------------------------------------------------------- */ diff --git a/stuff/config/qss/Default/less/layouts/schematic.less b/stuff/config/qss/Default/less/layouts/schematic.less index 689b137..72cc359 100644 --- a/stuff/config/qss/Default/less/layouts/schematic.less +++ b/stuff/config/qss/Default/less/layouts/schematic.less @@ -115,3 +115,7 @@ FxSettings { #FxSettingsPreviewShowButton { &:extend(.button-show all); } + +ChannelBar { + qproperty-TextColor: @text-color; +} \ No newline at end of file diff --git a/stuff/config/qss/Light/Light.qss b/stuff/config/qss/Light/Light.qss index aa68d45..6c830a1 100644 --- a/stuff/config/qss/Light/Light.qss +++ b/stuff/config/qss/Light/Light.qss @@ -1631,6 +1631,9 @@ FxSettings QToolBar QToolBar { #FxSettingsHelpButton:hover { background-color: #a8bee7; } +ChannelBar { + qproperty-TextColor: #000; +} /* ----------------------------------------------------------------------------- Script Console ----------------------------------------------------------------------------- */ diff --git a/toonz/sources/include/toonzqt/histogram.h b/toonz/sources/include/toonzqt/histogram.h index 307c051..7034a9b 100644 --- a/toonz/sources/include/toonzqt/histogram.h +++ b/toonz/sources/include/toonzqt/histogram.h @@ -80,6 +80,10 @@ class DVAPI ChannelBar final : public QWidget { bool m_isHorizontal; bool m_drawNumbers; + + QColor m_textColor; + + Q_PROPERTY(QColor TextColor READ getTextColor WRITE setTextColor) public: ChannelBar(QWidget *parent = 0, QColor m_color = QColor(), @@ -93,6 +97,8 @@ public: void draw(QPainter *painter, QPoint translation = QPoint(0, 0)); + void setTextColor(const QColor &color) { m_textColor = color; } + QColor getTextColor() const { return m_textColor; } protected: void paintEvent(QPaintEvent *event) override; }; diff --git a/toonz/sources/toonzqt/histogram.cpp b/toonz/sources/toonzqt/histogram.cpp index 15518b8..a215b65 100644 --- a/toonz/sources/toonzqt/histogram.cpp +++ b/toonz/sources/toonzqt/histogram.cpp @@ -314,7 +314,7 @@ void ChannelBar::draw(QPainter *p, QPoint translation) { p->setBrush(QBrush(linearGrad)); - p->setPen(Qt::black); + p->setPen(getTextColor()); p->drawRect(x0, y0, w - 1, h - 1); if (m_drawNumbers) { diff --git a/toonz/sources/toonzqt/tonecurvefield.cpp b/toonz/sources/toonzqt/tonecurvefield.cpp index 133a31d..a450976 100644 --- a/toonz/sources/toonzqt/tonecurvefield.cpp +++ b/toonz/sources/toonzqt/tonecurvefield.cpp @@ -363,6 +363,13 @@ void ChennelCurveEditor::moveCentralControlPoint(int index, setPoint(index + 2, getNewSecondHandlePoint(p, nextP, m_points.at(index + 2))); if (nextDistance < 0) d = QPointF(nextP.x() - p.x(), d.y()); + if (nextDistance < 16) { + double nextYDistance = nextP.y() - (p.y() + d.y()); + if (nextYDistance > -16 && nextYDistance < 16) { + double offset = nextYDistance > 0 ? -16 : +16; + d = QPointF(d.x(), nextP.y() - p.y() + offset); + } + } } // Caso particolare: Punto di controllo corrente == ultimo visibile, // Punto di controllo precedente @@ -375,6 +382,13 @@ void ChennelCurveEditor::moveCentralControlPoint(int index, setPoint(index - 1, getNewSecondHandlePoint(precP, p, m_points.at(index - 1))); if (precDistance < 0) d = QPointF(precP.x() - p.x(), d.y()); + if (precDistance < 16) { + double precYDistance = (p.y() + d.y()) - precP.y(); + if (precYDistance > -16 && precYDistance < 16) { + double offset = precYDistance > 0 ? 16 : -16; + d = QPointF(d.x(), precP.y() - p.y() + offset); + } + } } // Altrimenti calcolo il nuovo delta else if (nextDistance < 16) @@ -382,6 +396,8 @@ void ChennelCurveEditor::moveCentralControlPoint(int index, else if (precDistance < 16) d = QPointF(precP.x() - p.x() + 16, d.y()); + if (d.isNull()) return; + // Punto di controllo speciale: il primo visualizzato. if (index == 3) { QPointF dY = QPointF(0, d.y()); @@ -674,17 +690,8 @@ void ChennelCurveEditor::paintEvent(QPaintEvent *e) { else if (isCentralControlPoint(i) && i < n - 4) painter.drawLine(p, nextP); } - QPainterPath circle; QRectF pointRect(p.x() - rad, p.y() - rad, 2 * rad, 2 * rad); - if (r.contains(pointRect)) -#if QT_VERSION >= 0x050000 - painter.setClipRect(pointRect.adjusted(-1, -1, 1, 1)); -#else - painter.setClipRect(pointRect.adjusted(-1, -1, 1, 1), Qt::UniteClip); -#endif - circle.addEllipse(pointRect); - painter.fillPath(circle, brush); - painter.drawPath(circle); + painter.drawEllipse(pointRect); p = nextP; } }