summaryrefslogtreecommitdiff
path: root/objects.js
diff options
context:
space:
mode:
authorGubolin <gubolin@fantasymail.de>2015-02-24 10:06:26 +0100
committerGubolin <gubolin@fantasymail.de>2015-02-24 10:06:26 +0100
commit6ff8e7e2d6c983bafe0658d17cbbb14118980e92 (patch)
treea7386af920e295b9b053b88315541399467aab26 /objects.js
parent3c6380dfa5866cf3425f44b1d1eb08ef5c3baf1b (diff)
parent2ca378c50bf67b6af5e16ba72af81f4f84db308c (diff)
downloadsnap-6ff8e7e2d6c983bafe0658d17cbbb14118980e92.tar.gz
snap-6ff8e7e2d6c983bafe0658d17cbbb14118980e92.zip
Merge branch 'master' into github_backend
Diffstat (limited to 'objects.js')
-rw-r--r--objects.js70
1 files changed, 62 insertions, 8 deletions
diff --git a/objects.js b/objects.js
index 7277719..981fb20 100644
--- a/objects.js
+++ b/objects.js
@@ -9,7 +9,7 @@
written by Jens Mönig
jens@moenig.org
- Copyright (C) 2014 by Jens Mönig
+ Copyright (C) 2015 by Jens Mönig
This file is part of Snap!.
@@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.objects = '2014-December-04';
+modules.objects = '2015-January-21';
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',
@@ -1309,6 +1315,7 @@ SpriteMorph.prototype.init = function (globals) {
this.anchor = null;
this.nestingScale = 1;
this.rotatesWithAnchor = true;
+ this.layers = null; // cache for dragging nested sprites, don't serialize
this.blocksCache = {}; // not to be serialized (!)
this.paletteCache = {}; // not to be serialized (!)
@@ -1918,6 +1925,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'));
@@ -2634,7 +2643,9 @@ SpriteMorph.prototype.userMenu = function () {
menu.addItem("duplicate", 'duplicate');
menu.addItem("delete", 'remove');
menu.addItem("move", 'move');
- menu.addItem("edit", 'edit');
+ if (!this.isClone) {
+ menu.addItem("edit", 'edit');
+ }
menu.addLine();
if (this.anchor) {
menu.addItem(
@@ -2650,6 +2661,7 @@ SpriteMorph.prototype.userMenu = function () {
};
SpriteMorph.prototype.exportSprite = function () {
+ if (this.isCoone) {return; }
var ide = this.parentThatIsA(IDE_Morph);
if (ide) {
ide.exportSprite(this);
@@ -3143,13 +3155,11 @@ SpriteMorph.prototype.positionTalkBubble = function () {
bubble.changed();
};
-// dragging and dropping adjustments b/c of talk bubbles
+// dragging and dropping adjustments b/c of talk bubbles and parts
SpriteMorph.prototype.prepareToBeGrabbed = function (hand) {
- var bubble = this.talkBubble();
- if (!bubble) {return null; }
this.removeShadow();
- bubble.hide();
+ this.recordLayers();
if (!this.bounds.containsPoint(hand.position())) {
this.setCenter(hand.position());
}
@@ -3157,6 +3167,7 @@ SpriteMorph.prototype.prepareToBeGrabbed = function (hand) {
};
SpriteMorph.prototype.justDropped = function () {
+ this.restoreLayers();
this.positionTalkBubble();
};
@@ -3522,6 +3533,7 @@ SpriteMorph.prototype.mouseClickLeft = function () {
};
SpriteMorph.prototype.mouseDoubleClick = function () {
+ if (this.isClone) {return; }
this.edit();
};
@@ -3579,6 +3591,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) {
@@ -4023,6 +4045,33 @@ SpriteMorph.prototype.allAnchors = function () {
return result;
};
+SpriteMorph.prototype.recordLayers = function () {
+ var stage = this.parentThatIsA(StageMorph);
+ if (!stage) {
+ this.layerCache = null;
+ return;
+ }
+ this.layers = this.allParts();
+ this.layers.forEach(function (part) {
+ var bubble = part.talkBubble();
+ if (bubble) {bubble.hide(); }
+ });
+ this.layers.sort(function (x, y) {
+ return stage.children.indexOf(x) < stage.children.indexOf(y) ?
+ -1 : 1;
+ });
+};
+
+SpriteMorph.prototype.restoreLayers = function () {
+ if (this.layers && this.layers.length > 1) {
+ this.layers.forEach(function (sprite) {
+ sprite.comeToFront();
+ sprite.positionTalkBubble();
+ });
+ }
+ this.layers = null;
+};
+
// SpriteMorph highlighting
SpriteMorph.prototype.addHighlight = function (oldHighlight) {
@@ -5059,6 +5108,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'));
@@ -5509,6 +5560,9 @@ StageMorph.prototype.watcherFor =
StageMorph.prototype.getLastAnswer
= SpriteMorph.prototype.getLastAnswer;
+StageMorph.prototype.reportThreadCount
+ = SpriteMorph.prototype.reportThreadCount;
+
// StageMorph message broadcasting
StageMorph.prototype.allMessageNames
@@ -6757,7 +6811,7 @@ WatcherMorph.prototype.object = function () {
WatcherMorph.prototype.isGlobal = function (selector) {
return contains(
['getLastAnswer', 'getLastMessage', 'getTempo', 'getTimer',
- 'reportMouseX', 'reportMouseY'],
+ 'reportMouseX', 'reportMouseY', 'reportThreadCount'],
selector
);
};