m_playIcon = KIcon("media-playback-start");
m_pauseIcon = KIcon("media-playback-pause");
- toolbar->addAction(KIcon("kdenlive-zone-start"), i18n("Set zone start"), this, SLOT(slotSetZoneStart()));
- toolbar->addAction(KIcon("kdenlive-zone-end"), i18n("Set zone end"), this, SLOT(slotSetZoneEnd()));
+ QAction *zoneStart = toolbar->addAction(KIcon("kdenlive-zone-start"), i18n("Set zone start"), this, SLOT(slotSetZoneStart()));
+ QAction *zoneEnd = toolbar->addAction(KIcon("kdenlive-zone-end"), i18n("Set zone end"), this, SLOT(slotSetZoneEnd()));
toolbar->addAction(KIcon("media-seek-backward"), i18n("Rewind"), this, SLOT(slotRewind()));
toolbar->addAction(KIcon("media-skip-backward"), i18n("Rewind 1 frame"), this, SLOT(slotRewindOneFrame()));
m_playAction = playMenu->addAction(m_playIcon, i18n("Play"));
m_playAction->setCheckable(true);
connect(m_playAction, SIGNAL(triggered()), this, SLOT(slotPlay()));
- playMenu->addAction(m_playIcon, i18n("Play Section"), this, SLOT(slotPlay()));
- playMenu->addAction(m_playIcon, i18n("Loop Section"), this, SLOT(slotPlay()));
+ playMenu->addAction(m_playIcon, i18n("Play Section"), this, SLOT(slotPlayZone()));
+ playMenu->addAction(m_playIcon, i18n("Loop Section"), this, SLOT(slotLoopZone()));
toolbar->addAction(KIcon("media-skip-forward"), i18n("Forward 1 frame"), this, SLOT(slotForwardOneFrame()));
toolbar->addAction(KIcon("media-seek-forward"), i18n("Forward"), this, SLOT(slotForward()));
m_contextMenu = new QMenu(this);
m_contextMenu->addMenu(playMenu);
+
+ QMenu *goMenu = new QMenu(i18n("Go to..."), this);
+ goMenu->addAction(i18n("Start"), this, SLOT(slotStart()));
+ goMenu->addAction(i18n("End"), this, SLOT(slotEnd()));
+ goMenu->addAction(i18n("Zone start"), this, SLOT(slotZoneStart()));
+ goMenu->addAction(i18n("Zone end"), this, SLOT(slotZoneEnd()));
+ m_contextMenu->addMenu(goMenu);
+
+ m_contextMenu->addAction(zoneStart);
+ m_contextMenu->addAction(zoneEnd);
+
QAction *extractFrame = m_contextMenu->addAction(KIcon("document-new"), i18n("Extract frame"), this, SLOT(slotExtractCurrentFrame()));
connect(m_ruler, SIGNAL(seekRenderer(int)), this, SLOT(slotSeek(int)));
+ connect(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SIGNAL(zoneUpdated(QPoint)));
connect(render, SIGNAL(durationChanged(int)), this, SLOT(adjustRulerSize(int)));
connect(render, SIGNAL(rendererPosition(int)), this, SLOT(seekCursor(int)));
connect(render, SIGNAL(rendererStopped(int)), this, SLOT(rendererStopped(int)));
mimeData->setData("kdenlive/clip", data);
drag->setMimeData(mimeData);
QPixmap pix = m_currentClip->thumbnail();
+ kDebug() << "/ / / /CLIP DRAGGED PIXMAP: " << pix.width() << "x" << pix.height();
drag->setPixmap(pix);
drag->setHotSpot(QPoint(0, 50));
drag->start(Qt::MoveAction);
m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(m_position));
}
+void Monitor::slotZoneStart() {
+ if (!m_isActive) m_monitorManager->activateMonitor(m_name);
+ render->play(0);
+ m_position = m_ruler->zone().x();
+ render->seekToFrame(m_position);
+ emit renderPosition(m_position);
+ m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(m_position));
+}
+
+void Monitor::slotZoneEnd() {
+ if (!m_isActive) m_monitorManager->activateMonitor(m_name);
+ render->play(0);
+ m_position = m_ruler->zone().y();
+ render->seekToFrame(m_position);
+ emit renderPosition(m_position);
+ m_timePos->setText(m_monitorManager->timecode().getTimecodeFromFrames(m_position));
+}
+
void Monitor::slotRewind(double speed) {
if (!m_isActive) m_monitorManager->activateMonitor(m_name);
if (speed == 0) {
m_playAction->setIcon(m_pauseIcon);
}
+void Monitor::slotPlayZone() {
+ if (render == NULL) return;
+ if (!m_isActive) m_monitorManager->activateMonitor(m_name);
+ QPoint p = m_ruler->zone();
+ render->playZone(GenTime(p.x(), render->fps()), GenTime(p.y(), render->fps()));
+ m_playAction->setChecked(true);
+ m_playAction->setIcon(m_pauseIcon);
+}
+
+void Monitor::slotLoopZone() {
+ if (render == NULL) return;
+ if (!m_isActive) m_monitorManager->activateMonitor(m_name);
+ QPoint p = m_ruler->zone();
+ render->loopZone(GenTime(p.x(), render->fps()), GenTime(p.y(), render->fps()));
+ m_playAction->setChecked(true);
+ m_playAction->setIcon(m_pauseIcon);
+}
+
void Monitor::slotSetXml(DocClipBase *clip, const int position) {
if (render == NULL) return;
if (!m_isActive) m_monitorManager->activateMonitor(m_name);
void start();
void activateMonitor();
void slotPlay();
+ void slotPlayZone();
+ void slotLoopZone();
void slotForward(double speed = 0);
void slotRewind(double speed = 0);
void slotRewindOneFrame();
void saveSceneList(QString path, QDomElement info = QDomElement());
void slotStart();
void slotEnd();
+ void slotZoneStart();
+ void slotZoneEnd();
void slotZoneMoved(int start, int end);
signals:
}
}
-Render::Render(const QString & rendererName, int winid, int extid, QWidget *parent): QObject(parent), m_name(rendererName), m_mltConsumer(NULL), m_mltProducer(NULL), m_mltTextProducer(NULL), m_winid(winid), m_externalwinid(extid), m_framePosition(0), m_isBlocked(true), m_blackClip(NULL), m_isSplitView(false) {
+Render::Render(const QString & rendererName, int winid, int extid, QWidget *parent): QObject(parent), m_name(rendererName), m_mltConsumer(NULL), m_mltProducer(NULL), m_mltTextProducer(NULL), m_winid(winid), m_externalwinid(extid), m_framePosition(0), m_isBlocked(true), m_blackClip(NULL), m_isSplitView(false), m_isZoneMode(false), m_isLoopMode(false) {
kDebug() << "////////// USING PROFILE: " << (char*)KdenliveSettings::current_profile().toUtf8().data();
refreshTimer = new QTimer(this);
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
- if (rendererName == "project") m_monitorId = 10000;
- else m_monitorId = 10001;
+ /*if (rendererName == "project") m_monitorId = 10000;
+ else m_monitorId = 10001;*/
osdTimer = new QTimer(this);
connect(osdTimer, SIGNAL(timeout()), this, SLOT(slotOsdTimeout()));
/** Wraps the VEML command of the same name; Seeks the renderer clip to the given time. */
void Render::seek(GenTime time) {
- sendSeekCommand(time);
- //emit positionChanged(time);
+ if (!m_mltProducer)
+ return;
+ //kDebug()<<"////////// KDENLIVE SEEK: "<<(int) (time.frames(m_fps));
+ m_mltProducer->seek((int)(time.frames(m_fps)));
+ refresh();
}
//static
m_isBlocked = true;
if (m_mltProducer) {
+ if (m_isZoneMode) resetZoneMode();
m_mltProducer->set_speed(0.0);
//m_mltProducer->set("out", m_mltProducer->get_length() - 1);
//kDebug() << m_mltProducer->get_length();
kDebug() << "///////////// RENDER STOP-------2";
if (m_mltProducer) {
+ if (m_isZoneMode) resetZoneMode();
m_mltProducer->set_speed(0.0);
m_mltProducer->seek((int) startTime.frames(m_fps));
}
void Render::switchPlay() {
if (!m_mltProducer || !m_mltConsumer)
return;
+ if (m_isZoneMode) resetZoneMode();
if (m_mltProducer->get_speed() == 0.0) {
//m_isBlocked = false;
m_mltProducer->set_speed(1.0);
refresh();
}
-void Render::play(double speed, const GenTime & startTime) {
- kDebug() << "///////////// RENDER PLAY2-------" << speed;
- if (!m_mltProducer)
+void Render::play(const GenTime & startTime) {
+ if (!m_mltProducer || !m_mltConsumer)
return;
- //m_mltProducer->set("out", m_mltProducer->get_length() - 1);
- //if (speed == 0.0) m_mltConsumer->set("refresh", 0);
- m_mltProducer->set_speed(speed);
m_mltProducer->seek((int)(startTime.frames(m_fps)));
- //m_mltConsumer->purge();
- //refresh();
+ m_mltProducer->set_speed(1.0);
+ m_mltConsumer->set("refresh", 1);
}
-void Render::play(double speed, const GenTime & startTime,
- const GenTime & stopTime) {
- kDebug() << "///////////// RENDER PLAY3-------" << speed << stopTime.frames(m_fps);
- if (!m_mltProducer)
+void Render::loopZone(const GenTime & startTime, const GenTime & stopTime) {
+ if (!m_mltProducer || !m_mltConsumer)
+ return;
+ //m_mltProducer->set("eof", "loop");
+ m_isLoopMode = true;
+ m_loopStart = startTime;
+ playZone(startTime, stopTime);
+}
+
+void Render::playZone(const GenTime & startTime, const GenTime & stopTime) {
+ if (!m_mltProducer || !m_mltConsumer)
return;
m_mltProducer->set("out", stopTime.frames(m_fps));
m_mltProducer->seek((int)(startTime.frames(m_fps)));
- m_mltConsumer->purge();
- m_mltProducer->set_speed(speed);
- refresh();
+ m_mltProducer->set_speed(1.0);
+ m_mltConsumer->set("refresh", 1);
+ m_isZoneMode = true;
}
-
-void Render::sendSeekCommand(GenTime time) {
- //kDebug()<<" ********* RENDER SEND SEEK";
- if (!m_mltProducer)
- return;
- //kDebug()<<"////////// KDENLIVE SEEK: "<<(int) (time.frames(m_fps));
- m_mltProducer->seek((int)(time.frames(m_fps)));
- refresh();
+void Render::resetZoneMode() {
+ m_mltProducer->set("out", m_mltProducer->get_length() - 1);
+ //m_mltProducer->set("eof", "pause");
+ m_isZoneMode = false;
+ m_isLoopMode = false;
}
void Render::seekToFrame(int pos) {
//kDebug()<<" ********* RENDER SEEK TO POS";
if (!m_mltProducer)
return;
+ resetZoneMode();
m_mltProducer->seek(pos);
refresh();
}
}
}
-/** Sets the description of this renderer to desc. */
-void Render::setDescription(const QString & description) {
- m_description = description;
-}
-
-/** Returns the description of this renderer */
-QString Render::description() {
- return m_description;
-}
-
-
double Render::playSpeed() {
if (m_mltProducer) return m_mltProducer->get_speed();
return 0.0;
// This is used to know when the playing stopped
if (m_mltProducer) {
double pos = m_mltProducer->position();
+ if (m_isLoopMode) play(m_loopStart);
+ else if (m_isZoneMode) resetZoneMode();
emit rendererStopped((int) pos);
//if (qApp->activeWindow()) QApplication::postEvent(qApp->activeWindow(), new PositionChangeEvent(GenTime((int) pos, m_fps), m_monitorId + 100));
//new QCustomEvent(10002));
play the current scene at the speed specified, relative to normal
playback. e.g. 1.0 is normal speed, 0.0 is paused, -1.0 means play
backwards. Specifes the start/stop times for playback.*/
- void play(double speed, const GenTime & startTime);
- void play(double speed, const GenTime & startTime,
- const GenTime & stopTime);
-
- /** Returns the description of this renderer */
- QString description();
+ void play(const GenTime & startTime);
+ void playZone(const GenTime & startTime, const GenTime & stopTime);
+ void loopZone(const GenTime & startTime, const GenTime & stopTime);
/** Returns the name of the renderer. */
const QString & rendererName() const;
Mlt::Profile *m_mltProfile;
double m_framePosition;
double m_fps;
- uint m_monitorId;
+
+ /** true if we are playing a zone (ie the in and out properties have been temporarily changed) */
+ bool m_isZoneMode;
+ bool m_isLoopMode;
+ GenTime m_loopStart;
+
/** true when monitor is in split view (several tracks at the same time) */
bool m_isSplitView;
QTimer *refreshTimer;
QTimer *osdTimer;
KUrl m_exportedFile;
- int exportDuration, firstExportFrame, lastExportFrame;
/** A human-readable description of this renderer. */
- QString m_description;
int m_winid;
int m_externalwinid;
- /** The actually seek command, private so people can't avoid the buffering of multiple seek commands. */
- void sendSeekCommand(GenTime time);
/** Sets the description of this renderer to desc. */
- void setDescription(const QString & description);
void closeMlt();
void mltCheckLength(bool reload = true);
QMap<QString, QString> mltGetTransitionParamsFromXml(QDomElement xml);
QMap<QString, Mlt::Producer *> m_slowmotionProducers;
void buildConsumer();
+ void resetZoneMode();
private slots: // Private slots
/** refresh monitor display */
// virtual
void SmallRuler::mousePressEvent(QMouseEvent * event) {
const int pos = event->x() / m_scale;
- emit seekRenderer((int) pos);
+ if (event->button() == Qt::RightButton) {
+ // Right button clicked, move selection zone
+ if (qAbs(pos - m_zoneStart) < qAbs(pos - m_zoneEnd)) m_zoneStart = pos;
+ else m_zoneEnd = pos;
+ emit zoneChanged(QPoint(m_zoneStart, m_zoneEnd));
+ update();
+
+ } else emit seekRenderer((int) pos);
}
// virtual
void SmallRuler::mouseMoveEvent(QMouseEvent * event) {
const int pos = event->x() / m_scale;
- emit seekRenderer((int) pos);
+ if (event->buttons() & Qt::LeftButton) emit seekRenderer((int) pos);
}
void SmallRuler::slotNewValue(int value) {
signals:
void seekRenderer(int);
+ void zoneChanged(QPoint);
};
#endif