aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-04-11 15:54:22 +0200
committerJean-Baptiste Mardelle <[email protected]>2015-04-11 15:54:22 +0200
commit872ff4f1d74b364997b60949accd496e2b4bbf96 (patch)
tree65237d2b2f2bea57f64508020c4e40d2f41e52e2
parentf85e406d14d0a37dc7f190050e4f58cc1d022fda (diff)
Cleanup monitor qml and fix zooming
-rw-r--r--data/kdenlivemonitor.qml1
-rw-r--r--data/kdenlivemonitoreffectscene.qml91
-rw-r--r--data/kdenlivemonitorsplit.qml29
-rw-r--r--src/effectstack/widgets/geometrywidget.cpp31
-rw-r--r--src/effectstack/widgets/geometrywidget.h2
-rw-r--r--src/monitor/glwidget.cpp15
-rw-r--r--src/monitor/monitor.cpp24
-rw-r--r--src/monitor/monitor.h3
8 files changed, 124 insertions, 72 deletions
diff --git a/data/kdenlivemonitor.qml b/data/kdenlivemonitor.qml
index 4858ce7..255f59f 100644
--- a/data/kdenlivemonitor.qml
+++ b/data/kdenlivemonitor.qml
@@ -12,6 +12,7 @@ Item {
property double scale
Rectangle {
+ id: overlaybg
anchors {
right: parent.right
//left: parent.left
diff --git a/data/kdenlivemonitoreffectscene.qml b/data/kdenlivemonitoreffectscene.qml
index 308b1b0..eaba3bb 100644
--- a/data/kdenlivemonitoreffectscene.qml
+++ b/data/kdenlivemonitoreffectscene.qml
@@ -9,28 +9,61 @@ Item {
property string comment
property string framenum
property rect framesize
- property rect framebase
+ property point profile
property point center
property double scale
+ onScaleChanged: canvas.requestPaint()
property bool iskeyframe
+ property var centerPoints: []
+ onCenterPointsChanged: canvas.requestPaint()
signal effectChanged()
signal addKeyframe()
- Item {
- id: effectscene
- objectName: "effectscene"
+ Canvas {
+ id: canvas
+ width: root.width
+ height: root.height
+ anchors.centerIn: root
+ contextType: "2d";
+ renderStrategy: Canvas.Threaded;
+ onPaint:
+ {
+ if (context) {
+ context.clearRect(0,0, width, height);
+ context.beginPath()
+ context.strokeStyle = Qt.rgba(1, 0, 0, 0.5)
+ context.lineWidth = 2
+
+ for(var i = 0; i < root.centerPoints.length; i++)
+ {
+ var p1 = convertPoint(root.centerPoints[i])
+ if(i == 0)
+ {
+ context.moveTo(p1.x, p1.y)
+ continue
+ }
+ context.lineTo(p1.x, p1.y)
+ }
+ context.stroke()
+ context.restore()
+ }
+ }
+
+ function convertPoint(p)
+ {
+ var x = frame.x + p.x * root.scale
+ var y = frame.y + p.y * root.scale
+ return Qt.point(x,y);
+ }
+ }
Rectangle {
id: frame
- objectName: "frame"
+ objectName: "referenceframe"
property color hoverColor: "#ff0000"
- //anchors.centerIn: root.center
- //x: root.framebase.x
- //y: root.framebase.y
- width: root.framebase.width * root.scale
- height: root.framebase.height * root.scale
+ width: root.profile.x * root.scale
+ height: root.profile.y * root.scale
x: root.center.x - width / 2
y: root.center.y - height / 2
- //height: root.height * 0.1
color: "transparent"
border.color: "#ffffff00"
}
@@ -48,13 +81,11 @@ Item {
}
Rectangle {
id: framerect
- objectName: "framerect"
property color hoverColor: "#ff0000"
x: frame.x + root.framesize.x * root.scale
y: frame.y + root.framesize.y * root.scale
width: root.framesize.width * root.scale
height: root.framesize.height * root.scale
- //height: root.height * 0.1
color: "transparent"
border.color: "#ffff0000"
Rectangle {
@@ -64,13 +95,13 @@ Item {
left: parent.left
}
visible: root.iskeyframe
- width: 10
- height: 10
+ width: effectsize.height * 0.7
+ height: this.width
color: "red"
MouseArea {
property int oldMouseX
property int oldMouseY
- width: effectsize.height; height: effectsize.height
+ width: parent.width; height: parent.height
anchors.centerIn: parent
hoverEnabled: true
cursorShape: Qt.SizeFDiagCursor
@@ -112,14 +143,14 @@ Item {
top: parent.top
right: parent.right
}
- width: 10
- height: 10
+ width: effectsize.height * 0.7
+ height: this.width
color: "red"
visible: root.iskeyframe
MouseArea {
property int oldMouseX
property int oldMouseY
- width: effectsize.height; height: effectsize.height
+ width: parent.width; height: parent.height
anchors.centerIn: parent
hoverEnabled: true
cursorShape: Qt.SizeBDiagCursor
@@ -149,14 +180,14 @@ Item {
bottom: parent.bottom
left: parent.left
}
- width: 10
- height: 10
+ width: effectsize.height * 0.7
+ height: this.width
color: "red"
visible: root.iskeyframe
MouseArea {
property int oldMouseX
property int oldMouseY
- width: effectsize.height; height: effectsize.height
+ width: parent.width; height: parent.height
anchors.centerIn: parent
hoverEnabled: true
cursorShape: Qt.SizeBDiagCursor
@@ -186,14 +217,14 @@ Item {
bottom: parent.bottom
right: parent.right
}
- width: 10
- height: 10
+ width: effectsize.height * 0.7
+ height: this.width
color: "red"
visible: root.iskeyframe
MouseArea {
property int oldMouseX
property int oldMouseY
- width: effectsize.height; height: effectsize.height
+ width: parent.width; height: parent.height
anchors.centerIn: parent
hoverEnabled: true
cursorShape: Qt.SizeFDiagCursor
@@ -230,16 +261,16 @@ Item {
Rectangle {
anchors.centerIn: parent
width: 1
- height: effectsize.height * 1.5
+ height: root.iskeyframe ? effectsize.height * 1.5 : effectsize.height / 2
color: framerect.hoverColor
- visible: root.iskeyframe
MouseArea {
width: effectsize.height * 1.5; height: effectsize.height * 1.5
anchors.centerIn: parent
property int oldMouseX
property int oldMouseY
hoverEnabled: true
- cursorShape: Qt.SizeAllCursor
+ enabled: root.iskeyframe
+ cursorShape: root.iskeyframe ? Qt.SizeAllCursor : Qt.ArrowCursor
onEntered: { framerect.hoverColor = '#ffff00'}
onExited: { framerect.hoverColor = '#ff0000'}
onPressed: {
@@ -261,11 +292,9 @@ Item {
}
Rectangle {
anchors.centerIn: parent
- width: effectsize.height * 1.5
+ width: root.iskeyframe ? effectsize.height * 1.5 : effectsize.height / 2
height: 1
color: framerect.hoverColor
- visible: root.iskeyframe
}
}
- }
}
diff --git a/data/kdenlivemonitorsplit.qml b/data/kdenlivemonitorsplit.qml
index a6d8a3b..91f637b 100644
--- a/data/kdenlivemonitorsplit.qml
+++ b/data/kdenlivemonitorsplit.qml
@@ -7,7 +7,9 @@ Item {
// default size, but scalable by user
height: 300; width: 400
signal qmlMoveSplit(real percent)
-
+ property int splitterPos
+ splitterPos: this.width / 2
+
MouseArea {
width: rootsplit.width; height: rootsplit.height
anchors.centerIn: parent
@@ -15,11 +17,36 @@ Item {
cursorShape: Qt.SizeHorCursor
onPressed: {
rootsplit.qmlMoveSplit(mouseX / width)
+ rootsplit.splitterPos = mouseX
}
onPositionChanged: {
if (pressed) {
rootsplit.qmlMoveSplit(mouseX / width)
+ rootsplit.splitterPos = mouseX
}
+ timer.restart()
+ splitter.visible = true
+ }
+ //onEntered: { splitter.visible = true }
+ onExited: { splitter.visible = false }
+ }
+
+ Rectangle {
+ id: splitter
+ x: rootsplit.splitterPos
+ y: 0
+ width: 1
+ height: rootsplit.height
+ color: "red"
+ visible: false
+ }
+
+ Timer {
+ id: timer
+
+ interval: 1000; running: false; repeat: false
+ onTriggered: {
+ splitter.visible = false
}
}
}
diff --git a/src/effectstack/widgets/geometrywidget.cpp b/src/effectstack/widgets/geometrywidget.cpp
index a745fb9..d2b0415 100644
--- a/src/effectstack/widgets/geometrywidget.cpp
+++ b/src/effectstack/widgets/geometrywidget.cpp
@@ -349,7 +349,7 @@ void GeometryWidget::setupParam(const QDomElement &elem, int minframe, int maxfr
}
Mlt::GeometryItem item;
- m_geometry->fetch(&item, 0);
+ m_geometry->fetch(&item, m_monitor->render->seekFramePosition() - m_clipPos);
/*if (m_rect) {
m_scene->removeItem(m_rect);
delete m_rect;
@@ -360,7 +360,7 @@ void GeometryWidget::setupParam(const QDomElement &elem, int minframe, int maxfr
}*/
m_monitor->slotShowEffectScene(true);
- m_monitor->setUpEffectGeometry(QRect(item.x(), item.y(), item.w(), item.h()));
+ m_monitor->setUpEffectGeometry(QRect(item.x(), item.y(), item.w(), item.h()), calculateCenters());
connect(m_monitor, SIGNAL(effectChanged(QRect)), this, SLOT(slotUpdateGeometry(QRect)));
/*m_geomPath = new OnMonitorPathItem();
connect(m_geomPath, SIGNAL(changed()), this, SLOT(slotUpdatePath()));
@@ -673,7 +673,9 @@ void GeometryWidget::slotUpdateGeometry(QRect r)
m_geomPath->setPoints(m_geometry);
m_scene->addItem(m_geomPath);
}*/
+ m_monitor->setUpEffectGeometry(QRect(), calculateCenters());
emit parameterChanged();
+
}
void GeometryWidget::slotUpdateProperties()
@@ -705,41 +707,54 @@ void GeometryWidget::slotUpdateProperties()
}
+QVariantList GeometryWidget::calculateCenters()
+{
+ QVariantList points;
+ Mlt::GeometryItem item;
+ int pos = 0;
+ while (!m_geometry->next_key(&item, pos)) {
+ QRect r(item.x(), item.y(), item.w(), item.h());
+ points.append(QVariant(r.center()));
+ pos = item.frame() + 1;
+ }
+ return points;
+}
+
void GeometryWidget::slotSetX(double value)
{
- m_monitor->setUpEffectGeometry(value, m_spinY->value(), m_spinWidth->value(), m_spinHeight->value());
slotUpdateGeometry();
+ m_monitor->setUpEffectGeometry(QRect(value, m_spinY->value(), m_spinWidth->value(), m_spinHeight->value()), calculateCenters());
}
void GeometryWidget::slotSetY(double value)
{
- m_monitor->setUpEffectGeometry(m_spinX->value(), value, m_spinWidth->value(), m_spinHeight->value());
slotUpdateGeometry();
+ m_monitor->setUpEffectGeometry(QRect(m_spinX->value(), value, m_spinWidth->value(), m_spinHeight->value()), calculateCenters());
}
void GeometryWidget::slotSetWidth(double value)
{
- m_monitor->setUpEffectGeometry(m_spinX->value(), m_spinY->value(), value, m_spinHeight->value());
slotUpdateGeometry();
+ m_monitor->setUpEffectGeometry(QRect(m_spinX->value(), m_spinY->value(), value, m_spinHeight->value()), calculateCenters());
}
void GeometryWidget::slotSetHeight(double value)
{
- m_monitor->setUpEffectGeometry(m_spinX->value(), m_spinY->value(), m_spinWidth->value(), value);
slotUpdateGeometry();
+ m_monitor->setUpEffectGeometry(QRect(m_spinX->value(), m_spinY->value(), m_spinWidth->value(), value), calculateCenters());
}
void GeometryWidget::updateMonitorGeometry()
{
- m_monitor->setUpEffectGeometry(m_spinX->value(), m_spinY->value(), m_spinWidth->value(), m_spinHeight->value());
slotUpdateGeometry();
+ m_monitor->setUpEffectGeometry(QRect(m_spinX->value(), m_spinY->value(), m_spinWidth->value(), m_spinHeight->value()), calculateCenters());
}
void GeometryWidget::slotResize(double value)
{
- m_monitor->setUpEffectGeometry(m_spinX->value(), m_spinY->value(), (int)((m_monitor->render->frameRenderWidth() * value / 100.0) + 0.5), (int)((m_monitor->render->renderHeight() * value / 100.0) + 0.5));
slotUpdateGeometry();
+ m_monitor->setUpEffectGeometry(QRect(m_spinX->value(), m_spinY->value(), (int)((m_monitor->render->frameRenderWidth() * value / 100.0) + 0.5), (int)((m_monitor->render->renderHeight() * value / 100.0) + 0.5)), calculateCenters());
}
diff --git a/src/effectstack/widgets/geometrywidget.h b/src/effectstack/widgets/geometrywidget.h
index cd3a087..c75b781 100644
--- a/src/effectstack/widgets/geometrywidget.h
+++ b/src/effectstack/widgets/geometrywidget.h
@@ -102,6 +102,8 @@ private:
QPoint m_frameSize;
/** @brief Update monitor rect with current width / height values. */
void updateMonitorGeometry();
+ /** @brief Calculate the path for rectangle center moves. */
+ QVariantList calculateCenters();
private slots:
/** @brief Updates controls according to position.
diff --git a/src/monitor/glwidget.cpp b/src/monitor/glwidget.cpp
index 1b54026..b422874 100644
--- a/src/monitor/glwidget.cpp
+++ b/src/monitor/glwidget.cpp
@@ -165,15 +165,8 @@ void GLWidget::initializeGL()
void GLWidget::effectRectChanged()
{
- QObject *item = rootObject()->findChild<QObject*>("framerect");
- QObject *base = rootObject()->findChild<QObject*>("frame");
- double scale = rootObject()->property("scale").toDouble();
- int x = (int) ((item->property("x").toInt() - base->property("x").toInt()) / scale + 0.5);
- int y = (int) ((item->property("y").toInt() - base->property("y").toInt()) / scale + 0.5);
- int w = (int) (item->property("width").toInt() / scale + 0.5);
- int h = (int) (item->property("height").toInt() / scale + 0.5);
- QRect r(x, y, w, h);
- emit effectChanged(r);
+ QRect rect = rootObject()->property("framesize").toRect();
+ emit effectChanged(rect);
}
void GLWidget::setBlankScene()
@@ -759,8 +752,8 @@ void GLWidget::slotShowEffectScene()
{
QObject *item = rootObject();
QObject::connect(item, SIGNAL(effectChanged()), this, SLOT(effectRectChanged()), Qt::UniqueConnection);
- item->setProperty("framebase", QRect(0, 0, m_consumer->profile()->width(), m_consumer->profile()->height()));
- item->setProperty("framerect", QRect(0, 0, m_consumer->profile()->width(), m_consumer->profile()->height()));
+ item->setProperty("profile", QPoint(m_consumer->profile()->width(), m_consumer->profile()->height()));
+ item->setProperty("framesize", QRect(0, 0, m_consumer->profile()->width(), m_consumer->profile()->height()));
item->setProperty("scale", (double) m_rect.width() / m_consumer->profile()->width() * m_zoom);
item->setProperty("center", m_rect.center());
}
diff --git a/src/monitor/monitor.cpp b/src/monitor/monitor.cpp
index 3e343e8..1da5a31 100644
--- a/src/monitor/monitor.cpp
+++ b/src/monitor/monitor.cpp
@@ -499,12 +499,6 @@ void Monitor::adjustScrollBars(float horizontal, float vertical)
void Monitor::setZoom()
{
- //emit zoomChanged(factor);
- //Settings.setPlayerZoom(factor);
- if (m_rootItem->objectName() != "root") {
- // we are not in main view, ignore
- return;
- }
if (m_glMonitor->zoom() == 1.0f) {
/* m_zoomButton->setIcon(icon);
m_zoomButton->setChecked(false);*/
@@ -513,11 +507,6 @@ void Monitor::setZoom()
} else {
adjustScrollBars(0.5f, 0.5f);
}
- QRect r;
- r.setSize(QSize((int) (m_glMonitor->rect().width() * m_glMonitor->zoom() + 0.5), (int) (m_glMonitor->rect().height() * m_glMonitor->zoom() + 0.5)));
- QSize s = m_glMonitor->size() / 2 - r.size() / 2;
- r.moveTopLeft(QPoint(s.width(), s.height()));
- m_rootItem->setProperty("framesize", r);
}
void Monitor::slotSwitchFullScreen(bool minimizeOnly)
@@ -1197,15 +1186,12 @@ void Monitor::slotShowEffectScene(bool show, bool manuallyTriggered)
else loadMasterQml();
}
-void Monitor::setUpEffectGeometry(QRect r)
+void Monitor::setUpEffectGeometry(QRect r, QVariantList list)
{
- m_rootItem->setProperty("framesize", r);
-}
-
-void Monitor::setUpEffectGeometry(int x, int y, int w, int h)
-{
- m_rootItem->setProperty("framesize", QRect(x, y, w, h));
- QRect res = m_rootItem->property("framesize").toRect();
+ if (!list.isEmpty()) {
+ m_rootItem->setProperty("centerPoints", list);
+ }
+ if (!r.isEmpty()) m_rootItem->setProperty("framesize", r);
}
QRect Monitor::effectRect() const
diff --git a/src/monitor/monitor.h b/src/monitor/monitor.h
index 201e3de..b4793a8 100644
--- a/src/monitor/monitor.h
+++ b/src/monitor/monitor.h
@@ -84,8 +84,7 @@ public:
int getZoneStart();
int getZoneEnd();
- void setUpEffectGeometry(QRect r);
- void setUpEffectGeometry(int x, int y, int w, int h);
+ void setUpEffectGeometry(QRect r, QVariantList list = QVariantList());
QRect effectRect() const;
void setEffectKeyframe(bool enable);
void sendFrameForAnalysis(bool analyse);