Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/widgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'widgets.py')
-rw-r--r--widgets.py53
1 files changed, 20 insertions, 33 deletions
diff --git a/widgets.py b/widgets.py
index 50be573..36d5327 100644
--- a/widgets.py
+++ b/widgets.py
@@ -30,8 +30,7 @@ class BrushButton(_ColorButton):
self._brush_size = 2
self._stamp_size = 20
self._brush_shape = 'circle'
- self._stamping = False
- self._pixbuf_stamp = None
+ self._resized_stamp = None
self._preview = gtk.DrawingArea()
self._preview.set_size_request(style.STANDARD_ICON_SIZE,
style.STANDARD_ICON_SIZE)
@@ -96,13 +95,15 @@ class BrushButton(_ColorButton):
stamp_size = gobject.property(type=int, getter=get_stamp_size,
setter=set_stamp_size)
- def set_stamping(self, stamping):
- # receive True or False
- self._stamping = stamping
+ def set_resized_stamp(self, resized_stamp):
+ self._resized_stamp = resized_stamp
+
+ def stop_stamping(self):
+ self._resized_stamp = None
self._preview.queue_draw()
def is_stamping(self):
- return self._stamping
+ return self._resized_stamp != None
def expose(self, widget, event):
if self._gc is None:
@@ -114,15 +115,10 @@ class BrushButton(_ColorButton):
True, 0, 0, style.STANDARD_ICON_SIZE, style.STANDARD_ICON_SIZE)
self._gc.set_foreground(self._color)
- if self._stamping:
- w = self._pixbuf_stamp.get_width()
- h = self._pixbuf_stamp.get_height()
- wr, hr = self._stamp_size, int(self._stamp_size * h * 1.0 / w)
- resized_stamp = self._pixbuf_stamp.scale_simple(wr, hr, gtk.gdk.INTERP_HYPER)
-
- width = resized_stamp.get_width()
- height = resized_stamp.get_height()
- self.pixmap.draw_pixbuf(self._gc, resized_stamp,
+ if self.is_stamping():
+ width = self._resized_stamp.get_width()
+ height = self._resized_stamp.get_height()
+ self.pixmap.draw_pixbuf(self._gc, self._resized_stamp,
0, 0, center - width / 2, center - height / 2, width, height)
else:
@@ -178,12 +174,6 @@ class ButtonStrokeColor(gtk.ToolItem):
def __init__(self, activity, **kwargs):
self._activity = activity
self.properties = self._activity.area.tool
-
- # This determines if the stamping tool is in use, if True the
- # size changes the stamping size, else it changes the brush
- # size:
- self._stamping = False
-
self._accelerator = None
self._tooltip = None
self._palette_invoker = ToolInvoker()
@@ -272,12 +262,12 @@ class ButtonStrokeColor(gtk.ToolItem):
style.SMALL_ICON_SIZE)
image2.set_from_pixbuf(pixbuf2)
item2.set_image(image2)
-
+
item1.connect('toggled', self._on_toggled, self.properties, 'circle')
item2.connect('toggled', self._on_toggled, self.properties, 'square')
-
+
label = gtk.Label(_('Shape'))
-
+
self.vbox_brush_options.pack_start(label)
self.vbox_brush_options.pack_start(item1)
self.vbox_brush_options.pack_start(item2)
@@ -301,7 +291,7 @@ class ButtonStrokeColor(gtk.ToolItem):
def _update_palette(self):
palette_children = self._palette._picker_hbox.get_children()
- if self._stamping:
+ if self.color_button.is_stamping():
# Hide palette color widgets:
for ch in palette_children[:4]:
ch.hide_all()
@@ -321,22 +311,19 @@ class ButtonStrokeColor(gtk.ToolItem):
self._palette._picker_hbox.resize_children()
self._palette._picker_hbox.queue_draw()
- def set_stamping(self, stamping):
- self._stamping = stamping
- self.color_button.set_stamping(stamping)
- if stamping:
+ def update_stamping(self):
+ if self.color_button.is_stamping():
self.size_spinbutton.set_value(self.color_button.stamp_size)
else:
self.size_spinbutton.set_value(self.color_button.brush_size)
self._update_palette()
- def is_stamping(self):
- return self._stamping
-
def _on_value_changed(self, spinbutton):
size = spinbutton.get_value_as_int()
- if self.is_stamping():
+ if self.color_button.is_stamping():
self.properties['stamp size'] = size
+ resized_stamp = self._activity.area.resizeStamp(size)
+ self.color_button.set_resized_stamp(resized_stamp)
self.color_button.set_stamp_size(self.properties['stamp size'])
else:
self.properties['line size'] = size