Skip to content

Commit bceb090

Browse files
committed
Prevent render outside rounded corners
1 parent 6bc7b18 commit bceb090

1 file changed

Lines changed: 32 additions & 24 deletions

File tree

src/qml/views/timeline/Clip.qml

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,24 @@ Rectangle {
5050
property bool elided: (width < 15) || (x + width < tracksFlickable.contentX) || (x > tracksFlickable.contentX + tracksFlickable.width) || (y + height < 0) || (y > tracksFlickable.contentY + tracksFlickable.contentHeight)
5151
property color clipColor: isBlank ? 'transparent' : isTransition ? 'mediumpurple' : isAudio ? 'darkseagreen' : root.shotcutBlue
5252
readonly property real _cornerRadius: 7.5
53-
property bool _roundLeft: {
53+
property real _roundLeft: {
5454
if (isBlank || !trackRoot || trackRoot.clipCount === 0)
55-
return false;
55+
return 0;
5656
if (index === 0)
57-
return true;
57+
return _cornerRadius;
5858
const prev = trackRoot.clipAt(index - 1);
59-
return prev !== null && prev !== undefined && prev.isBlank;
59+
return (prev && prev.isBlank) ? _cornerRadius : 0;
6060
}
61-
property bool _roundRight: {
61+
property real _roundRight: {
6262
if (isBlank || !trackRoot)
63-
return false;
63+
return 0;
6464
if (index === trackRoot.clipCount - 1)
65-
return true;
65+
return _cornerRadius;
6666
const next = trackRoot ? trackRoot.clipAt(index + 1) : null;
67-
return next !== null && next !== undefined && next.isBlank;
67+
return (next && next.isBlank) ? _cornerRadius : 0;
6868
}
69+
readonly property real _leftRoundedInset: _roundLeft / 2
70+
readonly property real _rightRoundedInset: _roundRight / 2
6971

7072
signal clicked(var clip, var mouse)
7173
signal clipRightClicked(var clip, var mouse)
@@ -131,10 +133,10 @@ Rectangle {
131133
return 'image://thumbnail/' + hash + '/' + mltService + '/' + clipResource + '#' + time;
132134
}
133135

134-
topLeftRadius: _roundLeft ? _cornerRadius : 0
135-
bottomLeftRadius: _roundLeft ? _cornerRadius : 0
136-
topRightRadius: _roundRight ? _cornerRadius : 0
137-
bottomRightRadius: _roundRight ? _cornerRadius : 0
136+
topLeftRadius: _roundLeft
137+
bottomLeftRadius: _roundLeft
138+
topRightRadius: _roundRight
139+
bottomRightRadius: _roundRight
138140
clip: true
139141
Drag.active: mouseArea.drag.active
140142
Drag.proposedAction: Qt.MoveAction
@@ -318,7 +320,7 @@ Rectangle {
318320
anchors.right: parent.right
319321
anchors.top: parent.top
320322
anchors.topMargin: parent.border.width
321-
anchors.rightMargin: parent.border.width + clipRoot.topRightRadius / 2
323+
anchors.rightMargin: parent.border.width + _rightRoundedInset
322324
anchors.bottom: parent.bottom
323325
anchors.bottomMargin: parent.height / 2
324326
width: height * 16 / 9
@@ -333,7 +335,7 @@ Rectangle {
333335
anchors.left: parent.left
334336
anchors.top: parent.top
335337
anchors.topMargin: parent.border.width
336-
anchors.leftMargin: parent.border.width + clipRoot.topLeftRadius / 2
338+
anchors.leftMargin: parent.border.width + _leftRoundedInset
337339
anchors.rightMargin: parent.border.width
338340
anchors.bottom: parent.bottom
339341
anchors.bottomMargin: parent.height / 2
@@ -356,11 +358,12 @@ Rectangle {
356358
id: waveform
357359

358360
readonly property int maxWidth: Math.max(application.maxTextureSize / 2, 2048)
359-
readonly property real leftOffset: _roundLeft ? _cornerRadius / 2 : parent.border.width
360-
readonly property real rightOffset: _roundRight ? _cornerRadius / 2 : parent.border.width
361+
readonly property real leftOffset: Math.max(_leftRoundedInset, parent.border.width)
362+
readonly property real rightOffset: Math.max(_rightRoundedInset, parent.border.width)
363+
readonly property real availableWidth: Math.max(0, clipRoot.width - leftOffset - rightOffset)
361364

362365
visible: !elided && !isBlank && settings.timelineShowWaveforms && (parseInt(audioIndex) > -1 || audioIndex === 'all')
363-
height: (isAudio || parent.height <= 20) ? parent.height - (_roundLeft || _roundRight ? _cornerRadius / 2 : 0) : parent.height / 2
366+
height: (isAudio || parent.height <= 20) ? parent.height - (_cornerRadius / 2) : parent.height / 2
364367
anchors.left: parent.left
365368
anchors.bottom: parent.bottom
366369
anchors.leftMargin: leftOffset
@@ -378,7 +381,7 @@ Rectangle {
378381

379382
trackIndex: clipRoot.trackIndex
380383
clipIndex: clipRoot.readonlyClipIndex
381-
width: Math.min(clipRoot.width - waveform.leftOffset - waveform.rightOffset, waveform.maxWidth)
384+
width: Math.min(waveform.maxWidth, Math.max(0, waveform.availableWidth - index * waveform.maxWidth))
382385
height: waveform.height
383386
fillColor: clipColor
384387
inPoint: Math.round((clipRoot.inPoint + index * waveform.maxWidth / timeScale) * speed) * channels
@@ -442,7 +445,7 @@ Rectangle {
442445
anchors.top: parent.top
443446
anchors.left: parent.left
444447
anchors.topMargin: parent.border.width
445-
anchors.leftMargin: parent.border.width + ((isAudio || !settings.timelineShowThumbnails) ? filtersIcon.enabledWidth : inThumbnail.width + filtersIcon.width)
448+
anchors.leftMargin: parent.border.width + _leftRoundedInset + ((isAudio || !settings.timelineShowThumbnails) ? filtersIcon.enabledWidth : (inThumbnail.width + filtersIcon.width))
446449
width: label.width + 2
447450
height: label.height
448451
}
@@ -452,6 +455,7 @@ Rectangle {
452455

453456
text: clipName
454457
visible: !elided && !isBlank && !isTransition
458+
width: Math.min(implicitWidth, parent.width - leftLabelBackground.anchors.leftMargin - _rightRoundedInset - 2 * parent.border.width)
455459
font.pointSize: 8
456460
color: 'black'
457461

@@ -471,7 +475,7 @@ Rectangle {
471475
anchors.top: parent.top
472476
anchors.right: parent.right
473477
anchors.topMargin: parent.border.width
474-
anchors.rightMargin: parent.border.width + ((isAudio || !settings.timelineShowThumbnails) ? (clipRoot.topRightRadius / 2) : outThumbnail.width)
478+
anchors.rightMargin: parent.border.width + _rightRoundedInset + ((isAudio || !settings.timelineShowThumbnails) ? 0 : outThumbnail.width)
475479
width: labelRight.width + 2
476480
height: labelRight.height
477481
}
@@ -505,7 +509,7 @@ Rectangle {
505509
anchors.left: parent.left
506510
anchors.top: parent.top
507511
anchors.topMargin: parent.border.width
508-
anchors.leftMargin: parent.border.width + ((isAudio || !settings.timelineShowThumbnails) ? (enabled ? width : 0) : inThumbnail.width) + (clipRoot.topLeftRadius / 2)
512+
anchors.leftMargin: parent.border.width + _leftRoundedInset + ((isAudio || !settings.timelineShowThumbnails) ? (enabled ? width : 0) : inThumbnail.width)
509513
width: visible ? label.height : 0
510514
height: label.height
511515
padding: 0
@@ -529,9 +533,11 @@ Rectangle {
529533
visible: !elided && !isBlank && !isTransition
530534
width: parent.fadeIn * timeScale
531535
height: parent.height - parent.border.width * 2
536+
cornerRadius: _roundLeft
532537
anchors.left: parent.left
533538
anchors.top: parent.top
534-
anchors.margins: parent.border.width
539+
anchors.leftMargin: parent.border.width
540+
anchors.topMargin: parent.border.width
535541
opacity: 0.5
536542
}
537543

@@ -626,9 +632,11 @@ Rectangle {
626632
visible: !elided && !isBlank && !isTransition
627633
width: parent.fadeOut * timeScale
628634
height: parent.height - parent.border.width * 2
635+
cornerRadius: _roundRight
629636
anchors.right: parent.right
630637
anchors.top: parent.top
631-
anchors.margins: parent.border.width
638+
anchors.rightMargin: parent.border.width
639+
anchors.topMargin: parent.border.width
632640
opacity: 0.5
633641

634642
transform: Scale {
@@ -873,6 +881,6 @@ Rectangle {
873881
bottomLeftRadius: clipRoot.bottomLeftRadius
874882
topRightRadius: clipRoot.topRightRadius
875883
bottomRightRadius: clipRoot.bottomRightRadius
876-
z: 1
884+
z: 10
877885
}
878886
}

0 commit comments

Comments
 (0)