Ensure the monitor overlays work with consumer scaling

parent 87053733
Pipeline #13361 passed with stage
in 14 minutes and 6 seconds
......@@ -1291,6 +1291,7 @@ void MainWindow::setupActions()
connect(m_scaleGroup, &QActionGroup::triggered, [this] (QAction *ac) {
int scaling = ac->data().toInt();
KdenliveSettings::setPreviewScaling(scaling);
// Clear timeline selection so that any qml monitor scene is reset
pCore->monitorManager()->updatePreviewScaling();
});
#endif
......
......@@ -238,19 +238,19 @@ void GLWidget::resizeGL(int width, int height)
x = (width - w) / 2;
y = (height - h) / 2;
m_rect.setRect(x, y, w, h);
double scalex = (double)m_rect.width() / m_profileSize.width() * m_zoom;
double scaley = (double)m_rect.width() /
((double)m_profileSize.height() * m_dar / m_profileSize.width()) /
m_profileSize.width() * m_zoom;
QPoint center = m_rect.center();
QQuickItem *rootQml = rootObject();
if (rootQml) {
rootQml->setProperty("center", center);
QSize s = pCore->getCurrentFrameSize();
double scalex = (double)m_rect.width() / s.width() * m_zoom;
double scaley = (double)m_rect.width() /
((double)s.height() * m_dar / s.width()) /
s.width() * m_zoom;
rootQml->setProperty("center", m_rect.center());
rootQml->setProperty("scalex", scalex);
rootQml->setProperty("scaley", scaley);
if (rootQml->objectName() == QLatin1String("rootsplit")) {
// Adjust splitter pos
rootQml->setProperty("splitterPos", x + (rootQml->property("realpercent").toDouble() * w));
rootQml->setProperty("splitterPos", x + (rootQml->property("percentage").toDouble() * w));
}
}
emit rectChanged();
......@@ -1062,7 +1062,7 @@ int GLWidget::reconfigure()
if (KdenliveSettings::external_display()) {
m_consumer->set("terminate_on_pause", 0);
}
m_profileSize = pCore->getCurrentFrameSize();
m_profileSize = QSize(pCore->getProjectProfile()->width(), pCore->getProjectProfile()->height());
m_colorSpace = pCore->getCurrentProfile()->colorspace();
m_dar = pCore->getCurrentDar();
} else {
......@@ -1594,12 +1594,13 @@ void GLWidget::refreshSceneLayout()
if (!rootObject()) {
return;
}
rootObject()->setProperty("profile", QPoint(m_profileSize.width(), m_profileSize.height()));
rootObject()->setProperty("scalex", (double)m_rect.width() / pCore->getCurrentProfile()->width() * m_zoom);
QSize s = pCore->getCurrentFrameSize();
rootObject()->setProperty("profile", s);
rootObject()->setProperty("scalex", (double)m_rect.width() / s.width() * m_zoom);
rootObject()->setProperty("scaley",
(double)m_rect.width() /
(((double)m_profileSize.height() * m_dar / m_profileSize.width())) /
m_profileSize.width() * m_zoom);
(((double)s.height() * m_dar / s.width())) /
s.width() * m_zoom);
}
void GLWidget::switchPlay(bool play, double speed)
......@@ -1813,5 +1814,6 @@ void GLWidget::updateScaling()
}
pCore->updatePreviewProfile();
reconfigure();
resizeGL(width(), height());
#endif
}
......@@ -1891,7 +1891,7 @@ void Monitor::loadQmlScene(MonitorSceneType type)
type = MonitorSceneDefault;
}
double ratio = (double)m_glMonitor->profileSize().width() / (int)(m_glMonitor->profileSize().height() * pCore->getCurrentProfile()->dar() + 0.5);
m_qmlManager->setScene(m_id, type, m_glMonitor->profileSize(), ratio, m_glMonitor->displayRect(), m_glMonitor->zoom(), m_timePos->maximum());
m_qmlManager->setScene(m_id, type, pCore->getCurrentFrameSize(), ratio, m_glMonitor->displayRect(), m_glMonitor->zoom(), m_timePos->maximum());
QQuickItem *root = m_glMonitor->rootObject();
switch (type) {
case MonitorSceneSplit:
......@@ -1927,17 +1927,16 @@ void Monitor::setQmlProperty(const QString &name, const QVariant &value)
void Monitor::slotAdjustEffectCompare()
{
QRect r = m_glMonitor->rect();
double percent = 0.5;
if (m_qmlManager->sceneType() == MonitorSceneSplit) {
// Adjust splitter pos
QQuickItem *root = m_glMonitor->rootObject();
percent = 0.5 - ((root->property("splitterPos").toInt() - r.left() - r.width() / 2.0) / (double)r.width() / 2.0) / 0.75;
percent = root->property("percentage").toDouble();
// Store real frame percentage for resize events
root->setProperty("realpercent", percent);
}
if (m_splitEffect) {
m_splitEffect->set("0", percent);
m_splitEffect->set("0", 0.5 - (percent - 0.5) * .666);
}
m_glMonitor->refresh();
}
......
......@@ -94,6 +94,9 @@ void QmlManager::setScene(Kdenlive::MonitorId id, MonitorSceneType type, QSize p
case MonitorSceneSplit:
m_view->setSource(QUrl(QStringLiteral("qrc:/qml/kdenlivemonitorsplit.qml")));
root = m_view->rootObject();
root->setProperty("profile", QPoint(profile.width(), profile.height()));
root->setProperty("scalex", (double)displayRect.width() / profile.width() * zoom);
root->setProperty("scaley", (double)displayRect.width() / profileStretch / profile.width() * zoom);
break;
case MonitorSceneRipple:
m_view->setSource(QUrl(QStringLiteral("qrc:/qml/kdenlivemonitorripple.qml")));
......@@ -128,7 +131,6 @@ void QmlManager::effectPolygonChanged()
return;
}
QVariantList points = m_view->rootObject()->property("centerPoints").toList();
qDebug() << "// GOT NEW POLYGON FROM QML: " << points;
emit effectPointsChanged(points);
}
......
......@@ -10,16 +10,19 @@ Item {
// default size, but scalable by user
height: 300; width: 400
property double timeScale: 1
property double frameSize: 10
property int duration: 300
property int mouseRulerPos: 0
property int splitterPos
property point center
property rect framesize
property real baseUnit: fontMetrics.font.pixelSize * 0.8
// percentage holds splitter pos relative to the scene percentage
property double percentage
// realpercent holds splitter pos relative to the frame width percentage
property double realpercent
property point profile
property point center
property double offsetx
property double offsety
property double scalex
property double scaley
signal qmlMoveSplit()
......@@ -29,7 +32,6 @@ Item {
}
percentage: 0.5
realpercent: 0.5
splitterPos: this.width / 2
onDurationChanged: {
......@@ -46,13 +48,13 @@ Item {
cursorShape: Qt.SizeHorCursor
acceptedButtons: Qt.LeftButton
onPressed: {
root.percentage = mouseX / width
root.percentage = (mouseX - (root.width - (root.profile.x * root.scalex)) / 2) / (root.profile.x * root.scalex)
root.splitterPos = mouseX
root.qmlMoveSplit()
}
onPositionChanged: {
if (pressed) {
root.percentage = mouseX / width
root.percentage = (mouseX - (root.width - (root.profile.x * root.scalex)) / 2) / (root.profile.x * root.scalex)
root.splitterPos = mouseX
root.qmlMoveSplit()
}
......
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