]> git.sesse.net Git - kdenlive/blobdiff - src/abstractscopewidget.h
Speedup: only convert displayed frame to QImage if necessary (for on monitor scene...
[kdenlive] / src / abstractscopewidget.h
index 415c8bc2c50e190673422ce5fc7fe04f3c3af0d4..2d38c30ef3d7bdcd4498cabb29357d8a7066a9c0 100644 (file)
@@ -64,14 +64,27 @@ class AbstractScopeWidget : public QWidget
     Q_OBJECT
 
 public:
-    AbstractScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent = 0);
+    AbstractScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, bool trackMouse = false, QWidget *parent = 0);
     virtual ~AbstractScopeWidget(); // Must be virtual because of inheritance, to avoid memory leaks
     QPalette m_scopePalette;
 
+    /** Initializes widget settings (reads configuration).
+      Has to be called in the implementing object. */
+    void init();
+
+    /** Does this scope have auto-refresh enabled */
+    bool autoRefreshEnabled();
+
     ///// Unimplemented /////
 
     virtual QString widgetName() const = 0;
 
+    ///// Variables /////
+    static const QPen penThick;
+    static const QPen penThin;
+    static const QPen penLight;
+    static const QPen penDark;
+
 protected:
     ///// Variables /////
 
@@ -93,6 +106,12 @@ protected:
         how many times faster the scope should be calculated. */
     QAction *m_aRealtime;
 
+    /** The mouse position; Updated when the mouse enters the widget
+        AND mouse tracking has been enabled. */
+    QPoint m_mousePos;
+    /** Knows whether the mouse currently lies within the widget or not.
+        Can e.g. be used for drawing a HUD only when the mouse is in the widget. */
+    bool m_mouseWithinWidget;
 
     /** Offset from the widget's borders */
     const uchar offset;
@@ -113,6 +132,15 @@ protected:
     int m_accelFactorScope;
     int m_accelFactorBackground;
 
+    /** Reads the widget's configuration.
+        Can be extended in the implementing subclass (make sure to run readConfig as well). */
+    virtual void readConfig();
+    /** Writes the widget configuration.
+        Implementing widgets have to implement an own method and run it in their destructor. */
+    void writeConfig();
+    /** Identifier for the widget's configuration. */
+    QString configName();
+
 
     ///// Unimplemented Methods /////
 
@@ -147,15 +175,18 @@ protected:
 
     ///// Reimplemented /////
 
+    void mouseMoveEvent(QMouseEvent *);
+    void leaveEvent(QEvent *);
     void mouseReleaseEvent(QMouseEvent *);
     void paintEvent(QPaintEvent *);
-    void raise();
     void resizeEvent(QResizeEvent *);
-    void showEvent(QShowEvent *);
+    void showEvent(QShowEvent *); // Called when the widget is activated via the Menu entry
+    //    void raise(); // Called only when  manually calling the event -> useless
+
 
 protected slots:
     /** Forces an update of all layers. */
-    void forceUpdate();
+    void forceUpdate(bool doUpdate = true);
     void forceUpdateHUD();
     void forceUpdateScope();
     void forceUpdateBackground();
@@ -163,11 +194,18 @@ protected slots:
 
 signals:
     /** mseconds represent the time taken for the calculation,
-        accelerationFactor the acceleration factor that has been used. */
+        accelerationFactor is the acceleration factor that has been used. */
     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. */
+    void signalMousePositionChanged();
+
+    /** Do we need the renderer to send its frames to us? */
+    void requestAutoRefresh(bool);
+
 private:
 
     /** Counts the number of frames that have been rendered in the active monitor.
@@ -195,6 +233,8 @@ private:
 
     QImage m_scopeImage;
 
+    QString m_widgetName;
+
     bool initialDimensionUpdateDone;
     void prodHUDThread();
     void prodScopeThread();
@@ -207,8 +247,13 @@ private slots:
       done in this abstract class. */
     void slotActiveMonitorChanged(bool isClipMonitor);
     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);
     void slotScopeRenderingFinished(uint mseconds, uint accelerationFactor);
     void slotBackgroundRenderingFinished(uint mseconds, uint accelerationFactor);