Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPootle daemon <pootle@pootle.sugarlabs.org>2012-07-08 04:32:37 (GMT)
committer Pootle daemon <pootle@pootle.sugarlabs.org>2012-07-08 04:32:37 (GMT)
commit9f4b20e2e913269d9a5447924235cbe6e6c86687 (patch)
tree4ba1341414284558879ee8998d0529f4638fd824
parent136b378639728b78c0fe0fe552bec20afafa264e (diff)
parentc288a269deee737c34e8b2415da17a75fda82349 (diff)
Merge branch 'master' of git.sugarlabs.org:turtleart/mainline
-rw-r--r--TurtleArt/tablock.py40
-rw-r--r--TurtleArt/taconstants.py5
-rw-r--r--TurtleArt/talogo.py15
-rw-r--r--TurtleArt/tapalette.py8
-rw-r--r--TurtleArt/tawindow.py20
-rw-r--r--taextras.py4
6 files changed, 75 insertions, 17 deletions
diff --git a/TurtleArt/tablock.py b/TurtleArt/tablock.py
index 5393b44..7e48d43 100644
--- a/TurtleArt/tablock.py
+++ b/TurtleArt/tablock.py
@@ -362,6 +362,42 @@ class Block:
self.svg.set_show(False)
self.refresh()
+ def contract_in_y(self, dy):
+ """ We may want to shrink a block veritcally. """
+ if self.spr is None:
+ return
+ self.ey -= dy
+ if self.ey < 0:
+ self.ey = 0
+ if self.type == 'block':
+ if self.ey > 0:
+ self.svg.set_hide(True)
+ else:
+ self.svg.set_hide(False)
+ self.svg.set_show(True)
+ else:
+ self.svg.set_hide(False)
+ self.svg.set_show(False)
+ self.refresh()
+
+ def contract_in_x(self, dx):
+ """ We may want to shrink a block horizontally. """
+ if self.spr is None:
+ return
+ self.ex -= dx
+ if self.ex < 0:
+ self.ex = 0
+ if self.type == 'block':
+ if self.ex > 0:
+ self.svg.set_hide(True)
+ else:
+ self.svg.set_hide(False)
+ self.svg.set_show(True)
+ else:
+ self.svg.set_hide(False)
+ self.svg.set_show(False)
+ self.refresh()
+
def reset_x(self):
if self.spr is None:
return 0
@@ -551,8 +587,8 @@ class Block:
else:
self.block_methods[k](svg)
return
- error_output('block type not found %s' % (self.name))
- self.block_methods['basic-style'](svg)
+ error_output('ERROR: block type not found %s' % (self.name))
+ self.block_methods['blank-style'](svg)
def _set_colors(self, svg):
if self._custom_colors:
diff --git a/TurtleArt/taconstants.py b/TurtleArt/taconstants.py
index f5af623..8cba7c2 100644
--- a/TurtleArt/taconstants.py
+++ b/TurtleArt/taconstants.py
@@ -90,9 +90,8 @@ EXPANDABLE_STYLE = ['boolean-style', 'compare-porch-style', 'compare-style',
'number-style-porch', 'number-style', 'basic-style-2arg',
'number-style-block', 'box-style-media']
-# Fixme: this should be based on styles
-EXPANDABLE_FLOW = ['repeat', 'until', 'while', 'if', 'forever', 'ifelse',
- 'sandwichclamp']
+# These are defined in add_block based on block style
+EXPANDABLE_FLOW = []
EXPANDABLE = ['vspace', 'hspace', 'identity2']
diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py
index 844f9e3..3e8fb0f 100644
--- a/TurtleArt/talogo.py
+++ b/TurtleArt/talogo.py
@@ -193,14 +193,13 @@ class LogoCode:
for b in blocks:
b.unhighlight()
+ # Hidden macro expansions
for b in blocks:
- # Hidden macro expansions
if b.name in ['while', 'until']:
action_blk, new_blocks = self._expand_forever(b, blk, blocks)
blocks = new_blocks[:]
if b == blk:
blk = action_blk
-
for b in blocks:
if b.name in ['forever']:
action_blk, new_blocks = self._expand_forever(b, blk, blocks)
@@ -261,7 +260,6 @@ class LogoCode:
if len(dock) > 4: # There could be a '(', ')', '[' or ']'.
code.append(dock[4])
if blk.primitive is not None: # make a tuple (prim, blk)
- # special case: expand 'while' and 'until' primitives
if blk in self.tw.block_list.list:
code.append((blk.primitive,
self.tw.block_list.list.index(blk)))
@@ -393,6 +391,7 @@ class LogoCode:
# If the blocks are visible, highlight the current block.
if not self.tw.hide and self.bindex is not None:
self.tw.block_list.list[self.bindex].highlight()
+
# In debugging modes, we pause between steps and show the turtle.
if self.tw.step_time > 0:
self.tw.active_turtle.show()
@@ -414,10 +413,12 @@ class LogoCode:
# Time to unhighlight the current block.
if not self.tw.hide and self.bindex is not None:
self.tw.block_list.list[self.bindex].unhighlight()
+
if self.procstop:
break
if self.iresult == None:
continue
+
if self.bindex is not None:
self.tw.block_list.list[self.bindex].highlight()
self.tw.showblocks()
@@ -853,11 +854,11 @@ class LogoCode:
inflow.connections[i] = action_blk
else:
i = None
+ j = None
if outflow is not None:
- j = outflow.connections.index(b)
- outflow.connections[j] = action_blk
- else:
- j = None
+ if b in outflow.connections:
+ j = outflow.connections.index(b)
+ outflow.connections[j] = action_blk
if until_blk and whileflow is not None:
action_first.connections.append(inflow)
diff --git a/TurtleArt/tapalette.py b/TurtleArt/tapalette.py
index dd5ca3f..b14c207 100644
--- a/TurtleArt/tapalette.py
+++ b/TurtleArt/tapalette.py
@@ -80,7 +80,7 @@ import gtk
from sugar.graphics.icon import Icon
from sugar.graphics import style
-from taconstants import EXPANDABLE_STYLE
+from taconstants import EXPANDABLE_STYLE, EXPANDABLE_FLOW
from tautils import debug_output
from util.helpbutton import add_section, add_paragraph
@@ -271,6 +271,12 @@ class Block():
return
else:
block_styles[self._style].append(self._name)
+ if self._style in ['clamp-style',
+ 'clamp-style-collapsible',
+ 'clamp-style-1arg',
+ 'clamp-style-boolean',
+ 'clamp-style-else']:
+ EXPANDABLE_FLOW.append(self._name)
if self._label is not None:
block_names[self._name] = self._label
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 97c70f3..d187580 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -2245,7 +2245,9 @@ class TurtleArtWindow():
elif blk.name == 'identity2' or blk.name == 'hspace':
group = find_group(blk)
if hide_button_hit(blk.spr, x, y):
- dx = blk.reset_x()
+ dx = -20
+ blk.contract_in_x(-dx)
+ # dx = blk.reset_x()
elif show_button_hit(blk.spr, x, y):
dx = 20
blk.expand_in_x(dx)
@@ -2259,7 +2261,9 @@ class TurtleArtWindow():
elif blk.name == 'vspace':
group = find_group(blk)
if hide_button_hit(blk.spr, x, y):
- dy = blk.reset_y()
+ dy = -20
+ blk.contract_in_y(-dy)
+ # dy = blk.reset_y()
elif show_button_hit(blk.spr, x, y):
dy = 20
blk.expand_in_y(dy)
@@ -2278,7 +2282,9 @@ class TurtleArtWindow():
dock0 = blk0.connections.index(blk)
if hide_button_hit(blk.spr, x, y):
- dy = blk.reset_y()
+ dy = -20
+ blk.contract_in_y(-dy)
+ # dy = blk.reset_y()
elif show_button_hit(blk.spr, x, y):
dy = 20
blk.expand_in_y(dy)
@@ -3340,6 +3346,14 @@ class TurtleArtWindow():
b[3] + self.canvas.cy + offset,
'block', values, self.block_scale)
+ # If it was an unknown block type, we need to match the number
+ # of dock items. TODO: Try to infer the dock type from connections
+ if len(b[4]) > len(blk.docks):
+ debug_output('dock mismatch %d > %d' % (len(b[4]), len(blk.docks)),
+ self.running_sugar)
+ for i in range(len(b[4]) - len(blk.docks)):
+ blk.docks.append(['unavailable', True, 0, 0])
+
# Some blocks get transformed.
if btype in block_styles['basic-style-var-arg'] and value is not None:
# Is there code stored in this userdefined block?
diff --git a/taextras.py b/taextras.py
index 4e04a76..1733ce7 100644
--- a/taextras.py
+++ b/taextras.py
@@ -238,6 +238,7 @@ polygon based on the current Turtle xy position.'),
_('reset'),
_('Reset the project; clear the object list.'),
_('motor'),
+ #TRANS: torque as in engine torque
_('torque'),
_('speed'),
_('Motor torque and speed range from 0 (off) to positive numbers; \
@@ -260,10 +261,11 @@ recent object created and the object at point x, y).'),
_('friction'),
_('Set the friction property for objects (value from 0 to 1, \
where 0 turns friction off and 1 is strong friction).'),
- # TRANS: bounciness is restitution
+ # TRANS: bounciness is coefficient of restitution
_('bounciness'),
_('Set the bounciness property for \
objects (a value from 0 to 1, where 0 means no bounce and 1 is very bouncy).'),
+ # TRANS: dynamic here means moving vs in a fixed position
_('dynamic'),
_('If dynamic = 1, the object can move; \
if dynamic = 0, it is fixed in position.')