Skip to content

Commit cd3246e

Browse files
committed
Adapting #3317 PR to enable CTRL to allow for adding to the current selection (for clips and transitions)
1 parent ada2ec8 commit cd3246e

File tree

1 file changed

+49
-26
lines changed

1 file changed

+49
-26
lines changed

src/timeline/js/controllers.js

+49-26
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,12 @@ App.controller("TimelineCtrl", function ($scope) {
517517
// Trim clip_id
518518
var id = clip_id.replace("clip_", "");
519519

520-
// Clear transitions also (if needed)
521-
if (id !== "" && clear_selections) {
522-
$scope.selectTransition("", clear_selections);
523-
$scope.selectEffect("", clear_selections);
520+
// Is CTRL pressed?
521+
var is_ctrl = event && event.ctrlKey;
522+
523+
// Clear transitions selection if needed
524+
if (id !== "" && clear_selections && !is_ctrl) {
525+
$scope.selectTransition("", true);
524526
}
525527
// Call slice method and exit (don't actually select the clip)
526528
if (id !== "" && $scope.enable_razor) {
@@ -531,18 +533,28 @@ App.controller("TimelineCtrl", function ($scope) {
531533
// Don't actually select clip
532534
return;
533535
}
534-
// Is CTRL pressed?
535-
var is_ctrl = false;
536-
if (event && event.ctrlKey) {
537-
is_ctrl = true;
538-
}
539536

540-
// Unselect all clips
537+
// Update selection for clips
541538
for (var clip_index = 0; clip_index < $scope.project.clips.length; clip_index++) {
542539
if ($scope.project.clips[clip_index].id === id) {
543-
$scope.project.clips[clip_index].selected = true;
544-
if ($scope.Qt) {
545-
timeline.addSelection(id, "clip", clear_selections);
540+
// Invert selection if CTRL is pressed and not forced add and already selected
541+
if (is_ctrl && clear_selections && ($scope.project.clips[clip_index].selected === true)) {
542+
$scope.project.clips[clip_index].selected = false;
543+
if ($scope.Qt) {
544+
timeline.removeSelection($scope.project.clips[clip_index].id, "clip");
545+
}
546+
}
547+
else {
548+
$scope.project.clips[clip_index].selected = true;
549+
if ($scope.Qt) {
550+
// Do not clear selection if CTRL is pressed
551+
if (is_ctrl) {
552+
timeline.addSelection(id, "clip", false);
553+
}
554+
else {
555+
timeline.addSelection(id, "clip", clear_selections);
556+
}
557+
}
546558
}
547559
}
548560
else if (clear_selections && !is_ctrl) {
@@ -559,10 +571,12 @@ App.controller("TimelineCtrl", function ($scope) {
559571
// Trim tran_id
560572
var id = tran_id.replace("transition_", "");
561573

562-
// Clear clips also (if needed)
563-
if (id !== "" && clear_selections) {
574+
// Is CTRL pressed?
575+
var is_ctrl = event && event.ctrlKey;
576+
577+
// Clear clips selection if needed
578+
if (id !== "" && clear_selections && !is_ctrl) {
564579
$scope.selectClip("", true);
565-
$scope.selectEffect("", true);
566580
}
567581
// Call slice method and exit (don't actually select the transition)
568582
if (id !== "" && $scope.enable_razor) {
@@ -574,18 +588,27 @@ App.controller("TimelineCtrl", function ($scope) {
574588
return;
575589
}
576590

577-
// Is CTRL pressed?
578-
var is_ctrl = false;
579-
if (event && event.ctrlKey) {
580-
is_ctrl = true;
581-
}
582-
583-
// Unselect all transitions
591+
// Update selection for transitions
584592
for (var tran_index = 0; tran_index < $scope.project.effects.length; tran_index++) {
585593
if ($scope.project.effects[tran_index].id === id) {
586-
$scope.project.effects[tran_index].selected = true;
587-
if ($scope.Qt) {
588-
timeline.addSelection(id, "transition", clear_selections);
594+
// Invert selection if CTRL is pressed and not forced add and already selected
595+
if (is_ctrl && clear_selections && ($scope.project.effects[tran_index].selected === true)) {
596+
$scope.project.effects[tran_index].selected = false;
597+
if ($scope.Qt) {
598+
timeline.removeSelection($scope.project.effects[tran_index].id, "transition");
599+
}
600+
}
601+
else {
602+
$scope.project.effects[tran_index].selected = true;
603+
if ($scope.Qt) {
604+
// Do not clear selection if CTRL is pressed
605+
if (is_ctrl) {
606+
timeline.addSelection(id, "transition", false);
607+
}
608+
else {
609+
timeline.addSelection(id, "transition", clear_selections);
610+
}
611+
}
589612
}
590613
}
591614
else if (clear_selections && !is_ctrl) {

0 commit comments

Comments
 (0)