Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2011-07-27 23:48:14 (GMT)
committer Walter Bender <walter.bender@gmail.com>2011-07-27 23:48:14 (GMT)
commite5c8c283d0f43e35bc76898f099fb50de252d3b0 (patch)
treeca9e65eac932c6dcdf1deed7154d926ad09c4668
parentd4d6e0b44f551328e92159bdf2cee3f4ba403f9b (diff)
clean up block rescaling code; move more constants inits to plugins
-rw-r--r--TurtleArt/taconstants.py21
-rw-r--r--TurtleArt/tawindow.py11
-rw-r--r--plugins/camera_sensor/camera_sensor.py4
-rw-r--r--plugins/turtle_blocks_extras/turtle_blocks_extras.py17
4 files changed, 34 insertions, 19 deletions
diff --git a/TurtleArt/taconstants.py b/TurtleArt/taconstants.py
index b39c1b7..857801e 100644
--- a/TurtleArt/taconstants.py
+++ b/TurtleArt/taconstants.py
@@ -103,15 +103,6 @@ COLLAPSIBLE = ['sandwichbottom', 'sandwichcollapsed']
OLD_DOCK = ['and', 'or', 'plus', 'minus', 'division', 'product', 'remainder']
#
-# These blocks get a special skin
-#
-BLOCKS_WITH_SKIN = ['journal', 'audio', 'description', 'nop', 'userdefined',
- 'video', 'userdefined2args', 'userdefined3args', 'camera']
-
-PYTHON_SKIN = ['nop', 'userdefined', 'userdefined2args', 'userdefined3args']
-
-
-#
# Blocks that can interchange strings and numbers for their arguments
#
STRING_OR_NUMBER_ARGS = ['plus2', 'equal2', 'less2', 'greater2', 'box',
@@ -125,12 +116,15 @@ STRING_OR_NUMBER_ARGS = ['plus2', 'equal2', 'less2', 'greater2', 'box',
CONTENT_ARGS = ['show', 'showaligned', 'push', 'storein', 'storeinbox1',
'storeinbox2']
-PREFIX_DICTIONARY = {'journal': '#smedia_', 'description': '#sdescr_',
- 'audio': '#saudio_', 'video': '#svideo_'}
+PREFIX_DICTIONARY = {}
#
-# Status blocks
+# These blocks get a special skin
#
+BLOCKS_WITH_SKIN = []
+
+PYTHON_SKIN = []
+
SKIN_PATHS = ['images']
MEDIA_SHAPES = []
@@ -139,6 +133,9 @@ NO_IMPORT = []
EXPAND_SKIN = {}
+#
+# Status blocks
+#
OVERLAY_SHAPES = ['Cartesian', 'Cartesian_labeled', 'polar', 'metric']
STATUS_SHAPES = ['status', 'info', 'nostack', 'dupstack', 'noinput',
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 09f9273..f8ff41c 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -772,9 +772,9 @@ class TurtleArtWindow():
# Some proto blocks get a skin.
if name in block_styles['box-style-media']:
self._proto_skin(name + 'small', n, i)
- elif name[:8] == 'template':
+ elif name[:8] == 'template': # Deprecated
self._proto_skin(name[8:], n, i)
- elif name[:7] == 'picture':
+ elif name[:7] == 'picture': # Deprecated
self._proto_skin(name[7:], n, i)
elif name in PYTHON_SKIN:
self._proto_skin('pythonsmall', n, i)
@@ -2622,11 +2622,11 @@ class TurtleArtWindow():
else:
self._block_skin('pythonoff', blk)
elif btype in block_styles['box-style-media'] and blk.spr is not None:
+ if btype in EXPAND_SKIN:
+ if blk.ex == 0:
+ blk.expand_in_x(EXPAND_SKIN[btype])
if len(blk.values) == 0 or blk.values[0] == 'None' or \
blk.values[0] is None or btype in NO_IMPORT:
- if btype in EXPAND_SKIN:
- if blk.ex == 0:
- blk.expand_in_x(EXPAND_SKIN[btype])
self._block_skin(btype + 'off', blk)
elif btype in ['video', 'audio', 'description']:
self._block_skin(btype + 'on', blk)
@@ -2920,6 +2920,7 @@ class TurtleArtWindow():
target_w = spr.label_safe_width()
target_h = spr.label_safe_height()
if name == '':
+ debug_output("%d, %d" % (target_w, target_h))
return target_w, target_h
image_w = self.media_shapes[name].get_width()
image_h = self.media_shapes[name].get_height()
diff --git a/plugins/camera_sensor/camera_sensor.py b/plugins/camera_sensor/camera_sensor.py
index 32a394d..7228b8b 100644
--- a/plugins/camera_sensor/camera_sensor.py
+++ b/plugins/camera_sensor/camera_sensor.py
@@ -30,7 +30,8 @@ from plugins.plugin import Plugin
from TurtleArt.tapalette import make_palette
from TurtleArt.talogo import media_blocks_dictionary, primitive_dictionary
from TurtleArt.tautils import get_path, debug_output
-from TurtleArt.taconstants import MEDIA_SHAPES, NO_IMPORT, SKIN_PATHS
+from TurtleArt.taconstants import MEDIA_SHAPES, NO_IMPORT, SKIN_PATHS, \
+ BLOCKS_WITH_SKIN
class Camera_sensor(Plugin):
@@ -124,6 +125,7 @@ is pushed to the stack'),
content_block=True)
NO_IMPORT.append('camera')
+ BLOCKS_WITH_SKIN.append('camera')
MEDIA_SHAPES.append('camerasmall')
MEDIA_SHAPES.append('cameraoff')
diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
index 865fb13..831eb3c 100644
--- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py
+++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
@@ -30,7 +30,8 @@ from TurtleArt.tapalette import make_palette, define_logo_function
from TurtleArt.talogo import primitive_dictionary, logoerror, \
media_blocks_dictionary
from TurtleArt.taconstants import DEFAULT_SCALE, ICON_SIZE, CONSTANTS, \
- MEDIA_SHAPES, SKIN_PATHS
+ MEDIA_SHAPES, SKIN_PATHS, BLOCKS_WITH_SKIN, PYTHON_SKIN, \
+ PREFIX_DICTIONARY
from TurtleArt.tautils import convert, round_int, debug_output
from TurtleArt.tajail import myfunc, myfunc_import
@@ -122,6 +123,8 @@ boolean operators from Numbers palette'))
default='None',
special_name=_('journal'),
help_string=_('Sugar Journal media object'))
+ PREFIX_DICTIONARY['journal'] = '#smedia_'
+ BLOCKS_WITH_SKIN.append('journal')
MEDIA_SHAPES.append('journalsmall')
MEDIA_SHAPES.append('journaloff')
MEDIA_SHAPES.append('journalon')
@@ -132,6 +135,8 @@ boolean operators from Numbers palette'))
special_name=_('audio'),
default='None',
help_string=_('Sugar Journal audio object'))
+ BLOCKS_WITH_SKIN.append('audio')
+ PREFIX_DICTIONARY['audio'] = '#saudio_'
MEDIA_SHAPES.append('audiosmall')
MEDIA_SHAPES.append('audiooff')
MEDIA_SHAPES.append('audioon')
@@ -142,6 +147,8 @@ boolean operators from Numbers palette'))
special_name=_('video'),
default='None',
help_string=_('Sugar Journal video object'))
+ BLOCKS_WITH_SKIN.append('video')
+ PREFIX_DICTIONARY['video'] = '#svideo_'
MEDIA_SHAPES.append('videosmall')
MEDIA_SHAPES.append('videooff')
MEDIA_SHAPES.append('videoon')
@@ -152,6 +159,8 @@ boolean operators from Numbers palette'))
special_name=_('description'),
default='None',
help_string=_('Sugar Journal description field'))
+ BLOCKS_WITH_SKIN.append('description')
+ PREFIX_DICTIONARY['description'] = '#sdescr_'
MEDIA_SHAPES.append('descriptionsmall')
MEDIA_SHAPES.append('descriptionoff')
MEDIA_SHAPES.append('descriptionon')
@@ -438,6 +447,8 @@ advanced multi-variable math equations, e.g., sin(x+y+z)'))
module found in the Journal'))
self.tw.lc.def_prim('userdefined', 1,
lambda self, x: primitive_dictionary['userdefined']([x]))
+ BLOCKS_WITH_SKIN.append('userdefined')
+ PYTHON_SKIN.append('userdefined')
palette.add_block('userdefined2args',
hidden=True,
@@ -451,6 +462,8 @@ module found in the Journal'))
module found in the Journal'))
self.tw.lc.def_prim('userdefined2', 2,
lambda self, x, y: primitive_dictionary['userdefined']([x, y]))
+ BLOCKS_WITH_SKIN.append('userdefined2args')
+ PYTHON_SKIN.append('userdefined2args')
palette.add_block('userdefined3args',
hidden=True,
@@ -465,6 +478,8 @@ module found in the Journal'))
self.tw.lc.def_prim('userdefined3', 3,
lambda self, x, y, z: primitive_dictionary['userdefined'](
[x, y, z]))
+ BLOCKS_WITH_SKIN.append('userdefined3args')
+ PYTHON_SKIN.append('userdefined3args')
MEDIA_SHAPES.append('pythonsmall')
MEDIA_SHAPES.append('pythonoff')
MEDIA_SHAPES.append('pythonon')