X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fgeometryval.cpp;h=7fa246e65c99893f9003940ea58f35efe66ccfea;hb=c3302003093710ee247ad84c0fe2ef3c579d417f;hp=b6c5e823ff7634ebff7e98698152a09c9d84197e;hpb=997748156e63b2e28c313521d7ff43e5ed77cb41;p=kdenlive diff --git a/src/geometryval.cpp b/src/geometryval.cpp index b6c5e823..7fa246e6 100644 --- a/src/geometryval.cpp +++ b/src/geometryval.cpp @@ -26,12 +26,12 @@ #include #include #include +#include -Geometryval::Geometryval(const MltVideoProfile profile, Timecode t, QPoint frame_size, int startPoint, QWidget* parent) : +Geometryval::Geometryval(const MltVideoProfile &profile, const Timecode &t, const QPoint &frame_size, int startPoint, QWidget* parent) : QWidget(parent), m_profile(profile), - m_timecode(t), m_paramRect(NULL), m_geom(NULL), m_path(NULL), @@ -41,7 +41,6 @@ Geometryval::Geometryval(const MltVideoProfile profile, Timecode t, QPoint frame m_timePos(t) { setupUi(this); - m_timePos.setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding); toolbarlayout->addWidget(&m_timePos); toolbarlayout->insertStretch(-1); @@ -66,7 +65,7 @@ Geometryval::Geometryval(const MltVideoProfile profile, Timecode t, QPoint frame m_sceneview->setScene(m_scene); m_dar = (m_profile.height * m_profile.display_aspect_num / (double) m_profile.display_aspect_den) / (double) m_profile.width; - m_realWidth = (int)(profile.height * profile.display_aspect_num / (double) profile.display_aspect_den); + m_realWidth = (int)(profile.height * profile.display_aspect_num / (double) profile.display_aspect_den + 0.5); QGraphicsRectItem *frameBorder = new QGraphicsRectItem(QRectF(0, 0, m_realWidth, profile.height)); frameBorder->setZValue(-1100); frameBorder->setBrush(QColor(255, 255, 0, 30)); @@ -111,7 +110,6 @@ Geometryval::Geometryval(const MltVideoProfile profile, Timecode t, QPoint frame connect(buttonDelete , SIGNAL(clicked()) , this , SLOT(slotDeleteFrame())); connect(buttonAdd , SIGNAL(clicked()) , this , SLOT(slotAddFrame())); connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateTransitionProperties())); - connect(m_scene, SIGNAL(doubleClickEvent()), this, SLOT(slotGeometry())); buttonhcenter->setIcon(KIcon("kdenlive-align-hor")); buttonhcenter->setToolTip(i18n("Align item horizontally")); @@ -227,7 +225,7 @@ void Geometryval::slotResizeCustom() void Geometryval::slotTransparencyChanged(int transp) { - int pos = m_timePos.value(); + int pos = m_timePos.getValue(); Mlt::GeometryItem item; int error = m_geom->fetch(&item, pos); if (error || item.key() == false) { @@ -247,18 +245,20 @@ void Geometryval::slotSyncCursor() void Geometryval::updateTimecodeFormat() { - m_timePos.slotPrepareTimeCodeFormat(m_timecode); + m_timePos.slotUpdateTimeCodeFormat(); } void Geometryval::slotPositionChanged(int pos, bool seek) { if (pos == -1) { - pos = m_timePos.value(); + pos = m_timePos.getValue(); } if (seek && KdenliveSettings::transitionfollowcursor()) emit seekToPos(pos + m_startPoint); m_timePos.setValue(pos); //spinPos->setValue(pos); + m_helper->blockSignals(true); m_helper->setValue(pos); + m_helper->blockSignals(false); Mlt::GeometryItem item; int error = m_geom->fetch(&item, pos); if (error || item.key() == false) { @@ -289,7 +289,7 @@ void Geometryval::slotDeleteFrame(int pos) { // check there is more than one keyframe Mlt::GeometryItem item; - int frame = m_timePos.value(); + int frame = m_timePos.getValue(); if (pos == -1) pos = frame; int error = m_geom->next_key(&item, pos + 1); @@ -313,7 +313,7 @@ void Geometryval::slotDeleteFrame(int pos) void Geometryval::slotAddFrame(int pos) { - int frame = m_timePos.value(); + int frame = m_timePos.getValue(); if (pos == -1) pos = frame; Mlt::GeometryItem item; item.frame(pos); @@ -383,13 +383,11 @@ void Geometryval::setupParam(const QDomElement par, int minFrame, int maxFrame) if (par.attribute("opacity") == "false") { label_opacity->setHidden(true); spinTransp->setHidden(true); - } else if (par.attribute("opacity") == "nonzero") { - spinTransp->setMinimum(1); } - char *tmp = (char *) qstrdup(val.toUtf8().data()); - if (m_geom) m_geom->parse(tmp, maxFrame - minFrame, m_profile.width, m_profile.height); - else m_geom = new Mlt::Geometry(tmp, maxFrame - minFrame, m_profile.width, m_profile.height); - delete[] tmp; + if (m_geom) + m_geom->parse(val.toUtf8().data(), maxFrame - minFrame, m_profile.width, m_profile.height); + else + m_geom = new Mlt::Geometry(val.toUtf8().data(), maxFrame - minFrame, m_profile.width, m_profile.height); //kDebug() << " / / UPDATING TRANSITION VALUE: " << m_geom->serialise(); //read param her and set rect @@ -420,12 +418,22 @@ void Geometryval::setupParam(const QDomElement par, int minFrame, int maxFrame) slotPositionChanged(0, false); slotUpdateGeometry(); if (!m_fixedMode) { - m_timePos.setMaximum(maxFrame - minFrame - 1); - connect(&m_timePos, SIGNAL(editingFinished()), this , SLOT(slotPositionChanged())); + m_timePos.setRange(0, maxFrame - minFrame - 1); + connect(&m_timePos, SIGNAL(timeCodeEditingFinished()), this , SLOT(slotPositionChanged())); } connect(spinTransp, SIGNAL(valueChanged(int)), this , SLOT(slotTransparencyChanged(int))); } +void Geometryval::slotSyncPosition(int relTimelinePos) +{ + if (m_timePos.maximum() > 0 && KdenliveSettings::transitionfollowcursor()) { + relTimelinePos = qMax(0, relTimelinePos); + relTimelinePos = qMin(relTimelinePos, m_timePos.maximum()); + if (relTimelinePos != m_timePos.getValue()) + slotPositionChanged(relTimelinePos, false); + } +} + void Geometryval::updateTransitionPath() { if (m_fixedMode) return; @@ -449,7 +457,7 @@ void Geometryval::updateTransitionPath() void Geometryval::slotUpdateTransitionProperties() { - int pos = m_timePos.value(); + int pos = m_timePos.getValue(); Mlt::GeometryItem item; int error = m_geom->next_key(&item, pos); if (error || item.frame() != pos) { @@ -481,7 +489,7 @@ void Geometryval::slotResetPosition() } } -void Geometryval::setFrameSize(QPoint p) +void Geometryval::setFrameSize(const QPoint &p) { m_frameSize = p; } @@ -491,6 +499,7 @@ void Geometryval::slotKeyframeMoved(int pos) { slotPositionChanged(pos); slotUpdateTransitionProperties(); + QTimer::singleShot(100, this, SIGNAL(parameterChanged())); } void Geometryval::slotSwitchOptions() @@ -563,10 +572,17 @@ void Geometryval::slotUpdateGeometry() bool Geometryval::keyframeSelected() { Mlt::GeometryItem item; - int pos = m_timePos.value(); + int pos = m_timePos.getValue(); if (m_geom->fetch(&item, pos) || item.key() == false) return false; return true; } +void Geometryval::slotUpdateRange(int inPoint, int outPoint) +{ + m_helper->setKeyGeometry(m_geom, outPoint - inPoint - 1); + m_helper->update(); + m_timePos.setRange(0, outPoint - inPoint - 1); +} +#include "geometryval.moc"