+void GeometryWidget::slotResetKeyframes()
+{
+ // Delete existing keyframes
+ Mlt::GeometryItem item;
+ while (!m_geometry->next_key(&item, 1)) {
+ m_geometry->remove(item.frame());
+ }
+
+ // Delete extra geometry keyframes too
+ for (int i = 0; i < m_extraGeometries.count(); ++i) {
+ Mlt::Geometry *geom = m_extraGeometries.at(i);
+ while (!geom->next_key(&item, 1)) {
+ geom->remove(item.frame());
+ }
+ }
+
+ // Create neutral first keyframe
+ item.frame(0);
+ item.x(0);
+ item.y(0);
+ item.w(m_monitor->render->frameRenderWidth());
+ item.h(m_monitor->render->renderHeight());
+ item.mix(100);
+ m_geometry->insert(item);
+ m_timeline->setKeyGeometry(m_geometry, m_outPoint - m_inPoint);
+ if (m_geomPath && KdenliveSettings::onmonitoreffects_geometryshowpath()) {
+ m_scene->removeItem(m_geomPath);
+ m_geomPath->setPoints(m_geometry);
+ m_scene->addItem(m_geomPath);
+ }
+ slotPositionChanged(-1, false);
+ emit parameterChanged();
+}
+
+void GeometryWidget::slotResetNextKeyframes()
+{
+ // Delete keyframes after cursor pos
+ Mlt::GeometryItem item;
+ int pos = m_timePos->getValue();
+ while (!m_geometry->next_key(&item, pos)) {
+ m_geometry->remove(item.frame());
+ }
+
+ // Delete extra geometry keyframes too
+ for (int i = 0; i < m_extraGeometries.count(); ++i) {
+ Mlt::Geometry *geom = m_extraGeometries.at(i);
+ while (!geom->next_key(&item, pos)) {
+ geom->remove(item.frame());
+ }
+ }
+
+ // Make sure we have at least one keyframe
+ if (m_geometry->next_key(&item, 0)) {
+ item.frame(0);
+ item.x(0);
+ item.y(0);
+ item.w(m_monitor->render->frameRenderWidth());
+ item.h(m_monitor->render->renderHeight());
+ item.mix(100);
+ m_geometry->insert(item);
+ }
+ m_timeline->setKeyGeometry(m_geometry, m_outPoint - m_inPoint);
+ if (m_geomPath && KdenliveSettings::onmonitoreffects_geometryshowpath()) {
+ m_scene->removeItem(m_geomPath);
+ m_geomPath->setPoints(m_geometry);
+ m_scene->addItem(m_geomPath);
+ }
+ slotPositionChanged(-1, false);
+ emit parameterChanged();
+}
+
+void GeometryWidget::slotResetPreviousKeyframes()
+{
+ // Delete keyframes before cursor pos
+ Mlt::GeometryItem item;
+ int pos = 0;
+ while (!m_geometry->next_key(&item, pos) && pos < m_timePos->getValue()) {
+ pos = item.frame() + 1;
+ m_geometry->remove(item.frame());
+ }
+
+ // Delete extra geometry keyframes too
+ for (int i = 0; i < m_extraGeometries.count(); ++i) {
+ Mlt::Geometry *geom = m_extraGeometries.at(i);
+ pos = 0;
+ while (!geom->next_key(&item, pos) && pos < m_timePos->getValue()) {
+ pos = item.frame() + 1;
+ geom->remove(item.frame());
+ }
+ }
+
+ // Make sure we have at least one keyframe
+ if (!m_geometry->next_key(&item, 0)) {
+ item.frame(0);
+ /*item.x(0);
+ item.y(0);
+ item.w(m_monitor->render->frameRenderWidth());
+ item.h(m_monitor->render->renderHeight());
+ item.mix(100);*/
+ m_geometry->insert(item);
+ }
+ else {
+ item.frame(0);
+ item.x(0);
+ item.y(0);
+ item.w(m_monitor->render->frameRenderWidth());
+ item.h(m_monitor->render->renderHeight());
+ item.mix(100);
+ m_geometry->insert(item);
+ }
+ m_timeline->setKeyGeometry(m_geometry, m_outPoint - m_inPoint);
+ if (m_geomPath && KdenliveSettings::onmonitoreffects_geometryshowpath()) {
+ m_scene->removeItem(m_geomPath);
+ m_geomPath->setPoints(m_geometry);
+ m_scene->addItem(m_geomPath);
+ }
+ slotPositionChanged(-1, false);
+ emit parameterChanged();
+}
+
+void GeometryWidget::importKeyframes(const QString &data, int maximum)
+{
+ QStringList list = data.split(';', QString::SkipEmptyParts);
+ if (list.isEmpty()) return;
+ QPoint screenSize = m_frameSize;
+ if (screenSize == QPoint() || screenSize.x() == 0 || screenSize.y() == 0) {
+ screenSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
+ }
+ // Clear existing keyframes
+ Mlt::GeometryItem item;
+
+ while (!m_geometry->next_key(&item, 0)) {
+ m_geometry->remove(item.frame());
+ }
+
+ int offset = 1;
+ if (maximum > 0 && list.count() > maximum) {
+ offset = list.count() / maximum;
+ }
+ for (int i = 0; i < list.count(); i += offset) {
+ QString geom = list.at(i);
+ if (geom.contains('=')) {
+ item.frame(geom.section('=', 0, 0).toInt());
+ geom = geom.section('=', 1);
+ }
+ else item.frame(0);
+ if (geom.contains('/')) {
+ item.x(geom.section('/', 0, 0).toDouble());
+ item.y(geom.section('/', 1, 1).section(':', 0, 0).toDouble());
+ }
+ else {
+ item.x(0);
+ item.y(0);
+ }
+ if (geom.contains('x')) {
+ item.w(geom.section('x', 0, 0).section(':', 1, 1).toDouble());
+ item.h(geom.section('x', 1, 1).section(':', 0, 0).toDouble());
+ }
+ else {
+ item.w(screenSize.x());
+ item.h(screenSize.y());
+ }
+ //TODO: opacity
+ item.mix(100);
+ m_geometry->insert(item);
+ }
+ m_timeline->setKeyGeometry(m_geometry, m_outPoint - m_inPoint);
+ if (m_geomPath && KdenliveSettings::onmonitoreffects_geometryshowpath()) {
+ m_scene->removeItem(m_geomPath);
+ m_geomPath->setPoints(m_geometry);
+ m_scene->addItem(m_geomPath);
+ }
+ slotPositionChanged(-1, false);
+ emit parameterChanged();
+}
+
+void GeometryWidget::slotUpdateRange(int inPoint, int outPoint)
+{
+ m_inPoint = inPoint;
+ m_outPoint = outPoint;
+ m_timeline->setKeyGeometry(m_geometry, m_outPoint - m_inPoint);
+ m_timePos->setRange(0, m_outPoint - m_inPoint);
+}
+