]> git.sesse.net Git - kdenlive/commitdiff
- Limit number of points in curve widget as they are limited in frei0r
authorTill Theato <root@ttill.de>
Fri, 7 May 2010 15:31:53 +0000 (15:31 +0000)
committerTill Theato <root@ttill.de>
Fri, 7 May 2010 15:31:53 +0000 (15:31 +0000)
- Add spin boxes for selected value in curve widget

svn path=/trunk/kdenlive/; revision=4420

src/effectstackedit.cpp
src/kis_curve_widget.cpp
src/kis_curve_widget.h
src/kis_curve_widget_p.h

index 1d201e1253cf9eb941594ca1488ad630c7d379d3..2d93948f44faca9fd7234d0c20e6836166e81404 100644 (file)
@@ -162,6 +162,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int in, int out)
             * keyframe: a list widget with a list of entries (position and value)
             * color: a color chooser button
             * position: a slider representing the position of a frame in the current clip
+            * curve: a single curve representing multiple points
             * wipe: a widget designed for the wipe transition, allowing to choose a position (left, right, top,...)
         */
 
@@ -274,6 +275,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int in, int out)
             connect(posedit, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters()));
         } else if (type == "curve") {
             KisCurveWidget *curve = new KisCurveWidget(this);
+            curve->setMaxPoints(pa.attribute("max").toInt());
             QList<QPointF> points;
             int number = EffectsList::parameter(e, pa.attribute("number")).toInt();
             QString inName = pa.attribute("inpoints");
@@ -287,7 +289,14 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int in, int out)
                 points << QPointF(EffectsList::parameter(e, in).toDouble(), EffectsList::parameter(e, out).toDouble());
             }
             if (!points.isEmpty()) curve->setCurve(KisCubicCurve(points));
+            QSpinBox *spinin = new QSpinBox();
+            spinin->setRange(0, 1000);
+            QSpinBox *spinout = new QSpinBox();
+            spinout->setRange(0, 1000);
+            curve->setupInOutControls(spinin, spinout, 0, 1000);
             m_vbox->addWidget(curve);
+            m_vbox->addWidget(spinin);
+            m_vbox->addWidget(spinout);
             connect(curve, SIGNAL(modified()), this, SLOT(collectAllParameters()));
             m_valueItems[paramName] = curve;
         } else if (type == "wipe") {
index ef741745d45698e417e5ae4ce7af0626dcbfd62c..6b0656ee191967af9dd0539bc3660c3d83466f73 100644 (file)
@@ -74,6 +74,8 @@ KisCurveWidget::KisCurveWidget(QWidget *parent, Qt::WFlags f)
 
     d->m_intIn = NULL;
     d->m_intOut = NULL;
+    
+    d->m_maxPoints = -1;
 
     setMouseTracking(true);
     setAutoFillBackground(false);
@@ -320,7 +322,7 @@ void KisCurveWidget::mousePressEvent(QMouseEvent * e)
 
     if (e->button() != Qt::LeftButton)
         return;
-
+    
     double x = e->pos().x() / (double)(width() - 1);
     double y = 1.0 - e->pos().y() / (double)(height() - 1);
 
@@ -328,6 +330,8 @@ void KisCurveWidget::mousePressEvent(QMouseEvent * e)
 
     int closest_point_index = d->nearestPointInRange(QPointF(x, y), width(), height());
     if (closest_point_index < 0) {
+        if (d->m_maxPoints > 0 && d->m_curve.points().count() >= d->m_maxPoints)
+            return;
         QPointF newPoint(x, y);
         if (!d->jumpOverExistingPoints(newPoint, -1))
             return;
@@ -454,4 +458,9 @@ void KisCurveWidget::leaveEvent(QEvent *)
 {
 }
 
+void KisCurveWidget::setMaxPoints(int max)
+{
+    d->m_maxPoints = max;
+}
+
 #include "kis_curve_widget.moc"
index 5115dfc583af4d7916ec22a005a0fbb8d8e62dbe..da61a6b8336771cda670dbebb42cd678936be38b 100644 (file)
@@ -131,6 +131,8 @@ public:
      * so the user can move this point anywhere in a moment
      */
     void addPointInTheMiddle();
+    
+    void setMaxPoints(int max);
 
 private:
 
index 31f15e9e238bdff9186decbfaf53454e0180c226..e3895f76f8d9a95abbab1f6198af52724fc1d4aa 100644 (file)
@@ -77,7 +77,7 @@ public:
     inline void setState(enumState st);
     inline enumState state() const;
 
-
+    int m_maxPoints;
 
     /*** Internal routins ***/