From 5ea297a1c4f65991ec0f53631f16dfc9efed6a4b Mon Sep 17 00:00:00 2001 From: Till Theato Date: Wed, 4 Aug 2010 21:39:50 +0000 Subject: [PATCH] Introduce very basic geometry editing on the monitor. Has to be enabled in the settings dialog first, but you probably do not want to do this now as it cannot compete with our little red rectangle yet. svn path=/trunk/kdenlive/; revision=4683 --- src/CMakeLists.txt | 3 + src/effectstackedit.cpp | 46 ++++++--- src/effectstackedit.h | 4 +- src/effectstackview.cpp | 4 +- src/effectstackview.h | 3 +- src/geometrywidget.cpp | 163 +++++++++++++++++++++++++++++++ src/geometrywidget.h | 68 +++++++++++++ src/kdenlivesettings.kcfg | 5 + src/mainwindow.cpp | 24 ++--- src/monitor.cpp | 37 ++++++- src/monitor.h | 11 ++- src/monitorscene.cpp | 88 +++++++++++++++++ src/monitorscene.h | 53 ++++++++++ src/transitionsettings.cpp | 4 +- src/transitionsettings.h | 3 +- src/widgets/configmisc_ui.ui | 11 ++- src/widgets/geometrywidget_ui.ui | 89 +++++++++++++++++ 17 files changed, 576 insertions(+), 40 deletions(-) create mode 100644 src/geometrywidget.cpp create mode 100644 src/geometrywidget.h create mode 100644 src/monitorscene.cpp create mode 100644 src/monitorscene.h create mode 100644 src/widgets/geometrywidget_ui.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4e844f06..8b41476d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -98,6 +98,7 @@ kde4_add_ui_files(kdenlive_UI widgets/waveform_ui.ui widgets/rgbparade_ui.ui widgets/histogram_ui.ui + widgets/geometrywidget_ui.ui ) set(kdenlive_SRCS @@ -214,6 +215,8 @@ set(kdenlive_SRCS razorgroupcommand.cpp colorpickerwidget.cpp choosecolorwidget.cpp + monitorscene.cpp + geometrywidget.cpp ) diff --git a/src/effectstackedit.cpp b/src/effectstackedit.cpp index 3e484e01..de1aaa6f 100644 --- a/src/effectstackedit.cpp +++ b/src/effectstackedit.cpp @@ -31,6 +31,7 @@ #include "kis_curve_widget.h" #include "kis_cubic_curve.h" #include "choosecolorwidget.h" +#include "geometrywidget.h" #include #include @@ -66,12 +67,13 @@ class Urlval: public QWidget, public Ui::Urlval_UI QMap EffectStackEdit::iconCache; -EffectStackEdit::EffectStackEdit(QWidget *parent) : +EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) : QScrollArea(parent), m_in(0), m_out(0), m_frameSize(QPoint()), - m_keyframeEditor(NULL) + m_keyframeEditor(NULL), + m_monitor(monitor) { m_baseWidget = new QWidget(this); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -122,7 +124,7 @@ void EffectStackEdit::updateTimecodeFormat() QString type = pa.attributes().namedItem("type").nodeValue(); QString paramName = i18n(na.toElement().text().toUtf8().data()); - if (type == "geometry") { + if (type == "geometry" && !KdenliveSettings::on_monitor_effects()) { Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]); geom->updateTimecodeFormat(); break; @@ -257,15 +259,26 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in m_valueItems[paramName+"complex"] = pl; connect(pl, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters())); } else if (type == "geometry") { - Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos); - if (minFrame == maxFrame) - geo->setupParam(pa, m_in, m_out); - else - geo->setupParam(pa, minFrame, maxFrame); - m_vbox->addWidget(geo); - m_valueItems[paramName+"geometry"] = geo; - connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters())); - connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int))); + if (KdenliveSettings::on_monitor_effects()) { + GeometryWidget *geometry = new GeometryWidget(m_monitor, pos, this); + if (minFrame == maxFrame) + geometry->setupParam(pa, m_in, m_out); + else + geometry->setupParam(pa, minFrame, maxFrame); + m_vbox->addWidget(geometry); + m_valueItems[paramName+"geometry"] = geometry; + connect(geometry, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters())); + } else { + Geometryval *geo = new Geometryval(m_profile, m_timecode, m_frameSize, pos); + if (minFrame == maxFrame) + geo->setupParam(pa, m_in, m_out); + else + geo->setupParam(pa, minFrame, maxFrame); + m_vbox->addWidget(geo); + m_valueItems[paramName+"geometry"] = geo; + connect(geo, SIGNAL(parameterChanged()), this, SLOT(collectAllParameters())); + connect(geo, SIGNAL(seekToPos(int)), this, SIGNAL(seekTimeline(int))); + } } else if (type == "keyframe" || type == "simplekeyframe") { // keyframe editor widget kDebug() << "min: " << m_in << ", MAX: " << m_out; @@ -532,8 +545,13 @@ void EffectStackEdit::collectAllParameters() ComplexParameter *complex = ((ComplexParameter*)m_valueItems.value(paramName)); namenode.item(i) = complex->getParamDesc(); } else if (type == "geometry") { - Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName)); - namenode.item(i).toElement().setAttribute("value", geom->getValue()); + if (KdenliveSettings::on_monitor_effects()) { + GeometryWidget *geometry = ((GeometryWidget*)m_valueItems.value(paramName)); + namenode.item(i).toElement().setAttribute("value", geometry->getValue()); + } else { + Geometryval *geom = ((Geometryval*)m_valueItems.value(paramName)); + namenode.item(i).toElement().setAttribute("value", geom->getValue()); + } } else if (type == "position") { PositionEdit *pedit = ((PositionEdit*)m_valueItems.value(paramName)); int pos = pedit->getPosition(); diff --git a/src/effectstackedit.h b/src/effectstackedit.h index 6cba4d9b..1ecf6263 100644 --- a/src/effectstackedit.h +++ b/src/effectstackedit.h @@ -39,12 +39,13 @@ struct wipeInfo { }; class QFrame; +class Monitor; class EffectStackEdit : public QScrollArea { Q_OBJECT public: - EffectStackEdit(QWidget *parent); + EffectStackEdit(Monitor *monitor, QWidget *parent = 0); ~EffectStackEdit(); void updateProjectFormat(MltVideoProfile profile, Timecode t); static QMap iconCache; @@ -68,6 +69,7 @@ private: int m_out; QPoint m_frameSize; KeyframeEdit *m_keyframeEditor; + Monitor *m_monitor; public slots: /** \brief Called when an effect is selected, builds the UI for this effect */ diff --git a/src/effectstackview.cpp b/src/effectstackview.cpp index 6e76a5c0..b5d80d0e 100644 --- a/src/effectstackview.cpp +++ b/src/effectstackview.cpp @@ -37,12 +37,12 @@ #include -EffectStackView::EffectStackView(QWidget *parent) : +EffectStackView::EffectStackView(Monitor *monitor, QWidget *parent) : QWidget(parent) { m_ui.setupUi(this); QVBoxLayout *vbox1 = new QVBoxLayout(m_ui.frame); - m_effectedit = new EffectStackEdit(m_ui.frame); + m_effectedit = new EffectStackEdit(monitor, m_ui.frame); vbox1->setContentsMargins(0, 0, 0, 0); vbox1->setSpacing(0); vbox1->addWidget(m_effectedit); diff --git a/src/effectstackview.h b/src/effectstackview.h index 68311d93..fffed50f 100644 --- a/src/effectstackview.h +++ b/src/effectstackview.h @@ -30,13 +30,14 @@ class EffectsList; class ClipItem; class MltVideoProfile; +class Monitor; class EffectStackView : public QWidget { Q_OBJECT public: - EffectStackView(QWidget *parent = 0); + EffectStackView(Monitor *monitor, QWidget *parent = 0); virtual ~EffectStackView(); /** @brief Raises @param dock if a clip is loaded. */ diff --git a/src/geometrywidget.cpp b/src/geometrywidget.cpp new file mode 100644 index 00000000..fee08f3a --- /dev/null +++ b/src/geometrywidget.cpp @@ -0,0 +1,163 @@ +/*************************************************************************** + * Copyright (C) 2010 by Till Theato (root@ttill.de) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#include "geometrywidget.h" +#include "monitor.h" +#include "renderer.h" +#include "monitorscene.h" + +#include + +GeometryWidget::GeometryWidget(Monitor* monitor, int clipPos, QWidget* parent ): + QWidget(parent), + m_monitor(monitor), + m_rect(NULL), + m_geometry(NULL), + m_clipPos(clipPos), + m_inPoint(0), + m_outPoint(1) +{ + m_ui.setupUi(this); + m_scene = monitor->getEffectScene(); + connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateGeometry())); + connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateProperties())); + + connect(m_monitor->render, SIGNAL(rendererPosition(int)), this, SLOT(slotCheckPosition(int))); + + connect(m_ui.spinX, SIGNAL(valueChanged(int)), this, SLOT(slotSetX(int))); + connect(m_ui.spinY, SIGNAL(valueChanged(int)), this, SLOT(slotSetY(int))); + connect(m_ui.spinWidth, SIGNAL(valueChanged(int)), this, SLOT(slotSetWidth(int))); + connect(m_ui.spinHeight, SIGNAL(valueChanged(int)), this, SLOT(slotSetHeight(int))); +} + +GeometryWidget::~GeometryWidget() +{ + m_monitor->slotEffectScene(false); + m_scene->disconnect(this); + delete m_rect; + delete m_geometry; +} + +QString GeometryWidget::getValue() const +{ + return m_geometry->serialise(); +} + +void GeometryWidget::setupParam(const QDomElement elem, int minframe, int maxframe) +{ + m_inPoint = minframe; + m_outPoint = maxframe; + QString value = elem.attribute("value"); + + char *tmp = (char *) qstrdup(value.toUtf8().data()); + if (m_geometry) + m_geometry->parse(tmp, maxframe - minframe, m_monitor->render->renderWidth(), m_monitor->render->renderHeight()); + else + m_geometry = new Mlt::Geometry(tmp, maxframe - minframe, m_monitor->render->renderWidth(), m_monitor->render->renderHeight()); + delete[] tmp; + + Mlt::GeometryItem item; + + m_geometry->fetch(&item, 0); + delete m_rect; + m_rect = new QGraphicsRectItem(QRectF(0, 0, item.w(), item.h())); + m_rect->setPos(item.x(), item.y()); + m_rect->setZValue(0); + m_rect->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); + + QPen framepen(Qt::DotLine); + framepen.setColor(Qt::yellow); + m_rect->setPen(framepen); + m_rect->setBrush(Qt::transparent); + m_scene->addItem(m_rect); + + slotUpdateProperties(); + slotCheckPosition(m_monitor->render->seekFramePosition()); +} + +void GeometryWidget::slotCheckPosition(int renderPos) +{ + if (renderPos >= m_clipPos && renderPos <= m_clipPos + m_outPoint - m_inPoint) + m_monitor->slotEffectScene(true); + else + m_monitor->slotEffectScene(false); +} + +void GeometryWidget::slotUpdateGeometry() +{ + Mlt::GeometryItem item; + m_geometry->next_key(&item, 0); + + QRectF rectSize = m_rect->rect().normalized(); + QPointF rectPos = m_rect->pos(); + item.x(rectPos.x()); + item.y(rectPos.y()); + item.w(rectSize.width()); + item.h(rectSize.height()); + m_geometry->insert(item); + emit parameterChanged(); +} + +void GeometryWidget::slotUpdateProperties() +{ + QRectF rectSize = m_rect->rect().normalized(); + QPointF rectPos = m_rect->pos(); + + m_ui.spinX->blockSignals(true); + m_ui.spinY->blockSignals(true); + m_ui.spinWidth->blockSignals(true); + m_ui.spinHeight->blockSignals(true); + + m_ui.spinX->setValue(rectPos.x()); + m_ui.spinY->setValue(rectPos.y()); + m_ui.spinWidth->setValue(rectSize.width()); + m_ui.spinHeight->setValue(rectSize.height()); + + m_ui.spinX->blockSignals(false); + m_ui.spinY->blockSignals(false); + m_ui.spinWidth->blockSignals(false); + m_ui.spinHeight->blockSignals(false); +} + +void GeometryWidget::slotSetX(int value) +{ + m_rect->setPos(value, m_ui.spinY->value()); + slotUpdateGeometry(); +} + +void GeometryWidget::slotSetY(int value) +{ + m_rect->setPos(m_ui.spinX->value(), value); + slotUpdateGeometry(); +} + +void GeometryWidget::slotSetWidth(int value) +{ + m_rect->setRect(0, 0, value, m_ui.spinHeight->value()); + slotUpdateGeometry(); +} + +void GeometryWidget::slotSetHeight(int value) +{ + m_rect->setRect(0, 0, m_ui.spinWidth->value(), value); + slotUpdateGeometry(); +} + +#include "geometrywidget.moc" diff --git a/src/geometrywidget.h b/src/geometrywidget.h new file mode 100644 index 00000000..f53278ad --- /dev/null +++ b/src/geometrywidget.h @@ -0,0 +1,68 @@ +/*************************************************************************** + * Copyright (C) 2010 by Till Theato (root@ttill.de) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#ifndef GEOMETRYWIDGET_H +#define GEOMETRYWIDGET_H + +#include "ui_geometrywidget_ui.h" +#include + +#include + +class QDomElement; +class QGraphicsRectItem; +class Monitor; +class MonitorScene; + +class GeometryWidget : public QWidget +{ + Q_OBJECT +public: + GeometryWidget(Monitor *monitor, int clipPos = 0, QWidget* parent = 0); + virtual ~GeometryWidget(); + QString getValue() const; + +public slots: + void setupParam(const QDomElement elem, int minframe, int maxframe); + +private: + Ui::GeometryWidget_UI m_ui; + int m_clipPos; + int m_inPoint; + int m_outPoint; + Monitor *m_monitor; + MonitorScene *m_scene; + QGraphicsRectItem *m_rect; + Mlt::Geometry *m_geometry; + +private slots: + void slotCheckPosition(int renderPos); + void slotUpdateGeometry(); + void slotUpdateProperties(); + void slotSetX(int value); + void slotSetY(int value); + void slotSetWidth(int value); + void slotSetHeight(int value); + +signals: + void parameterChanged(); +}; + +#endif diff --git a/src/kdenlivesettings.kcfg b/src/kdenlivesettings.kcfg index 1e812dcd..ace2e0c2 100644 --- a/src/kdenlivesettings.kcfg +++ b/src/kdenlivesettings.kcfg @@ -39,6 +39,11 @@ 00:00:05:00 + + + + false + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 78b22aff..ce8ea7ee 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -176,18 +176,6 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent m_projectListDock->setWidget(m_projectList); addDockWidget(Qt::TopDockWidgetArea, m_projectListDock); - m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this); - m_effectStackDock->setObjectName("effect_stack"); - m_effectStack = new EffectStackView(this); - m_effectStackDock->setWidget(m_effectStack); - addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock); - - m_transitionConfigDock = new QDockWidget(i18n("Transition"), this); - m_transitionConfigDock->setObjectName("transition"); - m_transitionConfig = new TransitionSettings(this); - m_transitionConfigDock->setWidget(m_transitionConfig); - addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock); - m_clipMonitorDock = new QDockWidget(i18n("Clip Monitor"), this); m_clipMonitorDock->setObjectName("clip_monitor"); m_clipMonitor = new Monitor("clip", m_monitorManager, QString(), this); @@ -210,6 +198,18 @@ MainWindow::MainWindow(const QString &MltPath, const KUrl & Url, QWidget *parent connect(m_recMonitor, SIGNAL(showConfigDialog(int, int)), this, SLOT(slotPreferences(int, int))); #endif + m_effectStackDock = new QDockWidget(i18n("Effect Stack"), this); + m_effectStackDock->setObjectName("effect_stack"); + m_effectStack = new EffectStackView(m_projectMonitor, this); + m_effectStackDock->setWidget(m_effectStack); + addDockWidget(Qt::TopDockWidgetArea, m_effectStackDock); + + m_transitionConfigDock = new QDockWidget(i18n("Transition"), this); + m_transitionConfigDock->setObjectName("transition"); + m_transitionConfig = new TransitionSettings(m_projectMonitor, this); + m_transitionConfigDock->setWidget(m_transitionConfig); + addDockWidget(Qt::TopDockWidgetArea, m_transitionConfigDock); + m_effectListDock = new QDockWidget(i18n("Effect List"), this); m_effectListDock->setObjectName("effect_list"); m_effectList = new EffectsListView(); diff --git a/src/monitor.cpp b/src/monitor.cpp index df5d98ba..3b62bc68 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -23,6 +23,7 @@ #include "monitormanager.h" #include "smallruler.h" #include "docclipbase.h" +#include "monitorscene.h" #include "kdenlivesettings.h" #include @@ -39,6 +40,9 @@ #include #include #include +#include +#include +#include Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget *parent) : @@ -161,6 +165,15 @@ Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget #ifndef Q_WS_MAC m_monitorRefresh->show(); #endif + + if (name == "project") { + m_effectScene = new MonitorScene(render); + m_effectView = new QGraphicsView(m_effectScene, m_ui.video_frame); + rendererBox->addWidget(m_effectView); + m_effectScene->setUp(); + m_effectView->hide(); + } + kDebug() << "/////// BUILDING MONITOR, ID: " << m_ui.video_frame->winId(); } @@ -170,6 +183,8 @@ Monitor::~Monitor() delete m_timePos; delete m_overlay; delete m_monitorRefresh; + delete m_effectView; + delete m_effectScene; delete render; } @@ -367,7 +382,7 @@ void Monitor::slotSetZoneEnd() void Monitor::mousePressEvent(QMouseEvent * event) { if (event->button() != Qt::RightButton) { - if (m_ui.video_frame->underMouse()) { + if (m_ui.video_frame->underMouse() && !m_effectView->isVisible()) { m_dragStarted = true; m_DragStartPosition = event->pos(); } @@ -378,7 +393,7 @@ void Monitor::mousePressEvent(QMouseEvent * event) void Monitor::mouseReleaseEvent(QMouseEvent * event) { if (m_dragStarted) { - if (m_ui.video_frame->underMouse()) { + if (m_ui.video_frame->underMouse() && !m_effectView->isVisible()) { if (isActive()) slotPlay(); else activateMonitor(); } else QWidget::mouseReleaseEvent(event); @@ -818,6 +833,21 @@ QStringList Monitor::getZoneInfo() const return result; } +void Monitor::slotEffectScene(bool show) +{ + if (m_name == "project") { + m_monitorRefresh->setVisible(!show); + m_effectView->setVisible(show); + if (show) + m_effectScene->slotUpdateBackground(); + } +} + +MonitorScene * Monitor::getEffectScene() +{ + return m_effectScene; +} + MonitorRefresh::MonitorRefresh(QWidget* parent) : \ QWidget(parent), m_renderer(NULL) @@ -832,8 +862,9 @@ void MonitorRefresh::setRenderer(Render* render) m_renderer = render; } -void MonitorRefresh::paintEvent(QPaintEvent * /*event*/) +void MonitorRefresh::paintEvent(QPaintEvent *event) { + Q_UNUSED(event); if (m_renderer) m_renderer->doRefresh(); } diff --git a/src/monitor.h b/src/monitor.h index 6b0be9d3..afdc611b 100644 --- a/src/monitor.h +++ b/src/monitor.h @@ -39,13 +39,16 @@ class MonitorManager; class Render; class SmallRuler; class DocClipBase; +class MonitorScene; +class QGraphicsView; +class QGraphicsPixmapItem; class MonitorRefresh : public QWidget { Q_OBJECT public: - MonitorRefresh(QWidget* parent); - virtual void paintEvent(QPaintEvent * event); + MonitorRefresh(QWidget *parent = 0); + virtual void paintEvent(QPaintEvent *event); void setRenderer(Render* render); private: @@ -83,6 +86,7 @@ public: void checkOverlay(); void updateTimecodeFormat(); void updateMarkers(DocClipBase *source); + MonitorScene *getEffectScene(); protected: virtual void mousePressEvent(QMouseEvent * event); @@ -123,6 +127,8 @@ private: QMenu *m_playMenu; QMenu *m_markerMenu; QPoint m_DragStartPosition; + MonitorScene *m_effectScene; + QGraphicsView *m_effectView; #ifdef Q_WS_MAC VideoGLWidget *m_glWidget; #endif @@ -171,6 +177,7 @@ public slots: void adjustRulerSize(int length); void setTimePos(const QString &pos); QStringList getZoneInfo() const; + void slotEffectScene(bool show = true); signals: void renderPosition(int); diff --git a/src/monitorscene.cpp b/src/monitorscene.cpp new file mode 100644 index 00000000..e52e7e9c --- /dev/null +++ b/src/monitorscene.cpp @@ -0,0 +1,88 @@ +/*************************************************************************** + * Copyright (C) 2010 by Till Theato (root@ttill.de) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#include "monitorscene.h" +#include "renderer.h" + +#include +#include +#include + +MonitorScene::MonitorScene(Render *renderer, QObject* parent) : + QGraphicsScene(parent), + m_renderer(renderer) +{ +} + +void MonitorScene::setUp() +{ + setBackgroundBrush(QBrush(QColor(0, 0, 255))); + + QPen framepen(Qt::DotLine); + framepen.setColor(Qt::red); + + m_frameBorder = new QGraphicsRectItem(QRectF(0, 0, m_renderer->renderWidth(), m_renderer->renderHeight())); + m_frameBorder->setPen(framepen); + m_frameBorder->setZValue(-9); + m_frameBorder->setBrush(Qt::transparent); + m_frameBorder->setFlags(0); + addItem(m_frameBorder); + + m_lastUpdate.start(); + m_background = new QGraphicsPixmapItem(); + m_background->setZValue(-10); + m_background->setFlags(0); + QPixmap bg(m_renderer->renderWidth(), m_renderer->renderHeight()); + bg.fill(); + m_background->setPixmap(bg); + addItem(m_background); + + connect(m_renderer, SIGNAL(rendererPosition(int)), this, SLOT(slotUpdateBackground())); + connect(m_renderer, SIGNAL(frameUpdated(int)), this, SLOT(slotUpdateBackground())); + slotUpdateBackground(); + views().at(0)->fitInView(m_frameBorder, Qt::KeepAspectRatio); + views().at(0)->centerOn(m_frameBorder); +} + +void MonitorScene::slotUpdateBackground() +{ + if (views().count() > 0 && views().at(0)->isVisible()) { + if (m_lastUpdate.elapsed() > 200) { + m_background->setPixmap(QPixmap::fromImage(m_renderer->extractFrame(m_renderer->seekFramePosition()))); + views().at(0)->fitInView(m_frameBorder, Qt::KeepAspectRatio); + views().at(0)->centerOn(m_frameBorder); + m_lastUpdate.start(); + } + } +} + +void MonitorScene::mousePressEvent(QGraphicsSceneMouseEvent* event) +{ + QGraphicsScene::mousePressEvent(event); +} + + +void MonitorScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) +{ + QGraphicsScene::mouseReleaseEvent(event); + emit actionFinished(); +} + +#include "monitorscene.moc" diff --git a/src/monitorscene.h b/src/monitorscene.h new file mode 100644 index 00000000..de9dbb0e --- /dev/null +++ b/src/monitorscene.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (C) 2010 by Till Theato (root@ttill.de) * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + + +#ifndef MONITORSCENE_H +#define MONITORSCENE_H + +#include +#include + +class QGraphicsPixmapItem; +class Render; + +class MonitorScene : public QGraphicsScene +{ + Q_OBJECT +public: + MonitorScene(Render *renderer, QObject* parent = 0); + void setUp(); + +protected: + virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); + +public slots: + void slotUpdateBackground(); + +private: + Render *m_renderer; + QGraphicsPixmapItem *m_background; + QGraphicsRectItem *m_frameBorder; + QTime m_lastUpdate; +signals: + void actionFinished(); +}; + +#endif diff --git a/src/transitionsettings.cpp b/src/transitionsettings.cpp index 55df1553..9f9437b4 100644 --- a/src/transitionsettings.cpp +++ b/src/transitionsettings.cpp @@ -26,14 +26,14 @@ #include -TransitionSettings::TransitionSettings(QWidget* parent) : +TransitionSettings::TransitionSettings(Monitor *monitor, QWidget* parent) : QWidget(parent), m_usedTransition(NULL), m_autoTrackTransition(0) { setupUi(this); QVBoxLayout *vbox1 = new QVBoxLayout(frame); - m_effectEdit = new EffectStackEdit(frame); + m_effectEdit = new EffectStackEdit(monitor, frame); vbox1->setContentsMargins(0, 0, 0, 0); vbox1->setSpacing(0); vbox1->addWidget(m_effectEdit); diff --git a/src/transitionsettings.h b/src/transitionsettings.h index 62b8445a..0a31e2a0 100644 --- a/src/transitionsettings.h +++ b/src/transitionsettings.h @@ -26,13 +26,14 @@ class Timecode; class Transition; class EffectsList; class EffectStackEdit; +class Monitor; class TransitionSettings : public QWidget, public Ui::TransitionSettings_UI { Q_OBJECT public: - TransitionSettings(QWidget* parent = 0); + TransitionSettings(Monitor *monitor, QWidget* parent = 0); void raiseWindow(QWidget*); void updateProjectFormat(MltVideoProfile profile, Timecode t, const QList info); void updateTimecodeFormat(); diff --git a/src/widgets/configmisc_ui.ui b/src/widgets/configmisc_ui.ui index 5d43df74..01f984c8 100644 --- a/src/widgets/configmisc_ui.ui +++ b/src/widgets/configmisc_ui.ui @@ -32,7 +32,7 @@ - + Default Durations @@ -83,7 +83,7 @@ - + Qt::Vertical @@ -103,6 +103,13 @@ + + + + Use on-monitor effects (Warning: experimental) + + + diff --git a/src/widgets/geometrywidget_ui.ui b/src/widgets/geometrywidget_ui.ui new file mode 100644 index 00000000..55daaafb --- /dev/null +++ b/src/widgets/geometrywidget_ui.ui @@ -0,0 +1,89 @@ + + + GeometryWidget_UI + + + + 0 + 0 + 256 + 120 + + + + Form + + + + + + X + + + + + + + -10000 + + + 10000 + + + + + + + Y + + + + + + + Width + + + + + + + Height + + + + + + + -10000 + + + 10000 + + + + + + + 1 + + + 10000 + + + + + + + 1 + + + 10000 + + + + + + + + -- 2.39.2