Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2010-09-16 20:52:29 (GMT)
committer Walter Bender <walter@sugarlabs.org>2010-09-16 20:52:29 (GMT)
commit7f262d557ecd676ea595e8a7287aae28c03850cb (patch)
treeace74cc9474821e974105a27c04a2c63f00992bb
parentaab4c5d6ec4e31b1270eef7df74d1a4f7b39fc9d (diff)
expandable math blocks
-rw-r--r--TurtleArt/taconstants.py6
-rw-r--r--TurtleArt/tawindow.py21
2 files changed, 24 insertions, 3 deletions
diff --git a/TurtleArt/taconstants.py b/TurtleArt/taconstants.py
index 684b5e6..06b72f5 100644
--- a/TurtleArt/taconstants.py
+++ b/TurtleArt/taconstants.py
@@ -233,7 +233,11 @@ PORTFOLIO_STYLE_1x2 = ['template1x2']
#
EXPANDABLE = ['vspace', 'hspace', 'templatelist', 'list', 'identity2',
'myfunc1arg', 'myfunc2arg', 'myfunc3arg', 'userdefined',
- 'userdefined2args', 'userdefined3args']
+ 'userdefined2args', 'userdefined3args', 'plus2', 'minus2',
+ 'division2', 'remainder2', 'product2', 'random']
+
+EXPANDABLE_MATH = ['plus2', 'minus2','division2', 'remainder2', 'product2',
+ 'random']
#
# Blocks that are 'collapsible'
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 2a8732f..2e1f974 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -49,7 +49,7 @@ from taconstants import HORIZONTAL_PALETTE, VERTICAL_PALETTE, BLOCK_SCALE, \
DEAD_DICTS, DEAD_KEYS, TEMPLATES, PYTHON_SKIN, \
PALETTE_HEIGHT, STATUS_LAYER, OLD_DOCK, OLD_NAMES, \
BOOLEAN_STYLE, BLOCK_NAMES, DEFAULT_TURTLE, \
- TURTLE_LAYER
+ TURTLE_LAYER, EXPANDABLE_MATH
from talogo import LogoCode, stop_logo
from tacanvas import TurtleGraphics
from tablock import Blocks, Block
@@ -1415,6 +1415,23 @@ class TurtleArtWindow():
if gblk != blk:
gblk.spr.move_relative((0, dy * blk.scale))
grow_stack_arm(find_sandwich_top(blk))
+ elif blk.name in EXPANDABLE_MATH:
+ if hide_button_hit(blk.spr, x, y):
+ dy = blk.reset_y()
+ elif show_button_hit(blk.spr, x, y):
+ dy = 20
+ blk.expand_in_y(dy)
+ else:
+ dy = 0
+ if blk.connections[1] is not None:
+ group = find_group(blk.connections[1])
+ group.append(blk)
+ else:
+ group = [blk]
+ for gblk in find_group(blk):
+ if gblk not in group:
+ gblk.spr.move_relative((0, dy * blk.scale))
+ grow_stack_arm(find_sandwich_top(blk))
elif blk.name in EXPANDABLE or blk.name == 'nop':
if show_button_hit(blk.spr, x, y):
n = len(blk.connections)
@@ -2014,7 +2031,7 @@ class TurtleArtWindow():
if value is not None:
self.block_scale = value
elif btype in EXPANDABLE or btype == 'nop':
- if btype == 'vspace':
+ if btype == 'vspace' or btype in EXPANDABLE_MATH:
if value is not None:
blk.expand_in_y(value)
elif btype == 'hspace' or btype == 'identity2':