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
### 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

Wyświetl plik

@ -6,7 +6,7 @@
<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/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/objects.js?version=2019-06-02"></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 ////////////////////////////////////////////////////////
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();

Wyświetl plik

@ -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;
}