]> git.sesse.net Git - kdenlive/blob - src/geometrywidget.cpp
Fix "fit to width / height" option not correctly updating in composite transition
[kdenlive] / src / geometrywidget.cpp
1 /***************************************************************************
2  *   Copyright (C) 2010 by Till Theato (root@ttill.de)                     *
3  *                                                                         *
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.                                   *
8  *                                                                         *
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.                          *
13  *                                                                         *
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  ***************************************************************************/
19
20
21 #include "geometrywidget.h"
22 #include "monitor.h"
23 #include "renderer.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"
31
32 #include <QtCore>
33 #include <QGraphicsView>
34 #include <QVBoxLayout>
35 #include <QGridLayout>
36 #include <QMenu>
37
38
39
40 GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos, bool isEffect, QWidget* parent):
41     QWidget(parent),
42     m_monitor(monitor),
43     m_timePos(new TimecodeDisplay(timecode)),
44     m_clipPos(clipPos),
45     m_inPoint(0),
46     m_outPoint(1),
47     m_isEffect(isEffect),
48     m_rect(NULL),
49     m_previous(NULL),
50     m_geometry(NULL),
51     m_showScene(true)
52 {
53     m_ui.setupUi(this);
54     setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
55     MonitorEditWidget *edit = monitor->getEffectEdit();
56     edit->removeCustomControls();
57     edit->addCustomButton(KIcon("transform-crop"), i18n("Show previous keyframe"), this, SLOT(slotShowPreviousKeyFrame(bool)), true, KdenliveSettings::onmonitoreffects_geometryshowprevious());
58     edit->showVisibilityButton(true);
59     m_scene = edit->getScene();
60
61
62     /*
63         Setup of timeline and keyframe controls
64     */
65
66     ((QGridLayout *)(m_ui.widgetTimeWrapper->layout()))->addWidget(m_timePos, 1, 6);
67
68     QVBoxLayout *layout = new QVBoxLayout(m_ui.frameTimeline);
69     m_timeline = new KeyframeHelper(m_ui.frameTimeline);
70     layout->addWidget(m_timeline);
71     layout->setContentsMargins(0, 0, 0, 0);
72
73     m_ui.buttonPrevious->setIcon(KIcon("media-skip-backward"));
74     m_ui.buttonPrevious->setToolTip(i18n("Go to previous keyframe"));
75     m_ui.buttonNext->setIcon(KIcon("media-skip-forward"));
76     m_ui.buttonNext->setToolTip(i18n("Go to next keyframe"));
77     m_ui.buttonAddDelete->setIcon(KIcon("document-new"));
78     m_ui.buttonAddDelete->setToolTip(i18n("Add keyframe"));
79
80     m_ui.buttonSync->setIcon(KIcon("insert-link"));
81     m_ui.buttonSync->setToolTip(i18n("Synchronize with timeline cursor"));
82     m_ui.buttonSync->setChecked(KdenliveSettings::transitionfollowcursor());
83
84     connect(m_timeline, SIGNAL(positionChanged(int)), this, SLOT(slotPositionChanged(int)));
85     connect(m_timeline, SIGNAL(keyframeMoved(int)),   this, SLOT(slotKeyframeMoved(int)));
86     connect(m_timeline, SIGNAL(addKeyframe(int)),     this, SLOT(slotAddKeyframe(int)));
87     connect(m_timeline, SIGNAL(removeKeyframe(int)),  this, SLOT(slotDeleteKeyframe(int)));
88     connect(m_timePos, SIGNAL(editingFinished()), this, SLOT(slotPositionChanged()));
89     connect(m_ui.buttonPrevious,  SIGNAL(clicked()), this, SLOT(slotPreviousKeyframe()));
90     connect(m_ui.buttonNext,      SIGNAL(clicked()), this, SLOT(slotNextKeyframe()));
91     connect(m_ui.buttonAddDelete, SIGNAL(clicked()), this, SLOT(slotAddDeleteKeyframe()));
92     connect(m_ui.buttonSync,      SIGNAL(toggled(bool)), this, SLOT(slotSetSynchronize(bool)));
93
94     m_spinX = new DragValue(i18n("X"), 0, 0, -1, QString(), false, this);
95     m_spinX->setRange(-99000, 99000);
96     m_ui.horizontalLayout->addWidget(m_spinX);
97     
98     m_spinY = new DragValue(i18n("Y"), 0, 0, -1, QString(), false, this);
99     m_spinY->setRange(-99000, 99000);
100     m_ui.horizontalLayout->addWidget(m_spinY);
101     
102     m_spinWidth = new DragValue(i18n("W"), m_monitor->render->frameRenderWidth(), 0, -1, QString(), false, this);
103     m_spinWidth->setRange(1, 99000);
104     m_ui.horizontalLayout->addWidget(m_spinWidth);
105     
106     m_spinHeight = new DragValue(i18n("H"), m_monitor->render->renderHeight(), 0, -1, QString(), false, this);
107     m_spinHeight->setRange(1, 99000);
108     m_ui.horizontalLayout->addWidget(m_spinHeight);
109     m_ui.horizontalLayout->addStretch(10);
110     
111     m_spinSize = new DragValue(i18n("Size"), 100, 2, -1, i18n("%"), false, this);
112     m_spinSize->setRange(1, 99000);
113     m_ui.horizontalLayout2->addWidget(m_spinSize);
114     
115     m_opacity = new DragValue(i18n("Opacity"), 100, 0, -1, i18n("%"), true, this);
116     m_ui.horizontalLayout2->addWidget(m_opacity);
117     
118     /*
119         Setup of geometry controls
120     */
121
122     connect(m_spinX,            SIGNAL(valueChanged(int)), this, SLOT(slotSetX(int)));
123     connect(m_spinY,            SIGNAL(valueChanged(int)), this, SLOT(slotSetY(int)));
124     connect(m_spinWidth,        SIGNAL(valueChanged(int)), this, SLOT(slotSetWidth(int)));
125     connect(m_spinHeight,       SIGNAL(valueChanged(int)), this, SLOT(slotSetHeight(int)));
126
127     connect(m_spinSize,         SIGNAL(valueChanged(double)), this, SLOT(slotResize(double)));
128
129     connect(m_opacity, SIGNAL(valueChanged(int)), this, SLOT(slotSetOpacity(int)));
130     
131     QMenu *menu = new QMenu(this);
132     QAction *adjustSize = new QAction(i18n("Adjust to original size"), this);
133     connect(adjustSize, SIGNAL(triggered()), this, SLOT(slotAdjustToFrameSize()));
134     menu->addAction(adjustSize);
135     QAction *fitToWidth = new QAction(i18n("Fit to width"), this);
136     connect(fitToWidth, SIGNAL(triggered()), this, SLOT(slotFitToWidth()));
137     menu->addAction(fitToWidth);
138     QAction *fitToHeight = new QAction(i18n("Fit to height"), this);
139     connect(fitToHeight, SIGNAL(triggered()), this, SLOT(slotFitToHeight()));
140     menu->addAction(fitToHeight);
141     menu->addSeparator();
142
143     QAction *alignleft = new QAction(KIcon("kdenlive-align-left"), i18n("Align left"), this);
144     connect(alignleft, SIGNAL(triggered()), this, SLOT(slotMoveLeft()));
145     menu->addAction(alignleft);
146     QAction *alignhcenter = new QAction(KIcon("kdenlive-align-hor"), i18n("Center horizontally"), this);
147     connect(alignhcenter, SIGNAL(triggered()), this, SLOT(slotCenterH()));
148     menu->addAction(alignhcenter);
149     QAction *alignright = new QAction(KIcon("kdenlive-align-right"), i18n("Align right"), this);
150     connect(alignright, SIGNAL(triggered()), this, SLOT(slotMoveRight()));
151     menu->addAction(alignright);
152     QAction *aligntop = new QAction(KIcon("kdenlive-align-top"), i18n("Align top"), this);
153     connect(aligntop, SIGNAL(triggered()), this, SLOT(slotMoveTop()));
154     menu->addAction(aligntop);    
155     QAction *alignvcenter = new QAction(KIcon("kdenlive-align-vert"), i18n("Center vertically"), this);
156     connect(alignvcenter, SIGNAL(triggered()), this, SLOT(slotCenterV()));
157     menu->addAction(alignvcenter);
158     QAction *alignbottom = new QAction(KIcon("kdenlive-align-bottom"), i18n("Align bottom"), this);
159     connect(alignbottom, SIGNAL(triggered()), this, SLOT(slotMoveBottom()));
160     menu->addAction(alignbottom);
161     m_ui.buttonOptions->setMenu(menu);
162
163     /*connect(m_ui.buttonMoveLeft,   SIGNAL(clicked()), this, SLOT(slotMoveLeft()));
164     connect(m_ui.buttonCenterH,    SIGNAL(clicked()), this, SLOT(slotCenterH()));
165     connect(m_ui.buttonMoveRight,  SIGNAL(clicked()), this, SLOT(slotMoveRight()));
166     connect(m_ui.buttonMoveTop,    SIGNAL(clicked()), this, SLOT(slotMoveTop()));
167     connect(m_ui.buttonCenterV,    SIGNAL(clicked()), this, SLOT(slotCenterV()));
168     connect(m_ui.buttonMoveBottom, SIGNAL(clicked()), this, SLOT(slotMoveBottom()));*/
169
170
171     /*
172         Setup of configuration controls
173     */
174
175     connect(edit, SIGNAL(showEdit(bool)), this, SLOT(slotShowScene(bool)));
176
177     connect(m_scene, SIGNAL(addKeyframe()),    this, SLOT(slotAddKeyframe()));
178     connect(m_monitor, SIGNAL(renderPosition(int)), this, SLOT(slotCheckMonitorPosition(int)));
179     connect(this, SIGNAL(parameterChanged()), this, SLOT(slotUpdateProperties()));
180 }
181
182 GeometryWidget::~GeometryWidget()
183 {
184     m_scene->setEnabled(true);
185     delete m_timePos;
186     delete m_timeline;
187     delete m_spinX;
188     delete m_spinY;
189     delete m_spinWidth;
190     delete m_spinHeight;
191     delete m_opacity;
192     m_scene->removeItem(m_rect);
193     if (m_rect) delete m_rect;
194     if (m_previous) delete m_previous;
195     delete m_geometry;
196     if (m_monitor) {
197         m_monitor->getEffectEdit()->showVisibilityButton(false);
198         m_monitor->slotEffectScene(false);
199     }
200 }
201
202 void GeometryWidget::slotShowPreviousKeyFrame(bool show)
203 {
204     KdenliveSettings::setOnmonitoreffects_geometryshowprevious(show);
205     slotPositionChanged(-1, false);
206 }
207
208 void GeometryWidget::updateTimecodeFormat()
209 {
210     m_timePos->slotUpdateTimeCodeFormat();
211 }
212
213 QString GeometryWidget::getValue() const
214 {
215     return m_geometry->serialise();
216 }
217
218 void GeometryWidget::setupParam(const QDomElement elem, int minframe, int maxframe)
219 {
220     m_inPoint = minframe;
221     m_outPoint = maxframe;
222
223     if (m_geometry)
224         m_geometry->parse(elem.attribute("value").toUtf8().data(), maxframe - minframe, m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
225     else
226         m_geometry = new Mlt::Geometry(elem.attribute("value").toUtf8().data(), maxframe - minframe, m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
227
228     if (elem.attribute("fixed") == "1" || maxframe < minframe) {
229         // Keyframes are disabled
230         m_ui.widgetTimeWrapper->setHidden(true);
231     } else {
232         m_ui.widgetTimeWrapper->setHidden(false);
233         m_timeline->setKeyGeometry(m_geometry, m_outPoint - m_inPoint - 1);
234         m_timeline->update();
235         m_timePos->setRange(0, m_outPoint - m_inPoint - 1);
236     }
237
238     // no opacity
239     if (elem.attribute("opacity") == "false") {
240         m_opacity->setHidden(true);
241         m_ui.horizontalLayout2->addStretch(2);
242     }
243
244     Mlt::GeometryItem item;
245
246     m_geometry->fetch(&item, 0);
247     delete m_rect;
248     m_rect = new OnMonitorRectItem(QRectF(0, 0, item.w(), item.h()), m_monitor->render->dar());
249     m_rect->setPos(item.x(), item.y());
250     m_rect->setZValue(0);
251     m_scene->addItem(m_rect);
252     connect(m_rect, SIGNAL(changed()), this, SLOT(slotUpdateGeometry()));
253
254     slotPositionChanged(0, false);
255     slotCheckMonitorPosition(m_monitor->render->seekFramePosition());
256 }
257
258 void GeometryWidget::slotSyncPosition(int relTimelinePos)
259 {
260     // do only sync if this effect is keyframable
261     if (m_timePos->maximum() > 0 && KdenliveSettings::transitionfollowcursor()) {
262         relTimelinePos = qBound(0, relTimelinePos, m_timePos->maximum());
263         if (relTimelinePos != m_timePos->getValue())
264             slotPositionChanged(relTimelinePos, false);
265     }
266 }
267
268
269 void GeometryWidget::slotPositionChanged(int pos, bool seek)
270 {
271     if (pos == -1)
272         pos = m_timePos->getValue();
273     else
274         m_timePos->setValue(pos);
275
276     m_timeline->blockSignals(true);
277     m_timeline->setValue(pos);
278     m_timeline->blockSignals(false);
279
280     Mlt::GeometryItem item;
281     Mlt::GeometryItem previousItem;
282     if (m_geometry->fetch(&item, pos) || item.key() == false) {
283         // no keyframe
284         m_rect->setEnabled(false);
285         m_scene->setEnabled(false);
286         m_ui.widgetGeometry->setEnabled(false);
287         m_ui.buttonAddDelete->setIcon(KIcon("document-new"));
288         m_ui.buttonAddDelete->setToolTip(i18n("Add keyframe"));
289     } else {
290         // keyframe
291         m_rect->setEnabled(true);
292         m_scene->setEnabled(true);
293         m_ui.widgetGeometry->setEnabled(true);
294         m_ui.buttonAddDelete->setIcon(KIcon("edit-delete"));
295         m_ui.buttonAddDelete->setToolTip(i18n("Delete keyframe"));
296     }
297     
298     if (KdenliveSettings::onmonitoreffects_geometryshowprevious() == false || m_geometry->prev_key(&previousItem, pos - 1) || previousItem.frame() == item.frame()) {
299         if (m_previous) {
300             m_scene->removeItem(m_previous);
301         }
302     }
303     else if (m_previous && m_previous->scene() && m_previous->data(Qt::UserRole).toInt() == previousItem.frame()) {
304         // previous frame already here, do nothing
305     }
306     else {
307         if (m_previous == NULL) {
308             m_previous = new QGraphicsRectItem(0, 0, previousItem.w(), previousItem.h());
309             m_previous->setBrush(QColor(200, 200, 0, 20));
310             m_previous->setPen(QPen(Qt::white, 0, Qt::DotLine));
311             m_previous->setPos(previousItem.x(), previousItem.y());
312             m_previous->setZValue(-1);
313             m_previous->setEnabled(false);
314         }
315         else {
316             m_previous->setPos(previousItem.x(), previousItem.y());
317             m_previous->setRect(0, 0, previousItem.w(), previousItem.h());
318         }
319         m_previous->setData(Qt::UserRole, previousItem.frame());
320         if (m_previous->scene() == 0) m_scene->addItem(m_previous);
321     }
322
323     m_rect->setPos(item.x(), item.y());
324     m_rect->setRect(0, 0, item.w(), item.h());
325
326     m_opacity->blockSignals(true);
327     m_opacity->setValue(item.mix());
328     m_opacity->blockSignals(false);
329
330     slotUpdateProperties();
331
332     if (seek && KdenliveSettings::transitionfollowcursor())
333         emit seekToPos(m_clipPos + pos);
334 }
335
336 void GeometryWidget::slotKeyframeMoved(int pos)
337 {
338     slotPositionChanged(pos);
339     slotUpdateGeometry();
340     QTimer::singleShot(100, this, SIGNAL(parameterChanged()));
341 }
342
343 void GeometryWidget::slotAddKeyframe(int pos)
344 {
345     Mlt::GeometryItem item;
346     if (pos == -1)
347         pos = m_timePos->getValue();
348     item.frame(pos);
349     QRectF r = m_rect->rect().normalized();
350     QPointF rectpos = m_rect->pos();
351     item.x(rectpos.x());
352     item.y(rectpos.y());
353     item.w(r.width());
354     item.h(r.height());
355     item.mix(m_opacity->value());
356     m_geometry->insert(item);
357
358     m_timeline->update();
359     slotPositionChanged(pos, false);
360     emit parameterChanged();
361 }
362
363 void GeometryWidget::slotDeleteKeyframe(int pos)
364 {
365     Mlt::GeometryItem item;
366     if (pos == -1)
367         pos = m_timePos->getValue();
368     // check there is more than one keyframe, do not allow to delete last one
369     if (m_geometry->next_key(&item, pos + 1)) {
370         if (m_geometry->prev_key(&item, pos - 1) || item.frame() == pos)
371             return;
372     }
373     m_geometry->remove(pos);
374
375     m_timeline->update();
376     slotPositionChanged(pos, false);
377     emit parameterChanged();
378 }
379
380 void GeometryWidget::slotPreviousKeyframe()
381 {
382     Mlt::GeometryItem item;
383     // Go to start if no keyframe is found
384     int currentPos = m_timePos->getValue();
385     int pos = 0;
386     if (!m_geometry->prev_key(&item, currentPos - 1) && item.frame() < currentPos)
387         pos = item.frame();
388
389     slotPositionChanged(pos);
390 }
391
392 void GeometryWidget::slotNextKeyframe()
393 {
394     Mlt::GeometryItem item;
395     // Go to end if no keyframe is found
396     int pos = m_timeline->frameLength;
397     if (!m_geometry->next_key(&item, m_timeline->value() + 1))
398         pos = item.frame();
399
400     slotPositionChanged(pos);
401 }
402
403 void GeometryWidget::slotAddDeleteKeyframe()
404 {
405     Mlt::GeometryItem item;
406     if (m_geometry->fetch(&item, m_timePos->getValue()) || item.key() == false)
407         slotAddKeyframe();
408     else
409         slotDeleteKeyframe();
410 }
411
412
413 void GeometryWidget::slotCheckMonitorPosition(int renderPos)
414 {
415     if (m_showScene) {
416         /*
417             We do only get the position in timeline if this geometry belongs to a transition,
418             therefore we need two ways here.
419         */
420         if (m_isEffect) {
421             emit checkMonitorPosition(renderPos);
422         } else {
423             if (renderPos >= m_clipPos && renderPos <= m_clipPos + m_outPoint - m_inPoint) {
424                 if (!m_scene->views().at(0)->isVisible())
425                     m_monitor->slotEffectScene(true);
426             } else {
427                 m_monitor->slotEffectScene(false);
428             }
429         }
430     }
431 }
432
433
434 void GeometryWidget::slotUpdateGeometry()
435 {
436     Mlt::GeometryItem item;
437     int pos = m_timePos->getValue();
438
439     // get keyframe and make sure it is the correct one
440     if (m_geometry->next_key(&item, pos) || item.frame() != pos)
441         return;
442
443     QRectF rectSize = m_rect->rect().normalized();
444     QPointF rectPos = m_rect->pos();
445     item.x(rectPos.x());
446     item.y(rectPos.y());
447     item.w(rectSize.width());
448     item.h(rectSize.height());
449     m_geometry->insert(item);
450     emit parameterChanged();
451 }
452
453 void GeometryWidget::slotUpdateProperties()
454 {
455     QRectF rectSize = m_rect->rect().normalized();
456     QPointF rectPos = m_rect->pos();
457     double size;
458     if (rectSize.width() / m_monitor->render->dar() > rectSize.height())
459         size = rectSize.width() * 100.0 / m_monitor->render->frameRenderWidth();
460     else
461         size = rectSize.height() * 100.0 / m_monitor->render->renderHeight();
462
463     m_spinX->blockSignals(true);
464     m_spinY->blockSignals(true);
465     m_spinWidth->blockSignals(true);
466     m_spinHeight->blockSignals(true);
467     m_spinSize->blockSignals(true);
468
469     m_spinX->setValue(rectPos.x());
470     m_spinY->setValue(rectPos.y());
471     m_spinWidth->setValue(rectSize.width());
472     m_spinHeight->setValue(rectSize.height());
473     m_spinSize->setValue(size);
474
475     m_spinX->blockSignals(false);
476     m_spinY->blockSignals(false);
477     m_spinWidth->blockSignals(false);
478     m_spinHeight->blockSignals(false);
479     m_spinSize->blockSignals(false);
480 }
481
482
483 void GeometryWidget::slotSetX(int value)
484 {
485     m_rect->setPos(value, m_spinY->value());
486     slotUpdateGeometry();
487 }
488
489 void GeometryWidget::slotSetY(int value)
490 {
491     m_rect->setPos(m_spinX->value(), value);
492     slotUpdateGeometry();
493 }
494
495 void GeometryWidget::slotSetWidth(int value)
496 {
497     m_rect->setRect(0, 0, value, m_spinHeight->value());
498     slotUpdateGeometry();
499 }
500
501 void GeometryWidget::slotSetHeight(int value)
502 {
503     m_rect->setRect(0, 0, m_spinWidth->value(), value);
504     slotUpdateGeometry();
505 }
506
507 void GeometryWidget::updateMonitorGeometry()
508 {
509     m_rect->setRect(0, 0, m_spinWidth->value(), m_spinHeight->value());
510     slotUpdateGeometry();
511 }
512
513
514 void GeometryWidget::slotResize(double value)
515 {
516     m_rect->setRect(0, 0,
517                     (int)((m_monitor->render->frameRenderWidth() * value / 100.0) + 0.5),
518                     (int)((m_monitor->render->renderHeight() * value / 100.0) + 0.5));
519     slotUpdateGeometry();
520 }
521
522
523 void GeometryWidget::slotSetOpacity(int value)
524 {
525     int pos = m_timePos->getValue();
526     Mlt::GeometryItem item;
527     if (m_geometry->fetch(&item, pos) || item.key() == false)
528         return;
529     item.mix(value);
530     m_geometry->insert(item);
531     emit parameterChanged();
532 }
533
534
535 void GeometryWidget::slotMoveLeft()
536 {
537     m_rect->setPos(0, m_rect->pos().y());
538     slotUpdateGeometry();
539 }
540
541 void GeometryWidget::slotCenterH()
542 {
543     m_rect->setPos((m_monitor->render->frameRenderWidth() - m_rect->rect().width()) / 2, m_rect->pos().y());
544     slotUpdateGeometry();
545 }
546
547 void GeometryWidget::slotMoveRight()
548 {
549     m_rect->setPos(m_monitor->render->frameRenderWidth() - m_rect->rect().width(), m_rect->pos().y());
550     slotUpdateGeometry();
551 }
552
553 void GeometryWidget::slotMoveTop()
554 {
555     m_rect->setPos(m_rect->pos().x(), 0);
556     slotUpdateGeometry();
557 }
558
559 void GeometryWidget::slotCenterV()
560 {
561     m_rect->setPos(m_rect->pos().x(), (m_monitor->render->renderHeight() - m_rect->rect().height()) / 2);
562     slotUpdateGeometry();
563 }
564
565 void GeometryWidget::slotMoveBottom()
566 {
567     m_rect->setPos(m_rect->pos().x(), m_monitor->render->renderHeight() - m_rect->rect().height());
568     slotUpdateGeometry();
569 }
570
571
572 void GeometryWidget::slotSetSynchronize(bool sync)
573 {
574     KdenliveSettings::setTransitionfollowcursor(sync);
575     if (sync)
576         emit seekToPos(m_clipPos + m_timePos->getValue());
577 }
578
579 void GeometryWidget::slotShowScene(bool show)
580 {
581     m_showScene = show;
582     if (!m_showScene)
583         m_monitor->slotEffectScene(false);
584     else
585         slotCheckMonitorPosition(m_monitor->render->seekFramePosition());
586 }
587
588 void GeometryWidget::setFrameSize(QPoint size)
589 {
590     m_frameSize = size;
591 }
592
593 void GeometryWidget::slotAdjustToFrameSize()
594 {
595     if (m_frameSize == QPoint()) m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
596     m_spinWidth->blockSignals(true);
597     m_spinHeight->blockSignals(true);
598     m_spinWidth->setValue((int) (m_frameSize.x() / m_monitor->render->sar() + 0.5));
599     m_spinHeight->setValue(m_frameSize.y());
600     m_spinWidth->blockSignals(false);
601     m_spinHeight->blockSignals(false);
602     updateMonitorGeometry();
603 }
604
605 void GeometryWidget::slotFitToWidth()
606 {
607     if (m_frameSize == QPoint()) m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
608     double factor = (double) m_monitor->render->frameRenderWidth() / m_frameSize.x() * m_monitor->render->sar();
609     m_spinWidth->blockSignals(true);
610     m_spinHeight->blockSignals(true);
611     m_spinHeight->setValue((int) (m_frameSize.y() * factor + 0.5));
612     m_spinWidth->setValue(m_monitor->render->frameRenderWidth());
613     m_spinWidth->blockSignals(false);
614     m_spinHeight->blockSignals(false);
615     updateMonitorGeometry();
616 }
617
618 void GeometryWidget::slotFitToHeight()
619 {
620     if (m_frameSize == QPoint()) m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
621     double factor = (double) m_monitor->render->renderHeight() / m_frameSize.y();
622     m_spinWidth->blockSignals(true);
623     m_spinHeight->blockSignals(true);
624     m_spinHeight->setValue(m_monitor->render->renderHeight());
625     m_spinWidth->setValue((int) (m_frameSize.x() / m_monitor->render->sar() * factor + 0.5));
626     m_spinWidth->blockSignals(false);
627     m_spinHeight->blockSignals(false);
628     updateMonitorGeometry();
629 }
630
631 #include "geometrywidget.moc"