def _dragProgressCb(self, action, actor, delta_x, delta_y): # We can't use delta_x here because it fluctuates weirdly. if not self.gotDragged: self.gotDragged = True self._context = EditingContext(self.bElement, self.timeline.bTimeline, None, GES.Edge.EDGE_NONE, None, self.timeline._container.app.action_log) mode = self.timeline._container.getEditionMode() self._context.setMode(mode) coords = self.dragAction.get_motion_coords() delta_x = coords[0] - self.dragBeginStartX delta_y = coords[1] - self.dragBeginStartY y = coords[1] + self.timeline._container.point.y priority = self._getLayerForY(y) new_start = self._dragBeginStart + self.pixelToNs(delta_x) self.ghostclip.props.x = max(0, self.nsToPixel(self._dragBeginStart) + delta_x) self.ghostclip.update(priority, y, False) if self.brother: self.brother.ghostclip.props.x = max(0, self.nsToPixel(self._dragBeginStart) + delta_x) self.brother.ghostclip.update(priority, y, True) if not self.ghostclip.props.visible: self._context.editTo(new_start, self.bElement.get_parent().get_layer().get_priority()) else: self._context.editTo(self._dragBeginStart, self.bElement.get_parent().get_layer().get_priority()) self.timeline._updateSize(self.ghostclip) return False
def _dragBeginCb(self, action, actor, event_x, event_y, modifiers): mode = self.timeline._container.getEditionMode() self._context = EditingContext( self.bElement, self.timeline.bTimeline, mode, GES.Edge.EDGE_NONE, self.timeline.selection.getSelectedTrackElements(), None) # This can't change during a drag, so we can safely compute it now for drag events. nbrLayers = len(self.timeline.bTimeline.get_layers()) self.brother = self.timeline.findBrother(self.bElement) self._dragBeginStart = self.bElement.get_start() self.dragBeginStartX = event_x self.dragBeginStartY = event_y self.nbrLayers = nbrLayers self.ghostclip.setNbrLayers(nbrLayers) self.ghostclip.setWidth(self.props.width) if self.brother: self.brother.ghostclip.setWidth(self.props.width) self.brother.ghostclip.setNbrLayers(nbrLayers) # We can also safely find if the object has a brother element self.setDragged(True)
def _dragBeginCb(self, action, actor, event_x, event_y, modifiers): self.dragBeginStartX = event_x self.dragBeginStartY = event_y elem = self.timelineElement.bElement.get_parent() self.timelineElement.setDragged(True) if self.isLeft: edge = GES.Edge.EDGE_START self._dragBeginStart = self.timelineElement.bElement.get_parent( ).get_start() else: edge = GES.Edge.EDGE_END self._dragBeginStart = self.timelineElement.bElement.get_parent().get_duration() + \ self.timelineElement.bElement.get_parent().get_start() self._context = EditingContext(elem, self.timelineElement.timeline.bTimeline, GES.EditMode.EDIT_TRIM, edge, set([]), None) self._context.connect("clip-trim", self.clipTrimCb) self._context.connect("clip-trim-finished", self.clipTrimFinishedCb)
def __check_with_video(self, clip, expected): context = EditingContext(clip, None, None, None, None, None) if expected: self.assertTrue(context.with_video) else: self.assertFalse(context.with_video)