From: Jean-Baptiste Mardelle Date: Sat, 30 Jan 2010 12:44:48 +0000 (+0000) Subject: When editing clip properties, changing crop start should not move the clip end, based... X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=c13c4861178fb86d8bf8b475621083ff933ab4b4;p=kdenlive When editing clip properties, changing crop start should not move the clip end, based on patch from Till Theato svn path=/trunk/kdenlive/; revision=4252 --- diff --git a/src/clipdurationdialog.cpp b/src/clipdurationdialog.cpp index 884a0318..58243e91 100644 --- a/src/clipdurationdialog.cpp +++ b/src/clipdurationdialog.cpp @@ -27,10 +27,12 @@ #include -ClipDurationDialog::ClipDurationDialog(AbstractClipItem *clip, Timecode tc, QWidget * parent): +ClipDurationDialog::ClipDurationDialog(AbstractClipItem *clip, Timecode tc, GenTime min, GenTime max, QWidget * parent): QDialog(parent), m_clip(clip), - m_tc(tc) + m_tc(tc), + m_min(min), + m_max(max) { setFont(KGlobalSettings::toolBarFont()); m_fps = m_tc.fps(); @@ -50,6 +52,7 @@ ClipDurationDialog::ClipDurationDialog(AbstractClipItem *clip, Timecode tc, QWid m_view.crop_label->hide(); } + m_crop = m_clip->cropStart().frames(m_fps); m_view.clip_position->setText(tc.getTimecode(m_clip->startPos())); m_view.crop_position->setText(tc.getTimecode(m_clip->cropStart())); m_view.clip_duration->setText(tc.getTimecode(m_clip->cropDuration())); @@ -60,6 +63,8 @@ ClipDurationDialog::ClipDurationDialog(AbstractClipItem *clip, Timecode tc, QWid connect(m_view.duration_up, SIGNAL(clicked()), this, SLOT(slotDurUp())); connect(m_view.duration_down, SIGNAL(clicked()), this, SLOT(slotDurDown())); connect(m_view.crop_position, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckCrop())); + connect(m_view.clip_duration, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckDuration())); + connect(m_view.clip_position, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckStart())); adjustSize(); } @@ -67,14 +72,6 @@ ClipDurationDialog::~ClipDurationDialog() { } -void ClipDurationDialog::setMargins(GenTime min, GenTime max) -{ - m_min = min; - m_max = max; - connect(m_view.clip_position, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckStart())); - connect(m_view.clip_duration, SIGNAL(textChanged(const QString &)), this, SLOT(slotCheckDuration())); -} - void ClipDurationDialog::slotCheckStart() { int pos = m_tc.getFrameCount(m_view.clip_position->text()); @@ -92,13 +89,17 @@ void ClipDurationDialog::slotCheckDuration() { int pos = m_tc.getFrameCount(m_view.clip_position->text()); int dur = m_tc.getFrameCount(m_view.clip_duration->text()); + int crop = m_tc.getFrameCount(m_view.crop_position->text()); GenTime start(pos, m_fps); GenTime duration(dur, m_fps); + GenTime cropStart(crop, m_fps); GenTime maxDuration; if (m_clip->maxDuration() == GenTime()) maxDuration = m_max; - else maxDuration = m_max == GenTime() ? start + m_clip->maxDuration() : qMin(m_max, start + m_clip->maxDuration()); + else maxDuration = m_max == GenTime() ? start + m_clip->maxDuration() - cropStart : qMin(m_max, start + m_clip->maxDuration() - cropStart); if (maxDuration != GenTime() && start + duration > maxDuration) { + m_view.clip_duration->blockSignals(true); m_view.clip_duration->setText(m_tc.getTimecode(maxDuration - start)); + m_view.clip_duration->blockSignals(false); } } @@ -106,11 +107,23 @@ void ClipDurationDialog::slotCheckCrop() { int dur = m_tc.getFrameCount(m_view.clip_duration->text()); int crop = m_tc.getFrameCount(m_view.crop_position->text()); + int diff = crop - m_crop; + if ((diff > 0 && diff < dur) || diff < 0) { + dur -= diff; + } else { + m_view.crop_position->setText(m_tc.getTimecode(GenTime(m_crop, m_fps))); + return; + } GenTime duration(dur, m_fps); GenTime cropStart(crop, m_fps); GenTime maxDuration = m_clip->maxDuration(); if (maxDuration != GenTime() && cropStart + duration > maxDuration) { - m_view.crop_position->setText(m_tc.getTimecode(maxDuration - duration)); + m_view.crop_position->setText(m_tc.getTimecode(GenTime(m_crop, m_fps))); + } else { + m_crop = crop; + m_view.clip_duration->blockSignals(true); + m_view.clip_duration->setText(m_tc.getTimecode(duration)); + m_view.clip_duration->blockSignals(false); } } diff --git a/src/clipdurationdialog.h b/src/clipdurationdialog.h index aaac24c9..17a57d07 100644 --- a/src/clipdurationdialog.h +++ b/src/clipdurationdialog.h @@ -32,12 +32,11 @@ class ClipDurationDialog : public QDialog Q_OBJECT public: - ClipDurationDialog(AbstractClipItem *clip, Timecode tc, QWidget * parent = 0); + ClipDurationDialog(AbstractClipItem *clip, Timecode tc, GenTime min, GenTime max, QWidget * parent = 0); ~ClipDurationDialog(); GenTime startPos() const; GenTime cropStart() const; GenTime duration() const; - void setMargins(GenTime min, GenTime max); protected: void wheelEvent(QWheelEvent * event); @@ -60,6 +59,7 @@ private: double m_fps; GenTime m_min; GenTime m_max; + int m_crop; }; diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 17ddcc78..5c4e3029 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -1209,7 +1209,6 @@ void CustomTrackView::mouseDoubleClickEvent(QMouseEvent *event) emit clipItemSelected(item, item->selectedEffectIndex()); } } else if (m_dragItem && !m_dragItem->isItemLocked()) { - ClipDurationDialog d(m_dragItem, m_document->timecode(), this); GenTime minimum; GenTime maximum; if (m_dragItem->type() == TRANSITIONWIDGET) { @@ -1218,7 +1217,7 @@ void CustomTrackView::mouseDoubleClickEvent(QMouseEvent *event) getClipAvailableSpace(m_dragItem, minimum, maximum); } //kDebug()<<"// GOT MOVE POS: "<timecode(), minimum, maximum, this); if (d.exec() == QDialog::Accepted) { if (m_dragItem->type() == TRANSITIONWIDGET) { // move & resize transition