[jokosher-devel] [PATCH] Patch for Launchpad bug 85938 - Usability for selection-based editing
- From: "Tom Halligan" <tom halligan gmail com>
- To: jokosher-devel-list gnome org
- Subject: [jokosher-devel] [PATCH] Patch for Launchpad bug 85938 - Usability for selection-based editing
- Date: Wed, 21 May 2008 01:55:16 +0100
Posted this to Launchpad RE: Jokosher bug #85938 at
https://bugs.launchpad.net/jokosher/+bug/85938 , thought I'd send to the mailing list too:
Small patch going part of the way to resolving this bug - splitting, cutting, copying, and deleting now works on a selection of an event rather than the entire thing from the right-click context menu.
These things still don't work from the edit menu, as Jokosher uses seperate code for the two and I haven't got round to coding the edit menu bits yet.
Also, these things work on pretty much an aesthetic level only - copying does not trim an event down to size properly (Looks ok, but plays the whole event rather than the selected portion), and various other issues related to other Jokosher bugs abound.
It looks nicer though :)
This patch was developed against Jokosher SVN from Revision 1512.
Still finding my way around the Jokosher code - lots of things seem kind of awkward, but that's for another discussion completely!
Peace
Tom
Index: /home/tom/Documents/Programming/eclipse_workspace/Jokosher/Jokosher/Event.py
===================================================================
--- /home/tom/Documents/Programming/eclipse_workspace/Jokosher/Jokosher/Event.py (revision 1512)
+++ /home/tom/Documents/Programming/eclipse_workspace/Jokosher/Jokosher/Event.py (working copy)
@@ -312,6 +312,42 @@
#_____________________________________________________________________
+ def DummySplitEvent(self, eventID=-1):
+ """
+ Only for use with a 2-point selection.
+ Essentially performs a 'fake split' and returns a new event
+ which would be the result of splitting an event at the 2 points.
+
+ This is used when the user shift-drags an event to create a selection,
+ then chooses 'copy' from the context menu. The new event can be placed
+ wherever the user wishes by right-clicking and choosing 'paste'.
+ """
+ if eventID >= 0:
+ e = [x for x in self.instrument.graveyard if x.id == eventID][0]
+ self.instrument.graveyard.remove(e)
+ else:
+ e = Event(self.instrument, self.file, self.levels_file)
+ e.name = self.name
+
+ dur = self.selection[1] - self.selection[0]
+
+ e.start = self.start + self.selection[0]
+ e.offset = self.selection[0] #+self.offset
+ e.duration = dur
+
+ millis = int(self.selection[0] * 1000)
+ e.levels_list = self.levels_list.slice_by_endtime(millis)
+
+ e.__UpdateAudioFadePoints()
+ e.SetProperties()
+ self.instrument.events.append(e)
+ e.emit("length")
+ e.emit("position")
+
+ return e
+
+
+
@UndoSystem.UndoCommand("JoinEvent", "temp", "temp2")
def SplitEvent(self, split_point, cutRightSide=True, eventID=-1):
"""
Index: /home/tom/Documents/Programming/eclipse_workspace/Jokosher/Jokosher/EventLaneViewer.py
===================================================================
--- /home/tom/Documents/Programming/eclipse_workspace/Jokosher/Jokosher/EventLaneViewer.py (revision 1512)
+++ /home/tom/Documents/Programming/eclipse_workspace/Jokosher/Jokosher/EventLaneViewer.py (working copy)
@@ -224,7 +224,7 @@
if self.popupIsActive:
self.OnMenuDone()
# Create context menu on RMB
- elif mouse.button == 3:
+ elif mouse.button == 3:
self.pasteContextMenuItem.set_sensitive( bool(self.project.clipboardList) )
self.highlightCursor = mouse.x
Index: /home/tom/Documents/Programming/eclipse_workspace/Jokosher/Jokosher/EventViewer.py
===================================================================
--- /home/tom/Documents/Programming/eclipse_workspace/Jokosher/Jokosher/EventViewer.py (revision 1512)
+++ /home/tom/Documents/Programming/eclipse_workspace/Jokosher/Jokosher/EventViewer.py (working copy)
@@ -997,7 +997,7 @@
widget -- reserved for GTK callbacks, don't use it explicitly.
mouse -- GTK mouse event that fired this method call.
"""
- if self.messageID: #clesr status bar if not already clear
+ if self.messageID: #clear status bar if not already clear
self.mainview.ClearStatusBar(self.messageID)
self.messageID = None
self.highlightCursor = None
@@ -1013,11 +1013,17 @@
gtkevent -- reserved for GTK callbacks, don't use it explicitly.
position -- The position in the event to split
"""
- if pos == 0.0:
- return
-
- pos /= float(self.project.viewScale)
- self.event.SplitEvent(pos)
+ if self.event.selection != [0,0]:
+ self.event.SplitEvent(self.event.selection[1])
+ self.event.SplitEvent(self.event.selection[0])
+ self.event.selection = [0,0]
+ self.HideDrawer()
+ else:
+ if pos == 0.0:
+ return
+ else:
+ pos /= float(self.project.viewScale)
+ self.event.SplitEvent(pos)
#_____________________________________________________________________
@@ -1028,8 +1034,16 @@
Parameters:
gtkevent -- reserved for GTK callbacks, don't use it explicitly.
"""
- self.project.clipboardList = [self.event]
- self.OnDelete()
+ if self.event.selection != [0,0]:
+ self.event.SplitEvent(self.event.selection[1])
+ e = self.event.SplitEvent(self.event.selection[0])
+ self.project.clipboardList = [e]
+ e.Delete()
+ self.event.selection = [0,0]
+ self.HideDrawer()
+ else:
+ self.project.clipboardList = [self.event]
+ self.OnDelete()
#_____________________________________________________________________
@@ -1040,7 +1054,12 @@
Parameters:
gtkevent -- reserved for GTK callbacks, don't use it explicitly.
"""
- self.project.clipboardList = [self.event]
+ if self.event.selection != [0,0]:
+ e = self.event.DummySplitEvent()
+ self.project.clipboardList = [e]
+ self.HideDrawer()
+ else:
+ self.project.clipboardList = [self.event]
#_____________________________________________________________________
@@ -1052,7 +1071,14 @@
Parameters:
event -- reserved for GTK callbacks, don't use it explicitly.
"""
- self.event.Delete()
+ if self.event.selection != [0,0]:
+ self.event.SplitEvent(self.event.selection[1])
+ e = self.event.SplitEvent(self.event.selection[0])
+ e.Delete()
+ self.event.selection = [0,0]
+ self.HideDrawer()
+ else:
+ self.event.Delete()
#_____________________________________________________________________
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]