summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <jb@kdenlive.org>2016-12-02 13:31:22 (GMT)
committerJean-Baptiste Mardelle <jb@kdenlive.org>2016-12-02 13:32:36 (GMT)
commitbaabfafe6fa546ce968a4eb523d1e1f3b2db2f81 (patch)
tree80a886a952c881738f098ab5a78535ecb3d23c2e
parent3254a73e8951f8a05ea42d5dca4956f2313b6210 (diff)
Fix monitor scene not adapting to zoom (rotoscoping, composite, ...)
Fix crash in rotoscoping BUG: 373113
-rw-r--r--data/kdenlivemonitorcornerscene.qml8
-rw-r--r--data/kdenlivemonitoreffectscene.qml8
-rw-r--r--data/kdenlivemonitorrotoscene.qml8
-rw-r--r--src/monitor/glwidget.cpp16
-rw-r--r--src/monitor/glwidget.h4
-rw-r--r--src/monitor/monitor.cpp16
-rw-r--r--src/monitor/monitor.h2
-rw-r--r--src/onmonitoritems/rotoscoping/rotowidget.cpp34
8 files changed, 64 insertions, 32 deletions
diff --git a/data/kdenlivemonitorcornerscene.qml b/data/kdenlivemonitorcornerscene.qml
index 94d2976..9a05939 100644
--- a/data/kdenlivemonitorcornerscene.qml
+++ b/data/kdenlivemonitorcornerscene.qml
@@ -17,6 +17,10 @@ Item {
property double sourcedar : 1
onScalexChanged: canvas.requestPaint()
onScaleyChanged: canvas.requestPaint()
+ property double offsetx : 0
+ property double offsety : 0
+ onOffsetxChanged: canvas.requestPaint()
+ onOffsetyChanged: canvas.requestPaint()
onSourcedarChanged: refreshdar()
property bool iskeyframe
property int requestedKeyFrame
@@ -131,8 +135,8 @@ Item {
property color hoverColor: "#ff0000"
width: root.profile.x * root.scalex
height: root.profile.y * root.scaley
- x: root.center.x - width / 2
- y: root.center.y - height / 2
+ x: root.center.x - width / 2 - root.offsetx
+ y: root.center.y - height / 2 - root.offsety
color: "transparent"
border.color: "#ffffff00"
}
diff --git a/data/kdenlivemonitoreffectscene.qml b/data/kdenlivemonitoreffectscene.qml
index f7a833f..bf6ae81 100644
--- a/data/kdenlivemonitoreffectscene.qml
+++ b/data/kdenlivemonitoreffectscene.qml
@@ -13,8 +13,12 @@ Item {
property point center
property double scalex
property double scaley
+ property double offsetx : 0
+ property double offsety : 0
onScalexChanged: canvas.requestPaint()
onScaleyChanged: canvas.requestPaint()
+ onOffsetxChanged: canvas.requestPaint()
+ onOffsetyChanged: canvas.requestPaint()
property bool iskeyframe
property int requestedKeyFrame
property var centerPoints: []
@@ -133,8 +137,8 @@ Item {
property color hoverColor: "#ff0000"
width: root.profile.x * root.scalex
height: root.profile.y * root.scaley
- x: root.center.x - width / 2
- y: root.center.y - height / 2
+ x: root.center.x - width / 2 - root.offsetx;
+ y: root.center.y - height / 2 - root.offsety;
color: "transparent"
border.color: "#ffffff00"
}
diff --git a/data/kdenlivemonitorrotoscene.qml b/data/kdenlivemonitorrotoscene.qml
index b707775..ff9648d 100644
--- a/data/kdenlivemonitorrotoscene.qml
+++ b/data/kdenlivemonitorrotoscene.qml
@@ -16,6 +16,10 @@ Item {
property double scaley : 1
property double stretch : 1
property double sourcedar : 1
+ property double offsetx : 0
+ property double offsety : 0
+ onOffsetxChanged: canvas.requestPaint()
+ onOffsetyChanged: canvas.requestPaint()
onScalexChanged: canvas.requestPaint()
onScaleyChanged: canvas.requestPaint()
onSourcedarChanged: refreshdar()
@@ -155,8 +159,8 @@ Item {
property color hoverColor: "#ff0000"
width: root.profile.x * root.scalex
height: root.profile.y * root.scaley
- x: root.center.x - width / 2
- y: root.center.y - height / 2
+ x: root.center.x - width / 2 - root.offsetx
+ y: root.center.y - height / 2 - root.offsety
color: "transparent"
border.color: "#ffffff00"
}
diff --git a/src/monitor/glwidget.cpp b/src/monitor/glwidget.cpp
index 6c4427a..9b8f1e7 100644
--- a/src/monitor/glwidget.cpp
+++ b/src/monitor/glwidget.cpp
@@ -1142,22 +1142,22 @@ void GLWidget::mouseDoubleClickEvent(QMouseEvent * event)
event->accept();
}
-void GLWidget::setOffsetX(int x)
+void GLWidget::setOffsetX(int x, int max)
{
m_offset.setX(x);
emit offsetChanged();
+ if (rootObject()) {
+ rootObject()->setProperty("offsetx", m_zoom > 1.0f ? x - max / 2.0 - 10: 0);
+ }
update();
}
-void GLWidget::setOffsetY(int y)
+void GLWidget::setOffsetY(int y, int max)
{
m_offset.setY(y);
- emit offsetChanged();
- // TODO: pass scrollbar offset for qml view
- /*if (rootObject()) {
- double scaley = (double) m_rect.width() / (((double) m_monitorProfile->height() * m_monitorProfile->dar() / m_monitorProfile->width())) / m_monitorProfile->width() * m_zoom;
- rootObject()->setProperty("offsety", y / scaley );
- }*/
+ if (rootObject()) {
+ rootObject()->setProperty("offsety", m_zoom > 1.0f ? y - max / 2.0 - 10: 0);
+ }
update();
}
diff --git a/src/monitor/glwidget.h b/src/monitor/glwidget.h
index 203f228..592e23c 100644
--- a/src/monitor/glwidget.h
+++ b/src/monitor/glwidget.h
@@ -103,8 +103,8 @@ protected:
public slots:
void setZoom(float zoom);
- void setOffsetX(int x);
- void setOffsetY(int y);
+ void setOffsetX(int x, int max);
+ void setOffsetY(int y, int max);
void slotSwitchAudioOverlay(bool enable);
void slotZoomScene(double value);
void initializeGL();
diff --git a/src/monitor/monitor.cpp b/src/monitor/monitor.cpp
index c10dd11..3e25684 100644
--- a/src/monitor/monitor.cpp
+++ b/src/monitor/monitor.cpp
@@ -182,8 +182,8 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
m_horizontalScroll = new QScrollBar(Qt::Horizontal);
glayout->addWidget(m_horizontalScroll, 1, 0);
m_horizontalScroll->hide();
- connect(m_horizontalScroll, SIGNAL(valueChanged(int)), m_glMonitor, SLOT(setOffsetX(int)));
- connect(m_verticalScroll, SIGNAL(valueChanged(int)), m_glMonitor, SLOT(setOffsetY(int)));
+ connect(m_horizontalScroll, &QScrollBar::valueChanged, this, &Monitor::setOffsetX);
+ connect(m_verticalScroll, &QScrollBar::valueChanged, this, &Monitor::setOffsetY);
connect(m_glMonitor, SIGNAL(frameDisplayed(const SharedFrame&)), this, SLOT(onFrameDisplayed(const SharedFrame&)));
connect(m_glMonitor, SIGNAL(mouseSeek(int,int)), this, SLOT(slotMouseSeek(int,int)));
connect(m_glMonitor, SIGNAL(monitorPlay()), this, SLOT(slotPlay()));
@@ -370,6 +370,16 @@ Monitor::~Monitor()
delete render;
}
+void Monitor::setOffsetX(int x)
+{
+ m_glMonitor->setOffsetX(x, m_horizontalScroll->maximum());
+}
+
+void Monitor::setOffsetY(int y)
+{
+ m_glMonitor->setOffsetY(y, m_verticalScroll->maximum());
+}
+
void Monitor::slotGetCurrentImage(bool request)
{
m_glMonitor->sendFrameForAnalysis = request;
@@ -735,6 +745,8 @@ void Monitor::setZoom()
if (m_glMonitor->zoom() == 1.0f) {
m_horizontalScroll->hide();
m_verticalScroll->hide();
+ m_glMonitor->setOffsetX(m_horizontalScroll->value(), m_horizontalScroll->maximum());
+ m_glMonitor->setOffsetY(m_verticalScroll->value(), m_verticalScroll->maximum());
} else {
adjustScrollBars(0.5f, 0.5f);
}
diff --git a/src/monitor/monitor.h b/src/monitor/monitor.h
index d8469e3..3067bae 100644
--- a/src/monitor/monitor.h
+++ b/src/monitor/monitor.h
@@ -270,6 +270,8 @@ private slots:
void slotUpdateQmlTimecode(const QString &tc);
/** @brief There was an error initializing Movit */
void gpuError();
+ void setOffsetX(int x);
+ void setOffsetY(int y);
public slots:
void slotOpenDvdFile(const QString &);
diff --git a/src/onmonitoritems/rotoscoping/rotowidget.cpp b/src/onmonitoritems/rotoscoping/rotowidget.cpp
index c8ddc20..8fc2daa 100644
--- a/src/onmonitoritems/rotoscoping/rotowidget.cpp
+++ b/src/onmonitoritems/rotoscoping/rotowidget.cpp
@@ -335,29 +335,35 @@ void RotoWidget::setupTrackingListen(const ItemInfo &info)
// TODO: track effects
return;
}
+ Mlt::Producer *clip = NULL;
+ if (info.track == 0) {
+ clip = m_monitor->render->getProducer();
+ } else {
+ Mlt::Service service(m_monitor->render->getProducer()->parent().get_service());
+ Mlt::Tractor tractor(service);
+ Mlt::Producer trackProducer(tractor.track(info.track));
+ Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
+ clip = trackPlaylist.get_clip_at((int)info.startPos.frames(KdenliveSettings::project_fps()));
+ }
- Mlt::Service service(m_monitor->render->getProducer()->parent().get_service());
- Mlt::Tractor tractor(service);
- Mlt::Producer trackProducer(tractor.track(tractor.count() - info.track - 1));
- Mlt::Playlist trackPlaylist((mlt_playlist) trackProducer.get_service());
-
- Mlt::Producer *clip = trackPlaylist.get_clip_at((int)info.startPos.frames(KdenliveSettings::project_fps()));
if (!clip) {
return;
}
int i = 0;
- Mlt::Filter *filter = clip->filter(0);
- while (filter) {
- if (strcmp(filter->get("kdenlive_id"), "rotoscoping") == 0) {
- m_filter = filter;
- filter->listen("tracking-finished", this, (mlt_listener)tracking_finished);
+ Mlt::Service service(*clip);
+ for (int ix = 0; ix < service.filter_count(); ++ix) {
+ QScopedPointer<Mlt::Filter> effect(service.filter(ix));
+ QString id = effect->get("kdenlive_id");
+ if (id == QLatin1String("rotoscoping")) {
+ m_filter = service.filter(ix);
+ m_filter->listen("tracking-finished", this, (mlt_listener)tracking_finished);
break;
}
- filter = clip->filter(++i);
}
-
- delete clip;
+ if (info.track > 0) {
+ delete clip;
+ }
}
void RotoWidget::setSpline(const QByteArray &spline, bool notify)