#include <QGraphicsRectItem>
#include <QMenu>
#include <QInputDialog>
+#include <QTimer>
-Geometryval::Geometryval(const MltVideoProfile profile, QPoint frame_size, int startPoint, QWidget* parent) :
+Geometryval::Geometryval(const MltVideoProfile profile, Timecode t, QPoint frame_size, int startPoint, QWidget* parent) :
QWidget(parent),
m_profile(profile),
m_paramRect(NULL),
m_path(NULL),
m_fixedMode(false),
m_frameSize(frame_size),
- m_startPoint(startPoint)
+ m_startPoint(startPoint),
+ m_timePos(t)
{
setupUi(this);
+ toolbarlayout->addWidget(&m_timePos);
+ toolbarlayout->insertStretch(-1);
+
QVBoxLayout* vbox = new QVBoxLayout(widget);
m_sceneview = new QGraphicsView(this);
m_sceneview->setBackgroundBrush(QBrush(Qt::black));
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"));
connect(spinY, SIGNAL(valueChanged(int)), this, SLOT(slotGeometryY(int)));
connect(spinWidth, SIGNAL(valueChanged(int)), this, SLOT(slotGeometryWidth(int)));
connect(spinHeight, SIGNAL(valueChanged(int)), this, SLOT(slotGeometryHeight(int)));
- connect(spinResize, SIGNAL(valueChanged(int)), this, SLOT(slotResizeCustom(int)));
+ connect(spinResize, SIGNAL(editingFinished()), this, SLOT(slotResizeCustom()));
connect(buttonResize, SIGNAL(clicked()), this, SLOT(slotResizeOriginal()));
connect(this, SIGNAL(parameterChanged()), this, SLOT(slotUpdateGeometry()));
slotUpdateTransitionProperties();
}
-void Geometryval::slotResizeCustom(int value)
+void Geometryval::slotResizeCustom()
{
if (!keyframeSelected())
return;
+ int value = spinResize->value();
m_paramRect->setRect(0, 0, m_realWidth * value / 100, m_profile.height * value / 100);
slotUpdateTransitionProperties();
}
void Geometryval::slotTransparencyChanged(int transp)
{
- int pos = spinPos->value();
+ int pos = m_timePos.getValue();
Mlt::GeometryItem item;
int error = m_geom->fetch(&item, pos);
if (error || item.key() == false) {
KdenliveSettings::setTransitionfollowcursor(m_syncAction->isChecked());
}
+void Geometryval::updateTimecodeFormat()
+{
+ m_timePos.slotUpdateTimeCodeFormat();
+}
+
void Geometryval::slotPositionChanged(int pos, bool seek)
{
+ if (pos == -1) {
+ pos = m_timePos.getValue();
+ }
if (seek && KdenliveSettings::transitionfollowcursor()) emit seekToPos(pos + m_startPoint);
- spinPos->setValue(pos);
+ 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) {
{
// check there is more than one keyframe
Mlt::GeometryItem item;
- if (pos == -1) pos = spinPos->value();
+ int frame = m_timePos.getValue();
+
+ if (pos == -1) pos = frame;
int error = m_geom->next_key(&item, pos + 1);
if (error) {
error = m_geom->prev_key(&item, pos - 1);
if (error || item.frame() == pos) return;
}
- m_geom->remove(spinPos->value());
+ m_geom->remove(frame);
buttonAdd->setEnabled(true);
buttonDelete->setEnabled(false);
widget->setEnabled(false);
void Geometryval::slotAddFrame(int pos)
{
- if (pos == -1) pos = spinPos->value();
+ int frame = m_timePos.getValue();
+ if (pos == -1) pos = frame;
Mlt::GeometryItem item;
item.frame(pos);
QRectF r = m_paramRect->rect().normalized();
{
Mlt::GeometryItem item;
int error = m_geom->next_key(&item, m_helper->value() + 1);
+ int pos;
kDebug() << "// SEEK TO NEXT KFR: " << error;
if (error) {
// Go to end
- spinPos->setValue(spinPos->maximum());
- return;
- }
- int pos = item.frame();
- spinPos->setValue(pos);
+ pos = m_helper->frameLength;
+ } else pos = item.frame();
+ m_timePos.setValue(pos);
+ slotPositionChanged();
}
void Geometryval::slotPreviousFrame()
kDebug() << "// SEEK TO NEXT KFR: " << error;
if (error) return;
int pos = item.frame();
- spinPos->setValue(pos);
+ m_timePos.setValue(pos);
+ slotPositionChanged();
}
spinTransp->setMaximum(500);
label_pos->setHidden(true);
m_helper->setHidden(true);
- spinPos->setHidden(true);
+ m_timePos.setHidden(true);
+ }
+ if (par.attribute("opacity") == "false") {
+ label_opacity->setHidden(true);
+ spinTransp->setHidden(true);
}
- 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
/*QDomDocument doc;
doc.appendChild(doc.importNode(par, true));
kDebug() << "IMPORTED TRANS: " << doc.toString();*/
- spinPos->setMaximum(maxFrame - minFrame - 1);
if (m_path == NULL) {
m_path = new QGraphicsPathItem();
m_path->setPen(QPen(Qt::red));
slotPositionChanged(0, false);
slotUpdateGeometry();
if (!m_fixedMode) {
- connect(spinPos, SIGNAL(valueChanged(int)), this , SLOT(slotPositionChanged(int)));
+ m_timePos.setRange(0, maxFrame - minFrame - 1);
+ connect(&m_timePos, SIGNAL(editingFinished()), 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;
void Geometryval::slotUpdateTransitionProperties()
{
- int pos = spinPos->value();
+ int pos = m_timePos.getValue();
Mlt::GeometryItem item;
int error = m_geom->next_key(&item, pos);
if (error || item.frame() != pos) {
{
slotPositionChanged(pos);
slotUpdateTransitionProperties();
+ QTimer::singleShot(100, this, SIGNAL(parameterChanged()));
}
void Geometryval::slotSwitchOptions()
frameOptions->setHidden(true);
m_editOptions->setChecked(false);
}
- adjustSize();
+ //adjustSize();
}
void Geometryval::slotGeometryX(int value)
bool Geometryval::keyframeSelected()
{
Mlt::GeometryItem item;
- if (m_geom->fetch(&item, spinPos->value()) || item.key() == false) return false;
+ int pos = m_timePos.getValue();
+ if (m_geom->fetch(&item, pos) || item.key() == false) return false;
return true;
}