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, -1, QString(), false, this);
96 m_spinX->setRange(-99000, 99000);
97 m_ui.horizontalLayout->addWidget(m_spinX);
99 m_spinY = new DragValue(i18nc("y axis position", "Y"), 0, 0, -1, QString(), false, this);
100 m_spinY->setRange(-99000, 99000);
101 m_ui.horizontalLayout->addWidget(m_spinY);
103 m_spinWidth = new DragValue(i18nc("Frame width", "W"), m_monitor->render->frameRenderWidth(), 0, -1, QString(), false, this);
104 m_spinWidth->setRange(1, 99000);
105 m_ui.horizontalLayout->addWidget(m_spinWidth);
107 m_spinHeight = new DragValue(i18nc("Frame height", "H"), m_monitor->render->renderHeight(), 0, -1, QString(), false, this);
108 m_spinHeight->setRange(1, 99000);
109 m_ui.horizontalLayout->addWidget(m_spinHeight);
111 QMenu *menu = new QMenu(this);
112 QAction *adjustSize = new QAction(i18n("Adjust to original size"), this);
113 connect(adjustSize, SIGNAL(triggered()), this, SLOT(slotAdjustToFrameSize()));
114 menu->addAction(adjustSize);
115 QAction *fitToWidth = new QAction(i18n("Fit to width"), this);
116 connect(fitToWidth, SIGNAL(triggered()), this, SLOT(slotFitToWidth()));
117 menu->addAction(fitToWidth);
118 QAction *fitToHeight = new QAction(i18n("Fit to height"), this);
119 connect(fitToHeight, SIGNAL(triggered()), this, SLOT(slotFitToHeight()));
120 menu->addAction(fitToHeight);
121 menu->addSeparator();
123 QAction *alignleft = new QAction(KIcon("kdenlive-align-left"), i18n("Align left"), this);
124 connect(alignleft, SIGNAL(triggered()), this, SLOT(slotMoveLeft()));
125 menu->addAction(alignleft);
126 QAction *alignhcenter = new QAction(KIcon("kdenlive-align-hor"), i18n("Center horizontally"), this);
127 connect(alignhcenter, SIGNAL(triggered()), this, SLOT(slotCenterH()));
128 menu->addAction(alignhcenter);
129 QAction *alignright = new QAction(KIcon("kdenlive-align-right"), i18n("Align right"), this);
130 connect(alignright, SIGNAL(triggered()), this, SLOT(slotMoveRight()));
131 menu->addAction(alignright);
132 QAction *aligntop = new QAction(KIcon("kdenlive-align-top"), i18n("Align top"), this);
133 connect(aligntop, SIGNAL(triggered()), this, SLOT(slotMoveTop()));
134 menu->addAction(aligntop);
135 QAction *alignvcenter = new QAction(KIcon("kdenlive-align-vert"), i18n("Center vertically"), this);
136 connect(alignvcenter, SIGNAL(triggered()), this, SLOT(slotCenterV()));
137 menu->addAction(alignvcenter);
138 QAction *alignbottom = new QAction(KIcon("kdenlive-align-bottom"), i18n("Align bottom"), this);
139 connect(alignbottom, SIGNAL(triggered()), this, SLOT(slotMoveBottom()));
140 menu->addAction(alignbottom);
141 m_ui.buttonOptions->setMenu(menu);
143 QHBoxLayout *alignLayout = new QHBoxLayout;
144 alignLayout->setSpacing(0);
145 QToolButton *alignButton = new QToolButton;
146 alignButton->setDefaultAction(alignleft);
147 alignButton->setAutoRaise(true);
148 alignLayout->addWidget(alignButton);
150 alignButton = new QToolButton;
151 alignButton->setDefaultAction(alignhcenter);
152 alignButton->setAutoRaise(true);
153 alignLayout->addWidget(alignButton);
155 alignButton = new QToolButton;
156 alignButton->setDefaultAction(alignright);
157 alignButton->setAutoRaise(true);
158 alignLayout->addWidget(alignButton);
160 alignButton = new QToolButton;
161 alignButton->setDefaultAction(aligntop);
162 alignButton->setAutoRaise(true);
163 alignLayout->addWidget(alignButton);
165 alignButton = new QToolButton;
166 alignButton->setDefaultAction(alignvcenter);
167 alignButton->setAutoRaise(true);
168 alignLayout->addWidget(alignButton);
170 alignButton = new QToolButton;
171 alignButton->setDefaultAction(alignbottom);
172 alignButton->setAutoRaise(true);
173 alignLayout->addWidget(alignButton);
175 m_ui.horizontalLayout->addLayout(alignLayout);
176 m_ui.horizontalLayout->addStretch(10);
178 m_spinSize = new DragValue(i18n("Size"), 100, 2, -1, i18n("%"), false, this);
179 m_spinSize->setRange(1, 99000);
180 m_ui.horizontalLayout2->addWidget(m_spinSize);
182 m_opacity = new DragValue(i18n("Opacity"), 100, 0, -1, i18n("%"), true, this);
183 m_ui.horizontalLayout2->addWidget(m_opacity);
187 m_rotateX = new DragValue(i18n("Rotate X"), 0, 0, -1, QString(), true, this);
188 m_rotateX->setRange(-1800, 1800);
189 m_rotateX->setObjectName("rotate_x");
190 m_ui.horizontalLayout3->addWidget(m_rotateX);
191 m_rotateY = new DragValue(i18n("Rotate Y"), 0, 0, -1, QString(), true, this);
192 m_rotateY->setRange(-1800, 1800);
193 m_rotateY->setObjectName("rotate_y");
194 m_ui.horizontalLayout3->addWidget(m_rotateY);
195 m_rotateZ = new DragValue(i18n("Rotate Z"), 0, 0, -1, QString(), true, this);
196 m_rotateZ->setRange(-1800, 1800);
197 m_rotateZ->setObjectName("rotate_z");
198 m_ui.horizontalLayout3->addWidget(m_rotateZ);
199 connect(m_rotateX, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateGeometry()));
200 connect(m_rotateY, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateGeometry()));
201 connect(m_rotateZ, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateGeometry()));
205 Setup of geometry controls
208 connect(m_spinX, SIGNAL(valueChanged(int)), this, SLOT(slotSetX(int)));
209 connect(m_spinY, SIGNAL(valueChanged(int)), this, SLOT(slotSetY(int)));
210 connect(m_spinWidth, SIGNAL(valueChanged(int)), this, SLOT(slotSetWidth(int)));
211 connect(m_spinHeight, SIGNAL(valueChanged(int)), this, SLOT(slotSetHeight(int)));
213 connect(m_spinSize, SIGNAL(valueChanged(double)), this, SLOT(slotResize(double)));
215 connect(m_opacity, SIGNAL(valueChanged(int)), this, SLOT(slotSetOpacity(int)));
217 /*connect(m_ui.buttonMoveLeft, SIGNAL(clicked()), this, SLOT(slotMoveLeft()));
218 connect(m_ui.buttonCenterH, SIGNAL(clicked()), this, SLOT(slotCenterH()));
219 connect(m_ui.buttonMoveRight, SIGNAL(clicked()), this, SLOT(slotMoveRight()));
220 connect(m_ui.buttonMoveTop, SIGNAL(clicked()), this, SLOT(slotMoveTop()));
221 connect(m_ui.buttonCenterV, SIGNAL(clicked()), this, SLOT(slotCenterV()));
222 connect(m_ui.buttonMoveBottom, SIGNAL(clicked()), this, SLOT(slotMoveBottom()));*/
226 Setup of configuration controls
229 connect(edit, SIGNAL(showEdit(bool)), this, SLOT(slotShowScene(bool)));
231 connect(m_scene, SIGNAL(addKeyframe()), this, SLOT(slotAddKeyframe()));
232 connect(m_monitor, SIGNAL(renderPosition(int)), this, SLOT(slotCheckMonitorPosition(int)));
233 connect(this, SIGNAL(parameterChanged()), this, SLOT(slotUpdateProperties()));
236 GeometryWidget::~GeometryWidget()
238 m_scene->setEnabled(true);
246 m_scene->removeItem(m_rect);
247 if (m_rect) delete m_rect;
248 if (m_previous) delete m_previous;
250 m_extraGeometryNames.clear();
251 m_extraFactors.clear();
252 while (!m_extraGeometries.isEmpty()) {
253 Mlt::Geometry *g = m_extraGeometries.takeFirst();
257 m_monitor->getEffectEdit()->showVisibilityButton(false);
258 m_monitor->slotEffectScene(false);
262 void GeometryWidget::slotShowPreviousKeyFrame(bool show)
264 KdenliveSettings::setOnmonitoreffects_geometryshowprevious(show);
265 slotPositionChanged(-1, false);
268 void GeometryWidget::updateTimecodeFormat()
270 m_timePos->slotUpdateTimeCodeFormat();
273 QString GeometryWidget::getValue() const
275 return m_geometry->serialise();
278 QString GeometryWidget::getExtraValue(const QString &name) const
280 int ix = m_extraGeometryNames.indexOf(name);
281 QString val = m_extraGeometries.at(ix)->serialise();
282 if (!val.contains("=")) val = val.section(',', 0, 0);
284 QStringList list = val.split(';');
286 foreach (const QString value, list) {
287 val.append(value.section(',', 0, 0) + ';');
293 void GeometryWidget::setupParam(const QDomElement elem, int minframe, int maxframe)
295 m_inPoint = minframe;
296 m_outPoint = maxframe;
299 m_geometry->parse(elem.attribute("value").toUtf8().data(), maxframe - minframe, m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
301 m_geometry = new Mlt::Geometry(elem.attribute("value").toUtf8().data(), maxframe - minframe, m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
303 if (elem.attribute("fixed") == "1" || maxframe < minframe) {
304 // Keyframes are disabled
305 m_ui.widgetTimeWrapper->setHidden(true);
307 m_ui.widgetTimeWrapper->setHidden(false);
308 m_timeline->setKeyGeometry(m_geometry, m_outPoint - m_inPoint - 1);
309 m_timeline->update();
310 m_timePos->setRange(0, m_outPoint - m_inPoint - 1);
314 if (elem.attribute("opacity") == "false") {
315 m_opacity->setHidden(true);
316 m_ui.horizontalLayout2->addStretch(2);
319 Mlt::GeometryItem item;
321 m_geometry->fetch(&item, 0);
323 m_rect = new OnMonitorRectItem(QRectF(0, 0, item.w(), item.h()), m_monitor->render->dar());
324 m_rect->setPos(item.x(), item.y());
325 m_rect->setZValue(0);
326 m_scene->addItem(m_rect);
327 connect(m_rect, SIGNAL(changed()), this, SLOT(slotUpdateGeometry()));
329 slotPositionChanged(0, false);
330 slotCheckMonitorPosition(m_monitor->render->seekFramePosition());
333 void GeometryWidget::addParameter(const QDomElement elem)
335 Mlt::Geometry *geometry = new Mlt::Geometry(elem.attribute("value").toUtf8().data(), m_outPoint - m_inPoint, m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
336 m_extraGeometries.append(geometry);
337 m_timeline->addGeometry(geometry);
338 m_extraFactors.append(elem.attribute("factor", "1"));
339 m_extraGeometryNames.append(elem.attribute("name"));
340 //kDebug()<<"ADDED PARAM: "<<elem.attribute("value");
343 void GeometryWidget::slotSyncPosition(int relTimelinePos)
345 // do only sync if this effect is keyframable
346 if (m_timePos->maximum() > 0 && KdenliveSettings::transitionfollowcursor()) {
347 relTimelinePos = qBound(0, relTimelinePos, m_timePos->maximum());
348 if (relTimelinePos != m_timePos->getValue())
349 slotPositionChanged(relTimelinePos, false);
354 void GeometryWidget::slotPositionChanged(int pos, bool seek)
357 pos = m_timePos->getValue();
359 m_timePos->setValue(pos);
361 m_timeline->blockSignals(true);
362 m_timeline->setValue(pos);
363 m_timeline->blockSignals(false);
365 Mlt::GeometryItem item;
366 Mlt::GeometryItem previousItem;
367 if (m_geometry->fetch(&item, pos) || item.key() == false) {
369 m_rect->setEnabled(false);
370 m_scene->setEnabled(false);
371 m_ui.widgetGeometry->setEnabled(false);
372 m_ui.buttonAddDelete->setIcon(KIcon("document-new"));
373 m_ui.buttonAddDelete->setToolTip(i18n("Add keyframe"));
376 m_rect->setEnabled(true);
377 m_scene->setEnabled(true);
378 m_ui.widgetGeometry->setEnabled(true);
379 m_ui.buttonAddDelete->setIcon(KIcon("edit-delete"));
380 m_ui.buttonAddDelete->setToolTip(i18n("Delete keyframe"));
383 if (KdenliveSettings::onmonitoreffects_geometryshowprevious() == false || m_geometry->prev_key(&previousItem, pos - 1) || previousItem.frame() == item.frame()) {
385 m_scene->removeItem(m_previous);
388 else if (m_previous && m_previous->scene() && m_previous->data(Qt::UserRole).toInt() == previousItem.frame()) {
389 // previous frame already here, do nothing
392 if (m_previous == NULL) {
393 m_previous = new QGraphicsRectItem(0, 0, previousItem.w(), previousItem.h());
394 m_previous->setBrush(QColor(200, 200, 0, 20));
395 m_previous->setPen(QPen(Qt::white, 0, Qt::DotLine));
396 m_previous->setPos(previousItem.x(), previousItem.y());
397 m_previous->setZValue(-1);
398 m_previous->setEnabled(false);
401 m_previous->setPos(previousItem.x(), previousItem.y());
402 m_previous->setRect(0, 0, previousItem.w(), previousItem.h());
404 m_previous->setData(Qt::UserRole, previousItem.frame());
405 if (m_previous->scene() == 0) m_scene->addItem(m_previous);
408 m_rect->setPos(item.x(), item.y());
409 m_rect->setRect(0, 0, item.w(), item.h());
411 m_opacity->blockSignals(true);
412 m_opacity->setValue(item.mix());
413 m_opacity->blockSignals(false);
415 for (int i = 0; i < m_extraGeometries.count(); i++) {
416 Mlt::Geometry *geom = m_extraGeometries.at(i);
417 QString name = m_extraGeometryNames.at(i);
418 if (!geom->fetch(&item, pos)) {
419 DragValue *widget = findChild<DragValue *>(name);
421 widget->blockSignals(true);
422 widget->setValue(item.x() * m_extraFactors.at(i).toInt());
423 widget->blockSignals(false);
428 slotUpdateProperties();
430 if (seek && KdenliveSettings::transitionfollowcursor())
431 emit seekToPos(m_clipPos + pos);
434 void GeometryWidget::slotKeyframeMoved(int pos)
436 slotPositionChanged(pos);
437 slotUpdateGeometry();
438 QTimer::singleShot(100, this, SIGNAL(parameterChanged()));
441 void GeometryWidget::slotAddKeyframe(int pos)
443 Mlt::GeometryItem item;
445 pos = m_timePos->getValue();
447 QRectF r = m_rect->rect().normalized();
448 QPointF rectpos = m_rect->pos();
453 item.mix(m_opacity->value());
454 m_geometry->insert(item);
456 for (int i = 0; i < m_extraGeometries.count(); i++) {
457 Mlt::Geometry *geom = m_extraGeometries.at(i);
458 QString name = m_extraGeometryNames.at(i);
459 DragValue *widget = findChild<DragValue *>(name);
461 Mlt::GeometryItem item2;
463 item2.x((double) widget->value() / m_extraFactors.at(i).toInt());
468 m_timeline->update();
469 slotPositionChanged(pos, false);
470 emit parameterChanged();
473 void GeometryWidget::slotDeleteKeyframe(int pos)
475 Mlt::GeometryItem item;
477 pos = m_timePos->getValue();
478 // check there is more than one keyframe, do not allow to delete last one
479 if (m_geometry->next_key(&item, pos + 1)) {
480 if (m_geometry->prev_key(&item, pos - 1) || item.frame() == pos)
483 m_geometry->remove(pos);
485 for (int i = 0; i < m_extraGeometries.count(); i++) {
486 Mlt::Geometry *geom = m_extraGeometries.at(i);
490 m_timeline->update();
491 slotPositionChanged(pos, false);
492 emit parameterChanged();
495 void GeometryWidget::slotPreviousKeyframe()
497 Mlt::GeometryItem item;
498 // Go to start if no keyframe is found
499 int currentPos = m_timePos->getValue();
501 if (!m_geometry->prev_key(&item, currentPos - 1) && item.frame() < currentPos)
504 slotPositionChanged(pos);
507 void GeometryWidget::slotNextKeyframe()
509 Mlt::GeometryItem item;
510 // Go to end if no keyframe is found
511 int pos = m_timeline->frameLength;
512 if (!m_geometry->next_key(&item, m_timeline->value() + 1))
515 slotPositionChanged(pos);
518 void GeometryWidget::slotAddDeleteKeyframe()
520 Mlt::GeometryItem item;
521 if (m_geometry->fetch(&item, m_timePos->getValue()) || item.key() == false)
524 slotDeleteKeyframe();
528 void GeometryWidget::slotCheckMonitorPosition(int renderPos)
532 We do only get the position in timeline if this geometry belongs to a transition,
533 therefore we need two ways here.
536 emit checkMonitorPosition(renderPos);
538 if (renderPos >= m_clipPos && renderPos <= m_clipPos + m_outPoint - m_inPoint) {
539 if (!m_scene->views().at(0)->isVisible())
540 m_monitor->slotEffectScene(true);
542 m_monitor->slotEffectScene(false);
549 void GeometryWidget::slotUpdateGeometry()
551 Mlt::GeometryItem item;
552 int pos = m_timePos->getValue();
554 // get keyframe and make sure it is the correct one
555 if (m_geometry->next_key(&item, pos) || item.frame() != pos)
558 QRectF rectSize = m_rect->rect().normalized();
559 QPointF rectPos = m_rect->pos();
562 item.w(rectSize.width());
563 item.h(rectSize.height());
564 m_geometry->insert(item);
566 for (int i = 0; i < m_extraGeometries.count(); i++) {
567 Mlt::Geometry *geom = m_extraGeometries.at(i);
568 QString name = m_extraGeometryNames.at(i);
569 Mlt::GeometryItem item2;
570 DragValue *widget = findChild<DragValue *>(name);
571 if (widget && !geom->next_key(&item2, pos) && item2.frame() == pos) {
572 item2.x((double) widget->value() / m_extraFactors.at(i).toInt());
577 emit parameterChanged();
580 void GeometryWidget::slotUpdateProperties()
582 QRectF rectSize = m_rect->rect().normalized();
583 QPointF rectPos = m_rect->pos();
585 if (rectSize.width() / m_monitor->render->dar() > rectSize.height())
586 size = rectSize.width() * 100.0 / m_monitor->render->frameRenderWidth();
588 size = rectSize.height() * 100.0 / m_monitor->render->renderHeight();
590 m_spinX->blockSignals(true);
591 m_spinY->blockSignals(true);
592 m_spinWidth->blockSignals(true);
593 m_spinHeight->blockSignals(true);
594 m_spinSize->blockSignals(true);
596 m_spinX->setValue(rectPos.x());
597 m_spinY->setValue(rectPos.y());
598 m_spinWidth->setValue(rectSize.width());
599 m_spinHeight->setValue(rectSize.height());
600 m_spinSize->setValue(size);
602 m_spinX->blockSignals(false);
603 m_spinY->blockSignals(false);
604 m_spinWidth->blockSignals(false);
605 m_spinHeight->blockSignals(false);
606 m_spinSize->blockSignals(false);
610 void GeometryWidget::slotSetX(int value)
612 m_rect->setPos(value, m_spinY->value());
613 slotUpdateGeometry();
616 void GeometryWidget::slotSetY(int value)
618 m_rect->setPos(m_spinX->value(), value);
619 slotUpdateGeometry();
622 void GeometryWidget::slotSetWidth(int value)
624 m_rect->setRect(0, 0, value, m_spinHeight->value());
625 slotUpdateGeometry();
628 void GeometryWidget::slotSetHeight(int value)
630 m_rect->setRect(0, 0, m_spinWidth->value(), value);
631 slotUpdateGeometry();
634 void GeometryWidget::updateMonitorGeometry()
636 m_rect->setRect(0, 0, m_spinWidth->value(), m_spinHeight->value());
637 slotUpdateGeometry();
641 void GeometryWidget::slotResize(double value)
643 m_rect->setRect(0, 0,
644 (int)((m_monitor->render->frameRenderWidth() * value / 100.0) + 0.5),
645 (int)((m_monitor->render->renderHeight() * value / 100.0) + 0.5));
646 slotUpdateGeometry();
650 void GeometryWidget::slotSetOpacity(int value)
652 int pos = m_timePos->getValue();
653 Mlt::GeometryItem item;
654 if (m_geometry->fetch(&item, pos) || item.key() == false)
657 m_geometry->insert(item);
658 emit parameterChanged();
662 void GeometryWidget::slotMoveLeft()
664 m_rect->setPos(0, m_rect->pos().y());
665 slotUpdateGeometry();
668 void GeometryWidget::slotCenterH()
670 m_rect->setPos((m_monitor->render->frameRenderWidth() - m_rect->rect().width()) / 2, m_rect->pos().y());
671 slotUpdateGeometry();
674 void GeometryWidget::slotMoveRight()
676 m_rect->setPos(m_monitor->render->frameRenderWidth() - m_rect->rect().width(), m_rect->pos().y());
677 slotUpdateGeometry();
680 void GeometryWidget::slotMoveTop()
682 m_rect->setPos(m_rect->pos().x(), 0);
683 slotUpdateGeometry();
686 void GeometryWidget::slotCenterV()
688 m_rect->setPos(m_rect->pos().x(), (m_monitor->render->renderHeight() - m_rect->rect().height()) / 2);
689 slotUpdateGeometry();
692 void GeometryWidget::slotMoveBottom()
694 m_rect->setPos(m_rect->pos().x(), m_monitor->render->renderHeight() - m_rect->rect().height());
695 slotUpdateGeometry();
699 void GeometryWidget::slotSetSynchronize(bool sync)
701 KdenliveSettings::setTransitionfollowcursor(sync);
703 emit seekToPos(m_clipPos + m_timePos->getValue());
706 void GeometryWidget::slotShowScene(bool show)
710 m_monitor->slotEffectScene(false);
712 slotCheckMonitorPosition(m_monitor->render->seekFramePosition());
715 void GeometryWidget::setFrameSize(QPoint size)
720 void GeometryWidget::slotAdjustToFrameSize()
722 if (m_frameSize == QPoint()) m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
723 m_spinWidth->blockSignals(true);
724 m_spinHeight->blockSignals(true);
725 m_spinWidth->setValue((int) (m_frameSize.x() / m_monitor->render->sar() + 0.5));
726 m_spinHeight->setValue(m_frameSize.y());
727 m_spinWidth->blockSignals(false);
728 m_spinHeight->blockSignals(false);
729 updateMonitorGeometry();
732 void GeometryWidget::slotFitToWidth()
734 if (m_frameSize == QPoint()) m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
735 double factor = (double) m_monitor->render->frameRenderWidth() / m_frameSize.x() * m_monitor->render->sar();
736 m_spinWidth->blockSignals(true);
737 m_spinHeight->blockSignals(true);
738 m_spinHeight->setValue((int) (m_frameSize.y() * factor + 0.5));
739 m_spinWidth->setValue(m_monitor->render->frameRenderWidth());
740 m_spinWidth->blockSignals(false);
741 m_spinHeight->blockSignals(false);
742 updateMonitorGeometry();
745 void GeometryWidget::slotFitToHeight()
747 if (m_frameSize == QPoint()) m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
748 double factor = (double) m_monitor->render->renderHeight() / m_frameSize.y();
749 m_spinWidth->blockSignals(true);
750 m_spinHeight->blockSignals(true);
751 m_spinHeight->setValue(m_monitor->render->renderHeight());
752 m_spinWidth->setValue((int) (m_frameSize.x() / m_monitor->render->sar() * factor + 0.5));
753 m_spinWidth->blockSignals(false);
754 m_spinHeight->blockSignals(false);
755 updateMonitorGeometry();
758 #include "geometrywidget.moc"