diff --git a/source/Ox.UI/js/Video/VideoEditPanel.js b/source/Ox.UI/js/Video/VideoEditPanel.js index 2f9f4740..265dc3df 100644 --- a/source/Ox.UI/js/Video/VideoEditPanel.js +++ b/source/Ox.UI/js/Video/VideoEditPanel.js @@ -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(); };