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 int size = style()->pixelMetric(QStyle::PM_SmallIconSize);
75 QSize iconSize(size, size);
77 m_ui.buttonPrevious->setIcon(KIcon("media-skip-backward"));
78 m_ui.buttonPrevious->setToolTip(i18n("Go to previous keyframe"));
79 m_ui.buttonPrevious->setIconSize(iconSize);
80 m_ui.buttonNext->setIcon(KIcon("media-skip-forward"));
81 m_ui.buttonNext->setToolTip(i18n("Go to next keyframe"));
82 m_ui.buttonNext->setIconSize(iconSize);
83 m_ui.buttonAddDelete->setIcon(KIcon("document-new"));
84 m_ui.buttonAddDelete->setToolTip(i18n("Add keyframe"));
85 m_ui.buttonAddDelete->setIconSize(iconSize);
87 m_ui.buttonSync->setIcon(KIcon("insert-link"));
88 m_ui.buttonSync->setToolTip(i18n("Synchronize with timeline cursor"));
89 m_ui.buttonSync->setChecked(KdenliveSettings::transitionfollowcursor());
90 m_ui.buttonSync->setIconSize(iconSize);
92 connect(m_timeline, SIGNAL(positionChanged(int)), this, SLOT(slotPositionChanged(int)));
93 connect(m_timeline, SIGNAL(keyframeMoved(int)), this, SLOT(slotKeyframeMoved(int)));
94 connect(m_timeline, SIGNAL(addKeyframe(int)), this, SLOT(slotAddKeyframe(int)));
95 connect(m_timeline, SIGNAL(removeKeyframe(int)), this, SLOT(slotDeleteKeyframe(int)));
96 connect(m_timePos, SIGNAL(editingFinished()), this, SLOT(slotPositionChanged()));
97 connect(m_ui.buttonPrevious, SIGNAL(clicked()), this, SLOT(slotPreviousKeyframe()));
98 connect(m_ui.buttonNext, SIGNAL(clicked()), this, SLOT(slotNextKeyframe()));
99 connect(m_ui.buttonAddDelete, SIGNAL(clicked()), this, SLOT(slotAddDeleteKeyframe()));
100 connect(m_ui.buttonSync, SIGNAL(toggled(bool)), this, SLOT(slotSetSynchronize(bool)));
102 m_spinX = new DragValue(i18nc("x axis position", "X"), 0, 0, -99000, 99000, -1, QString(), false, this);
103 m_ui.horizontalLayout->addWidget(m_spinX, 0, 0);
105 m_spinY = new DragValue(i18nc("y axis position", "Y"), 0, 0, -99000, 99000, -1, QString(), false, this);
106 m_ui.horizontalLayout->addWidget(m_spinY, 0, 1);
108 m_spinWidth = new DragValue(i18nc("Frame width", "W"), m_monitor->render->frameRenderWidth(), 0, 1, 99000, -1, QString(), false, this);
109 m_ui.horizontalLayout->addWidget(m_spinWidth, 0, 2);
111 m_spinHeight = new DragValue(i18nc("Frame height", "H"), m_monitor->render->renderHeight(), 0, 1, 99000, -1, QString(), false, this);
112 m_ui.horizontalLayout->addWidget(m_spinHeight, 0, 3);
114 QMenu *menu = new QMenu(this);
115 QAction *adjustSize = new QAction(i18n("Adjust to original size"), this);
116 connect(adjustSize, SIGNAL(triggered()), this, SLOT(slotAdjustToFrameSize()));
117 menu->addAction(adjustSize);
118 QAction *fitToWidth = new QAction(i18n("Fit to width"), this);
119 connect(fitToWidth, SIGNAL(triggered()), this, SLOT(slotFitToWidth()));
120 menu->addAction(fitToWidth);
121 QAction *fitToHeight = new QAction(i18n("Fit to height"), this);
122 connect(fitToHeight, SIGNAL(triggered()), this, SLOT(slotFitToHeight()));
123 menu->addAction(fitToHeight);
124 menu->addSeparator();
126 QAction *alignleft = new QAction(KIcon("kdenlive-align-left"), i18n("Align left"), this);
127 connect(alignleft, SIGNAL(triggered()), this, SLOT(slotMoveLeft()));
128 menu->addAction(alignleft);
129 QAction *alignhcenter = new QAction(KIcon("kdenlive-align-hor"), i18n("Center horizontally"), this);
130 connect(alignhcenter, SIGNAL(triggered()), this, SLOT(slotCenterH()));
131 menu->addAction(alignhcenter);
132 QAction *alignright = new QAction(KIcon("kdenlive-align-right"), i18n("Align right"), this);
133 connect(alignright, SIGNAL(triggered()), this, SLOT(slotMoveRight()));
134 menu->addAction(alignright);
135 QAction *aligntop = new QAction(KIcon("kdenlive-align-top"), i18n("Align top"), this);
136 connect(aligntop, SIGNAL(triggered()), this, SLOT(slotMoveTop()));
137 menu->addAction(aligntop);
138 QAction *alignvcenter = new QAction(KIcon("kdenlive-align-vert"), i18n("Center vertically"), this);
139 connect(alignvcenter, SIGNAL(triggered()), this, SLOT(slotCenterV()));
140 menu->addAction(alignvcenter);
141 QAction *alignbottom = new QAction(KIcon("kdenlive-align-bottom"), i18n("Align bottom"), this);
142 connect(alignbottom, SIGNAL(triggered()), this, SLOT(slotMoveBottom()));
143 menu->addAction(alignbottom);
144 m_ui.buttonOptions->setMenu(menu);
146 QHBoxLayout *alignLayout = new QHBoxLayout;
147 alignLayout->setSpacing(0);
148 QToolButton *alignButton = new QToolButton;
149 alignButton->setDefaultAction(alignleft);
150 alignButton->setAutoRaise(true);
151 alignLayout->addWidget(alignButton);
153 alignButton = new QToolButton;
154 alignButton->setDefaultAction(alignhcenter);
155 alignButton->setAutoRaise(true);
156 alignLayout->addWidget(alignButton);
158 alignButton = new QToolButton;
159 alignButton->setDefaultAction(alignright);
160 alignButton->setAutoRaise(true);
161 alignLayout->addWidget(alignButton);
163 alignButton = new QToolButton;
164 alignButton->setDefaultAction(aligntop);
165 alignButton->setAutoRaise(true);
166 alignLayout->addWidget(alignButton);
168 alignButton = new QToolButton;
169 alignButton->setDefaultAction(alignvcenter);
170 alignButton->setAutoRaise(true);
171 alignLayout->addWidget(alignButton);
173 alignButton = new QToolButton;
174 alignButton->setDefaultAction(alignbottom);
175 alignButton->setAutoRaise(true);
176 alignLayout->addWidget(alignButton);
177 alignLayout->addStretch(10);
179 m_ui.horizontalLayout->addLayout(alignLayout, 1, 0, 1, 4);
180 //m_ui.horizontalLayout->addStretch(10);
182 m_spinSize = new DragValue(i18n("Size"), 100, 2, 1, 99000, -1, i18n("%"), false, this);
183 m_ui.horizontalLayout2->addWidget(m_spinSize);
185 m_opacity = new DragValue(i18n("Opacity"), 100, 0, 0, 100, -1, i18n("%"), true, this);
186 m_ui.horizontalLayout2->addWidget(m_opacity);
190 m_rotateX = new DragValue(i18n("Rotate X"), 0, 0, -1800, 1800, -1, QString(), true, this);
191 m_rotateX->setObjectName("rotate_x");
192 m_ui.horizontalLayout3->addWidget(m_rotateX);
193 m_rotateY = new DragValue(i18n("Rotate Y"), 0, 0, -1800, 1800, -1, QString(), true, this);
194 m_rotateY->setObjectName("rotate_y");
195 m_ui.horizontalLayout3->addWidget(m_rotateY);
196 m_rotateZ = new DragValue(i18n("Rotate Z"), 0, 0, -1800, 1800, -1, QString(), true, this);
197 m_rotateZ->setObjectName("rotate_z");
198 m_ui.horizontalLayout3->addWidget(m_rotateZ);
199 connect(m_rotateX, SIGNAL(valueChanged(double)), this, SLOT(slotUpdateGeometry()));
200 connect(m_rotateY, SIGNAL(valueChanged(double)), this, SLOT(slotUpdateGeometry()));
201 connect(m_rotateZ, SIGNAL(valueChanged(double)), this, SLOT(slotUpdateGeometry()));
205 Setup of geometry controls
208 connect(m_spinX, SIGNAL(valueChanged(double)), this, SLOT(slotSetX(double)));
209 connect(m_spinY, SIGNAL(valueChanged(double)), this, SLOT(slotSetY(double)));
210 connect(m_spinWidth, SIGNAL(valueChanged(double)), this, SLOT(slotSetWidth(double)));
211 connect(m_spinHeight, SIGNAL(valueChanged(double)), this, SLOT(slotSetHeight(double)));
213 connect(m_spinSize, SIGNAL(valueChanged(double)), this, SLOT(slotResize(double)));
215 connect(m_opacity, SIGNAL(valueChanged(double)), this, SLOT(slotSetOpacity(double)));
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->slotShowEffectScene(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(';', QString::SkipEmptyParts);
286 val.append(list.takeFirst().section('/', 0, 0));
287 foreach (const QString value, list) {
288 val.append(';' + value.section('/', 0, 0));
294 void GeometryWidget::setupParam(const QDomElement elem, int minframe, int maxframe)
296 m_inPoint = minframe;
297 m_outPoint = maxframe;
301 m_geometry->parse(elem.attribute("value").toUtf8().data(), maxframe - minframe, m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
303 m_geometry = new Mlt::Geometry(elem.attribute("value").toUtf8().data(), maxframe - minframe, m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
305 if (elem.attribute("fixed") == "1" || maxframe < minframe) {
306 // Keyframes are disabled
307 m_ui.widgetTimeWrapper->setHidden(true);
309 m_ui.widgetTimeWrapper->setHidden(false);
310 m_timeline->setKeyGeometry(m_geometry, m_outPoint - m_inPoint);
311 m_timeline->update();
312 m_timePos->setRange(0, m_outPoint - m_inPoint);
316 if (elem.attribute("opacity") == "false") {
317 m_opacity->setHidden(true);
318 m_ui.horizontalLayout2->addStretch(2);
321 Mlt::GeometryItem item;
323 m_geometry->fetch(&item, 0);
325 m_rect = new OnMonitorRectItem(QRectF(0, 0, item.w(), item.h()), m_monitor->render->dar());
326 m_rect->setPos(item.x(), item.y());
327 m_rect->setZValue(0);
328 m_scene->addItem(m_rect);
329 connect(m_rect, SIGNAL(changed()), this, SLOT(slotUpdateGeometry()));
330 m_scene->centerView();
331 slotPositionChanged(0, false);
332 slotCheckMonitorPosition(m_monitor->render->seekFramePosition());
335 void GeometryWidget::addParameter(const QDomElement elem)
337 Mlt::Geometry *geometry = new Mlt::Geometry(elem.attribute("value").toUtf8().data(), m_outPoint - m_inPoint, m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
338 m_extraGeometries.append(geometry);
339 m_timeline->addGeometry(geometry);
340 m_extraFactors.append(elem.attribute("factor", "1"));
341 m_extraGeometryNames.append(elem.attribute("name"));
342 //kDebug()<<"ADDED PARAM: "<<elem.attribute("value");
345 void GeometryWidget::slotSyncPosition(int relTimelinePos)
347 // do only sync if this effect is keyframable
348 if (m_timePos->maximum() > 0 && KdenliveSettings::transitionfollowcursor()) {
349 relTimelinePos = qBound(0, relTimelinePos, m_timePos->maximum());
350 if (relTimelinePos != m_timePos->getValue())
351 slotPositionChanged(relTimelinePos, false);
356 void GeometryWidget::slotPositionChanged(int pos, bool seek)
359 pos = m_timePos->getValue();
361 m_timePos->setValue(pos);
363 m_timeline->blockSignals(true);
364 m_timeline->setValue(pos);
365 m_timeline->blockSignals(false);
367 Mlt::GeometryItem item;
368 Mlt::GeometryItem previousItem;
369 if (m_geometry->fetch(&item, pos) || item.key() == false) {
371 m_rect->setEnabled(false);
372 m_scene->setEnabled(false);
373 m_ui.widgetGeometry->setEnabled(false);
374 m_ui.buttonAddDelete->setIcon(KIcon("document-new"));
375 m_ui.buttonAddDelete->setToolTip(i18n("Add keyframe"));
378 m_rect->setEnabled(true);
379 m_scene->setEnabled(true);
380 m_ui.widgetGeometry->setEnabled(true);
381 m_ui.buttonAddDelete->setIcon(KIcon("edit-delete"));
382 m_ui.buttonAddDelete->setToolTip(i18n("Delete keyframe"));
385 if (KdenliveSettings::onmonitoreffects_geometryshowprevious() == false || m_geometry->prev_key(&previousItem, pos - 1) || previousItem.frame() == item.frame()) {
387 m_scene->removeItem(m_previous);
390 else if (m_previous && m_previous->scene() && m_previous->data(Qt::UserRole).toInt() == previousItem.frame()) {
391 // previous frame already here, do nothing
394 if (m_previous == NULL) {
395 m_previous = new QGraphicsRectItem(0, 0, previousItem.w(), previousItem.h());
396 m_previous->setBrush(QColor(200, 200, 0, 20));
397 m_previous->setPen(QPen(Qt::white, 0, Qt::DotLine));
398 m_previous->setPos(previousItem.x(), previousItem.y());
399 m_previous->setZValue(-1);
400 m_previous->setEnabled(false);
403 m_previous->setPos(previousItem.x(), previousItem.y());
404 m_previous->setRect(0, 0, previousItem.w(), previousItem.h());
406 m_previous->setData(Qt::UserRole, previousItem.frame());
407 if (m_previous->scene() == 0) m_scene->addItem(m_previous);
410 m_rect->setPos(item.x(), item.y());
411 m_rect->setRect(0, 0, item.w(), item.h());
413 m_opacity->blockSignals(true);
414 m_opacity->setValue(item.mix());
415 m_opacity->blockSignals(false);
417 for (int i = 0; i < m_extraGeometries.count(); i++) {
418 Mlt::Geometry *geom = m_extraGeometries.at(i);
419 QString name = m_extraGeometryNames.at(i);
420 if (!geom->fetch(&item, pos)) {
421 DragValue *widget = findChild<DragValue *>(name);
423 widget->blockSignals(true);
424 widget->setValue(item.x() * m_extraFactors.at(i).toInt());
425 widget->blockSignals(false);
430 slotUpdateProperties();
432 if (seek && KdenliveSettings::transitionfollowcursor())
433 emit seekToPos(m_clipPos + pos);
436 void GeometryWidget::slotKeyframeMoved(int pos)
438 slotPositionChanged(pos);
439 slotUpdateGeometry();
440 QTimer::singleShot(100, this, SIGNAL(parameterChanged()));
443 void GeometryWidget::slotAddKeyframe(int pos)
445 Mlt::GeometryItem item;
447 pos = m_timePos->getValue();
449 QRectF r = m_rect->rect().normalized();
450 QPointF rectpos = m_rect->pos();
455 item.mix(m_opacity->value());
456 m_geometry->insert(item);
458 for (int i = 0; i < m_extraGeometries.count(); i++) {
459 Mlt::Geometry *geom = m_extraGeometries.at(i);
460 QString name = m_extraGeometryNames.at(i);
461 DragValue *widget = findChild<DragValue *>(name);
463 Mlt::GeometryItem item2;
465 item2.x((double) widget->value() / m_extraFactors.at(i).toInt());
470 m_timeline->update();
471 slotPositionChanged(pos, false);
472 emit parameterChanged();
475 void GeometryWidget::slotDeleteKeyframe(int pos)
477 Mlt::GeometryItem item;
479 pos = m_timePos->getValue();
480 // check there is more than one keyframe, do not allow to delete last one
481 if (m_geometry->next_key(&item, pos + 1)) {
482 if (m_geometry->prev_key(&item, pos - 1) || item.frame() == pos)
485 m_geometry->remove(pos);
487 for (int i = 0; i < m_extraGeometries.count(); i++) {
488 Mlt::Geometry *geom = m_extraGeometries.at(i);
492 m_timeline->update();
493 slotPositionChanged(pos, false);
494 emit parameterChanged();
497 void GeometryWidget::slotPreviousKeyframe()
499 Mlt::GeometryItem item;
500 // Go to start if no keyframe is found
501 int currentPos = m_timePos->getValue();
503 if (!m_geometry->prev_key(&item, currentPos - 1) && item.frame() < currentPos)
506 slotPositionChanged(pos);
509 void GeometryWidget::slotNextKeyframe()
511 Mlt::GeometryItem item;
512 // Go to end if no keyframe is found
513 int pos = m_timeline->frameLength;
514 if (!m_geometry->next_key(&item, m_timeline->value() + 1))
517 slotPositionChanged(pos);
520 void GeometryWidget::slotAddDeleteKeyframe()
522 Mlt::GeometryItem item;
523 if (m_geometry->fetch(&item, m_timePos->getValue()) || item.key() == false)
526 slotDeleteKeyframe();
530 void GeometryWidget::slotCheckMonitorPosition(int renderPos)
534 We do only get the position in timeline if this geometry belongs to a transition,
535 therefore we need two ways here.
538 emit checkMonitorPosition(renderPos);
540 if (renderPos >= m_clipPos && renderPos <= m_clipPos + m_outPoint - m_inPoint) {
541 if (!m_scene->views().at(0)->isVisible())
542 m_monitor->slotShowEffectScene(true);
544 m_monitor->slotShowEffectScene(false);
551 void GeometryWidget::slotUpdateGeometry()
553 Mlt::GeometryItem item;
554 int pos = m_timePos->getValue();
556 // get keyframe and make sure it is the correct one
557 if (m_geometry->next_key(&item, pos) || item.frame() != pos)
560 QRectF rectSize = m_rect->rect().normalized();
561 QPointF rectPos = m_rect->pos();
564 item.w(rectSize.width());
565 item.h(rectSize.height());
566 m_geometry->insert(item);
568 for (int i = 0; i < m_extraGeometries.count(); i++) {
569 Mlt::Geometry *geom = m_extraGeometries.at(i);
570 QString name = m_extraGeometryNames.at(i);
571 Mlt::GeometryItem item2;
572 DragValue *widget = findChild<DragValue *>(name);
573 if (widget && !geom->next_key(&item2, pos) && item2.frame() == pos) {
574 item2.x((double) widget->value() / m_extraFactors.at(i).toInt());
578 emit parameterChanged();
581 void GeometryWidget::slotUpdateProperties()
583 QRectF rectSize = m_rect->rect().normalized();
584 QPointF rectPos = m_rect->pos();
586 if (rectSize.width() / m_monitor->render->dar() > rectSize.height())
587 size = rectSize.width() * 100.0 / m_monitor->render->frameRenderWidth();
589 size = rectSize.height() * 100.0 / m_monitor->render->renderHeight();
591 m_spinX->blockSignals(true);
592 m_spinY->blockSignals(true);
593 m_spinWidth->blockSignals(true);
594 m_spinHeight->blockSignals(true);
595 m_spinSize->blockSignals(true);
597 m_spinX->setValue(rectPos.x());
598 m_spinY->setValue(rectPos.y());
599 m_spinWidth->setValue(rectSize.width());
600 m_spinHeight->setValue(rectSize.height());
601 m_spinSize->setValue(size);
603 m_spinX->blockSignals(false);
604 m_spinY->blockSignals(false);
605 m_spinWidth->blockSignals(false);
606 m_spinHeight->blockSignals(false);
607 m_spinSize->blockSignals(false);
611 void GeometryWidget::slotSetX(double value)
613 m_rect->setPos(value, m_spinY->value());
614 slotUpdateGeometry();
617 void GeometryWidget::slotSetY(double value)
619 m_rect->setPos(m_spinX->value(), value);
620 slotUpdateGeometry();
623 void GeometryWidget::slotSetWidth(double value)
625 m_rect->setRect(0, 0, value, m_spinHeight->value());
626 slotUpdateGeometry();
629 void GeometryWidget::slotSetHeight(double value)
631 m_rect->setRect(0, 0, m_spinWidth->value(), value);
632 slotUpdateGeometry();
635 void GeometryWidget::updateMonitorGeometry()
637 m_rect->setRect(0, 0, m_spinWidth->value(), m_spinHeight->value());
638 slotUpdateGeometry();
642 void GeometryWidget::slotResize(double value)
644 m_rect->setRect(0, 0,
645 (int)((m_monitor->render->frameRenderWidth() * value / 100.0) + 0.5),
646 (int)((m_monitor->render->renderHeight() * value / 100.0) + 0.5));
647 slotUpdateGeometry();
651 void GeometryWidget::slotSetOpacity(double value)
653 int pos = m_timePos->getValue();
654 Mlt::GeometryItem item;
655 if (m_geometry->fetch(&item, pos) || item.key() == false)
658 m_geometry->insert(item);
659 emit parameterChanged();
663 void GeometryWidget::slotMoveLeft()
665 m_rect->setPos(0, m_rect->pos().y());
666 slotUpdateGeometry();
669 void GeometryWidget::slotCenterH()
671 m_rect->setPos((m_monitor->render->frameRenderWidth() - m_rect->rect().width()) / 2, m_rect->pos().y());
672 slotUpdateGeometry();
675 void GeometryWidget::slotMoveRight()
677 m_rect->setPos(m_monitor->render->frameRenderWidth() - m_rect->rect().width(), m_rect->pos().y());
678 slotUpdateGeometry();
681 void GeometryWidget::slotMoveTop()
683 m_rect->setPos(m_rect->pos().x(), 0);
684 slotUpdateGeometry();
687 void GeometryWidget::slotCenterV()
689 m_rect->setPos(m_rect->pos().x(), (m_monitor->render->renderHeight() - m_rect->rect().height()) / 2);
690 slotUpdateGeometry();
693 void GeometryWidget::slotMoveBottom()
695 m_rect->setPos(m_rect->pos().x(), m_monitor->render->renderHeight() - m_rect->rect().height());
696 slotUpdateGeometry();
700 void GeometryWidget::slotSetSynchronize(bool sync)
702 KdenliveSettings::setTransitionfollowcursor(sync);
704 emit seekToPos(m_clipPos + m_timePos->getValue());
707 void GeometryWidget::slotShowScene(bool show)
711 m_monitor->slotShowEffectScene(false);
713 slotCheckMonitorPosition(m_monitor->render->seekFramePosition());
716 void GeometryWidget::setFrameSize(QPoint size)
721 void GeometryWidget::slotAdjustToFrameSize()
723 if (m_frameSize == QPoint() || m_frameSize.x() == 0 || m_frameSize.y() == 0) {
724 m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
726 m_spinWidth->blockSignals(true);
727 m_spinHeight->blockSignals(true);
728 m_spinWidth->setValue((int) (m_frameSize.x() / m_monitor->render->sar() + 0.5));
729 m_spinHeight->setValue(m_frameSize.y());
730 m_spinWidth->blockSignals(false);
731 m_spinHeight->blockSignals(false);
732 updateMonitorGeometry();
735 void GeometryWidget::slotFitToWidth()
737 if (m_frameSize == QPoint() || m_frameSize.x() == 0 || m_frameSize.y() == 0) {
738 m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
740 double factor = (double) m_monitor->render->frameRenderWidth() / m_frameSize.x() * m_monitor->render->sar();
741 m_spinWidth->blockSignals(true);
742 m_spinHeight->blockSignals(true);
743 m_spinHeight->setValue((int) (m_frameSize.y() * factor + 0.5));
744 m_spinWidth->setValue(m_monitor->render->frameRenderWidth());
745 m_spinWidth->blockSignals(false);
746 m_spinHeight->blockSignals(false);
747 updateMonitorGeometry();
750 void GeometryWidget::slotFitToHeight()
752 if (m_frameSize == QPoint() || m_frameSize.x() == 0 || m_frameSize.y() == 0) {
753 m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
755 double factor = (double) m_monitor->render->renderHeight() / m_frameSize.y();
756 m_spinWidth->blockSignals(true);
757 m_spinHeight->blockSignals(true);
758 m_spinHeight->setValue(m_monitor->render->renderHeight());
759 m_spinWidth->setValue((int) (m_frameSize.x() / m_monitor->render->sar() * factor + 0.5));
760 m_spinWidth->blockSignals(false);
761 m_spinHeight->blockSignals(false);
762 updateMonitorGeometry();
765 #include "geometrywidget.moc"