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

Minor improvement to clip grabbing

parent 88d71bfa
Pipeline #5048 passed with stage
in 19 minutes and 9 seconds
......@@ -83,11 +83,15 @@ Rectangle {
onIsGrabbedChanged: {
if (clipRoot.isGrabbed) {
clipRoot.forceActiveFocus();
mouseArea.focus = true
grabItem()
}
}
function grabItem() {
clipRoot.forceActiveFocus()
mouseArea.focus = true
}
function clearAndMove(offset) {
controller.requestClearSelection()
controller.requestClipMove(clipRoot.clipId, clipRoot.trackId, clipRoot.modelStart - offset, true, true, true)
......
......@@ -83,10 +83,15 @@ Item {
onIsGrabbedChanged: {
if (compositionRoot.isGrabbed) {
compositionRoot.forceActiveFocus();
mouseArea.focus = true
grabItem()
}
}
function grabItem() {
compositionRoot.forceActiveFocus()
mouseArea.focus = true
}
onTrackIdChanged: {
compositionRoot.parentTrack = Logic.getTrackById(trackId)
compositionRoot.y = compositionRoot.originalTrackId == -1 || trackId == originalTrackId ? 0 : parentTrack.y - Logic.getTrackById(compositionRoot.originalTrackId).y;
......
......@@ -1144,11 +1144,13 @@ Rectangle {
var x = controller.getItemPosition(dragProxy.draggedItem)
var posx = Math.round((parent.x)/ root.timeScale)
var clickAccepted = true
if (controller.normalEdit() && (tk != Logic.getTrackIdFromPos(parent.y) || x != posx)) {
var currentMouseTrack = Logic.getTrackIdFromPos(parent.y)
if (controller.normalEdit() && (tk != currentMouseTrack || x != posx)) {
console.log('INCORRECT DRAG, Trying to recover item: ', parent.y,' XPOS: ',x,'=',posx,'on track: ',tk ,'\n!!!!!!!!!!')
// Try to find correct item
var tentativeClip = getItemAtPos(tk, mouseX + parent.x, dragProxy.isComposition)
var tentativeClip = getItemAtPos(currentMouseTrack, mouseX + parent.x, dragProxy.isComposition)
if (tentativeClip && tentativeClip.clipId) {
console.log('FOUND MISSING ITSM: ', tentativeClip.clipId)
clickAccepted = true
dragProxy.draggedItem = tentativeClip.clipId
dragProxy.x = tentativeClip.x
......@@ -1160,6 +1162,7 @@ Rectangle {
dragProxy.sourceFrame = tentativeClip.modelStart
dragProxy.isComposition = tentativeClip.isComposition
} else {
console.log('COULD NOT FIND ITSM ')
clickAccepted = false
mouse.accepted = false
dragProxy.draggedItem = -1
......@@ -1249,6 +1252,9 @@ Rectangle {
timeline.endFakeMove(dragProxy.draggedItem, dragFrame, true, true, true)
}
}
if (dragProxy.masterObject && dragProxy.masterObject.isGrabbed) {
dragProxy.masterObject.grabItem()
}
dragProxy.x = controller.getItemPosition(dragProxy.draggedItem) * timeline.scaleFactor
dragProxy.sourceFrame = dragFrame
bubbleHelp.hide()
......
......@@ -2149,6 +2149,7 @@ void TimelineController::grabCurrent()
}
std::unordered_set<int> ids = m_model->getCurrentSelection();
std::unordered_set<int> items_list;
int mainId = -1;
for (int i : ids) {
if (m_model->isGroup(i)) {
std::unordered_set<int> children = m_model->m_groups->getLeaves(i);
......@@ -2158,6 +2159,10 @@ void TimelineController::grabCurrent()
}
}
for (int id : items_list) {
if (mainId == -1 && m_model->getItemTrackId(id) == m_activeTrack) {
mainId = id;
continue;
}
if (m_model->isClip(id)) {
std::shared_ptr<ClipModel> clip = m_model->getClipPtr(id);
clip->setGrab(!clip->isGrabbed());
......@@ -2166,6 +2171,15 @@ void TimelineController::grabCurrent()
clip->setGrab(!clip->isGrabbed());
}
}
if (mainId > -1) {
if (m_model->isClip(mainId)) {
std::shared_ptr<ClipModel> clip = m_model->getClipPtr(mainId);
clip->setGrab(!clip->isGrabbed());
} else if (m_model->isComposition(mainId)) {
std::shared_ptr<CompositionModel> clip = m_model->getCompositionPtr(mainId);
clip->setGrab(!clip->isGrabbed());
}
}
}
int TimelineController::getItemMovingTrack(int itemId) const
......
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