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:
rolux 2014-02-07 05:44:39 +00:00
parent d3fc02e344
commit d2718c2ec1

View file

@ -361,6 +361,7 @@ Ox.VideoEditPanel = function(options, self) {
resize: resizeClips, resize: resizeClips,
resizeend: resizeendClips, resizeend: resizeendClips,
select: function(data) { select: function(data) {
self.options.selected = data;
that.triggerEvent('select', data); that.triggerEvent('select', data);
}, },
sort: function(data) { sort: function(data) {
@ -420,6 +421,39 @@ Ox.VideoEditPanel = function(options, self) {
return Ox.getObjectById(self.options.clips, id); 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() { function getCuts() {
var cuts = []; var cuts = [];
self.options.clips.forEach(function(clip, i) { 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() { that.invertSelection = function() {
self.$clipPanel.invertSelection(); self.$clipPanel.invertSelection();
}; };