Commit a582fd66 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix timeline keyframes sometimes disappearing from view.

CCBUGS: 448501
parent 2c5a5e58
......@@ -82,6 +82,11 @@ Rectangle {
onScrollStartChanged: {
clipRoot.hideClipViews = scrollStart > (clipDuration * timeline.scaleFactor) || scrollStart + scrollView.width < 0
if (!clipRoot.hideClipViews && clipRoot.width > scrollView.width) {
if (effectRow.item && effectRow.item.kfrCanvas) {
effectRow.item.kfrCanvas.requestPaint()
}
}
}
onIsGrabbedChanged: {
......@@ -120,11 +125,11 @@ Rectangle {
}
}
onKeyframeModelChanged: {
if (effectRow.item && effectRow.item.keyframecanvas) {
effectRow.item.keyframecanvas.requestPaint()
/*onKeyframeModelChanged: {
if (effectRow.item && effectRow.item.kfrCanvas) {
effectRow.item.kfrCanvas.requestPaint()
}
}
}*/
onClipDurationChanged: {
width = clipDuration * timeScale
......@@ -166,6 +171,11 @@ Rectangle {
x = modelStart * timeScale;
width = clipDuration * timeScale;
updateLabelOffset()
if (!clipRoot.hideClipViews) {
if (effectRow.item && effectRow.item.kfrCanvas) {
effectRow.item.kfrCanvas.requestPaint()
}
}
}
onScrollXChanged: {
updateLabelOffset()
......@@ -999,6 +1009,14 @@ Rectangle {
value: clipRoot.modelStart
when: effectRow.status == Loader.Ready && effectRow.item
}
Binding {
target: effectRow.item
property: "scrollStart"
value: clipRoot.scrollStart
when: effectRow.status == Loader.Ready && effectRow.item
// TODO: use restoreMode for Qt >= 5.15
// restoreMode: Binding.RestoreBindingOrValue
}
Binding {
target: effectRow.item
property: "clipId"
......
......@@ -60,14 +60,19 @@ Item {
signal trimmedOut(var clip)
onScrollStartChanged: {
compositionRoot.hideCompoViews = compositionRoot.scrollStart > width || compositionRoot.scrollStart + scrollView.contentItem.width < 0
compositionRoot.hideCompoViews = compositionRoot.scrollStart > width || compositionRoot.scrollStart + scrollView.width < 0
if (!compositionRoot.hideClipViews && compositionRoot.width > scrollView.width) {
if (effectRow.item && effectRow.item.kfrCanvas) {
effectRow.item.kfrCanvas.requestPaint()
}
}
}
onKeyframeModelChanged: {
/*onKeyframeModelChanged: {
if (effectRow.item && effectRow.item.keyframecanvas) {
effectRow.item.keyframecanvas.requestPaint()
}
}
}*/
onModelStartChanged: {
x = modelStart * timeScale;
......@@ -101,6 +106,11 @@ Item {
x = modelStart * timeScale;
width = clipDuration * timeScale;
labelRect.x = scrollX > modelStart * timeScale ? scrollX - modelStart * timeScale : 0
if (!compositionRoot.hideClipViews) {
if (effectRow.item && effectRow.item.kfrCanvas) {
effectRow.item.kfrCanvas.requestPaint()
}
}
}
onScrollXChanged: {
labelRect.x = scrollX > modelStart * timeScale ? scrollX - modelStart * timeScale : 0
......@@ -435,6 +445,12 @@ Item {
value: compositionRoot.modelStart
when: effectRow.status == Loader.Ready && effectRow.item
}
Binding {
target: effectRow.item
property: "scrollStart"
value: compositionRoot.scrollStart
when: effectRow.status == Loader.Ready && effectRow.item
}
Binding {
target: effectRow.item
property: "clipId"
......
......@@ -21,6 +21,8 @@ Rectangle
property int modelStart
property bool selected
property var kfrModel
property int scrollStart
property alias kfrCanvas: keyframecanvas
signal seek(int position)
onKfrCountChanged: {
......@@ -288,7 +290,10 @@ Rectangle
id: keyframecanvas
contextType: "2d"
renderStrategy: Canvas.Threaded
width: kfrCount > 1 ? parent.width : 0
property int offset: scrollStart < 0 || parent.width <= scrollView.width ? 0 : scrollStart
anchors.left: parent.left
anchors.leftMargin: offset
width: kfrCount > 1 ? Math.min(parent.width, scrollView.width) : 0
height: kfrCount > 1 ? parent.height : 0
opacity: keyframeContainer.selected ? 1 : 0.5
Component {
......@@ -302,7 +307,8 @@ Rectangle
property var paths : []
Path {
id: myPath
startX: 0; startY: parent.height
startX: 0
startY: parent.height
}
onPaint: {
......@@ -317,8 +323,13 @@ Rectangle
var ypos
for(var i = 0; i < keyframes.count; i++)
{
if (i + 1 < keyframes.count) {
if (keyframes.itemAt(i + 1).tmpPos < offset) {
continue;
}
}
xpos = keyframes.itemAt(i).tmpPos - offset
var type = i > 0 ? keyframes.itemAt(i-1).frameType : keyframes.itemAt(i).frameType
xpos = keyframes.itemAt(i).tmpPos
if (type === 0) {
// discrete
paths.push(compline.createObject(keyframecanvas, {"x": xpos, "y": ypos} ))
......@@ -331,9 +342,12 @@ Rectangle
// curve
paths.push(comp.createObject(keyframecanvas, {"x": xpos, "y": ypos} ))
}
if (xpos > scrollView.width) {
break;
}
}
paths.push(compline.createObject(keyframecanvas, {"x": parent.width, "y": ypos} ))
paths.push(compline.createObject(keyframecanvas, {"x": parent.width, "y": parent.height} ))
paths.push(compline.createObject(keyframecanvas, {"x": keyframecanvas.width, "y": ypos} ))
paths.push(compline.createObject(keyframecanvas, {"x": keyframecanvas.width, "y": keyframecanvas.height} ))
myPath.pathElements = paths
ctx.clearRect(0,0, width, height);
ctx.path = myPath;
......
Supports Markdown
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