svn path=/trunk/kdenlive/; revision=5277
m_mode(ModeNormal),
m_zoomLevel(0),
m_gridLines(3),
m_mode(ModeNormal),
m_zoomLevel(0),
m_gridLines(3),
+ m_showAllHandles(true),
m_pixmapCache(NULL),
m_pixmapIsDirty(true),
m_currentPointIndex(-1)
m_pixmapCache(NULL),
m_pixmapIsDirty(true),
m_currentPointIndex(-1)
+void BezierSplineEditor::setShowAllHandles(bool show)
+{
+ m_showAllHandles = show;
+ update();
+}
+
int BezierSplineEditor::gridLines()
{
return m_gridLines;
int BezierSplineEditor::gridLines()
{
return m_gridLines;
p.drawEllipse(QRectF(point.p.x() * wWidth - 3,
wHeight - 3 - point.p.y() * wHeight, 6, 6));
p.drawEllipse(QRectF(point.p.x() * wWidth - 3,
wHeight - 3 - point.p.y() * wHeight, 6, 6));
+ if (i != 0 && (i == m_currentPointIndex || m_showAllHandles)) {
#if QT_VERSION >= 0x040600
p.drawConvexPolygon(handle.translated(point.h1.x() * wWidth, wHeight - point.h1.y() * wHeight));
#else
#if QT_VERSION >= 0x040600
p.drawConvexPolygon(handle.translated(point.h1.x() * wWidth, wHeight - point.h1.y() * wHeight));
#else
p.drawConvexPolygon(tmp);
#endif
}
p.drawConvexPolygon(tmp);
#endif
}
+ if (i != max && (i == m_currentPointIndex || m_showAllHandles)) {
#if QT_VERSION >= 0x040600
p.drawConvexPolygon(handle.translated(point.h2.x() * wWidth, wHeight - point.h2.y() * wHeight));
#else
#if QT_VERSION >= 0x040600
p.drawConvexPolygon(handle.translated(point.h2.x() * wWidth, wHeight - point.h2.y() * wHeight));
#else
- if (nearestIndex >= 0) {
+ if (nearestIndex >= 0 && (nearestIndex == m_currentPointIndex || selectedPoint == PTypeP || m_showAllHandles)) {
+ // a point was found and it is not a hidden handle
BPoint point = m_spline.points()[nearestIndex];
if (qAbs(p.x() - point[(int)selectedPoint].x()) * wWidth < 5 && qAbs(p.y() - point[(int)selectedPoint].y()) * wHeight < 5) {
*sel = selectedPoint;
BPoint point = m_spline.points()[nearestIndex];
if (qAbs(p.x() - point[(int)selectedPoint].x()) * wWidth < 5 && qAbs(p.y() - point[(int)selectedPoint].y()) * wHeight < 5) {
*sel = selectedPoint;
CubicBezierSpline spline();
void setSpline(const CubicBezierSpline &spline);
CubicBezierSpline spline();
void setSpline(const CubicBezierSpline &spline);
+ /** @brief Returns the selected point or else BPoint. */
BPoint getCurrentPoint();
BPoint getCurrentPoint();
+
+ /** @brief Replaces current point with @param p (index stays the same). */
void updateCurrentPoint(const BPoint &p);
void updateCurrentPoint(const BPoint &p);
+ /** @brief Number of lines used in grid. */
+
+ /** @brief Sets the number of grid lines to draw (in one direction) to @param lines. */
void setGridLines(int lines);
void setGridLines(int lines);
+ /** @brief Sets the background pixmap to @param pixmap. */
void setPixmap(const QPixmap &pixmap);
void setPixmap(const QPixmap &pixmap);
+ /** @brief Sets the property showAllHandles to @param show.
+ *
+ * showAllHandles: Whether to show only handles for the selected point for all points. */
+ void setShowAllHandles(bool show);
+
public slots:
void slotZoomIn();
void slotZoomOut();
public slots:
void slotZoomIn();
void slotZoomOut();
modes m_mode;
int m_zoomLevel;
int m_gridLines;
modes m_mode;
int m_zoomLevel;
int m_gridLines;
+ /** Whether to show only handles for the selected point for all points. */
+ bool m_showAllHandles;
QPixmap m_pixmap;
QPixmap *m_pixmapCache;
bool m_pixmapIsDirty;
QPixmap m_pixmap;
QPixmap *m_pixmapCache;
bool m_pixmapIsDirty;
BPoint m_grabPNext;
BPoint m_grabPPrevious;
BPoint m_grabPNext;
BPoint m_grabPPrevious;
+ /** @brief Finds the point nearest to @param p and returns it's index.
+ * @param sel Is filled with the type of the closest point (h1, p, h2)
+ *
+ * If no point is near enough -1 is returned. */
int nearestPointInRange(QPointF p, int wWidth, int wHeight, point_types *sel);
signals:
int nearestPointInRange(QPointF p, int wWidth, int wHeight, point_types *sel);
signals:
BezierSplineWidget::BezierSplineWidget(const QString& spline, QWidget* parent) :
QWidget(parent),
BezierSplineWidget::BezierSplineWidget(const QString& spline, QWidget* parent) :
QWidget(parent),
+ m_mode(ModeRGB),
+ m_showPixmap(true)
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(&m_edit);
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(&m_edit);
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.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.buttonShowAllHandles->setIcon(KIcon("draw-bezier-curves"));
m_ui.widgetPoint->setEnabled(false);
CubicBezierSpline s;
m_ui.widgetPoint->setEnabled(false);
CubicBezierSpline s;
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()));
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()));
+ connect(m_ui.buttonShowAllHandles, SIGNAL(toggled(bool)), this, SLOT(slotShowAllHandles(bool)));
m_edit.setGridLines(KdenliveSettings::bezier_gridlines());
m_ui.buttonShowPixmap->setChecked(KdenliveSettings::bezier_showpixmap());
m_edit.setGridLines(KdenliveSettings::bezier_gridlines());
m_ui.buttonShowPixmap->setChecked(KdenliveSettings::bezier_showpixmap());
+ m_ui.buttonShowAllHandles->setChecked(KdenliveSettings::bezier_showallhandles());
}
QString BezierSplineWidget::spline()
}
QString BezierSplineWidget::spline()
m_edit.setSpline(CubicBezierSpline());
}
m_edit.setSpline(CubicBezierSpline());
}
+void BezierSplineWidget::slotShowAllHandles(bool show)
+{
+ m_edit.setShowAllHandles(show);
+ KdenliveSettings::setBezier_showallhandles(show);
+}
+
#include "beziersplinewidget.moc"
#include "beziersplinewidget.moc"
/** @brief Linkes the handles. This will always make them stay in one line through p. */
void slotSetHandlesLinked(bool linked);
/** @brief Linkes the handles. This will always make them stay in one line through p. */
void slotSetHandlesLinked(bool linked);
+ void slotShowAllHandles(bool show);
+
private:
Ui::BezierSpline_UI m_ui;
BezierSplineEditor m_edit;
private:
Ui::BezierSpline_UI m_ui;
BezierSplineEditor m_edit;
<label>Should a background indicating the changes caused by curve manipulation be shown.</label>
<default>true</default>
</entry>
<label>Should a background indicating the changes caused by curve manipulation be shown.</label>
<default>true</default>
</entry>
+
+ <entry name="bezier_showallhandles" type="Bool">
+ <label>Show handles for all points or only for the selected one.</label>
+ <default>true</default>
+ </entry>
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="1" column="0" colspan="7">
+ <item row="1" column="0" colspan="8">
<widget class="QWidget" name="widgetPoint" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<widget class="QWidget" name="widgetPoint" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checkable">
<bool>true</bool>
</property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
<property name="autoRaise">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</property>
</widget>
</item>
</property>
</widget>
</item>
- <item row="2" column="6">
+ <item row="2" column="7">
<spacer name="spacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<spacer name="spacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</property>
</widget>
</item>
+ <item row="2" column="6">
+ <widget class="QToolButton" name="buttonShowAllHandles">
+ <property name="toolTip">
+ <string>Show handles for all points or only for the selected one</string>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<resources/>
</layout>
</widget>
<resources/>