From: Till Theato Date: Mon, 3 Jan 2011 19:43:16 +0000 (+0000) Subject: Bezier Spline: Add button to reset current spline (without affecting any other settings) X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=60e1b785f5b31dfd72003389bf69504820931cb5;p=kdenlive Bezier Spline: Add button to reset current spline (without affecting any other settings) svn path=/trunk/kdenlive/; revision=5255 --- diff --git a/src/beziercurve/beziersplineeditor.cpp b/src/beziercurve/beziersplineeditor.cpp index 2d85c676..50735c67 100644 --- a/src/beziercurve/beziersplineeditor.cpp +++ b/src/beziercurve/beziersplineeditor.cpp @@ -51,8 +51,13 @@ CubicBezierSpline BezierSplineEditor::spline() void BezierSplineEditor::setSpline(const CubicBezierSpline& spline) { - // TODO: cleanup - m_spline.fromString(spline.toString()); + int precision = m_spline.getPrecision(); + m_spline = spline; + m_spline.setPrecision(precision); + m_currentPointIndex = -1; + m_mode = ModeNormal; + emit modified(); + update(); } BPoint BezierSplineEditor::getCurrentPoint() @@ -228,7 +233,7 @@ void BezierSplineEditor::paintEvent(QPaintEvent* event) void BezierSplineEditor::resizeEvent(QResizeEvent* event) { - m_spline.setPrecision(width()); + m_spline.setPrecision(width() > height() ? width() : height()); m_pixmapIsDirty = true; QWidget::resizeEvent(event); } diff --git a/src/beziercurve/beziersplinewidget.cpp b/src/beziercurve/beziersplinewidget.cpp index b7f52f0d..695efbb9 100644 --- a/src/beziercurve/beziersplinewidget.cpp +++ b/src/beziercurve/beziersplinewidget.cpp @@ -40,6 +40,7 @@ BezierSplineWidget::BezierSplineWidget(const QString& spline, QWidget* parent) : m_ui.buttonZoomOut->setIcon(KIcon("zoom-out")); m_ui.buttonGridChange->setIcon(KIcon("view-grid")); m_ui.buttonShowPixmap->setIcon(QIcon(QPixmap::fromImage(ColorTools::rgbCurvePlane(QSize(16, 16), ColorTools::COL_Luma, 0.8)))); + m_ui.buttonResetSpline->setIcon(KIcon("view-refresh")); m_ui.widgetPoint->setEnabled(false); CubicBezierSpline s; @@ -60,6 +61,7 @@ BezierSplineWidget::BezierSplineWidget(const QString& spline, QWidget* parent) : connect(m_ui.buttonZoomOut, SIGNAL(clicked()), &m_edit, SLOT(slotZoomOut())); connect(m_ui.buttonGridChange, SIGNAL(clicked()), this, SLOT(slotGridChange())); connect(m_ui.buttonShowPixmap, SIGNAL(toggled(bool)), this, SLOT(slotShowPixmap(bool))); + connect(m_ui.buttonResetSpline, SIGNAL(clicked()), this, SLOT(slotResetSpline())); m_edit.setGridLines(KdenliveSettings::bezier_gridlines()); m_ui.buttonShowPixmap->setChecked(KdenliveSettings::bezier_showpixmap()); @@ -90,7 +92,7 @@ void BezierSplineWidget::slotShowPixmap(bool show) m_showPixmap = show; KdenliveSettings::setBezier_showpixmap(show); if (show && m_mode != ModeAlpha && m_mode != ModeRGB) - m_edit.setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(m_edit.size(), (ColorTools::ColorsRGB)((int)(m_mode == ModeLuma ? 3 : m_mode)), 0.8))); + m_edit.setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(m_edit.size(), (ColorTools::ColorsRGB)((int)(m_mode))))); else m_edit.setPixmap(QPixmap()); } @@ -136,4 +138,9 @@ void BezierSplineWidget::slotUpdateSpline() emit modified(); } +void BezierSplineWidget::slotResetSpline() +{ + m_edit.setSpline(CubicBezierSpline()); +} + #include "beziersplinewidget.moc" diff --git a/src/beziercurve/beziersplinewidget.h b/src/beziercurve/beziersplinewidget.h index e19f387f..761df80d 100644 --- a/src/beziercurve/beziersplinewidget.h +++ b/src/beziercurve/beziersplinewidget.h @@ -35,7 +35,7 @@ public: QString spline(); - enum CurveModes { ModeRed, ModeGreen, ModeBlue, ModeAlpha, ModeLuma, ModeRGB }; + enum CurveModes { ModeRed, ModeGreen, ModeBlue, ModeAlpha, ModeLuma, ModeRGB/*, ModeSaturation*/ }; void setMode(CurveModes mode); private slots: @@ -43,6 +43,7 @@ private slots: void slotUpdateSpline(); void slotGridChange(); void slotShowPixmap(bool show = true); + void slotResetSpline(); private: Ui::BezierSpline_UI m_ui; diff --git a/src/beziercurve/cubicbezierspline.cpp b/src/beziercurve/cubicbezierspline.cpp index f188860d..ba95d3a8 100644 --- a/src/beziercurve/cubicbezierspline.cpp +++ b/src/beziercurve/cubicbezierspline.cpp @@ -62,6 +62,7 @@ CubicBezierSpline& CubicBezierSpline::operator=(const CubicBezierSpline& spline) { m_precision = spline.m_precision; m_points = spline.m_points; + m_validSpline = false; return *this; } diff --git a/src/widgets/bezierspline_ui.ui b/src/widgets/bezierspline_ui.ui index 3ef39ca3..773c2269 100644 --- a/src/widgets/bezierspline_ui.ui +++ b/src/widgets/bezierspline_ui.ui @@ -14,7 +14,7 @@ Form - + @@ -202,7 +202,7 @@ - + Show background indicating changes caused by modifying the curve. @@ -218,7 +218,7 @@ - + ... @@ -228,7 +228,7 @@ - + ... @@ -238,7 +238,7 @@ - + Increases the number of lines in the grid.<br />After 8 lines it will begin from 0 again. @@ -251,7 +251,7 @@ - + Qt::Horizontal @@ -264,6 +264,19 @@ + + + + Reset the selected spline + + + ... + + + true + + +