Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Desenho.py
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-07-04 22:09:44 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-08-10 13:49:29 (GMT)
commit292668290231e966bbc3629bd75f5c3853648ec4 (patch)
treef483c2f2a9c4de62d10009b9401dd1453a209a91 /Desenho.py
parent16c5b2406cac683eb7009ae84f0c6a4db36cf7c7 (diff)
Initial phase of clipboard operations ported to cairo
Copy, paste and move operations are implemented. NOTES: * Change size of selection is not implemented in this patch. * A refactoring was done to do the code easier to understand. Previously, the Area.selmove was used to check if a selection is in progress. Now only to check if a area is being moved. A selection is detected using Area.is_selected(). The propery selmove now is private _selmove. The selected area now should be obtained using Area.get_selection_bounds(), and not using Area.orig_x, Area.orig_y and the selection size. This properties should be removed after finish refactoring. The property Area.sel_get_out was removed. Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'Desenho.py')
-rw-r--r--Desenho.py50
1 files changed, 27 insertions, 23 deletions
diff --git a/Desenho.py b/Desenho.py
index da5196a..ab791ff 100644
--- a/Desenho.py
+++ b/Desenho.py
@@ -203,9 +203,7 @@ class Desenho:
size = widget.tool['line size']
shape = widget.tool['line shape']
if shape == 'circle':
- logging.error('trace circle')
if last:
- logging.error('trace circle last')
widget.drawing_ctx.set_line_width(size)
widget.drawing_ctx.set_line_cap(cairo.LINE_CAP_ROUND)
@@ -289,6 +287,7 @@ class Desenho:
width, height = widget.window.get_size()
ctx.save()
+ ctx.new_path()
ctx.move_to(*points[0])
for point in points:
ctx.line_to(*point)
@@ -584,7 +583,6 @@ class Desenho:
@param self -- Desenho.Desenho instance
@param widget -- Area object (GtkDrawingArea)
@param coords -- Two value tuple
- @param fill -- Fill object
"""
width, height = widget.window.get_size()
@@ -593,7 +591,7 @@ class Desenho:
widget.set_selection_bounds(x, y, dx, dy)
widget.queue_draw()
- def moveSelection(self, widget, coords):
+ def move_selection(self, widget, coords):
"""Move the selection.
@param self -- Desenho.Desenho instance
@@ -603,28 +601,35 @@ class Desenho:
@param pixbuf_copy -- For import image
"""
-
- width, height = widget.window.get_size()
-
- widget.pixmap_temp.draw_drawable(widget.gc, widget.pixmap,
- 0, 0, 0, 0, width, height)
+ widget.desenha = True
dx = int(coords[0] - widget.oldx)
dy = int(coords[1] - widget.oldy)
- size = widget.pixmap_sel.get_size()
-
- widget.pixmap_temp.draw_drawable(widget.gc, widget.pixmap_sel,
- 0, 0, widget.orig_x + dx, widget.orig_y + dy, size[0], size[1])
-
- widget.set_selection_bounds(widget.orig_x + dx, widget.orig_y + dy,
- size[0], size[1])
-
-# widget.pixmap_temp.draw_rectangle(widget.gc_selection, False,
-# widget.orig_x + dx, widget.orig_y + dy, size[0], size[1])
-# widget.pixmap_temp.draw_rectangle(widget.gc_selection1, False,
-# widget.orig_x + dx - 1, widget.orig_y + dy - 1,
-# size[0] + 2, size[1] + 2)
+ x, y, width, height = widget.get_selection_bounds()
+
+ if widget.pending_clean_selection_background:
+ # clear the selection background
+ logging.error('clean background %s', (x, y, width, height))
+ widget.drawing_ctx.save()
+ widget.drawing_ctx.new_path()
+ widget.drawing_ctx.rectangle(x, y, width, height)
+ widget.drawing_ctx.set_source_rgb(1.0, 1.0, 1.0)
+ widget.drawing_ctx.fill()
+ widget.drawing_ctx.restore()
+ widget.pending_clean_selection_background = False
+
+ selection_surface = widget.get_selection()
+ widget.oldx = coords[0]
+ widget.oldy = coords[1]
+
+ new_x, new_y = x + dx, y + dy
+ widget.temp_ctx.save()
+ widget.temp_ctx.translate(new_x, new_y)
+ widget.temp_ctx.set_source_surface(selection_surface)
+ widget.temp_ctx.paint()
+ widget.temp_ctx.restore()
+ widget.set_selection_bounds(new_x, new_y, width, height)
widget.queue_draw()
@@ -638,7 +643,6 @@ class Desenho:
"""
width, height = widget.window.get_size()
widget.desenha = True
- widget.selmove = True
#Create the pixbuf for future resizes
try: