]> git.sesse.net Git - kdenlive/commitdiff
Add AbstractOnMonitorItem (preparations for more on-monitor effects should now be...
authorTill Theato <root@ttill.de>
Tue, 12 Oct 2010 14:26:03 +0000 (14:26 +0000)
committerTill Theato <root@ttill.de>
Tue, 12 Oct 2010 14:26:03 +0000 (14:26 +0000)
svn path=/trunk/kdenlive/; revision=4984

src/CMakeLists.txt
src/geometrywidget.cpp
src/monitorscene.cpp
src/monitorscene.h
src/monitorscenecontrolwidget.cpp
src/monitorscenecontrolwidget.h
src/onmonitoritems/abstractonmonitoritem.cpp [new file with mode: 0644]
src/onmonitoritems/abstractonmonitoritem.h [new file with mode: 0644]
src/onmonitoritems/onmonitorrectitem.cpp
src/onmonitoritems/onmonitorrectitem.h

index d07ec9c51d46c24858472466873175843518c19c..367e0475c24300c17cd256123b440dfc3553a1b4 100644 (file)
@@ -227,6 +227,7 @@ set(kdenlive_SRCS
   blackmagic/capture.cpp
   blackmagic/devices.cpp
   stopmotion/stopmotion.cpp
+  onmonitoritems/abstractonmonitoritem.cpp 
   onmonitoritems/onmonitorrectitem.cpp
   monitorscenecontrolwidget.cpp
 )
index cc378de928702483956f6969be7c9311c5da8b48..157b9ad2c28e2761328129929a8519806a4f1424 100644 (file)
@@ -188,7 +188,7 @@ void GeometryWidget::setupParam(const QDomElement elem, int minframe, int maxfra
 
     m_geometry->fetch(&item, 0);
     delete m_rect;
-    m_rect = new OnMonitorRectItem(QRectF(0, 0, item.w(), item.h()));
+    m_rect = new OnMonitorRectItem(QRectF(0, 0, item.w(), item.h()), m_scene);
     m_rect->setPos(item.x(), item.y());
     m_rect->setZValue(0);
     m_scene->addItem(m_rect);
index eec47da33f49cb73a2b0a96cf6d8295469cbe13b..7396cf861d2b5065f248988d8f6845acd0123f34 100644 (file)
@@ -92,11 +92,6 @@ void MonitorScene::slotUpdateBackground()
     }
 }
 
-void MonitorScene::slotSetDirectUpdate(bool directUpdate)
-{
-    KdenliveSettings::setMonitorscene_directupdate(directUpdate);
-}
-
 void MonitorScene::slotSetBackgroundImage(const QImage &image)
 {
     if (m_view && m_view->isVisible()) {
@@ -148,14 +143,14 @@ void MonitorScene::addItem(QGraphicsItem* item)
 {
     QGraphicsScene::addItem(item);
 
-    OnMonitorRectItem *rect = qgraphicsitem_cast<OnMonitorRectItem*>(item);
+    /*OnMonitorRectItem *rect = qgraphicsitem_cast<OnMonitorRectItem*>(item);
     if (rect) {
         connect(this, SIGNAL(mousePressed(QGraphicsSceneMouseEvent*)), rect, SLOT(slotMousePressed(QGraphicsSceneMouseEvent*)));
         connect(this, SIGNAL(mouseReleased(QGraphicsSceneMouseEvent*)), rect, SLOT(slotMouseReleased(QGraphicsSceneMouseEvent*)));
         connect(this, SIGNAL(mouseMoved(QGraphicsSceneMouseEvent*)), rect, SLOT(slotMouseMoved(QGraphicsSceneMouseEvent*)));
         connect(rect, SIGNAL(actionFinished()), this, SIGNAL(actionFinished()));
         connect(rect, SIGNAL(setCursor(const QCursor &)), this, SLOT(slotSetCursor(const QCursor &)));
-    }
+    }*/
 }
 
 void MonitorScene::slotSetCursor(const QCursor &cursor)
index 8831eb9ac246c8adb0c81c45fd03c3065215807a..081537ceaad50acd1c7633fc58420fcef8e0887f 100644 (file)
@@ -59,9 +59,6 @@ protected:
 public slots:
     /** @brief Sets the backgrounditem's pixmap to m_backgroundImage (only if a certain amount of time has passed since last update). */
     void slotUpdateBackground();
-    
-    /** @brief Sets the KdenliveSetting directupdate with true = update parameters (rerender frame) during mouse move (before mouse button is released) */
-    void slotSetDirectUpdate(bool directUpdate);
 
     /** @brief Sets the scene's zoom level.
      * @param value zoom level with 100 = show frame at original size */
index cbf65a4d5d07bdf81a64669f586da93c7cbddc42..0ba4d5afb2eec9114ad39650fea7c162472db4f3 100644 (file)
@@ -61,7 +61,7 @@ MonitorSceneControlWidget::MonitorSceneControlWidget(MonitorScene* scene, QWidge
     m_scene->slotZoomFit();
 
     connect(m_ui.buttonShowScene, SIGNAL(toggled(bool)), this, SIGNAL(showScene(bool)));
-    connect(m_ui.buttonDirectUpdate, SIGNAL(toggled(bool)), m_scene, SLOT(slotSetDirectUpdate(bool)));
+    connect(m_ui.buttonDirectUpdate, SIGNAL(toggled(bool)), this, SLOT(slotSetDirectUpdate(bool)));
 }
 
 MonitorSceneControlWidget::~MonitorSceneControlWidget()
@@ -74,4 +74,10 @@ QToolButton *MonitorSceneControlWidget::getShowHideButton()
     return m_buttonConfig;
 }
 
+void MonitorSceneControlWidget::slotSetDirectUpdate(bool directUpdate)
+{
+    KdenliveSettings::setMonitorscene_directupdate(directUpdate);
+}
+
+
 #include "monitorscenecontrolwidget.moc"
index 1ed36fc4e8b32afaa2710d271d71b3e6effcbbdd..b35cc9dd7423b732589848ca5efbda2ef1da6f45 100644 (file)
@@ -40,6 +40,10 @@ public:
     /** @brief Returns a button for showing and hiding the monitor scene controls (this widget). */
     QToolButton *getShowHideButton();
 
+private slots:
+    /** @brief Sets the KdenliveSetting directupdate with true = update parameters (rerender frame) during mouse move (before mouse button is released) */
+    void slotSetDirectUpdate(bool directUpdate);
+
 private:
     Ui::MonitorSceneControlWidget_UI m_ui;
     MonitorScene *m_scene;
diff --git a/src/onmonitoritems/abstractonmonitoritem.cpp b/src/onmonitoritems/abstractonmonitoritem.cpp
new file mode 100644 (file)
index 0000000..32360cb
--- /dev/null
@@ -0,0 +1,45 @@
+/***************************************************************************
+ *   Copyright (C) 2010 by Till Theato (root@ttill.de)                     *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+#include "abstractonmonitoritem.h"
+#include "monitorscene.h"
+
+#include <QGraphicsSceneMouseEvent>
+
+
+AbstractOnMonitorItem::AbstractOnMonitorItem(MonitorScene* scene) :
+    m_modified(false)
+{
+    connect(scene, SIGNAL(mousePressed(QGraphicsSceneMouseEvent*)), this, SLOT(slotMousePressed(QGraphicsSceneMouseEvent*)));
+    connect(scene, SIGNAL(mouseReleased(QGraphicsSceneMouseEvent*)), this, SLOT(slotMouseReleased(QGraphicsSceneMouseEvent*)));
+    connect(scene, SIGNAL(mouseMoved(QGraphicsSceneMouseEvent*)), this, SLOT(slotMouseMoved(QGraphicsSceneMouseEvent*)));
+    connect(this, SIGNAL(actionFinished()), scene, SIGNAL(actionFinished()));
+    connect(this, SIGNAL(requestCursor(const QCursor &)), scene, SLOT(slotSetCursor(const QCursor &)));
+}
+
+void AbstractOnMonitorItem::slotMouseReleased(QGraphicsSceneMouseEvent* event)
+{
+    if (m_modified) {
+        m_modified = false;
+        emit actionFinished();
+    }
+    event->accept();
+}
+
+#include "abstractonmonitoritem.moc"
diff --git a/src/onmonitoritems/abstractonmonitoritem.h b/src/onmonitoritems/abstractonmonitoritem.h
new file mode 100644 (file)
index 0000000..1832fa4
--- /dev/null
@@ -0,0 +1,52 @@
+/***************************************************************************
+ *   Copyright (C) 2010 by Till Theato (root@ttill.de)                     *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+
+
+#ifndef ABSTRACTONMONITORITEM_H
+#define ABSTRACTONMONITORITEM_H
+
+#include <QtCore>
+#include <QGraphicsItem>
+
+
+class MonitorScene;
+
+class AbstractOnMonitorItem : public QObject
+{
+    Q_OBJECT
+public:
+    AbstractOnMonitorItem(MonitorScene *scene);
+    //virtual ~AbstractOnMonitorItem() = 0;
+
+protected slots:
+    virtual void slotMousePressed(QGraphicsSceneMouseEvent *event) = 0;
+    /** @brief emits actionFinished signal if item was modified. */
+    virtual void slotMouseReleased(QGraphicsSceneMouseEvent *event);
+    virtual void slotMouseMoved(QGraphicsSceneMouseEvent *event) = 0;
+
+protected:
+    bool m_modified;
+
+signals:
+    void actionFinished();
+    void requestCursor(const QCursor &);
+    //void modified();
+};
+
+#endif
index 0b63a1986209cdcb5ba92446bf5a6923656ec946..05909b5d8b9a4f28954e37c3110c3ae18f9ef0a5 100644 (file)
@@ -25,7 +25,8 @@
 #include <QStyleOptionGraphicsItem>
 #include <QCursor>
 
-OnMonitorRectItem::OnMonitorRectItem(const QRectF &rect, QGraphicsItem* parent) :
+OnMonitorRectItem::OnMonitorRectItem(const QRectF &rect, MonitorScene *scene, QGraphicsItem* parent) :
+        AbstractOnMonitorItem(scene),
         QGraphicsRectItem(rect, parent)
 {
     setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
@@ -77,39 +78,28 @@ rectActions OnMonitorRectItem::getMode(QPoint pos)
         return NoAction;
 }
 
-int OnMonitorRectItem::type() const
+/*int OnMonitorRectItem::type() const
 {
     return Type;
-}
-
-void OnMonitorRectItem::setEnabled(bool enabled)
-{
-    m_enabled = enabled;
-}
+}*/
 
 void OnMonitorRectItem::slotMousePressed(QGraphicsSceneMouseEvent* event)
 {
-    if (!m_enabled)
+    event->accept();
+
+    if (!isEnabled())
         return;
 
     m_clickPoint = event->scenePos();
     m_mode = getMode(m_clickPoint.toPoint());
 }
 
-void OnMonitorRectItem::slotMouseReleased(QGraphicsSceneMouseEvent* event)
+void OnMonitorRectItem::slotMouseMoved(QGraphicsSceneMouseEvent* event)
 {
-    if (m_modified) {
-        m_modified = false;
-        emit actionFinished();
-    }
-
     event->accept();
-}
 
-void OnMonitorRectItem::slotMouseMoved(QGraphicsSceneMouseEvent* event)
-{
-    if (!m_enabled) {
-        emit setCursor(QCursor(Qt::ArrowCursor));
+    if (!isEnabled()) {
+        emit requestCursor(QCursor(Qt::ArrowCursor));
         return;
     }
 
@@ -198,25 +188,25 @@ void OnMonitorRectItem::slotMouseMoved(QGraphicsSceneMouseEvent* event)
         switch (getMode(event->scenePos().toPoint())) {
         case ResizeTopLeft:
         case ResizeBottomRight:
-            emit setCursor(QCursor(Qt::SizeFDiagCursor));
+            emit requestCursor(QCursor(Qt::SizeFDiagCursor));
             break;
         case ResizeTopRight:
         case ResizeBottomLeft:
-            emit setCursor(QCursor(Qt::SizeBDiagCursor));
+            emit requestCursor(QCursor(Qt::SizeBDiagCursor));
             break;
         case ResizeTop:
         case ResizeBottom:
-            emit setCursor(QCursor(Qt::SizeVerCursor));
+            emit requestCursor(QCursor(Qt::SizeVerCursor));
             break;
         case ResizeLeft:
         case ResizeRight:
-            emit setCursor(QCursor(Qt::SizeHorCursor));
+            emit requestCursor(QCursor(Qt::SizeHorCursor));
             break;
         case Move:
-            emit setCursor(QCursor(Qt::OpenHandCursor));
+            emit requestCursor(QCursor(Qt::OpenHandCursor));
             break;
         default:
-            emit setCursor(QCursor(Qt::ArrowCursor));
+            emit requestCursor(QCursor(Qt::ArrowCursor));
             break;
         }
     }
@@ -224,8 +214,6 @@ void OnMonitorRectItem::slotMouseMoved(QGraphicsSceneMouseEvent* event)
         emit actionFinished();
         m_modified = false;
     }
-
-    event->accept();
 }
 
 void OnMonitorRectItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
@@ -235,7 +223,7 @@ void OnMonitorRectItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*
     painter->setPen(pen());
     painter->drawRect(option->rect);
 
-    if (m_enabled) {
+    if (isEnabled()) {
         double handleSize = 6 / painter->matrix().m11();
         double halfHandleSize = handleSize / 2;
         painter->fillRect(-halfHandleSize, -halfHandleSize, handleSize, handleSize, QColor(Qt::yellow));
@@ -245,6 +233,4 @@ void OnMonitorRectItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*
     }
 }
 
-
-
 #include "onmonitorrectitem.moc"
index 44e9104eac7549b29db05f18c946ffabc2145ca8..c5d20c5f09157bb2f1dd989f11045ca39e0e7489 100644 (file)
 #ifndef ONMONITORRECTITEM_H
 #define ONMONITORRECTITEM_H
 
+#include "abstractonmonitoritem.h"
+
 #include <QtCore>
 #include <QGraphicsRectItem>
 
 enum rectActions { Move, ResizeTopLeft, ResizeBottomLeft, ResizeTopRight, ResizeBottomRight, ResizeLeft, ResizeRight, ResizeTop, ResizeBottom, NoAction };
 
-class OnMonitorRectItem : public QObject, public QGraphicsRectItem
+class OnMonitorRectItem : public AbstractOnMonitorItem, public QGraphicsRectItem
 {
     Q_OBJECT
 public:
-    OnMonitorRectItem(const QRectF &rect, QGraphicsItem *parent = 0);
-
-    /** @brief Enables/Disables the ability to modify the item.
-     * @param enabled (default = true) */
-    void setEnabled(bool enabled = true);
+    OnMonitorRectItem(const QRectF &rect, MonitorScene *scene, QGraphicsItem *parent = 0);
 
     /** @brief Gets The action mode for the area @param pos +- 4.
      * e.g. pos(0,0) returns ResizeTopLeft */
     rectActions getMode(QPoint pos);
     
-    enum { Type = UserType + 1};
-    /** @brief Reimplemented to make sure casting works. */
-    int type() const;
+    /*enum { Type = UserType + 1};
+    /** @brief Reimplemented to make sure casting works. * /
+    int type() const;*/
 
     /** @brief Reimplemented to draw the handles. */
     virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 );
@@ -50,20 +48,12 @@ public:
 public slots:
     /** @brief Saves current mouse position and mode. */
     void slotMousePressed(QGraphicsSceneMouseEvent *event);
-    /** @brief emits actionFinished signal if item was modified. */
-    void slotMouseReleased(QGraphicsSceneMouseEvent *event);
     /** @brief Modifies item according to mouse position and mode. */
     void slotMouseMoved(QGraphicsSceneMouseEvent *event);
 
 private:
     rectActions m_mode;
     QPointF m_clickPoint;
-    bool m_enabled;
-    bool m_modified;
-
-signals:
-    void actionFinished();
-    void setCursor(const QCursor &);
 };
 
 #endif