]> git.sesse.net Git - kdenlive/commitdiff
Bezier Spline: Add grid. Number of lines in the grid can be increased with a button...
authorTill Theato <root@ttill.de>
Sun, 2 Jan 2011 12:59:00 +0000 (12:59 +0000)
committerTill Theato <root@ttill.de>
Sun, 2 Jan 2011 12:59:00 +0000 (12:59 +0000)
svn path=/trunk/kdenlive/; revision=5238

src/beziercurve/beziersplineeditor.cpp
src/beziercurve/beziersplineeditor.h
src/beziercurve/beziersplinewidget.cpp
src/widgets/bezierspline_ui.ui

index 291a3d8248c82bdafc4fa99b76334fe880f564f5..af5b26ab17de8314d4138189e4c46631d77911b1 100644 (file)
@@ -25,6 +25,7 @@
 BezierSplineEditor::BezierSplineEditor(QWidget* parent) :
         QWidget(parent),
         m_zoomLevel(0),
+        m_gridLines(3),
         m_mode(ModeNormal),
         m_currentPointIndex(-1)
 {
@@ -76,6 +77,12 @@ void BezierSplineEditor::slotZoomOut()
     update();
 }
 
+void BezierSplineEditor::slotGridChange()
+{
+    m_gridLines = (m_gridLines + 1) % 9;
+    update();
+}
+
 void BezierSplineEditor::paintEvent(QPaintEvent* event)
 {
     Q_UNUSED(event);
@@ -96,14 +103,27 @@ void BezierSplineEditor::paintEvent(QPaintEvent* event)
     /*p.setPen(QPen(Qt::gray, 1, Qt::SolidLine));
     p.drawLine(QLineF(0, wHeight, wWidth, 0));*/
 
+    p.setPen(QPen(Qt::gray, 1, Qt::SolidLine));
+
+    /*
+     * Borders
+     */
     if (m_zoomLevel != 0) {
-        /*
-         * Borders
-         */
-        p.setPen(QPen(Qt::gray, 1, Qt::SolidLine));
         p.drawRect(offset, offset, wWidth, wHeight);
     }
 
+    /*
+     * Grid
+     */
+    if (m_gridLines != 0) {
+        double stepH = wWidth / (double)(m_gridLines + 1);
+        double stepV = wHeight / (double)(m_gridLines + 1);
+        for (int i = 1; i <= m_gridLines; ++i) {
+            p.drawLine(QLineF(i * stepH, 0, i * stepH, wHeight).translated(offset, offset));
+            p.drawLine(QLineF(0, i * stepV, wWidth, i * stepV).translated(offset, offset));
+        }
+    }
+
     /*
      * Spline
      */
index 68fb7b6ed6c66bf4a4a352fc4e9c2c55b16b3a7e..b4dfe7aeafafdef0fcd8d37212032abc3790f7d8 100644 (file)
@@ -40,6 +40,7 @@ public:
 public slots:
     void slotZoomIn();
     void slotZoomOut();
+    void slotGridChange();
 
 protected:
     //void keyPressEvent(QKeyEvent *event);
@@ -56,6 +57,7 @@ private:
     enum point_types { PTypeH1, PTypeP, PTypeH2 };
     modes m_mode;
     int m_zoomLevel;
+    int m_gridLines;
     int m_currentPointIndex;
     point_types m_currentPointType;
     double m_grabOffsetX;
index b2491c75724dd13939691e9f93d27717e453a7ed..36eb6cc70fa73e4a0fd4c7f615a30b8983c0ee14 100644 (file)
@@ -35,6 +35,7 @@ BezierSplineWidget::BezierSplineWidget(const QString& spline, QWidget* parent) :
     m_ui.buttonLinkHandles->setEnabled(false);
     m_ui.buttonZoomIn->setIcon(KIcon("zoom-in"));
     m_ui.buttonZoomOut->setIcon(KIcon("zoom-out"));
+    m_ui.buttonGridChange->setIcon(KIcon("view-grid"));
     m_ui.widgetPoint->setEnabled(false);
 
     CubicBezierSpline s;
@@ -53,6 +54,7 @@ BezierSplineWidget::BezierSplineWidget(const QString& spline, QWidget* parent) :
 
     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()));
 }
 
 QString BezierSplineWidget::spline()
index e0cbb66a29c7991e4f4b1f86709c88b9165bcb45..53c6e909b4ab38f517696c571340ab4e8b2d07a0 100644 (file)
@@ -14,7 +14,7 @@
    <string>Form</string>
   </property>
   <layout class="QGridLayout" name="gridLayout">
-   <item row="1" column="5" colspan="3">
+   <item row="1" column="5" colspan="4">
     <widget class="QWidget" name="widgetPoint" native="true">
      <layout class="QGridLayout" name="gridLayout_2">
       <item row="0" column="0" colspan="9">
      </layout>
     </widget>
    </item>
-   <item row="2" column="5">
+   <item row="2" column="6">
     <widget class="QToolButton" name="buttonZoomIn">
      <property name="text">
       <string>...</string>
      </property>
     </widget>
    </item>
-   <item row="2" column="6">
+   <item row="2" column="7">
     <widget class="QToolButton" name="buttonZoomOut">
      <property name="text">
       <string>...</string>
      </property>
     </widget>
    </item>
-   <item row="2" column="7">
+   <item row="2" column="8">
     <spacer name="spacer">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
      </property>
     </spacer>
    </item>
+   <item row="2" column="5">
+    <widget class="QToolButton" name="buttonGridChange">
+     <property name="toolTip">
+      <string>Increases the number of lines in the grid.&lt;br /&gt;After 8 lines it will begin from 0 again.</string>
+     </property>
+     <property name="text">
+      <string>...</string>
+     </property>
+     <property name="autoRaise">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <resources/>