made watchers immediately react to inheritance changes

pull/89/head
jmoenig 2019-06-02 16:09:29 +02:00
rodzic 13b10457e5
commit 5cfc67ae1a
2 zmienionych plików z 11 dodań i 7 usunięć

Wyświetl plik

@ -88,7 +88,8 @@
### 2019-06-02
* Objects, Store: made "pen down?" and "shown?" attributes watchable onstage
* Objects, Blocks: made "shown?" attribute inheritable
* Objects, Blocks: made "pen down?" attribute inheritable
* Objects, Blocks: made "pen down?" attribute inheritable
* Objects: made watchers immediately react to inheritance changes
### 2019-06-01
* Objects: new "pen down?" predicate

Wyświetl plik

@ -4295,11 +4295,11 @@ SpriteMorph.prototype.changeSize = function (delta) {
SpriteMorph.prototype.down = function () {
this.setPenDown(true);
}
};
SpriteMorph.prototype.up = function () {
this.setPenDown(false);
}
};
SpriteMorph.prototype.setPenDown = function (bool, noShadow) {
if (bool) {
@ -10707,6 +10707,7 @@ WatcherMorph.prototype.init = function (
this.labelText = label || '';
this.version = null;
this.objName = '';
this.isGhosted = false; // transient, don't persist
// initialize inherited properties
WatcherMorph.uber.init.call(
@ -10785,7 +10786,7 @@ WatcherMorph.prototype.setSliderMax = function (num, noUpdate) {
WatcherMorph.prototype.update = function () {
var newValue, sprite, num, att,
isGhosted = false;
isInherited = false;
if (this.target && this.getter) {
this.updateLabel();
@ -10826,7 +10827,7 @@ WatcherMorph.prototype.update = function () {
reportShown: 'shown?',
getPenDown: 'pen down?'
} [this.getter];
isGhosted = att ? this.target.inheritsAttribute(att) : false;
isInherited = att ? this.target.inheritsAttribute(att) : false;
}
if (newValue !== '' && !isNil(newValue)) {
num = +newValue;
@ -10834,11 +10835,13 @@ WatcherMorph.prototype.update = function () {
newValue = Math.round(newValue * 1000000000) / 1000000000;
}
}
if (newValue !== this.currentValue) {
if (newValue !== this.currentValue ||
isInherited !== this.isGhosted) {
this.changed();
this.cellMorph.contents = newValue;
this.isGhosted = isInherited;
if (isSnapObject(this.target)) {
if (isGhosted) {
if (isInherited) {
this.cellMorph.setColor(this.readoutColor.lighter(35));
} else {
this.cellMorph.setColor(this.readoutColor);