From 03470f034404972c1e77607b6974048b912dba6e Mon Sep 17 00:00:00 2001 From: Gonzalo Odiard Date: Wed, 31 Oct 2012 19:29:05 +0000 Subject: Fix freeform tool use with touch - part of SL#4074 To do easier show where the freeform will be closed, a circle is displayed. Signed-off-by: Gonzalo Odiard --- diff --git a/Area.py b/Area.py index e717706..2c0b886 100644 --- a/Area.py +++ b/Area.py @@ -429,7 +429,6 @@ class Area(Gtk.DrawingArea): self.tool_end(x, y, shift_pressed) def tool_start(self, coord_x, coord_y, button1_pressed): - logging.error('tool start') width, height = self.get_size() # text design_mode = True @@ -537,16 +536,15 @@ class Area(Gtk.DrawingArea): # add the tool size if self.tool['name'] == 'stamp': wr, hr = self.stamp_dimentions - min_x = min_x - wr - min_y = min_y - wr - max_x = max_x + hr - max_y = max_y + hr + elif self.tool['name'] == 'freeform': + wr = hr = 20 else: - size = self.tool['line size'] - min_x = min_x - size * 2 - min_y = min_y - size * 2 - max_x = max_x + size * 2 - max_y = max_y + size * 2 + wr = hr = self.tool['line size'] * 2 + min_x = min_x - wr + min_y = min_y - wr + max_x = max_x + hr + max_y = max_y + hr + return (min_x, min_y, max_x - min_x, max_y - min_y) def mousemove(self, widget, event): @@ -560,7 +558,6 @@ class Area(Gtk.DrawingArea): if event.get_source_device().get_name().find('touchscreen') >= 0 and \ not self._on_touch: return - logging.error('mouse move') x = event.x y = event.y shift_pressed = event.get_state() & Gdk.ModifierType.SHIFT_MASK @@ -569,7 +566,6 @@ class Area(Gtk.DrawingArea): Gdk.event_request_motions(event) def tool_move(self, x, y, button1_pressed, shift_pressed): - logging.error('tool move') self.x_cursor, self.y_cursor = int(x), int(y) @@ -696,7 +692,6 @@ class Area(Gtk.DrawingArea): (y_point < y_min) or (y_point > y_min + height)) def tool_end(self, coord_x, coord_y, shift_pressed): - logging.error('tool end') coords = (coord_x, coord_y) if self.tool['name'] in ['rectangle', 'ellipse', 'line']: if shift_pressed or self.keep_shape_ratio: @@ -776,7 +771,7 @@ class Area(Gtk.DrawingArea): # GObject.idle_add (with the fill_flood function) finishes # and an unconsistent undo state is saved self.enable_undo() - if self.tool['name'] != 'marquee-rectangular': + if self.tool['name'] not in ('marquee-rectangular', 'freeform'): self.desenha = False self.queue_draw() diff --git a/Desenho.py b/Desenho.py index b93f616..e05a907 100644 --- a/Desenho.py +++ b/Desenho.py @@ -725,7 +725,6 @@ class Desenho: @param temp -- switch between drawing context and temp context @param fill -- Fill object """ - if param == "moving": # mouse not pressed moving if self.points: @@ -756,13 +755,32 @@ class Desenho: # close the polygon self.points.append((first[0], first[1])) self._draw_polygon(widget, False, fill, self.points) + widget.desenha = False widget.last = [] self.points = [] widget.enable_undo() - widget.queue_draw() return widget.desenha = True + + if self.points: + # Draw a circle to show where the freeform start/finish + ctx = widget.temp_ctx + ctx.save() + x_init, y_init = self.points[0] + ctx.new_path() + ctx.translate(x_init, y_init) + ctx.set_line_width(1) + ctx.set_source_rgba(1., 1., 1., 1.) + ctx.set_line_cap(cairo.LINE_CAP_ROUND) + ctx.set_line_join(cairo.LINE_JOIN_ROUND) + ctx.arc(0, 0, 20, 0., 2 * math.pi) + ctx.stroke_preserve() + ctx.set_dash([5, 5], 0) + ctx.set_source_rgba(0., 0., 0., 1.) + ctx.stroke() + ctx.restore() + # Display the polygon open in the temp canvas self._draw_polygon(widget, True, False, self.points, closed=False) self.clear_control_points() -- cgit v0.9.1