summaryrefslogtreecommitdiff
path: root/objects.js
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2015-01-02 10:30:00 +0100
committerGubolin <gubolin@fantasymail.de>2015-01-02 10:30:00 +0100
commitaba651ba26bc9e79016b34070da5eacd407dac99 (patch)
tree8c92107550bbce2c715e32e90f4cd9a14fde7015 /objects.js
parent98755a4467991b6fb31563b17f8c15b1c5266294 (diff)
parentb31df39d7f126eaa303c8dae1cf6a14c739a2cc5 (diff)
downloadsnap-aba651ba26bc9e79016b34070da5eacd407dac99.tar.gz
snap-aba651ba26bc9e79016b34070da5eacd407dac99.zip
resolve merge conflictanykey_issue387
Diffstat (limited to 'objects.js')
-rw-r--r--objects.js101
1 files changed, 75 insertions, 26 deletions
diff --git a/objects.js b/objects.js
index db72b9c..1dc70d6 100644
--- a/objects.js
+++ b/objects.js
@@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.objects = '2014-October-08';
+modules.objects = '2014-December-17';
var SpriteMorph;
var StageMorph;
@@ -793,6 +793,12 @@ SpriteMorph.prototype.initBlocks = function () {
category: 'sensing',
spec: 'frames'
},
+ reportThreadCount: {
+ dev: true,
+ type: 'reporter',
+ category: 'sensing',
+ spec: 'processes'
+ },
doAsk: {
type: 'command',
category: 'sensing',
@@ -1156,6 +1162,13 @@ SpriteMorph.prototype.initBlocks = function () {
category: 'lists',
spec: 'map %repRing over %l'
},
+ doForEach: {
+ dev: true,
+ type: 'command',
+ category: 'lists',
+ spec: 'for %upvar in %l %cs',
+ defaults: [localize('each item')]
+ },
// Code mapping - experimental
doMapCodeOrHeader: { // experimental
@@ -1679,6 +1692,20 @@ SpriteMorph.prototype.blockTemplates = function (category) {
return menu;
}
+ function addVar(pair) {
+ if (pair) {
+ if (myself.variables.silentFind(pair[0])) {
+ myself.inform('that name is already in use');
+ } else {
+ myself.addVariable(pair[0], pair[1]);
+ myself.toggleVariableWatcher(pair[0], pair[1]);
+ myself.blocksCache[cat] = null;
+ myself.paletteCache[cat] = null;
+ myself.parentThatIsA(IDE_Morph).refreshPalette();
+ }
+ }
+ }
+
if (cat === 'motion') {
blocks.push(block('forward'));
@@ -1903,6 +1930,8 @@ SpriteMorph.prototype.blockTemplates = function (category) {
txt.setColor(this.paletteTextColor);
blocks.push(txt);
blocks.push('-');
+ blocks.push(watcherToggle('reportThreadCount'));
+ blocks.push(block('reportThreadCount'));
blocks.push(block('colorFiltered'));
blocks.push(block('reportStackSize'));
blocks.push(block('reportFrameCount'));
@@ -1973,15 +2002,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
function () {
new VariableDialogMorph(
null,
- function (pair) {
- if (pair && !myself.variables.silentFind(pair[0])) {
- myself.addVariable(pair[0], pair[1]);
- myself.toggleVariableWatcher(pair[0], pair[1]);
- myself.blocksCache[cat] = null;
- myself.paletteCache[cat] = null;
- myself.parentThatIsA(IDE_Morph).refreshPalette();
- }
- },
+ addVar,
myself
).prompt(
'Variable name',
@@ -2063,6 +2084,8 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(txt);
blocks.push('-');
blocks.push(block('reportMap'));
+ blocks.push('-');
+ blocks.push(block('doForEach'));
}
/////////////////////////////////
@@ -2170,8 +2193,8 @@ SpriteMorph.prototype.freshPalette = function (category) {
var defs = SpriteMorph.prototype.blocks,
hiddens = StageMorph.prototype.hiddenPrimitives;
return Object.keys(hiddens).some(function (any) {
- return defs[any].category === category ||
- contains((more[category] || []), any);
+ return !isNil(defs[any]) && (defs[any].category === category
+ || contains((more[category] || []), any));
});
}
@@ -2210,7 +2233,7 @@ SpriteMorph.prototype.freshPalette = function (category) {
var hiddens = StageMorph.prototype.hiddenPrimitives,
defs = SpriteMorph.prototype.blocks;
Object.keys(hiddens).forEach(function (sel) {
- if (defs[sel].category === category) {
+ if (defs[sel] && (defs[sel].category === category)) {
delete StageMorph.prototype.hiddenPrimitives[sel];
}
});
@@ -3238,8 +3261,11 @@ SpriteMorph.prototype.setCenter = function (aPoint, justMe) {
SpriteMorph.prototype.nestingBounds = function () {
// same as fullBounds(), except that it uses "parts" instead of children
- var result;
- result = this.bounds;
+ // and special cases the costume-less "arrow" shape's bounding box
+ var result = this.bounds;
+ if (!this.costume && this.penBounds) {
+ result = this.penBounds.translateBy(this.position());
+ }
this.parts.forEach(function (part) {
if (part.isVisible) {
result = result.merge(part.nestingBounds());
@@ -3589,6 +3615,16 @@ SpriteMorph.prototype.reportMouseY = function () {
return 0;
};
+// SpriteMorph thread count (for debugging)
+
+SpriteMorph.prototype.reportThreadCount = function () {
+ var stage = this.parentThatIsA(StageMorph);
+ if (stage) {
+ return stage.threads.processes.length;
+ }
+ return 0;
+};
+
// SpriteMorph variable watchers (for palette checkbox toggling)
SpriteMorph.prototype.findVariableWatcher = function (varName) {
@@ -4896,6 +4932,20 @@ StageMorph.prototype.blockTemplates = function (category) {
);
}
+ function addVar(pair) {
+ if (pair) {
+ if (myself.variables.silentFind(pair[0])) {
+ myself.inform('that name is already in use');
+ } else {
+ myself.addVariable(pair[0], pair[1]);
+ myself.toggleVariableWatcher(pair[0], pair[1]);
+ myself.blocksCache[cat] = null;
+ myself.paletteCache[cat] = null;
+ myself.parentThatIsA(IDE_Morph).refreshPalette();
+ }
+ }
+ }
+
if (cat === 'motion') {
txt = new TextMorph(localize(
@@ -5066,6 +5116,8 @@ StageMorph.prototype.blockTemplates = function (category) {
txt.setColor(this.paletteTextColor);
blocks.push(txt);
blocks.push('-');
+ blocks.push(watcherToggle('reportThreadCount'));
+ blocks.push(block('reportThreadCount'));
blocks.push(block('colorFiltered'));
blocks.push(block('reportStackSize'));
blocks.push(block('reportFrameCount'));
@@ -5138,15 +5190,7 @@ StageMorph.prototype.blockTemplates = function (category) {
function () {
new VariableDialogMorph(
null,
- function (pair) {
- if (pair && !myself.variables.silentFind(pair[0])) {
- myself.addVariable(pair[0], pair[1]);
- myself.toggleVariableWatcher(pair[0], pair[1]);
- myself.blocksCache[cat] = null;
- myself.paletteCache[cat] = null;
- myself.parentThatIsA(IDE_Morph).refreshPalette();
- }
- },
+ addVar,
myself
).prompt(
'Variable name',
@@ -5222,6 +5266,8 @@ StageMorph.prototype.blockTemplates = function (category) {
blocks.push(txt);
blocks.push('-');
blocks.push(block('reportMap'));
+ blocks.push('-');
+ blocks.push(block('doForEach'));
}
/////////////////////////////////
@@ -5360,7 +5406,7 @@ StageMorph.prototype.thumbnail = function (extentPoint, excludedSprite) {
this.dimensions.y * this.scale
);
this.children.forEach(function (morph) {
- if (morph !== excludedSprite) {
+ if (morph.isVisible && (morph !== excludedSprite)) {
fb = morph.fullBounds();
fimg = morph.fullImage();
if (fimg.width && fimg.height) {
@@ -5522,6 +5568,9 @@ StageMorph.prototype.watcherFor =
StageMorph.prototype.getLastAnswer
= SpriteMorph.prototype.getLastAnswer;
+StageMorph.prototype.reportThreadCount
+ = SpriteMorph.prototype.reportThreadCount;
+
// StageMorph message broadcasting
StageMorph.prototype.allMessageNames
@@ -6770,7 +6819,7 @@ WatcherMorph.prototype.object = function () {
WatcherMorph.prototype.isGlobal = function (selector) {
return contains(
['getLastAnswer', 'getKeysPressed', 'getLastMessage', 'getTempo', 'getTimer',
- 'reportMouseX', 'reportMouseY'],
+ 'reportMouseX', 'reportMouseY', 'reportThreadCount'],
selector
);
};