#include <QVBoxLayout>
#include <QGridLayout>
-GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos, bool isEffect, QWidget* parent ):
+
+
+GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos, bool isEffect, QWidget* parent):
QWidget(parent),
m_monitor(monitor),
m_timePos(new TimecodeDisplay(timecode)),
connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateGeometry()));
+ connect(m_scene, SIGNAL(addKeyframe()), this, SLOT(slotAddKeyframe()));
connect(m_monitor, SIGNAL(renderPosition(int)), this, SLOT(slotCheckMonitorPosition(int)));
connect(this, SIGNAL(parameterChanged()), this, SLOT(slotUpdateProperties()));
}
m_inPoint = minframe;
m_outPoint = maxframe;
- char *tmp = (char *) qstrdup(elem.attribute("value").toUtf8().data());
if (m_geometry)
- m_geometry->parse(tmp, maxframe - minframe, m_monitor->render->renderWidth(), m_monitor->render->renderHeight());
+ m_geometry->parse(elem.attribute("value").toUtf8().data(), maxframe - minframe, m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
else
- m_geometry = new Mlt::Geometry(tmp, maxframe - minframe, m_monitor->render->renderWidth(), m_monitor->render->renderHeight());
- delete[] tmp;
-
- // remove keyframes out of range
- Mlt::GeometryItem invalidItem;
- bool foundInvalidItem = false;
- while (!m_geometry->next_key(&invalidItem, maxframe - minframe)) {
- foundInvalidItem = true;
- m_geometry->remove(invalidItem.frame());
- }
+ m_geometry = new Mlt::Geometry(elem.attribute("value").toUtf8().data(), maxframe - minframe, m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
- if (elem.attribute("fixed") == "1") {
+ if (elem.attribute("fixed") == "1" || maxframe < minframe) {
// Keyframes are disabled
m_ui.widgetTimeWrapper->setHidden(true);
} else {
m_geometry->fetch(&item, 0);
delete m_rect;
- m_rect = new QGraphicsRectItem(QRectF(0, 0, item.w(), item.h()));
+ m_rect = new QGraphicsRectHandleItem(QRectF(0, 0, item.w(), item.h()));
m_rect->setPos(item.x(), item.y());
m_rect->setZValue(0);
m_rect->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
slotPositionChanged(0, false);
slotCheckMonitorPosition(m_monitor->render->seekFramePosition());
-
- // update if we had to remove a keyframe which got out of range
- if (foundInvalidItem)
- QTimer::singleShot(300, this, SIGNAL(parameterChanged()));
}
void GeometryWidget::slotSyncPosition(int relTimelinePos)
void GeometryWidget::slotPositionChanged(int pos, bool seek)
{
- if (pos == -1) {
+ if (pos == -1)
pos = m_timePos->getValue();
- m_timeline->blockSignals(true);
- m_timeline->setValue(pos);
- m_timeline->blockSignals(false);
- } else {
+ else
m_timePos->setValue(pos);
- }
+
+ m_timeline->blockSignals(true);
+ m_timeline->setValue(pos);
+ m_timeline->blockSignals(false);
Mlt::GeometryItem item;
if (m_geometry->fetch(&item, pos) || item.key() == false) {
// no keyframe
+ m_rect->drawHandles = false;
m_scene->setEnabled(false);
m_ui.widgetGeometry->setEnabled(false);
m_ui.buttonAddDelete->setIcon(KIcon("document-new"));
m_ui.buttonAddDelete->setToolTip(i18n("Add keyframe"));
} else {
// keyframe
+ m_rect->drawHandles = true;
m_scene->setEnabled(true);
m_ui.widgetGeometry->setEnabled(true);
m_ui.buttonAddDelete->setIcon(KIcon("edit-delete"));
{
slotPositionChanged(pos);
slotUpdateGeometry();
+ QTimer::singleShot(100, this, SIGNAL(parameterChanged()));
}
void GeometryWidget::slotAddKeyframe(int pos)
// Go to start if no keyframe is found
int currentPos = m_timePos->getValue();
int pos = 0;
- if(!m_geometry->prev_key(&item, currentPos - 1) && item.frame() < currentPos)
+ if (!m_geometry->prev_key(&item, currentPos - 1) && item.frame() < currentPos)
pos = item.frame();
slotPositionChanged(pos);
if (m_showScene) {
/*
We do only get the position in timeline if this geometry belongs to a transition,
- therefore we need to ways here.
+ therefore we need two ways here.
*/
if (m_isEffect) {
emit checkMonitorPosition(renderPos);
{
Mlt::GeometryItem item;
int pos = m_timePos->getValue();
+
// get keyframe and make sure it is the correct one
if (m_geometry->next_key(&item, pos) || item.frame() != pos)
return;
QPointF rectPos = m_rect->pos();
int size;
if (rectSize.width() / m_monitor->render->dar() < rectSize.height())
- size = (int)((rectSize.width() * 100.0 / m_monitor->render->renderWidth()) + 0.5);
+ size = (int)((rectSize.width() * 100.0 / m_monitor->render->frameRenderWidth()) + 0.5);
else
size = (int)((rectSize.height() * 100.0 / m_monitor->render->renderHeight()) + 0.5);
void GeometryWidget::slotResize(int value)
{
m_rect->setRect(0, 0,
- (int)((m_monitor->render->renderWidth() * value / 100.0) + 0.5),
+ (int)((m_monitor->render->frameRenderWidth() * value / 100.0) + 0.5),
(int)((m_monitor->render->renderHeight() * value / 100.0) + 0.5));
slotUpdateGeometry();
}
void GeometryWidget::slotCenterH()
{
- m_rect->setPos((m_monitor->render->renderWidth() - m_rect->rect().width()) / 2, m_rect->pos().y());
+ m_rect->setPos((m_monitor->render->frameRenderWidth() - m_rect->rect().width()) / 2, m_rect->pos().y());
slotUpdateGeometry();
}
void GeometryWidget::slotMoveRight()
{
- m_rect->setPos(m_monitor->render->renderWidth() - m_rect->rect().width(), m_rect->pos().y());
+ m_rect->setPos(m_monitor->render->frameRenderWidth() - m_rect->rect().width(), m_rect->pos().y());
slotUpdateGeometry();
}
void GeometryWidget::slotSetSynchronize(bool sync)
{
KdenliveSettings::setTransitionfollowcursor(sync);
+ if (sync)
+ emit seekToPos(m_clipPos + m_timePos->getValue());
}
void GeometryWidget::slotShowScene(bool show)