split clip at position

This commit is contained in:
j 2015-10-04 16:08:44 +01:00
parent 078be8e98f
commit 5bdc80a24f

View file

@ -235,7 +235,7 @@ Ox.ClipPanel = function(options, self) {
that.selectClip();
self.$list.gainFocus();
} else if (data.id == 'splitclip') {
// ...
splitClip();
} else if (data.id == 'split') {
splitClips();
} else if (data.id == 'join') {
@ -454,6 +454,13 @@ Ox.ClipPanel = function(options, self) {
'delete': function(data) {
self.options.editable && that.triggerEvent('delete', data);
},
key_backslash: function(data) {
that.selectClip();
self.$list.gainFocus();
},
key_shift_backslash: function(data) {
splitClip();
},
move: function(data) {
data.ids.forEach(function(id, index) {
self.$list.value(id, 'index', index);
@ -586,6 +593,30 @@ Ox.ClipPanel = function(options, self) {
self.$list.options({selected: self.options.selected});
}
function splitClip() {
that.selectClip();
var index;
Ox.forEach(self.options.clips, function(clip, i) {
if (clip.position <= self.options.position) {
index = i
} else {
return false; // break
}
});
var clip = self.options.clips[index];
if (clip) {
var position = self.options.position - clip.position + clip['in'];
if (position != clip['in'] && position != clip['out']) {
var ids = [clip.id];
var split = [
{'in': clip['in'], 'out': position, 'item': clip.item},
{'in': position, 'out': clip['out'], 'item': clip.item}
];
that.triggerEvent('split', {ids: ids, split: split});
}
}
}
function splitClips() {
var ids = getEditable(self.options.selected).filter(function(id) {
var clip = Ox.getObjectById(self.options.clips, id);