#include <QGraphicsRectItem>
#include <QMenu>
#include <QInputDialog>
+#include <QTimer>
-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),
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));
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));
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()));
- connect(pos_up, SIGNAL(clicked()), this, SLOT(slotPosUp()));
- connect(pos_down, SIGNAL(clicked()), this, SLOT(slotPosDown()));
buttonhcenter->setIcon(KIcon("kdenlive-align-hor"));
buttonhcenter->setToolTip(i18n("Align item horizontally"));
void Geometryval::slotTransparencyChanged(int transp)
{
- int pos;
- if (KdenliveSettings::frametimecode()) pos = timePos->text().toInt();
- else pos = m_timecode.getFrameCount(timePos->text());
+ int pos = m_timePos.getValue();
Mlt::GeometryItem item;
int error = m_geom->fetch(&item, pos);
if (error || item.key() == false) {
void Geometryval::updateTimecodeFormat()
{
- timePos->setInputMask("");
- if (KdenliveSettings::frametimecode()) {
- int frames = m_timecode.getFrameCount(timePos->text());
- QIntValidator *valid = new QIntValidator(this);
- valid->setBottom(0);
- timePos->setValidator(valid);
- timePos->setText(QString::number(frames));
- } else {
- int pos = timePos->text().toInt();
- timePos->setValidator(m_timecode.validator());
- timePos->setText(m_timecode.getTimecodeFromFrames(pos));
- }
-}
-
-void Geometryval::slotPosUp()
-{
- int pos;
- if (KdenliveSettings::frametimecode()) pos = timePos->text().toInt();
- else pos = m_timecode.getFrameCount(timePos->text());
- pos ++;
- if (pos > m_helper->frameLength) pos = m_helper->frameLength;
- if (KdenliveSettings::frametimecode()) {
- timePos->setText(QString::number(pos));
- } else timePos->setText(m_timecode.getTimecodeFromFrames(pos));
- slotPositionChanged();
-}
-
-void Geometryval::slotPosDown()
-{
- int pos;
- if (KdenliveSettings::frametimecode()) pos = timePos->text().toInt();
- else pos = m_timecode.getFrameCount(timePos->text());
- pos --;
- if (pos < 0) pos = 0;
- if (KdenliveSettings::frametimecode()) {
- timePos->setText(QString::number(pos));
- } else timePos->setText(m_timecode.getTimecodeFromFrames(pos));
- slotPositionChanged();
+ m_timePos.slotUpdateTimeCodeFormat();
}
void Geometryval::slotPositionChanged(int pos, bool seek)
{
if (pos == -1) {
- if (KdenliveSettings::frametimecode()) pos = timePos->text().toInt();
- else pos = m_timecode.getFrameCount(timePos->text());
+ pos = m_timePos.getValue();
}
if (seek && KdenliveSettings::transitionfollowcursor()) emit seekToPos(pos + m_startPoint);
- if (KdenliveSettings::frametimecode()) {
- timePos->setText(QString::number(pos));
- } else timePos->setText(m_timecode.getTimecodeFromFrames(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;
- int frame;
- if (KdenliveSettings::frametimecode()) frame = timePos->text().toInt();
- else frame = m_timecode.getFrameCount(timePos->text());
+ int frame = m_timePos.getValue();
if (pos == -1) pos = frame;
int error = m_geom->next_key(&item, pos + 1);
void Geometryval::slotAddFrame(int pos)
{
- int frame;
- if (KdenliveSettings::frametimecode()) frame = timePos->text().toInt();
- else frame = m_timecode.getFrameCount(timePos->text());
+ int frame = m_timePos.getValue();
if (pos == -1) pos = frame;
Mlt::GeometryItem item;
item.frame(pos);
// Go to end
pos = m_helper->frameLength;
} else pos = item.frame();
-
- if (KdenliveSettings::frametimecode()) {
- timePos->setText(QString::number(pos));
- } else timePos->setText(m_timecode.getTimecodeFromFrames(pos));
+ m_timePos.setValue(pos);
slotPositionChanged();
}
kDebug() << "// SEEK TO NEXT KFR: " << error;
if (error) return;
int pos = item.frame();
- if (KdenliveSettings::frametimecode()) {
- timePos->setText(QString::number(pos));
- } else timePos->setText(m_timecode.getTimecodeFromFrames(pos));
+ m_timePos.setValue(pos);
slotPositionChanged();
}
spinTransp->setMaximum(500);
label_pos->setHidden(true);
m_helper->setHidden(true);
- timePos->setHidden(true);
+ m_timePos.setHidden(true);
}
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
slotPositionChanged(0, false);
slotUpdateGeometry();
if (!m_fixedMode) {
- connect(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;
void Geometryval::slotUpdateTransitionProperties()
{
- int pos;
- if (KdenliveSettings::frametimecode()) pos = timePos->text().toInt();
- else pos = m_timecode.getFrameCount(timePos->text());
+ int pos = m_timePos.getValue();
Mlt::GeometryItem item;
int error = m_geom->next_key(&item, pos);
if (error || item.frame() != pos) {
}
}
-void Geometryval::setFrameSize(QPoint p)
+void Geometryval::setFrameSize(const QPoint &p)
{
m_frameSize = p;
}
{
slotPositionChanged(pos);
slotUpdateTransitionProperties();
+ QTimer::singleShot(100, this, SIGNAL(parameterChanged()));
}
void Geometryval::slotSwitchOptions()
bool Geometryval::keyframeSelected()
{
Mlt::GeometryItem item;
- int pos;
- if (KdenliveSettings::frametimecode()) pos = timePos->text().toInt();
- else pos = m_timecode.getFrameCount(timePos->text());
+ 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"