]> git.sesse.net Git - kdenlive/blobdiff - src/abstractscopewidget.h
Fix small display issue in render widget
[kdenlive] / src / abstractscopewidget.h
index 1de70528bf0b16d792b91f7433f04c9b562117dd..a2515051d798dc8ee4fb6d9fa5d87dca8a6dce35 100644 (file)
@@ -40,9 +40,6 @@
   The custom context menu already contains entries, like for enabling auto-
   refresh. It can certainly be extended in the implementation of the widget.
 
-  Note: Widgets deriving from this class should connect slotActiveMonitorChanged
-  to the appropriate signal.
-
   If you intend to write an own widget inheriting from this one, please read
   the comments on the unimplemented methods carefully. They are not only here
   for optical amusement, but also contain important information.
 
 class QMenu;
 
-class Monitor;
-class Render;
-
 class AbstractScopeWidget : public QWidget
 {
     Q_OBJECT
 
 public:
-    AbstractScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, bool trackMouse = false, QWidget *parent = 0);
+    /** trackMouse enables mouse tracking; The variables m_mousePos and m_mouseWithinWidget will be set
+            if mouse tracking is enabled. See also signalMousePositionChanged(). */
+    AbstractScopeWidget(bool trackMouse = false, QWidget *parent = 0);
     virtual ~AbstractScopeWidget(); // Must be virtual because of inheritance, to avoid memory leaks
+
+
+    enum RescaleDirection { North, Northeast, East, Southeast };
+
+
     QPalette m_scopePalette;
 
     /** Initializes widget settings (reads configuration).
       Has to be called in the implementing object. */
-    void init();
+    virtual void init();
 
-    /** Does this scope have auto-refresh enabled */
+    /** Tell whether this scope has auto-refresh enabled. Required for determining whether
+        new data (e.g. an image frame) has to be delivered to this widget. */
     bool autoRefreshEnabled();
 
     ///// Unimplemented /////
@@ -80,24 +82,29 @@ public:
     virtual QString widgetName() const = 0;
 
     ///// Variables /////
+    static const QColor colHighlightLight;
+    static const QColor colHighlightDark;
+    static const QColor colDarkWhite;
+
     static const QPen penThick;
     static const QPen penThin;
     static const QPen penLight;
+    static const QPen penLightDots;
+    static const QPen penLighter;
     static const QPen penDark;
+    static const QPen penDarkDots;
+    static const QPen penBackground;
+
+    static const QString directions[]; // Mainly for debug output
 
 protected:
     ///// Variables /////
 
-    Monitor *m_projMonitor;
-    Monitor *m_clipMonitor;
-    Render *m_activeRender;
-
-
     /** The context menu. Feel free to add new entries in your implementation. */
     QMenu *m_menu;
 
     /** Enables auto refreshing of the scope.
-        This is when a new frame is shown on the active monitor.
+        This is when fresh data is incoming.
         Resize events always force a recalculation. */
     QAction *m_aAutoRefresh;
 
@@ -145,7 +152,8 @@ protected:
     ///// Unimplemented Methods /////
 
     /** Where on the widget we can paint in.
-        May also update other variables that depend on the widget's size.  */
+        May also update other variables, like m_scopeRect or custom ones,
+        that have to change together with the widget's size.  */
     virtual QRect scopeRect() = 0;
 
     /** @brief HUD renderer. Must emit signalHUDRenderingFinished(). @see renderScope */
@@ -153,13 +161,13 @@ protected:
     /** @brief Scope renderer. Must emit signalScopeRenderingFinished()
         when calculation has finished, to allow multi-threading.
         accelerationFactor hints how much faster than usual the calculation should be accomplished, if possible. */
-    virtual QImage renderScope(uint accelerationFactor, const QImage) = 0;
+    virtual QImage renderScope(uint accelerationFactor) = 0;
     /** @brief Background renderer. Must emit signalBackgroundRenderingFinished(). @see renderScope */
     virtual QImage renderBackground(uint accelerationFactor) = 0;
 
-    /** Must return true if the HUD layer depends on the input monitor.
+    /** Must return true if the HUD layer depends on the input data.
         If it does not, then it does not need to be re-calculated when
-        a new frame from the monitor is incoming. */
+        fresh data is incoming. */
     virtual bool isHUDDependingOnInput() const = 0;
     /** @see isHUDDependingOnInput() */
     virtual bool isScopeDependingOnInput() const = 0;
@@ -173,11 +181,17 @@ protected:
     virtual uint calculateAccelFactorScope(uint oldMseconds, uint oldFactor);
     virtual uint calculateAccelFactorBackground(uint oldMseconds, uint oldFactor);
 
+    /** The Abstract Scope will try to detect the movement direction when dragging on the widget with the mouse.
+        As soon as the direction is determined it will execute this method. Can be used e.g. for re-scaling content.
+        This is just a dummy function, re-implement to add functionality. */
+    virtual void handleMouseDrag(const QPoint movement, const RescaleDirection rescaleDirection, const Qt::KeyboardModifiers rescaleModifiers);
+
     ///// Reimplemented /////
 
-    void mouseMoveEvent(QMouseEvent *);
+    void mouseMoveEvent(QMouseEvent *event);
+    void mousePressEvent(QMouseEvent *event);
+    void mouseReleaseEvent(QMouseEvent *event);
     void leaveEvent(QEvent *);
-    void mouseReleaseEvent(QMouseEvent *);
     void paintEvent(QPaintEvent *);
     void resizeEvent(QResizeEvent *);
     void showEvent(QShowEvent *); // Called when the widget is activated via the Menu entry
@@ -194,13 +208,14 @@ protected slots:
 
 signals:
     /** mseconds represent the time taken for the calculation,
-        accelerationFactor is the acceleration factor that has been used. */
+        accelerationFactor is the acceleration factor that has been used for this calculation. */
     void signalHUDRenderingFinished(uint mseconds, uint accelerationFactor);
     void signalScopeRenderingFinished(uint mseconds, uint accelerationFactor);
     void signalBackgroundRenderingFinished(uint mseconds, uint accelerationFactor);
 
     /** For the mouse position itself see m_mousePos.
-        To check whether the mouse has leaved the widget, see m_mouseWithinWidget. */
+        To check whether the mouse has leaved the widget, see m_mouseWithinWidget.
+        This signal is typically connected to forceUpdateHUD(). */
     void signalMousePositionChanged();
 
     /** Do we need the renderer to send its frames to us? */
@@ -208,8 +223,8 @@ signals:
 
 private:
 
-    /** Counts the number of frames that have been rendered in the active monitor.
-      The frame number will be reset when the calculation starts for the current frame. */
+    /** Counts the number of data frames that have been rendered in the active monitor.
+      The frame number will be reset when the calculation starts for the current data set. */
     QAtomicInt m_newHUDFrames;
     QAtomicInt m_newScopeFrames;
     QAtomicInt m_newBackgroundFrames;
@@ -242,19 +257,25 @@ private:
     void prodScopeThread();
     void prodBackgroundThread();
 
-public slots:
-    /** @brief Must be called when the active monitor has shown a new frame.
-      This slot must be connected in the implementing class, it is *not*
-      done in this abstract class. */
-    void slotActiveMonitorChanged(bool isClipMonitor);
+    ///// Movement detection /////
+    const int m_rescaleMinDist;
+    const float m_rescaleVerticalThreshold;
 
-private slots:
+    bool m_rescaleActive;
+    bool m_rescalePropertiesLocked;
+    bool m_rescaleFirstRescaleDone;
+    short m_rescaleScale;
+    Qt::KeyboardModifiers m_rescaleModifiers;
+    RescaleDirection m_rescaleDirection;
+    QPoint m_rescaleStartPoint;
+
+
+protected slots:
     void customContextMenuRequested(const QPoint &pos);
     /** To be called when a new frame has been received.
       The scope then decides whether and when it wants to recalculate the scope, depending
       on whether it is currently visible and whether a calculation thread is already running. */
     void slotRenderZoneUpdated();
-    void slotRenderZoneUpdated(QImage);
     /** The following slots are called when rendering of a component has finished. They e.g. update
       the widget and decide whether to immediately restart the calculation thread. */
     void slotHUDRenderingFinished(uint mseconds, uint accelerationFactor);