]> git.sesse.net Git - kdenlive/commitdiff
Bezier Spline: add backgrounds for modes rgb and alpha
authorTill Theato <root@ttill.de>
Thu, 6 Jan 2011 22:00:53 +0000 (22:00 +0000)
committerTill Theato <root@ttill.de>
Thu, 6 Jan 2011 22:00:53 +0000 (22:00 +0000)
svn path=/trunk/kdenlive/; revision=5280

src/beziercurve/beziersplinewidget.cpp
src/colortools.cpp
src/colortools.h
src/effectstackedit.cpp

index 04ec3b64ef72025f58a278e59167f0c7279de6aa..f351420b040ea7c0288941331d15ea3c539a8db9 100644 (file)
@@ -69,6 +69,7 @@ BezierSplineWidget::BezierSplineWidget(const QString& spline, QWidget* parent) :
 
     m_edit.setGridLines(KdenliveSettings::bezier_gridlines());
     m_ui.buttonShowPixmap->setChecked(KdenliveSettings::bezier_showpixmap());
+    slotShowPixmap(m_ui.buttonShowPixmap->isChecked());
     m_ui.buttonShowAllHandles->setChecked(KdenliveSettings::bezier_showallhandles());
 }
 
@@ -96,8 +97,8 @@ void BezierSplineWidget::slotShowPixmap(bool show)
 {
     m_showPixmap = show;
     KdenliveSettings::setBezier_showpixmap(show);
-    if (show && (m_mode == ModeRed || m_mode == ModeGreen || m_mode == ModeBlue || m_mode == ModeLuma ))
-        m_edit.setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(m_edit.size(), (ColorTools::ColorsRGB)((int)(m_mode == ModeLuma ? int(m_mode) - 1 : m_mode)))));
+    if (show && (int)m_mode < 6)
+        m_edit.setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(m_edit.size(), (ColorTools::ColorsRGB)((int)m_mode), 1, palette().background().color().rgb())));
     else
         m_edit.setPixmap(QPixmap());
 }
index 6e44a33473f9a5f02759aab215671e2c86debf3a..eeb659829a90c325a1f5df7d1d043e617b2a5249 100644 (file)
@@ -134,7 +134,7 @@ QImage ColorTools::yuvVerticalPlane(const QSize &size, const float &angle, const
 
 }
 
-QImage ColorTools::rgbCurvePlane(const QSize &size, const ColorTools::ColorsRGB &color, float scaling)
+QImage ColorTools::rgbCurvePlane(const QSize &size, const ColorTools::ColorsRGB &color, float scaling, const QRgb &background)
 {
     Q_ASSERT(scaling > 0 && scaling <= 1);
 
@@ -169,6 +169,8 @@ QImage ColorTools::rgbCurvePlane(const QSize &size, const ColorTools::ColorsRGB
                 plane.setPixel(x, (h-y-1), qRgb(dval, dcol, dval));
             } else if (color == ColorTools::COL_B){
                 plane.setPixel(x, (h-y-1), qRgb(dval, dval, dcol));
+            } else if (color == ColorTools::COL_A) {
+                plane.setPixel(x, (h-y-1), qRgb(dcol / 255. * qRed(background), dcol / 255. * qGreen(background), dcol / 255. * qBlue(background)));
             } else {
                 plane.setPixel(x, (h-y-1), qRgb(dcol, dcol, dcol));
             }
index 0441377c4e8df12bc923dc385ea81444ec772ee9..adfbd634ec8a639b4fcc2d5bb09391f9a2ccbf5f 100644 (file)
@@ -26,7 +26,7 @@ class ColorTools : public QObject
 public:
     ColorTools();
 
-    enum ColorsRGB { COL_R, COL_G, COL_B, COL_Luma };
+    enum ColorsRGB { COL_R, COL_G, COL_B, COL_A, COL_Luma, COL_RGB };
 
     /**
       @brief Draws a UV plane with given Y value.
@@ -54,7 +54,7 @@ public:
       simulates the case that the curves can adjust only +- scaling*255. This mainly delivers a more constant look
       when also using the Luma component for the curves display but might not represent the actual color change!
      */
-    static QImage rgbCurvePlane(const QSize &size, const ColorTools::ColorsRGB &color, float scaling = 1);
+    static QImage rgbCurvePlane(const QSize &size, const ColorTools::ColorsRGB &color, float scaling = 1, const QRgb &background = QRgb());
     /**
       @brief Draws a YPbPr plane with Pb on the x axis and Pr on the y axis.
       Y is the Y value to use.
index 0a629559c91a6c51dd6e555aa8f37ffc87bc1467..360c62f1d03c172ffd07a8d54539ca2b650091c9 100644 (file)
@@ -147,7 +147,7 @@ void EffectStackEdit::meetDependency(const QString& name, QString type, QString
         KisCurveWidget *curve = (KisCurveWidget*)m_valueItems[name];
         if (curve) {
             int color = value.toInt();
-            curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)color, 0.8)));
+            curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)(color == 3 ? 4 : color), 0.8)));
         }
     } else if (type == "bezier_spline") {
         BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems[name];