From 2a534fb3fce51434288c5913f2fb183d5ebca5ed Mon Sep 17 00:00:00 2001 From: Pootle daemon Date: Sat, 23 Feb 2013 05:31:19 +0000 Subject: Merge branch 'master' of git.sugarlabs.org:turtleart/mainline --- diff --git a/NEWS b/NEWS index 9a1c358..735bd73 100644 --- a/NEWS +++ b/NEWS @@ -1,9 +1,17 @@ +173 + +ENHANCEMENTS: +* Increase expand/shrink dots touch + 172 ENHANCEMENTS: * Prevent rearrangement of blocks while program is running * New translations +BUG FIX: +* Detect XO hardware on some old systems + 171 ENHANCEMENTS: diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py index ffa07a2..1416a61 100644 --- a/TurtleArt/tabasics.py +++ b/TurtleArt/tabasics.py @@ -571,7 +571,7 @@ tasetshade :shade \r') primitive_dictionary['minus'] = self._prim_minus palette.add_block('minus2', style='number-style-porch', - label='–', + label=' –', special_name=_('minus'), prim_name='minus', logo_command='taminus', @@ -597,7 +597,7 @@ minus :y\rend\r') primitive_dictionary['division'] = self._prim_careful_divide palette.add_block('division2', style='number-style-porch', - label='/', + label=' /', special_name=_('divide'), prim_name='division', logo_command='quotient', @@ -666,7 +666,7 @@ operators')) primitive_dictionary['more'] = self._prim_more palette.add_block('greater2', style='compare-porch-style', - label='>', + label=' >', string_or_number=True, special_name=_('greater than'), prim_name='greater?', @@ -679,7 +679,7 @@ operators')) primitive_dictionary['less'] = self._prim_less palette.add_block('less2', style='compare-porch-style', - label='<', + label=' <', special_name=_('less than'), string_or_number=True, prim_name='less?', diff --git a/TurtleArt/tablock.py b/TurtleArt/tablock.py index 3f64066..6b9e5be 100644 --- a/TurtleArt/tablock.py +++ b/TurtleArt/tablock.py @@ -866,7 +866,7 @@ class Block: self.svg.docks[1][1]]] def _make_compare_style(self, svg): - self.svg.expand(10 + self.dx + self.ex, self.ey) + self.svg.expand(15 + self.dx + self.ex, self.ey) self._make_block_graphics(svg, self.svg.boolean_compare) self.docks = [['bool', True, self.svg.docks[0][0], self.svg.docks[0][1], '('], @@ -881,7 +881,7 @@ class Block: self._make_compare_style(svg) def _make_boolean_style(self, svg): - self.svg.expand(10 + self.dx + self.ex, self.ey) + self.svg.expand(15 + self.dx + self.ex, self.ey) self._make_block_graphics(svg, self.svg.boolean_and_or) self.docks = [['bool', True, self.svg.docks[0][0], self.svg.docks[0][1]], diff --git a/TurtleArt/tasprite_factory.py b/TurtleArt/tasprite_factory.py index c40d13a..3278e8a 100755 --- a/TurtleArt/tasprite_factory.py +++ b/TurtleArt/tasprite_factory.py @@ -305,7 +305,7 @@ class SVG: self._innie_spacer - self._stroke_width) self._hide_x = self._x + self._radius + self._stroke_width - self._hide_y = self._y - self._radius * 0 + self._stroke_width + self._hide_y = self._y self._show_x = self._x + self._radius + self._stroke_width svg += self._rarc_to(1, -1) @@ -321,7 +321,7 @@ class SVG: svg += self._do_boolean() svg += self._rline_to(0, self._radius / 2.0) - self._show_y = self._y + self._radius * 0 + self._show_y = self._y self._show_y -= (self._innie_y1 + self._innie_y2 + self._stroke_width) svg += self.line_to(xx, self._y) @@ -402,7 +402,7 @@ class SVG: svg += self._rline_to(0, yoffset) self._hide_x = self._x + self._radius + self._stroke_width - self._hide_y = self._y - self._radius * 0 + self._stroke_width + self._hide_y = self._y self._show_x = self._x + self._radius + self._stroke_width svg += self._rarc_to(1, -1) @@ -421,8 +421,9 @@ class SVG: svg += self._rline_to(-self._expand_x, 0) - self._show_y = self._y + self._radius * 0 - self._show_y -= (self._innie_y1 + self._innie_y2 + self._stroke_width) + self._show_y = self._y + self._show_y -= \ + (self._innie_y1 + self._innie_y2 + self._stroke_width * 2) svg += self._end_boolean() self.margins[0] = int((self._radius + self._stroke_width) * \ @@ -947,14 +948,19 @@ class SVG: def _corner(self, sign_x, sign_y, a=90, l=0, s=1, start=True, end=True): svg_str = "" - if sign_x == 1 and sign_y == -1: + if sign_x == 1 and sign_y == -1: # Upper-left corner self._hide_x = self._x + self._radius + self._stroke_width - self._hide_y = self._y - self._radius * 0 + self._stroke_width self._show_x = self._x + self._radius + self._stroke_width - if sign_x == 1 and sign_y == 1 and len(self._innie) == 1: - self._show_x = self._x - self._radius + self._stroke_width - if sign_x == -1 and sign_y == 1: - self._show_y = self._y + self._radius * 0 - self._stroke_width + self._hide_y = self._y + self._stroke_width + elif sign_x == 1 and sign_y == 1: # Upper-right corner + if len(self._innie) == 1 and self._innie[0]: + self._show_x = self._x - self._radius + self._show_y = self._hide_y + elif sign_x == -1 and sign_y == 1: # Lower-right corner + if not (len(self._innie) == 1 and self._innie[0]): + self._show_y = \ + self._y - self._stroke_width + if self._radius > 0: r2 = self._radius / 2.0 if start: @@ -998,36 +1004,34 @@ class SVG: r = self._dot_radius y2 = y - 1.5 else: - scale = self._scale * 2 + scale = self._scale * 1.75 scale2 = scale / 2 - x = self._hide_x * scale2 - y = self._hide_y * scale2 + x = self._hide_x * self._scale + y = self._hide_y * self._scale r = self._dot_radius * scale2 - y2 = y - scale + scale2 / 2 + y2 = y - scale2 svg += self._circle(r, x, y) self._fill, self._stroke = HIDE_WHITE, HIDE_WHITE svg += self._rect(10 * scale2, scale, x - 5 * scale2, y2) self._fill, self._stroke = _saved_fill, _saved_stroke return svg - def _show_dot(self, noscale=False): + def _show_dot(self): _saved_fill, _saved_stroke = self._fill, self._stroke self._fill, self._stroke = HIT_GREEN, HIT_GREEN svg = "/n/n" - if noscale: - scale = self._scale - else: - scale = self._scale * 2 + scale = self._scale * 1.75 scale2 = scale / 2 - svg += self._circle(self._dot_radius * scale2, self._show_x * scale2, - self._show_y * scale2) + svg += self._circle(self._dot_radius * scale2, + self._show_x * self._scale, + self._show_y * self._scale) self._fill, self._stroke = SHOW_WHITE, SHOW_WHITE svg += self._rect(10 * scale2, - 2 * scale2, self._show_x * scale2 - 5 * scale2, - self._show_y * scale2 - scale2 + scale2 / 2) + 2 * scale2, self._show_x * self._scale - 5 * scale2, + self._show_y * self._scale - scale2 + scale2 / 2) svg += self._rect(2 * scale2, 10 * scale2, - self._show_x * scale2 - scale2 + scale2 / 2, - self._show_y * scale2 - 5 * scale2) + self._show_x * self._scale - scale2 + scale2 / 2, + self._show_y * self._scale - 5 * scale2) self._fill, self._stroke = _saved_fill, _saved_stroke return svg diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py index f6df191..2342ab0 100644 --- a/TurtleArt/tawindow.py +++ b/TurtleArt/tawindow.py @@ -239,23 +239,7 @@ class TurtleArtWindow(): self.canvas.clearscreen(False) - CONSTANTS['titlex'] = int(-(self.canvas.width * TITLEXY[0]) / \ - (self.coord_scale * 2)) - CONSTANTS['leftx'] = int(-(self.canvas.width * TITLEXY[0]) / \ - (self.coord_scale * 2)) - CONSTANTS['rightx'] = 0 - CONSTANTS['titley'] = int((self.canvas.height * TITLEXY[1]) / \ - (self.coord_scale * 2)) - CONSTANTS['topy'] = int((self.canvas.height * (TITLEXY[1] - 0.125)) / \ - (self.coord_scale * 2)) - CONSTANTS['bottomy'] = 0 - CONSTANTS['leftpos'] = int(-self.canvas.width / (self.coord_scale * 2)) - CONSTANTS['toppos'] = int(self.canvas.height / (self.coord_scale * 2)) - CONSTANTS['rightpos'] = int(self.canvas.width / (self.coord_scale * 2)) - CONSTANTS['bottompos'] = int(-self.canvas.height / \ - (self.coord_scale * 2)) - CONSTANTS['width'] = int(self.canvas.width / self.coord_scale) - CONSTANTS['height'] = int(self.canvas.height / self.coord_scale) + self._configure_cb(None) self._icon_paths = [os.path.join(self.path, 'icons')] self.turtleart_plugins = [] @@ -402,6 +386,7 @@ class TurtleArtWindow(): self.window.connect("button-release-event", self._buttonrelease_cb) self.window.connect("motion-notify-event", self._move_cb) self.window.connect("key-press-event", self._keypress_cb) + gtk.gdk.screen_get_default().connect('size-changed', self._configure_cb) target = [("text/plain", 0, 0)] self.window.drag_dest_set(gtk.DEST_DEFAULT_ALL, target, @@ -493,6 +478,38 @@ class TurtleArtWindow(): ''' Check to see if project has any blocks in use ''' return len(self.just_blocks()) == 1 + def _configure_cb(self, event): + ''' Screen size has changed ''' + self.width = gtk.gdk.screen_width() + self.height = gtk.gdk.screen_height() + CONSTANTS['titlex'] = int(-(self.width * TITLEXY[0]) / \ + (self.coord_scale * 2)) + CONSTANTS['leftx'] = int(-(self.width * TITLEXY[0]) / \ + (self.coord_scale * 2)) + CONSTANTS['rightx'] = 0 + CONSTANTS['titley'] = int((self.height * TITLEXY[1]) / \ + (self.coord_scale * 2)) + CONSTANTS['topy'] = int((self.height * (TITLEXY[1] - 0.125)) / \ + (self.coord_scale * 2)) + CONSTANTS['bottomy'] = 0 + CONSTANTS['leftpos'] = int(-self.width / (self.coord_scale * 2)) + CONSTANTS['toppos'] = int(self.height / (self.coord_scale * 2)) + CONSTANTS['rightpos'] = int(self.width / (self.coord_scale * 2)) + CONSTANTS['bottompos'] = int(-self.height / (self.coord_scale * 2)) + CONSTANTS['width'] = int(self.width / self.coord_scale) + CONSTANTS['height'] = int(self.height / self.coord_scale) + + if event is None: + return + + # If there are any constant blocks on the canvas, relabel them + for blk in self.just_blocks(): + if blk.name in ['leftpos', 'toppos', 'rightpos', 'bottompos', + 'width', 'height']: + blk.spr.set_label('%s = %d' % (block_names[blk.name][0], + CONSTANTS[blk.name])) + blk.resize() + def _expose_cb(self, win=None, event=None): ''' Repaint ''' self.do_expose_event(event) @@ -1250,8 +1267,11 @@ before making changes to your Turtle Blocks program')) self.dragging_canvas[2] = y if spr is None: if not self.running_blocks and not self.hw in ( - XO1, XO15, XO175, XO4): + XO1, XO15, XO175, XO30): self.dragging_canvas[0] = True + self.dragging_counter = 0 + self.dragging_dx = 0 + self.dragging_dy = 0 return True self.dragging_canvas[0] = False self.selected_spr = spr @@ -2133,11 +2153,18 @@ before making changes to your Turtle Blocks program')) ''' Process mouse movements ''' if self.running_sugar and self.dragging_canvas[0]: - dx = self.dragging_canvas[1] - x - dy = self.dragging_canvas[2] - y - self.dragging_canvas[1] = x - self.dragging_canvas[2] = y - self.activity.adjust_sw(dx, dy) + # Don't adjust with each mouse move or GTK cannot keep pace. + if self.dragging_counter < 10: + self.dragging_dx += self.dragging_canvas[1] - x + self.dragging_dy += self.dragging_canvas[2] - y + self.dragging_canvas[1] = x + self.dragging_canvas[2] = y + self.dragging_counter += 1 + else: + self.activity.adjust_sw(self.dragging_dx, self.dragging_dy) + self.dragging_counter = 0 + self.dragging_dx = 0 + self.dragging_dy = 0 return True self.block_operation = 'move' @@ -2309,6 +2336,11 @@ before making changes to your Turtle Blocks program')) def button_release(self, x, y): if self.running_sugar and self.dragging_canvas[0]: + if self.dragging_counter > 0: + self.activity.adjust_sw(self.dragging_dx, self.dragging_dy) + self.dragging_counter = 0 + self.dragging_dx = 0 + self.dragging_dy = 0 self.dragging_canvas[0] = False self.dragging_canvas[1] = x self.dragging_canvas[2] = y diff --git a/activity/activity.info b/activity/activity.info index 10d8de0..118e2de 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -1,6 +1,6 @@ [Activity] name = TurtleBlocks -activity_version = 172 +activity_version = 173 license = MIT bundle_id = org.laptop.TurtleArtActivity exec = sugar-activity TurtleArtActivity.TurtleArtActivity -- cgit v0.9.1