From a3b0f8cf7943bcea39e8d9404c16094e574cf62c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Sun, 20 Jan 2008 22:31:16 +0000 Subject: [PATCH] Start porting timeline to QGraphicsView svn path=/branches/KDE4/; revision=1805 --- src/CMakeLists.txt | 3 + src/addclipcommand.cpp | 2 +- src/clipitem.cpp | 168 ++++++++++++++++++++++++++++++ src/clipitem.h | 53 ++++++++++ src/customruler.cpp | 19 ++++ src/customruler.h | 3 + src/customtrackview.cpp | 207 +++++++++++++++++++++++++++++++++++++ src/customtrackview.h | 63 +++++++++++ src/documentaudiotrack.cpp | 3 +- src/documentaudiotrack.h | 2 +- src/documenttrack.cpp | 3 +- src/documenttrack.h | 2 +- src/documentvideotrack.cpp | 3 +- src/documentvideotrack.h | 2 +- src/kdenlivedoc.cpp | 19 +++- src/kdenlivedoc.h | 3 +- src/labelitem.cpp | 68 ++++++++++++ src/labelitem.h | 37 +++++++ src/main.cpp | 2 +- src/mainwindow.cpp | 54 ++++++++-- src/mainwindow.h | 20 +++- src/projectitem.cpp | 2 + src/projectlistview.cpp | 6 +- src/renderer.cpp | 12 +-- src/trackview.cpp | 138 +++++++++++++++++++------ src/trackview.h | 33 ++++++ src/widgets/timeline_ui.ui | 4 +- 27 files changed, 866 insertions(+), 65 deletions(-) create mode 100644 src/clipitem.cpp create mode 100644 src/clipitem.h create mode 100644 src/customtrackview.cpp create mode 100644 src/customtrackview.h create mode 100644 src/labelitem.cpp create mode 100644 src/labelitem.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 988f4f82..47cde5da 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,6 +50,9 @@ set(kdenlive_SRCS trackpanelfunctionfactory.cpp trackpanelfunction.cpp trackpanelclipmovefunction.cpp + customtrackview.cpp + clipitem.cpp + labelitem.cpp ) kde4_add_kcfg_files(kdenlive_SRCS GENERATE_MOC kdenlivesettings.kcfgc ) diff --git a/src/addclipcommand.cpp b/src/addclipcommand.cpp index 0242f694..80e43df7 100644 --- a/src/addclipcommand.cpp +++ b/src/addclipcommand.cpp @@ -23,7 +23,7 @@ AddClipCommand::AddClipCommand(ProjectList *list, const QStringList &names, cons : m_list(list), m_names(names), m_xml(xml), m_id(id), m_url(url), m_group(group), m_doIt(doIt) { if (doIt) setText(i18n("Add clip")); else setText(i18n("Delete clip")); - } + } // virtual diff --git a/src/clipitem.cpp b/src/clipitem.cpp new file mode 100644 index 00000000..7912cbc9 --- /dev/null +++ b/src/clipitem.cpp @@ -0,0 +1,168 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * 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 +#include + +#include + + +#include "clipitem.h" + +ClipItem::ClipItem(int clipType, QString name, int producer, const QRectF & rect) + : QGraphicsRectItem(rect), m_resizeMode(0), m_grabPoint(0), m_producer(producer) +{ + setToolTip(name); + //setCursor(Qt::SizeHorCursor); + setFlags(QGraphicsItem::ItemClipsToShape | QGraphicsItem::ItemClipsChildrenToShape | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); + //producer = "sjis isjisjsi sij ssao sa sao "; + m_label = new LabelItem( name, this); + QRectF textRect = m_label->boundingRect(); + m_textWidth = textRect.width(); + m_label->setPos(rect.x() + rect.width()/2 - m_textWidth/2, rect.y() + rect.height() / 2 - textRect.height()/2); +} + +int ClipItem::type () const +{ + return 70000; +} + +// virtual + void ClipItem::paint(QPainter *painter, + const QStyleOptionGraphicsItem *option, + QWidget *widget) + { + painter->setClipRect( option->exposedRect ); + painter->fillRect(rect(), Qt::red); + //kDebug()<<"ITEM REPAINT RECT: "<drawText(rect(), Qt::AlignCenter, m_name); + painter->drawRect(rect()); + //painter->drawRoundRect(-10, -10, 20, 20); + } + +// virtual + void ClipItem::mousePressEvent ( QGraphicsSceneMouseEvent * event ) + { + if (abs(event->pos().x() - rect().x()) < 6) + m_resizeMode = 1; + else if (abs(event->pos().x() - (rect().x() + rect().width())) < 6) + m_resizeMode = 2; + else { + m_resizeMode = 0; + m_grabPoint = event->pos().x() - rect().x(); + } + QGraphicsRectItem::mousePressEvent(event); + } + +// virtual + void ClipItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) + { + m_resizeMode = 0; + QGraphicsRectItem::mouseReleaseEvent(event); + } + + void ClipItem::moveTo(double x, double offset) + { + double origX = rect().x(); + double origY = rect().y(); + setRect(x, origY + offset, rect().width(), rect().height()); + + QList collisionList = collidingItems(); + for (int i = 0; i < collisionList.size(); ++i) { + QGraphicsItem *item = collisionList.at(i); + if (item->type() == 70000) + { + if (offset == 0) + { + QRectF other = ((QGraphicsRectItem *)item)->rect(); + QPointF pos = mapFromItem(item, other.x()+other.width(), 0); + //mapToItem(collisionList.at(i), collisionList.at(i)->boundingRect()).boundingRect(); + if (x < origX) { + kDebug()<<"COLLISION, MOVING TO------"; + origX = other.x() + other.width(); + } + else if (x > origX) { + kDebug()<<"COLLISION, MOVING TO+++"; + origX = other.x() - rect().width(); + } + } + setRect(origX, origY, rect().width(), rect().height()); + offset = 0; + origX = rect().x(); + break; + } + } + + QList childrenList = children(); + for (int i = 0; i < childrenList.size(); ++i) { + childrenList.at(i)->moveBy(rect().x() - origX , offset); + } + } + +// virtual + void ClipItem::mouseMoveEvent ( QGraphicsSceneMouseEvent * event ) + { + double moveX = event->scenePos().x(); + double originalX = rect().x(); + if (m_resizeMode == 1) { + setRect(moveX, rect().y(), originalX + rect().width() - moveX, rect().height()); + return; + } + if (m_resizeMode == 2) { + setRect(originalX, rect().y(), moveX - originalX, rect().height()); + return; + } + int moveTrack = (int) event->scenePos().y() / 50; + int currentTrack = (int) rect().y() / 50; + int offset = moveTrack - currentTrack; + if (offset != 0) offset = 50 * offset; + moveTo(moveX - m_grabPoint, offset); + + } + + +// virtual +/* +void CustomTrackView::mousePressEvent ( QMouseEvent * event ) +{ + int pos = event->x(); + if (event->modifiers() == Qt::ControlModifier) + setDragMode(QGraphicsView::ScrollHandDrag); + else if (event->modifiers() == Qt::ShiftModifier) + setDragMode(QGraphicsView::RubberBandDrag); + else { + QGraphicsItem * item = itemAt(event->pos()); + if (item) { + } + else emit cursorMoved((int) mapToScene(event->x(), 0).x()); + } + kDebug()< +#include + +#include "labelitem.h" + +class ClipItem : public QGraphicsRectItem +{ + + public: + ClipItem(int clipType, QString name, int producer, const QRectF & rect); + 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; + int m_grabPoint; + int m_producer; +}; + +#endif diff --git a/src/customruler.cpp b/src/customruler.cpp index f1edad9a..4b26427c 100644 --- a/src/customruler.cpp +++ b/src/customruler.cpp @@ -1,3 +1,21 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * 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 #include @@ -88,6 +106,7 @@ void CustomRuler::mouseMoveEvent ( QMouseEvent * event ) void CustomRuler::slotNewValue ( int _value ) { m_cursorPosition = _value / pixelPerMark(); + emit cursorMoved(m_cursorPosition / FRAME_SIZE); KRuler::slotNewValue(_value); } diff --git a/src/customruler.h b/src/customruler.h index 9d50f266..ad468c8c 100644 --- a/src/customruler.h +++ b/src/customruler.h @@ -24,6 +24,9 @@ class CustomRuler : public KRuler public slots: void slotNewValue ( int _value ); + + signals: + void cursorMoved(int); }; #endif diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp new file mode 100644 index 00000000..376be5c7 --- /dev/null +++ b/src/customtrackview.cpp @@ -0,0 +1,207 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * 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 +#include +#include +#include + +#include +#include + +#include "customtrackview.h" +#include "clipitem.h" +#include "definitions.h" + +CustomTrackView::CustomTrackView(QGraphicsScene * scene, QWidget *parent) + : QGraphicsView(scene, parent), m_tracksCount(0), m_cursorPos(0), m_dropItem(NULL) +{ + setMouseTracking(true); + setAcceptDrops(true); +} + +// virtual +void CustomTrackView::mouseMoveEvent ( QMouseEvent * event ) +{ + int pos = event->x(); + if (event->modifiers() == Qt::ControlModifier) + setDragMode(QGraphicsView::ScrollHandDrag); + else if (event->modifiers() == Qt::ShiftModifier) + setDragMode(QGraphicsView::RubberBandDrag); + else { + QGraphicsItem * item = itemAt(event->pos()); + if (item) { + while (item->parentItem()) + item = item->parentItem(); + int cursorPos = event->x(); + QRectF itemRect = item->sceneBoundingRect(); + int itemStart = mapFromScene(itemRect.x(), 0).x(); + int itemEnd = mapFromScene(itemRect.x() + itemRect.width(), 0).x(); + if (abs(itemStart - cursorPos) < 6 || abs(itemEnd - cursorPos) < 6) + setCursor(Qt::SizeHorCursor); + else setCursor(Qt::OpenHandCursor); + + } + else { + setCursor(Qt::ArrowCursor); + } + } + QGraphicsView::mouseMoveEvent(event); +} + +// virtual +void CustomTrackView::mousePressEvent ( QMouseEvent * event ) +{ + int pos = event->x(); + if (event->modifiers() == Qt::ControlModifier) + setDragMode(QGraphicsView::ScrollHandDrag); + else if (event->modifiers() == Qt::ShiftModifier) + setDragMode(QGraphicsView::RubberBandDrag); + else { + QGraphicsItem * item = itemAt(event->pos()); + if (item) { + /*while (item->parentItem()) + item = item->parentItem(); + + int cursorPos = event->x(); + QRectF itemRect = item->sceneBoundingRect(); + int itemStart = mapFromScene(itemRect.x(), 0).x(); + int itemEnd = mapFromScene(itemRect.x() + itemRect.width(), 0).x(); + if (abs(itemStart - cursorPos) < 6) + ((ClipItem *) item )->setResizeMode(1); + else if (abs(itemEnd - cursorPos) < 6) + ((ClipItem *) item )->setResizeMode(2); + */} + else { + setCursor(Qt::ArrowCursor); + emit cursorMoved((int) mapToScene(event->x(), 0).x()); + } + } + //kDebug()<mimeData()->hasText()) { + QString clip = event->mimeData()->text(); + addItem(clip, event->pos()); + event->acceptProposedAction(); + } +} + + +void CustomTrackView::addItem(QString producer, QPoint pos) +{ + QDomDocument doc; + doc.setContent(producer); + QDomElement elem = doc.documentElement(); + int in = elem.attribute("in", 0).toInt(); + int out = elem.attribute("duration", 0).toInt(); + if (out == 0) out = elem.attribute("out", 0).toInt() - in; + kDebug()<<"ADDING CLIP: "<addItem(m_dropItem); +} + + +void CustomTrackView::dragMoveEvent(QDragMoveEvent * event) { + event->setDropAction(Qt::IgnoreAction); + if (m_dropItem) { + int trackTop = ((int) mapToScene(event->pos()).y()/50) * 50 + 1; + m_dropItem->moveTo(mapToScene(event->pos()).x(), trackTop - m_dropItem->rect().y()); + } + //if (item) { + event->setDropAction(Qt::MoveAction); + if (event->mimeData()->hasText()) { + event->acceptProposedAction(); + } + //} +} + +void CustomTrackView::dragLeaveEvent ( QDragLeaveEvent * event ) { + if (m_dropItem) delete m_dropItem; + m_dropItem = NULL; +} + +void CustomTrackView::dropEvent ( QDropEvent * event ) { + m_dropItem = NULL; +} + + +QStringList CustomTrackView::mimeTypes () const +{ + QStringList qstrList; + // list of accepted mime types for drop + qstrList.append("text/plain"); + return qstrList; +} + +Qt::DropActions CustomTrackView::supportedDropActions () const +{ + // returns what actions are supported when dropping + return Qt::MoveAction; +} + +void CustomTrackView::addTrack () +{ + m_tracksCount++; +} + +void CustomTrackView::removeTrack () +{ + m_tracksCount--; +} + +void CustomTrackView::setCursorPos(int pos) +{ + m_cursorPos = pos; +} + +int CustomTrackView::cursorPos() +{ + return m_cursorPos; +} + +void CustomTrackView::mouseReleaseEvent ( QMouseEvent * event ) +{ + QGraphicsView::mouseReleaseEvent(event); + setDragMode(QGraphicsView::NoDrag); +} + +void CustomTrackView::drawBackground ( QPainter * painter, const QRectF & rect ) +{ + //kDebug()<<"///// DRAWING BG: "<drawRect(rect); + for (uint i = 0; i < m_tracksCount;i++) + { + painter->drawLine(rect.x(), 50 * i, rect.x() + rect.width(), 50 * i); + } +} + +void CustomTrackView::drawForeground ( QPainter * painter, const QRectF & rect ) +{ + //kDebug()<<"///// DRAWING FB: "<drawLine(m_cursorPos, rect.y(), m_cursorPos, rect.y() + rect.height()); +} + +#include "customtrackview.moc" diff --git a/src/customtrackview.h b/src/customtrackview.h new file mode 100644 index 00000000..8d601acd --- /dev/null +++ b/src/customtrackview.h @@ -0,0 +1,63 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * 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 CUSTOMTRACKVIEW_H +#define CUSTOMTRACKVIEW_H + +#include + +#include "clipitem.h" + +class CustomTrackView : public QGraphicsView +{ + Q_OBJECT + + public: + CustomTrackView(QGraphicsScene * scene, QWidget *parent=0); + virtual void mousePressEvent ( QMouseEvent * event ); + virtual void mouseReleaseEvent ( QMouseEvent * event ); + virtual void mouseMoveEvent ( QMouseEvent * event ); + void addTrack(); + void removeTrack(); + void setCursorPos(int pos); + int cursorPos(); + + protected: + virtual void drawBackground ( QPainter * painter, const QRectF & rect ); + virtual void drawForeground ( QPainter * painter, const QRectF & rect ); + virtual void dragEnterEvent ( QDragEnterEvent * event ); + virtual void dragMoveEvent(QDragMoveEvent * event); + virtual void dragLeaveEvent ( QDragLeaveEvent * event ); + virtual void dropEvent ( QDropEvent * event ); + virtual QStringList mimeTypes() const; + virtual Qt::DropActions supportedDropActions () const; + + private: + int m_tracksCount; + int m_cursorPos; + ClipItem *m_dropItem; + void addItem(QString producer, QPoint pos); + + signals: + void cursorMoved(int); + +}; + +#endif diff --git a/src/documentaudiotrack.cpp b/src/documentaudiotrack.cpp index 66544538..586e4e00 100644 --- a/src/documentaudiotrack.cpp +++ b/src/documentaudiotrack.cpp @@ -17,6 +17,7 @@ DocumentAudioTrack::DocumentAudioTrack(QDomElement xml, TrackView * view, QWidge } // virtual +/* void DocumentAudioTrack::paintEvent(QPaintEvent *e ) { QRect region = e->rect(); @@ -24,6 +25,6 @@ void DocumentAudioTrack::paintEvent(QPaintEvent *e ) painter.fillRect(region, QBrush(Qt::green)); painter.drawLine(region.bottomLeft (), region.bottomRight ()); } - +*/ #include "documentaudiotrack.moc" diff --git a/src/documentaudiotrack.h b/src/documentaudiotrack.h index 45b58e96..c806243f 100644 --- a/src/documentaudiotrack.h +++ b/src/documentaudiotrack.h @@ -12,7 +12,7 @@ class DocumentAudioTrack : public DocumentTrack DocumentAudioTrack(QDomElement xml, TrackView * view, QWidget *parent=0); protected: - virtual void paintEvent(QPaintEvent * /*e*/); + //virtual void paintEvent(QPaintEvent * /*e*/); private: TrackView *m_trackView; diff --git a/src/documenttrack.cpp b/src/documenttrack.cpp index 060f55a8..676165f1 100644 --- a/src/documenttrack.cpp +++ b/src/documenttrack.cpp @@ -75,6 +75,7 @@ QList DocumentTrack::clipList() } // virtual +/* void DocumentTrack::paintEvent(QPaintEvent *e ) { QRect region = e->rect(); @@ -83,6 +84,6 @@ void DocumentTrack::paintEvent(QPaintEvent *e ) painter.fillRect(region, QBrush(Qt::red)); painter.drawLine(region.bottomLeft (), region.bottomRight ()); } - +*/ #include "documenttrack.moc" diff --git a/src/documenttrack.h b/src/documenttrack.h index 2084634e..27caf4d5 100644 --- a/src/documenttrack.h +++ b/src/documenttrack.h @@ -30,7 +30,7 @@ class DocumentTrack : public QWidget QStringList applicableFunctions(const QString & mode); protected: - virtual void paintEvent(QPaintEvent * /*e*/); + //virtual void paintEvent(QPaintEvent * /*e*/); private: QDomElement m_xml; diff --git a/src/documentvideotrack.cpp b/src/documentvideotrack.cpp index 042e6268..b92971fc 100644 --- a/src/documentvideotrack.cpp +++ b/src/documentvideotrack.cpp @@ -17,6 +17,7 @@ DocumentVideoTrack::DocumentVideoTrack(QDomElement xml, TrackView * view, QWidge } // virtual +/* void DocumentVideoTrack::paintEvent(QPaintEvent *e ) { QList trackClipList = clipList(); @@ -39,6 +40,6 @@ void DocumentVideoTrack::paintEvent(QPaintEvent *e ) painter.drawText(clipRect, Qt::AlignCenter, trackClipList.at(i).producer); } } - +*/ #include "documentvideotrack.moc" diff --git a/src/documentvideotrack.h b/src/documentvideotrack.h index 0168553e..83d45d9c 100644 --- a/src/documentvideotrack.h +++ b/src/documentvideotrack.h @@ -13,7 +13,7 @@ class DocumentVideoTrack : public DocumentTrack DocumentVideoTrack(QDomElement xml, TrackView * view, QWidget *parent=0); protected: - virtual void paintEvent(QPaintEvent * /*e*/); + //virtual void paintEvent(QPaintEvent * /*e*/); private: TrackView *m_trackView; diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index bab68a29..b796a100 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -28,7 +28,7 @@ #include "kdenlivedoc.h" -KdenliveDoc::KdenliveDoc(KUrl url, double fps, int width, int height, QWidget *parent):QObject(parent), m_render(NULL), m_url(url), m_fps(fps), m_width(width), m_height(height), m_projectName(NULL) +KdenliveDoc::KdenliveDoc(const KUrl &url, double fps, int width, int height, QWidget *parent):QObject(parent), m_render(NULL), m_url(url), m_fps(fps), m_width(width), m_height(height), m_projectName(NULL) { m_commandStack = new KUndoStack(); @@ -110,6 +110,23 @@ void KdenliveDoc::setRenderer(Render *render) if (m_render) m_render->setSceneList(m_document); } +QString KdenliveDoc::producerName(int id) +{ + QString result = "unnamed"; + QDomNodeList prods = producersList(); + int ct = prods.count(); + for (int i = 0; i < ct ; i++) + { + QDomElement e = prods.item(i).toElement(); + if (e.attribute("id") != "black" && e.attribute("id").toInt() == id) { + result = e.attribute("name"); + if (result.isEmpty()) result = KUrl(e.attribute("resource")).fileName(); + break; + } + } + return result; +} + QDomDocument KdenliveDoc::generateSceneList() { QDomDocument doc; diff --git a/src/kdenlivedoc.h b/src/kdenlivedoc.h index 0b1967f1..b0a2c0ff 100644 --- a/src/kdenlivedoc.h +++ b/src/kdenlivedoc.h @@ -37,7 +37,7 @@ class KdenliveDoc:public QObject { Q_OBJECT public: - KdenliveDoc(KUrl url, double fps, int width, int height, QWidget *parent = 0); + KdenliveDoc(const KUrl &url, double fps, int width, int height, QWidget *parent = 0); ~KdenliveDoc(); QString documentName(); QDomNodeList producersList(); @@ -50,6 +50,7 @@ class KdenliveDoc:public QObject { QDomDocument toXml(); void setRenderer(Render *render); KUndoStack *commandStack(); + QString producerName(int id); private: KUrl m_url; diff --git a/src/labelitem.cpp b/src/labelitem.cpp new file mode 100644 index 00000000..4547bf2b --- /dev/null +++ b/src/labelitem.cpp @@ -0,0 +1,68 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * 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 +#include + +#include + + +#include "labelitem.h" + +LabelItem::LabelItem(QString text, QGraphicsRectItem *parent) + : QGraphicsSimpleTextItem(text, parent) +{ + //setParentItem(parent); + setFlags(QGraphicsItem::ItemIgnoresTransformations); +} + +int LabelItem::type () const +{ + return 70001; +} + +// virtual +/* + void LabelItem::paint(QPainter *painter, + const QStyleOptionGraphicsItem *option, + QWidget *widget) + { + //painter->setClipRect( option->exposedRect ); + QRectF rep = option->exposedRect; + QGraphicsRectItem *parent = (QGraphicsRectItem *) parentItem(); + QRectF par = parent->boundingRect(); + //kDebug()<<"REPAINT RECT: "<rect(); + //QRectF transRect = deviceTransform(view->viewportTransform()).inverted().mapRect(parrect); + //painter->setClipRect( par); + //painter->fillRect(rect(), Qt::red); + QPainterPath path; + path.addPolygon(mapFromParent(parentItem()->boundingRect())); + //painter->fillPath(path, QColor(200, 100, 200, 150)); + //painter->setClipPath(path); + painter->fillRect(boundingRect(), QColor(200, 100, 200, 150)); + painter->drawText(boundingRect(), Qt::AlignCenter, text()); + //painter->drawRect(rect()); + //painter->drawRoundRect(-10, -10, 20, 20); + }*/ + +#include "labelitem.moc" diff --git a/src/labelitem.h b/src/labelitem.h new file mode 100644 index 00000000..042a9e8a --- /dev/null +++ b/src/labelitem.h @@ -0,0 +1,37 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * 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 LABELITEM_H +#define LABELITEM_H + +#include +#include +#include + +class LabelItem : public QGraphicsSimpleTextItem +{ + + public: + LabelItem(QString text, QGraphicsRectItem *parent = 0); + //virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + virtual int type () const; +}; + +#endif diff --git a/src/main.cpp b/src/main.cpp index f6a8888d..908c9ce8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,7 +26,7 @@ int main (int argc, char *argv[]) KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); //new if(args->count()) //new { - window->openFile(args->url(0).url()); //new + window->openFile(args->url(0)); //new } return app.exec(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 39fa17f8..72d6994b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -99,6 +99,12 @@ MainWindow::MainWindow(QWidget *parent) m_undoView->setStack(m_commandStack); addDockWidget(Qt::TopDockWidgetArea, undoViewDock); + overviewDock = new QDockWidget(i18n("Project Overview"), this); + overviewDock->setObjectName("project_overview"); + m_overView = new CustomTrackView(NULL, this); + overviewDock->setWidget(m_overView); + addDockWidget(Qt::TopDockWidgetArea, overviewDock); + setupActions(); tabifyDockWidget (projectListDock, effectListDock); tabifyDockWidget (projectListDock, effectStackDock); @@ -120,6 +126,21 @@ MainWindow::MainWindow(QWidget *parent) newFile(); } +//virtual +bool MainWindow::queryClose() +{ + saveOptions(); + switch ( KMessageBox::warningYesNoCancel( this, i18n("Save changes to document ?")) ) { + case KMessageBox::Yes : + // save document here. If saving fails, return false; + return true; + case KMessageBox::No : + return true; + default: // cancel + return false; + } +} + void MainWindow::slotRaiseMonitor(bool clipMonitor) { if (clipMonitor) clipMonitorDock->raise(); @@ -156,7 +177,10 @@ void MainWindow::setupActions() KStandardAction::open(this, SLOT(openFile()), actionCollection()); - + + m_fileOpenRecent = KStandardAction::openRecent(this, SLOT(openFile(const KUrl &)), + actionCollection()); + KStandardAction::save(this, SLOT(saveFile()), actionCollection()); @@ -172,12 +196,24 @@ void MainWindow::setupActions() KStandardAction::redo(this, SLOT(redo()), actionCollection());*/ - KStandardAction::preferences(this, SLOT(slotPreferences()), - actionCollection()); + readOptions(); /*m_redo = m_commandStack->createRedoAction(actionCollection()); m_undo = m_commandStack->createUndoAction(actionCollection());*/ } + +void MainWindow::saveOptions() +{ + KSharedConfigPtr config = KGlobal::config (); + m_fileOpenRecent->saveEntries(KConfigGroup (config, "Recent Files")); + config->sync(); +} + +void MainWindow::readOptions() +{ + KSharedConfigPtr config = KGlobal::config (); + m_fileOpenRecent->loadEntries(KConfigGroup (config, "Recent Files")); +} void MainWindow::newFile() { @@ -228,12 +264,15 @@ void MainWindow::saveFile() void MainWindow::openFile() //changed { - openFile(KFileDialog::getOpenFileName(KUrl(), "application/vnd.kde.kdenlive,*.kdenlive")); + KUrl url = KFileDialog::getOpenUrl(KUrl(), "application/vnd.kde.kdenlive;*.kdenlive"); + if (url.isEmpty()) return; + m_fileOpenRecent->addUrl (url); + openFile(url); } -void MainWindow::openFile(const QString &inputFileName) //new +void MainWindow::openFile(const KUrl &url) //new { - KdenliveDoc *doc = new KdenliveDoc(KUrl(inputFileName), 25, 720, 576); + KdenliveDoc *doc = new KdenliveDoc(url, 25, 720, 576); TrackView *trackView = new TrackView(doc); m_timelineArea->setCurrentIndex(m_timelineArea->addTab(trackView, QIcon(), doc->documentName())); m_timelineArea->setTabToolTip(m_timelineArea->currentIndex(), doc->url().path()); @@ -254,6 +293,9 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //chang //m_undoView->setStack(0); m_commandStack = doc->commandStack(); + m_overView->setScene(trackView->projectScene()); + m_overView->scale(m_overView->width() / trackView->duration(), m_overView->height() / (50 * trackView->tracksNumber())); + //m_overView->fitInView(m_overView->itemAt(0, 50), Qt::KeepAspectRatio); QAction *redo = m_commandStack->createRedoAction(actionCollection()); QAction *undo = m_commandStack->createUndoAction(actionCollection()); diff --git a/src/mainwindow.h b/src/mainwindow.h index 5c47b182..d429199a 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -23,18 +23,21 @@ #include #include +#include #include #include #include #include #include +#include #include "projectlist.h" #include "monitor.h" #include "monitormanager.h" #include "kdenlivedoc.h" #include "trackview.h" +#include "customtrackview.h" class MainWindow : public KXmlGuiWindow { @@ -42,7 +45,9 @@ class MainWindow : public KXmlGuiWindow public: MainWindow(QWidget *parent=0); - void openFile(const QString &inputFileName); + + protected: + virtual bool queryClose(); private: KTabWidget* m_timelineArea; @@ -74,7 +79,18 @@ class MainWindow : public KXmlGuiWindow KUndoStack *m_commandStack; QAction *m_undo; QAction *m_redo; - + + QDockWidget *overviewDock; + CustomTrackView *m_overView; + + KRecentFilesAction *m_fileOpenRecent; + void readOptions(); + void saveOptions(); + + public slots: + void openFile(const KUrl &url); + + private slots: void newFile(); void activateDocument(); diff --git a/src/projectitem.cpp b/src/projectitem.cpp index 7ac2a3eb..909e7b86 100644 --- a/src/projectitem.cpp +++ b/src/projectitem.cpp @@ -160,6 +160,7 @@ void ProjectItem::slotSetToolTip() void ProjectItem::setProperties(const QMap < QString, QString > &attributes, const QMap < QString, QString > &metadata) { if (attributes.contains("duration")) { + if (m_clipType == DocClipBase::AUDIO || m_clipType == DocClipBase::VIDEO || m_clipType == DocClipBase::AV) m_element.setAttribute("duration", attributes["duration"].toInt()); m_duration = GenTime(attributes["duration"].toInt(), 25); setData(1, DurationRole, Timecode::getEasyTimecode(m_duration, 25)); m_durationKnown = true; @@ -191,6 +192,7 @@ void ProjectItem::setProperties(const QMap < QString, QString > &attributes, con if (m_element.isNull()) { QDomDocument doc; m_element = doc.createElement("producer"); + m_element.setAttribute("duration", attributes["duration"].toInt()); } m_element.setAttribute("resource", attributes["filename"]); m_element.setAttribute("type", (int) m_clipType); diff --git a/src/projectlistview.cpp b/src/projectlistview.cpp index 83bb7a6f..a8ebce7f 100644 --- a/src/projectlistview.cpp +++ b/src/projectlistview.cpp @@ -161,8 +161,8 @@ void ProjectListView::mouseMoveEvent(QMouseEvent *event) mimeData->setText(doc.toString()); //mimeData->setImageData(image); drag->setMimeData(mimeData); - drag->setPixmap(clickItem->icon(0).pixmap(40 *16/9.0, 40)); - drag->setHotSpot(QPoint(0, 20)); + drag->setPixmap(clickItem->icon(0).pixmap(50 *16/9.0, 50)); + drag->setHotSpot(QPoint(0, 50)); drag->start(Qt::MoveAction); //Qt::DropAction dropAction; @@ -199,7 +199,7 @@ QStringList ProjectListView::mimeTypes () const Qt::DropActions ProjectListView::supportedDropActions () const { // returns what actions are supported when dropping - return Qt::MoveAction | Qt::MoveAction; + return Qt::MoveAction; } #include "projectlistview.moc" diff --git a/src/renderer.cpp b/src/renderer.cpp index 8bac2f46..2fb82122 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -197,10 +197,6 @@ QPixmap Render::frameThumbnail(Mlt::Frame *frame, int width, int height, bool bo QPixmap pix(width, height); mlt_image_format format = mlt_image_rgb24a; - /*if (border) { - width = width -2; - height = height -2; - }*/ uint8_t *thumb = frame->get_image(format, width, height); QImage image(thumb, width, height, QImage::Format_ARGB32); @@ -210,12 +206,6 @@ QPixmap Render::frameThumbnail(Mlt::Frame *frame, int width, int height, bool bo QPainter painter(&pix); painter.drawRect(0, 0, width - 1, height - 1); } - /*if (!border) pix = pix.fromImage(image); - //bitBlt(&pix, 0, 0, &image, 0, 0, width, height); - else { - pix.fill(black); - bitBlt(&pix, 1, 1, &image, 0, 0, width, height); - }*/ } else pix.fill(Qt::black); return pix; @@ -419,7 +409,7 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) Mlt::Filter m_convert("avcolour_space"); m_convert.set("forced", mlt_image_rgb24a); producer.attach(m_convert); - + producer.set("profile", "hdv_1080_50i"); Mlt::Frame * frame = producer.get_frame(); if (frame->is_valid()) { diff --git a/src/trackview.cpp b/src/trackview.cpp index 77b76dfe..fa770a59 100644 --- a/src/trackview.cpp +++ b/src/trackview.cpp @@ -1,3 +1,22 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * 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 #include @@ -10,10 +29,11 @@ #include "documentaudiotrack.h" #include "headertrack.h" #include "trackview.h" +#include "clipitem.h" #include "trackpanelclipmovefunction.h" TrackView::TrackView(KdenliveDoc *doc, QWidget *parent) - : QWidget(parent), m_doc(doc), m_scale(1.0), m_panelUnderMouse(NULL), m_function(NULL) + : QWidget(parent), m_doc(doc), m_scale(1.0), m_panelUnderMouse(NULL), m_function(NULL), m_projectTracks(0), m_projectDuration(0) { setMouseTracking(true); view = new Ui::TimeLine_UI(); @@ -23,39 +43,34 @@ TrackView::TrackView(KdenliveDoc *doc, QWidget *parent) layout->addWidget(m_ruler); view->ruler_frame->setLayout(layout); - m_tracksLayout = new QVBoxLayout; - m_tracksLayout->setContentsMargins (0, 0, 0, 0); - m_scrollArea = new QScrollArea; - - m_tracksLayout->addWidget(m_scrollArea); - m_scrollArea->setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOn); - m_scrollArea->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); - m_scrollArea->setWidgetResizable( true ); - - m_scrollBox = new QFrame(m_scrollArea); - //m_scrollBox ->setFlat(false); - m_scrollBox ->setFocusPolicy(Qt::WheelFocus); - m_scrollBox->setSizePolicy( QSizePolicy::Preferred,QSizePolicy::Fixed ); - - m_tracksAreaLayout = new QVBoxLayout(m_scrollBox); - m_tracksAreaLayout->setContentsMargins (0, 0, 0, 0); - m_tracksAreaLayout->setSpacing(0); -//MyScroll->setGeometry(...); - m_scrollArea->setWidget(m_scrollBox); - - view->tracks_frame->setLayout(m_tracksLayout); + m_scene = new QGraphicsScene(); + m_trackview = new CustomTrackView(m_scene, this); + m_trackview->scale(FRAME_SIZE, 1); + m_trackview->setAlignment(Qt::AlignLeft | Qt::AlignTop); + //m_scene->addRect(QRectF(0, 0, 100, 100), QPen(), QBrush(Qt::red)); m_headersLayout = new QVBoxLayout; m_headersLayout->setContentsMargins (0, 0, 0, 0); view->headers_frame->setLayout(m_headersLayout); + QVBoxLayout *tracksLayout = new QVBoxLayout; + tracksLayout->setContentsMargins (0, 0, 0, 0); + view->tracks_frame->setLayout(tracksLayout); + tracksLayout->addWidget(m_trackview); + parseDocument(doc->toXml()); TrackPanelClipMoveFunction *m_moveFunction = new TrackPanelClipMoveFunction(this); registerFunction("move", m_moveFunction); setEditMode("move"); + view->horizontalSlider->setValue(0); + m_currentZoom = view->horizontalSlider->value(); connect(view->horizontalSlider, SIGNAL(valueChanged ( int )), this, SLOT(slotChangeZoom( int ))); + connect(m_ruler, SIGNAL(cursorMoved ( int )), this, SLOT(slotCursorMoved( int ))); + connect(m_trackview, SIGNAL(cursorMoved ( int )), this, SLOT(slotCursorMoved( int ))); + + m_cursorLine = m_scene->addLine(0, 0, 0, 200); //m_trackview->height()); } void TrackView::registerFunction(const QString & name, TrackPanelFunction * function) @@ -63,10 +78,21 @@ void TrackView::registerFunction(const QString & name, TrackPanelFunction * func m_factory.registerFunction(name, function); } +int TrackView::duration() +{ + return m_projectDuration; +} + +int TrackView::tracksNumber() +{ + return m_projectTracks; +} + void TrackView::parseDocument(QDomDocument doc) { QDomNodeList tracks = doc.elementsByTagName("playlist"); m_projectDuration = 300; + m_projectTracks = tracks.count(); int duration; for (int i = 0; i < tracks.count(); i++) { @@ -74,23 +100,37 @@ void TrackView::parseDocument(QDomDocument doc) // this is an audio track duration = slotAddAudioTrack(i, tracks.item(i).toElement()); } - else duration = slotAddVideoTrack(i, tracks.item(i).toElement()); + else if (!tracks.item(i).toElement().attribute("id", QString::null).isEmpty()) + duration = slotAddVideoTrack(i, tracks.item(i).toElement()); if (duration > m_projectDuration) m_projectDuration = duration; } - m_tracksAreaLayout->insertStretch (1000); //m_scrollBox->setGeometry(0, 0, 300 * zoomFactor(), m_scrollArea->height()); } +void TrackView::slotCursorMoved(int pos) +{ + kDebug()<<"///// CURSOR: "<setPos(pos, 0); + m_trackview->setCursorPos(pos); + m_trackview->invalidateScene(QRectF(), QGraphicsScene::ForegroundLayer); +} + void TrackView::slotChangeZoom(int factor) { m_ruler->setPixelPerMark(factor); - m_scale = m_ruler->pixelPerMark(); + //m_scale = m_ruler->pixelPerMark(); + m_scale = (double) m_ruler->comboScale[m_currentZoom] / m_ruler->comboScale[factor]; + //else m_scale = (double) m_ruler->comboScale[m_currentZoom] / m_ruler->comboScale[factor]; + m_currentZoom = factor; + kDebug()<<"///// ZOOMING: "<scale(m_scale, 1); + /* for (int i = 0; i < documentTracks.count(); i++) { kDebug()<<"------REPAINTING OBJECT"; documentTracks.at(i)->update(); //documentTracks.at(i)->setFixedWidth(300 * zoomFactor()); } - m_scrollBox->setFixedWidth(( m_projectDuration + 300) * zoomFactor()); + m_scrollBox->setFixedWidth(( m_projectDuration + 300) * zoomFactor());*/ /*m_scrollArea->horizontalScrollBar()->setMaximum(300 * zoomFactor()); m_scrollArea->horizontalScrollBar()->setPageStep(FRAME_SIZE * zoomFactor());*/ } @@ -112,9 +152,10 @@ KdenliveDoc *TrackView::document() int TrackView::slotAddAudioTrack(int ix, QDomElement xml) { - DocumentTrack *track = new DocumentAudioTrack(xml, this, m_scrollBox); + m_trackview->addTrack(); + DocumentTrack *track = new DocumentAudioTrack(xml, this, m_trackview); HeaderTrack *header = new HeaderTrack(); - m_tracksAreaLayout->addWidget(track); //, ix, Qt::AlignTop); + //m_tracksAreaLayout->addWidget(track); //, ix, Qt::AlignTop); m_headersLayout->addWidget(header); //, ix, Qt::AlignTop); documentTracks.insert(ix, track); return track->duration(); @@ -123,12 +164,37 @@ int TrackView::slotAddAudioTrack(int ix, QDomElement xml) int TrackView::slotAddVideoTrack(int ix, QDomElement xml) { - DocumentTrack *track = new DocumentVideoTrack(xml, this, m_scrollBox); + m_trackview->addTrack(); + DocumentTrack *track = new DocumentVideoTrack(xml, this, m_trackview); HeaderTrack *header = new HeaderTrack(); - m_tracksAreaLayout->addWidget(track); //, ix, Qt::AlignTop); + int trackTop = 50 * ix; + int trackBottom = trackTop + 50; + // parse track + int position = 0; + for(QDomNode n = xml.firstChild(); !n.isNull(); n = n.nextSibling()) + { + QDomElement elem = n.toElement(); + if (elem.tagName() == "blank") { + position += elem.attribute("length", 0).toInt(); + } + else if (elem.tagName() == "entry") { + int in = elem.attribute("in", 0).toInt(); + int out = elem.attribute("out", 0).toInt() - in; + QString clipName = m_doc->producerName(elem.attribute("producer").toInt()); + //kDebug()<<"++++++++++++++\n\n / / /ADDING CLIP: "<addItem(item); + position += out; + + //m_clipList.append(clip); + } + } + //m_trackDuration = position; + + //m_tracksAreaLayout->addWidget(track); //, ix, Qt::AlignTop); m_headersLayout->addWidget(header); //, ix, Qt::AlignTop); documentTracks.insert(ix, track); - return track->duration(); + return position; //track->show(); } @@ -137,6 +203,16 @@ DocumentTrack *TrackView::panelAt(int y) return NULL; } +QGraphicsScene *TrackView::projectScene() +{ + return m_scene; +} + +CustomTrackView *TrackView::projectView() +{ + return m_trackview; +} + void TrackView::setEditMode(const QString & editMode) { m_editMode = editMode; diff --git a/src/trackview.h b/src/trackview.h index 410ecef0..8f82af1f 100644 --- a/src/trackview.h +++ b/src/trackview.h @@ -1,3 +1,23 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) * + * * + * 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 TRACKVIEW_H #define TRACKVIEW_H @@ -5,6 +25,8 @@ #include #include #include +#include +#include #define FRAME_SIZE 90 @@ -14,6 +36,7 @@ #include "documenttrack.h" #include "trackpanelfunctionfactory.h" #include "trackpanelfunction.h" +#include "customtrackview.h" class TrackView : public QWidget { @@ -30,6 +53,10 @@ class TrackView : public QWidget const int mapLocalToValue(int x) const; void setEditMode(const QString & editMode); const QString & editMode() const; + QGraphicsScene *projectScene(); + CustomTrackView *projectView(); + int duration(); + int tracksNumber(); public slots: KdenliveDoc *document(); @@ -37,14 +64,19 @@ class TrackView : public QWidget private: Ui::TimeLine_UI *view; CustomRuler *m_ruler; + CustomTrackView *m_trackview; double m_scale; QList documentTracks; int m_projectDuration; + int m_projectTracks; TrackPanelFunctionFactory m_factory; DocumentTrack *m_panelUnderMouse; /** The currently applied function. This lasts from mousePressed until mouseRelease. */ TrackPanelFunction *m_function; QString m_editMode; + QGraphicsScene *m_scene; + uint m_currentZoom; + QGraphicsLineItem *m_cursorLine; KdenliveDoc *m_doc; QVBoxLayout *m_tracksLayout; @@ -60,6 +92,7 @@ class TrackView : public QWidget private slots: void slotChangeZoom(int factor); + void slotCursorMoved(int pos); }; #endif diff --git a/src/widgets/timeline_ui.ui b/src/widgets/timeline_ui.ui index f66d016e..cf3c7500 100644 --- a/src/widgets/timeline_ui.ui +++ b/src/widgets/timeline_ui.ui @@ -5,8 +5,8 @@ 0 0 - 326 - 145 + 308 + 130 -- 2.39.2