Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Shift+click to individually resize grouped clips

parent 00eca74f
......@@ -854,7 +854,7 @@ bool TimelineModel::requestGroupDeletion(int clipId, Fun &undo, Fun &redo)
return true;
}
int TimelineModel::requestItemResize(int itemId, int size, bool right, bool logUndo, int snapDistance)
int TimelineModel::requestItemResize(int itemId, int size, bool right, bool logUndo, int snapDistance, bool allowSingleResize)
{
#ifdef LOGGING
m_logFile << "timeline->requestItemResize(" << itemId << "," << size << " ," << (right ? "true" : "false") << ", " << (logUndo ? "true" : "false") << ", "
......@@ -886,7 +886,7 @@ int TimelineModel::requestItemResize(int itemId, int size, bool right, bool logU
Fun undo = []() { return true; };
Fun redo = []() { return true; };
std::unordered_set<int> all_items;
if (m_groups->isInGroup(itemId)) {
if (!allowSingleResize && m_groups->isInGroup(itemId)) {
int groupId = m_groups->getRootId(itemId);
auto items = m_groups->getLeaves(groupId);
for (int id : items) {
......
......@@ -356,7 +356,7 @@ public:
@param logUndo if set to true, an undo object is created
@param snap if set to true, the resize order will be coerced to use the snapping grid
*/
Q_INVOKABLE int requestItemResize(int itemId, int size, bool right, bool logUndo = true, int snapDistance = -1);
Q_INVOKABLE int requestItemResize(int itemId, int size, bool right, bool logUndo = true, int snapDistance = -1, bool allowSingleResize = false);
/* @brief Change the duration of an item (clip or composition)
This action is undoable
Returns true on success. If it fails, nothing is modified.
......
......@@ -71,10 +71,10 @@ Rectangle {
signal dragged(var clip, var mouse)
signal dropped(var clip)
signal draggedToTrack(var clip, int pos, int xpos)
signal trimmingIn(var clip, real newDuration, var mouse)
signal trimmedIn(var clip)
signal trimmingOut(var clip, real newDuration, var mouse)
signal trimmedOut(var clip)
signal trimmingIn(var clip, real newDuration, var mouse, bool shiftTrim)
signal trimmedIn(var clip, bool shiftTrim)
signal trimmingOut(var clip, real newDuration, var mouse, bool shiftTrim)
signal trimmedOut(var clip, bool shiftTrim)
SequentialAnimation on color {
id: flashclip
......@@ -688,7 +688,6 @@ Rectangle {
opacity: 0
Drag.active: trimInMouseArea.drag.active
Drag.proposedAction: Qt.MoveAction
enabled: !clipRoot.grouped
visible: root.activeTool === 0 && !mouseArea.drag.active
MouseArea {
......@@ -698,24 +697,26 @@ Rectangle {
drag.target: parent
drag.axis: Drag.XAxis
drag.smoothed: false
property bool shiftTrim: false
cursorShape: (containsMouse ? Qt.SizeHorCursor : Qt.ClosedHandCursor);
onPressed: {
root.stopScrolling = true
clipRoot.originalX = clipRoot.x
clipRoot.originalDuration = clipDuration
parent.anchors.left = undefined
shiftTrim = mouse.modifiers & Qt.ShiftModifier
}
onReleased: {
root.stopScrolling = false
parent.anchors.left = clipRoot.left
clipRoot.trimmedIn(clipRoot)
clipRoot.trimmedIn(clipRoot, shiftTrim)
}
onPositionChanged: {
if (mouse.buttons === Qt.LeftButton) {
var delta = Math.round((trimIn.x) / timeScale)
if (delta !== 0) {
var newDuration = clipDuration - delta
clipRoot.trimmingIn(clipRoot, newDuration, mouse)
clipRoot.trimmingIn(clipRoot, newDuration, mouse, shiftTrim)
}
}
}
......@@ -737,18 +738,14 @@ Rectangle {
opacity: 0
Drag.active: trimOutMouseArea.drag.active
Drag.proposedAction: Qt.MoveAction
enabled: !clipRoot.grouped
visible: root.activeTool === 0 && !mouseArea.drag.active
MouseArea {
id: trimOutMouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: (containsMouse
? (pressed
? Qt.SizeHorCursor
: Qt.SizeHorCursor)
: Qt.ClosedHandCursor);
property bool shiftTrim: false
cursorShape: (containsMouse ? Qt.SizeHorCursor : Qt.ClosedHandCursor);
drag.target: parent
drag.axis: Drag.XAxis
drag.smoothed: false
......@@ -757,17 +754,18 @@ Rectangle {
root.stopScrolling = true
clipRoot.originalDuration = clipDuration
parent.anchors.right = undefined
shiftTrim = mouse.modifiers & Qt.ShiftModifier
}
onReleased: {
root.stopScrolling = false
parent.anchors.right = clipRoot.right
clipRoot.trimmedOut(clipRoot)
clipRoot.trimmedOut(clipRoot, shiftTrim)
}
onPositionChanged: {
if (mouse.buttons === Qt.LeftButton) {
var newDuration = Math.round((parent.x + parent.width) / timeScale)
if (newDuration != clipDuration) {
clipRoot.trimmingOut(clipRoot, newDuration, mouse)
clipRoot.trimmingOut(clipRoot, newDuration, mouse, shiftTrim)
}
}
}
......
......@@ -287,7 +287,7 @@ Column{
}
}
onTrimmingIn: {
var new_duration = controller.requestItemResize(clip.clipId, newDuration, false, false, root.snapping)
var new_duration = controller.requestItemResize(clip.clipId, newDuration, false, false, root.snapping, shiftTrim)
if (new_duration > 0) {
clip.lastValidDuration = new_duration
clip.originalX = clip.draggedX
......@@ -295,33 +295,33 @@ Column{
var delta = new_duration - clip.originalDuration
var s = timeline.timecode(Math.abs(delta))
s = '%1%2 = %3'.arg((delta < 0)? '+' : (delta > 0)? '-' : '')
.arg(s.substring(3))
.arg(s)
.arg(timeline.timecode(clipDuration))
bubbleHelp.show(clip.x - 20, trackRoot.y + trackRoot.height, s)
}
}
onTrimmedIn: {
bubbleHelp.hide()
controller.requestItemResize(clip.clipId, clip.originalDuration, false, false, root.snapping)
controller.requestItemResize(clip.clipId, clip.lastValidDuration, false, true, root.snapping)
controller.requestItemResize(clip.clipId, clip.originalDuration, false, false, root.snapping, shiftTrim)
controller.requestItemResize(clip.clipId, clip.lastValidDuration, false, true, root.snapping, shiftTrim)
}
onTrimmingOut: {
var new_duration = controller.requestItemResize(clip.clipId, newDuration, true, false, root.snapping)
var new_duration = controller.requestItemResize(clip.clipId, newDuration, true, false, root.snapping, shiftTrim)
if (new_duration > 0) {
clip.lastValidDuration = new_duration
// Show amount trimmed as a time in a "bubble" help.
var delta = clip.originalDuration - new_duration
var s = timeline.timecode(Math.abs(delta))
s = '%1%2 = %3'.arg((delta < 0)? '+' : (delta > 0)? '-' : '')
.arg(s.substring(3))
.arg(s)
.arg(timeline.timecode(new_duration))
bubbleHelp.show(clip.x + clip.width - 20, trackRoot.y + trackRoot.height, s)
}
}
onTrimmedOut: {
bubbleHelp.hide()
controller.requestItemResize(clip.clipId, clip.originalDuration, true, false, root.snapping)
controller.requestItemResize(clip.clipId, clip.lastValidDuration, true, true, root.snapping)
controller.requestItemResize(clip.clipId, clip.originalDuration, true, false, root.snapping, shiftTrim)
controller.requestItemResize(clip.clipId, clip.lastValidDuration, true, true, root.snapping, shiftTrim)
}
Component.onCompleted: {
......@@ -382,7 +382,7 @@ Column{
var delta = newDuration - clip.originalDuration
var s = timeline.timecode(Math.abs(delta))
s = '%1%2 = %3'.arg((delta < 0)? '+' : (delta > 0)? '-' : '')
.arg(s.substring(3))
.arg(s)
.arg(timeline.timecode(clipDuration))
bubbleHelp.show(clip.x + clip.width, trackRoot.y + trackRoot.height, s)
}
......@@ -399,7 +399,7 @@ Column{
var delta = newDuration - clip.originalDuration
var s = timeline.timecode(Math.abs(delta))
s = '%1%2 = %3'.arg((delta < 0)? '+' : (delta > 0)? '-' : '')
.arg(s.substring(3))
.arg(s)
.arg(timeline.timecode(clipDuration))
bubbleHelp.show(clip.x + clip.width, trackRoot.y + trackRoot.height, s)
}
......
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