hello, I just started using Mypaint, and found it's really a nice
application, I like it very much.
I have a little suggestion: I use to import reference images or sketches
from different files, and I found that sometimes it would be useful to
have the possibility to re-position the imported layers, to match an
existing drawing or for similar purposes, so I added a quick and a bit
dirty way of doing it (I just had a look and got lost in the code, so
there are probably far better ways to do it, bu it's just a suggestion)
basically I would add the possibility to move a layer using
<control><shift> and arrow keys, and proportionally to zoom level, so
you can zoom in for fine tuning of displacement.
I include a patch, and I would love to have your suggestions and tips if
you think there are smarter and better way of doing it.
best to all, and thanks for your nice and impressive work
arch. francesco fantoni, modena, italy
>From 56dbd888c4b968a2c56043f9880de2e558fa7243 Mon Sep 17 00:00:00 2001
From: francesco fantoni <france...@francesco.(none)>
Date: Sat, 2 Oct 2010 12:04:48 +0200
Subject: [PATCH] added a quick and dirty possibility of moving a layer, useful when you import different size images and want to re-position them on canvas. it adds <control><shift>arrows keys
---
gui/document.py | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/gui/document.py b/gui/document.py
index aff0680..a159b66 100644
--- a/gui/document.py
+++ b/gui/document.py
@@ -81,7 +81,6 @@ class Document(object):
# Context actions are also added in init_context_actions
('ContextStore', None, _('Save to Most Recently Restored'), 'q', None, self.context_cb),
-
('ClearLayer', gtk.STOCK_CLEAR, _('Clear'), 'Delete', None, self.clear_layer_cb),
('CopyLayer', gtk.STOCK_COPY, _('Copy to Clipboard'), '<control>C', None, self.copy_cb),
('PasteLayer', gtk.STOCK_PASTE, _('Paste Clipboard (Replace Layer)'), '<control>V', None, self.paste_cb),
@@ -170,6 +169,11 @@ class Document(object):
kbm.add_extra_key('Down', lambda(action): self.pan('PanDown'))
kbm.add_extra_key('Up', lambda(action): self.pan('PanUp'))
+ kbm.add_extra_key('<control><shift>Left', lambda(action): self.drag_layer('Left'))
+ kbm.add_extra_key('<control><shift>Right', lambda(action): self.drag_layer('Right'))
+ kbm.add_extra_key('<control><shift>Down', lambda(action): self.drag_layer('Down'))
+ kbm.add_extra_key('<control><shift>Up', lambda(action): self.drag_layer('Up'))
+
kbm.add_extra_key('<control>Left', 'RotateLeft')
kbm.add_extra_key('<control>Right', 'RotateRight')
@@ -208,6 +212,25 @@ class Document(object):
self.model.load_layer_from_pixbuf(pixbuf, x, y)
cb.request_image(callback)
+ def drag_layer(self, command):
+ # moves current layer by a variable amount of space, according to zoom level, using <control><shift> arrows
+ step = min(self.tdw.window.get_size()) / (10*self.zoomlevel)
+ if command == 'Left' : dx, dy = (-step, 0)
+ elif command == 'Right': dx, dy = (+step, 0)
+ elif command == 'Up' : dx, dy = (0, -step)
+ elif command == 'Down' : dx, dy = (0, +step)
+ else: dx, dy = (0,0)
+ bbox = self.model.get_bbox()
+ if bbox.w == 0 or bbox.h == 0:
+ print "WARNING: empty document, nothing to move"
+ return
+ else:
+ pixbuf = self.model.layer.surface.render_as_pixbuf(*bbox)
+ x = bbox.x + dx
+ y = bbox.y + dy
+ self.model.clear_layer()
+ self.model.load_layer_from_pixbuf(pixbuf, x, y)
+
def brush_modified_cb(self):
# called at every brush setting modification, should return fast
self.model.set_brush(self.app.brush)
--
1.7.0.4
_______________________________________________
Mypaint-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/mypaint-discuss