Skip to content

Commit

Permalink
Adapting #3317 PR to enable CTRL to allow for adding to the current s…
Browse files Browse the repository at this point in the history
…election (for clips and transitions)
  • Loading branch information
jonoomph committed Sep 11, 2020
1 parent ada2ec8 commit cd3246e
Showing 1 changed file with 49 additions and 26 deletions.
75 changes: 49 additions & 26 deletions src/timeline/js/controllers.js
Expand Up @@ -517,10 +517,12 @@ App.controller("TimelineCtrl", function ($scope) {
// Trim clip_id
var id = clip_id.replace("clip_", "");

// Clear transitions also (if needed)
if (id !== "" && clear_selections) {
$scope.selectTransition("", clear_selections);
$scope.selectEffect("", clear_selections);
// Is CTRL pressed?
var is_ctrl = event && event.ctrlKey;

// Clear transitions selection if needed
if (id !== "" && clear_selections && !is_ctrl) {
$scope.selectTransition("", true);
}
// Call slice method and exit (don't actually select the clip)
if (id !== "" && $scope.enable_razor) {
Expand All @@ -531,18 +533,28 @@ App.controller("TimelineCtrl", function ($scope) {
// Don't actually select clip
return;
}
// Is CTRL pressed?
var is_ctrl = false;
if (event && event.ctrlKey) {
is_ctrl = true;
}

// Unselect all clips
// Update selection for clips
for (var clip_index = 0; clip_index < $scope.project.clips.length; clip_index++) {
if ($scope.project.clips[clip_index].id === id) {
$scope.project.clips[clip_index].selected = true;
if ($scope.Qt) {
timeline.addSelection(id, "clip", clear_selections);
// Invert selection if CTRL is pressed and not forced add and already selected
if (is_ctrl && clear_selections && ($scope.project.clips[clip_index].selected === true)) {
$scope.project.clips[clip_index].selected = false;
if ($scope.Qt) {
timeline.removeSelection($scope.project.clips[clip_index].id, "clip");
}
}
else {
$scope.project.clips[clip_index].selected = true;
if ($scope.Qt) {
// Do not clear selection if CTRL is pressed
if (is_ctrl) {
timeline.addSelection(id, "clip", false);
}
else {
timeline.addSelection(id, "clip", clear_selections);
}
}
}
}
else if (clear_selections && !is_ctrl) {
Expand All @@ -559,10 +571,12 @@ App.controller("TimelineCtrl", function ($scope) {
// Trim tran_id
var id = tran_id.replace("transition_", "");

// Clear clips also (if needed)
if (id !== "" && clear_selections) {
// Is CTRL pressed?
var is_ctrl = event && event.ctrlKey;

// Clear clips selection if needed
if (id !== "" && clear_selections && !is_ctrl) {
$scope.selectClip("", true);
$scope.selectEffect("", true);
}
// Call slice method and exit (don't actually select the transition)
if (id !== "" && $scope.enable_razor) {
Expand All @@ -574,18 +588,27 @@ App.controller("TimelineCtrl", function ($scope) {
return;
}

// Is CTRL pressed?
var is_ctrl = false;
if (event && event.ctrlKey) {
is_ctrl = true;
}

// Unselect all transitions
// Update selection for transitions
for (var tran_index = 0; tran_index < $scope.project.effects.length; tran_index++) {
if ($scope.project.effects[tran_index].id === id) {
$scope.project.effects[tran_index].selected = true;
if ($scope.Qt) {
timeline.addSelection(id, "transition", clear_selections);
// Invert selection if CTRL is pressed and not forced add and already selected
if (is_ctrl && clear_selections && ($scope.project.effects[tran_index].selected === true)) {
$scope.project.effects[tran_index].selected = false;
if ($scope.Qt) {
timeline.removeSelection($scope.project.effects[tran_index].id, "transition");
}
}
else {
$scope.project.effects[tran_index].selected = true;
if ($scope.Qt) {
// Do not clear selection if CTRL is pressed
if (is_ctrl) {
timeline.addSelection(id, "transition", false);
}
else {
timeline.addSelection(id, "transition", clear_selections);
}
}
}
}
else if (clear_selections && !is_ctrl) {
Expand Down

0 comments on commit cd3246e

Please sign in to comment.