Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2010-09-17 16:29:10 (GMT)
committer Walter Bender <walter@sugarlabs.org>2010-09-17 16:29:10 (GMT)
commita4828b634d1c8e6374785f503da26a6def3d8ade (patch)
tree9bf49d163f3c62aaf591e05e444bc502484db3d7 /TurtleArt
parenta70753dd5b92f6fa519170c484208091b634a7cf (diff)
expandable 2-arg blocks
Diffstat (limited to 'TurtleArt')
-rw-r--r--TurtleArt/tablock.py23
-rw-r--r--TurtleArt/taconstants.py14
-rw-r--r--TurtleArt/tawindow.py16
3 files changed, 37 insertions, 16 deletions
diff --git a/TurtleArt/tablock.py b/TurtleArt/tablock.py
index ab90373..5c83dff 100644
--- a/TurtleArt/tablock.py
+++ b/TurtleArt/tablock.py
@@ -20,7 +20,21 @@
#THE SOFTWARE.
import gtk
-from taconstants import *
+from taconstants import EXPANDABLE, EXPANDABLE_BLOCKS, EXPANDABLE_ARGS, \
+ PRIMITIVES, OLD_NAMES, BLOCK_SCALE, BLOCK_NAMES, CONTENT_BLOCKS, \
+ PALETTES, COLORS, BASIC_STYLE_HEAD, BASIC_STYLE_HEAD_1ARG, \
+ BASIC_STYLE_TAIL, BASIC_STYLE, BASIC_STYLE_EXTENDED, BASIC_STYLE_1ARG, \
+ BASIC_STYLE_VAR_ARG, BULLET_STYLE, BASIC_STYLE_2ARG, BOX_STYLE, \
+ BOX_STYLE_MEDIA, NUMBER_STYLE, NUMBER_STYLE_VAR_ARG, NUMBER_STYLE_BLOCK, \
+ NUMBER_STYLE_PORCH, NUMBER_STYLE_1ARG, NUMBER_STYLE_1STRARG, \
+ COMPARE_STYLE, BOOLEAN_STYLE, NOT_STYLE, FLOW_STYLE, FLOW_STYLE_TAIL, \
+ FLOW_STYLE_1ARG, FLOW_STYLE_BOOLEAN, FLOW_STYLE_WHILE, FLOW_STYLE_ELSE, \
+ COLLAPSIBLE_TOP, COLLAPSIBLE_TOP_NO_ARM, COLLAPSIBLE_TOP_NO_LABEL, \
+ COLLAPSIBLE_TOP_NO_ARM_NO_LABEL, COLLAPSIBLE_BOTTOM, PORTFOLIO_STYLE_2x2, \
+ PORTFOLIO_STYLE_1x1, PORTFOLIO_STYLE_2x1, PORTFOLIO_STYLE_1x2, BOX_COLORS, \
+ STANDARD_STROKE_WIDTH, SELECTED_STROKE_WIDTH, SELECTED_COLOR
+
+
from tasprite_factory import SVG, svg_str_to_pixbuf
import sprites
from gettext import gettext as _
@@ -105,6 +119,8 @@ class Block:
# If there is already a block with the same name, reuse it
copy_block = None
if self.name not in EXPANDABLE and \
+ self.name not in EXPANDABLE_BLOCKS and \
+ self.name not in EXPANDABLE_ARGS and \
self.name not in ['string', 'sandwichtop', 'sandwichtop_no_label']:
for b in block_list.list:
if b.scale == self.scale and b.name == self.name:
@@ -279,7 +295,10 @@ class Block:
self.shapes[1] = copy_block.shapes[1]
self.docks = copy_block.docks[:]
else:
- if self.name in EXPANDABLE and self.type == 'block':
+ if (self.name in EXPANDABLE or \
+ self.name in EXPANDABLE_BLOCKS or \
+ self.name in EXPANDABLE_ARGS) and \
+ self.type == 'block':
self.svg.set_show(True)
self._make_block(self.svg)
diff --git a/TurtleArt/taconstants.py b/TurtleArt/taconstants.py
index 7ad4aa1..097bd5c 100644
--- a/TurtleArt/taconstants.py
+++ b/TurtleArt/taconstants.py
@@ -237,15 +237,15 @@ PORTFOLIO_STYLE_1x2 = ['template1x2']
#
# Blocks that are expandable
#
-EXPANDABLE = ['vspace', 'hspace', 'templatelist', 'list', 'identity2',
- 'myfunc1arg', 'myfunc2arg', 'myfunc3arg', 'userdefined',
- 'userdefined2args', 'userdefined3args', 'plus2', 'minus2',
- 'division2', 'remainder2', 'product2', 'random', 'equal2',
- 'greater2', 'less2', 'and2', 'or2']
+EXPANDABLE = ['vspace', 'hspace', 'identity2']
-EXPANDABLE_MATH = ['plus2', 'minus2','division2', 'remainder2', 'product2',
- 'random', 'equal2', 'greater2', 'less2', 'and2', 'or2']
+EXPANDABLE_BLOCKS = ['plus2', 'minus2','division2', 'remainder2', 'product2',
+ 'random', 'equal2', 'greater2', 'less2', 'and2', 'or2',
+ 'arc', 'setxy', 'fillscreen', 'storein', 'write']
+EXPANDABLE_ARGS = ['templatelist', 'list', 'myfunc1arg', 'myfunc2arg',
+ 'myfunc3arg', 'userdefined', 'userdefined2args',
+ 'userdefined3args']
#
# Blocks that are 'collapsible'
#
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 743647b..3100d7c 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -49,8 +49,8 @@ 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, EXPANDABLE_MATH, COMPARE_STYLE, \
- BOOLEAN_STYLE
+ TURTLE_LAYER, EXPANDABLE_BLOCKS, COMPARE_STYLE, \
+ BOOLEAN_STYLE, EXPANDABLE_ARGS
from talogo import LogoCode, stop_logo
from tacanvas import TurtleGraphics
from tablock import Blocks, Block
@@ -1416,7 +1416,7 @@ 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:
+ elif blk.name in EXPANDABLE_BLOCKS:
if hide_button_hit(blk.spr, x, y):
dy = blk.reset_y()
elif show_button_hit(blk.spr, x, y):
@@ -1438,7 +1438,7 @@ class TurtleArtWindow():
for gblk in find_group(blk):
gblk.spr.move_relative((0, -dy * blk.scale))
grow_stack_arm(find_sandwich_top(blk))
- elif blk.name in EXPANDABLE or blk.name == 'nop':
+ elif blk.name in EXPANDABLE_ARGS or blk.name == 'nop':
if show_button_hit(blk.spr, x, y):
n = len(blk.connections)
group = find_group(blk.connections[n-1])
@@ -2036,8 +2036,9 @@ class TurtleArtWindow():
elif btype == 'start': # block size is saved in start block
if value is not None:
self.block_scale = value
- elif btype in EXPANDABLE or btype == 'nop':
- if btype == 'vspace' or btype in EXPANDABLE_MATH:
+ elif btype in EXPANDABLE or btype in EXPANDABLE_BLOCKS or \
+ btype in EXPANDABLE_ARGS or btype == 'nop':
+ if btype == 'vspace' or btype in EXPANDABLE_BLOCKS:
if value is not None:
blk.expand_in_y(value)
elif btype == 'hspace' or btype == 'identity2':
@@ -2151,7 +2152,8 @@ class TurtleArtWindow():
_name = (_blk.name, _blk.values[0])
else:
_name = (_blk.name)
- elif _blk.name in EXPANDABLE:
+ elif _blk.name in EXPANDABLE or _blk.name in EXPANDABLE_BLOCKS or \
+ _blk.name in EXPANDABLE_ARGS:
_ex, _ey = _blk.get_expand_x_y()
if _ex > 0:
_name = (_blk.name, _ex)