trackplacer: UI change, drag markers with middle button.

This commit is contained in:
Eric S. Raymond 2008-10-18 05:45:35 +00:00
parent 6bfa38fde3
commit a6537645b9

View file

@ -53,7 +53,7 @@ This is trackplacer, an editor for visually editing sets of journey tracks on Ba
You are editing or creating a set of named tracks; at any given time there will one track that is selected for editing. For campaigns with a linear narrative there will be only one track, always selected, and you will not have to concern yourself about its name. If your campaign has a non-linear structure, you will want to create one track for each segment.
The radio buttons near the top left corner control which icon is placed by a left click. The two rightmost are special; when the trashcan is clicked a left click deletes already-placed icons, and the convert/copy icon tries to copy a nearby icon from an unselected track onto the selected one, preserving its pixel coordinates exactly. Every time you place an icon, it is added to the currently selected track.
The radio buttons near the top left corner control which icon is placed by a left click. The two rightmost are special; when the trashcan is clicked a left click deletes already-placed icons, and the convert/copy icon tries to copy a nearby icon from an unselected track onto the selected one, preserving its pixel coordinates exactly. Every time you place an icon, it is added to the currently selected track. You may also drag icons with the middle button.
The rule for adding markers to the selected track is as follows: if the two markers closest to the mouse pointer are adjacent on the track, insert the new marker between them in the track order. Otherwise, append it to the end of the track.
@ -726,16 +726,20 @@ class TracksEditor:
return False
def button_press_event(self, widget, event):
if self.pixmap is None:
return
if self.journey.selected_track() is None:
w = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK)
w.set_markup("No track to edit!")
w.run()
return
if event.button == 1 and self.pixmap != None:
a = self.action
x = int(event.x)
y = int(event.y)
self.selected = self.snap_to(x, y)
# Pick up state information whatever button is pressed
a = self.action
x = int(event.x)
y = int(event.y)
self.selected = self.snap_to(x, y)
# Event button 1 - draw
if event.button == 1:
# Skip the redraw in half the cases
self.log("Action %s at (%d, %d): feature = %s" % (self.action, x, y, self.selected))
if self.selected == None and self.action == "COPY":
@ -769,6 +773,7 @@ class TracksEditor:
self.erase_feature(widget, (a, x, y))
self.journey.remove(x, y)
self.log("Tracks are %s" % self.journey)
# If we ever implement a context menu for button 3, it goes here.
return True
def motion_notify_event(self, widget, event):
@ -780,8 +785,8 @@ class TracksEditor:
self.coordwin.set_text("(%d, %d)" % (x, y))
state = event.state
# This code enables dragging icons.
if state & gtk.gdk.BUTTON1_MASK and self.pixmap != None:
# This code enables dragging icons wit h the middle button.
if state & gtk.gdk.BUTTON2_MASK and self.pixmap != None:
if self.selected is not None:
(action, lx, ly) = self.journey[self.selected]
self.erase_feature(widget, (action, lx, ly))