From 9f648c1340b8c1cc9b4f8e414427e2d08784cc57 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Wed, 03 Mar 2010 19:51:00 +0000 Subject: fixed collapsible block regression --- diff --git a/sprites.py b/sprites.py index 0bdab1f..045ab98 100644 --- a/sprites.py +++ b/sprites.py @@ -164,11 +164,11 @@ class Sprite: self.images[i] = image self._dx[i] = dx self._dy[i] = dy - if isinstance(self.images[i], gtk.gdk.Pixbuf): - _w = self.images[i].get_width() - _h = self.images[i].get_height() + if isinstance(image, gtk.gdk.Pixbuf): + _w = image.get_width() + _h = image.get_height() else: - _w, _h = self.images[i].get_size() + _w, _h = image.get_size() if i == 0: # Always reset width and height when base image changes. self._width = _w + dx self._height = _h + dy diff --git a/tablock.py b/tablock.py index ec6d99c..ea67ed0 100644 --- a/tablock.py +++ b/tablock.py @@ -76,7 +76,7 @@ class Block: def __init__(self, block_list, sprite_list, name, x, y, type='block', values=[], scale=BLOCK_SCALE, colors=["#FF0000","#A00000"]): self.spr = None - self.shapes = [] + self.shapes = [None, None] self.name = name self.colors = colors self.scale = scale @@ -212,7 +212,7 @@ class Block: self.svg.set_hide(False) if self.type == 'block': self.svg.set_show(True) - else: + else: # 'proto' self.svg.set_show(False) self.refresh() return dy @@ -283,7 +283,6 @@ class Block: self._set_colors(svg) self.svg.set_stroke_width(STANDARD_STROKE_WIDTH) self.svg.clear_docks() - self.shapes = [] if self.name in BASIC_STYLE: self._make_basic_style(svg) elif self.name in BASIC_STYLE_HEAD: @@ -769,73 +768,73 @@ class Block: self.svg.docks[1][1]]] def _make_basic_block(self, svg): - self.shapes.append(svg_str_to_pixbuf(self.svg.basic_block())) + self.shapes[0] = svg_str_to_pixbuf(self.svg.basic_block()) self.width = self.svg.get_width() self.height = self.svg.get_height() self.svg.set_stroke_width(SELECTED_STROKE_WIDTH) self.svg.set_stroke_color(SELECTED_COLOR) - self.shapes.append(svg_str_to_pixbuf(self.svg.basic_block())) + self.shapes[1] = svg_str_to_pixbuf(self.svg.basic_block()) def _make_collapsible_top_block(self, svg): - self.shapes.append(svg_str_to_pixbuf(self.svg.sandwich_top())) + self.shapes[0] = svg_str_to_pixbuf(self.svg.sandwich_top()) self.width = self.svg.get_width() self.height = self.svg.get_height() self.svg.set_stroke_width(SELECTED_STROKE_WIDTH) self.svg.set_stroke_color(SELECTED_COLOR) - self.shapes.append(svg_str_to_pixbuf(self.svg.sandwich_top())) + self.shapes[1] = svg_str_to_pixbuf(self.svg.sandwich_top()) def _make_collapsible_bottom_block(self, svg): - self.shapes.append(svg_str_to_pixbuf(self.svg.sandwich_bottom())) + self.shapes[0] = svg_str_to_pixbuf(self.svg.sandwich_bottom()) self.width = self.svg.get_width() self.height = self.svg.get_height() self.svg.set_stroke_width(SELECTED_STROKE_WIDTH) self.svg.set_stroke_color(SELECTED_COLOR) - self.shapes.append(svg_str_to_pixbuf(self.svg.sandwich_bottom())) + self.shapes[1] = svg_str_to_pixbuf(self.svg.sandwich_bottom()) def _make_basic_box(self, svg): - self.shapes.append(svg_str_to_pixbuf(self.svg.basic_box())) + self.shapes[0] = svg_str_to_pixbuf(self.svg.basic_box()) self.width = self.svg.get_width() self.height = self.svg.get_height() self.svg.set_stroke_width(SELECTED_STROKE_WIDTH) self.svg.set_stroke_color(SELECTED_COLOR) - self.shapes.append(svg_str_to_pixbuf(self.svg.basic_box())) + self.shapes[1] = svg_str_to_pixbuf(self.svg.basic_box()) def _make_portfolio(self, svg): - self.shapes.append(svg_str_to_pixbuf(self.svg.portfolio())) + self.shapes[0] = svg_str_to_pixbuf(self.svg.portfolio()) self.width = self.svg.get_width() self.height = self.svg.get_height() self.svg.set_stroke_width(SELECTED_STROKE_WIDTH) self.svg.set_stroke_color(SELECTED_COLOR) - self.shapes.append(svg_str_to_pixbuf(self.svg.portfolio())) + self.shapes[1] = svg_str_to_pixbuf(self.svg.portfolio()) def _make_basic_flow(self, svg): - self.shapes.append(svg_str_to_pixbuf(self.svg.basic_flow())) + self.shapes[0] = svg_str_to_pixbuf(self.svg.basic_flow()) self.width = self.svg.get_width() self.height = self.svg.get_height() self.svg.set_stroke_width(SELECTED_STROKE_WIDTH) self.svg.set_stroke_color(SELECTED_COLOR) - self.shapes.append(svg_str_to_pixbuf(self.svg.basic_flow())) + self.shapes[1] = svg_str_to_pixbuf(self.svg.basic_flow()) def _make_boolean_compare(self, svg): - self.shapes.append(svg_str_to_pixbuf(self.svg.boolean_compare())) + self.shapes[0] = svg_str_to_pixbuf(self.svg.boolean_compare()) self.width = self.svg.get_width() self.height = self.svg.get_height() self.svg.set_stroke_width(SELECTED_STROKE_WIDTH) self.svg.set_stroke_color(SELECTED_COLOR) - self.shapes.append(svg_str_to_pixbuf(self.svg.boolean_compare())) + self.shapes[1] = svg_str_to_pixbuf(self.svg.boolean_compare()) def _make_boolean_and_or(self, svg): - self.shapes.append(svg_str_to_pixbuf(self.svg.boolean_and_or())) + self.shapes[0] = svg_str_to_pixbuf(self.svg.boolean_and_or()) self.width = self.svg.get_width() self.height = self.svg.get_height() self.svg.set_stroke_width(SELECTED_STROKE_WIDTH) self.svg.set_stroke_color(SELECTED_COLOR) - self.shapes.append(svg_str_to_pixbuf(self.svg.boolean_and_or())) + self.shapes[1] = svg_str_to_pixbuf(self.svg.boolean_and_or()) def _make_boolean_not(self, svg): - self.shapes.append(svg_str_to_pixbuf(self.svg.boolean_not())) + self.shapes[0] = svg_str_to_pixbuf(self.svg.boolean_not()) self.width = self.svg.get_width() self.height = self.svg.get_height() self.svg.set_stroke_width(SELECTED_STROKE_WIDTH) self.svg.set_stroke_color(SELECTED_COLOR) - self.shapes.append(svg_str_to_pixbuf(self.svg.boolean_not())) + self.shapes[1] = svg_str_to_pixbuf(self.svg.boolean_not()) diff --git a/tasprite_factory.py b/tasprite_factory.py index 97b1426..45dcb99 100755 --- a/tasprite_factory.py +++ b/tasprite_factory.py @@ -76,6 +76,7 @@ class SVG: self.margins = [0, 0, 0, 0] def basic_block(self): + self.reset_min_max() (x, y) = self._calculate_x_y() self.margins[2] = 0 self.margins[3] = 0 @@ -118,6 +119,7 @@ class SVG: return self.header() + svg def basic_flow(self): + self.reset_min_max() (x, y) = self._calculate_x_y() self.margins[2] = 0 self.margins[3] = 0 @@ -176,6 +178,7 @@ class SVG: return self.header() + svg def portfolio(self): + self.reset_min_max() (x, y) = self._calculate_x_y() self.margins[0] = int(x+2*self._stroke_width+0.5) self.margins[1] = int(y+self._stroke_width+0.5+self._slot_y) @@ -212,6 +215,7 @@ class SVG: return self.header() + svg def basic_box(self): + self.reset_min_max() self.set_outie(True) x = self._stroke_width/2.0+self._innie_x1+self._innie_x2 self.margins[0] = int((x+self._stroke_width+0.5)*self._scale) @@ -232,6 +236,7 @@ class SVG: return self.header() + svg def boolean_and_or(self): + self.reset_min_max() svg = self._start_boolean(self._stroke_width/2.0, self._radius*5.5+self._stroke_width/2.0+\ self._innie_y2+self._innie_spacer) @@ -256,6 +261,7 @@ class SVG: return self.header() + svg def boolean_not(self): + self.reset_min_max() svg = self._start_boolean(self._stroke_width/2.0, self._radius*2.0+self._stroke_width/2.0) svg += self._rline_to(0,-self._stroke_width) @@ -275,6 +281,7 @@ class SVG: return self.header() + svg def boolean_compare(self): + self.reset_min_max() yoffset = self._radius*2+2*self._innie_y2+\ self._innie_spacer+self._stroke_width/2.0 if self._porch is True: @@ -305,6 +312,7 @@ class SVG: return self.header() + svg def turtle(self, colors): + self.reset_min_max() self._fill, self._stroke = colors[0], colors[1] svg = "%s%s%s%s%s%s%s%s" % (" 0: + print "reseting arm" top.reset_y() - (tx, ty) = top.spr.get_xy() - (tw, th) = top.spr.get_dimensions() - (bx, by) = bot.spr.get_xy() + """ + tx, ty = top.spr.get_xy() + tw, th = top.spr.get_dimensions() + bx, by = bot.spr.get_xy() dy = by-(ty+th) if dy > 0: top.expand_in_y(dy/top.scale) + top.refresh() """ Check the state of collapsible blocks upon change in dock state. -- cgit v0.9.1