- draw background indicating changes caused by modifying the curve, can be turned off
- store number of grid lines in kdenlivesettings
svn path=/trunk/kdenlive/; revision=5239
BezierSplineEditor::BezierSplineEditor(QWidget* parent) :
QWidget(parent),
+ m_mode(ModeNormal),
m_zoomLevel(0),
m_gridLines(3),
- m_mode(ModeNormal),
+ m_pixmapCache(NULL),
+ m_pixmapIsDirty(true),
m_currentPointIndex(-1)
{
setMouseTracking(true);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
+BezierSplineEditor::~BezierSplineEditor()
+{
+ if (m_pixmapCache)
+ delete m_pixmapCache;
+}
+
CubicBezierSpline BezierSplineEditor::spline()
{
return m_spline;
}
}
+void BezierSplineEditor::setPixmap(const QPixmap& pixmap)
+{
+ m_pixmap = pixmap;
+ m_pixmapIsDirty = true;
+ update();
+}
+
void BezierSplineEditor::slotZoomIn()
{
m_zoomLevel = qMax(m_zoomLevel-1, 0);
+ m_pixmapIsDirty = true;
update();
}
void BezierSplineEditor::slotZoomOut()
{
m_zoomLevel = qMin(m_zoomLevel+1, 3);
+ m_pixmapIsDirty = true;
update();
}
-void BezierSplineEditor::slotGridChange()
+int BezierSplineEditor::gridLines()
+{
+ return m_gridLines;
+}
+
+void BezierSplineEditor::setGridLines(int lines)
{
- m_gridLines = (m_gridLines + 1) % 9;
+ m_gridLines = qBound(0, lines, 8);
update();
}
QPainter p(this);
- p.fillRect(rect(), palette().background());
-
int wWidth = width() - 1;
int wHeight = height() - 1;
int offset = 1/8. * m_zoomLevel * (wWidth > wHeight ? wWidth : wHeight);
wWidth -= 2 * offset;
wHeight -= 2 * offset;
+ /*
+ * Background
+ */
+ p.fillRect(rect(), palette().background());
+ if (!m_pixmap.isNull()) {
+ if (m_pixmapIsDirty || !m_pixmapCache) {
+ if (m_pixmapCache)
+ delete m_pixmapCache;
+ m_pixmapCache = new QPixmap(wWidth + 1, wHeight + 1);
+ QPainter cachePainter(m_pixmapCache);
+
+ cachePainter.scale(1.0*(wWidth+1) / m_pixmap.width(), 1.0*(wHeight+1) / m_pixmap.height());
+ cachePainter.drawPixmap(0, 0, m_pixmap);
+ m_pixmapIsDirty = false;
+ }
+ p.drawPixmap(offset, offset, *m_pixmapCache);
+ }
+
/*
* Standard line
*/
void BezierSplineEditor::resizeEvent(QResizeEvent* event)
{
m_spline.setPrecision(width());
+ m_pixmapIsDirty = true;
QWidget::resizeEvent(event);
}
public:
BezierSplineEditor(QWidget* parent = 0);
+ virtual ~BezierSplineEditor();
CubicBezierSpline spline();
void setSpline(const CubicBezierSpline &spline);
BPoint getCurrentPoint();
void updateCurrentPoint(const BPoint &p);
+ int gridLines();
+ void setGridLines(int lines);
+
+ void setPixmap(const QPixmap &pixmap);
+
public slots:
void slotZoomIn();
void slotZoomOut();
- void slotGridChange();
protected:
//void keyPressEvent(QKeyEvent *event);
modes m_mode;
int m_zoomLevel;
int m_gridLines;
+ QPixmap m_pixmap;
+ QPixmap *m_pixmapCache;
+ bool m_pixmapIsDirty;
+
int m_currentPointIndex;
point_types m_currentPointType;
double m_grabOffsetX;
***************************************************************************/
#include "beziersplinewidget.h"
+#include "colortools.h"
+#include "kdenlivesettings.h"
#include <QVBoxLayout>
#include <KIcon>
BezierSplineWidget::BezierSplineWidget(const QString& spline, QWidget* parent) :
- QWidget(parent)
+ QWidget(parent),
+ m_mode(ModeRed)
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(&m_edit);
m_ui.buttonZoomIn->setIcon(KIcon("zoom-in"));
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.widgetPoint->setEnabled(false);
CubicBezierSpline s;
connect(m_ui.buttonZoomIn, SIGNAL(clicked()), &m_edit, SLOT(slotZoomIn()));
connect(m_ui.buttonZoomOut, SIGNAL(clicked()), &m_edit, SLOT(slotZoomOut()));
- connect(m_ui.buttonGridChange, SIGNAL(clicked()), &m_edit, SLOT(slotGridChange()));
+ connect(m_ui.buttonGridChange, SIGNAL(clicked()), this, SLOT(slotGridChange()));
+ connect(m_ui.buttonShowPixmap, SIGNAL(toggled(bool)), this, SLOT(slotShowPixmap(bool)));
+
+ m_edit.setGridLines(KdenliveSettings::bezier_gridlines());
+ m_ui.buttonShowPixmap->setChecked(KdenliveSettings::bezier_showpixmap());
}
QString BezierSplineWidget::spline()
return m_edit.spline().toString();
}
+void BezierSplineWidget::setMode(BezierSplineWidget::CurveModes mode)
+{
+ if (m_mode != mode) {
+ m_mode = mode;
+ if (m_showPixmap)
+ slotShowPixmap();
+ }
+}
+
+void BezierSplineWidget::slotGridChange()
+{
+ m_edit.setGridLines((m_edit.gridLines() + 1) % 9);
+ KdenliveSettings::setBezier_gridlines(m_edit.gridLines());
+}
+
+void BezierSplineWidget::slotShowPixmap(bool show)
+{
+ m_showPixmap = show;
+ KdenliveSettings::setBezier_showpixmap(show);
+ if (show)
+ m_edit.setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(m_edit.size(), (ColorTools::ColorsRGB)((int)m_mode), 0.8)));
+ else
+ m_edit.setPixmap(QPixmap());
+}
+
void BezierSplineWidget::slotUpdatePoint(const BPoint &p)
{
blockSignals(true);
QString spline();
+ enum CurveModes { ModeRed, ModeGreen, ModeBlue, ModeLuma };
+ void setMode(CurveModes mode);
+
private slots:
void slotUpdatePoint(const BPoint &p);
void slotUpdateSpline();
+ void slotGridChange();
+ void slotShowPixmap(bool show = true);
private:
Ui::BezierSpline_UI m_ui;
BezierSplineEditor m_edit;
+ CurveModes m_mode;
+ bool m_showPixmap;
signals:
void modified();
int color = value.toInt();
curve->setPixmap(QPixmap::fromImage(ColorTools::rgbCurvePlane(curve->size(), (ColorTools::ColorsRGB)color, 0.8)));
}
+ } else if (type == "bezier_spline") {
+ BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems[name];
+ if (widget) {
+ widget->setMode((BezierSplineWidget::CurveModes)value.toInt());
+ }
}
}
m_vbox->addWidget(widget);
m_valueItems[paramName] = widget;
connect(widget, SIGNAL(modified()), this, SLOT(collectAllParameters()));
+ QString depends = pa.attribute("depends");
+ if (!depends.isEmpty())
+ meetDependency(paramName, type, EffectsList::parameter(e, depends));
} else if (type == "corners") {
CornersWidget *corners = new CornersWidget(m_monitor, pos, isEffect, pa.attribute("factor").toInt(), this);
connect(corners, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
} else if (type == "bezier_spline") {
BezierSplineWidget *widget = (BezierSplineWidget*)m_valueItems.value(paramName);
setValue = widget->spline();
+ QString depends = pa.attributes().namedItem("depends").nodeValue();
+ if (!depends.isEmpty())
+ meetDependency(paramName, type, EffectsList::parameter(newparam, depends));
} else if (type == "corners") {
CornersWidget *corners = ((CornersWidget*)m_valueItems.value(paramName));
QString xName = pa.attributes().namedItem("xpoints").nodeValue();
<default></default>
</entry>
</group>
+
+ <group name="bezier_spline">
+ <entry name="bezier_gridlines" type="Int">
+ <label>Number of lines to use for the grid.</label>
+ <default>3</default>
+ </entry>
+
+ <entry name="bezier_showpixmap" type="Bool">
+ <label>Should a background indicating the changes caused by curve manipulation be shown.</label>
+ <default>true</default>
+ </entry>
+ </group>
<group name="unmanaged">
<rect>
<x>0</x>
<y>0</y>
- <width>336</width>
- <height>94</height>
+ <width>315</width>
+ <height>83</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="1" column="5" colspan="4">
+ <item row="1" column="0" colspan="6">
<widget class="QWidget" name="widgetPoint" native="true">
<layout class="QGridLayout" name="gridLayout_2">
+ <property name="margin">
+ <number>0</number>
+ </property>
<item row="0" column="0" colspan="9">
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
</layout>
</widget>
</item>
- <item row="2" column="6">
- <widget class="QToolButton" name="buttonZoomIn">
+ <item row="2" column="0">
+ <widget class="QToolButton" name="buttonShowPixmap">
+ <property name="toolTip">
+ <string>Show background indicating changes caused by modifying the curve.</string>
+ </property>
<property name="text">
<string>...</string>
</property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
- <item row="2" column="7">
- <widget class="QToolButton" name="buttonZoomOut">
+ <item row="2" column="3">
+ <widget class="QToolButton" name="buttonZoomIn">
<property name="text">
<string>...</string>
</property>
</property>
</widget>
</item>
- <item row="2" column="8">
- <spacer name="spacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <item row="2" column="4">
+ <widget class="QToolButton" name="buttonZoomOut">
+ <property name="text">
+ <string>...</string>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
+ <property name="autoRaise">
+ <bool>true</bool>
</property>
- </spacer>
+ </widget>
</item>
- <item row="2" column="5">
+ <item row="2" column="1">
<widget class="QToolButton" name="buttonGridChange">
<property name="toolTip">
<string>Increases the number of lines in the grid.<br />After 8 lines it will begin from 0 again.</string>
</property>
</widget>
</item>
+ <item row="2" column="5">
+ <spacer name="spacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
<resources/>