]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.h
First big cleanup of transition / clipitem. Transitions are a bit broken for now...
[kdenlive] / src / clipitem.h
index d80e096ba1872aa991561534521485959a6a0588..f9de3c1a218541cfe2b9be1c0074f2badf29dda4 100644 (file)
 #define CLIPITEM_H
 
 #include <QGraphicsRectItem>
+#include <QDomElement>
 #include <QGraphicsSceneMouseEvent>
+#include <QTimeLine>
 
-#include "labelitem.h"
+#include "definitions.h"
+#include "gentime.h"
+#include "effectslist.h"
+#include "abstractclipitem.h"
 
-class ClipItem : public QGraphicsRectItem
-{
-  
-  public:
-    ClipItem(int clipType, QString name, int producer, const QRectF & rect);
+class DocClipBase;
+class Transition;
+
+class ClipItem : public AbstractClipItem {
+    Q_OBJECT
+
+public:
+    ClipItem(DocClipBase *clip, ItemInfo info, double scale, double fps);
+    virtual ~ ClipItem();
     virtual void paint(QPainter *painter,
-                           const QStyleOptionGraphicsItem *option,
-                           QWidget *widget);
-    virtual int type () const;
-    void moveTo(double x, double offset);
-
-  protected:
-    virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
-    virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
-    virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
-
-  private:
-    LabelItem *m_label;
-    int m_textWidth;
-    uint m_resizeMode;
+                       const QStyleOptionGraphicsItem *option,
+                       QWidget *widget);
+    virtual int type() const;
+    void resizeStart(int posx, double scale);
+    void resizeEnd(int posx, double scale);
+    OPERATIONTYPE operationMode(QPointF pos, double scale);
+    int clipProducer();
+    int clipType();
+    DocClipBase *baseClip();
+    QString clipName();
+    QDomElement xml() const;
+
+    void setFadeOut(int pos, double scale);
+    void setFadeIn(int pos, double scale);
+    /** Give a string list of the clip's effect names */
+    QStringList effectNames();
+    /** Add an effect to the clip and return the parameters that will be passed to Mlt */
+    QMap <QString, QString> addEffect(QDomElement effect);
+    /** Get the effect parameters that will be passed to Mlt */
+    QMap <QString, QString> getEffectArgs(QDomElement effect);
+    /** Delete effect with id index */
+    void deleteEffect(QString index);
+    /** return the number of effects in that clip */
+    int effectsCount();
+    /** return a unique effect id */
+    int effectsCounter();
+    /** return the xml of effect at index ix in stack */
+    QDomElement effectAt(int ix);
+    /** Replace effect at pos ix with given value */
+    void setEffectAt(int ix, QDomElement effect);
+    void flashClip();
+    void addTransition(Transition*);
+    /** regenerate audio and video thumbnails */
+    void resetThumbs();
+
+protected:
+    virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
+    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * event);
+    virtual void mousePressEvent(QGraphicsSceneMouseEvent * event);
+    virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
+    virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
+    virtual void dropEvent(QGraphicsSceneDragDropEvent *event);
+    virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *);
+    virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
+
+private:
+    QDomElement m_xml;
+    DocClipBase *m_clip;
+    OPERATIONTYPE m_resizeMode;
     int m_grabPoint;
     int m_producer;
+    CLIPTYPE m_clipType;
+    QString m_clipName;
+
+
+    int m_maxTrack;
+
+    QPixmap m_startPix;
+    QPixmap m_endPix;
+    bool m_hasThumbs;
+    QTimer *startThumbTimer;
+    QTimer *endThumbTimer;
+
+    /** counter used to provide a unique id to each effect */
+    int m_effectsCounter;
+    double m_opacity;
+    QTimeLine *m_timeLine;
+    uint m_thumbsRequested;
+    bool m_hover;
+
+    EffectsList m_effectList;
+    QList <Transition*> m_transitionsList;
+    QMap<int, QPixmap> audioThumbCachePic;
+    bool audioThumbWasDrawn, audioThumbReady;
+    double framePixelWidth;
+    QMap<int, QPainterPath > channelPaths;
+
+private slots:
+    void slotThumbReady(int frame, QPixmap pix);
+    void slotFetchThumbs();
+    void slotGetStartThumb();
+    void slotGetEndThumb();
+    void slotGotAudioData();
+    void slotPrepareAudioThumb(double, QPainterPath, int, int);
+    void animate(qreal value);
+
+signals:
+    void getThumb(int, int);
+    void prepareAudioThumb(double, QPainterPath, int, int);
+
 };
 
 #endif