Fix monitor scene not adapting to zoom (rotoscoping, composite, ...)

Fix crash in rotoscoping
BUG: 373113
parent 3254a73e
......@@ -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"
}
......
......@@ -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"
}
......
......@@ -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"
}
......
......@@ -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();
}
......
......@@ -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();
......
......@@ -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);
}
......
......@@ -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 &);
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment