Exemple #1
0
 def on_drag_end(self, event):
   view = self._dragging_connection_view
   self._dragging_connection_view = None
   # remove the view if it didn't form a connection
   view.finalize_connection()
   QApplication.instance().restoreOverrideCursor()
   UndoManager.end_action()
Exemple #2
0
 def on_drag_end(self, event):
     self._start_pos = None
     try:
         self._target.on_change()
     except AttributeError:
         pass
     UndoManager.end_action()
Exemple #3
0
 def on_drag_end(self, event):
   self._start_rect = None
   self._start_bounds = None
   try:
     self._target.on_change()
   except AttributeError: pass
   UndoManager.end_action()
Exemple #4
0
 def on_split(self, *args):
   current_track = None
   for track in self.tracks:
     if (self.block in track):
       current_track = track
       break
   # if the block has multiple repeats, split the repeats
   if (self.block.events.duration < self.block.duration):
     UndoManager.begin_action(track)
     self.block.split_repeats(track=current_track)
     UndoManager.end_action()
   else:
     times = [ ]
     # get selected events in the block
     selected_events = self.get_selected_notes()
     # if events are selected in the block, find boundaries 
     #  between selected and deselected events
     if (len(selected_events) > 0):
       # sort all block events by time
       events = list(self.block.events)
       events.sort(key=lambda e: e.time)
       # find boundaries
       was_selected = (events[0] in selected_events)
       for event in events:
         # count notes only
         if (not hasattr(event, 'pitch')): continue
         is_selected = (event in selected_events)
         if (is_selected != was_selected):
           times.append(event.time)
           was_selected = is_selected
     # if there are times to split on, we can split
     if (len(times) > 0):
       UndoManager.begin_action((self.block, current_track))
       self.block.split(times, track=current_track)
       UndoManager.end_action()
Exemple #5
0
 def on_drag_end(self, event):
     view = self._dragging_connection_view
     self._dragging_connection_view = None
     # remove the view if it didn't form a connection
     view.finalize_connection()
     QApplication.instance().restoreOverrideCursor()
     UndoManager.end_action()
Exemple #6
0
 def on_group(self):
   workspace_view = self.view.parentItemWithAttribute('document')
   if (workspace_view is None): return
   units = workspace_view.document.units
   selected_units = self.selected_units()
   UndoManager.begin_action(units)
   units.append(GroupUnit(units=selected_units, name='Group'))
   UndoManager.end_action()
Exemple #7
0
 def on_join(self, *args):
   blocks = self.get_selected_blocks()
   blocks.add(self.block)
   UndoManager.begin_action((blocks, self.tracks))
   if (len(blocks) > 1):
     self.block.join(blocks, tracks=self.tracks)
   else:
     self.block.join_repeats()
   UndoManager.end_action()
Exemple #8
0
 def on_delete(self, *args):
   current_track = None
   for track in self.tracks:
     if (self.block in track):
       current_track = track
       break
   if (current_track is None): return
   UndoManager.begin_action(current_track)
   current_track.remove(self.block)
   UndoManager.end_action()
Exemple #9
0
 def on_key_delete(self, event):
   root_item = self
   while root_item.parentItem():
     root_item = root_item.parentItem()
   document_view = self.parentItemWithAttribute('document')
   document = None
   if (document_view is not None):
     document = document_view.document
   UndoManager.begin_action(document)
   self._delete_selected_child_items(root_item)
   UndoManager.end_action()
Exemple #10
0
 def toggle_mark(self, *args):
   UndoManager.begin_action(self.marks)
   t = self.time
   found = False
   for mark in set(self.marks):
     if (mark.time == t):
       self.marks.remove(mark)
       found = True
   if (not found):
     self.marks.append(Mark(time=t))
   UndoManager.end_action()
Exemple #11
0
 def on_key_delete(self, event):
     root_item = self
     while root_item.parentItem():
         root_item = root_item.parentItem()
     document_view = self.parentItemWithAttribute('document')
     document = None
     if (document_view is not None):
         document = document_view.document
     UndoManager.begin_action(document)
     self._delete_selected_child_items(root_item)
     UndoManager.end_action()
Exemple #12
0
 def remove_unit(self, unit, inputs=(), outputs=()):
   units = self.units
   patch_bay = self.patch_bay
   UndoManager.begin_action((units, patch_bay, inputs, outputs))
   patch_bay.remove_connections_for_unit(unit)
   for item in inputs:
     patch_bay.remove_connections_for_unit(item)
   for item in outputs:
     patch_bay.remove_connections_for_unit(item)
   units.remove(unit)
   # remove the unit from any groups it might be a part of
   for group in units:
     if ((hasattr(group, 'units')) and (unit in group.units)):
       group.units.remove(unit)
   UndoManager.end_action()
 def change_track(self, delta):
   block = self.block
   # get the track list and track that contain this block
   tracks_view = self.parentItemWithAttribute('tracks')
   track_view = self.parentItemWithAttribute('track')
   if ((tracks_view is None) or (track_view is None)): return
   tracks = tracks_view.tracks
   current_track = track_view.track
   if (len(tracks) <= 1): return
   # get the index of the current track
   current_index = tracks.index(current_track)
   # get the new track index, and exit if it's not changing
   new_index = min(max(0, current_index + delta), len(tracks) - 1)
   if (new_index == current_index): return
   new_track = tracks[new_index]
   UndoManager.begin_action((current_track, new_track))
   # move this view into the new track layout so 
   #  it maintains its keyboard/mouse focus
   old_layout = self.parentItem()
   def find_track_layout(node, track):
     for item in node.childItems():
       if ((isinstance(item, view.ListLayout)) and 
           (hasattr(item, 'track')) and
           (item.track is track)):
         return(item)
       result = find_track_layout(item, track)
       if (result is not None): return(result)
     return(None)
   new_layout = find_track_layout(tracks_view.track_layout, new_track)
   del old_layout._view_map[block]
   new_layout._view_map[block] = self
   self.setParentItem(new_layout)
   # move the block in the model layer
   current_track.remove(block)
   new_track.append(block)
   UndoManager.end_action()    
Exemple #14
0
 def on_record_stop(self):
   UndoManager.end_action(group='record')
Exemple #15
0
 def on_add(self):
   UndoManager.begin_action(self.unit.tracks)
   self.unit.tracks.add_track()
   UndoManager.end_action()
Exemple #16
0
 def on_change_path(self, path):
   UndoManager.begin_action(self.instrument)
   self.instrument.path = path
   UndoManager.end_action()
Exemple #17
0
 def add_unit(self, new_unit):
   UndoManager.begin_action(self.units)
   self.units.append(new_unit)
   UndoManager.end_action()
Exemple #18
0
 def on_drag_end(self, event):
   self.finalize_connection()
   QApplication.instance().restoreOverrideCursor()
   UndoManager.end_action()
Exemple #19
0
 def on_browse(self):
   UndoManager.begin_action(self.instrument)
   self.instrument.browse()
   UndoManager.end_action()
 def on_drag_end(self, event):
   UndoManager.end_action()
Exemple #21
0
 def focusOutEvent(self, e):
     EditableLabel.focusOutEvent(self, e)
     UndoManager.end_action()
Exemple #22
0
 def focusOutEvent(self, e):
   EditableLabel.focusOutEvent(self, e)
   UndoManager.end_action()
Exemple #23
0
 def on_remove(self):
   UndoManager.begin_action((self.instruments, self.document))
   if (self.document is not None):
     self.document.patch_bay.remove_connections_for_unit(self.instrument)
   self.instruments.remove(self.instrument)
   UndoManager.end_action()
Exemple #24
0
 def on_drag_end_x(self, event):
     self._drag_start_times = dict()
     UndoManager.end_action()
Exemple #25
0
 def on_add(self):
   instrument = sampler.Instrument.new_from_browse()
   if (instrument is None): return
   UndoManager.begin_action(self._content.instruments)
   self._content.instruments.append(instrument)
   UndoManager.end_action()
 def on_record_stop(self):
     UndoManager.end_action(group='record')
Exemple #27
0
 def on_drag_end(self, event):
     self.finalize_connection()
     QApplication.instance().restoreOverrideCursor()
     UndoManager.end_action()
 def on_drag_end(self, event):
   view.Interactive.on_drag_end(self, event)
   UndoManager.end_action(group='drag_block')
Exemple #29
0
 def on_delete(self, *args):
   UndoManager.begin_action((self.tracks, self.patch_bay))
   self.tracks.remove(self.track)
   UndoManager.end_action()
Exemple #30
0
 def on_drag_end_y(self, event):
     self._drag_start_pitches = dict()
     UndoManager.end_action()
 def on_add(self):
     UndoManager.begin_action(self.unit.tracks)
     self.unit.tracks.add_track()
     UndoManager.end_action()
Exemple #32
0
 def on_drag_end_x(self, event):
   self._drag_start_times = dict()
   UndoManager.end_action()
Exemple #33
0
 def on_drag_end_y(self, event):
   self._drag_start_pitches = dict()
   UndoManager.end_action()
 def on_add(self):
     instrument = sampler.Instrument.new_from_browse()
     if (instrument is None): return
     UndoManager.begin_action(self._content.instruments)
     self._content.instruments.append(instrument)
     UndoManager.end_action()