From 1585a1664a9bbdb7c8efa5f3da361b4aaf6450e4 Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sun, 1 Mar 2015 09:51:26 +0100 Subject: remove language and location blocks --- objects.js | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'objects.js') diff --git a/objects.js b/objects.js index 5ad18e7..d0c32df 100644 --- a/objects.js +++ b/objects.js @@ -941,16 +941,6 @@ SpriteMorph.prototype.initBlocks = function () { category: 'sensing', spec: 'current acceleration along the z axes' }, - reportLanguage: { - type: 'reporter', - category: 'sensing', - spec: 'language' - }, - reportLocation: { - type: 'reporter', - category: 'sensing', - spec: 'location %locations' - }, // Operators reifyScript: { @@ -1986,9 +1976,6 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('reportDate')); blocks.push('-'); - blocks.push(block('reportLanguage')); - blocks.push(block('reportLocation')); - blocks.push('-'); blocks.push(block('doVibrate')); blocks.push('-'); blocks.push(block('reportCompassHeading')); @@ -5192,9 +5179,6 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('reportDate')); blocks.push('-'); - blocks.push(block('reportLanguage')); - blocks.push(block('reportLocation')); - blocks.push('-'); blocks.push(block('doVibrate')); blocks.push('-'); blocks.push(block('reportCompassHeading')); -- cgit v1.3.1 From e3f7a47d95711effb8ab4b95b1c5fdde9178a72a Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sun, 8 Mar 2015 15:15:29 +0100 Subject: destroy old peers properly --- objects.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'objects.js') diff --git a/objects.js b/objects.js index 282d01f..3a39a5c 100644 --- a/objects.js +++ b/objects.js @@ -4428,11 +4428,9 @@ StageMorph.prototype.initPeering = function (id) { if (window.peers) { // I don't know why, but it works. - window.peers.forEach(function (oldpeer) { - if (id != oldpeer.id) { - oldpeer.destroy() - } - }); + while (window.peers.length > 0) { + window.peers.pop().destroy(); + } } this.peer = new Peer(id, { -- cgit v1.3.1 From 916dfe65e4afe636ce42e178fe88815b4b86026d Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sun, 8 Mar 2015 16:13:29 +0100 Subject: another attempt to fix disconnect issues --- objects.js | 13 ++++--------- threads.js | 6 ++---- 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'objects.js') diff --git a/objects.js b/objects.js index 3a39a5c..b115b3b 100644 --- a/objects.js +++ b/objects.js @@ -4426,11 +4426,9 @@ StageMorph.prototype.init = function (globals) { StageMorph.prototype.initPeering = function (id) { var myself = this; - if (window.peers) { + if (window.peer) { // I don't know why, but it works. - while (window.peers.length > 0) { - window.peers.pop().destroy(); - } + window.peer.destroy(); } this.peer = new Peer(id, { @@ -4440,13 +4438,10 @@ StageMorph.prototype.initPeering = function (id) { path: '/' }); - this.peer.on('open', function (id) { - myself.peerId = id; - }); this.peer.on('disconnected', function () { // peer.reconnect does not work (?) because 'id' is undefined if (!myself.peer.destroyed) { - myself.initPeering(myself.peerId); + myself.initPeering(myself.peer.id); } }); this.peer.on('error', function (err) { @@ -4461,7 +4456,7 @@ StageMorph.prototype.initPeering = function (id) { }); }); - window.peers.push(this.peer); + window.peer = this.peer; }; StageMorph.prototype.newPeerMessage = function (data, peer) { diff --git a/threads.js b/threads.js index 165c7fc..d8ec04f 100644 --- a/threads.js +++ b/threads.js @@ -1302,15 +1302,13 @@ Process.prototype.sendPeerMessage = function (message, peer) { var stage = this.homeContext.receiver.parentThatIsA(StageMorph), ide = this.homeContext.receiver.parentThatIsA(IDE_Morph); - console.log(peer, stage.peerId); if (peer instanceof List) { peer.asArray().forEach(function (singlePeer) { myself.sendPeerMessage(message, singlePeer); }); return; } - if (peer == stage.peerId) { - console.log('hello self!'); + if (peer == stage.peer.id) { stage.newPeerMessage(message, peer); return; } @@ -1348,7 +1346,7 @@ Process.prototype.reportPeerList = function () { Process.prototype.reportPeerId = function () { var stage = this.homeContext.receiver.parentThatIsA(StageMorph); - return stage.peerId; + return stage.peer.id; }; // Process lists primitives -- cgit v1.3.1 From 9163b3ca714086e1877249bf38e47040bd1b3e67 Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sun, 8 Mar 2015 16:32:36 +0100 Subject: solve connection issues --- objects.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'objects.js') diff --git a/objects.js b/objects.js index b115b3b..e25f119 100644 --- a/objects.js +++ b/objects.js @@ -4426,11 +4426,6 @@ StageMorph.prototype.init = function (globals) { StageMorph.prototype.initPeering = function (id) { var myself = this; - if (window.peer) { - // I don't know why, but it works. - window.peer.destroy(); - } - this.peer = new Peer(id, { host: 'snapmesh.herokuapp.com', port: 443, @@ -4439,9 +4434,10 @@ StageMorph.prototype.initPeering = function (id) { }); this.peer.on('disconnected', function () { - // peer.reconnect does not work (?) because 'id' is undefined - if (!myself.peer.destroyed) { - myself.initPeering(myself.peer.id); + if (!myself.peer.destroyed && myself.peer.id) { + myself.peer.reconnect(); + } else { + myself.initPeering(); } }); this.peer.on('error', function (err) { @@ -4455,8 +4451,6 @@ StageMorph.prototype.initPeering = function (id) { }); }); }); - - window.peer = this.peer; }; StageMorph.prototype.newPeerMessage = function (data, peer) { -- cgit v1.3.1 From 121cf8b3658909f79571b621e9a9916c7f601dfc Mon Sep 17 00:00:00 2001 From: Gubolin Date: Fri, 20 Mar 2015 20:53:20 +0100 Subject: create one peer per IDE --- gui.js | 31 ++++++++++++++++++++++++++++++- objects.js | 33 +-------------------------------- threads.js | 14 +++++++------- 3 files changed, 38 insertions(+), 40 deletions(-) (limited to 'objects.js') diff --git a/gui.js b/gui.js index 1f51405..543f776 100644 --- a/gui.js +++ b/gui.js @@ -246,7 +246,36 @@ IDE_Morph.prototype.init = function (isAutoFill) { // override inherited properites: this.color = this.backgroundColor; - window.peers = []; + this.createPeer(); +}; + +IDE_Morph.prototype.createPeer = function() { + var myself = this; + this.peer = new Peer(this.peerId, { + host: 'snapmesh.herokuapp.com', + port: 443, + secure: true, + path: '/' + }); + + this.peer.on('open', function (id) { + myself.peerId = id; + }); + this.peer.on('disconnected', function () { + myself.peer.destroy(); + myself.createPeer(); + }); + this.peer.on('error', function (err) { + console.log(err); // DEBUG + }); + + this.peer.on('connection', function (connection) { + connection.on('open', function () { + connection.on('data', function (data) { + myself.stage.newPeerMessage(data, connection.peer); + }); + }); + }); }; IDE_Morph.prototype.openIn = function (world) { diff --git a/objects.js b/objects.js index e25f119..3859295 100644 --- a/objects.js +++ b/objects.js @@ -4419,42 +4419,11 @@ StageMorph.prototype.init = function (globals) { this.acceptsDrops = false; this.setColor(new Color(255, 255, 255)); this.fps = this.frameRate; - - this.initPeering(); -}; - -StageMorph.prototype.initPeering = function (id) { - var myself = this; - - this.peer = new Peer(id, { - host: 'snapmesh.herokuapp.com', - port: 443, - secure: true, - path: '/' - }); - - this.peer.on('disconnected', function () { - if (!myself.peer.destroyed && myself.peer.id) { - myself.peer.reconnect(); - } else { - myself.initPeering(); - } - }); - this.peer.on('error', function (err) { - console.log(err); // DEBUG - }); - - this.peer.on('connection', function (connection) { - connection.on('open', function () { - connection.on('data', function (data) { - myself.newPeerMessage(data, connection.peer); - }); - }); - }); }; StageMorph.prototype.newPeerMessage = function (data, peer) { var ide = this.parentThatIsA(IDE_Morph); + if (!ide || !peer) return; var myself = this; var hats = [], model, message; diff --git a/threads.js b/threads.js index d8ec04f..573b7fe 100644 --- a/threads.js +++ b/threads.js @@ -1308,12 +1308,12 @@ Process.prototype.sendPeerMessage = function (message, peer) { }); return; } - if (peer == stage.peer.id) { + if (peer == ide.peer.id) { stage.newPeerMessage(message, peer); return; } - var connection = stage.peer.connect(peer, {reliable: true}); + var connection = ide.peer.connect(peer, {reliable: true}); connection.on('open', function () { var data; if (typeof message == "string") { @@ -1331,11 +1331,11 @@ Process.prototype.reportPeerList = function () { var myself = this; if (!this.context.wait) { - var stage = this.homeContext.receiver.parentThatIsA(StageMorph); - stage.peer.listAllPeers(function (peers) { + this.context.wait = true; + var ide = this.homeContext.receiver.parentThatIsA(IDE_Morph); + ide.peer.listAllPeers(function (peers) { myself.context.result = new List(peers); }); - this.context.wait = true; } else if (this.context.result) { return this.context.result; } @@ -1345,8 +1345,8 @@ Process.prototype.reportPeerList = function () { }; Process.prototype.reportPeerId = function () { - var stage = this.homeContext.receiver.parentThatIsA(StageMorph); - return stage.peer.id; + var ide = this.homeContext.receiver.parentThatIsA(IDE_Morph); + return ide.peer.id; }; // Process lists primitives -- cgit v1.3.1 From 4acf1896bd9fa57d3dbe3f4721b6790c6f3b0d56 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Sat, 21 Mar 2015 11:12:43 +0100 Subject: Prototypal inheritance of sprite-local variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (experimental) slotwise inheritance à la Henry Lieberman for sprite-local variables. see http://web.media.mit.edu/~lieber/Lieberary/OOP/Delegation/Delegation.htm l Let a sprite inherit another sprite’s local variables by making it the “parent” in the sprite-icon’s context menu (the button icon in the sprite corral underneath the stage). The child not only inherits the variable slot but also - dynamically - the parent variable’s value. Changing the parent’s variable value also changes it for every child. If a child uses SET or CHANGE on an inherited variable it automatically “shadows” it with its own value, thereby stopping dynamic participation in the parent slot’s value (in effect dis-inheriting that slot). Deleting a shadowed variable slot once again reinstates its inheritance status. inherited variables are shown as “ghosted” both in the child’s variables palette and in such stage watchers. “Shadowing” them un-ghosts both the variable blob template in the palette and the watcher onstage (if any). Deleting a shadowed variable once again ghosts the watcher and the palette block template. Delete a (shadowed) variable either via the “Delete a variable” button in the IDE or using the new “Delete” block in the variables category --- blocks.js | 12 +++- gui.js | 18 ++++-- history.txt | 4 ++ morphic.js | 27 +++++--- objects.js | 206 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----- snap.html | 2 +- store.js | 45 +++++++++++-- threads.js | 73 ++++++++++++++------- widgets.js | 11 ++-- 9 files changed, 335 insertions(+), 63 deletions(-) (limited to 'objects.js') diff --git a/blocks.js b/blocks.js index aef09da..711976f 100644 --- a/blocks.js +++ b/blocks.js @@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2015-March-09'; +modules.blocks = '2015-March-21'; var SyntaxElementMorph; @@ -3016,6 +3016,12 @@ BlockMorph.prototype.alternateBlockColor = function () { this.fixChildrensBlockColor(true); // has issues if not forced }; +BlockMorph.prototype.ghost = function () { + this.setColor( + SpriteMorph.prototype.blockColor[this.category].lighter(35) + ); +}; + BlockMorph.prototype.fixLabelColor = function () { if (this.zebraContrast > 0 && this.category) { var clr = SpriteMorph.prototype.blockColor[this.category]; @@ -3096,6 +3102,10 @@ BlockMorph.prototype.mouseClickLeft = function () { } }; +BlockMorph.prototype.reactToTemplateCopy = function () { + this.forceNormalColoring(); +}; + // BlockMorph thumbnail BlockMorph.prototype.thumbnail = function (scale, clipWidth, noShadow) { diff --git a/gui.js b/gui.js index 50f3cb2..4cd2a9b 100644 --- a/gui.js +++ b/gui.js @@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2015-March-15'; +modules.gui = '2015-March-21'; // Declarations @@ -2598,7 +2598,7 @@ IDE_Morph.prototype.aboutSnap = function () { module, btn1, btn2, btn3, btn4, licenseBtn, translatorsBtn, world = this.world(); - aboutTxt = 'Snap! 4.0\nBuild Your Own Blocks\n\n--- rc ---\n\n' + aboutTxt = 'Snap! 4.1 (OOP)\nBuild Your Own Blocks\n\n--- dev ---\n\n' + 'Copyright \u24B8 2015 Jens M\u00F6nig and ' + 'Brian Harvey\n' + 'jens@moenig.org, bh@cs.berkeley.edu\n\n' @@ -5182,7 +5182,7 @@ function SpriteIconMorph(aSprite, aTemplate) { } SpriteIconMorph.prototype.init = function (aSprite, aTemplate) { - var colors, action, query, myself = this; + var colors, action, query, hover, myself = this; if (!aTemplate) { colors = [ @@ -5212,6 +5212,11 @@ SpriteIconMorph.prototype.init = function (aSprite, aTemplate) { return false; }; + hover = function () { + if (!aSprite.exemplar) {return null; } + return (localize('parent' + ':\n' + aSprite.exemplar.name)); + }; + // additional properties: this.object = aSprite || new SpriteMorph(); // mandatory, actually this.version = this.object.version; @@ -5227,7 +5232,7 @@ SpriteIconMorph.prototype.init = function (aSprite, aTemplate) { this.object.name, // label string query, // predicate/selector null, // environment - null, // hint + hover, // hint aTemplate // optional, for cached background images ); @@ -5398,6 +5403,7 @@ SpriteIconMorph.prototype.userMenu = function () { menu.addItem("duplicate", 'duplicateSprite'); menu.addItem("delete", 'removeSprite'); menu.addLine(); + menu.addItem("parent...", 'chooseExemplar'); if (this.object.anchor) { menu.addItem( localize('detach from') + ' ' + this.object.anchor.name, @@ -5432,6 +5438,10 @@ SpriteIconMorph.prototype.exportSprite = function () { this.object.exportSprite(); }; +SpriteIconMorph.prototype.chooseExemplar = function () { + this.object.chooseExemplar(); +}; + SpriteIconMorph.prototype.showSpriteOnStage = function () { this.object.showOnStage(); }; diff --git a/history.txt b/history.txt index b53e59c..e02d368 100755 --- a/history.txt +++ b/history.txt @@ -2476,3 +2476,7 @@ ______ ------ * Store: fixed #743 * GUI, html: switch from beta to release candidate + +150321 +------ +* OOP: Prototypal inheritance of sprite-local variables diff --git a/morphic.js b/morphic.js index 9616897..359e552 100644 --- a/morphic.js +++ b/morphic.js @@ -8,7 +8,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!. @@ -527,6 +527,12 @@ a duplicate of the template whose "isDraggable" flag is true and whose "isTemplate" flag is false, in other words: a non-template. + When creating a copy from a template, the copy's + + reactToTemplateCopy + + is invoked, if it is present. + Dragging is indicated by adding a drop shadow to the morph in hand. If a morph follows the hand without displaying a drop shadow it is merely being moved about without changing its parent (owner morph), @@ -1020,9 +1026,10 @@ programming hero. I have originally written morphic.js in Florian Balmer's Notepad2 - editor for Windows and later switched to Apple's Dashcode. I've also - come to depend on both Douglas Crockford's JSLint, Mozilla's Firebug - and Google's Chrome to get it right. + editor for Windows, later switched to Apple's Dashcode and later + still to Apple's Xcode. I've also come to depend on both Douglas + Crockford's JSLint, Mozilla's Firebug and Google's Chrome to get + it right. IX. contributors @@ -1041,7 +1048,7 @@ /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, FileList, getBlurredShadowSupport*/ -var morphicVersion = '2014-December-05'; +var morphicVersion = '2015-March-21'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -8060,7 +8067,7 @@ TriggerMorph.prototype.init = function ( this.environment = environment || null; this.labelString = labelString || null; this.label = null; - this.hint = hint || null; + this.hint = hint || null; // null, String, or Function this.fontSize = fontSize || MorphicPreferences.menuFontSize; this.fontStyle = fontStyle || 'sans-serif'; this.highlightColor = new Color(192, 192, 192); @@ -8209,10 +8216,11 @@ TriggerMorph.prototype.triggerDoubleClick = function () { // TriggerMorph events: TriggerMorph.prototype.mouseEnter = function () { + var contents = this.hint instanceof Function ? this.hint() : this.hint; this.image = this.highlightImage; this.changed(); - if (this.hint) { - this.bubbleHelp(this.hint); + if (contents) { + this.bubbleHelp(contents); } }; @@ -9683,6 +9691,9 @@ HandMorph.prototype.processMouseMove = function (event) { morph = this.morphToGrab.fullCopy(); morph.isTemplate = false; morph.isDraggable = true; + if (morph.reactToTemplateCopy) { + morph.reactToTemplateCopy(); + } this.grab(morph); this.grabOrigin = this.morphToGrab.situation(); } diff --git a/objects.js b/objects.js index 1fe1309..56e5806 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2015-February-28'; +modules.objects = '2015-March-21'; var SpriteMorph; var StageMorph; @@ -1103,6 +1103,13 @@ SpriteMorph.prototype.initBlocks = function () { spec: 'script variables %scriptVars' }, + // inheritance - experimental + doDeleteAttr: { + type: 'command', + category: 'variables', + spec: 'delete %var' + }, + // Lists reportNewList: { type: 'reporter', @@ -1348,11 +1355,13 @@ SpriteMorph.prototype.init = function (globals) { 'confetti': 0 }; + // sprite inheritance + this.exemplar = null; + SpriteMorph.uber.init.call(this); this.isDraggable = true; this.isDown = false; - this.heading = 90; this.changed(); this.drawNew(); @@ -1642,7 +1651,8 @@ SpriteMorph.prototype.variableBlock = function (varName) { SpriteMorph.prototype.blockTemplates = function (category) { var blocks = [], myself = this, varNames, button, - cat = category || 'motion', txt; + cat = category || 'motion', txt, + inheritedVars = this.inheritedVariableNames(); function block(selector) { if (StageMorph.prototype.hiddenPrimitives[selector]) { @@ -1657,6 +1667,9 @@ SpriteMorph.prototype.blockTemplates = function (category) { var newBlock = SpriteMorph.prototype.variableBlock(varName); newBlock.isDraggable = false; newBlock.isTemplate = true; + if (contains(inheritedVars, varName)) { + newBlock.ghost(); + } return newBlock; } @@ -1705,15 +1718,16 @@ SpriteMorph.prototype.blockTemplates = function (category) { } function addVar(pair) { + var ide; if (pair) { - if (myself.variables.silentFind(pair[0])) { + if (myself.isVariableNameInUse(pair[0])) { myself.inform('that name is already in use'); } else { + ide = myself.parentThatIsA(IDE_Morph); myself.addVariable(pair[0], pair[1]); myself.toggleVariableWatcher(pair[0], pair[1]); - myself.blocksCache[cat] = null; - myself.paletteCache[cat] = null; - myself.parentThatIsA(IDE_Morph).refreshPalette(); + ide.flushBlocksCache('variables'); // b/c of inheritance + ide.refreshPalette(); } } } @@ -2028,7 +2042,7 @@ SpriteMorph.prototype.blockTemplates = function (category) { button.showHelp = BlockMorph.prototype.showHelp; blocks.push(button); - if (this.variables.allNames().length > 0) { + if (this.deletableVariableNames().length > 0) { button = new PushButtonMorph( null, function () { @@ -2037,7 +2051,7 @@ SpriteMorph.prototype.blockTemplates = function (category) { null, myself ); - myself.variables.allNames().forEach(function (name) { + myself.deletableVariableNames().forEach(function (name) { menu.addItem(name, name); }); menu.popUpAtHand(myself.world()); @@ -2067,6 +2081,13 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push(block('doHideVar')); blocks.push(block('doDeclareVariables')); + // inheritance: + + blocks.push('-'); + blocks.push(block('doDeleteAttr')); + + /////////////////////////////// + blocks.push('='); blocks.push(block('reportNewList')); @@ -2491,7 +2512,7 @@ SpriteMorph.prototype.searchBlocks = function () { SpriteMorph.prototype.addVariable = function (name, isGlobal) { var ide = this.parentThatIsA(IDE_Morph); if (isGlobal) { - this.variables.parentFrame.addVar(name); + this.globalVariables().addVar(name); if (ide) { ide.flushBlocksCache('variables'); } @@ -2503,7 +2524,10 @@ SpriteMorph.prototype.addVariable = function (name, isGlobal) { SpriteMorph.prototype.deleteVariable = function (varName) { var ide = this.parentThatIsA(IDE_Morph); - this.deleteVariableWatcher(varName); + if (!contains(this.inheritedVariableNames(true), varName)) { + // check only shadowed variables + this.deleteVariableWatcher(varName); + } this.variables.deleteVar(varName); if (ide) { ide.flushBlocksCache('variables'); // b/c the var could be global @@ -3643,6 +3667,7 @@ SpriteMorph.prototype.reportThreadCount = function () { SpriteMorph.prototype.findVariableWatcher = function (varName) { var stage = this.parentThatIsA(StageMorph), + globals = this.globalVariables(), myself = this; if (stage === null) { return null; @@ -3652,7 +3677,7 @@ SpriteMorph.prototype.findVariableWatcher = function (varName) { function (morph) { return morph instanceof WatcherMorph && (morph.target === myself.variables - || morph.target === myself.variables.parentFrame) + || morph.target === globals) && morph.getter === varName; } ); @@ -3660,6 +3685,7 @@ SpriteMorph.prototype.findVariableWatcher = function (varName) { SpriteMorph.prototype.toggleVariableWatcher = function (varName, isGlobal) { var stage = this.parentThatIsA(StageMorph), + globals = this.globalVariables(), watcher, others; if (stage === null) { @@ -3679,12 +3705,12 @@ SpriteMorph.prototype.toggleVariableWatcher = function (varName, isGlobal) { // if no watcher exists, create a new one if (isNil(isGlobal)) { - isGlobal = contains(this.variables.parentFrame.names(), varName); + isGlobal = contains(globals.names(), varName); } watcher = new WatcherMorph( varName, this.blockColor.variables, - isGlobal ? this.variables.parentFrame : this.variables, + isGlobal ? globals : this.variables, varName ); watcher.setPosition(stage.position().add(10)); @@ -4110,6 +4136,118 @@ SpriteMorph.prototype.restoreLayers = function () { this.layers = null; }; +// SpriteMorph inheritance - general + +SpriteMorph.prototype.chooseExemplar = function () { + var stage = this.parentThatIsA(StageMorph), + myself = this, + other = stage.children.filter(function (m) { + return m instanceof SpriteMorph && + (!contains(m.allExemplars(), myself)); + }), + menu; + menu = new MenuMorph( + function (aSprite) {myself.setExemplar(aSprite); }, + localize('current parent') + + ':\n' + + (this.exemplar ? this.exemplar.name : localize('none')) + ); + other.forEach(function (eachSprite) { + menu.addItem(eachSprite.name, eachSprite); + }); + menu.addLine(); + menu.addItem(localize('none'), null); + menu.popUpAtHand(this.world()); +}; + +SpriteMorph.prototype.setExemplar = function (another) { + var ide = this.parentThatIsA(IDE_Morph); + this.exemplar = another; + if (isNil(another)) { + this.variables.parentFrame = (this.globalVariables()); + } else { + this.variables.parentFrame = (another.variables); + } + if (ide) { + ide.flushBlocksCache('variables'); + ide.refreshPalette(); + } +}; + +SpriteMorph.prototype.allExemplars = function () { + // including myself + var all = [], + current = this; + while (!isNil(current)) { + all.push(current); + current = current.exemplar; + } + return all; +}; + +SpriteMorph.prototype.specimens = function () { + // without myself + var myself = this; + return this.siblings().filter(function (m) { + return m instanceof SpriteMorph && (m.exemplar === myself); + }); +}; + +SpriteMorph.prototype.allSpecimens = function () { + // without myself + var myself = this; + return this.siblings().filter(function (m) { + return m instanceof SpriteMorph && contains(m.allExemplars(), myself); + }); +}; + +// SpriteMorph inheritance - variables + +SpriteMorph.prototype.isVariableNameInUse = function (vName) { + if (contains(this.variables.names(), vName)) {return true; } + return contains(this.globalVariables().names(), vName); +}; + +SpriteMorph.prototype.globalVariables = function () { + var current = this.variables.parentFrame; + while (current.owner) { + current = current.parentFrame; + } + return current; +}; + +SpriteMorph.prototype.shadowVar = function (name, value) { + var ide = this.parentThatIsA(IDE_Morph); + this.variables.addVar(name, value); + ide.flushBlocksCache('variables'); + ide.refreshPalette(); +}; + +SpriteMorph.prototype.inheritedVariableNames = function (shadowedOnly) { + var names = [], + own = this.variables.names(), + current = this.variables.parentFrame; + + function test(each) { + return shadowedOnly ? contains(own, each) : !contains(own, each); + } + + while (current.owner instanceof SpriteMorph) { + names.push.apply( + names, + current.names().filter(test) + ); + current = current.parentFrame; + } + return names; +}; + +SpriteMorph.prototype.deletableVariableNames = function () { + return this.variables.names().concat( + this.globalVariables().names() + ); +}; + // SpriteMorph highlighting SpriteMorph.prototype.addHighlight = function (oldHighlight) { @@ -4966,7 +5104,7 @@ StageMorph.prototype.blockTemplates = function (category) { function addVar(pair) { if (pair) { - if (myself.variables.silentFind(pair[0])) { + if (myself.isVariableNameInUse(pair[0])) { myself.inform('that name is already in use'); } else { myself.addVariable(pair[0], pair[1]); @@ -5269,6 +5407,13 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push(block('doHideVar')); blocks.push(block('doDeclareVariables')); + // inheritance: + + blocks.push('-'); + blocks.push(block('doDeleteAttr')); + + /////////////////////////////// + blocks.push('='); blocks.push(block('reportNewList')); @@ -5660,6 +5805,14 @@ StageMorph.prototype.doubleDefinitionsFor StageMorph.prototype.replaceDoubleDefinitionsFor = SpriteMorph.prototype.replaceDoubleDefinitionsFor; +// StageMorph inheritance support - variables + +StageMorph.prototype.isVariableNameInUse + = SpriteMorph.prototype.isVariableNameInUse; + +StageMorph.prototype.globalVariables + = SpriteMorph.prototype.globalVariables; + // SpriteBubbleMorph //////////////////////////////////////////////////////// /* @@ -6892,13 +7045,32 @@ WatcherMorph.prototype.setSliderMax = function (num) { // WatcherMorph updating: WatcherMorph.prototype.update = function () { - var newValue, - num; + var newValue, sprite, num; + if (this.target && this.getter) { this.updateLabel(); if (this.target instanceof VariableFrame) { newValue = this.target.vars[this.getter] ? this.target.vars[this.getter].value : undefined; + if (newValue === undefined && this.target.owner) { + sprite = this.target.owner; + if (contains(sprite.inheritedVariableNames(), this.getter)) { + newValue = this.target.getVar(this.getter); + // ghost cell color + this.cellMorph.setColor( + SpriteMorph.prototype.blockColor.variables + .lighter(35) + ); + } else { + this.destroy(); + return; + } + } else { + // un-ghost the cell color + this.cellMorph.setColor( + SpriteMorph.prototype.blockColor.variables + ); + } } else { newValue = this.target[this.getter](); } diff --git a/snap.html b/snap.html index 976bcd6..234ed1f 100755 --- a/snap.html +++ b/snap.html @@ -2,7 +2,7 @@ - Snap! Build Your Own Blocks + Snap! Build Your Own Blocks. Development (OOP) diff --git a/store.js b/store.js index d4a2b64..b2bb0a3 100644 --- a/store.js +++ b/store.js @@ -61,7 +61,7 @@ SyntaxElementMorph, Variable*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2015-March-15'; +modules.store = '2015-March-21'; // XML_Serializer /////////////////////////////////////////////////////// @@ -459,9 +459,17 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) { myself.loadValue(model); }); - // restore nesting associations + // restore inheritance and nesting associations myself.project.stage.children.forEach(function (sprite) { - var anchor; + var exemplar, anchor; + if (sprite.inheritanceInfo) { // only sprites can inherit + exemplar = myself.project.sprites[ + sprite.inheritanceInfo.exemplar + ]; + if (exemplar) { + sprite.setExemplar(exemplar); + } + } if (sprite.nestingInfo) { // only sprites may have nesting info anchor = myself.project.sprites[sprite.nestingInfo.anchor]; if (anchor) { @@ -471,6 +479,7 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) { } }); myself.project.stage.children.forEach(function (sprite) { + delete sprite.inheritanceInfo; if (sprite.nestingInfo) { // only sprites may have nesting info sprite.nestingScale = +(sprite.nestingInfo.scale || sprite.scale); delete sprite.nestingInfo; @@ -639,9 +648,17 @@ SnapSerializer.prototype.loadSprites = function (xmlString, ide) { myself.loadObject(sprite, model); }); - // restore nesting associations + // restore inheritance and nesting associations project.stage.children.forEach(function (sprite) { - var anchor; + var exemplar, anchor; + if (sprite.inheritanceInfo) { // only sprites can inherit + exemplar = project.sprites[ + sprite.inheritanceInfo.exemplar + ]; + if (exemplar) { + sprite.setExemplar(exemplar); + } + } if (sprite.nestingInfo) { // only sprites may have nesting info anchor = project.sprites[sprite.nestingInfo.anchor]; if (anchor) { @@ -651,6 +668,7 @@ SnapSerializer.prototype.loadSprites = function (xmlString, ide) { } }); project.stage.children.forEach(function (sprite) { + delete sprite.inheritanceInfo; if (sprite.nestingInfo) { // only sprites may have nesting info sprite.nestingScale = +(sprite.nestingInfo.scale || sprite.scale); delete sprite.nestingInfo; @@ -690,6 +708,7 @@ SnapSerializer.prototype.loadMediaModel = function (xmlNode) { SnapSerializer.prototype.loadObject = function (object, model) { // private var blocks = model.require('blocks'); + this.loadInheritanceInfo(object, model); this.loadNestingInfo(object, model); this.loadCostumes(object, model); this.loadSounds(object, model); @@ -699,6 +718,14 @@ SnapSerializer.prototype.loadObject = function (object, model) { this.loadScripts(object.scripts, model.require('scripts')); }; +SnapSerializer.prototype.loadInheritanceInfo = function (object, model) { + // private + var info = model.childNamed('inherit'); + if (info) { + object.inheritanceInfo = info.attributes; + } +}; + SnapSerializer.prototype.loadNestingInfo = function (object, model) { // private var info = model.childNamed('nest'); @@ -1467,6 +1494,7 @@ SpriteMorph.prototype.toXML = function (serializer) { ' draggable="@"' + '%' + ' costume="@" color="@,@,@" pen="@" ~>' + + '%' + // inheritance info '%' + // nesting info '%' + '%' + @@ -1489,6 +1517,13 @@ SpriteMorph.prototype.toXML = function (serializer) { this.color.b, this.penPoint, + // inheritance info + this.exemplar + ? '' + : '', + // nesting info this.anchor ? ' optional, if specified label will left-align hasPreview, // show press color on left edge (e.g. category) @@ -560,12 +560,13 @@ ToggleButtonMorph.prototype.init = function ( // ToggleButtonMorph events ToggleButtonMorph.prototype.mouseEnter = function () { + var contents = this.hint instanceof Function ? this.hint() : this.hint; if (!this.state) { this.image = this.highlightImage; this.changed(); } - if (this.hint) { - this.bubbleHelp(this.hint); + if (contents) { + this.bubbleHelp(contents); } }; -- cgit v1.3.1 From af9b3dec293c45ac4b109f4ef3c21ba2f5bc55c3 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Mon, 23 Mar 2015 12:44:46 +0100 Subject: OOP: Tweaks for scope conflicts when adding / removing vars --- blocks.js | 29 +++++++++++++++++++++++++++-- history.txt | 4 ++++ objects.js | 38 ++++++++++++++++++++++---------------- threads.js | 9 ++++++--- 4 files changed, 59 insertions(+), 21 deletions(-) (limited to 'objects.js') diff --git a/blocks.js b/blocks.js index 711976f..45f1049 100644 --- a/blocks.js +++ b/blocks.js @@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2015-March-21'; +modules.blocks = '2015-March-23'; var SyntaxElementMorph; @@ -1191,6 +1191,15 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { ); part.isStatic = true; break; + case '%shd': + part = new InputSlotMorph( + null, + false, + 'shadowedVariablesMenu', + true + ); + part.isStatic = true; + break; case '%lst': part = new InputSlotMorph( null, @@ -1889,7 +1898,8 @@ SyntaxElementMorph.prototype.endLayout = function () { %att - chameleon colored rectangular drop-down for attributes %fun - chameleon colored rectangular drop-down for math functions %typ - chameleon colored rectangular drop-down for data types - %var - chameleon colored rectangular drop-down for variable names + %var - chameleon colored rectangular drop-down for variable names + %shd - Chameleon colored rectuangular drop-down for shadowed var names %lst - chameleon colored rectangular drop-down for list names %b - chameleon colored hexagonal slot (for predicates) %l - list icon @@ -6902,6 +6912,21 @@ InputSlotMorph.prototype.getVarNamesDict = function () { return {}; }; +InputSlotMorph.prototype.shadowedVariablesMenu = function () { + var block = this.parentThatIsA(BlockMorph), + rcvr, + dict = {}; + + if (!block) {return dict; } + rcvr = block.receiver(); + if (rcvr) { + rcvr.inheritedVariableNames(true).forEach(function (name) { + dict[name] = name; + }); + } + return dict; +}; + InputSlotMorph.prototype.setChoices = function (dict, readonly) { // externally specify choices and read-only status, // used for custom blocks diff --git a/history.txt b/history.txt index e02d368..fc54386 100755 --- a/history.txt +++ b/history.txt @@ -2480,3 +2480,7 @@ ______ 150321 ------ * OOP: Prototypal inheritance of sprite-local variables + +150321 +------ +* OOP: Objects, Blocks, Threads - tweaks diff --git a/objects.js b/objects.js index 56e5806..2ea8427 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2015-March-21'; +modules.objects = '2015-March-23'; var SpriteMorph; var StageMorph; @@ -1107,7 +1107,7 @@ SpriteMorph.prototype.initBlocks = function () { doDeleteAttr: { type: 'command', category: 'variables', - spec: 'delete %var' + spec: 'delete %shd' }, // Lists @@ -1720,12 +1720,14 @@ SpriteMorph.prototype.blockTemplates = function (category) { function addVar(pair) { var ide; if (pair) { - if (myself.isVariableNameInUse(pair[0])) { + if (myself.isVariableNameInUse(pair[0], pair[1])) { myself.inform('that name is already in use'); } else { ide = myself.parentThatIsA(IDE_Morph); myself.addVariable(pair[0], pair[1]); - myself.toggleVariableWatcher(pair[0], pair[1]); + if (!myself.showingVariableWatcher(pair[0])) { + myself.toggleVariableWatcher(pair[0], pair[1]); + } ide.flushBlocksCache('variables'); // b/c of inheritance ide.refreshPalette(); } @@ -4203,7 +4205,10 @@ SpriteMorph.prototype.allSpecimens = function () { // SpriteMorph inheritance - variables -SpriteMorph.prototype.isVariableNameInUse = function (vName) { +SpriteMorph.prototype.isVariableNameInUse = function (vName, isGlobal) { + if (isGlobal) { + return contains(this.variables.allNames(), vName); + } if (contains(this.variables.names(), vName)) {return true; } return contains(this.globalVariables().names(), vName); }; @@ -4243,8 +4248,14 @@ SpriteMorph.prototype.inheritedVariableNames = function (shadowedOnly) { }; SpriteMorph.prototype.deletableVariableNames = function () { - return this.variables.names().concat( - this.globalVariables().names() + var locals = this.variables.names(), + inherited = this.inheritedVariableNames(); + return locals.concat( + this.globalVariables().names().filter( + function (each) { + return !contains(locals, each) && !contains(inherited, each); + } + ) ); }; @@ -5406,16 +5417,7 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push(block('doShowVar')); blocks.push(block('doHideVar')); blocks.push(block('doDeclareVariables')); - - // inheritance: - - blocks.push('-'); - blocks.push(block('doDeleteAttr')); - - /////////////////////////////// - blocks.push('='); - blocks.push(block('reportNewList')); blocks.push('-'); blocks.push(block('reportCONS')); @@ -5813,6 +5815,10 @@ StageMorph.prototype.isVariableNameInUse StageMorph.prototype.globalVariables = SpriteMorph.prototype.globalVariables; +StageMorph.prototype.inheritedVariableNames = function () { + return []; +}; + // SpriteBubbleMorph //////////////////////////////////////////////////////// /* diff --git a/threads.js b/threads.js index d3dcfc9..82f7ab0 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2015-March-21'; +modules.threads = '2015-March-23'; var ThreadManager; var Process; @@ -1299,14 +1299,17 @@ Process.prototype.doRemoveTemporaries = function () { Process.prototype.doDeleteAttr = function (attrName) { // currently only variables are deletable - var name = attrName; + var name = attrName, + rcvr = this.blockReceiver(); if (name instanceof Context) { if (name.expression.selector === 'reportGetVar') { name = name.expression.blockSpec; } } - this.blockReceiver().deleteVariable(name); + if (contains(rcvr.inheritedVariableNames(true), name)) { + rcvr.deleteVariable(name); + } }; // Process lists primitives -- cgit v1.3.1 From 93864cd4739963a462d5ea62f226531e2ecf27e1 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Mon, 23 Mar 2015 13:40:54 +0100 Subject: OOP: Fix variable watcher slider functionality --- objects.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'objects.js') diff --git a/objects.js b/objects.js index 2ea8427..4ade0fa 100644 --- a/objects.js +++ b/objects.js @@ -7161,7 +7161,11 @@ WatcherMorph.prototype.fixLayout = function () { this.sliderMorph.button.pressColor.b += 100; this.sliderMorph.setHeight(fontSize); this.sliderMorph.action = function (num) { - myself.target.vars[myself.getter].value = Math.round(num); + myself.target.setVar( + myself.getter, + Math.round(num), + myself.target.owner + ); }; this.add(this.sliderMorph); } -- cgit v1.3.1 From 457224dd620eea4f20f24ebc62391363333cd00f Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Tue, 24 Mar 2015 17:16:00 +0100 Subject: tweak inherited variable watcher slider deserialization --- history.txt | 6 +++++- morphic.js | 14 +++++++------- objects.js | 24 +++++++++++++----------- store.js | 6 +++--- 4 files changed, 28 insertions(+), 22 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index fc54386..fda02a3 100755 --- a/history.txt +++ b/history.txt @@ -2481,6 +2481,10 @@ ______ ------ * OOP: Prototypal inheritance of sprite-local variables -150321 +150323 ------ * OOP: Objects, Blocks, Threads - tweaks + +150323 +------ +* OOP: Morphic, Objects, Store - tweak inherited variable watcher slider deserialization diff --git a/morphic.js b/morphic.js index 359e552..c725209 100644 --- a/morphic.js +++ b/morphic.js @@ -1048,7 +1048,7 @@ /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, FileList, getBlurredShadowSupport*/ -var morphicVersion = '2015-March-21'; +var morphicVersion = '2015-March-24'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -5933,7 +5933,7 @@ SliderMorph.prototype.userSetStart = function (num) { this.start = Math.max(num, this.stop); }; -SliderMorph.prototype.setStart = function (num) { +SliderMorph.prototype.setStart = function (num, noUpdate) { // for context menu demo purposes var newStart; if (typeof num === 'number') { @@ -5951,12 +5951,12 @@ SliderMorph.prototype.setStart = function (num) { } } this.value = Math.max(this.value, this.start); - this.updateTarget(); + if (!noUpdate) {this.updateTarget(); } this.drawNew(); this.changed(); }; -SliderMorph.prototype.setStop = function (num) { +SliderMorph.prototype.setStop = function (num, noUpdate) { // for context menu demo purposes var newStop; if (typeof num === 'number') { @@ -5968,12 +5968,12 @@ SliderMorph.prototype.setStop = function (num) { } } this.value = Math.min(this.value, this.stop); - this.updateTarget(); + if (!noUpdate) {this.updateTarget(); } this.drawNew(); this.changed(); }; -SliderMorph.prototype.setSize = function (num) { +SliderMorph.prototype.setSize = function (num, noUpdate) { // for context menu demo purposes var newSize; if (typeof num === 'number') { @@ -5991,7 +5991,7 @@ SliderMorph.prototype.setSize = function (num) { } } this.value = Math.min(this.value, this.stop - this.size); - this.updateTarget(); + if (!noUpdate) {this.updateTarget(); } this.drawNew(); this.changed(); }; diff --git a/objects.js b/objects.js index 4ade0fa..66726a1 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2015-March-23'; +modules.objects = '2015-March-24'; var SpriteMorph; var StageMorph; @@ -4224,8 +4224,10 @@ SpriteMorph.prototype.globalVariables = function () { SpriteMorph.prototype.shadowVar = function (name, value) { var ide = this.parentThatIsA(IDE_Morph); this.variables.addVar(name, value); - ide.flushBlocksCache('variables'); - ide.refreshPalette(); + if (ide) { + ide.flushBlocksCache('variables'); + ide.refreshPalette(); + } }; SpriteMorph.prototype.inheritedVariableNames = function (shadowedOnly) { @@ -7032,19 +7034,19 @@ WatcherMorph.prototype.isGlobal = function (selector) { // WatcherMorph slider accessing: -WatcherMorph.prototype.setSliderMin = function (num) { +WatcherMorph.prototype.setSliderMin = function (num, noUpdate) { if (this.target instanceof VariableFrame) { - this.sliderMorph.setSize(1); - this.sliderMorph.setStart(num); - this.sliderMorph.setSize(this.sliderMorph.rangeSize() / 5); + this.sliderMorph.setSize(1, noUpdate); + this.sliderMorph.setStart(num, noUpdate); + this.sliderMorph.setSize(this.sliderMorph.rangeSize() / 5, noUpdate); } }; -WatcherMorph.prototype.setSliderMax = function (num) { +WatcherMorph.prototype.setSliderMax = function (num, noUpdate) { if (this.target instanceof VariableFrame) { - this.sliderMorph.setSize(1); - this.sliderMorph.setStop(num); - this.sliderMorph.setSize(this.sliderMorph.rangeSize() / 5); + this.sliderMorph.setSize(1, noUpdate); + this.sliderMorph.setStop(num, noUpdate); + this.sliderMorph.setSize(this.sliderMorph.rangeSize() / 5, noUpdate); } }; diff --git a/store.js b/store.js index b2bb0a3..138dc24 100644 --- a/store.js +++ b/store.js @@ -61,7 +61,7 @@ SyntaxElementMorph, Variable*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2015-March-21'; +modules.store = '2015-March-24'; // XML_Serializer /////////////////////////////////////////////////////// @@ -540,8 +540,8 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) { } watcher.setStyle(model.attributes.style || 'normal'); if (watcher.style === 'slider') { - watcher.setSliderMin(model.attributes.min || '1'); - watcher.setSliderMax(model.attributes.max || '100'); + watcher.setSliderMin(model.attributes.min || '1', true); + watcher.setSliderMax(model.attributes.max || '100', true); } watcher.setPosition( project.stage.topLeft().add(new Point( -- cgit v1.3.1 From 834b3918adc35792eae7d6cf59a17f48f0d88cb9 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Wed, 15 Apr 2015 17:30:43 +0200 Subject: fixed #770 --- history.txt | 1 + objects.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index 9cdc5c9..0efef9b 100755 --- a/history.txt +++ b/history.txt @@ -2484,3 +2484,4 @@ ______ 150415 ------ * Threads: flush Stage>>keysPressed when prompting the user +* Objects: fixed #770 diff --git a/objects.js b/objects.js index 1fe1309..db5ab88 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2015-February-28'; +modules.objects = '2015-April-15'; var SpriteMorph; var StageMorph; @@ -3081,7 +3081,7 @@ SpriteMorph.prototype.setEffect = function (effect, value) { if (eff === 'ghost') { this.alpha = 1 - Math.min(Math.max(+value || 0, 0), 100) / 100; } else { - this.graphicsValues[eff] = value; + this.graphicsValues[eff] = +value; } this.drawNew(); this.changed(); @@ -3096,7 +3096,7 @@ SpriteMorph.prototype.changeEffect = function (effect, value) { if (eff === 'ghost') { this.setEffect(effect, this.getGhostEffect() + (+value || 0)); } else { - this.setEffect(effect, this.graphicsValues[eff] + value); + this.setEffect(effect, +this.graphicsValues[eff] + (+value)); } }; -- cgit v1.3.1 From 4f39a406da6dbbea1ae6a34cfcbc1026ef6ad6aa Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Wed, 15 Apr 2015 17:32:08 +0200 Subject: fixed #770 --- history.txt | 2 +- objects.js | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index ef96624..b3b4da3 100755 --- a/history.txt +++ b/history.txt @@ -2497,4 +2497,4 @@ ______ 150415 ------ * Threads: flush Stage>>keysPressed when prompting the user - +* Objects: fixed #770 diff --git a/objects.js b/objects.js index 66726a1..173be51 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2015-March-24'; +modules.objects = '2015-April-15'; var SpriteMorph; var StageMorph; @@ -2369,6 +2369,29 @@ SpriteMorph.prototype.freshPalette = function (category) { } }); + // inherited custom blocks: (under construction...) + + // y += unit * 1.6; + if (this.exemplar) { + this.exemplar.customBlocks.forEach(function (definition) { + var block; + if (definition.category === category || + (category === 'variables' + && contains( + ['lists', 'other'], + definition.category + ))) { + block = definition.templateInstance(); + y += unit * 0.3; + block.setPosition(new Point(x, y)); + palette.addContents(block); + block.ghost(); + x = 0; + y += block.height(); + } + }); + } + //layout palette.scrollX(palette.padding); @@ -3107,7 +3130,7 @@ SpriteMorph.prototype.setEffect = function (effect, value) { if (eff === 'ghost') { this.alpha = 1 - Math.min(Math.max(+value || 0, 0), 100) / 100; } else { - this.graphicsValues[eff] = value; + this.graphicsValues[eff] = +value; } this.drawNew(); this.changed(); @@ -3122,7 +3145,7 @@ SpriteMorph.prototype.changeEffect = function (effect, value) { if (eff === 'ghost') { this.setEffect(effect, this.getGhostEffect() + (+value || 0)); } else { - this.setEffect(effect, this.graphicsValues[eff] + value); + this.setEffect(effect, +this.graphicsValues[eff] + (+value)); } }; -- cgit v1.3.1 From 9e4b73eae9adcbad1cef270411b56d0676cf0006 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 17 Apr 2015 15:27:29 +0200 Subject: OOP: Prototypal inheritance of sprite-local custom blocks (palette only) --- history.txt | 4 ++++ objects.js | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index b3b4da3..938213e 100755 --- a/history.txt +++ b/history.txt @@ -2498,3 +2498,7 @@ ______ ------ * Threads: flush Stage>>keysPressed when prompting the user * Objects: fixed #770 + +150415 +------ +* OOP: Objects, Prototypal inheritance of sprite-local custom blocks (palette only) diff --git a/objects.js b/objects.js index 173be51..52292ca 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2015-April-15'; +modules.objects = '2015-April-17'; var SpriteMorph; var StageMorph; @@ -2373,7 +2373,7 @@ SpriteMorph.prototype.freshPalette = function (category) { // y += unit * 1.6; if (this.exemplar) { - this.exemplar.customBlocks.forEach(function (definition) { + this.inheritedBlocks(true).forEach(function (definition) { var block; if (definition.category === category || (category === 'variables' @@ -4284,6 +4284,48 @@ SpriteMorph.prototype.deletableVariableNames = function () { ); }; +// SpriteMorph inheritance - custom blocks + +SpriteMorph.prototype.ownBlocks = function () { + var dict = {}; + this.customBlocks.forEach(function (def) { + dict[def.blockSpec()] = def; + }); + return dict; +}; + +SpriteMorph.prototype.allBlocks = function (valuesOnly) { + var dict = {}; + this.allExemplars().reverse().forEach(function (sprite) { + sprite.customBlocks.forEach(function (def) { + dict[def.blockSpec()] = def; + }); + }); + if (valuesOnly) { + return Object.keys(dict).map(function (key) {return dict[key]; }); + } + return dict; +}; + +SpriteMorph.prototype.inheritedBlocks = function (valuesOnly) { + var dict = {}, + own = Object.keys(this.ownBlocks()), + others = this.allExemplars().reverse(); + others.pop(); + others.forEach(function (sprite) { + sprite.customBlocks.forEach(function (def) { + var spec = def.blockSpec(); + if (!contains(own, spec)) { + dict[spec] = def; + } + }); + }); + if (valuesOnly) { + return Object.keys(dict).map(function (key) {return dict[key]; }); + } + return dict; +}; + // SpriteMorph highlighting SpriteMorph.prototype.addHighlight = function (oldHighlight) { -- cgit v1.3.1 From 6b19caf75d5ea26c1eef93edbe21d7c45bd97742 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Mon, 18 May 2015 12:23:57 +0200 Subject: Fix encoding for exported sprites (esp. comments) --- gui.js | 6 ++++-- history.txt | 6 ++++++ objects.js | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'objects.js') diff --git a/gui.js b/gui.js index e8394aa..026a12c 100644 --- a/gui.js +++ b/gui.js @@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2015-May-01'; +modules.gui = '2015-May-18'; // Declarations @@ -2964,7 +2964,9 @@ IDE_Morph.prototype.exportGlobalBlocks = function () { }; IDE_Morph.prototype.exportSprite = function (sprite) { - var str = this.serializer.serialize(sprite.allParts()); + var str = encodeURIComponent( + this.serializer.serialize(sprite.allParts()) + ); window.open('data:text/xml, Date: Wed, 17 Jun 2015 20:08:59 -0400 Subject: Remove clone function (unused) --- morphic.js | 10 ---------- objects.js | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) (limited to 'objects.js') diff --git a/morphic.js b/morphic.js index 6ce8559..e23812a 100644 --- a/morphic.js +++ b/morphic.js @@ -1242,16 +1242,6 @@ function getDocumentPositionOf(aDOMelement) { return pos; } -function clone(target) { - // answer a new instance of target's type - if (typeof target === 'object') { - var Clone = function () {nop(); }; - Clone.prototype = target; - return new Clone(); - } - return target; -} - function copy(target) { // answer a shallow copy of target var value, c, property; diff --git a/objects.js b/objects.js index 462aed2..8d11ff6 100644 --- a/objects.js +++ b/objects.js @@ -105,7 +105,7 @@ InspectorMorph, ListMorph, Math, MenuItemMorph, MenuMorph, Morph, MorphicPreferences, MouseSensorMorph, Node, Object, PenMorph, Point, Rectangle, ScrollFrameMorph, ShadowMorph, SliderButtonMorph, SliderMorph, String, StringFieldMorph, StringMorph, TextMorph, -TriggerMorph, WorldMorph, clone, contains, copy, degrees, detect, +TriggerMorph, WorldMorph, contains, copy, degrees, detect, document, getDocumentPositionOf, isNaN, isObject, isString, newCanvas, nop, parseFloat, radians, standardSettings, touchScreenSettings, useBlurredShadows, version, window, modules, IDE_Morph, VariableDialogMorph, -- cgit v1.3.1 From 6a82960cf77f9eac16c9a1ce13f360d80469799d Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 20:46:54 -0400 Subject: Optimize moveBy and friends This results in realtime speed for dragging where I used to get 10-15 fps before this change. --- morphic.js | 43 +++++++++---------------------------------- objects.js | 2 +- 2 files changed, 10 insertions(+), 35 deletions(-) (limited to 'objects.js') diff --git a/morphic.js b/morphic.js index e23812a..5cc4062 100644 --- a/morphic.js +++ b/morphic.js @@ -2398,19 +2398,16 @@ Morph.prototype.visibleBounds = function () { // Morph accessing - simple changes: Morph.prototype.moveBy = function (delta) { - this.changed(); - this.bounds = this.bounds.translateBy(delta); - this.children.forEach(function (child) { - child.moveBy(delta); - }); - this.changed(); + this.fullChanged(); + this.silentMoveBy(delta); + this.fullChanged(); }; Morph.prototype.silentMoveBy = function (delta) { this.bounds = this.bounds.translateBy(delta); - this.children.forEach(function (child) { - child.silentMoveBy(delta); - }); + for (var children = this.children, i = children.length; i--;) { + children[i].silentMoveBy(delta); + } }; Morph.prototype.setPosition = function (aPoint) { @@ -3146,9 +3143,7 @@ Morph.prototype.slideBackTo = function (situation, inSteps) { this.fps = 0; this.step = function () { - myself.fullChanged(); - myself.silentMoveBy(new Point(xStep, yStep)); - myself.fullChanged(); + myself.moveBy(new Point(xStep, yStep)); stepCount += 1; if (stepCount === steps) { situation.origin.add(myself); @@ -8433,17 +8428,6 @@ FrameMorph.prototype.fullDrawOn = function (aCanvas, aRect) { }); }; -// FrameMorph scrolling optimization: - -FrameMorph.prototype.moveBy = function (delta) { - this.changed(); - this.bounds = this.bounds.translateBy(delta); - this.children.forEach(function (child) { - child.silentMoveBy(delta); - }); - this.changed(); -}; - // FrameMorph scrolling support: FrameMorph.prototype.submorphBounds = function () { @@ -9274,7 +9258,8 @@ HandMorph.prototype.init = function (aWorld) { this.contextMenuEnabled = false; }; -HandMorph.prototype.changed = function () { +HandMorph.prototype.changed = +HandMorph.prototype.fullChanged = function () { var b; if (this.world !== null) { b = this.fullBounds(); @@ -9282,7 +9267,6 @@ HandMorph.prototype.changed = function () { this.world.broken.push(this.fullBounds().spread()); } } - }; // HandMorph navigation: @@ -9865,15 +9849,6 @@ HandMorph.prototype.destroyTemporaries = function () { }); }; -// HandMorph dragging optimization - -HandMorph.prototype.moveBy = function (delta) { - Morph.prototype.trackChanges = false; - HandMorph.uber.moveBy.call(this, delta); - Morph.prototype.trackChanges = true; - this.fullChanged(); -}; - // WorldMorph ////////////////////////////////////////////////////////// diff --git a/objects.js b/objects.js index 8d11ff6..1e8060e 100644 --- a/objects.js +++ b/objects.js @@ -3290,7 +3290,7 @@ SpriteMorph.prototype.nestingBounds = function () { // SpriteMorph motion primitives -Morph.prototype.setPosition = function (aPoint, justMe) { +SpriteMorph.prototype.setPosition = function (aPoint, justMe) { // override the inherited default to make sure my parts follow // unless it's justMe var delta = aPoint.subtract(this.topLeft()); -- cgit v1.3.1 From 4c21c9f187033172fa58a1bd3100d7c494617f10 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 15:11:51 +0200 Subject: Revert to "new" for object creation and prepare for new release --- blocks.js | 68 ++++++++++++++++++++++++++++++------------------------------- byob.js | 28 ++++++++++++------------- gui.js | 22 ++++++++++---------- history.txt | 7 +++++++ lists.js | 22 ++++++++++---------- objects.js | 24 +++++++++++----------- paint.js | 14 +++++-------- store.js | 5 ++--- widgets.js | 20 +++++++++--------- xml.js | 8 +++++--- 10 files changed, 111 insertions(+), 107 deletions(-) mode change 100644 => 100755 xml.js (limited to 'objects.js') diff --git a/blocks.js b/blocks.js index d023db8..ec01f96 100644 --- a/blocks.js +++ b/blocks.js @@ -155,8 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2015-June-08'; - +modules.blocks = '2015-June-25'; var SyntaxElementMorph; var BlockMorph; @@ -240,7 +239,7 @@ WorldMorph.prototype.customMorphs = function () { // SyntaxElementMorph inherits from Morph: -SyntaxElementMorph.prototype = Object.create(Morph.prototype); +SyntaxElementMorph.prototype = new Morph(); SyntaxElementMorph.prototype.constructor = SyntaxElementMorph; SyntaxElementMorph.uber = Morph.prototype; @@ -360,6 +359,10 @@ SyntaxElementMorph.prototype.init = function () { this.cachedInputs = null; }; +// SyntaxElementMorph stepping: + +SyntaxElementMorph.prototype.step = null; + // SyntaxElementMorph accessing: SyntaxElementMorph.prototype.parts = function () { @@ -621,10 +624,6 @@ SyntaxElementMorph.prototype.topBlock = function () { return this; }; -// SyntaxElementMorph stepping: - -SyntaxElementMorph.prototype.step = null; - // SyntaxElementMorph drag & drop: SyntaxElementMorph.prototype.reactToGrabOf = function (grabbedMorph) { @@ -1429,11 +1428,11 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { false, // italic false, // isNumeric MorphicPreferences.isFlat ? - new Point() : this.embossing, // shadowOffset + new Point() : this.embossing, // shadowOffset this.color.darker(this.labelContrast), // shadowColor new Color(255, 255, 255), // color this.labelFontName // fontName - ); + ); } return part; }; @@ -1944,7 +1943,7 @@ SyntaxElementMorph.prototype.endLayout = function () { // BlockMorph inherits from SyntaxElementMorph: -BlockMorph.prototype = Object.create(SyntaxElementMorph.prototype); +BlockMorph.prototype = new SyntaxElementMorph(); BlockMorph.prototype.constructor = BlockMorph; BlockMorph.uber = SyntaxElementMorph.prototype; @@ -2065,7 +2064,8 @@ BlockMorph.prototype.setSpec = function (spec) { } part = myself.labelPart(word); myself.add(part); - if (!(part instanceof CommandSlotMorph || part instanceof StringMorph)) { + if (!(part instanceof CommandSlotMorph || + part instanceof StringMorph)) { part.drawNew(); } if (part instanceof RingMorph) { @@ -3266,7 +3266,7 @@ BlockMorph.prototype.snap = function () { // CommandBlockMorph inherits from BlockMorph: -CommandBlockMorph.prototype = Object.create(BlockMorph.prototype); +CommandBlockMorph.prototype = new BlockMorph(); CommandBlockMorph.prototype.constructor = CommandBlockMorph; CommandBlockMorph.uber = BlockMorph.prototype; @@ -3946,7 +3946,7 @@ CommandBlockMorph.prototype.drawBottomRightEdge = function (context) { // HatBlockMorph inherits from CommandBlockMorph: -HatBlockMorph.prototype = Object.create(CommandBlockMorph.prototype); +HatBlockMorph.prototype = new CommandBlockMorph(); HatBlockMorph.prototype.constructor = HatBlockMorph; HatBlockMorph.uber = CommandBlockMorph.prototype; @@ -4124,7 +4124,7 @@ HatBlockMorph.prototype.drawTopLeftEdge = function (context) { // ReporterBlockMorph inherits from BlockMorph: -ReporterBlockMorph.prototype = Object.create(BlockMorph.prototype); +ReporterBlockMorph.prototype = new BlockMorph(); ReporterBlockMorph.prototype.constructor = ReporterBlockMorph; ReporterBlockMorph.uber = BlockMorph.prototype; @@ -4648,7 +4648,7 @@ ReporterBlockMorph.prototype.drawDiamond = function (context) { // RingMorph inherits from ReporterBlockMorph: -RingMorph.prototype = Object.create(ReporterBlockMorph.prototype); +RingMorph.prototype = new ReporterBlockMorph(); RingMorph.prototype.constructor = RingMorph; RingMorph.uber = ReporterBlockMorph.prototype; @@ -4785,7 +4785,7 @@ RingMorph.prototype.fixBlockColor = function (nearest, isForced) { // ScriptsMorph inherits from FrameMorph: -ScriptsMorph.prototype = Object.create(FrameMorph.prototype); +ScriptsMorph.prototype = new FrameMorph(); ScriptsMorph.prototype.constructor = ScriptsMorph; ScriptsMorph.uber = FrameMorph.prototype; @@ -5325,7 +5325,7 @@ ScriptsMorph.prototype.reactToDropOf = function (droppedMorph, hand) { // ArgMorph inherits from SyntaxElementMorph: -ArgMorph.prototype = Object.create(SyntaxElementMorph.prototype); +ArgMorph.prototype = new SyntaxElementMorph(); ArgMorph.prototype.constructor = ArgMorph; ArgMorph.uber = SyntaxElementMorph.prototype; @@ -5438,7 +5438,7 @@ ArgMorph.prototype.isEmptySlot = function () { // CommandSlotMorph inherits from ArgMorph: -CommandSlotMorph.prototype = Object.create(ArgMorph.prototype); +CommandSlotMorph.prototype = new ArgMorph(); CommandSlotMorph.prototype.constructor = CommandSlotMorph; CommandSlotMorph.uber = ArgMorph.prototype; @@ -5888,7 +5888,7 @@ CommandSlotMorph.prototype.drawEdges = function (context) { // RingCommandSlotMorph inherits from CommandSlotMorph: -RingCommandSlotMorph.prototype = Object.create(CommandSlotMorph.prototype); +RingCommandSlotMorph.prototype = new CommandSlotMorph(); RingCommandSlotMorph.prototype.constructor = RingCommandSlotMorph; RingCommandSlotMorph.uber = CommandSlotMorph.prototype; @@ -6044,7 +6044,7 @@ RingCommandSlotMorph.prototype.drawFlat = function (context) { // CSlotMorph inherits from CommandSlotMorph: -CSlotMorph.prototype = Object.create(CommandSlotMorph.prototype); +CSlotMorph.prototype = new CommandSlotMorph(); CSlotMorph.prototype.constructor = CSlotMorph; CSlotMorph.uber = CommandSlotMorph.prototype; @@ -6467,7 +6467,7 @@ CSlotMorph.prototype.drawBottomEdge = function (context) { // InputSlotMorph inherits from ArgMorph: -InputSlotMorph.prototype = Object.create(ArgMorph.prototype); +InputSlotMorph.prototype = new ArgMorph(); InputSlotMorph.prototype.constructor = InputSlotMorph; InputSlotMorph.uber = ArgMorph.prototype; @@ -7403,7 +7403,7 @@ InputSlotMorph.prototype.drawRoundBorder = function (context) { // TemplateSlotMorph inherits from ArgMorph: -TemplateSlotMorph.prototype = Object.create(ArgMorph.prototype); +TemplateSlotMorph.prototype = new ArgMorph(); TemplateSlotMorph.prototype.constructor = TemplateSlotMorph; TemplateSlotMorph.uber = ArgMorph.prototype; @@ -7507,7 +7507,7 @@ TemplateSlotMorph.prototype.drawRounded = ReporterBlockMorph // BooleanSlotMorph inherits from ArgMorph: -BooleanSlotMorph.prototype = Object.create(ArgMorph.prototype); +BooleanSlotMorph.prototype = new ArgMorph(); BooleanSlotMorph.prototype.constructor = BooleanSlotMorph; BooleanSlotMorph.uber = ArgMorph.prototype; @@ -7664,7 +7664,7 @@ BooleanSlotMorph.prototype.isEmptySlot = function () { // ArrowMorph inherits from Morph: -ArrowMorph.prototype = Object.create(Morph.prototype); +ArrowMorph.prototype = new Morph(); ArrowMorph.prototype.constructor = ArrowMorph; ArrowMorph.uber = Morph.prototype; @@ -7734,7 +7734,7 @@ ArrowMorph.prototype.drawNew = function () { // TextSlotMorph inherits from InputSlotMorph: -TextSlotMorph.prototype = Object.create(InputSlotMorph.prototype); +TextSlotMorph.prototype = new InputSlotMorph(); TextSlotMorph.prototype.constructor = TextSlotMorph; TextSlotMorph.uber = InputSlotMorph.prototype; @@ -7817,7 +7817,7 @@ TextSlotMorph.prototype.layoutChanged = function () { // SymbolMorph inherits from Morph: -SymbolMorph.prototype = Object.create(Morph.prototype); +SymbolMorph.prototype = new Morph(); SymbolMorph.prototype.constructor = SymbolMorph; SymbolMorph.uber = Morph.prototype; @@ -9110,7 +9110,7 @@ SymbolMorph.prototype.drawSymbolRobot = function (canvas, color) { // ColorSlotMorph inherits from ArgMorph: -ColorSlotMorph.prototype = Object.create(ArgMorph.prototype); +ColorSlotMorph.prototype = new ArgMorph(); ColorSlotMorph.prototype.constructor = ColorSlotMorph; ColorSlotMorph.uber = ArgMorph.prototype; @@ -9218,7 +9218,7 @@ ColorSlotMorph.prototype.drawRectBorder = // BlockHighlightMorph inherits from Morph: -BlockHighlightMorph.prototype = Object.create(Morph.prototype); +BlockHighlightMorph.prototype = new Morph(); BlockHighlightMorph.prototype.constructor = BlockHighlightMorph; BlockHighlightMorph.uber = Morph.prototype; @@ -9243,7 +9243,7 @@ function BlockHighlightMorph() { // MultiArgMorph inherits from ArgMorph: -MultiArgMorph.prototype = Object.create(ArgMorph.prototype); +MultiArgMorph.prototype = new ArgMorph(); MultiArgMorph.prototype.constructor = MultiArgMorph; MultiArgMorph.uber = ArgMorph.prototype; @@ -9673,7 +9673,7 @@ MultiArgMorph.prototype.isEmptySlot = function () { // ArgLabelMorph inherits from ArgMorph: -ArgLabelMorph.prototype = Object.create(ArgMorph.prototype); +ArgLabelMorph.prototype = new ArgMorph(); ArgLabelMorph.prototype.constructor = ArgLabelMorph; ArgLabelMorph.uber = ArgMorph.prototype; @@ -9803,7 +9803,7 @@ ArgLabelMorph.prototype.isEmptySlot = function () { // FunctionSlotMorph inherits from ArgMorph: -FunctionSlotMorph.prototype = Object.create(ArgMorph.prototype); +FunctionSlotMorph.prototype = new ArgMorph(); FunctionSlotMorph.prototype.constructor = FunctionSlotMorph; FunctionSlotMorph.uber = ArgMorph.prototype; @@ -10184,7 +10184,7 @@ FunctionSlotMorph.prototype.drawDiamond = function (context) { // ReporterSlotMorph inherits from FunctionSlotMorph: -ReporterSlotMorph.prototype = Object.create(FunctionSlotMorph.prototype); +ReporterSlotMorph.prototype = new FunctionSlotMorph(); ReporterSlotMorph.prototype.constructor = ReporterSlotMorph; ReporterSlotMorph.uber = FunctionSlotMorph.prototype; @@ -10267,7 +10267,7 @@ ReporterSlotMorph.prototype.fixLayout = function () { // ReporterSlotMorph inherits from FunctionSlotMorph: -RingReporterSlotMorph.prototype = Object.create(ReporterSlotMorph.prototype); +RingReporterSlotMorph.prototype = new ReporterSlotMorph(); RingReporterSlotMorph.prototype.constructor = RingReporterSlotMorph; RingReporterSlotMorph.uber = ReporterSlotMorph.prototype; @@ -10655,7 +10655,7 @@ RingReporterSlotMorph.prototype.drawDiamond = function (context) { // CommentMorph inherits from BoxMorph: -CommentMorph.prototype = Object.create(BoxMorph.prototype); +CommentMorph.prototype = new BoxMorph(); CommentMorph.prototype.constructor = CommentMorph; CommentMorph.uber = BoxMorph.prototype; diff --git a/byob.js b/byob.js index 32d8969..4c39872 100644 --- a/byob.js +++ b/byob.js @@ -106,7 +106,7 @@ SymbolMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2015-May-23'; +modules.byob = '2015-June-25'; // Declarations @@ -379,7 +379,7 @@ CustomBlockDefinition.prototype.scriptsPicture = function () { // CustomCommandBlockMorph inherits from CommandBlockMorph: -CustomCommandBlockMorph.prototype = Object.create(CommandBlockMorph.prototype); +CustomCommandBlockMorph.prototype = new CommandBlockMorph(); CustomCommandBlockMorph.prototype.constructor = CustomCommandBlockMorph; CustomCommandBlockMorph.uber = CommandBlockMorph.prototype; @@ -896,7 +896,7 @@ CustomCommandBlockMorph.prototype.alternatives = function () { // CustomReporterBlockMorph inherits from ReporterBlockMorph: -CustomReporterBlockMorph.prototype = Object.create(ReporterBlockMorph.prototype); +CustomReporterBlockMorph.prototype = new ReporterBlockMorph(); CustomReporterBlockMorph.prototype.constructor = CustomReporterBlockMorph; CustomReporterBlockMorph.uber = ReporterBlockMorph.prototype; @@ -1028,7 +1028,7 @@ CustomReporterBlockMorph.prototype.alternatives // JaggedBlockMorph inherits from ReporterBlockMorph: -JaggedBlockMorph.prototype = Object.create(ReporterBlockMorph.prototype); +JaggedBlockMorph.prototype = new ReporterBlockMorph(); JaggedBlockMorph.prototype.constructor = JaggedBlockMorph; JaggedBlockMorph.uber = ReporterBlockMorph.prototype; @@ -1177,7 +1177,7 @@ JaggedBlockMorph.prototype.drawEdges = function (context) { // BlockDialogMorph inherits from DialogBoxMorph: -BlockDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); +BlockDialogMorph.prototype = new DialogBoxMorph(); BlockDialogMorph.prototype.constructor = BlockDialogMorph; BlockDialogMorph.uber = DialogBoxMorph.prototype; @@ -1624,7 +1624,7 @@ BlockDialogMorph.prototype.fixLayout = function () { // BlockEditorMorph inherits from DialogBoxMorph: -BlockEditorMorph.prototype = Object.create(DialogBoxMorph.prototype); +BlockEditorMorph.prototype = new DialogBoxMorph(); BlockEditorMorph.prototype.constructor = BlockEditorMorph; BlockEditorMorph.uber = DialogBoxMorph.prototype; @@ -1936,7 +1936,7 @@ BlockEditorMorph.prototype.fixLayout = function () { // PrototypeHatBlockMorph inherits from HatBlockMorph: -PrototypeHatBlockMorph.prototype = Object.create(HatBlockMorph.prototype); +PrototypeHatBlockMorph.prototype = new HatBlockMorph(); PrototypeHatBlockMorph.prototype.constructor = PrototypeHatBlockMorph; PrototypeHatBlockMorph.uber = HatBlockMorph.prototype; @@ -2146,7 +2146,7 @@ BlockLabelFragment.prototype.setSingleInputType = function (type) { // BlockLabelFragmentMorph inherits from StringMorph: -BlockLabelFragmentMorph.prototype = Object.create(StringMorph.prototype); +BlockLabelFragmentMorph.prototype = new StringMorph(); BlockLabelFragmentMorph.prototype.constructor = BlockLabelFragmentMorph; BlockLabelFragmentMorph.uber = StringMorph.prototype; @@ -2268,7 +2268,7 @@ BlockLabelFragmentMorph.prototype.userMenu = function () { // BlockLabelPlaceHolderMorph inherits from StringMorph: -BlockLabelPlaceHolderMorph.prototype = Object.create(StringMorph.prototype); +BlockLabelPlaceHolderMorph.prototype = new StringMorph(); BlockLabelPlaceHolderMorph.prototype.constructor = BlockLabelPlaceHolderMorph; BlockLabelPlaceHolderMorph.uber = StringMorph.prototype; @@ -2396,7 +2396,7 @@ BlockLabelPlaceHolderMorph.prototype.updateBlockLabel // BlockInputFragmentMorph inherits from TemplateSlotMorph: -BlockInputFragmentMorph.prototype = Object.create(TemplateSlotMorph.prototype); +BlockInputFragmentMorph.prototype = new TemplateSlotMorph(); BlockInputFragmentMorph.prototype.constructor = BlockInputFragmentMorph; BlockInputFragmentMorph.uber = TemplateSlotMorph.prototype; @@ -2426,7 +2426,7 @@ BlockInputFragmentMorph.prototype.updateBlockLabel // InputSlotDialogMorph inherits from DialogBoxMorph: -InputSlotDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); +InputSlotDialogMorph.prototype = new DialogBoxMorph(); InputSlotDialogMorph.prototype.constructor = InputSlotDialogMorph; InputSlotDialogMorph.uber = DialogBoxMorph.prototype; @@ -3026,7 +3026,7 @@ InputSlotDialogMorph.prototype.show = function () { // VariableDialogMorph inherits from DialogBoxMorph: -VariableDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); +VariableDialogMorph.prototype = new DialogBoxMorph(); VariableDialogMorph.prototype.constructor = VariableDialogMorph; VariableDialogMorph.uber = DialogBoxMorph.prototype; @@ -3145,7 +3145,7 @@ VariableDialogMorph.prototype.fixLayout = function () { // BlockExportDialogMorph inherits from DialogBoxMorph: -BlockExportDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); +BlockExportDialogMorph.prototype = new DialogBoxMorph(); BlockExportDialogMorph.prototype.constructor = BlockExportDialogMorph; BlockExportDialogMorph.uber = DialogBoxMorph.prototype; @@ -3327,7 +3327,7 @@ BlockExportDialogMorph.prototype.fixLayout // BlockImportDialogMorph inherits from DialogBoxMorph // and pseudo-inherits from BlockExportDialogMorph: -BlockImportDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); +BlockImportDialogMorph.prototype = new DialogBoxMorph(); BlockImportDialogMorph.prototype.constructor = BlockImportDialogMorph; BlockImportDialogMorph.uber = DialogBoxMorph.prototype; diff --git a/gui.js b/gui.js index 89e2d89..f50fd47 100644 --- a/gui.js +++ b/gui.js @@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2015-May-18'; +modules.gui = '2015-June-25'; // Declarations @@ -88,7 +88,7 @@ var JukeboxMorph; // IDE_Morph inherits from Morph: -IDE_Morph.prototype = Object.create(Morph.prototype); +IDE_Morph.prototype = new Morph(); IDE_Morph.prototype.constructor = IDE_Morph; IDE_Morph.uber = Morph.prototype; @@ -2614,7 +2614,7 @@ IDE_Morph.prototype.aboutSnap = function () { module, btn1, btn2, btn3, btn4, licenseBtn, translatorsBtn, world = this.world(); - aboutTxt = 'Snap! 4.0\nBuild Your Own Blocks\n\n' + aboutTxt = 'Snap! 4.0.1\nBuild Your Own Blocks\n\n' + 'Copyright \u24B8 2015 Jens M\u00F6nig and ' + 'Brian Harvey\n' + 'jens@moenig.org, bh@cs.berkeley.edu\n\n' @@ -2648,7 +2648,7 @@ IDE_Morph.prototype.aboutSnap = function () { creditsTxt = localize('Contributors') + '\n\nNathan Dinsmore: Saving/Loading, Snap-Logo Design, ' - + 'countless bugfixes' + + 'countless bugfixes and optimizations' + '\nKartik Chandra: Paint Editor' + '\nMichael Ball: Time/Date UI, many bugfixes' + '\n"Ava" Yuan Yuan: Graphic Effects' @@ -4274,7 +4274,7 @@ IDE_Morph.prototype.prompt = function (message, callback, choices, key) { // ProjectDialogMorph inherits from DialogBoxMorph: -ProjectDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); +ProjectDialogMorph.prototype = new DialogBoxMorph(); ProjectDialogMorph.prototype.constructor = ProjectDialogMorph; ProjectDialogMorph.uber = DialogBoxMorph.prototype; @@ -5181,7 +5181,7 @@ ProjectDialogMorph.prototype.fixLayout = function () { // SpriteIconMorph inherits from ToggleButtonMorph (Widgets) -SpriteIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); +SpriteIconMorph.prototype = new ToggleButtonMorph(); SpriteIconMorph.prototype.constructor = SpriteIconMorph; SpriteIconMorph.uber = ToggleButtonMorph.prototype; @@ -5571,7 +5571,7 @@ SpriteIconMorph.prototype.copySound = function (sound) { // CostumeIconMorph inherits from ToggleButtonMorph (Widgets) // ... and copies methods from SpriteIconMorph -CostumeIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); +CostumeIconMorph.prototype = new ToggleButtonMorph(); CostumeIconMorph.prototype.constructor = CostumeIconMorph; CostumeIconMorph.uber = ToggleButtonMorph.prototype; @@ -5782,7 +5782,7 @@ CostumeIconMorph.prototype.prepareToBeGrabbed = function () { // TurtleIconMorph inherits from ToggleButtonMorph (Widgets) // ... and copies methods from SpriteIconMorph -TurtleIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); +TurtleIconMorph.prototype = new ToggleButtonMorph(); TurtleIconMorph.prototype.constructor = TurtleIconMorph; TurtleIconMorph.uber = ToggleButtonMorph.prototype; @@ -5965,7 +5965,7 @@ TurtleIconMorph.prototype.userMenu = function () { // WardrobeMorph inherits from ScrollFrameMorph -WardrobeMorph.prototype = Object.create(ScrollFrameMorph.prototype); +WardrobeMorph.prototype = new ScrollFrameMorph(); WardrobeMorph.prototype.constructor = WardrobeMorph; WardrobeMorph.uber = ScrollFrameMorph.prototype; @@ -6148,7 +6148,7 @@ WardrobeMorph.prototype.reactToDropOf = function (icon) { // SoundIconMorph inherits from ToggleButtonMorph (Widgets) // ... and copies methods from SpriteIconMorph -SoundIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); +SoundIconMorph.prototype = new ToggleButtonMorph(); SoundIconMorph.prototype.constructor = SoundIconMorph; SoundIconMorph.uber = ToggleButtonMorph.prototype; @@ -6356,7 +6356,7 @@ SoundIconMorph.prototype.prepareToBeGrabbed = function () { // JukeboxMorph instance creation -JukeboxMorph.prototype = Object.create(ScrollFrameMorph.prototype); +JukeboxMorph.prototype = new ScrollFrameMorph(); JukeboxMorph.prototype.constructor = JukeboxMorph; JukeboxMorph.uber = ScrollFrameMorph.prototype; diff --git a/history.txt b/history.txt index 1262a28..9d9c00c 100755 --- a/history.txt +++ b/history.txt @@ -2516,3 +2516,10 @@ ______ 150608 ------ * Blocks: Fixed #820 + +150625 +------ +* Morphic, Objects, Blocks, XML: Optimizations and dramatic speed-up. Thanks, Nathan!! +* Objects: push maximum clone count up to 1000, tweak Note::play + +=== Release v4.0.1 === diff --git a/lists.js b/lists.js index 769b8b3..6fc9545 100644 --- a/lists.js +++ b/lists.js @@ -7,7 +7,7 @@ written by Jens Mönig and Brian Harvey jens@moenig.org, bh@cs.berkeley.edu - Copyright (C) 2014 by Jens Mönig and Brian Harvey + Copyright (C) 2015 by Jens Mönig and Brian Harvey This file is part of Snap!. @@ -61,7 +61,7 @@ PushButtonMorph, SyntaxElementMorph, Color, Point, WatcherMorph, StringMorph, SpriteMorph, ScrollFrameMorph, CellMorph, ArrowMorph, MenuMorph, snapEquals, Morph, isNil, localize, MorphicPreferences*/ -modules.lists = '2014-November-20'; +modules.lists = '2015-June-25'; var List; var ListWatcherMorph; @@ -363,7 +363,7 @@ List.prototype.equalTo = function (other) { // ListWatcherMorph inherits from BoxMorph: -ListWatcherMorph.prototype = Object.create(BoxMorph.prototype); +ListWatcherMorph.prototype = new BoxMorph(); ListWatcherMorph.prototype.constructor = ListWatcherMorph; ListWatcherMorph.uber = BoxMorph.prototype; @@ -388,13 +388,6 @@ ListWatcherMorph.prototype.init = function (list, parentCell) { this.lastCell = null; this.parentCell = parentCell || null; // for circularity detection - ListWatcherMorph.uber.init.call( - this, - SyntaxElementMorph.prototype.rounding, - 1.000001, // shadow bug in Chrome, - new Color(120, 120, 120) - ); - // elements declarations this.label = new StringMorph( localize('length: ') + this.list.length(), @@ -443,6 +436,13 @@ ListWatcherMorph.prototype.init = function (list, parentCell) { this.plusButton.drawNew(); this.plusButton.fixLayout(); + ListWatcherMorph.uber.init.call( + this, + SyntaxElementMorph.prototype.rounding, + 1.000001, // shadow bug in Chrome, + new Color(120, 120, 120) + ); + this.color = new Color(220, 220, 220); this.isDraggable = true; this.setExtent(new Point(80, 70).multiplyBy( @@ -634,7 +634,7 @@ ListWatcherMorph.prototype.setStartIndex = function (index) { }; ListWatcherMorph.prototype.fixLayout = function () { - if (!this.label) return; + if (!this.label) {return; } Morph.prototype.trackChanges = false; if (this.frame) { this.arrangeCells(); diff --git a/objects.js b/objects.js index 1e8060e..8eeb236 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2015-May-18'; +modules.objects = '2015-June-25'; var SpriteMorph; var StageMorph; @@ -147,7 +147,7 @@ var SpriteHighlightMorph; // SpriteMorph inherits from PenMorph: -SpriteMorph.prototype = Object.create(PenMorph.prototype); +SpriteMorph.prototype = new PenMorph(); SpriteMorph.prototype.constructor = SpriteMorph; SpriteMorph.uber = PenMorph.prototype; @@ -2718,7 +2718,7 @@ SpriteMorph.prototype.remove = function () { SpriteMorph.prototype.createClone = function () { var stage = this.parentThatIsA(StageMorph); - if (stage && stage.cloneCount <= 300) { + if (stage && stage.cloneCount <= 1000) { this.fullCopy().clonify(stage); } }; @@ -4289,7 +4289,7 @@ SpriteMorph.prototype.doScreenshot = function (imgSource, data) { // SpriteHighlightMorph inherits from Morph: -SpriteHighlightMorph.prototype = Object.create(Morph.prototype); +SpriteHighlightMorph.prototype = new Morph(); SpriteHighlightMorph.prototype.constructor = SpriteHighlightMorph; SpriteHighlightMorph.uber = Morph.prototype; @@ -4307,7 +4307,7 @@ function SpriteHighlightMorph() { // StageMorph inherits from FrameMorph: -StageMorph.prototype = Object.create(FrameMorph.prototype); +StageMorph.prototype = new FrameMorph(); StageMorph.prototype.constructor = StageMorph; StageMorph.uber = FrameMorph.prototype; @@ -5669,7 +5669,7 @@ StageMorph.prototype.replaceDoubleDefinitionsFor // SpriteBubbleMorph inherits from SpeechBubbleMorph: -SpriteBubbleMorph.prototype = Object.create(SpeechBubbleMorph.prototype); +SpriteBubbleMorph.prototype = new SpeechBubbleMorph(); SpriteBubbleMorph.prototype.constructor = SpriteBubbleMorph; SpriteBubbleMorph.uber = SpeechBubbleMorph.prototype; @@ -6168,7 +6168,7 @@ Costume.prototype.isTainted = function () { // SVG_Costume inherits from Costume: -SVG_Costume.prototype = Object.create(Costume.prototype); +SVG_Costume.prototype = new Costume(); SVG_Costume.prototype.constructor = SVG_Costume; SVG_Costume.uber = Costume.prototype; @@ -6219,7 +6219,7 @@ SVG_Costume.prototype.shrinkToFit = function (extentPoint) { // CostumeEditorMorph inherits from Morph: -CostumeEditorMorph.prototype = Object.create(Morph.prototype); +CostumeEditorMorph.prototype = new Morph(); CostumeEditorMorph.prototype.constructor = CostumeEditorMorph; CostumeEditorMorph.uber = Morph.prototype; @@ -6429,7 +6429,7 @@ Note.prototype.play = function () { if (!this.oscillator.stop) { this.oscillator.stop = this.oscillator.noteOff; } - this.oscillator.type = 0; + this.oscillator.type = 'sine'; this.oscillator.frequency.value = Math.pow(2, (this.pitch - 69) / 12) * 440; this.oscillator.connect(this.gainNode); @@ -6454,7 +6454,7 @@ Note.prototype.stop = function () { // CellMorph inherits from BoxMorph: -CellMorph.prototype = Object.create(BoxMorph.prototype); +CellMorph.prototype = new BoxMorph(); CellMorph.prototype.constructor = CellMorph; CellMorph.uber = BoxMorph.prototype; @@ -6794,7 +6794,7 @@ CellMorph.prototype.mouseClickLeft = function (pos) { // WatcherMorph inherits from BoxMorph: -WatcherMorph.prototype = Object.create(BoxMorph.prototype); +WatcherMorph.prototype = new BoxMorph(); WatcherMorph.prototype.constructor = WatcherMorph; WatcherMorph.uber = BoxMorph.prototype; @@ -7281,7 +7281,7 @@ WatcherMorph.prototype.drawNew = function () { // StagePrompterMorph inherits from BoxMorph: -StagePrompterMorph.prototype = Object.create(BoxMorph.prototype); +StagePrompterMorph.prototype = new BoxMorph(); StagePrompterMorph.prototype.constructor = StagePrompterMorph; StagePrompterMorph.uber = BoxMorph.prototype; diff --git a/paint.js b/paint.js index 6e4ae8b..6d9b09c 100644 --- a/paint.js +++ b/paint.js @@ -5,7 +5,7 @@ inspired by the Scratch paint editor. written by Kartik Chandra - Copyright (C) 2014 by Kartik Chandra + Copyright (C) 2015 by Kartik Chandra This file is part of Snap!. @@ -69,7 +69,7 @@ // Global stuff //////////////////////////////////////////////////////// -modules.paint = '2014-September-29'; +modules.paint = '2015-June-25'; // Declarations @@ -81,7 +81,7 @@ var PaintColorPickerMorph; // A complete paint editor -PaintEditorMorph.prototype = Object.create(DialogBoxMorph.prototype); +PaintEditorMorph.prototype = new DialogBoxMorph(); PaintEditorMorph.prototype.constructor = PaintEditorMorph; PaintEditorMorph.uber = DialogBoxMorph.prototype; @@ -92,7 +92,6 @@ function PaintEditorMorph() { } PaintEditorMorph.prototype.init = function () { - PaintEditorMorph.uber.init.call(this); // additional properties: this.paper = null; // paint canvas this.oncancel = null; @@ -477,7 +476,7 @@ PaintEditorMorph.prototype.getUserColor = function () { // A large hsl color picker -PaintColorPickerMorph.prototype = Object.create(Morph.prototype); +PaintColorPickerMorph.prototype = new Morph(); PaintColorPickerMorph.prototype.constructor = PaintColorPickerMorph; PaintColorPickerMorph.uber = Morph.prototype; @@ -486,7 +485,6 @@ function PaintColorPickerMorph(extent, action) { } PaintColorPickerMorph.prototype.init = function (extent, action) { - PaintColorPickerMorph.uber.init.call(this); this.setExtent(extent || new Point(200, 100)); this.action = action || nop; this.drawNew(); @@ -554,7 +552,7 @@ PaintColorPickerMorph.prototype.mouseMove = modify its image, based on a 'tool' property. */ -PaintCanvasMorph.prototype = Object.create(Morph.prototype); +PaintCanvasMorph.prototype = new Morph(); PaintCanvasMorph.prototype.constructor = PaintCanvasMorph; PaintCanvasMorph.uber = Morph.prototype; @@ -563,7 +561,6 @@ function PaintCanvasMorph(shift) { } PaintCanvasMorph.prototype.init = function (shift) { - PaintCanvasMorph.uber.init.call(this); this.rotationCenter = new Point(240, 180); this.dragRect = null; this.previousDragPoint = null; @@ -964,7 +961,6 @@ PaintCanvasMorph.prototype.buildContents = function () { }; PaintCanvasMorph.prototype.drawNew = function () { - if (!this.background) return; var can = newCanvas(this.extent()); this.merge(this.background, can); this.merge(this.paper, can); diff --git a/store.js b/store.js index a45c801..e73ba9f 100644 --- a/store.js +++ b/store.js @@ -61,7 +61,7 @@ SyntaxElementMorph, Variable*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2015-April-26'; +modules.store = '2015-June-25'; // XML_Serializer /////////////////////////////////////////////////////// @@ -246,7 +246,7 @@ var SnapSerializer; // SnapSerializer inherits from XML_Serializer: -SnapSerializer.prototype = Object.create(XML_Serializer.prototype); +SnapSerializer.prototype = new XML_Serializer(); SnapSerializer.prototype.constructor = SnapSerializer; SnapSerializer.uber = XML_Serializer.prototype; @@ -274,7 +274,6 @@ SnapSerializer.prototype.watcherLabels = { // SnapSerializer instance creation: function SnapSerializer() { - XML_Serializer.call(this); this.init(); } diff --git a/widgets.js b/widgets.js index 2f96f2c..a8644af 100644 --- a/widgets.js +++ b/widgets.js @@ -7,7 +7,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!. @@ -74,7 +74,7 @@ HTMLCanvasElement, fontHeight, SymbolMorph, localize, SpeechBubbleMorph, ArrowMorph, MenuMorph, isString, isNil, SliderMorph, MorphicPreferences, ScrollFrameMorph*/ -modules.widgets = '2014-February-13'; +modules.widgets = '2015-June-25'; var PushButtonMorph; var ToggleButtonMorph; @@ -91,7 +91,7 @@ var InputFieldMorph; // PushButtonMorph inherits from TriggerMorph: -PushButtonMorph.prototype = Object.create(TriggerMorph.prototype); +PushButtonMorph.prototype = new TriggerMorph(); PushButtonMorph.prototype.constructor = PushButtonMorph; PushButtonMorph.uber = TriggerMorph.prototype; @@ -476,7 +476,7 @@ PushButtonMorph.prototype.createLabel = function () { // ToggleButtonMorph inherits from PushButtonMorph: -ToggleButtonMorph.prototype = Object.create(PushButtonMorph.prototype); +ToggleButtonMorph.prototype = new PushButtonMorph(); ToggleButtonMorph.prototype.constructor = ToggleButtonMorph; ToggleButtonMorph.uber = PushButtonMorph.prototype; @@ -900,7 +900,7 @@ ToggleButtonMorph.prototype.show = function () { // TabMorph inherits from ToggleButtonMorph: -TabMorph.prototype = Object.create(ToggleButtonMorph.prototype); +TabMorph.prototype = new ToggleButtonMorph(); TabMorph.prototype.constructor = TabMorph; TabMorph.uber = ToggleButtonMorph.prototype; @@ -1022,7 +1022,7 @@ TabMorph.prototype.drawEdges = function ( // ToggleMorph inherits from PushButtonMorph: -ToggleMorph.prototype = Object.create(PushButtonMorph.prototype); +ToggleMorph.prototype = new PushButtonMorph(); ToggleMorph.prototype.constructor = ToggleMorph; ToggleMorph.uber = PushButtonMorph.prototype; @@ -1270,7 +1270,7 @@ ToggleMorph.prototype.show = ToggleButtonMorph.prototype.show; // ToggleElementMorph inherits from TriggerMorph: -ToggleElementMorph.prototype = Object.create(TriggerMorph.prototype); +ToggleElementMorph.prototype = new TriggerMorph(); ToggleElementMorph.prototype.constructor = ToggleElementMorph; ToggleElementMorph.uber = TriggerMorph.prototype; @@ -1440,7 +1440,7 @@ ToggleElementMorph.prototype.mouseClickLeft // DialogBoxMorph inherits from Morph: -DialogBoxMorph.prototype = Object.create(Morph.prototype); +DialogBoxMorph.prototype = new Morph(); DialogBoxMorph.prototype.constructor = DialogBoxMorph; DialogBoxMorph.uber = Morph.prototype; @@ -2866,7 +2866,7 @@ DialogBoxMorph.prototype.outlinePathBody = function (context, radius) { // AlignmentMorph inherits from Morph: -AlignmentMorph.prototype = Object.create(Morph.prototype); +AlignmentMorph.prototype = new Morph(); AlignmentMorph.prototype.constructor = AlignmentMorph; AlignmentMorph.uber = Morph.prototype; @@ -2940,7 +2940,7 @@ AlignmentMorph.prototype.fixLayout = function () { // InputFieldMorph inherits from Morph: -InputFieldMorph.prototype = Object.create(Morph.prototype); +InputFieldMorph.prototype = new Morph(); InputFieldMorph.prototype.constructor = InputFieldMorph; InputFieldMorph.uber = Morph.prototype; diff --git a/xml.js b/xml.js old mode 100644 new mode 100755 index 16b03f0..b80f520 --- a/xml.js +++ b/xml.js @@ -7,7 +7,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!. @@ -57,7 +57,9 @@ Nathan Dinsmore contributed to the design and implemented a first working version of a complete XMLSerializer. I have taken much of the overall design and many of the functions and methods in this file from - Nathan's fine original prototype. + Nathan's fine original prototype. Recently Nathan has once again + worked his magic on the parser and optimized it by an order of + magnitude. */ @@ -65,7 +67,7 @@ // Global stuff //////////////////////////////////////////////////////// -modules.xml = '2014-January-09'; +modules.xml = '2015-June-25'; // Declarations -- cgit v1.3.1 From 7c8dd2b4e89ca10168df128df80edc14a60fcf13 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 15:36:21 +0200 Subject: remove some spaces --- objects.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'objects.js') diff --git a/objects.js b/objects.js index 118e3c8..3f95385 100644 --- a/objects.js +++ b/objects.js @@ -3509,9 +3509,9 @@ SpriteMorph.prototype.allHatBlocksFor = function (message) { if (morph.selector) { if (morph.selector === 'receiveMessage') { event = morph.inputs()[0].evaluate(); - return event === message - || (event instanceof Array - && message !== '__shout__go__' + return event === message + || (event instanceof Array + && message !== '__shout__go__' && message !== '__clone__init__'); } if (morph.selector === 'receiveGo') { -- cgit v1.3.1