diff --git a/HISTORY.md b/HISTORY.md
index dd83bf05..a2a0f93b 100755
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -86,7 +86,8 @@
* French
### 2019-06-02
-* Objects, store: made "pen down?" and "shown?" attributes watchable onstage
+* Objects, Store: made "pen down?" and "shown?" attributes watchable onstage
+* Objects, Blocks: made "shown?" attribute inheritable
### 2019-06-01
* Objects: new "pen down?" predicate
diff --git a/snap.html b/snap.html
index 76247d7d..ccd118e7 100755
--- a/snap.html
+++ b/snap.html
@@ -6,7 +6,7 @@
-
+
diff --git a/src/blocks.js b/src/blocks.js
index 3e0ae5d5..5e033ae3 100644
--- a/src/blocks.js
+++ b/src/blocks.js
@@ -148,7 +148,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.blocks = '2019-May-29';
+modules.blocks = '2019-June-02';
var SyntaxElementMorph;
var BlockMorph;
@@ -2776,7 +2776,8 @@ BlockMorph.prototype.userMenu = function () {
getScale: 'size',
getCostumeIdx: 'costume #',
getVolume: 'volume',
- getPan: 'balance'
+ getPan: 'balance',
+ reportShown: 'shown?'
}[this.selector];
if (field && rcvr && rcvr.exemplar) {
menu.addLine();
diff --git a/src/objects.js b/src/objects.js
index 39b200d1..b4f86a53 100644
--- a/src/objects.js
+++ b/src/objects.js
@@ -128,6 +128,7 @@ SpriteMorph.prototype.attributes =
'volume',
'balance',
'sounds',
+ 'shown?',
'scripts'
];
@@ -2197,7 +2198,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('show'));
blocks.push(block('hide'));
blocks.push(watcherToggle('reportShown'));
- blocks.push(block('reportShown'));
+ blocks.push(block('reportShown', this.inheritsAttribute('shown?')));
blocks.push('-');
blocks.push(block('goToLayer'));
blocks.push(block('goBack'));
@@ -4039,17 +4040,41 @@ SpriteMorph.prototype.corpsify = function () {
nested parts.
*/
-SpriteMorph.prototype.hide = function () {
- SpriteMorph.uber.hide.call(this);
- this.parts.forEach(function (part) {part.hide(); });
+SpriteMorph.prototype.show = function () {
+ this.setVisibility(true);
};
-SpriteMorph.prototype.show = function () {
- SpriteMorph.uber.show.call(this);
- this.parts.forEach(function (part) {part.show(); });
+SpriteMorph.prototype.hide = function () {
+ this.setVisibility(false);
+};
+
+SpriteMorph.prototype.setVisibility = function (bool, noShadow) {
+ if (bool) {
+ SpriteMorph.uber.show.call(this);
+ } else {
+ SpriteMorph.uber.hide.call(this);
+ }
+
+ // progagate to parts
+ this.parts.forEach(function (part) {part.setVisibility(bool); });
+
+ // propagate to children that inherit my visibility
+ if (!noShadow) {
+ this.shadowAttribute('shown?');
+ }
+ this.instances.forEach(function (instance) {
+ if (instance.cachedPropagation) {
+ if (instance.inheritsAttribute('shown?')) {
+ instance.setVisibility(bool, true);
+ }
+ }
+ });
};
SpriteMorph.prototype.reportShown = function () {
+ if (this.inheritsAttribute('shown?')) {
+ return this.exemplar.reportShown();
+ }
return this.isVisible;
};
@@ -6184,7 +6209,8 @@ SpriteMorph.prototype.updatePropagationCache = function () {
'size',
'costume #',
'volume',
- 'balance'
+ 'balance',
+ 'shown?'
],
function (att) {
return contains(myself.inheritedAttributes, att);
@@ -6308,6 +6334,10 @@ SpriteMorph.prototype.refreshInheritedAttribute = function (aName) {
this.cachedPropagation = true;
this.setVolume(this.getVolume(), true);
break;
+ case 'shown?':
+ this.cachedPropagation = true;
+ this.setVisibility(this.reportShown(), true);
+ break;
case 'balance':
this.cachedPropagation = true;
this.setPan(this.getPan(), true);
@@ -10753,7 +10783,8 @@ WatcherMorph.prototype.update = function () {
getCostumeIdx: 'costume #',
getScale: 'size',
getVolume: 'volume',
- getPan: 'balance'
+ getPan: 'balance',
+ reportShown: 'shown?'
} [this.getter];
isGhosted = att ? this.target.inheritsAttribute(att) : false;
}