From 9e0bf5bf04e7ad25fa7ff59e1438b4f6a4913304 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Wed, 03 Feb 2010 17:35:22 +0000 Subject: expandable identity block --- diff --git a/block.py b/block.py index 7d2a4ec..ac90fe3 100644 --- a/block.py +++ b/block.py @@ -571,7 +571,7 @@ class Block: self._left, self._right = 2, self.svg.get_width()-self.svg.docks[1][0] def _make_portfolio_style_2x2(self, svg): - self.svg.expand(25+self._dx+self._ex, 10+self._ey) + self.svg.expand(30+self._dx+self._ex, 10+self._ey) self.svg.set_slot(True) self.svg.set_tab(True) self.svg.set_innie([True, True, False, True]) @@ -593,7 +593,7 @@ class Block: self._left, self._right = 2, self.svg.get_width()-2 def _make_portfolio_style_2x1(self, svg): - self.svg.expand(25+self._dx+self._ex, 10+self._ey) + self.svg.expand(30+self._dx+self._ex, 10+self._ey) self.svg.set_slot(True) self.svg.set_tab(True) self.svg.set_innie([True, True]) @@ -611,7 +611,7 @@ class Block: self._left, self._right = 2, self.svg.get_width()-2 def _make_portfolio_style_1x2(self, svg): - self.svg.expand(self._dx+self._ex, 15+self._ey) + self.svg.expand(30+self._dx+self._ex, 15+self._ey) self.svg.set_slot(True) self.svg.set_tab(True) self.svg.set_innie([True, True, False, True]) @@ -631,7 +631,7 @@ class Block: def _make_portfolio_style_1x1(self, svg): - self.svg.expand(self._dx+self._ex, 15+self._ey) + self.svg.expand(30+self._dx+self._ex, 15+self._ey) self.svg.set_slot(True) self.svg.set_tab(True) self.svg.set_innie([True, True]) diff --git a/constants.py b/constants.py index 74975f6..e9343dd 100644 --- a/constants.py +++ b/constants.py @@ -52,8 +52,8 @@ PALETTES = [['forward', 'back', 'clean', 'left', 'right', 'show', ['kbinput', 'push', 'printheap', 'keyboard', 'pop', 'clearheap', 'myfunc', 'nop', 'leftpos', 'toppos', 'width', 'rightpos', 'bottompos', 'height', 'turtle', 'print'], - ['journal', 'audio', 'description', 'list', 'template1x1', - 'template1x2', 'template2x1', 'template2x2', + ['journal', 'audio', 'description', 'templatelist', 'template1x1a', + 'template1x1', 'template1x2', 'template2x1', 'template2x2', 'hideblocks', 'showblocks'], ['restore']] @@ -83,6 +83,8 @@ PYTHON_X = 17 PYTHON_Y = 8 MEDIA_X = 37 MEDIA_Y = 6 +TEMPLATE_X = 24 +TEMPLATE_Y = 18 PIXBUF_X = 17 PIXBUF_Y = 2 BLOCK_SCALE = 2.0 @@ -120,8 +122,8 @@ FLOW_STYLE_1ARG = ['repeat'] FLOW_STYLE_BOOLEAN = ['if'] FLOW_STYLE_ELSE = ['ifelse'] PORTFOLIO_STYLE_2x2 = ['template2x2'] -BULLET_STYLE = ['list'] -PORTFOLIO_STYLE_1x1 = ['template1x1'] +BULLET_STYLE = ['templatelist'] +PORTFOLIO_STYLE_1x1 = ['template1x1', 'template1x1a'] PORTFOLIO_STYLE_2x1 = ['template2x1'] PORTFOLIO_STYLE_1x2 = ['template1x2'] @@ -146,7 +148,7 @@ MACROS = { # # blocks that are expandable # -EXPANDABLE = ['vspace', 'hspace', 'list'] +EXPANDABLE = ['vspace', 'hspace', 'templatelist', 'identity2'] # # Old block styles that need dock adjustments @@ -198,7 +200,6 @@ BLOCK_NAMES = { 'left':[_('left')], 'leftpos':[_('left')], 'less2':['<'], - 'list':[_('list')], 'minus2':['–'], 'myfunc':[_('Python'),_('code'),_('value')], 'nop':[_(' ')], @@ -245,9 +246,11 @@ BLOCK_NAMES = { 'storeinbox2':[_('store in box 2')], 'string':[_('text')], 'template1x1':[' '], + 'template1x1a':[' '], 'template1x2':[' '], 'template2x1':[' '], 'template2x2':[' '], + 'templatelist':[' '], 'textsize':[_('text size')], 'toppos':[_('top')], 'turtle':[_('turtle')], @@ -297,7 +300,7 @@ PRIMITIVES = { 'left':'left', 'leftpos':'lpos', 'less2':'less?', - 'list':'bullet', + 'templatelist':'bullet', 'minus2':'minus', 'myfunc':'myfunc', 'nop':'userdefined', @@ -342,6 +345,7 @@ PRIMITIVES = { 'storeinbox1':'storeinbox1', 'storeinbox2':'storeinbox2', 'template1x1':'t1x1', + 'template1x1a':'t1x1a', 'template1x2':'t1x2', 'template2x1':'t2x1', 'template2x2':'t2x2', @@ -372,7 +376,6 @@ DEFAULTS = { 'ifelse':[None,'vspace', None, 'vspace'], 'journal':[None], 'left':[90], - 'list':[_('Title'), '∙ '], 'media':[None], 'myfunc':[_('x'),100], 'nop':[100], @@ -394,9 +397,11 @@ DEFAULTS = { 'storein':[_('my box'),100], 'string':[_('text')], 'template1x1':[_('Title'), 'None'], + 'template1x1a':[_('Title'), 'None'], 'template1x2':[_('Title'), 'None', 'None'], 'template2x1':[_('Title'), 'None', 'None'], 'template2x2':[_('Title'), 'None', 'None', 'None', 'None'], + 'templatelist':[_('Title'), '∙ '], 'turtle':[1], 'wait':[1]} @@ -405,7 +410,7 @@ DEFAULTS = { # STRING_OR_NUMBER_ARGS = ['plus2', 'equal2', 'less2', 'greater2', 'template1x1', 'template1x2', 'template2x1', - 'template2x2', 'list', 'nop', + 'template2x2', 'template1x1a', 'templatelist', 'nop', 'print', 'stack', 'hat'] CONTENT_ARGS = ['show', 'push', 'storein', 'storeinbox1', 'storeinbox2'] @@ -417,7 +422,8 @@ CONTENT_ARGS = ['show', 'push', 'storein', 'storeinbox1', 'storeinbox2'] MEDIA_SHAPES = ['audiooff', 'audioon', 'audiosmall', 'journaloff', 'journalon', 'journalsmall', 'descriptionoff', 'descriptionon', 'descriptionsmall', - 'pythonoff', 'pythonon', 'pythonsmall'] + 'pythonoff', 'pythonon', 'pythonsmall', + 'list', '1x1', '1x1a', '2x1', '1x2', '2x2'] OVERLAY_SHAPES = ['Cartesian', 'polar'] @@ -433,7 +439,7 @@ OLD_NAMES = {'product':'product2', 'storeinbox':'storein', 'less':'less2', 'greater':'greater2', 'equal':'equal2', 'remainder':'remainder2', 'identity':'identity2', 'division':'division2', 'if else':'if', 'audiooff':'audio', - 'descriptionoff':'description','template3':'list', + 'descriptionoff':'description','template3':'templatelist', 'template1':'template1x1', 'template2':'template2x1', 'template6':'template1x2', 'template7':'template2x2', 'template4':'template1x1a', 'hres':'width', 'vres':'height' } @@ -472,9 +478,11 @@ SPECIAL_NAMES = { 'product2':_('multiply'), 'sqrt':_('square root'), 'template1x1':_('presentation 1x1'), + 'template1x1a':_('presentation 1x1'), 'template1x2':_('presentation 1x2'), 'template2x1':_('presentation 2x1'), 'template2x2':_('presentation 2x2'), + 'templatelist':_('presentation bulleted list'), 'textsize':_('text size'), 'vspace':_('vertical space')} @@ -568,11 +576,11 @@ HELP_STRINGS = { 'storein':_("store numeric value in named variable"), 'string':_("string value"), 'template1x1':_("presentation template: select Journal object (with description)"), - 'template2x1':_("presentation template: select two Journal objects"), - 'list':_("presentation template: list of bullets"), 'template1x1a':_("presentation template: select Journal object (no description)"), 'template1x2':_("presentation template: select two Journal objects"), + 'template2x1':_("presentation template: select two Journal objects"), 'template2x2':_("presentation template: select four Journal objects"), + 'templatelist':_("presentation template: list of bullets"), 'textcolor':_("holds current text color (can be used in place of a number block)"), 'textsize':_("holds current text size (can be used in place of a number block)"), 'toppos':_("ycor of top of screen"), diff --git a/sprite_factory.py b/sprite_factory.py index 9d4056a..1e8c157 100755 --- a/sprite_factory.py +++ b/sprite_factory.py @@ -63,6 +63,7 @@ class SVG: self._draw_innies = True self._hide = False self._show = False + self._dot_radius = 8 self._fill = "#00FF00" self._stroke = "#00A000" self._gradiant = False @@ -100,11 +101,18 @@ class SVG: svg += self._close_path() svg += self._style() if self._show is True: - svg += self._show_dot(12, - self._height-12-self._innie_y2-self._slot_y) + if self._outie is True: + x = self._innie_x1 + 2*self._innie_x2 + 2*self._dot_radius + else: + x = 12 + svg += self._show_dot(x,self._height-12-self._innie_y2-self._slot_y) if self._hide is True: - svg += self._hide_dot(self._width-12, - self._height-12-self._innie_y2-self._slot_y) + if True in self._innie: + x = self._width - (self._innie_x1 + 2*self._innie_x2 +\ + 2*self._dot_radius) + else: + x = self._width-12 + svg += self._hide_dot(x,self._height-12-self._innie_y2-self._slot_y) svg += self._footer() return self._header() + svg @@ -594,7 +602,7 @@ class SVG: _saved_fill, _saved_stroke = self._fill, self._stroke self._fill, self._stroke = "#FF0000", "#FF0000" svg = "/n/n" - svg += self._circle(8, x, y) + svg += self._circle(self._dot_radius, x, y) self._fill, self._stroke = "#FFFFFF", "#FFFFFF" svg += self._rect(10, 2, x-5, y-1) self._fill, self._stroke = _saved_fill, _saved_stroke @@ -604,7 +612,7 @@ class SVG: _saved_fill, _saved_stroke = self._fill, self._stroke self._fill, self._stroke = "#00FE00", "#00FE00" svg = "/n/n" - svg += self._circle(8, x, y) + svg += self._circle(self._dot_radius, x, y) self._fill, self._stroke = "#FEFEFE", "#FEFEFE" svg += self._rect(10, 2, x-5, y-1) svg += self._rect(2, 10, x-1, y-5) diff --git a/talogo.py b/talogo.py index 252be09..0180ff5 100644 --- a/talogo.py +++ b/talogo.py @@ -21,13 +21,13 @@ #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN #THE SOFTWARE. -import re -from time import clock +import gtk import gobject -from operator import isNumberType +from time import clock +from math import sqrt from random import uniform +from operator import isNumberType import audioop -from math import sqrt import subprocess from UserDict import UserDict try: @@ -853,7 +853,7 @@ class LogoCode: try: dsobject = datastore.get(media[6:]) except: - print "Couldn't open media object %s" % (media[6:]) + print "Couldn't open Journal object %s" % (media[6:]) if movie_media_type(dsobject.file_path[-4:]): play_movie_from_file(self, dsobject.file_path, int(x), int(y), int(w), int(h)) diff --git a/tawindow.py b/tawindow.py index 3fdfa64..6841d01 100644 --- a/tawindow.py +++ b/tawindow.py @@ -430,6 +430,10 @@ class TurtleArtWindow(): self.palettes[n][i].spr.set_image(self.media_shapes[ name+'small'], 1, int(MEDIA_X*scale/BLOCK_SCALE), int(MEDIA_Y*scale/BLOCK_SCALE)) + elif name[:8] == 'template': + self.palettes[n][i].spr.set_image(self.media_shapes[ + name[8:]], 1, int(TEMPLATE_X*scale/BLOCK_SCALE), + int(TEMPLATE_Y*scale/BLOCK_SCALE)) elif name == 'nop': self.palettes[n][i].spr.set_image(self.media_shapes[ 'pythonsmall'], 1, int(PYTHON_X*scale/BLOCK_SCALE), @@ -1038,6 +1042,17 @@ class TurtleArtWindow(): blk.spr.labels[0] += CURSOR elif blk.name in BOX_STYLE_MEDIA: self._import_from_journal(self.selected_blk) + elif blk.name=='identity2': + group = self._find_group(blk) + r,g,b,a = blk.spr.get_pixel((x, y)) + if (r == 255 and g == 0) or g == 255: + dx = blk.reset_x() + else: + dx = 20 + blk.expand_in_x(dx) + for b in group: + if b != blk: + b.spr.move_relative((dx*blk.scale, 0)) elif blk.name=='vspace': group = self._find_group(blk) r,g,b,a = blk.spr.get_pixel((x, y)) @@ -1588,7 +1603,7 @@ class TurtleArtWindow(): if btype == 'vspace': if value is not None: blk.expand_in_y(value) - elif btype == 'hspace': + elif btype == 'hspace' or btype == 'identity2': if value is not None: blk.expand_in_x(value) elif btype == 'list': -- cgit v0.9.1