made "shown?" attribute inheritable

pull/89/head
jmoenig 2019-06-02 15:32:28 +02:00
rodzic 2e3cdac9f5
commit ee9eb87977
4 zmienionych plików z 46 dodań i 13 usunięć

Wyświetl plik

@ -86,7 +86,8 @@
* French * French
### 2019-06-02 ### 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 ### 2019-06-01
* Objects: new "pen down?" predicate * Objects: new "pen down?" predicate

Wyświetl plik

@ -6,7 +6,7 @@
<link rel="shortcut icon" href="src/favicon.ico"> <link rel="shortcut icon" href="src/favicon.ico">
<script type="text/javascript" src="src/morphic.js?version=2019-05-21"></script> <script type="text/javascript" src="src/morphic.js?version=2019-05-21"></script>
<script type="text/javascript" src="src/widgets.js?version=2019-04-05"></script> <script type="text/javascript" src="src/widgets.js?version=2019-04-05"></script>
<script type="text/javascript" src="src/blocks.js?version=2019-05-29"></script> <script type="text/javascript" src="src/blocks.js?version=2019-06-02"></script>
<script type="text/javascript" src="src/threads.js?version=2019-05-31"></script> <script type="text/javascript" src="src/threads.js?version=2019-05-31"></script>
<script type="text/javascript" src="src/objects.js?version=2019-06-02"></script> <script type="text/javascript" src="src/objects.js?version=2019-06-02"></script>
<script type="text/javascript" src="src/gui.js?version=2019-05-29"></script> <script type="text/javascript" src="src/gui.js?version=2019-05-29"></script>

Wyświetl plik

@ -148,7 +148,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
modules.blocks = '2019-May-29'; modules.blocks = '2019-June-02';
var SyntaxElementMorph; var SyntaxElementMorph;
var BlockMorph; var BlockMorph;
@ -2776,7 +2776,8 @@ BlockMorph.prototype.userMenu = function () {
getScale: 'size', getScale: 'size',
getCostumeIdx: 'costume #', getCostumeIdx: 'costume #',
getVolume: 'volume', getVolume: 'volume',
getPan: 'balance' getPan: 'balance',
reportShown: 'shown?'
}[this.selector]; }[this.selector];
if (field && rcvr && rcvr.exemplar) { if (field && rcvr && rcvr.exemplar) {
menu.addLine(); menu.addLine();

Wyświetl plik

@ -128,6 +128,7 @@ SpriteMorph.prototype.attributes =
'volume', 'volume',
'balance', 'balance',
'sounds', 'sounds',
'shown?',
'scripts' 'scripts'
]; ];
@ -2197,7 +2198,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('show')); blocks.push(block('show'));
blocks.push(block('hide')); blocks.push(block('hide'));
blocks.push(watcherToggle('reportShown')); blocks.push(watcherToggle('reportShown'));
blocks.push(block('reportShown')); blocks.push(block('reportShown', this.inheritsAttribute('shown?')));
blocks.push('-'); blocks.push('-');
blocks.push(block('goToLayer')); blocks.push(block('goToLayer'));
blocks.push(block('goBack')); blocks.push(block('goBack'));
@ -4039,17 +4040,41 @@ SpriteMorph.prototype.corpsify = function () {
nested parts. nested parts.
*/ */
SpriteMorph.prototype.hide = function () { SpriteMorph.prototype.show = function () {
SpriteMorph.uber.hide.call(this); this.setVisibility(true);
this.parts.forEach(function (part) {part.hide(); });
}; };
SpriteMorph.prototype.show = function () { SpriteMorph.prototype.hide = function () {
SpriteMorph.uber.show.call(this); this.setVisibility(false);
this.parts.forEach(function (part) {part.show(); }); };
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 () { SpriteMorph.prototype.reportShown = function () {
if (this.inheritsAttribute('shown?')) {
return this.exemplar.reportShown();
}
return this.isVisible; return this.isVisible;
}; };
@ -6184,7 +6209,8 @@ SpriteMorph.prototype.updatePropagationCache = function () {
'size', 'size',
'costume #', 'costume #',
'volume', 'volume',
'balance' 'balance',
'shown?'
], ],
function (att) { function (att) {
return contains(myself.inheritedAttributes, att); return contains(myself.inheritedAttributes, att);
@ -6308,6 +6334,10 @@ SpriteMorph.prototype.refreshInheritedAttribute = function (aName) {
this.cachedPropagation = true; this.cachedPropagation = true;
this.setVolume(this.getVolume(), true); this.setVolume(this.getVolume(), true);
break; break;
case 'shown?':
this.cachedPropagation = true;
this.setVisibility(this.reportShown(), true);
break;
case 'balance': case 'balance':
this.cachedPropagation = true; this.cachedPropagation = true;
this.setPan(this.getPan(), true); this.setPan(this.getPan(), true);
@ -10753,7 +10783,8 @@ WatcherMorph.prototype.update = function () {
getCostumeIdx: 'costume #', getCostumeIdx: 'costume #',
getScale: 'size', getScale: 'size',
getVolume: 'volume', getVolume: 'volume',
getPan: 'balance' getPan: 'balance',
reportShown: 'shown?'
} [this.getter]; } [this.getter];
isGhosted = att ? this.target.inheritsAttribute(att) : false; isGhosted = att ? this.target.inheritsAttribute(att) : false;
} }