1 /***************************************************************************
2 * Copyright (C) 2010 by Till Theato (root@ttill.de) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
21 #include "geometrywidget.h"
24 #include "keyframehelper.h"
25 #include "timecodedisplay.h"
26 #include "monitorscene.h"
27 #include "monitoreditwidget.h"
28 #include "onmonitoritems/onmonitorrectitem.h"
29 #include "kdenlivesettings.h"
30 #include "dragvalue.h"
33 #include <QGraphicsView>
34 #include <QVBoxLayout>
35 #include <QGridLayout>
40 GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos, bool isEffect, bool showRotation, QWidget* parent):
43 m_timePos(new TimecodeDisplay(timecode)),
52 m_showRotation(showRotation)
55 setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
56 MonitorEditWidget *edit = monitor->getEffectEdit();
57 edit->removeCustomControls();
58 edit->addCustomButton(KIcon("transform-crop"), i18n("Show previous keyframe"), this, SLOT(slotShowPreviousKeyFrame(bool)), true, KdenliveSettings::onmonitoreffects_geometryshowprevious());
59 edit->showVisibilityButton(true);
60 m_scene = edit->getScene();
64 Setup of timeline and keyframe controls
67 ((QGridLayout *)(m_ui.widgetTimeWrapper->layout()))->addWidget(m_timePos, 1, 6);
69 QVBoxLayout *layout = new QVBoxLayout(m_ui.frameTimeline);
70 m_timeline = new KeyframeHelper(m_ui.frameTimeline);
71 layout->addWidget(m_timeline);
72 layout->setContentsMargins(0, 0, 0, 0);
74 m_ui.buttonPrevious->setIcon(KIcon("media-skip-backward"));
75 m_ui.buttonPrevious->setToolTip(i18n("Go to previous keyframe"));
76 m_ui.buttonNext->setIcon(KIcon("media-skip-forward"));
77 m_ui.buttonNext->setToolTip(i18n("Go to next keyframe"));
78 m_ui.buttonAddDelete->setIcon(KIcon("document-new"));
79 m_ui.buttonAddDelete->setToolTip(i18n("Add keyframe"));
81 m_ui.buttonSync->setIcon(KIcon("insert-link"));
82 m_ui.buttonSync->setToolTip(i18n("Synchronize with timeline cursor"));
83 m_ui.buttonSync->setChecked(KdenliveSettings::transitionfollowcursor());
85 connect(m_timeline, SIGNAL(positionChanged(int)), this, SLOT(slotPositionChanged(int)));
86 connect(m_timeline, SIGNAL(keyframeMoved(int)), this, SLOT(slotKeyframeMoved(int)));
87 connect(m_timeline, SIGNAL(addKeyframe(int)), this, SLOT(slotAddKeyframe(int)));
88 connect(m_timeline, SIGNAL(removeKeyframe(int)), this, SLOT(slotDeleteKeyframe(int)));
89 connect(m_timePos, SIGNAL(editingFinished()), this, SLOT(slotPositionChanged()));
90 connect(m_ui.buttonPrevious, SIGNAL(clicked()), this, SLOT(slotPreviousKeyframe()));
91 connect(m_ui.buttonNext, SIGNAL(clicked()), this, SLOT(slotNextKeyframe()));
92 connect(m_ui.buttonAddDelete, SIGNAL(clicked()), this, SLOT(slotAddDeleteKeyframe()));
93 connect(m_ui.buttonSync, SIGNAL(toggled(bool)), this, SLOT(slotSetSynchronize(bool)));
95 m_spinX = new DragValue(i18nc("x axis position", "X"), 0, 0, -99000, 99000, -1, QString(), false, this);
96 m_ui.horizontalLayout->addWidget(m_spinX);
98 m_spinY = new DragValue(i18nc("y axis position", "Y"), 0, 0, -99000, 99000, -1, QString(), false, this);
99 m_ui.horizontalLayout->addWidget(m_spinY);
101 m_spinWidth = new DragValue(i18nc("Frame width", "W"), m_monitor->render->frameRenderWidth(), 0, 1, 99000, -1, QString(), false, this);
102 m_ui.horizontalLayout->addWidget(m_spinWidth);
104 m_spinHeight = new DragValue(i18nc("Frame height", "H"), m_monitor->render->renderHeight(), 0, 1, 99000, -1, QString(), false, this);
105 m_ui.horizontalLayout->addWidget(m_spinHeight);
107 QMenu *menu = new QMenu(this);
108 QAction *adjustSize = new QAction(i18n("Adjust to original size"), this);
109 connect(adjustSize, SIGNAL(triggered()), this, SLOT(slotAdjustToFrameSize()));
110 menu->addAction(adjustSize);
111 QAction *fitToWidth = new QAction(i18n("Fit to width"), this);
112 connect(fitToWidth, SIGNAL(triggered()), this, SLOT(slotFitToWidth()));
113 menu->addAction(fitToWidth);
114 QAction *fitToHeight = new QAction(i18n("Fit to height"), this);
115 connect(fitToHeight, SIGNAL(triggered()), this, SLOT(slotFitToHeight()));
116 menu->addAction(fitToHeight);
117 menu->addSeparator();
119 QAction *alignleft = new QAction(KIcon("kdenlive-align-left"), i18n("Align left"), this);
120 connect(alignleft, SIGNAL(triggered()), this, SLOT(slotMoveLeft()));
121 menu->addAction(alignleft);
122 QAction *alignhcenter = new QAction(KIcon("kdenlive-align-hor"), i18n("Center horizontally"), this);
123 connect(alignhcenter, SIGNAL(triggered()), this, SLOT(slotCenterH()));
124 menu->addAction(alignhcenter);
125 QAction *alignright = new QAction(KIcon("kdenlive-align-right"), i18n("Align right"), this);
126 connect(alignright, SIGNAL(triggered()), this, SLOT(slotMoveRight()));
127 menu->addAction(alignright);
128 QAction *aligntop = new QAction(KIcon("kdenlive-align-top"), i18n("Align top"), this);
129 connect(aligntop, SIGNAL(triggered()), this, SLOT(slotMoveTop()));
130 menu->addAction(aligntop);
131 QAction *alignvcenter = new QAction(KIcon("kdenlive-align-vert"), i18n("Center vertically"), this);
132 connect(alignvcenter, SIGNAL(triggered()), this, SLOT(slotCenterV()));
133 menu->addAction(alignvcenter);
134 QAction *alignbottom = new QAction(KIcon("kdenlive-align-bottom"), i18n("Align bottom"), this);
135 connect(alignbottom, SIGNAL(triggered()), this, SLOT(slotMoveBottom()));
136 menu->addAction(alignbottom);
137 m_ui.buttonOptions->setMenu(menu);
139 QHBoxLayout *alignLayout = new QHBoxLayout;
140 alignLayout->setSpacing(0);
141 QToolButton *alignButton = new QToolButton;
142 alignButton->setDefaultAction(alignleft);
143 alignButton->setAutoRaise(true);
144 alignLayout->addWidget(alignButton);
146 alignButton = new QToolButton;
147 alignButton->setDefaultAction(alignhcenter);
148 alignButton->setAutoRaise(true);
149 alignLayout->addWidget(alignButton);
151 alignButton = new QToolButton;
152 alignButton->setDefaultAction(alignright);
153 alignButton->setAutoRaise(true);
154 alignLayout->addWidget(alignButton);
156 alignButton = new QToolButton;
157 alignButton->setDefaultAction(aligntop);
158 alignButton->setAutoRaise(true);
159 alignLayout->addWidget(alignButton);
161 alignButton = new QToolButton;
162 alignButton->setDefaultAction(alignvcenter);
163 alignButton->setAutoRaise(true);
164 alignLayout->addWidget(alignButton);
166 alignButton = new QToolButton;
167 alignButton->setDefaultAction(alignbottom);
168 alignButton->setAutoRaise(true);
169 alignLayout->addWidget(alignButton);
171 m_ui.horizontalLayout->addLayout(alignLayout);
172 m_ui.horizontalLayout->addStretch(10);
174 m_spinSize = new DragValue(i18n("Size"), 100, 2, 1, 99000, -1, i18n("%"), false, this);
175 m_ui.horizontalLayout2->addWidget(m_spinSize);
177 m_opacity = new DragValue(i18n("Opacity"), 100, 0, 0, 100, -1, i18n("%"), true, this);
178 m_ui.horizontalLayout2->addWidget(m_opacity);
182 m_rotateX = new DragValue(i18n("Rotate X"), 0, 0, -1800, 1800, -1, QString(), true, this);
183 m_rotateX->setObjectName("rotate_x");
184 m_ui.horizontalLayout3->addWidget(m_rotateX);
185 m_rotateY = new DragValue(i18n("Rotate Y"), 0, 0, -1800, 1800, -1, QString(), true, this);
186 m_rotateY->setObjectName("rotate_y");
187 m_ui.horizontalLayout3->addWidget(m_rotateY);
188 m_rotateZ = new DragValue(i18n("Rotate Z"), 0, 0, -1800, 1800, -1, QString(), true, this);
189 m_rotateZ->setObjectName("rotate_z");
190 m_ui.horizontalLayout3->addWidget(m_rotateZ);
191 connect(m_rotateX, SIGNAL(valueChanged(double)), this, SLOT(slotUpdateGeometry()));
192 connect(m_rotateY, SIGNAL(valueChanged(double)), this, SLOT(slotUpdateGeometry()));
193 connect(m_rotateZ, SIGNAL(valueChanged(double)), this, SLOT(slotUpdateGeometry()));
197 Setup of geometry controls
200 connect(m_spinX, SIGNAL(valueChanged(double)), this, SLOT(slotSetX(double)));
201 connect(m_spinY, SIGNAL(valueChanged(double)), this, SLOT(slotSetY(double)));
202 connect(m_spinWidth, SIGNAL(valueChanged(double)), this, SLOT(slotSetWidth(double)));
203 connect(m_spinHeight, SIGNAL(valueChanged(double)), this, SLOT(slotSetHeight(double)));
205 connect(m_spinSize, SIGNAL(valueChanged(double)), this, SLOT(slotResize(double)));
207 connect(m_opacity, SIGNAL(valueChanged(double)), this, SLOT(slotSetOpacity(double)));
209 /*connect(m_ui.buttonMoveLeft, SIGNAL(clicked()), this, SLOT(slotMoveLeft()));
210 connect(m_ui.buttonCenterH, SIGNAL(clicked()), this, SLOT(slotCenterH()));
211 connect(m_ui.buttonMoveRight, SIGNAL(clicked()), this, SLOT(slotMoveRight()));
212 connect(m_ui.buttonMoveTop, SIGNAL(clicked()), this, SLOT(slotMoveTop()));
213 connect(m_ui.buttonCenterV, SIGNAL(clicked()), this, SLOT(slotCenterV()));
214 connect(m_ui.buttonMoveBottom, SIGNAL(clicked()), this, SLOT(slotMoveBottom()));*/
218 Setup of configuration controls
221 connect(edit, SIGNAL(showEdit(bool)), this, SLOT(slotShowScene(bool)));
223 connect(m_scene, SIGNAL(addKeyframe()), this, SLOT(slotAddKeyframe()));
224 connect(m_monitor, SIGNAL(renderPosition(int)), this, SLOT(slotCheckMonitorPosition(int)));
225 connect(this, SIGNAL(parameterChanged()), this, SLOT(slotUpdateProperties()));
228 GeometryWidget::~GeometryWidget()
230 m_scene->setEnabled(true);
238 m_scene->removeItem(m_rect);
239 if (m_rect) delete m_rect;
240 if (m_previous) delete m_previous;
242 m_extraGeometryNames.clear();
243 m_extraFactors.clear();
244 while (!m_extraGeometries.isEmpty()) {
245 Mlt::Geometry *g = m_extraGeometries.takeFirst();
249 m_monitor->getEffectEdit()->showVisibilityButton(false);
250 m_monitor->slotEffectScene(false);
254 void GeometryWidget::slotShowPreviousKeyFrame(bool show)
256 KdenliveSettings::setOnmonitoreffects_geometryshowprevious(show);
257 slotPositionChanged(-1, false);
260 void GeometryWidget::updateTimecodeFormat()
262 m_timePos->slotUpdateTimeCodeFormat();
265 QString GeometryWidget::getValue() const
267 return m_geometry->serialise();
270 QString GeometryWidget::getExtraValue(const QString &name) const
272 int ix = m_extraGeometryNames.indexOf(name);
273 QString val = m_extraGeometries.at(ix)->serialise();
274 if (!val.contains("=")) val = val.section(',', 0, 0);
276 QStringList list = val.split(';');
278 foreach (const QString value, list) {
279 val.append(value.section(',', 0, 0) + ';');
285 void GeometryWidget::setupParam(const QDomElement elem, int minframe, int maxframe)
287 m_inPoint = minframe;
288 m_outPoint = maxframe;
291 m_geometry->parse(elem.attribute("value").toUtf8().data(), maxframe - minframe, m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
293 m_geometry = new Mlt::Geometry(elem.attribute("value").toUtf8().data(), maxframe - minframe, m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
295 if (elem.attribute("fixed") == "1" || maxframe < minframe) {
296 // Keyframes are disabled
297 m_ui.widgetTimeWrapper->setHidden(true);
299 m_ui.widgetTimeWrapper->setHidden(false);
300 m_timeline->setKeyGeometry(m_geometry, m_outPoint - m_inPoint);
301 m_timeline->update();
302 m_timePos->setRange(0, m_outPoint - m_inPoint);
306 if (elem.attribute("opacity") == "false") {
307 m_opacity->setHidden(true);
308 m_ui.horizontalLayout2->addStretch(2);
311 Mlt::GeometryItem item;
313 m_geometry->fetch(&item, 0);
315 m_rect = new OnMonitorRectItem(QRectF(0, 0, item.w(), item.h()), m_monitor->render->dar());
316 m_rect->setPos(item.x(), item.y());
317 m_rect->setZValue(0);
318 m_scene->addItem(m_rect);
319 connect(m_rect, SIGNAL(changed()), this, SLOT(slotUpdateGeometry()));
321 slotPositionChanged(0, false);
322 slotCheckMonitorPosition(m_monitor->render->seekFramePosition());
325 void GeometryWidget::addParameter(const QDomElement elem)
327 Mlt::Geometry *geometry = new Mlt::Geometry(elem.attribute("value").toUtf8().data(), m_outPoint - m_inPoint, m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
328 m_extraGeometries.append(geometry);
329 m_timeline->addGeometry(geometry);
330 m_extraFactors.append(elem.attribute("factor", "1"));
331 m_extraGeometryNames.append(elem.attribute("name"));
332 //kDebug()<<"ADDED PARAM: "<<elem.attribute("value");
335 void GeometryWidget::slotSyncPosition(int relTimelinePos)
337 // do only sync if this effect is keyframable
338 if (m_timePos->maximum() > 0 && KdenliveSettings::transitionfollowcursor()) {
339 relTimelinePos = qBound(0, relTimelinePos, m_timePos->maximum());
340 if (relTimelinePos != m_timePos->getValue())
341 slotPositionChanged(relTimelinePos, false);
346 void GeometryWidget::slotPositionChanged(int pos, bool seek)
349 pos = m_timePos->getValue();
351 m_timePos->setValue(pos);
353 m_timeline->blockSignals(true);
354 m_timeline->setValue(pos);
355 m_timeline->blockSignals(false);
357 Mlt::GeometryItem item;
358 Mlt::GeometryItem previousItem;
359 if (m_geometry->fetch(&item, pos) || item.key() == false) {
361 m_rect->setEnabled(false);
362 m_scene->setEnabled(false);
363 m_ui.widgetGeometry->setEnabled(false);
364 m_ui.buttonAddDelete->setIcon(KIcon("document-new"));
365 m_ui.buttonAddDelete->setToolTip(i18n("Add keyframe"));
368 m_rect->setEnabled(true);
369 m_scene->setEnabled(true);
370 m_ui.widgetGeometry->setEnabled(true);
371 m_ui.buttonAddDelete->setIcon(KIcon("edit-delete"));
372 m_ui.buttonAddDelete->setToolTip(i18n("Delete keyframe"));
375 if (KdenliveSettings::onmonitoreffects_geometryshowprevious() == false || m_geometry->prev_key(&previousItem, pos - 1) || previousItem.frame() == item.frame()) {
377 m_scene->removeItem(m_previous);
380 else if (m_previous && m_previous->scene() && m_previous->data(Qt::UserRole).toInt() == previousItem.frame()) {
381 // previous frame already here, do nothing
384 if (m_previous == NULL) {
385 m_previous = new QGraphicsRectItem(0, 0, previousItem.w(), previousItem.h());
386 m_previous->setBrush(QColor(200, 200, 0, 20));
387 m_previous->setPen(QPen(Qt::white, 0, Qt::DotLine));
388 m_previous->setPos(previousItem.x(), previousItem.y());
389 m_previous->setZValue(-1);
390 m_previous->setEnabled(false);
393 m_previous->setPos(previousItem.x(), previousItem.y());
394 m_previous->setRect(0, 0, previousItem.w(), previousItem.h());
396 m_previous->setData(Qt::UserRole, previousItem.frame());
397 if (m_previous->scene() == 0) m_scene->addItem(m_previous);
400 m_rect->setPos(item.x(), item.y());
401 m_rect->setRect(0, 0, item.w(), item.h());
403 m_opacity->blockSignals(true);
404 m_opacity->setValue(item.mix());
405 m_opacity->blockSignals(false);
407 for (int i = 0; i < m_extraGeometries.count(); i++) {
408 Mlt::Geometry *geom = m_extraGeometries.at(i);
409 QString name = m_extraGeometryNames.at(i);
410 if (!geom->fetch(&item, pos)) {
411 DragValue *widget = findChild<DragValue *>(name);
413 widget->blockSignals(true);
414 widget->setValue(item.x() * m_extraFactors.at(i).toInt());
415 widget->blockSignals(false);
420 slotUpdateProperties();
422 if (seek && KdenliveSettings::transitionfollowcursor())
423 emit seekToPos(m_clipPos + pos);
426 void GeometryWidget::slotKeyframeMoved(int pos)
428 slotPositionChanged(pos);
429 slotUpdateGeometry();
430 QTimer::singleShot(100, this, SIGNAL(parameterChanged()));
433 void GeometryWidget::slotAddKeyframe(int pos)
435 Mlt::GeometryItem item;
437 pos = m_timePos->getValue();
439 QRectF r = m_rect->rect().normalized();
440 QPointF rectpos = m_rect->pos();
445 item.mix(m_opacity->value());
446 m_geometry->insert(item);
448 for (int i = 0; i < m_extraGeometries.count(); i++) {
449 Mlt::Geometry *geom = m_extraGeometries.at(i);
450 QString name = m_extraGeometryNames.at(i);
451 DragValue *widget = findChild<DragValue *>(name);
453 Mlt::GeometryItem item2;
455 item2.x((double) widget->value() / m_extraFactors.at(i).toInt());
460 m_timeline->update();
461 slotPositionChanged(pos, false);
462 emit parameterChanged();
465 void GeometryWidget::slotDeleteKeyframe(int pos)
467 Mlt::GeometryItem item;
469 pos = m_timePos->getValue();
470 // check there is more than one keyframe, do not allow to delete last one
471 if (m_geometry->next_key(&item, pos + 1)) {
472 if (m_geometry->prev_key(&item, pos - 1) || item.frame() == pos)
475 m_geometry->remove(pos);
477 for (int i = 0; i < m_extraGeometries.count(); i++) {
478 Mlt::Geometry *geom = m_extraGeometries.at(i);
482 m_timeline->update();
483 slotPositionChanged(pos, false);
484 emit parameterChanged();
487 void GeometryWidget::slotPreviousKeyframe()
489 Mlt::GeometryItem item;
490 // Go to start if no keyframe is found
491 int currentPos = m_timePos->getValue();
493 if (!m_geometry->prev_key(&item, currentPos - 1) && item.frame() < currentPos)
496 slotPositionChanged(pos);
499 void GeometryWidget::slotNextKeyframe()
501 Mlt::GeometryItem item;
502 // Go to end if no keyframe is found
503 int pos = m_timeline->frameLength;
504 if (!m_geometry->next_key(&item, m_timeline->value() + 1))
507 slotPositionChanged(pos);
510 void GeometryWidget::slotAddDeleteKeyframe()
512 Mlt::GeometryItem item;
513 if (m_geometry->fetch(&item, m_timePos->getValue()) || item.key() == false)
516 slotDeleteKeyframe();
520 void GeometryWidget::slotCheckMonitorPosition(int renderPos)
524 We do only get the position in timeline if this geometry belongs to a transition,
525 therefore we need two ways here.
528 emit checkMonitorPosition(renderPos);
530 if (renderPos >= m_clipPos && renderPos <= m_clipPos + m_outPoint - m_inPoint) {
531 if (!m_scene->views().at(0)->isVisible())
532 m_monitor->slotEffectScene(true);
534 m_monitor->slotEffectScene(false);
541 void GeometryWidget::slotUpdateGeometry()
543 Mlt::GeometryItem item;
544 int pos = m_timePos->getValue();
546 // get keyframe and make sure it is the correct one
547 if (m_geometry->next_key(&item, pos) || item.frame() != pos)
550 QRectF rectSize = m_rect->rect().normalized();
551 QPointF rectPos = m_rect->pos();
554 item.w(rectSize.width());
555 item.h(rectSize.height());
556 m_geometry->insert(item);
558 for (int i = 0; i < m_extraGeometries.count(); i++) {
559 Mlt::Geometry *geom = m_extraGeometries.at(i);
560 QString name = m_extraGeometryNames.at(i);
561 Mlt::GeometryItem item2;
562 DragValue *widget = findChild<DragValue *>(name);
563 if (widget && !geom->next_key(&item2, pos) && item2.frame() == pos) {
564 item2.x((double) widget->value() / m_extraFactors.at(i).toInt());
569 emit parameterChanged();
572 void GeometryWidget::slotUpdateProperties()
574 QRectF rectSize = m_rect->rect().normalized();
575 QPointF rectPos = m_rect->pos();
577 if (rectSize.width() / m_monitor->render->dar() > rectSize.height())
578 size = rectSize.width() * 100.0 / m_monitor->render->frameRenderWidth();
580 size = rectSize.height() * 100.0 / m_monitor->render->renderHeight();
582 m_spinX->blockSignals(true);
583 m_spinY->blockSignals(true);
584 m_spinWidth->blockSignals(true);
585 m_spinHeight->blockSignals(true);
586 m_spinSize->blockSignals(true);
588 m_spinX->setValue(rectPos.x());
589 m_spinY->setValue(rectPos.y());
590 m_spinWidth->setValue(rectSize.width());
591 m_spinHeight->setValue(rectSize.height());
592 m_spinSize->setValue(size);
594 m_spinX->blockSignals(false);
595 m_spinY->blockSignals(false);
596 m_spinWidth->blockSignals(false);
597 m_spinHeight->blockSignals(false);
598 m_spinSize->blockSignals(false);
602 void GeometryWidget::slotSetX(double value)
604 m_rect->setPos(value, m_spinY->value());
605 slotUpdateGeometry();
608 void GeometryWidget::slotSetY(double value)
610 m_rect->setPos(m_spinX->value(), value);
611 slotUpdateGeometry();
614 void GeometryWidget::slotSetWidth(double value)
616 m_rect->setRect(0, 0, value, m_spinHeight->value());
617 slotUpdateGeometry();
620 void GeometryWidget::slotSetHeight(double value)
622 m_rect->setRect(0, 0, m_spinWidth->value(), value);
623 slotUpdateGeometry();
626 void GeometryWidget::updateMonitorGeometry()
628 m_rect->setRect(0, 0, m_spinWidth->value(), m_spinHeight->value());
629 slotUpdateGeometry();
633 void GeometryWidget::slotResize(double value)
635 m_rect->setRect(0, 0,
636 (int)((m_monitor->render->frameRenderWidth() * value / 100.0) + 0.5),
637 (int)((m_monitor->render->renderHeight() * value / 100.0) + 0.5));
638 slotUpdateGeometry();
642 void GeometryWidget::slotSetOpacity(double value)
644 int pos = m_timePos->getValue();
645 Mlt::GeometryItem item;
646 if (m_geometry->fetch(&item, pos) || item.key() == false)
649 m_geometry->insert(item);
650 emit parameterChanged();
654 void GeometryWidget::slotMoveLeft()
656 m_rect->setPos(0, m_rect->pos().y());
657 slotUpdateGeometry();
660 void GeometryWidget::slotCenterH()
662 m_rect->setPos((m_monitor->render->frameRenderWidth() - m_rect->rect().width()) / 2, m_rect->pos().y());
663 slotUpdateGeometry();
666 void GeometryWidget::slotMoveRight()
668 m_rect->setPos(m_monitor->render->frameRenderWidth() - m_rect->rect().width(), m_rect->pos().y());
669 slotUpdateGeometry();
672 void GeometryWidget::slotMoveTop()
674 m_rect->setPos(m_rect->pos().x(), 0);
675 slotUpdateGeometry();
678 void GeometryWidget::slotCenterV()
680 m_rect->setPos(m_rect->pos().x(), (m_monitor->render->renderHeight() - m_rect->rect().height()) / 2);
681 slotUpdateGeometry();
684 void GeometryWidget::slotMoveBottom()
686 m_rect->setPos(m_rect->pos().x(), m_monitor->render->renderHeight() - m_rect->rect().height());
687 slotUpdateGeometry();
691 void GeometryWidget::slotSetSynchronize(bool sync)
693 KdenliveSettings::setTransitionfollowcursor(sync);
695 emit seekToPos(m_clipPos + m_timePos->getValue());
698 void GeometryWidget::slotShowScene(bool show)
702 m_monitor->slotEffectScene(false);
704 slotCheckMonitorPosition(m_monitor->render->seekFramePosition());
707 void GeometryWidget::setFrameSize(QPoint size)
712 void GeometryWidget::slotAdjustToFrameSize()
714 if (m_frameSize == QPoint()) m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
715 m_spinWidth->blockSignals(true);
716 m_spinHeight->blockSignals(true);
717 m_spinWidth->setValue((int) (m_frameSize.x() / m_monitor->render->sar() + 0.5));
718 m_spinHeight->setValue(m_frameSize.y());
719 m_spinWidth->blockSignals(false);
720 m_spinHeight->blockSignals(false);
721 updateMonitorGeometry();
724 void GeometryWidget::slotFitToWidth()
726 if (m_frameSize == QPoint()) m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
727 double factor = (double) m_monitor->render->frameRenderWidth() / m_frameSize.x() * m_monitor->render->sar();
728 m_spinWidth->blockSignals(true);
729 m_spinHeight->blockSignals(true);
730 m_spinHeight->setValue((int) (m_frameSize.y() * factor + 0.5));
731 m_spinWidth->setValue(m_monitor->render->frameRenderWidth());
732 m_spinWidth->blockSignals(false);
733 m_spinHeight->blockSignals(false);
734 updateMonitorGeometry();
737 void GeometryWidget::slotFitToHeight()
739 if (m_frameSize == QPoint()) m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
740 double factor = (double) m_monitor->render->renderHeight() / m_frameSize.y();
741 m_spinWidth->blockSignals(true);
742 m_spinHeight->blockSignals(true);
743 m_spinHeight->setValue(m_monitor->render->renderHeight());
744 m_spinWidth->setValue((int) (m_frameSize.x() / m_monitor->render->sar() * factor + 0.5));
745 m_spinWidth->blockSignals(false);
746 m_spinHeight->blockSignals(false);
747 updateMonitorGeometry();
750 #include "geometrywidget.moc"