clip panel: add selectClipAtPosition

This commit is contained in:
rolux 2014-02-12 13:39:50 +05:30
parent f538cf2b0b
commit 5fae9d2213

View file

@ -41,6 +41,9 @@ Ox.ClipPanel = function(options, self) {
sort: getListSort(), sort: getListSort(),
sortable: isSortable() sortable: isSortable()
}); });
self.$menu[
self.options.clips.length ? 'enableItem' : 'disableItem'
]('select');
updateStatus(); updateStatus();
}, },
duration: updateStatus, duration: updateStatus,
@ -170,11 +173,11 @@ Ox.ClipPanel = function(options, self) {
{id: 'annotations', title: Ox._('View Annotations'), checked: self.options.view == 'annotations'}, {id: 'annotations', title: Ox._('View Annotations'), checked: self.options.view == 'annotations'},
]}, ]},
{}, {},
{id: 'select', title: 'Select Clip at Current Position', disabled: true}, {id: 'select', title: 'Select Clip at Current Position', disabled: self.options.clips.length == 0},
{}, {},
{id: 'split', title: Ox._('Split Selected Clips at Cuts'), disabled: !self.options.editable || !self.options.selected.length || self.options.view == 'annotations'}, {id: 'split', title: Ox._('Split Selected Clips at Cuts'), disabled: !self.options.editable || self.options.selected.length == 0 || self.options.view == 'annotations'},
{id: 'join', title: Ox._('Join Selected Clips at Cuts'), disabled: !self.options.editable || self.options.selected.length < 2 || self.options.view == 'annotations'}, {id: 'join', title: Ox._('Join Selected Clips at Cuts'), disabled: !self.options.editable || self.options.selected.length < 2 || self.options.view == 'annotations'},
{id: 'replace', title: Ox._('Make Selected Clips Editable'), disabled: !self.options.editable || !self.options.selected.length || self.options.view == 'annotations'} {id: 'replace', title: Ox._('Make Selected Clips Editable'), disabled: !self.options.editable || self.options.selected.length == 0 || self.options.view == 'annotations'}
], ],
title: 'set', title: 'set',
tooltip: Ox._('Options'), tooltip: Ox._('Options'),
@ -518,7 +521,7 @@ Ox.ClipPanel = function(options, self) {
} }
}); });
if (joined) { if (joined) {
return false; // brea; return false; // break;
} }
}); });
} while (joined); } while (joined);
@ -531,6 +534,19 @@ Ox.ClipPanel = function(options, self) {
} }
} }
function selectClipAtPosition() {
var index;
Ox.forEach(self.options.clips, function(clip, i) {
index = i;
if (clip.position + clip.duration < self.options.position) {
return false; // break
}
});
self.options.selected = [self.options.clips[index].id];
selectClips();
that.triggerEvent('select', {ids: self.options.selected});
}
function selectClips() { function selectClips() {
if (self.options.editable) { if (self.options.editable) {
self.$menu[ self.$menu[