video edit panel: add getClipSelection method (clips selected in list or - potentially cut and dereferenced - clips selected in in-to-out)
This commit is contained in:
parent
d3fc02e344
commit
d2718c2ec1
1 changed files with 41 additions and 0 deletions
|
@ -361,6 +361,7 @@ Ox.VideoEditPanel = function(options, self) {
|
|||
resize: resizeClips,
|
||||
resizeend: resizeendClips,
|
||||
select: function(data) {
|
||||
self.options.selected = data;
|
||||
that.triggerEvent('select', data);
|
||||
},
|
||||
sort: function(data) {
|
||||
|
@ -420,6 +421,39 @@ Ox.VideoEditPanel = function(options, self) {
|
|||
return Ox.getObjectById(self.options.clips, id);
|
||||
}
|
||||
|
||||
function getClipsInSelection() {
|
||||
// FIXME: there should be a library function (intersect?) for this
|
||||
var clips = self.options.clips.filter(function(clip) {
|
||||
var endPosition = clip.position + clip.duration;
|
||||
return (
|
||||
clip.position >= self.options['in']
|
||||
&& endPosition < self.options.out
|
||||
) || (
|
||||
clip.position <= self.options['in']
|
||||
&& endPosition > self.options['in']
|
||||
) || (
|
||||
clip.position < self.options.out
|
||||
&& endPosition >= self.options.out
|
||||
)
|
||||
});
|
||||
return clips.map(function(clip, index) {
|
||||
var dereference = false,
|
||||
endPosition = clip.position + clip.duration,
|
||||
inPoint = clip['in'],
|
||||
outPoint = clip.out;
|
||||
if (index == 0 && clip.position < self.options['in']) {
|
||||
dereference = true;
|
||||
inPoint = Ox.round(clip['in'] + self.options['in'] - clip.position, 3);
|
||||
}
|
||||
if (index == clips.length - 1 && endPosition > self.options.out) {
|
||||
dereference = true;
|
||||
outPoint = Ox.round(clip.out + self.options.out - endPosition, 3);
|
||||
}
|
||||
return clip.annotation && !dereference ? clip.annotation
|
||||
: clip.item + '/' + inPoint + '-' + outPoint;
|
||||
});
|
||||
}
|
||||
|
||||
function getCuts() {
|
||||
var cuts = [];
|
||||
self.options.clips.forEach(function(clip, i) {
|
||||
|
@ -591,6 +625,13 @@ Ox.VideoEditPanel = function(options, self) {
|
|||
});
|
||||
}
|
||||
|
||||
that.getClipSelection = function() {
|
||||
return self.options.selected.length ? self.options.selected.map(function(id) {
|
||||
var clip = getClipById(id);
|
||||
return clip.annotation || clip.item + '/' + clip['in'] + '-' + clip.out;
|
||||
}) : getClipsInSelection();
|
||||
};
|
||||
|
||||
that.invertSelection = function() {
|
||||
self.$clipPanel.invertSelection();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue