Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/toolbox.py
diff options
context:
space:
mode:
authorAyush Goyal <ayush@seeta.in>2010-10-28 20:07:37 (GMT)
committer Gonzalo Odiard <godiard@sugarlabs.org>2010-10-29 12:17:24 (GMT)
commita4c7f039f0b2785bcef54b16fb0afb26064c2b5a (patch)
treeb0defabc6020f5057ff19f77b91ce29119360c47 /toolbox.py
parentd8fe531e66be80615c8947ffee74f9f92f68931a (diff)
Fixed aspect ratio mode for Shape tools (OLPC#3705)
Added fixed aspect ratio mode for line,ellipse and rectangle tool using Shift key as mask or using a keep aspect ratio checkbox from palette.This allows drawing of straight lines & 45 degree lines from line tool,circle from ellipse tool and square from rectangle tool Signed-off-by: Ayush Goyal <ayush@seeta.in>
Diffstat (limited to 'toolbox.py')
-rw-r--r--toolbox.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/toolbox.py b/toolbox.py
index 3c8ab92..ebed30f 100644
--- a/toolbox.py
+++ b/toolbox.py
@@ -855,6 +855,11 @@ class ShapesToolbar(gtk.Toolbar):
tool['fill'] = checkbutton.get_active()
self.set_tool(tool=tool)
+ def _on_keep_aspect_checkbutton_toggled(self, checkbutton, tool):
+ self._activity.area.keep_shape_ratio[tool['name']] = \
+ checkbutton.get_active()
+ self.set_tool(tool=tool)
+
def _configure_palette_shape_ellipse(self):
logging.debug('Creating palette to shape ellipse')
self._create_simple_palette(self._shape_ellipse, self._SHAPE_ELLIPSE)
@@ -991,6 +996,14 @@ class ShapesToolbar(gtk.Toolbar):
size_spinbutton.connect('value-changed',
self._on_line_size_value_changed, tool)
+ if tool['name'] in ['rectangle', 'ellipse', 'line']:
+ keep_aspect_checkbutton = gtk.CheckButton(_('Keep Aspect'))
+ ratio = self._activity.area.keep_shape_ratio[tool['name']]
+ keep_aspect_checkbutton.set_active(ratio)
+ keep_aspect_checkbutton.connect('toggled',
+ self._on_keep_aspect_checkbutton_toggled, tool)
+ palette.content_box.pack_start(keep_aspect_checkbutton)
+
palette.content_box.show_all()
def _configure_palette_shape_line(self):