Warning, /multimedia/kdenlive/src/timeline2/view/qml/RulerZone.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2021 Jean-Baptiste Mardelle 0003 0004 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 import QtQuick 2.15 0008 import QtQuick.Controls 2.15 0009 0010 // monitor zone 0011 Rectangle { 0012 id: rzone 0013 property int frameIn: 0 0014 property int frameOut: 0 0015 x: frameIn * timeline.scaleFactor 0016 width: (frameOut - frameIn) * timeline.scaleFactor 0017 visible: frameOut > frameIn 0018 Rectangle { 0019 anchors.left: parent.left 0020 height: parent.height 0021 width: 2 0022 color: 'white' 0023 opacity: 0.5 0024 } 0025 Rectangle { 0026 anchors.right: parent.right 0027 height: parent.height 0028 width: 2 0029 color: 'white' 0030 opacity: 0.5 0031 } 0032 0033 0034 Rectangle { 0035 id: centerDrag 0036 anchors.centerIn: parent 0037 height: parent.height 0038 width: height 0039 color: moveMouseArea.containsMouse || moveMouseArea.drag.active ? 'white' : 'transparent' 0040 border.color: 'white' 0041 border.width: 1.5 0042 opacity: 0.5 0043 Drag.active: moveMouseArea.drag.active 0044 Drag.proposedAction: Qt.MoveAction 0045 MouseArea { 0046 id: moveMouseArea 0047 anchors.left: parent.left 0048 anchors.top: parent.top 0049 width: parent.width 0050 height: parent.height 0051 hoverEnabled: true 0052 drag.axis: Drag.XAxis 0053 drag.smoothed: false 0054 property var startZone 0055 onPressed: { 0056 startZone = Qt.point(frameIn, frameOut) 0057 anchors.left= undefined 0058 } 0059 onEntered: { 0060 resizeActive = true 0061 } 0062 onExited: { 0063 if (!pressed) { 0064 resizeActive = false 0065 } 0066 } 0067 onReleased: { 0068 updateZone(startZone, Qt.point(frameIn, frameOut), true) 0069 resizeActive = false 0070 anchors.left= parent.left 0071 } 0072 onPositionChanged: mouse => { 0073 if (mouse.buttons === Qt.LeftButton) { 0074 resizeActive = true 0075 var offset = Math.round(mouseX/ timeline.scaleFactor) 0076 if (offset != 0) { 0077 var newPos = Math.max(0, controller.suggestSnapPoint(frameIn + offset,mouse.modifiers & Qt.ShiftModifier ? -1 : root.snapping)) 0078 if (newPos == frameIn + offset) { 0079 // No snap at start, check end 0080 var newPos = Math.max(0, controller.suggestSnapPoint(frameOut + offset,mouse.modifiers & Qt.ShiftModifier ? -1 : root.snapping)) 0081 if (newPos == frameOut + offset) { 0082 newPos = frameIn + offset 0083 } else { 0084 newPos = frameIn + (newPos - frameOut) 0085 } 0086 } 0087 if (newPos < 0) { 0088 newPos = frameIn + offset; 0089 } 0090 frameOut += newPos - frameIn 0091 frameIn = newPos 0092 } 0093 } 0094 } 0095 } 0096 } 0097 // Zone frame indicator 0098 Rectangle { 0099 visible: trimInMouseArea.drag.active || trimInMouseArea.containsMouse 0100 width: inLabel.contentWidth + 4 0101 height: inLabel.contentHeight 0102 anchors.bottom: rzone.top 0103 color: activePalette.highlight 0104 Label { 0105 id: inLabel 0106 anchors.fill: parent 0107 horizontalAlignment: Text.AlignHCenter 0108 text: timeline.timecode(frameIn) 0109 font: miniFont 0110 color: activePalette.highlightedText 0111 } 0112 } 0113 Rectangle { 0114 visible: trimOutMouseArea.drag.active || trimOutMouseArea.containsMouse 0115 width: outLabel.contentWidth + 4 0116 height: outLabel.contentHeight 0117 anchors.bottom: rzone.top 0118 color: activePalette.highlight 0119 x: rzone.width - (outLabel.contentWidth + 4) 0120 Label { 0121 id: outLabel 0122 anchors.fill: parent 0123 horizontalAlignment: Text.AlignHCenter 0124 text: timeline.timecode(frameOut) 0125 font: miniFont 0126 color: activePalette.highlightedText 0127 } 0128 } 0129 Rectangle { 0130 id: durationRect 0131 anchors.bottom: rzone.top 0132 visible: (!useTimelineRuler && moveMouseArea.containsMouse && !moveMouseArea.pressed) || ((useTimelineRuler || trimInMouseArea.drag.active || trimOutMouseArea.drag.active) && showZoneLabels && parent.width > 3 * width) || (useTimelineRuler && !trimInMouseArea.drag.active && !trimOutMouseArea.drag.active) 0133 anchors.horizontalCenter: parent.horizontalCenter 0134 width: durationLabel.contentWidth + 4 0135 height: durationLabel.contentHeight 0136 color: activePalette.highlight 0137 Label { 0138 id: durationLabel 0139 anchors.fill: parent 0140 horizontalAlignment: Text.AlignHCenter 0141 text: timeline.timecode(frameOut - frameIn) 0142 font: miniFont 0143 color: activePalette.highlightedText 0144 } 0145 } 0146 Rectangle { 0147 id: trimIn 0148 anchors.left: parent.left 0149 anchors.leftMargin: 0 0150 height: parent.height 0151 width: 5 0152 color: 'lawngreen' 0153 opacity: 0 0154 Drag.active: trimInMouseArea.drag.active 0155 Drag.proposedAction: Qt.MoveAction 0156 0157 MouseArea { 0158 id: trimInMouseArea 0159 anchors.fill: parent 0160 hoverEnabled: true 0161 drag.target: parent 0162 drag.axis: Drag.XAxis 0163 drag.smoothed: false 0164 property var startZone 0165 onEntered: { 0166 resizeActive = true 0167 parent.opacity = 1 0168 } 0169 onExited: { 0170 resizeActive = false 0171 parent.opacity = 0 0172 } 0173 onPressed: { 0174 parent.anchors.left = undefined 0175 parent.opacity = 1 0176 startZone = Qt.point(frameIn, frameOut) 0177 } 0178 onReleased: { 0179 resizeActive = false 0180 parent.anchors.left = rzone.left 0181 updateZone(startZone, Qt.point(frameIn, frameOut), true) 0182 } 0183 onPositionChanged: mouse => { 0184 if (mouse.buttons === Qt.LeftButton) { 0185 resizeActive = true 0186 var newPos = controller.suggestSnapPoint(frameIn + Math.round(trimIn.x / timeline.scaleFactor), mouse.modifiers & Qt.ShiftModifier ? -1 : root.snapping) 0187 if (newPos < 0) { 0188 newPos = 0 0189 } 0190 frameIn = frameOut > -1 ? Math.min(newPos, frameOut - 1) : newPos 0191 } 0192 } 0193 } 0194 } 0195 Rectangle { 0196 id: trimOut 0197 anchors.right: parent.right 0198 anchors.rightMargin: 0 0199 height: parent.height 0200 width: 5 0201 color: 'darkred' 0202 opacity: 0 0203 Drag.active: trimOutMouseArea.drag.active 0204 Drag.proposedAction: Qt.MoveAction 0205 0206 MouseArea { 0207 id: trimOutMouseArea 0208 anchors.fill: parent 0209 hoverEnabled: true 0210 drag.target: parent 0211 drag.axis: Drag.XAxis 0212 drag.smoothed: false 0213 property var startZone 0214 onEntered: { 0215 resizeActive = true 0216 parent.opacity = 1 0217 } 0218 onExited: { 0219 resizeActive = false 0220 parent.opacity = 0 0221 } 0222 onPressed: { 0223 parent.anchors.right = undefined 0224 parent.opacity = 1 0225 startZone = Qt.point(frameIn, frameOut) 0226 } 0227 onReleased: { 0228 resizeActive = false 0229 parent.anchors.right = rzone.right 0230 updateZone(startZone, Qt.point(frameIn, frameOut), true) 0231 } 0232 onPositionChanged: mouse => { 0233 if (mouse.buttons === Qt.LeftButton) { 0234 resizeActive = true 0235 frameOut = Math.max(controller.suggestSnapPoint(frameIn + Math.round((trimOut.x + trimOut.width) / timeline.scaleFactor), mouse.modifiers & Qt.ShiftModifier ? -1 : root.snapping), frameIn + 1) 0236 } 0237 } 0238 } 0239 } 0240 } 0241 0242