Author: esr
Date: Sun Oct 12 16:02:16 2008
New Revision: 30086

URL: http://svn.gna.org/viewcvs/wesnoth?rev=30086&view=rev
Log:
trackplacer: we can erase brush dots now.

Modified:
    trunk/data/tools/trackplacer

Modified: trunk/data/tools/trackplacer
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/trackplacer?rev=30086&r1=30085&r2=30086&view=diff
==============================================================================
--- trunk/data/tools/trackplacer (original)
+++ trunk/data/tools/trackplacer Sun Oct 12 16:02:16 2008
@@ -35,6 +35,14 @@
 journey_icon = "data/core/images/misc/new-journey.png"
 battle_icon = "data/core/images/misc/new-battle.png"
 rest_icon =  "data/core/images/misc/flag-red.png"
+
+# Size of the rectangle around the mouse pointer within which the code
+# will seek tracking dots. Should be about (N-1)/2 where N is the
+# pixel radius of the journey dot.  For this and other reasons, it's
+# helpful id the tracking dot and other icons all have a square
+# aspect ratio and an odd number of pixels on the sise, so each has
+# a well-defibed center pixel.
+see_distance = 5
 
 class ReadException(exceptions.Exception):
     "Exception thrown while reading a track file."
@@ -277,32 +285,35 @@
             ys = self.map_height - y
         self.pixmap.draw_drawable(self.default_gc, self.map, x, y, x, y, xs, 
ys)
 
-
-    # Create a new backing pixmap of the appropriate size
     def configure_event(self, widget, event):
+        "Create a new backing pixmap of the appropriate size."
         x, y, width, height = widget.get_allocation()
         self.pixmap = gtk.gdk.Pixmap(widget.window, width, height)
         self.default_gc = self.drawing_area.get_style().fg_gc[gtk.STATE_NORMAL]
         self.refresh_map()
         return True
 
-    # Redraw the screen from the backing pixmap
     def expose_event(self, widget, event):
+        "Redraw the screen from the backing pixmap"
         x , y, width, height = event.area
         widget.window.draw_drawable(self.default_gc,
                                     self.pixmap, x, y, x, y, width, height)
         return False
 
-    # Draw a rectangle on the screen
-    def draw_brush(self, widget, x, y):
-        rect = (int(x-5), int(y-5), 10, 10)
-        self.pixmap.draw_rectangle(widget.get_style().black_gc, True,
-                                   rect[0], rect[1], rect[2], rect[3])
+    def draw_icon(self, widget, x, y):
+        "Draw or erase a track dot."
+        rect = (int(x-see_distance), int(y-see_distance), see_distance*2, 
see_distance*2)
+        if self.action == "DELETE":
+            self.refresh_map(*rect)
+        else:
+            self.pixmap.draw_rectangle(widget.get_style().black_gc, True,
+                                       rect[0], rect[1], rect[2], rect[3])
+            self.journey.track.append(self.action)
         widget.queue_draw_area(rect[0], rect[1], rect[2], rect[3])
 
     def button_press_event(self, widget, event):
         if event.button == 1 and self.pixmap != None:
-            self.draw_brush(widget, event.x, event.y)
+            self.draw_icon(widget, event.x, event.y)
         return True
 
     def motion_notify_event(self, widget, event):
@@ -313,8 +324,9 @@
             y = event.y
             state = event.state
 
-        if state & gtk.gdk.BUTTON1_MASK and self.pixmap != None:
-            self.draw_brush(widget, x, y)
+        # Lets you draw pixels by dragging, not the effect we want.
+        #if state & gtk.gdk.BUTTON1_MASK and self.pixmap != None:
+        #    self.draw_icon(widget, x, y)
 
         return True
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to