Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2010-02-23 15:47:27 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2010-02-23 15:47:27 (GMT)
commit50a833ba082d4c121e79feefdd34ce950a27bac6 (patch)
tree9dbe210b13b6d973bb6c3fa78a3f259bf7f77889
parent0c6609291198c30d11ec03b4e9591e39aa05a522 (diff)
removed arm from collasped stack
-rw-r--r--TurtleArtActivity.py2
-rw-r--r--icons/hideshowoff.svg11
-rw-r--r--samples/sinfunction.ta2
-rw-r--r--tablock.py21
-rw-r--r--taconstants.py15
-rwxr-xr-xtasprite_factory.py34
-rw-r--r--tawindow.py23
7 files changed, 71 insertions, 37 deletions
diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py
index 94a7226..196f34c 100644
--- a/TurtleArtActivity.py
+++ b/TurtleArtActivity.py
@@ -779,7 +779,7 @@ class TurtleArtActivity(activity.Activity):
palette_toolbar_button = ToolbarButton(
page=palette_toolbar,
- icon_name='paletteoff')
+ icon_name='palette')
palette_toolbar.show()
toolbar_box.toolbar.insert(palette_toolbar_button, -1)
palette_toolbar_button.show()
diff --git a/icons/hideshowoff.svg b/icons/hideshowoff.svg
index 3a475c5..3db14c9 100644
--- a/icons/hideshowoff.svg
+++ b/icons/hideshowoff.svg
@@ -14,4 +14,15 @@
d="m 1.5,25.5 0,-8 a 8,8 0 0 1 8,-8 l 8,0 0,4 20,0 0,-4 8,0 a 8,8 0 0 1 8,8 l 0,8 0,8 a 8,8 0 0 1 -8,8 l -8,0 -2,0 0,4 -16,0 0,-4 -2,0 -8,0 a 8,8 0 0 1 -8,-8 l 0,-8 z"
id="path2882"
style="fill:#404040;fill-opacity:1;stroke:#ffffff;stroke-width:2.5;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 35.875,27.5 c 0,4.62493 -3.74962,8.374182 -8.375,8.374182 -4.62538,0 -8.375,-3.749252 -8.375,-8.374182 0,-4.624929 3.74962,-8.374182 8.375,-8.374182 4.62538,0 8.375,3.749253 8.375,8.374182 l 0,0 z"
+ id="path5"
+ style="fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:1px;stroke-opacity:1" />
+ <rect
+ width="10"
+ height="2"
+ x="22.5"
+ y="26.5"
+ id="rect2844"
+ style="fill:#404040;fill-opacity:1;fill-rule:nonzero;stroke:#404040;stroke-width:1.5;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
</svg>
diff --git a/samples/sinfunction.ta b/samples/sinfunction.ta
index a5d0717..6ac9e3e 100644
--- a/samples/sinfunction.ta
+++ b/samples/sinfunction.ta
@@ -1 +1 @@
-[[0, "start", 76, 215, [null, 46]], [1, "storeinbox1", 141, 503, [33, 2, 36]], [2, ["number", -3.1400000000000001], 259, 503, [1, null]], [3, "repeat", 398, 229, [48, 4, 23, null]], [4, ["number", 628], 449, 229, [3, null]], [5, "setxy", 463, 525, [32, 27, 29, 11]], [6, "box1", 585, 331, [21, null]], [7, ["identity2", 40], 585, 449, [8, 9]], [8, "product2", 531, 449, [25, 7, 41]], [9, "myfunc", 719, 449, [7, 10, 18]], [10, ["string", "sin(x)"], 799, 449, [9, null]], [11, ["vspace", 0], 463, 609, [5, 12]], [12, "forward", 463, 643, [11, 13, 14]], [13, ["number", 0], 534, 643, [12, null]], [14, "storeinbox1", 463, 685, [12, 15, 40]], [15, "plus2", 581, 685, [14, 16, 17]], [16, "box1", 635, 685, [15, null]], [17, ["number", 0.01], 635, 727, [15, null]], [18, "box1", 799, 491, [9, null]], [19, "clean", 76, 291, [46, 20]], [20, "cartesian", 76, 325, [19, 34]], [21, "product2", 531, 331, [23, 6, 22]], [22, ["number", 100], 585, 373, [21, null]], [23, "storein", 463, 289, [3, 24, 21, 31]], [24, ["string", "x"], 531, 289, [23, null]], [25, "storein", 463, 407, [31, 26, 8, 32]], [26, ["string", "sin(x)"], 531, 407, [25, null]], [27, "box", 521, 525, [5, 28, null]], [28, ["string", "x"], 576, 525, [27, null]], [29, "box", 521, 567, [5, 30, null]], [30, ["string", "sin(x)"], 576, 567, [29, null]], [31, ["vspace", 0], 463, 373, [23, 25]], [32, ["vspace", 0], 463, 491, [25, 5]], [33, "setcolor", 141, 461, [42, 45, 1]], [34, "storeinbox2", 76, 359, [20, 35, 42]], [35, ["number", "1"], 194, 359, [34, null]], [36, "storeinbox2", 141, 545, [1, 38, 49]], [37, ["number", "2"], 313, 587, [38, null]], [38, "plus2", 259, 545, [36, 39, 37]], [39, "box2", 313, 545, [38, null]], [40, ["vspace", 0], 463, 727, [14, null]], [41, "box2", 585, 491, [8, null]], [42, "repeat", 76, 401, [34, 43, 33, 44]], [43, ["number", "400"], 127, 401, [42, null]], [44, ["vspace", 60], 76, 479, [42, 47]], [45, "box2", 218, 461, [33, null]], [46, "hideblocks", 76, 257, [0, 19]], [47, "showblocks", 76, 633, [44, null]], [48, "hat1", 398, 187, [null, 3]], [49, "stack1", 141, 587, [36, null]], [-1, ["turtle", 1], -12, -4, 0, 37.0, 50, 5]] \ No newline at end of file
+[[0, "start", 76, 215, [null, 46]], [1, "storeinbox1", 141, 503, [33, 2, 36]], [2, ["number", -3.1400000000000001], 259, 503, [1, null]], [3, "repeat", 398, 229, [48, 4, 23, null]], [4, ["number", 628], 449, 229, [3, null]], [5, "setxy", 463, 525, [32, 27, 29, 11]], [6, "box1", 585, 331, [21, null]], [7, ["identity2", 40], 585, 449, [8, 9]], [8, "product2", 531, 449, [25, 7, 41]], [9, "myfunc", 719, 449, [7, 10, 18]], [10, ["string", "sin(x)"], 799, 449, [9, null]], [11, ["vspace", 0], 463, 609, [5, 12]], [12, "forward", 463, 643, [11, 13, 14]], [13, ["number", 0], 534, 643, [12, null]], [14, "storeinbox1", 463, 685, [12, 15, 40]], [15, "plus2", 581, 685, [14, 16, 17]], [16, "box1", 635, 685, [15, null]], [17, ["number", 0.01], 635, 727, [15, null]], [18, "box1", 799, 491, [9, null]], [19, "clean", 76, 291, [46, 20]], [20, "cartesian", 76, 325, [19, 34]], [21, "product2", 531, 331, [23, 6, 22]], [22, ["number", 100], 585, 373, [21, null]], [23, "storein", 463, 289, [3, 24, 21, 31]], [24, ["string", "x"], 531, 289, [23, null]], [25, "storein", 463, 407, [31, 26, 8, 32]], [26, ["string", "sin(x)"], 531, 407, [25, null]], [27, "box", 521, 525, [5, 28, null]], [28, ["string", "x"], 576, 525, [27, null]], [29, "box", 521, 567, [5, 30, null]], [30, ["string", "sin(x)"], 576, 567, [29, null]], [31, ["vspace", 0], 463, 373, [23, 25]], [32, ["vspace", 0], 463, 491, [25, 5]], [33, "setcolor", 141, 461, [42, 45, 1]], [34, "storeinbox2", 76, 359, [20, 35, 42]], [35, ["number", "1"], 194, 359, [34, null]], [36, "storeinbox2", 141, 545, [1, 38, 49]], [37, ["number", "2"], 313, 587, [38, null]], [38, "plus2", 259, 545, [36, 39, 37]], [39, "box2", 313, 545, [38, null]], [40, ["vspace", 0], 463, 727, [14, null]], [41, "box2", 585, 491, [8, null]], [42, "repeat", 76, 401, [34, 43, 33, 44]], [43, ["number", "200"], 127, 401, [42, null]], [44, ["vspace", 60], 76, 479, [42, 47]], [45, "box2", 218, 461, [33, null]], [46, "hideblocks", 76, 257, [0, 19]], [47, "showblocks", 76, 633, [44, null]], [48, "hat1", 398, 187, [null, 3]], [49, "stack1", 141, 587, [36, null]], [-1, ["turtle", 1], 312, 9, 0, 799.0, 50, 5]] \ No newline at end of file
diff --git a/tablock.py b/tablock.py
index 304c870..d01bb6d 100644
--- a/tablock.py
+++ b/tablock.py
@@ -288,7 +288,7 @@ class Block:
elif self.name in BASIC_STYLE_HEAD:
self._make_basic_style_head(svg)
elif self.name in BASIC_STYLE_EXTENDED:
- self._make_basic_style_extended(svg)
+ self._make_basic_style(svg, 16)
elif self.name in BASIC_STYLE_HEAD_1ARG:
self._make_basic_style_head_1arg(svg)
elif self.name in BASIC_STYLE_TAIL:
@@ -335,6 +335,8 @@ class Block:
self._make_flow_style_else(svg)
elif self.name in COLLAPSIBLE_TOP:
self._make_collapsible_style_top(svg)
+ elif self.name in COLLAPSIBLE_TOP_NO_ARM:
+ self._make_collapsible_style_top(svg, True)
elif self.name in COLLAPSIBLE_BOTTOM:
self._make_collapsible_style_bottom(svg)
elif self.name in PORTFOLIO_STYLE_2x2:
@@ -358,14 +360,8 @@ class Block:
self.colors = COLORS[p]
self.svg.set_colors(self.colors)
- def _make_basic_style(self, svg):
- self.svg.expand(self.dx+self.ex, self.ey)
- self._make_basic_block(svg)
- self.docks = [['flow',True,self.svg.docks[0][0],self.svg.docks[0][1]],
- ['flow',False,self.svg.docks[1][0],self.svg.docks[1][1]]]
-
- def _make_basic_style_extended(self, svg):
- self.svg.expand(self.dx+16+self.ex, 16+self.ey)
+ def _make_basic_style(self, svg, extension=0):
+ self.svg.expand(self.dx+self.ex+extension, self.ey+extension)
self._make_basic_block(svg)
self.docks = [['flow',True,self.svg.docks[0][0],self.svg.docks[0][1]],
['flow',False,self.svg.docks[1][0],self.svg.docks[1][1]]]
@@ -464,8 +460,8 @@ class Block:
self.svg.set_slot(False)
self._make_basic_block(svg)
"""
- NOTE: The "outie" is added last, so the dock order in the NUMBER_STYLE
- needs to be modified.
+ NOTE: The "outie" is added last, so the dock order in NUMBER_STYLE
+ blocks needs to be modified.
"""
self.docks = [['number', True, self.svg.docks[2][0],
self.svg.docks[2][1]],
@@ -662,8 +658,9 @@ class Block:
['flow', False, self.svg.docks[4][0],
self.svg.docks[4][1], ']']]
- def _make_collapsible_style_top(self, svg):
+ def _make_collapsible_style_top(self, svg, no_arm=False):
self.svg.expand(self.dx+self.ex, self.ey)
+ self.svg.set_no_arm(no_arm)
self._make_collapsible_top_block(svg)
self.docks = [['flow', True, self.svg.docks[0][0],
self.svg.docks[0][1]],
diff --git a/taconstants.py b/taconstants.py
index 0a6db58..123896f 100644
--- a/taconstants.py
+++ b/taconstants.py
@@ -192,6 +192,7 @@ FLOW_STYLE_BOOLEAN = ['if', 'while', 'until']
FLOW_STYLE_WHILE = ['while2']
FLOW_STYLE_ELSE = ['ifelse']
COLLAPSIBLE_TOP = ['sandwichtop']
+COLLAPSIBLE_TOP_NO_ARM = ['sandwichtop2']
COLLAPSIBLE_BOTTOM = ['sandwichbottom']
# Depreciated block styles
@@ -315,9 +316,10 @@ BLOCK_NAMES = {
'rightx':[_('picture right')],
'savepix':[_('save picture')],
'scale':[_('scale')],
- 'sandwichbottom':[''],
+ 'sandwichbottom':[' '],
'sandwichcollapsed':[_('click to open')],
- 'sandwichtop':['top of stack'],
+ 'sandwichtop':[_('top of stack')],
+ 'sandwichtop2':[_('top of stack')],
'setcolor':[_('set color')],
'seth':[_('set heading')],
'setpensize':[_('set pen size')],
@@ -438,6 +440,7 @@ PRIMITIVES = {
'rightpos':'rpos',
'rightx':'rightx',
'sandwichtop':'comment',
+ 'sandwichtop2':'comment',
'sandwichbottom':'nop',
'sandwichcollapsed':'nop',
'savepix':'savepix',
@@ -515,6 +518,7 @@ DEFAULTS = {
'repeat':[4, None, 'vspace'],
'right':[90],
'sandwichtop':[_('label')],
+ 'sandwichtop2':[_('label')],
'savepix':[_('picture name')],
'setcolor':[0],
'seth':[0],
@@ -547,7 +551,8 @@ STRING_OR_NUMBER_ARGS = ['plus2', 'equal2', 'less2', 'greater2', 'box',
'template1x1', 'template1x2', 'template2x1', 'list',
'template2x2', 'template1x1a', 'templatelist', 'nop',
'print', 'stack', 'hat', 'addturtle', 'myfunc',
- 'myfunc1arg', 'myfunc2arg', 'myfunc3arg']
+ 'myfunc1arg', 'myfunc2arg', 'myfunc3arg', 'comment',
+ 'sandwichtop', 'sandwichtop2']
CONTENT_ARGS = ['show', 'showaligned', 'push', 'storein', 'storeinbox1',
'storeinbox2']
@@ -722,6 +727,10 @@ HELP_STRINGS = {
'right':_("turns turtle clockwise (angle in degrees)"),
'run-fastoff':_("Run"),
'run-slowoff':_("Step"),
+ 'sandwichbottom':_("bottom block in a collapsibe stack: click to collapse"),
+ 'sandwichcollapsed':_("bottom block in a collapsed stack: click to open"),
+ 'sandwichtop':_("top of a collapsible stack"),
+ 'sandwichtop2':_("top of a collapsed stack"),
'savepix':_("saves a picture to the Sugar Journal"),
'scale':_("holds current scale value"),
'setcolor':_("sets color of the line drawn by the turtle"),
diff --git a/tasprite_factory.py b/tasprite_factory.py
index bdd7202..07ff23f 100755
--- a/tasprite_factory.py
+++ b/tasprite_factory.py
@@ -59,6 +59,7 @@ class SVG:
self._porch_y = self._innie_y1+self._innie_y2+4*self._stroke_width
self._expand_x = 0
self._expand_y = 0
+ self._no_arm = False
self._else = False
self._draw_innies = True
self._hide = False
@@ -417,9 +418,13 @@ class SVG:
svg += self._line_to(xx, self._y)
svg += self._rline_to(-self._expand_x, 0)
svg += self._do_tab()
- svg += self._inverse_corner(-1, 1, 90, 0, 0)
- svg += self._rline_to(0, self._expand_y)
- svg += self._rline_to(-self._radius, 0)
+ if self._no_arm:
+ svg += self._rline_to(-self._radius-self._stroke_width, 0)
+ svg += self._corner(-1, -1)
+ else:
+ svg += self._inverse_corner(-1, 1, 90, 0, 0)
+ svg += self._rline_to(0, self._expand_y)
+ svg += self._rline_to(-self._radius, 0)
svg += self._close_path()
self._calculate_w_h()
svg += self._style()
@@ -537,6 +542,9 @@ class SVG:
def set_else(self, flag=False):
self._else = flag
+ def set_no_arm(self, flag=True):
+ self._no_arm = flag
+
#
# Exotic methods
#
@@ -936,23 +944,25 @@ def close_file(f):
def generator(datapath):
- svgt = SVG()
- svgt.set_orientation(180)
- f = open_file(datapath, "turtle180.svg")
- svg_str = svgt.turtle(["#FF0000","#00FF00"])
- f.write(svg_str)
- close_file(f)
-
- """
svg0 = SVG()
f = open_file(datapath, "basic.svg")
svg0.set_scale(2)
svg0.set_tab(True)
svg0.set_slot(True)
- svg_str = svg0.basic_block()
+ svg0.set_no_arm(True)
+ svg_str = svg0.sandwich_top()
+ f.write(svg_str)
+ close_file(f)
+
+ """
+ svgt = SVG()
+ svgt.set_orientation(180)
+ f = open_file(datapath, "turtle180.svg")
+ svg_str = svgt.turtle(["#FF0000","#00FF00"])
f.write(svg_str)
close_file(f)
+
svg2 = SVG()
f = open_file(datapath, "box-test.svg")
svg2.set_scale(1)
diff --git a/tawindow.py b/tawindow.py
index 987582d..d451e5f 100644
--- a/tawindow.py
+++ b/tawindow.py
@@ -1450,7 +1450,7 @@ class TurtleArtWindow():
def _uncollapse_forks(self, top, looping=False):
if top == None:
return
- if looping and top.name == 'sandwichtop':
+ if looping and top.name == 'sandwichtop' or top.name == 'sandwichtop2':
self._restore_stack(top)
return
if len(top.connections) == 0:
@@ -1459,11 +1459,11 @@ class TurtleArtWindow():
while b is not None:
if b.name in COLLAPSIBLE:
return
- if b.name == 'sandwichtop':
+ if b.name == 'sandwichtop' or b.name == 'sandwichtop2':
self._restore_stack(b)
return
# Follow a fork
- if b.name in ['repeat', 'if', 'ifelse', 'forever', 'while']:
+ if b.name in ['repeat','if','ifelse','forever','while','until']:
top = self._find_sandwich_top_below(
b.connections[len(b.connections)-2])
if top is not None:
@@ -1488,7 +1488,7 @@ class TurtleArtWindow():
if b.name in ['repeat', 'if', 'ifelse', 'forever', 'while']:
if blk != b.connections[len(b.connections)-1]:
return None
- if b.name == 'sandwichtop':
+ if b.name == 'sandwichtop' or b.name == 'sandwichtop2':
return b
blk = b
b = b.connections[0]
@@ -1501,7 +1501,7 @@ class TurtleArtWindow():
# Always follow the main branch of a flow: the last connection.
b = blk.connections[len(blk.connections)-1]
while b is not None:
- if b.name == 'sandwichtop':
+ if b.name == 'sandwichtop' or b.name == 'sandwichtop2':
return None
if b.name in COLLAPSIBLE:
return b
@@ -1512,12 +1512,12 @@ class TurtleArtWindow():
Find the sandwich top below this block.
"""
def _find_sandwich_top_below(self, blk):
- if blk.name == 'sandwichtop':
+ if blk.name == 'sandwichtop' or blk.name == 'sandwichtop2':
return blk
# Always follow the main branch of a flow: the last connection.
b = blk.connections[len(blk.connections)-1]
while b is not None:
- if b.name == 'sandwichtop':
+ if b.name == 'sandwichtop' or b.name == 'sandwichtop2':
return b
b = b.connections[len(b.connections)-1]
return None
@@ -1570,7 +1570,10 @@ class TurtleArtWindow():
b.status = 'collapsed'
else:
b.spr.move_relative((dx, dy))
- self._reset_stack_arm(top)
+ # Remove 'sandwichtop' arm
+ top.name = 'sandwichtop2'
+ top.refresh()
+ # self._reset_stack_arm(top)
"""
Restore all the blocks between the sandwich top and sandwich bottom.
@@ -1615,6 +1618,10 @@ class TurtleArtWindow():
b.status = None
else:
b.spr.move_relative((dx, dy))
+
+ # Add 'sandwichtop' arm
+ top.name = 'sandwichtop'
+ top.refresh()
self._grow_stack_arm(top)
"""