X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fabstractscopewidget.h;h=e518e1f08758eadf723c15101ce998e30ba79313;hb=e0a70e0428309070f6ed2716beaeaaba05edd3b5;hp=bee68863a02725d13f078122e5fe8d163d756393;hpb=dfbaa896b04c1105271d691fcf967aeb98bf6892;p=kdenlive diff --git a/src/abstractscopewidget.h b/src/abstractscopewidget.h index bee68863..e518e1f0 100644 --- a/src/abstractscopewidget.h +++ b/src/abstractscopewidget.h @@ -58,15 +58,23 @@ class AbstractScopeWidget : public QWidget Q_OBJECT public: + /** 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. */ 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 ///// @@ -74,12 +82,20 @@ 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 ///// @@ -136,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 */ @@ -164,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 @@ -181,7 +204,7 @@ protected slots: void forceUpdateHUD(); void forceUpdateScope(); void forceUpdateBackground(); - virtual void slotAutoRefreshToggled(bool); + void slotAutoRefreshToggled(bool); signals: /** mseconds represent the time taken for the calculation, @@ -191,7 +214,8 @@ signals: 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? */ @@ -233,13 +257,25 @@ private: void prodScopeThread(); void prodBackgroundThread(); + ///// Movement detection ///// + const int m_rescaleMinDist; + const float m_rescaleVerticalThreshold; + + 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);//TODO remove /** 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);