From 9e5fb9a4cba980c977d4e11e5c9a4e7f9c8596db Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Sat, 25 Oct 2014 02:03:12 -0700 Subject: Set location.hash to cloud URLs on project shares This will make it much easier to get the URL for a shared project. It also removes the # from the URL when the open project is unshared." --- gui.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gui.js b/gui.js index 04481cc..6052953 100644 --- a/gui.js +++ b/gui.js @@ -4864,6 +4864,7 @@ ProjectDialogMorph.prototype.deleteProject = function () { ProjectDialogMorph.prototype.shareProject = function () { var myself = this, + ide = this.siblings()[0], proj = this.listField.selected, entry = this.listField.active; @@ -4894,6 +4895,15 @@ ProjectDialogMorph.prototype.shareProject = function () { myself.ide.cloudError(), [proj.ProjectName] ); + // Set the Shared URL if the project is currently open + if (proj.ProjectName === ide.projectName) { + var usr = SnapCloud.username, + projectId = 'Username=' + + encodeURIComponent(usr.toLowerCase()) + + '&ProjectName=' + + encodeURIComponent(ide.projectName); + location.hash = projectId; + } }, myself.ide.cloudError() ); @@ -4904,6 +4914,7 @@ ProjectDialogMorph.prototype.shareProject = function () { ProjectDialogMorph.prototype.unshareProject = function () { var myself = this, + ide = this.siblings()[0], proj = this.listField.selected, entry = this.listField.active; @@ -4935,6 +4946,10 @@ ProjectDialogMorph.prototype.unshareProject = function () { myself.ide.cloudError(), [proj.ProjectName] ); + // Remove the shared URL if the project is open. + if (proj.ProjectName === ide.projectName) { + location.hash = ''; + } }, myself.ide.cloudError() ); -- cgit v1.3.1 From e892ea80cb627961a0f84ebe61b7610528f67090 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 24 Nov 2014 15:23:40 -0800 Subject: Shared URLs: remove call to .siblings() Project dialog morphs reference `ide` directly instead of using a function call --- gui.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gui.js b/gui.js index f53d597..d80e61a 100644 --- a/gui.js +++ b/gui.js @@ -4865,7 +4865,7 @@ ProjectDialogMorph.prototype.deleteProject = function () { ProjectDialogMorph.prototype.shareProject = function () { var myself = this, - ide = this.siblings()[0], + ide = this.ide, proj = this.listField.selected, entry = this.listField.active; @@ -4902,7 +4902,7 @@ ProjectDialogMorph.prototype.shareProject = function () { projectId = 'Username=' + encodeURIComponent(usr.toLowerCase()) + '&ProjectName=' + - encodeURIComponent(ide.projectName); + encodeURIComponent(proj.projectName); location.hash = projectId; } }, @@ -4915,7 +4915,7 @@ ProjectDialogMorph.prototype.shareProject = function () { ProjectDialogMorph.prototype.unshareProject = function () { var myself = this, - ide = this.siblings()[0], + ide = this.ide, proj = this.listField.selected, entry = this.listField.active; -- cgit v1.3.1 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 --- blocks.js | 19 ----------------- gui.js | 1 - objects.js | 16 -------------- threads.js | 72 -------------------------------------------------------------- 4 files changed, 108 deletions(-) diff --git a/blocks.js b/blocks.js index 35f31a4..e56d0ed 100644 --- a/blocks.js +++ b/blocks.js @@ -866,25 +866,6 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { ); part.setContents(['date']); break; - case '%locations': - part = new InputSlotMorph( - null, // text - false, // non-numeric - { - 'all' : ['all'], - 'country' : ['country'], - 'state' : ['state'], - 'state district' : ['state district'], - 'suburb' : ['suburb'], - 'city' : ['city'], - 'road' : ['road'], - 'house number' : ['house number'], - 'licence': ['licence'] - }, - true // read-only - ); - part.setContents(['all']); - break; case '%delim': part = new InputSlotMorph( null, // text diff --git a/gui.js b/gui.js index b452941..c3104c5 100644 --- a/gui.js +++ b/gui.js @@ -3546,7 +3546,6 @@ IDE_Morph.prototype.setLanguage = function (lang, callback) { if (lang === 'en') { return this.reflectLanguage('en', callback); } - myself.userLanguage = lang; translation = document.createElement('script'); translation.id = 'language'; translation.onload = function () { 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')); diff --git a/threads.js b/threads.js index 06454e3..7587f06 100644 --- a/threads.js +++ b/threads.js @@ -2669,78 +2669,6 @@ Process.prototype.reportTimer = function () { return 0; }; -Process.prototype.reportLanguage = function () { - var ide = this.homeContext.receiver.parentThatIsA(IDE_Morph); - if (ide) { - var lang = ide.userLanguage; - if (lang) { - return lang; - } - } - return 'en'; -}; - -Process.prototype.reportLocation = function (name) { - var myself = this; - - if (!myself.context.jsonpScript) { - if (!navigator.geolocation) { - myself.handleError({name: 'Location', - message: 'navigator.geolocation is not supported'}); - } - window.OSM_JSONP_Callback = function (data) { - myself.context.json = data; - window.OSM_JSONP_Callback = undefined; - }; - myself.context.jsonpScript = document.createElement('script'); - - navigator.geolocation.getCurrentPosition( - function (pos) { - var crd = pos.coords; - - myself.context.jsonpScript.src = - 'https://nominatim.openstreetmap.org/reverse' - + '?format=json&json_callback=OSM_JSONP_Callback' - + '&zoom=18&addressdetails=1' - + '&lat=' - + crd.latitude - + '&lon=' - + crd.longitude; - document.getElementsByTagName('HEAD')[0] - .appendChild(myself.context.jsonpScript); - }, - function (err) { - console.log(err); - myself.handleError({name: 'Location', message: err}); - }, - { enableHightAccuracy: true, timeout: 30000, maximumAge: 0} - ); - } else { - if (myself.context.json) { - switch (myself.inputOption(name)) { - case 'all': - return myself.context.json.display_name; - case 'state district': - return myself.context.json.address.state_district; - case 'house number': - return myself.context.json.address.house_number; - case 'licence': - return myself.context.json.licence; - case 'country': - case 'state': - case 'suburb': - case 'city': - case 'road': - return myself.context. - json.address[myself.inputOption(name)]; - } - } - } - - this.pushContext('doYield'); - this.pushContext(); -}; - // Process Dates and times in Snap // Map block options to built-in functions var dateMap = { -- cgit v1.3.1 From 3af7d0d6100fba5fcc0ce062597d3dea61ef2ea7 Mon Sep 17 00:00:00 2001 From: Gubolin Date: Wed, 4 Mar 2015 16:29:28 +0100 Subject: I just lost my git repository the second time. --- binary.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/binary.sh b/binary.sh index 9de5fa0..868cef6 100755 --- a/binary.sh +++ b/binary.sh @@ -49,8 +49,6 @@ git clone $snapsource $buildsource cd "$buildsource" git checkout mobileapp -rm -rf .git/ - if [ $ide == false ] then # minimize everything -- cgit v1.3.1 From 4b2ca15547c88ff9a785d4716011079cf6c7ae09 Mon Sep 17 00:00:00 2001 From: Gubolin Date: Wed, 4 Mar 2015 17:46:52 +0100 Subject: drop "binary mode" support (too difficult to mantain) --- binary.js | 1099 ------------------------------------------------------------- binary.sh | 13 +- 2 files changed, 4 insertions(+), 1108 deletions(-) delete mode 100755 binary.js diff --git a/binary.js b/binary.js deleted file mode 100755 index d1a9b21..0000000 --- a/binary.js +++ /dev/null @@ -1,1099 +0,0 @@ -/* - - gui.js - - a programming environment - based on morphic.js, blocks.js, threads.js and objects.js - inspired by Scratch - - written by Jens Mönig - jens@moenig.org - - Copyright (C) 2014 by Jens Mönig - - This file is part of Snap!. - - Snap! is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation, either version 3 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - - - prerequisites: - -------------- - needs blocks.js, threads.js, objects.js and morphic.js - - - toc - --- - the following list shows the order in which all constructors are - defined. Use this list to locate code in this document: - - IDE_Morph - - - credits - ------- - Nathan Dinsmore contributed saving and loading of projects, - ypr-Snap! project conversion and countless bugfixes - Ian Reynolds contributed handling and visualization of sounds - -*/ - -/*global modules, Morph, SpriteMorph, Color, newCanvas, -VariableFrame, Point, MenuMorph, -morphicVersion, DialogBoxMorph, ToggleButtonMorph, contains, -StageMorph, PushButtonMorph, Process, SnapSerializer, MorphicPreferences, -SymbolMorph, -BlockImportDialogMorph, SnapTranslator, localize, List */ - -// Global stuff //////////////////////////////////////////////////////// - -modules.gui = '2014-July-30'; - -// Declarations - -var IDE_Morph; - -// IDE_Morph /////////////////////////////////////////////////////////// - -// I am SNAP's top-level frame, the Editor window - -// IDE_Morph inherits from Morph: - -IDE_Morph.prototype = new Morph(); -IDE_Morph.prototype.constructor = IDE_Morph; -IDE_Morph.uber = Morph.prototype; - -// IDE_Morph preferences settings and skins - -IDE_Morph.prototype.setDefaultDesign = function () { - MorphicPreferences.isFlat = false; - SpriteMorph.prototype.paletteColor = new Color(55, 55, 55); - SpriteMorph.prototype.paletteTextColor = new Color(230, 230, 230); - StageMorph.prototype.paletteTextColor - = SpriteMorph.prototype.paletteTextColor; - StageMorph.prototype.paletteColor = SpriteMorph.prototype.paletteColor; - SpriteMorph.prototype.sliderColor - = SpriteMorph.prototype.paletteColor.lighter(30); - - IDE_Morph.prototype.buttonContrast = 30; - IDE_Morph.prototype.backgroundColor = new Color(40, 40, 40); - IDE_Morph.prototype.frameColor = SpriteMorph.prototype.paletteColor; - - IDE_Morph.prototype.groupColor - = SpriteMorph.prototype.paletteColor.lighter(8); - IDE_Morph.prototype.sliderColor = SpriteMorph.prototype.sliderColor; - IDE_Morph.prototype.buttonLabelColor = new Color(255, 255, 255); - IDE_Morph.prototype.tabColors = [ - IDE_Morph.prototype.groupColor.darker(40), - IDE_Morph.prototype.groupColor.darker(60), - IDE_Morph.prototype.groupColor - ]; - IDE_Morph.prototype.rotationStyleColors = IDE_Morph.prototype.tabColors; - IDE_Morph.prototype.appModeColor = new Color(); - IDE_Morph.prototype.scriptsPaneTexture = 'scriptsPaneTexture.gif'; - IDE_Morph.prototype.padding = 5; -}; - -IDE_Morph.prototype.setFlatDesign = function () { - MorphicPreferences.isFlat = true; - SpriteMorph.prototype.paletteColor = new Color(255, 255, 255); - SpriteMorph.prototype.paletteTextColor = new Color(70, 70, 70); - StageMorph.prototype.paletteTextColor - = SpriteMorph.prototype.paletteTextColor; - StageMorph.prototype.paletteColor = SpriteMorph.prototype.paletteColor; - SpriteMorph.prototype.sliderColor = SpriteMorph.prototype.paletteColor; - - IDE_Morph.prototype.buttonContrast = 30; - IDE_Morph.prototype.backgroundColor = new Color(200, 200, 200); - IDE_Morph.prototype.frameColor = new Color(255, 255, 255); - - IDE_Morph.prototype.groupColor = new Color(230, 230, 230); - IDE_Morph.prototype.sliderColor = SpriteMorph.prototype.sliderColor; - IDE_Morph.prototype.buttonLabelColor = new Color(70, 70, 70); - IDE_Morph.prototype.tabColors = [ - IDE_Morph.prototype.groupColor.lighter(60), - IDE_Morph.prototype.groupColor.darker(10), - IDE_Morph.prototype.groupColor - ]; - IDE_Morph.prototype.rotationStyleColors = [ - IDE_Morph.prototype.groupColor, - IDE_Morph.prototype.groupColor.darker(10), - IDE_Morph.prototype.groupColor.darker(30) - ]; - IDE_Morph.prototype.appModeColor = IDE_Morph.prototype.frameColor; - IDE_Morph.prototype.scriptsPaneTexture = null; - IDE_Morph.prototype.padding = 1; -}; - -IDE_Morph.prototype.setDefaultDesign(); - -// IDE_Morph instance creation: - -function IDE_Morph(isAutoFill) { - this.init(isAutoFill); -} - -IDE_Morph.prototype.init = function (isAutoFill) { - // global font setting - MorphicPreferences.globalFontFamily = 'Helvetica, Arial'; - - // restore saved user preferences - this.userLanguage = null; - - // additional properties: - this.source = 'local'; - this.serializer = new SnapSerializer(); - - this.globalVariables = new VariableFrame(); - this.currentSprite = new SpriteMorph(this.globalVariables); - this.sprites = new List([this.currentSprite]); - this.currentCategory = 'motion'; - this.currentTab = 'scripts'; - this.projectName = ''; - this.projectNotes = ''; - - this.logo = null; - this.controlBar = null; - this.stage = null; - - this.isAutoFill = isAutoFill || true; - - this.filePicker = null; - this.hasChangedMedia = false; - - this.isAnimating = true; - this.stageRatio = 1; // for IDE animations, e.g. when zooming - - this.loadNewProject = false; // flag when starting up translated - this.shield = null; - - // initialize inherited properties: - IDE_Morph.uber.init.call(this); - - // override inherited properites: - this.color = this.appModeColor; -}; - -IDE_Morph.prototype.openIn = function (world) { - var hash; - - this.buildPanes(); - world.add(this); - - this.reactToWorldResize(world.bounds); - - function getURL(url) { - try { - var request = new XMLHttpRequest(); - request.open('GET', url, false); - request.send(); - if (request.status === 200) { - return request.responseText; - } - throw new Error('unable to retrieve ' + url); - } catch (err) { - return; - } - } - - function interpretUrlAnchors() { - if (location.hash.substr(0, 6) === '#open:') { - hash = location.hash.substr(6); - if (hash.charAt(0) === '%' - || hash.search(/\%(?:[0-9a-f]{2})/i) > -1) { - hash = decodeURIComponent(hash); - } - if (contains( - ['project', 'blocks', 'sprites', 'snapdata'].map( - function (each) { - return hash.substr(0, 8).indexOf(each); - } - ), - 1 - )) { - this.droppedText(hash); - } else { - this.droppedText(getURL(hash)); - } - } - } - - if (this.userLanguage) { - this.setLanguage(this.userLanguage, interpretUrlAnchors); - } else { - interpretUrlAnchors.call(this); - } -}; - -// IDE_Morph construction - -IDE_Morph.prototype.buildPanes = function () { - this.createLogo(); - this.createControlBar(); - this.createStage(); -}; - -IDE_Morph.prototype.createLogo = function () { - var myself = this; - - if (this.logo) { - this.logo.destroy(); - } - - this.logo = new Morph(); - this.logo.texture = 'snap_logo_sm.png'; - this.logo.drawNew = function () { - this.image = newCanvas(this.extent()); - var context = this.image.getContext('2d'); - context.fillStyle = this.color; - context.fillRect(0, 0, this.width(), this.height()); - if (this.texture) { - this.drawTexture(this.texture); - } - }; - - this.logo.drawCachedTexture = function () { - var context = this.image.getContext('2d'); - context.drawImage( - this.cachedTexture, - 5, - Math.round((this.height() - this.cachedTexture.height) / 2) - ); - this.changed(); - }; - - this.logo.mouseClickLeft = function () { - myself.snapMenu(); - }; - - this.logo.color = new Color(); - this.logo.setExtent(new Point(200, 28)); // dimensions are fixed - this.add(this.logo); -}; - -IDE_Morph.prototype.createControlBar = function () { - // assumes the logo has already been created - var padding = 5, - button, - stopButton, - pauseButton, - startButton, - x, - colors = [ - this.groupColor, - this.frameColor.darker(50), - this.frameColor.darker(50) - ], - myself = this; - - if (this.controlBar) { - this.controlBar.destroy(); - } - - this.controlBar = new Morph(); - this.controlBar.color = this.appModeColor; - this.controlBar.setHeight(this.logo.height()); // height is fixed - this.controlBar.mouseClickLeft = function () { - this.world().fillPage(); - }; - this.add(this.controlBar); - - // stopButton - button = new PushButtonMorph( - this, - 'stopAllScripts', - new SymbolMorph('octagon', 14) - ); - button.corner = 12; - button.color = colors[0]; - button.highlightColor = colors[1]; - button.pressColor = colors[2]; - button.labelMinExtent = new Point(36, 18); - button.padding = 0; - button.labelShadowOffset = new Point(-1, -1); - button.labelShadowColor = colors[1]; - button.labelColor = new Color(200, 0, 0); - button.contrast = this.buttonContrast; - button.drawNew(); - // button.hint = 'stop\nevery-\nthing'; - button.fixLayout(); - stopButton = button; - this.controlBar.add(stopButton); - - //pauseButton - button = new ToggleButtonMorph( - null, //colors, - myself, // the IDE is the target - 'togglePauseResume', - [ - new SymbolMorph('pause', 12), - new SymbolMorph('pointRight', 14) - ], - function () { // query - return myself.isPaused(); - } - ); - - button.corner = 12; - button.color = colors[0]; - button.highlightColor = colors[1]; - button.pressColor = colors[2]; - button.labelMinExtent = new Point(36, 18); - button.padding = 0; - button.labelShadowOffset = new Point(-1, -1); - button.labelShadowColor = colors[1]; - button.labelColor = new Color(255, 220, 0); - button.contrast = this.buttonContrast; - button.drawNew(); - // button.hint = 'pause/resume\nall scripts'; - button.fixLayout(); - button.refresh(); - pauseButton = button; - this.controlBar.add(pauseButton); - this.controlBar.pauseButton = pauseButton; // for refreshing - - // startButton - button = new PushButtonMorph( - this, - 'pressStart', - new SymbolMorph('flag', 14) - ); - button.corner = 12; - button.color = colors[0]; - button.highlightColor = colors[1]; - button.pressColor = colors[2]; - button.labelMinExtent = new Point(36, 18); - button.padding = 0; - button.labelShadowOffset = new Point(-1, -1); - button.labelShadowColor = colors[1]; - button.labelColor = new Color(0, 200, 0); - button.contrast = this.buttonContrast; - button.drawNew(); - // button.hint = 'start green\nflag scripts'; - button.fixLayout(); - startButton = button; - this.controlBar.add(startButton); - this.controlBar.startButton = startButton; - - this.controlBar.fixLayout = function () { - x = this.right() - padding; - [stopButton, pauseButton, startButton].forEach( - function (button) { - button.setCenter(myself.controlBar.center()); - button.setRight(x); - x -= button.width(); - x -= padding; - } - ); - - x = myself.right() - StageMorph.prototype.dimensions.x; - - this.updateLabel(); - }; - - this.controlBar.updateLabel = function () { - if (this.label) { - this.label.destroy(); - } - }; -}; - -IDE_Morph.prototype.createStage = function () { - // assumes that the logo pane has already been created - if (this.stage) { - this.stage.destroy(); - } - StageMorph.prototype.frameRate = 0; - this.stage = new StageMorph(this.globalVariables); - this.stage.setExtent(this.stage.dimensions); // dimensions are fixed - if (this.currentSprite instanceof SpriteMorph) { - this.currentSprite.setPosition( - this.stage.center().subtract( - this.currentSprite.extent().divideBy(2) - ) - ); - this.stage.add(this.currentSprite); - } - this.add(this.stage); -}; - -IDE_Morph.prototype.createCorral = function () { -}; - -// IDE_Morph resizing - -IDE_Morph.prototype.setExtent = function (point) { - var minExt, - ext; - - // determine the minimum dimensions making sense for the current mode - minExt = StageMorph.prototype.dimensions.add( - this.controlBar.height() + 10 - ); - ext = point.max(minExt); - IDE_Morph.uber.setExtent.call(this, ext); - this.fixLayout(); -}; - -// IDE_Morph events - -IDE_Morph.prototype.reactToWorldResize = function (rect) { - if (this.isAutoFill) { - this.setPosition(rect.origin); - this.setExtent(rect.extent()); - } - if (this.filePicker) { - document.body.removeChild(this.filePicker); - this.filePicker = null; - } -}; - -// IDE_Morph layout - -IDE_Morph.prototype.fixLayout = function () { - var padding = this.padding; - - Morph.prototype.trackChanges = false; - - // controlBar - this.controlBar.setPosition(this.logo.topRight()); - this.controlBar.setWidth(this.right() - this.controlBar.left()); - this.controlBar.fixLayout(); - - // stage - this.stage.setScale(Math.floor(Math.min( - (this.width() - padding * 2) / this.stage.dimensions.x, - (this.height() - this.controlBar.height() * 2 - padding * 2) - / this.stage.dimensions.y - ) * 10) / 10); - this.stage.setCenter(this.center()); - - Morph.prototype.trackChanges = true; - this.changed(); -}; - -IDE_Morph.prototype.droppedText = function (aString, name) { - var lbl = name ? name.split('.')[0] : ''; - if (aString.indexOf(' Date: Wed, 4 Mar 2015 18:35:40 +0100 Subject: support cloud projects --- binary.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/binary.sh b/binary.sh index 83b8d12..809d1fe 100755 --- a/binary.sh +++ b/binary.sh @@ -18,6 +18,8 @@ then echo " Desktop win32 win64 osx linux32 linux64" echo "" echo "If FILE/URL is given, it will be #open-ed inside Snap! immediately. URL will be loaded at runtime." + echo "If URL starts with a hash ('#'), it will be used as initial base url suffix" + echo " (for example '#present:UserName=foo\&ProjectName=bar', escape the '&')." echo "" echo "" echo "The following environment variables will be used, if available:" @@ -65,11 +67,17 @@ then url=$3 fi - # load custom project from url - sed -i "/ide\.openIn/a\ - ide.droppedText(ide.getURL('$url'));" snap.html - sed -i "/this.toggleAppMode(false)/d" gui.js - sed -i "s/snap.html/snap.html#run:/g" config.xml package.json + if [[ $url == \#* ]] + then + # load custom project from cloud or string + sed -i "s/snap.html/snap.html${url}/g" config.xml package.json + else + # load custom project from url + sed -i "/ide\.openIn/a\ + ide.droppedText(ide.getURL('$url'));" snap.html + sed -i "/this.toggleAppMode(false)/d" gui.js + sed -i "s/snap.html/snap.html#run:/g" config.xml package.json + fi fi # compress all js files -- cgit v1.3.1 From 692486e3778a0b678151a671d4aa999e0536859f Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sun, 8 Mar 2015 15:04:58 +0100 Subject: speed up connections to self --- threads.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/threads.js b/threads.js index 2d1ce77..165c7fc 100644 --- a/threads.js +++ b/threads.js @@ -1299,16 +1299,22 @@ Process.prototype.doRemoveTemporaries = function () { Process.prototype.sendPeerMessage = function (message, peer) { var myself = this; + 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!'); + stage.newPeerMessage(message, peer); + return; + } - var stage = this.homeContext.receiver.parentThatIsA(StageMorph), - ide = this.homeContext.receiver.parentThatIsA(IDE_Morph); var connection = stage.peer.connect(peer, {reliable: true}); connection.on('open', function () { var data; -- 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(-) 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(-) 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(-) 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 802ace18d18784a026a7c1c0466da264828b8227 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Mon, 9 Mar 2015 07:09:43 +0100 Subject: fixed #738 --- blocks.js | 13 ++++++++++--- history.txt | 4 ++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/blocks.js b/blocks.js index c519703..d82d788 100644 --- a/blocks.js +++ b/blocks.js @@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2015-March-06'; +modules.blocks = '2015-March-09'; var SyntaxElementMorph; @@ -400,10 +400,14 @@ SyntaxElementMorph.prototype.debugCachedInputs = function () { } for (i = 0; i < realInputs.length; i += 1) { if (this.cachedInputs[i] !== realInputs[i]) { - throw new Error('cached input does not match ' + + throw new Error('cached input does not match: ' + this.constructor.name + + ' #' + + i + ' ' + - i); + this.cachedInputs[i].constructor.name + + ' != ' + + realInputs[i].constructor.name); } } }; @@ -3059,6 +3063,9 @@ BlockMorph.prototype.fullCopy = function () { ans.setSpec(this.instantiationSpec); } ans.allChildren().filter(function (block) { + if (block instanceof SyntaxElementMorph) { + block.cachedInputs = null; + } return !isNil(block.comment); }).forEach(function (block) { var cmnt = block.comment.fullCopy(); diff --git a/history.txt b/history.txt index d042af4..8265210 100755 --- a/history.txt +++ b/history.txt @@ -2466,3 +2466,7 @@ ______ 150306 ------ * Blocks: fixed #736 + +150309 +------ +* Blocks: fixed #738 -- cgit v1.3.1 From 31ea6f603085827ba95f20f55faca3e4fa85365e Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Mon, 9 Mar 2015 07:39:51 +0100 Subject: Only enable input caching for blocks --- blocks.js | 11 ++--------- gui.js | 8 ++++---- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/blocks.js b/blocks.js index d82d788..aef09da 100644 --- a/blocks.js +++ b/blocks.js @@ -340,7 +340,7 @@ SyntaxElementMorph.prototype.setScale = function (num) { }; SyntaxElementMorph.prototype.setScale(1); -SyntaxElementMorph.prototype.isCachingInputs = true; +SyntaxElementMorph.prototype.isCachingInputs = false; // SyntaxElementMorph instance creation: @@ -1943,6 +1943,7 @@ BlockMorph.uber = SyntaxElementMorph.prototype; // BlockMorph preferences settings: +BlockMorph.prototype.isCachingInputs = true; BlockMorph.prototype.zebraContrast = 40; // alternating color brightness // BlockMorph sound feedback: @@ -9228,10 +9229,6 @@ MultiArgMorph.prototype = new ArgMorph(); MultiArgMorph.prototype.constructor = MultiArgMorph; MultiArgMorph.uber = ArgMorph.prototype; -// MultiArgMorph preferences settings - -MultiArgMorph.prototype.isCachingInputs = false; - // MultiArgMorph instance creation: function MultiArgMorph( @@ -9662,10 +9659,6 @@ ArgLabelMorph.prototype = new ArgMorph(); ArgLabelMorph.prototype.constructor = ArgLabelMorph; ArgLabelMorph.uber = ArgMorph.prototype; -// ArgLabelMorph preferences settings - -ArgLabelMorph.prototype.isCachingInputs = false; - // MultiArgMorph instance creation: function ArgLabelMorph(argMorph, labelTxt) { diff --git a/gui.js b/gui.js index 75220b3..b103ccc 100644 --- a/gui.js +++ b/gui.js @@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2015-February-28'; +modules.gui = '2015-March-09'; // Declarations @@ -2269,10 +2269,10 @@ IDE_Morph.prototype.settingsMenu = function () { addPreference( 'Cache Inputs', function () { - SyntaxElementMorph.prototype.isCachingInputs = - !SyntaxElementMorph.prototype.isCachingInputs; + BlockMorph.prototype.isCachingInputs = + !BlockMorph.prototype.isCachingInputs; }, - SyntaxElementMorph.prototype.isCachingInputs, + BlockMorph.prototype.isCachingInputs, 'uncheck to stop caching\ninputs (for debugging the evaluator)', 'check to cache inputs\nboosts recursion', true -- cgit v1.3.1 From 7f9fe78c56dbe26ccdcd8f6fd33cbb9766add474 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Sun, 15 Mar 2015 14:55:37 +0100 Subject: fixed #743 --- history.txt | 5 +++++ store.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/history.txt b/history.txt index 8265210..1a430fb 100755 --- a/history.txt +++ b/history.txt @@ -2470,3 +2470,8 @@ ______ 150309 ------ * Blocks: fixed #738 +* GUI, Blocks: Only enable input caching for blocks + +150315 +------ +* Store: fixed #743 diff --git a/store.js b/store.js index b17fb49..d4a2b64 100644 --- a/store.js +++ b/store.js @@ -61,7 +61,7 @@ SyntaxElementMorph, Variable*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2015-February-28'; +modules.store = '2015-March-15'; // XML_Serializer /////////////////////////////////////////////////////// @@ -782,7 +782,7 @@ SnapSerializer.prototype.loadCustomBlocks = function ( names = definition.parseSpec(definition.spec).filter( function (str) { - return str.charAt(0) === '%'; + return str.charAt(0) === '%' && str.length > 1; } ).map(function (str) { return str.substr(1); -- cgit v1.3.1 From fdd2ecf7d91d8026d3ca42c4bd52774877c72645 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Sun, 15 Mar 2015 15:01:25 +0100 Subject: switch from beta to release candidate --- gui.js | 4 ++-- history.txt | 1 + snap.html | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gui.js b/gui.js index b103ccc..50f3cb2 100644 --- a/gui.js +++ b/gui.js @@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2015-March-09'; +modules.gui = '2015-March-15'; // 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--- beta ---\n\n' + aboutTxt = 'Snap! 4.0\nBuild Your Own Blocks\n\n--- rc ---\n\n' + 'Copyright \u24B8 2015 Jens M\u00F6nig and ' + 'Brian Harvey\n' + 'jens@moenig.org, bh@cs.berkeley.edu\n\n' diff --git a/history.txt b/history.txt index 1a430fb..b53e59c 100755 --- a/history.txt +++ b/history.txt @@ -2475,3 +2475,4 @@ ______ 150315 ------ * Store: fixed #743 +* GUI, html: switch from beta to release candidate diff --git a/snap.html b/snap.html index 93b4c73..976bcd6 100755 --- a/snap.html +++ b/snap.html @@ -2,7 +2,7 @@ - Snap! Build Your Own Blocks. Beta + Snap! Build Your Own Blocks -- 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(-) 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(-) 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(-) 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(-) 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 34187eb69e99b87158fe21a94a810085227b88cb Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Mon, 23 Mar 2015 13:56:05 +0100 Subject: fix (part of) "show variable" primitive for inheritance --- threads.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/threads.js b/threads.js index 82f7ab0..0511c53 100644 --- a/threads.js +++ b/threads.js @@ -1216,7 +1216,7 @@ Process.prototype.doShowVar = function (varName) { } // if no watcher exists, create a new one isGlobal = contains( - this.homeContext.receiver.variables.parentFrame.names(), + this.homeContext.receiver.globalVariables().names(), varName ); if (isGlobal || target.owner) { -- 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(-) 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 5bf3820ce190d2334187681fb384421c594f52ac Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Wed, 25 Mar 2015 14:03:06 +0100 Subject: fixed #752 and #745 --- history.txt | 4 ++++ threads.js | 21 +++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/history.txt b/history.txt index b53e59c..e30cb00 100755 --- a/history.txt +++ b/history.txt @@ -2476,3 +2476,7 @@ ______ ------ * Store: fixed #743 * GUI, html: switch from beta to release candidate + +150325 +------ +* Threads: fixed #752 diff --git a/threads.js b/threads.js index 50af8dd..7100aa6 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2015-February-28'; +modules.threads = '2015-March-25'; var ThreadManager; var Process; @@ -1153,13 +1153,16 @@ Process.prototype.doDeclareVariables = function (varNames) { Process.prototype.doSetVar = function (varName, value) { var varFrame = this.context.variables, name = varName; - if (name instanceof Context) { if (name.expression.selector === 'reportGetVar') { - name = name.expression.blockSpec; + name.variables.setVar( + name.expression.blockSpec, + value + ); + return; } } - varFrame.setVar(name, value); + varFrame.setVar(name, value, this.blockReceiver()); }; Process.prototype.doChangeVar = function (varName, value) { @@ -1168,10 +1171,14 @@ Process.prototype.doChangeVar = function (varName, value) { if (name instanceof Context) { if (name.expression.selector === 'reportGetVar') { - name = name.expression.blockSpec; + name.variables.changeVar( + name.expression.blockSpec, + value + ); + return; } } - varFrame.changeVar(name, value); + varFrame.changeVar(name, value, this.blockReceiver()); }; Process.prototype.reportGetVar = function () { @@ -1323,6 +1330,8 @@ Process.prototype.doDeleteFromList = function (index, list) { } if (this.inputOption(index) === 'last') { idx = list.length(); + } else if (isNaN(+this.inputOption(index))) { + return null; } list.remove(idx); }; -- cgit v1.3.1 From 303188f2d5c3280972d02060e8e0fdaf50b4310e Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Wed, 25 Mar 2015 14:05:34 +0100 Subject: OOP: integrated and adjusted fix for #752 and #745 --- history.txt | 5 +++++ threads.js | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/history.txt b/history.txt index fda02a3..8a2066d 100755 --- a/history.txt +++ b/history.txt @@ -2488,3 +2488,8 @@ ______ 150323 ------ * OOP: Morphic, Objects, Store - tweak inherited variable watcher slider deserialization + +150325 +------ +* Threads: fixed #752 +* OOP: integrated and adjusted fix for #752 diff --git a/threads.js b/threads.js index 0511c53..52f464d 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2015-March-23'; +modules.threads = '2015-March-25'; var ThreadManager; var Process; @@ -1153,10 +1153,14 @@ Process.prototype.doDeclareVariables = function (varNames) { Process.prototype.doSetVar = function (varName, value) { var varFrame = this.context.variables, name = varName; - if (name instanceof Context) { if (name.expression.selector === 'reportGetVar') { - name = name.expression.blockSpec; + name.variables.setVar( + name.expression.blockSpec, + value, + this.blockReceiver() + ); + return; } } varFrame.setVar(name, value, this.blockReceiver()); @@ -1168,7 +1172,12 @@ Process.prototype.doChangeVar = function (varName, value) { if (name instanceof Context) { if (name.expression.selector === 'reportGetVar') { - name = name.expression.blockSpec; + name.variables.changeVar( + name.expression.blockSpec, + value, + this.blockReceiver() + ); + return; } } varFrame.changeVar(name, value, this.blockReceiver()); @@ -1340,6 +1349,8 @@ Process.prototype.doDeleteFromList = function (index, list) { } if (this.inputOption(index) === 'last') { idx = list.length(); + } else if (isNaN(+this.inputOption(index))) { + return null; } list.remove(idx); }; -- cgit v1.3.1 From 30caffbf02a54f73697f8f62e3e3f31f3a55db2f Mon Sep 17 00:00:00 2001 From: Bernat Romagosa Date: Fri, 10 Apr 2015 13:18:03 +0200 Subject: new parameters to allow embedding projects --- gui.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gui.js b/gui.js index 04481cc..4f3a9a6 100644 --- a/gui.js +++ b/gui.js @@ -364,8 +364,21 @@ IDE_Morph.prototype.openIn = function (world) { myself.shield.destroy(); myself.shield = null; msg.destroy(); - myself.toggleAppMode(true); - myself.runScripts(); + + if (dict.editMode) { + myself.toggleAppMode(false); + } else { + myself.toggleAppMode(true); + } + + if (!dict.noRun) { + myself.runScripts(); + } + + if (dict.hideControls) { + myself.controlBar.hide(); + window.onbeforeunload = function (evt) {}; + } } ]); }, -- cgit v1.3.1 From 7eb778a98e08e4c79a73ed41be6beafa1fda5788 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Wed, 15 Apr 2015 17:02:10 +0200 Subject: flush Stage>>keysPressed when prompting the user --- history.txt | 5 +++++ threads.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/history.txt b/history.txt index 8a2066d..ef96624 100755 --- a/history.txt +++ b/history.txt @@ -2493,3 +2493,8 @@ ______ ------ * Threads: fixed #752 * OOP: integrated and adjusted fix for #752 + +150415 +------ +* Threads: flush Stage>>keysPressed when prompting the user + diff --git a/threads.js b/threads.js index 52f464d..6ba0442 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2015-March-25'; +modules.threads = '2015-April-15'; var ThreadManager; var Process; @@ -1835,6 +1835,7 @@ Process.prototype.doAsk = function (data) { isStage = this.blockReceiver() instanceof StageMorph, activePrompter; + stage.keysPressed = {}; if (!this.prompter) { activePrompter = detect( stage.children, -- cgit v1.3.1 From db01489a49631ffed9a3d2acefa8581ded8752ad Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Wed, 15 Apr 2015 17:03:36 +0200 Subject: flush Stage>>keysPressed when prompting the user --- history.txt | 4 ++++ threads.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/history.txt b/history.txt index e30cb00..9cdc5c9 100755 --- a/history.txt +++ b/history.txt @@ -2480,3 +2480,7 @@ ______ 150325 ------ * Threads: fixed #752 + +150415 +------ +* Threads: flush Stage>>keysPressed when prompting the user diff --git a/threads.js b/threads.js index 7100aa6..dfd89e7 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2015-March-25'; +modules.threads = '2015-April-15'; var ThreadManager; var Process; @@ -1816,6 +1816,7 @@ Process.prototype.doAsk = function (data) { isStage = this.blockReceiver() instanceof StageMorph, activePrompter; + stage.keysPressed = {}; if (!this.prompter) { activePrompter = detect( stage.children, -- 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(-) 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(-) 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(-) 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 9385e4b57c88c382c1758e54c258ac237d238679 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Sun, 26 Apr 2015 22:47:37 -0400 Subject: fixed #784 --- history.txt | 4 ++++ store.js | 78 ++++++++++++++++++++++++++++++++++--------------------------- 2 files changed, 47 insertions(+), 35 deletions(-) diff --git a/history.txt b/history.txt index 0efef9b..6c1a637 100755 --- a/history.txt +++ b/history.txt @@ -2485,3 +2485,7 @@ ______ ------ * Threads: flush Stage>>keysPressed when prompting the user * Objects: fixed #770 + +150426 +------ +* Store: fixed #784 diff --git a/store.js b/store.js index d4a2b64..5cba3c3 100644 --- a/store.js +++ b/store.js @@ -61,7 +61,7 @@ SyntaxElementMorph, Variable*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2015-March-15'; +modules.store = '2015-April-26'; // XML_Serializer /////////////////////////////////////////////////////// @@ -491,7 +491,7 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) { /* Watchers */ model.sprites.childrenNamed('watcher').forEach(function (model) { - var watcher, color, target, hidden, extX, extY; + var watcher, color, target, hidden, extX, extY, vFrame; color = myself.loadColor(model.attributes.color); target = Object.prototype.hasOwnProperty.call( @@ -512,14 +512,20 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) { model.attributes, 'var' )) { - watcher = new WatcherMorph( - model.attributes['var'], - color, - isNil(target) ? project.globalVariables - : target.variables, - model.attributes['var'], - hidden - ); + vFrame = isNil(target) ? project.globalVariables + : target.variables; + if (Object.prototype.hasOwnProperty.call( + vFrame.vars, + model.attributes['var'] + )) { + watcher = new WatcherMorph( + model.attributes['var'], + color, + vFrame, + model.attributes['var'], + hidden + ); + } } else { watcher = new WatcherMorph( localize(myself.watcherLabels[model.attributes.s]), @@ -529,33 +535,35 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) { hidden ); } - watcher.setStyle(model.attributes.style || 'normal'); - if (watcher.style === 'slider') { - watcher.setSliderMin(model.attributes.min || '1'); - watcher.setSliderMax(model.attributes.max || '100'); - } - watcher.setPosition( - project.stage.topLeft().add(new Point( - +model.attributes.x || 0, - +model.attributes.y || 0 - )) - ); - project.stage.add(watcher); - watcher.onNextStep = function () {this.currentValue = null; }; - - // set watcher's contentsMorph's extent if it is showing a list and - // its monitor dimensions are given - if (watcher.currentValue instanceof List) { - extX = model.attributes.extX; - if (extX) { - watcher.cellMorph.contentsMorph.setWidth(+extX); + if (watcher) { + watcher.setStyle(model.attributes.style || 'normal'); + if (watcher.style === 'slider') { + watcher.setSliderMin(model.attributes.min || '1'); + watcher.setSliderMax(model.attributes.max || '100'); } - extY = model.attributes.extY; - if (extY) { - watcher.cellMorph.contentsMorph.setHeight(+extY); + watcher.setPosition( + project.stage.topLeft().add(new Point( + +model.attributes.x || 0, + +model.attributes.y || 0 + )) + ); + project.stage.add(watcher); + watcher.onNextStep = function () {this.currentValue = null; }; + + // set watcher's contentsMorph's extent if it is showing a list + // and if its monitor dimensions are given + if (watcher.currentValue instanceof List) { + extX = model.attributes.extX; + if (extX) { + watcher.cellMorph.contentsMorph.setWidth(+extX); + } + extY = model.attributes.extY; + if (extY) { + watcher.cellMorph.contentsMorph.setHeight(+extY); + } + // adjust my contentsMorph's handle position + watcher.cellMorph.contentsMorph.handle.drawNew(); } - // adjust my contentsMorph's handle position - watcher.cellMorph.contentsMorph.handle.drawNew(); } }); this.objects = {}; -- cgit v1.3.1 From 30e43a359e5ba1a7ec3c6ab331e8f9ec7e43ca7e Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 11:49:35 -0400 Subject: Morphic: Dynamic enhancements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit new event hooks for “reactToTemplateCopy”, first mouse click on editable text, and allow trigger hint to also be a function returning a dynamic help string rather than only a static string --- morphic.js | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/morphic.js b/morphic.js index 9616897..2850e32 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-May-01'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -5926,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') { @@ -5944,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') { @@ -5961,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') { @@ -5984,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(); }; @@ -7447,6 +7454,8 @@ StringMorph.prototype.mouseClickLeft = function (pos) { StringMorph.prototype.enableSelecting = function () { this.mouseDownLeft = function (pos) { + var crs = this.root().cursor, + already = crs ? crs.target === this : false; this.clearSelection(); if (this.isEditable && (!this.isDraggable)) { this.edit(); @@ -7454,6 +7463,7 @@ StringMorph.prototype.enableSelecting = function () { this.startMark = this.slotAt(pos); this.endMark = this.startMark; this.currentlySelecting = true; + if (!already) {this.escalateEvent('mouseDownLeft', pos); } } }; this.mouseMove = function (pos) { @@ -8060,7 +8070,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 +8219,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 +9694,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(); } -- cgit v1.3.1 From 340f91b7f2c46e0068562935c7277054d779e1bf Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 11:50:59 -0400 Subject: Morphic: event hook for first mouse click on editable text --- morphic.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/morphic.js b/morphic.js index c725209..2850e32 100644 --- a/morphic.js +++ b/morphic.js @@ -1048,7 +1048,7 @@ /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, FileList, getBlurredShadowSupport*/ -var morphicVersion = '2015-March-24'; +var morphicVersion = '2015-May-01'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -7454,6 +7454,8 @@ StringMorph.prototype.mouseClickLeft = function (pos) { StringMorph.prototype.enableSelecting = function () { this.mouseDownLeft = function (pos) { + var crs = this.root().cursor, + already = crs ? crs.target === this : false; this.clearSelection(); if (this.isEditable && (!this.isDraggable)) { this.edit(); @@ -7461,6 +7463,7 @@ StringMorph.prototype.enableSelecting = function () { this.startMark = this.slotAt(pos); this.endMark = this.startMark; this.currentlySelecting = true; + if (!already) {this.escalateEvent('mouseDownLeft', pos); } } }; this.mouseMove = function (pos) { -- cgit v1.3.1 From 585d1541b8ce45ba2be1367ab4ddac1b9a1095d6 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 11:53:42 -0400 Subject: select all text when first clicking an input slot --- blocks.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/blocks.js b/blocks.js index aef09da..8e428d0 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-May-01'; var SyntaxElementMorph; @@ -6987,6 +6987,15 @@ InputSlotMorph.prototype.fixLayout = function () { // InputSlotMorph events: +InputSlotMorph.prototype.mouseDownLeft = function (pos) { + if (this.isReadOnly || this.arrow().bounds.containsPoint(pos)) { + this.escalateEvent('mouseDownLeft', pos); + } else { + this.contents().edit(); + this.contents().selectAll(); + } +}; + InputSlotMorph.prototype.mouseClickLeft = function (pos) { if (this.arrow().bounds.containsPoint(pos)) { this.dropDownMenu(); -- cgit v1.3.1 From 4d5b9ca135233a23b556fd2f07e0ff6bd8a0bd74 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 11:55:33 -0400 Subject: select all text when first clicking an input slot --- blocks.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/blocks.js b/blocks.js index 45f1049..8049e59 100644 --- a/blocks.js +++ b/blocks.js @@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2015-March-23'; +modules.blocks = '2015-May-01'; var SyntaxElementMorph; @@ -7022,6 +7022,15 @@ InputSlotMorph.prototype.fixLayout = function () { // InputSlotMorph events: +InputSlotMorph.prototype.mouseDownLeft = function (pos) { + if (this.isReadOnly || this.arrow().bounds.containsPoint(pos)) { + this.escalateEvent('mouseDownLeft', pos); + } else { + this.contents().edit(); + this.contents().selectAll(); + } +}; + InputSlotMorph.prototype.mouseClickLeft = function (pos) { if (this.arrow().bounds.containsPoint(pos)) { this.dropDownMenu(); -- cgit v1.3.1 From c46d8093ef7c65958fd044a6b070df1f3ba84f51 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 11:56:42 -0400 Subject: indicate numeric inputs in the block prototype with the # sign --- byob.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/byob.js b/byob.js index c9f3daa..bc0f75f 100644 --- a/byob.js +++ b/byob.js @@ -106,7 +106,7 @@ SymbolMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2015-March-02'; +modules.byob = '2015-May-01'; // Declarations @@ -2049,7 +2049,13 @@ BlockLabelFragment.prototype.defTemplateSpecFragment = function () { )) { suff = ' \u03BB'; } else if (this.defaultValue) { - suff = ' = ' + this.defaultValue.toString(); + if (this.type === '%n') { + suff = ' # = ' + this.defaultValue.toString(); + } else { // 'any' or 'text' + suff = ' = ' + this.defaultValue.toString(); + } + } else if (this.type === '%n') { + suff = ' #'; } return this.labelString + suff; }; -- cgit v1.3.1 From 86e4170a571455d3f828fd2b1161313b3126beef Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 11:57:12 -0400 Subject: indicate numeric inputs in the block prototype with the # sign --- byob.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/byob.js b/byob.js index c9f3daa..bc0f75f 100644 --- a/byob.js +++ b/byob.js @@ -106,7 +106,7 @@ SymbolMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2015-March-02'; +modules.byob = '2015-May-01'; // Declarations @@ -2049,7 +2049,13 @@ BlockLabelFragment.prototype.defTemplateSpecFragment = function () { )) { suff = ' \u03BB'; } else if (this.defaultValue) { - suff = ' = ' + this.defaultValue.toString(); + if (this.type === '%n') { + suff = ' # = ' + this.defaultValue.toString(); + } else { // 'any' or 'text' + suff = ' = ' + this.defaultValue.toString(); + } + } else if (this.type === '%n') { + suff = ' #'; } return this.labelString + suff; }; -- cgit v1.3.1 From b6efcaf17c0230d5eea3f3d8a6d30e142c8d67cf Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 11:59:17 -0400 Subject: return empty string when querying first letter of a list --- threads.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/threads.js b/threads.js index dfd89e7..165ad0e 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2015-April-15'; +modules.threads = '2015-May-01'; var ThreadManager; var Process; @@ -2185,6 +2185,9 @@ Process.prototype.reportJoinWords = function (aList) { // Process string ops Process.prototype.reportLetter = function (idx, string) { + if (string instanceof List) { // catch a common user error + return ''; + } var i = +(idx || 0), str = (string || '').toString(); return str[i - 1] || ''; -- cgit v1.3.1 From d96a5984e64cdd2e8c4abcd0abaabaadf7cc1c02 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 11:59:51 -0400 Subject: return empty string when querying first letter of a list --- threads.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/threads.js b/threads.js index 6ba0442..47d5616 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2015-April-15'; +modules.threads = '2015-May-01'; var ThreadManager; var Process; @@ -2204,6 +2204,9 @@ Process.prototype.reportJoinWords = function (aList) { // Process string ops Process.prototype.reportLetter = function (idx, string) { + if (string instanceof List) { // catch a common user error + return ''; + } var i = +(idx || 0), str = (string || '').toString(); return str[i - 1] || ''; -- cgit v1.3.1 From 052a3e07b31d59a88343faa55001314ad058820e Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 12:00:56 -0400 Subject: hide “save to disk” option behind shift-click again (has issues in Chrome) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gui.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gui.js b/gui.js index 50f3cb2..f8c218c 100644 --- a/gui.js +++ b/gui.js @@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2015-March-15'; +modules.gui = '2015-May-01'; // Declarations @@ -2384,12 +2384,15 @@ IDE_Morph.prototype.projectMenu = function () { menu.addItem('New', 'createNewProject'); menu.addItem('Open...', 'openProjectsBrowser'); menu.addItem('Save', "save"); - menu.addItem( - 'Save to disk', - 'saveProjectToDisk', - 'store this project\nin the downloads folder\n' - + '(in supporting browsers)' - ); + if (shiftClicked) { + menu.addItem( + 'Save to disk', + 'saveProjectToDisk', + 'store this project\nin the downloads folder\n' + + '(in supporting browsers)', + new Color(100, 0, 0) + ); + } menu.addItem('Save As...', 'saveProjectsBrowser'); menu.addLine(); menu.addItem( -- cgit v1.3.1 From 1f9d5d384d73432c42e711eb05bb2ff9a31e9b34 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 12:01:51 -0400 Subject: hide “save to disk” option behind shift-click again (has issues in Chrome) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gui.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gui.js b/gui.js index 4cd2a9b..69b4a9d 100644 --- a/gui.js +++ b/gui.js @@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2015-March-21'; +modules.gui = '2015-May-01'; // Declarations @@ -2384,12 +2384,15 @@ IDE_Morph.prototype.projectMenu = function () { menu.addItem('New', 'createNewProject'); menu.addItem('Open...', 'openProjectsBrowser'); menu.addItem('Save', "save"); - menu.addItem( - 'Save to disk', - 'saveProjectToDisk', - 'store this project\nin the downloads folder\n' - + '(in supporting browsers)' - ); + if (shiftClicked) { + menu.addItem( + 'Save to disk', + 'saveProjectToDisk', + 'store this project\nin the downloads folder\n' + + '(in supporting browsers)', + new Color(100, 0, 0) + ); + } menu.addItem('Save As...', 'saveProjectsBrowser'); menu.addLine(); menu.addItem( -- cgit v1.3.1 From 4cd3488e60f61bbe6650fed3bf17591258cc38a8 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 12:11:07 -0400 Subject: formatting tweaks for JSLint’s benefit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gui.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gui.js b/gui.js index 594a682..4554f5f 100644 --- a/gui.js +++ b/gui.js @@ -386,9 +386,9 @@ IDE_Morph.prototype.openIn = function (world) { msg.destroy(); if (dict.editMode) { - myself.toggleAppMode(false); + myself.toggleAppMode(false); } else { - myself.toggleAppMode(true); + myself.toggleAppMode(true); } if (!dict.noRun) { @@ -397,7 +397,7 @@ IDE_Morph.prototype.openIn = function (world) { if (dict.hideControls) { myself.controlBar.hide(); - window.onbeforeunload = function (evt) {}; + window.onbeforeunload = function () {nop(); }; } } ]); -- cgit v1.3.1 From 8fa2b2c1f2d1b8d0b71204a7fb4a8b783762ff1a Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 12:18:16 -0400 Subject: parameters for embedding projects Thanks, Bernat! --- gui.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gui.js b/gui.js index 69b4a9d..0d866b4 100644 --- a/gui.js +++ b/gui.js @@ -384,8 +384,21 @@ IDE_Morph.prototype.openIn = function (world) { myself.shield.destroy(); myself.shield = null; msg.destroy(); - myself.toggleAppMode(true); - myself.runScripts(); + + if (dict.editMode) { + myself.toggleAppMode(false); + } else { + myself.toggleAppMode(true); + } + + if (!dict.noRun) { + myself.runScripts(); + } + + if (dict.hideControls) { + myself.controlBar.hide(); + window.onbeforeunload = function () {nop(); }; + } } ]); }, -- cgit v1.3.1 From 8e92c65cae699004342092133b0a7f99a6f1ed5c Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 12:24:52 -0400 Subject: Release! --- gui.js | 2 +- history.txt | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gui.js b/gui.js index 4554f5f..e8394aa 100644 --- a/gui.js +++ b/gui.js @@ -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--- rc ---\n\n' + aboutTxt = 'Snap! 4.0\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' diff --git a/history.txt b/history.txt index 6c1a637..107e796 100755 --- a/history.txt +++ b/history.txt @@ -2489,3 +2489,11 @@ ______ 150426 ------ * Store: fixed #784 + +150501 +------ +* Morphic, Blocks: select all text when first clicking an input slot +* BYOB: indicate numeric inputs in the block prototype with the # sign +* Threads: return empty string when querying first letter of a list +* GUI: hide “save to disk” option behind shift-click again (has issues in Chrome) +* GUI: parameters for embedding projects in iFrames, thanks, Bernat! -- cgit v1.3.1 From 83628bc0aca42c078a96b0a6fbb2675cf6cae5c3 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Fri, 1 May 2015 12:25:31 -0400 Subject: update history --- history.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/history.txt b/history.txt index 938213e..7f60776 100755 --- a/history.txt +++ b/history.txt @@ -2502,3 +2502,11 @@ ______ 150415 ------ * OOP: Objects, Prototypal inheritance of sprite-local custom blocks (palette only) + +150501 +------ +* Morphic, Blocks: select all text when first clicking an input slot +* BYOB: indicate numeric inputs in the block prototype with the # sign +* Threads: return empty string when querying first letter of a list +* GUI: hide “save to disk” option behind shift-click again (has issues in Chrome) +* GUI: parameters for embedding projects in iFrames, thanks, Bernat! -- cgit v1.3.1 From 9d6eb9dd190bac4152ac7c5b0d17a7219b69c74c Mon Sep 17 00:00:00 2001 From: Manuel Menezes de Sequeira Date: Mon, 4 May 2015 12:27:16 +0100 Subject: Update portuguese translation to align with latest german version. --- lang-pt.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lang-pt.js b/lang-pt.js index 2d3804a..e9f309f 100755 --- a/lang-pt.js +++ b/lang-pt.js @@ -185,7 +185,7 @@ SnapTranslator.dict.pt = { 'translator_e-mail': 'mmsequeira@gmail.com', 'last_changed': - '2014-10-01', + '2015-05-04', // GUI // control bar: @@ -417,8 +417,18 @@ SnapTranslator.dict.pt = { 'Quando alguém clicar em %greenflag', 'when %keyHat key pressed': 'Quando alguém pressionar a tecla %keyHat', - 'when I am clicked': - 'Quando alguém clicar em ti', + 'when I am %interaction': + 'Quando o rato %interaction', + 'clicked': + 'clicar em ti', + 'pressed': + 'pressionar em ti', + 'dropped': + 'te largar', + 'mouse-entered': + 'entrar em ti', + 'mouse-departed': + 'sair de ti', 'when I receive %msgHat': 'Quando receberes a mensagem %msgHat', 'broadcast %msg': @@ -647,13 +657,17 @@ SnapTranslator.dict.pt = { 'Abrir um projecto…', 'Save': 'Guardar este projecto', + 'Save to disk': + 'Guardar no disco', + 'store this project\nin the downloads folder\n(in supporting browsers)': + 'Guardar este projecto\nna sua pasta de descargas\n' + + '(em navegadores que o suportem).', 'Save As...': 'Guardar este projecto como…', 'Import...': 'Importar…', 'file menu import hint': - 'Abrir um projecto exportado,\n' - + 'substitundo o projecto corrente, ou\n' + 'Abrir um projecto exportado,\nsubstitundo o projecto corrente, ou\n' + 'importar uma biblioteca de blocos, um\n' + 'traje ou um som para o projecto corrente.', 'Export project as plain text...': @@ -1443,10 +1457,6 @@ SnapTranslator.dict.pt = { 'Suportar produção de código', 'check for block\nto text mapping features': 'Assinalar para funcionalidades\nde mapeamento entre blocos e texto.', - 'Save to disk': - 'Guardar no disco', - 'experimental - store this project\nin your downloads folder': - 'Experimental - Guardar este projecto\nna sua pasta de descargas.', 'saved.': 'guardado.', 'options...': -- cgit v1.3.1 From 1bc6fc0b617c12de6a819ae0c2179477c2b61461 Mon Sep 17 00:00:00 2001 From: Manuel Menezes de Sequeira Date: Mon, 4 May 2015 12:32:09 +0100 Subject: Update last_changed field for Portuguese localization --- locale.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locale.js b/locale.js index f6059d6..85e8de9 100644 --- a/locale.js +++ b/locale.js @@ -209,7 +209,7 @@ SnapTranslator.dict.pt = { 'translator_e-mail': 'mmsequeira@gmail.com', 'last_changed': - '2014-10-01' + '2015-05-04' }; SnapTranslator.dict.cs = { -- 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(-) 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: Thu, 21 May 2015 20:19:22 +0200 Subject: Fix encoding for exported libraries of global blocks --- byob.js | 6 ++++-- history.txt | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/byob.js b/byob.js index bc0f75f..86b6b4b 100644 --- a/byob.js +++ b/byob.js @@ -106,7 +106,7 @@ SymbolMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2015-May-01'; +modules.byob = '2015-May-21'; // Declarations @@ -3297,7 +3297,9 @@ BlockExportDialogMorph.prototype.selectNone = function () { // BlockExportDialogMorph ops BlockExportDialogMorph.prototype.exportBlocks = function () { - var str = this.serializer.serialize(this.blocks); + var str = encodeURIComponent( + this.serializer.serialize(this.blocks) + ); if (this.blocks.length > 0) { window.open(encodeURI('data:text/xml,' + str - + '')); + + ''); } else { new DialogBoxMorph().inform( 'Export blocks', diff --git a/history.txt b/history.txt index 8e6a8fc..29c56e5 100755 --- a/history.txt +++ b/history.txt @@ -2508,3 +2508,7 @@ ______ 150521 ------ * BYOB: Fix encoding for exported libraries of global blocks + +150523 +------ +* BYOB: Fix encoding glitch -- cgit v1.3.1 From df05d92ab9cf052b2312a8aebb7ccf69d39e8174 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Sat, 23 May 2015 00:37:11 +0200 Subject: fix block library export encoding glitch --- byob.js | 6 +++--- history.txt | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/byob.js b/byob.js index 86b6b4b..1c2cfee 100644 --- a/byob.js +++ b/byob.js @@ -106,7 +106,7 @@ SymbolMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2015-May-21'; +modules.byob = '2015-May-23'; // Declarations @@ -3301,13 +3301,13 @@ BlockExportDialogMorph.prototype.exportBlocks = function () { this.serializer.serialize(this.blocks) ); if (this.blocks.length > 0) { - window.open(encodeURI('data:text/xml,' + str - + '')); + + ''); } else { new DialogBoxMorph().inform( 'Export blocks', diff --git a/history.txt b/history.txt index 62d267d..adaf659 100755 --- a/history.txt +++ b/history.txt @@ -2518,3 +2518,7 @@ ______ 150521 ------ * BYOB: Fix encoding for exported libraries of global blocks + +150521 +------ +* BYOB: Fix encoding glitch -- cgit v1.3.1 From 2cbba6c762fc664bd4d4d0733c89192982d135d2 Mon Sep 17 00:00:00 2001 From: Brian Broll Date: Sat, 23 May 2015 17:09:45 -0500 Subject: Fixed #809 --- gui.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui.js b/gui.js index 026a12c..02d6b7c 100644 --- a/gui.js +++ b/gui.js @@ -4733,8 +4733,8 @@ ProjectDialogMorph.prototype.getExamplesProjectList = function () { } } ); - projects.sort(function (x, y) { - return x.name < y.name ? -1 : 1; + projects = projects.sort(function (x, y) { + return x.name.toLowerCase() < y.name.toLowerCase() ? -1 : 1; }); return projects; }; -- cgit v1.3.1 From 1cb12813352309914de12261aff449c5e398ffdb Mon Sep 17 00:00:00 2001 From: Brian Harvey Date: Tue, 26 May 2015 22:48:00 -0700 Subject: Finally creating the missing help screens. --- help/createClone.png | Bin 0 -> 187161 bytes help/doCallCC.png | Bin 0 -> 130086 bytes help/doPauseAll.png | Bin 0 -> 142103 bytes help/doSetFastTracking.png | Bin 0 -> 180730 bytes help/doStopOthers.png | Bin 0 -> 146270 bytes help/doStopThis.png | Bin 0 -> 171046 bytes help/getLastMessage.png | Bin 0 -> 84422 bytes help/receiveInteraction.png | Bin 49453 -> 113207 bytes help/receiveOnClone.png | Bin 0 -> 148344 bytes help/removeClone.png | Bin 0 -> 152507 bytes help/reportAttributeOf.png | Bin 0 -> 151943 bytes help/reportCallCC.png | Bin 0 -> 127777 bytes help/reportDate.png | Bin 0 -> 160002 bytes help/reportIsFastTracking.png | Bin 0 -> 180193 bytes help/reportJSFunction.png | Bin 0 -> 135342 bytes help/reportTextSplit.png | Bin 0 -> 211050 bytes help/reportURL.png | Bin 0 -> 154595 bytes 17 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 help/createClone.png create mode 100644 help/doCallCC.png create mode 100644 help/doPauseAll.png create mode 100644 help/doSetFastTracking.png create mode 100644 help/doStopOthers.png create mode 100644 help/doStopThis.png create mode 100644 help/getLastMessage.png create mode 100644 help/receiveOnClone.png create mode 100644 help/removeClone.png create mode 100644 help/reportAttributeOf.png create mode 100644 help/reportCallCC.png create mode 100644 help/reportDate.png create mode 100644 help/reportIsFastTracking.png create mode 100644 help/reportJSFunction.png create mode 100644 help/reportTextSplit.png create mode 100644 help/reportURL.png diff --git a/help/createClone.png b/help/createClone.png new file mode 100644 index 0000000..b00e867 Binary files /dev/null and b/help/createClone.png differ diff --git a/help/doCallCC.png b/help/doCallCC.png new file mode 100644 index 0000000..d286ad4 Binary files /dev/null and b/help/doCallCC.png differ diff --git a/help/doPauseAll.png b/help/doPauseAll.png new file mode 100644 index 0000000..975fa73 Binary files /dev/null and b/help/doPauseAll.png differ diff --git a/help/doSetFastTracking.png b/help/doSetFastTracking.png new file mode 100644 index 0000000..7ee62a9 Binary files /dev/null and b/help/doSetFastTracking.png differ diff --git a/help/doStopOthers.png b/help/doStopOthers.png new file mode 100644 index 0000000..ccb8850 Binary files /dev/null and b/help/doStopOthers.png differ diff --git a/help/doStopThis.png b/help/doStopThis.png new file mode 100644 index 0000000..cc072ac Binary files /dev/null and b/help/doStopThis.png differ diff --git a/help/getLastMessage.png b/help/getLastMessage.png new file mode 100644 index 0000000..4484652 Binary files /dev/null and b/help/getLastMessage.png differ diff --git a/help/receiveInteraction.png b/help/receiveInteraction.png index 6ace2e3..76b0715 100644 Binary files a/help/receiveInteraction.png and b/help/receiveInteraction.png differ diff --git a/help/receiveOnClone.png b/help/receiveOnClone.png new file mode 100644 index 0000000..19cdf78 Binary files /dev/null and b/help/receiveOnClone.png differ diff --git a/help/removeClone.png b/help/removeClone.png new file mode 100644 index 0000000..3afc24a Binary files /dev/null and b/help/removeClone.png differ diff --git a/help/reportAttributeOf.png b/help/reportAttributeOf.png new file mode 100644 index 0000000..ab4aff8 Binary files /dev/null and b/help/reportAttributeOf.png differ diff --git a/help/reportCallCC.png b/help/reportCallCC.png new file mode 100644 index 0000000..8c911c6 Binary files /dev/null and b/help/reportCallCC.png differ diff --git a/help/reportDate.png b/help/reportDate.png new file mode 100644 index 0000000..16e67cd Binary files /dev/null and b/help/reportDate.png differ diff --git a/help/reportIsFastTracking.png b/help/reportIsFastTracking.png new file mode 100644 index 0000000..2929a79 Binary files /dev/null and b/help/reportIsFastTracking.png differ diff --git a/help/reportJSFunction.png b/help/reportJSFunction.png new file mode 100644 index 0000000..ecb2f0c Binary files /dev/null and b/help/reportJSFunction.png differ diff --git a/help/reportTextSplit.png b/help/reportTextSplit.png new file mode 100644 index 0000000..18d1422 Binary files /dev/null and b/help/reportTextSplit.png differ diff --git a/help/reportURL.png b/help/reportURL.png new file mode 100644 index 0000000..e7c24c5 Binary files /dev/null and b/help/reportURL.png differ -- cgit v1.3.1 From 1b2e0aded404f23bfe8d47edf3053ccb24011e92 Mon Sep 17 00:00:00 2001 From: Théo Segonds Date: Sun, 7 Jun 2015 16:52:48 +0200 Subject: Remove hardcoded URLs in gui.js. This fix #814 --- gui.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/gui.js b/gui.js index 026a12c..00d1cc3 100644 --- a/gui.js +++ b/gui.js @@ -82,6 +82,11 @@ var WardrobeMorph; var SoundIconMorph; var JukeboxMorph; +// Get the full url without "snap.html" +var baseUrl = document.URL.split('/'); +baseUrl.pop(baseUrl.length-1); +baseUrl = baseUrl.join('/')+'/'; + // IDE_Morph /////////////////////////////////////////////////////////// // I am SNAP's top-level frame, the Editor window @@ -2491,13 +2496,10 @@ IDE_Morph.prototype.projectMenu = function () { function () { // read a list of libraries from an external file, var libMenu = new MenuMorph(this, 'Import library'), - libUrl = 'http://snap.berkeley.edu/snapsource/libraries/' + - 'LIBRARIES'; + libUrl = baseUrl + 'libraries/' + 'LIBRARIES'; function loadLib(name) { - var url = 'http://snap.berkeley.edu/snapsource/libraries/' - + name - + '.xml'; + var url = baseUrl + 'libraries/' + name + '.xml'; myself.droppedText(myself.getURL(url), name); } @@ -4216,8 +4218,7 @@ IDE_Morph.prototype.getURLsbeOrRelative = function (url) { var request = new XMLHttpRequest(), myself = this; try { - request.open('GET', 'http://snap.berkeley.edu/snapsource/' + - url, false); + request.open('GET', baseUrl + url, false); request.send(); if (request.status === 200) { return request.responseText; @@ -4658,8 +4659,7 @@ ProjectDialogMorph.prototype.setSource = function (source) { myself.nameField.setContents(item.name || ''); } src = myself.ide.getURL( - 'http://snap.berkeley.edu/snapsource/Examples/' + - item.name + '.xml' + baseUrl + 'Examples/' + item.name + '.xml' ); xml = myself.ide.serializer.parse(src); @@ -4713,8 +4713,9 @@ ProjectDialogMorph.prototype.getLocalProjectList = function () { ProjectDialogMorph.prototype.getExamplesProjectList = function () { var dir, projects = []; + //alert(baseUrl); - dir = this.ide.getURL('http://snap.berkeley.edu/snapsource/Examples/'); + dir = this.ide.getURL(baseUrl + 'Examples/'); dir.split('\n').forEach( function (line) { var startIdx = line.search(new RegExp('href=".*xml"')), @@ -4833,9 +4834,7 @@ ProjectDialogMorph.prototype.openProject = function () { if (this.source === 'cloud') { this.openCloudProject(proj); } else if (this.source === 'examples') { - src = this.ide.getURL( - 'http://snap.berkeley.edu/snapsource/Examples/' + - proj.name + '.xml' + src = this.ide.getURL(baseUrl + 'Examples/' + proj.name + '.xml' ); this.ide.openProjectString(src); this.destroy(); -- cgit v1.3.1 From 14a5f87402fde84d332e5e9b6e44c3f3b9cf1421 Mon Sep 17 00:00:00 2001 From: Théo Segonds Date: Sun, 7 Jun 2015 17:05:49 +0200 Subject: add a index.html file to redirect automaticly to snap.html --- index.html | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..4c1a0f4 --- /dev/null +++ b/index.html @@ -0,0 +1,7 @@ + + + + + + + -- cgit v1.3.1 From 03c4acd367dabe946f8091c7ad55f059ad919579 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Mon, 8 Jun 2015 15:40:59 +0200 Subject: fixed #820 --- blocks.js | 7 ++++++- history.txt | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/blocks.js b/blocks.js index 8e428d0..67324ca 100644 --- a/blocks.js +++ b/blocks.js @@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2015-May-01'; +modules.blocks = '2015-June-08'; var SyntaxElementMorph; @@ -3066,6 +3066,11 @@ BlockMorph.prototype.fullCopy = function () { ans.allChildren().filter(function (block) { if (block instanceof SyntaxElementMorph) { block.cachedInputs = null; + if (block instanceof InputSlotMorph) { + block.contents().clearSelection(); + } + } else if (block instanceof CursorMorph) { + block.destroy(); } return !isNil(block.comment); }).forEach(function (block) { diff --git a/history.txt b/history.txt index 29c56e5..1262a28 100755 --- a/history.txt +++ b/history.txt @@ -2512,3 +2512,7 @@ ______ 150523 ------ * BYOB: Fix encoding glitch + +150608 +------ +* Blocks: Fixed #820 -- cgit v1.3.1 From 44e4f5d94bc6e448beb46e5d688153c8203d6da8 Mon Sep 17 00:00:00 2001 From: Jens Mönig Date: Mon, 8 Jun 2015 15:46:22 +0200 Subject: fixed #820 --- blocks.js | 7 ++++++- history.txt | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/blocks.js b/blocks.js index 8049e59..27aae82 100644 --- a/blocks.js +++ b/blocks.js @@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2015-May-01'; +modules.blocks = '2015-June-08'; var SyntaxElementMorph; @@ -3082,6 +3082,11 @@ BlockMorph.prototype.fullCopy = function () { ans.allChildren().filter(function (block) { if (block instanceof SyntaxElementMorph) { block.cachedInputs = null; + if (block instanceof InputSlotMorph) { + block.contents().clearSelection(); + } + } else if (block instanceof CursorMorph) { + block.destroy(); } return !isNil(block.comment); }).forEach(function (block) { diff --git a/history.txt b/history.txt index adaf659..f9ea785 100755 --- a/history.txt +++ b/history.txt @@ -2522,3 +2522,7 @@ ______ 150521 ------ * BYOB: Fix encoding glitch + +150608 +------ +* Blocks: Fixed #820 -- cgit v1.3.1 From 26108539f5639061a66862ed066c8df8342a097c Mon Sep 17 00:00:00 2001 From: Bernat Romagosa Date: Tue, 9 Jun 2015 12:40:55 +0200 Subject: fixes #815 --- objects.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/objects.js b/objects.js index 8cae1c7..59341a8 100644 --- a/objects.js +++ b/objects.js @@ -3509,7 +3509,10 @@ SpriteMorph.prototype.allHatBlocksFor = function (message) { if (morph.selector) { if (morph.selector === 'receiveMessage') { event = morph.inputs()[0].evaluate(); - return event === message || (event instanceof Array); + return event === message + || (event instanceof Array + && message !== '__shout__go__' + && message !== '__clone__init__'); } if (morph.selector === 'receiveGo') { return message === '__shout__go__'; -- cgit v1.3.1 From e1704587aa6c435d6830ceba6f15b0ef09a7bf29 Mon Sep 17 00:00:00 2001 From: Brian Harvey Date: Wed, 10 Jun 2015 17:41:01 -0700 Subject: Speed up join words and list->sentence in tools.xml --- tools.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools.xml b/tools.xml index e05d7bb..5a7a963 100644 --- a/tools.xml +++ b/tools.xml @@ -1 +1 @@ -
1datamapmany1data lists
1
1
110i
1
cont
catchtag
cont
catchtag
\ No newline at end of file +
1datamapmany1data lists
1
1
110i
1
cont
catchtag
cont
catchtag
\ No newline at end of file -- cgit v1.3.1 From 3885ced35aee903f74d48c293bc3f0665a38dba5 Mon Sep 17 00:00:00 2001 From: Brian Harvey Date: Wed, 10 Jun 2015 18:02:55 -0700 Subject: Fix errors in two help screens. --- help/doStopOthers.png | Bin 146270 -> 141638 bytes help/reportDate.png | Bin 160002 -> 396763 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/help/doStopOthers.png b/help/doStopOthers.png index ccb8850..b90dff9 100644 Binary files a/help/doStopOthers.png and b/help/doStopOthers.png differ diff --git a/help/reportDate.png b/help/reportDate.png index 16e67cd..f13cf38 100644 Binary files a/help/reportDate.png and b/help/reportDate.png differ -- cgit v1.3.1 From e21a872b0dcbca2e7ea8311d9b54f709876d1848 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 15 Jun 2015 17:19:25 -0700 Subject: Implement log10 and 10^x math functions --- blocks.js | 6 +++--- threads.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/blocks.js b/blocks.js index 67324ca..1ef322c 100644 --- a/blocks.js +++ b/blocks.js @@ -1111,9 +1111,9 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { acos : ['acos'], atan : ['atan'], ln : ['ln'], - // log : 'log', - 'e^' : ['e^'] - // '10^' : '10^' + log : ['log'], + 'e^' : ['e^'], + '10^' : ['10^'] }, true ); diff --git a/threads.js b/threads.js index 165ad0e..61b5722 100644 --- a/threads.js +++ b/threads.js @@ -2122,14 +2122,14 @@ Process.prototype.reportMonadic = function (fname, n) { case 'ln': result = Math.log(x); break; - case 'log': - result = 0; + case 'log': // base 10 + result = Math.log(x) / Math.LN10; break; case 'e^': result = Math.exp(x); break; case '10^': - result = 0; + result = Math.pow(10, x); break; default: nop(); -- cgit v1.3.1 From 93d67ed386bba4862ac00eb55dcf664300ce53c7 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 15 Jun 2015 18:49:24 -0700 Subject: Fix Error Handing in the DATE block For some reason the function wasnt properly catching errors and was instead rasing native JS errors. This fixes that bug, so the function will now report nothing when it doesnt know what to do. In addition, moving the variable `dateMap` inside the function reduces a global variable, which shouldnt affect anything other than keeping the code clean. :) --- threads.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/threads.js b/threads.js index 165ad0e..efe9ba4 100644 --- a/threads.js +++ b/threads.js @@ -2640,26 +2640,26 @@ Process.prototype.reportTimer = function () { }; // Process Dates and times in Snap -// Map block options to built-in functions -var dateMap = { - 'year' : 'getFullYear', - 'month' : 'getMonth', - 'date': 'getDate', - 'day of week' : 'getDay', - 'hour' : 'getHours', - 'minute' : 'getMinutes', - 'second' : 'getSeconds', - 'time in milliseconds' : 'getTime' -}; - Process.prototype.reportDate = function (datefn) { var inputFn = this.inputOption(datefn), - currDate = new Date(), - func = dateMap[inputFn], - result = currDate[func](); + // Map block options to built-in functions + dateMap = { + 'year' : 'getFullYear', + 'month' : 'getMonth', + 'date': 'getDate', + 'day of week' : 'getDay', + 'hour' : 'getHours', + 'minute' : 'getMinutes', + 'second' : 'getSeconds', + 'time in milliseconds' : 'getTime' + }; if (!dateMap[inputFn]) { return ''; } + var currDate = new Date(), + func = dateMap[inputFn], + result = currDate[func](); + // Show months as 1-12 and days as 1-7 if (inputFn === 'month' || inputFn === 'day of week') { result += 1; -- cgit v1.3.1 From 87c2503571bd7f5e753bc16a05bd198fc58d7d7c Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 17:11:40 -0400 Subject: Use Object.create(…) instead of new …() for inheritance (faster) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blocks.js | 50 +++++++++++++++++++++++++------------------------- byob.js | 26 +++++++++++++------------- gui.js | 16 ++++++++-------- lists.js | 2 +- morphic.js | 58 +++++++++++++++++++++++++++++----------------------------- objects.js | 22 +++++++++++----------- paint.js | 6 +++--- store.js | 2 +- widgets.js | 16 ++++++++-------- xml.js | 2 +- 10 files changed, 100 insertions(+), 100 deletions(-) diff --git a/blocks.js b/blocks.js index 67324ca..3613dae 100644 --- a/blocks.js +++ b/blocks.js @@ -240,7 +240,7 @@ WorldMorph.prototype.customMorphs = function () { // SyntaxElementMorph inherits from Morph: -SyntaxElementMorph.prototype = new Morph(); +SyntaxElementMorph.prototype = Object.create(Morph.prototype); SyntaxElementMorph.prototype.constructor = SyntaxElementMorph; SyntaxElementMorph.uber = Morph.prototype; @@ -1937,7 +1937,7 @@ SyntaxElementMorph.prototype.endLayout = function () { // BlockMorph inherits from SyntaxElementMorph: -BlockMorph.prototype = new SyntaxElementMorph(); +BlockMorph.prototype = Object.create(SyntaxElementMorph.prototype); BlockMorph.prototype.constructor = BlockMorph; BlockMorph.uber = SyntaxElementMorph.prototype; @@ -3262,7 +3262,7 @@ BlockMorph.prototype.snap = function () { // CommandBlockMorph inherits from BlockMorph: -CommandBlockMorph.prototype = new BlockMorph(); +CommandBlockMorph.prototype = Object.create(BlockMorph.prototype); CommandBlockMorph.prototype.constructor = CommandBlockMorph; CommandBlockMorph.uber = BlockMorph.prototype; @@ -3942,7 +3942,7 @@ CommandBlockMorph.prototype.drawBottomRightEdge = function (context) { // HatBlockMorph inherits from CommandBlockMorph: -HatBlockMorph.prototype = new CommandBlockMorph(); +HatBlockMorph.prototype = Object.create(CommandBlockMorph.prototype); HatBlockMorph.prototype.constructor = HatBlockMorph; HatBlockMorph.uber = CommandBlockMorph.prototype; @@ -4120,7 +4120,7 @@ HatBlockMorph.prototype.drawTopLeftEdge = function (context) { // ReporterBlockMorph inherits from BlockMorph: -ReporterBlockMorph.prototype = new BlockMorph(); +ReporterBlockMorph.prototype = Object.create(BlockMorph.prototype); ReporterBlockMorph.prototype.constructor = ReporterBlockMorph; ReporterBlockMorph.uber = BlockMorph.prototype; @@ -4644,7 +4644,7 @@ ReporterBlockMorph.prototype.drawDiamond = function (context) { // RingMorph inherits from ReporterBlockMorph: -RingMorph.prototype = new ReporterBlockMorph(); +RingMorph.prototype = Object.create(ReporterBlockMorph.prototype); RingMorph.prototype.constructor = RingMorph; RingMorph.uber = ReporterBlockMorph.prototype; @@ -4781,7 +4781,7 @@ RingMorph.prototype.fixBlockColor = function (nearest, isForced) { // ScriptsMorph inherits from FrameMorph: -ScriptsMorph.prototype = new FrameMorph(); +ScriptsMorph.prototype = Object.create(FrameMorph.prototype); ScriptsMorph.prototype.constructor = ScriptsMorph; ScriptsMorph.uber = FrameMorph.prototype; @@ -5321,7 +5321,7 @@ ScriptsMorph.prototype.reactToDropOf = function (droppedMorph, hand) { // ArgMorph inherits from SyntaxElementMorph: -ArgMorph.prototype = new SyntaxElementMorph(); +ArgMorph.prototype = Object.create(SyntaxElementMorph.prototype); ArgMorph.prototype.constructor = ArgMorph; ArgMorph.uber = SyntaxElementMorph.prototype; @@ -5434,7 +5434,7 @@ ArgMorph.prototype.isEmptySlot = function () { // CommandSlotMorph inherits from ArgMorph: -CommandSlotMorph.prototype = new ArgMorph(); +CommandSlotMorph.prototype = Object.create(ArgMorph.prototype); CommandSlotMorph.prototype.constructor = CommandSlotMorph; CommandSlotMorph.uber = ArgMorph.prototype; @@ -5884,7 +5884,7 @@ CommandSlotMorph.prototype.drawEdges = function (context) { // RingCommandSlotMorph inherits from CommandSlotMorph: -RingCommandSlotMorph.prototype = new CommandSlotMorph(); +RingCommandSlotMorph.prototype = Object.create(CommandSlotMorph.prototype); RingCommandSlotMorph.prototype.constructor = RingCommandSlotMorph; RingCommandSlotMorph.uber = CommandSlotMorph.prototype; @@ -6040,7 +6040,7 @@ RingCommandSlotMorph.prototype.drawFlat = function (context) { // CSlotMorph inherits from CommandSlotMorph: -CSlotMorph.prototype = new CommandSlotMorph(); +CSlotMorph.prototype = Object.create(CommandSlotMorph.prototype); CSlotMorph.prototype.constructor = CSlotMorph; CSlotMorph.uber = CommandSlotMorph.prototype; @@ -6463,7 +6463,7 @@ CSlotMorph.prototype.drawBottomEdge = function (context) { // InputSlotMorph inherits from ArgMorph: -InputSlotMorph.prototype = new ArgMorph(); +InputSlotMorph.prototype = Object.create(ArgMorph.prototype); InputSlotMorph.prototype.constructor = InputSlotMorph; InputSlotMorph.uber = ArgMorph.prototype; @@ -7399,7 +7399,7 @@ InputSlotMorph.prototype.drawRoundBorder = function (context) { // TemplateSlotMorph inherits from ArgMorph: -TemplateSlotMorph.prototype = new ArgMorph(); +TemplateSlotMorph.prototype = Object.create(ArgMorph.prototype); TemplateSlotMorph.prototype.constructor = TemplateSlotMorph; TemplateSlotMorph.uber = ArgMorph.prototype; @@ -7503,7 +7503,7 @@ TemplateSlotMorph.prototype.drawRounded = ReporterBlockMorph // BooleanSlotMorph inherits from ArgMorph: -BooleanSlotMorph.prototype = new ArgMorph(); +BooleanSlotMorph.prototype = Object.create(ArgMorph.prototype); BooleanSlotMorph.prototype.constructor = BooleanSlotMorph; BooleanSlotMorph.uber = ArgMorph.prototype; @@ -7660,7 +7660,7 @@ BooleanSlotMorph.prototype.isEmptySlot = function () { // ArrowMorph inherits from Morph: -ArrowMorph.prototype = new Morph(); +ArrowMorph.prototype = Object.create(Morph.prototype); ArrowMorph.prototype.constructor = ArrowMorph; ArrowMorph.uber = Morph.prototype; @@ -7730,7 +7730,7 @@ ArrowMorph.prototype.drawNew = function () { // TextSlotMorph inherits from InputSlotMorph: -TextSlotMorph.prototype = new InputSlotMorph(); +TextSlotMorph.prototype = Object.create(InputSlotMorph.prototype); TextSlotMorph.prototype.constructor = TextSlotMorph; TextSlotMorph.uber = InputSlotMorph.prototype; @@ -7813,7 +7813,7 @@ TextSlotMorph.prototype.layoutChanged = function () { // SymbolMorph inherits from Morph: -SymbolMorph.prototype = new Morph(); +SymbolMorph.prototype = Object.create(Morph.prototype); SymbolMorph.prototype.constructor = SymbolMorph; SymbolMorph.uber = Morph.prototype; @@ -9106,7 +9106,7 @@ SymbolMorph.prototype.drawSymbolRobot = function (canvas, color) { // ColorSlotMorph inherits from ArgMorph: -ColorSlotMorph.prototype = new ArgMorph(); +ColorSlotMorph.prototype = Object.create(ArgMorph.prototype); ColorSlotMorph.prototype.constructor = ColorSlotMorph; ColorSlotMorph.uber = ArgMorph.prototype; @@ -9214,7 +9214,7 @@ ColorSlotMorph.prototype.drawRectBorder = // BlockHighlightMorph inherits from Morph: -BlockHighlightMorph.prototype = new Morph(); +BlockHighlightMorph.prototype = Object.create(Morph.prototype); BlockHighlightMorph.prototype.constructor = BlockHighlightMorph; BlockHighlightMorph.uber = Morph.prototype; @@ -9239,7 +9239,7 @@ function BlockHighlightMorph() { // MultiArgMorph inherits from ArgMorph: -MultiArgMorph.prototype = new ArgMorph(); +MultiArgMorph.prototype = Object.create(ArgMorph.prototype); MultiArgMorph.prototype.constructor = MultiArgMorph; MultiArgMorph.uber = ArgMorph.prototype; @@ -9669,7 +9669,7 @@ MultiArgMorph.prototype.isEmptySlot = function () { // ArgLabelMorph inherits from ArgMorph: -ArgLabelMorph.prototype = new ArgMorph(); +ArgLabelMorph.prototype = Object.create(ArgMorph.prototype); ArgLabelMorph.prototype.constructor = ArgLabelMorph; ArgLabelMorph.uber = ArgMorph.prototype; @@ -9799,7 +9799,7 @@ ArgLabelMorph.prototype.isEmptySlot = function () { // FunctionSlotMorph inherits from ArgMorph: -FunctionSlotMorph.prototype = new ArgMorph(); +FunctionSlotMorph.prototype = Object.create(ArgMorph.prototype); FunctionSlotMorph.prototype.constructor = FunctionSlotMorph; FunctionSlotMorph.uber = ArgMorph.prototype; @@ -10180,7 +10180,7 @@ FunctionSlotMorph.prototype.drawDiamond = function (context) { // ReporterSlotMorph inherits from FunctionSlotMorph: -ReporterSlotMorph.prototype = new FunctionSlotMorph(); +ReporterSlotMorph.prototype = Object.create(FunctionSlotMorph.prototype); ReporterSlotMorph.prototype.constructor = ReporterSlotMorph; ReporterSlotMorph.uber = FunctionSlotMorph.prototype; @@ -10263,7 +10263,7 @@ ReporterSlotMorph.prototype.fixLayout = function () { // ReporterSlotMorph inherits from FunctionSlotMorph: -RingReporterSlotMorph.prototype = new ReporterSlotMorph(); +RingReporterSlotMorph.prototype = Object.create(ReporterSlotMorph.prototype); RingReporterSlotMorph.prototype.constructor = RingReporterSlotMorph; RingReporterSlotMorph.uber = ReporterSlotMorph.prototype; @@ -10651,7 +10651,7 @@ RingReporterSlotMorph.prototype.drawDiamond = function (context) { // CommentMorph inherits from BoxMorph: -CommentMorph.prototype = new BoxMorph(); +CommentMorph.prototype = Object.create(BoxMorph.prototype); CommentMorph.prototype.constructor = CommentMorph; CommentMorph.uber = BoxMorph.prototype; diff --git a/byob.js b/byob.js index 1c2cfee..32d8969 100644 --- a/byob.js +++ b/byob.js @@ -379,7 +379,7 @@ CustomBlockDefinition.prototype.scriptsPicture = function () { // CustomCommandBlockMorph inherits from CommandBlockMorph: -CustomCommandBlockMorph.prototype = new CommandBlockMorph(); +CustomCommandBlockMorph.prototype = Object.create(CommandBlockMorph.prototype); CustomCommandBlockMorph.prototype.constructor = CustomCommandBlockMorph; CustomCommandBlockMorph.uber = CommandBlockMorph.prototype; @@ -896,7 +896,7 @@ CustomCommandBlockMorph.prototype.alternatives = function () { // CustomReporterBlockMorph inherits from ReporterBlockMorph: -CustomReporterBlockMorph.prototype = new ReporterBlockMorph(); +CustomReporterBlockMorph.prototype = Object.create(ReporterBlockMorph.prototype); CustomReporterBlockMorph.prototype.constructor = CustomReporterBlockMorph; CustomReporterBlockMorph.uber = ReporterBlockMorph.prototype; @@ -1028,7 +1028,7 @@ CustomReporterBlockMorph.prototype.alternatives // JaggedBlockMorph inherits from ReporterBlockMorph: -JaggedBlockMorph.prototype = new ReporterBlockMorph(); +JaggedBlockMorph.prototype = Object.create(ReporterBlockMorph.prototype); JaggedBlockMorph.prototype.constructor = JaggedBlockMorph; JaggedBlockMorph.uber = ReporterBlockMorph.prototype; @@ -1177,7 +1177,7 @@ JaggedBlockMorph.prototype.drawEdges = function (context) { // BlockDialogMorph inherits from DialogBoxMorph: -BlockDialogMorph.prototype = new DialogBoxMorph(); +BlockDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); BlockDialogMorph.prototype.constructor = BlockDialogMorph; BlockDialogMorph.uber = DialogBoxMorph.prototype; @@ -1624,7 +1624,7 @@ BlockDialogMorph.prototype.fixLayout = function () { // BlockEditorMorph inherits from DialogBoxMorph: -BlockEditorMorph.prototype = new DialogBoxMorph(); +BlockEditorMorph.prototype = Object.create(DialogBoxMorph.prototype); BlockEditorMorph.prototype.constructor = BlockEditorMorph; BlockEditorMorph.uber = DialogBoxMorph.prototype; @@ -1936,7 +1936,7 @@ BlockEditorMorph.prototype.fixLayout = function () { // PrototypeHatBlockMorph inherits from HatBlockMorph: -PrototypeHatBlockMorph.prototype = new HatBlockMorph(); +PrototypeHatBlockMorph.prototype = Object.create(HatBlockMorph.prototype); PrototypeHatBlockMorph.prototype.constructor = PrototypeHatBlockMorph; PrototypeHatBlockMorph.uber = HatBlockMorph.prototype; @@ -2146,7 +2146,7 @@ BlockLabelFragment.prototype.setSingleInputType = function (type) { // BlockLabelFragmentMorph inherits from StringMorph: -BlockLabelFragmentMorph.prototype = new StringMorph(); +BlockLabelFragmentMorph.prototype = Object.create(StringMorph.prototype); BlockLabelFragmentMorph.prototype.constructor = BlockLabelFragmentMorph; BlockLabelFragmentMorph.uber = StringMorph.prototype; @@ -2268,7 +2268,7 @@ BlockLabelFragmentMorph.prototype.userMenu = function () { // BlockLabelPlaceHolderMorph inherits from StringMorph: -BlockLabelPlaceHolderMorph.prototype = new StringMorph(); +BlockLabelPlaceHolderMorph.prototype = Object.create(StringMorph.prototype); BlockLabelPlaceHolderMorph.prototype.constructor = BlockLabelPlaceHolderMorph; BlockLabelPlaceHolderMorph.uber = StringMorph.prototype; @@ -2396,7 +2396,7 @@ BlockLabelPlaceHolderMorph.prototype.updateBlockLabel // BlockInputFragmentMorph inherits from TemplateSlotMorph: -BlockInputFragmentMorph.prototype = new TemplateSlotMorph(); +BlockInputFragmentMorph.prototype = Object.create(TemplateSlotMorph.prototype); BlockInputFragmentMorph.prototype.constructor = BlockInputFragmentMorph; BlockInputFragmentMorph.uber = TemplateSlotMorph.prototype; @@ -2426,7 +2426,7 @@ BlockInputFragmentMorph.prototype.updateBlockLabel // InputSlotDialogMorph inherits from DialogBoxMorph: -InputSlotDialogMorph.prototype = new DialogBoxMorph(); +InputSlotDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); InputSlotDialogMorph.prototype.constructor = InputSlotDialogMorph; InputSlotDialogMorph.uber = DialogBoxMorph.prototype; @@ -3026,7 +3026,7 @@ InputSlotDialogMorph.prototype.show = function () { // VariableDialogMorph inherits from DialogBoxMorph: -VariableDialogMorph.prototype = new DialogBoxMorph(); +VariableDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); VariableDialogMorph.prototype.constructor = VariableDialogMorph; VariableDialogMorph.uber = DialogBoxMorph.prototype; @@ -3145,7 +3145,7 @@ VariableDialogMorph.prototype.fixLayout = function () { // BlockExportDialogMorph inherits from DialogBoxMorph: -BlockExportDialogMorph.prototype = new DialogBoxMorph(); +BlockExportDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); 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 = new DialogBoxMorph(); +BlockImportDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); BlockImportDialogMorph.prototype.constructor = BlockImportDialogMorph; BlockImportDialogMorph.uber = DialogBoxMorph.prototype; diff --git a/gui.js b/gui.js index 026a12c..89e2d89 100644 --- a/gui.js +++ b/gui.js @@ -88,7 +88,7 @@ var JukeboxMorph; // IDE_Morph inherits from Morph: -IDE_Morph.prototype = new Morph(); +IDE_Morph.prototype = Object.create(Morph.prototype); IDE_Morph.prototype.constructor = IDE_Morph; IDE_Morph.uber = Morph.prototype; @@ -4274,7 +4274,7 @@ IDE_Morph.prototype.prompt = function (message, callback, choices, key) { // ProjectDialogMorph inherits from DialogBoxMorph: -ProjectDialogMorph.prototype = new DialogBoxMorph(); +ProjectDialogMorph.prototype = Object.create(DialogBoxMorph.prototype); ProjectDialogMorph.prototype.constructor = ProjectDialogMorph; ProjectDialogMorph.uber = DialogBoxMorph.prototype; @@ -5181,7 +5181,7 @@ ProjectDialogMorph.prototype.fixLayout = function () { // SpriteIconMorph inherits from ToggleButtonMorph (Widgets) -SpriteIconMorph.prototype = new ToggleButtonMorph(); +SpriteIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); 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 = new ToggleButtonMorph(); +CostumeIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); 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 = new ToggleButtonMorph(); +TurtleIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); TurtleIconMorph.prototype.constructor = TurtleIconMorph; TurtleIconMorph.uber = ToggleButtonMorph.prototype; @@ -5965,7 +5965,7 @@ TurtleIconMorph.prototype.userMenu = function () { // WardrobeMorph inherits from ScrollFrameMorph -WardrobeMorph.prototype = new ScrollFrameMorph(); +WardrobeMorph.prototype = Object.create(ScrollFrameMorph.prototype); 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 = new ToggleButtonMorph(); +SoundIconMorph.prototype = Object.create(ToggleButtonMorph.prototype); SoundIconMorph.prototype.constructor = SoundIconMorph; SoundIconMorph.uber = ToggleButtonMorph.prototype; @@ -6356,7 +6356,7 @@ SoundIconMorph.prototype.prepareToBeGrabbed = function () { // JukeboxMorph instance creation -JukeboxMorph.prototype = new ScrollFrameMorph(); +JukeboxMorph.prototype = Object.create(ScrollFrameMorph.prototype); JukeboxMorph.prototype.constructor = JukeboxMorph; JukeboxMorph.uber = ScrollFrameMorph.prototype; diff --git a/lists.js b/lists.js index bd856fe..be7f933 100644 --- a/lists.js +++ b/lists.js @@ -363,7 +363,7 @@ List.prototype.equalTo = function (other) { // ListWatcherMorph inherits from BoxMorph: -ListWatcherMorph.prototype = new BoxMorph(); +ListWatcherMorph.prototype = Object.create(BoxMorph.prototype); ListWatcherMorph.prototype.constructor = ListWatcherMorph; ListWatcherMorph.uber = BoxMorph.prototype; diff --git a/morphic.js b/morphic.js index 2850e32..029afd1 100644 --- a/morphic.js +++ b/morphic.js @@ -528,7 +528,7 @@ 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. @@ -2171,7 +2171,7 @@ var TextMorph; // Morph inherits from Node: -Morph.prototype = new Node(); +Morph.prototype = Object.create(Node.prototype); Morph.prototype.constructor = Morph; Morph.uber = Node.prototype; @@ -3696,7 +3696,7 @@ Morph.prototype.overlappingImage = function (otherMorph) { // ShadowMorph inherits from Morph: -ShadowMorph.prototype = new Morph(); +ShadowMorph.prototype = Object.create(Morph.prototype); ShadowMorph.prototype.constructor = ShadowMorph; ShadowMorph.uber = Morph.prototype; @@ -3712,7 +3712,7 @@ function ShadowMorph() { // HandleMorph inherits from Morph: -HandleMorph.prototype = new Morph(); +HandleMorph.prototype = Object.create(Morph.prototype); HandleMorph.prototype.constructor = HandleMorph; HandleMorph.uber = Morph.prototype; @@ -3967,7 +3967,7 @@ var PenMorph; // PenMorph inherits from Morph: -PenMorph.prototype = new Morph(); +PenMorph.prototype = Object.create(Morph.prototype); PenMorph.prototype.constructor = PenMorph; PenMorph.uber = Morph.prototype; @@ -4199,7 +4199,7 @@ var ColorPaletteMorph; // ColorPaletteMorph inherits from Morph: -ColorPaletteMorph.prototype = new Morph(); +ColorPaletteMorph.prototype = Object.create(Morph.prototype); ColorPaletteMorph.prototype.constructor = ColorPaletteMorph; ColorPaletteMorph.uber = Morph.prototype; @@ -4331,7 +4331,7 @@ var GrayPaletteMorph; // GrayPaletteMorph inherits from ColorPaletteMorph: -GrayPaletteMorph.prototype = new ColorPaletteMorph(); +GrayPaletteMorph.prototype = Object.create(ColorPaletteMorph.prototype); GrayPaletteMorph.prototype.constructor = GrayPaletteMorph; GrayPaletteMorph.uber = ColorPaletteMorph.prototype; @@ -4362,7 +4362,7 @@ GrayPaletteMorph.prototype.drawNew = function () { // ColorPickerMorph inherits from Morph: -ColorPickerMorph.prototype = new Morph(); +ColorPickerMorph.prototype = Object.create(Morph.prototype); ColorPickerMorph.prototype.constructor = ColorPickerMorph; ColorPickerMorph.uber = Morph.prototype; @@ -4431,7 +4431,7 @@ var BlinkerMorph; // BlinkerMorph inherits from Morph: -BlinkerMorph.prototype = new Morph(); +BlinkerMorph.prototype = Object.create(Morph.prototype); BlinkerMorph.prototype.constructor = BlinkerMorph; BlinkerMorph.uber = Morph.prototype; @@ -4464,7 +4464,7 @@ var CursorMorph; // CursorMorph inherits from BlinkerMorph: -CursorMorph.prototype = new BlinkerMorph(); +CursorMorph.prototype = Object.create(BlinkerMorph.prototype); CursorMorph.prototype.constructor = CursorMorph; CursorMorph.uber = BlinkerMorph.prototype; @@ -4884,7 +4884,7 @@ var BoxMorph; // BoxMorph inherits from Morph: -BoxMorph.prototype = new Morph(); +BoxMorph.prototype = Object.create(Morph.prototype); BoxMorph.prototype.constructor = BoxMorph; BoxMorph.uber = Morph.prototype; @@ -5092,7 +5092,7 @@ var SpeechBubbleMorph; // SpeechBubbleMorph inherits from BoxMorph: -SpeechBubbleMorph.prototype = new BoxMorph(); +SpeechBubbleMorph.prototype = Object.create(BoxMorph.prototype); SpeechBubbleMorph.prototype.constructor = SpeechBubbleMorph; SpeechBubbleMorph.uber = BoxMorph.prototype; @@ -5392,7 +5392,7 @@ var CircleBoxMorph; // CircleBoxMorph inherits from Morph: -CircleBoxMorph.prototype = new Morph(); +CircleBoxMorph.prototype = Object.create(Morph.prototype); CircleBoxMorph.prototype.constructor = CircleBoxMorph; CircleBoxMorph.uber = Morph.prototype; @@ -5512,7 +5512,7 @@ var SliderButtonMorph; // SliderButtonMorph inherits from CircleBoxMorph: -SliderButtonMorph.prototype = new CircleBoxMorph(); +SliderButtonMorph.prototype = Object.create(CircleBoxMorph.prototype); SliderButtonMorph.prototype.constructor = SliderButtonMorph; SliderButtonMorph.uber = CircleBoxMorph.prototype; @@ -5724,7 +5724,7 @@ SliderButtonMorph.prototype.mouseMove = function () { // SliderMorph inherits from CircleBoxMorph: -SliderMorph.prototype = new CircleBoxMorph(); +SliderMorph.prototype = Object.create(CircleBoxMorph.prototype); SliderMorph.prototype.constructor = SliderMorph; SliderMorph.uber = CircleBoxMorph.prototype; @@ -6092,7 +6092,7 @@ var MouseSensorMorph; // MouseSensorMorph inherits from BoxMorph: -MouseSensorMorph.prototype = new BoxMorph(); +MouseSensorMorph.prototype = Object.create(BoxMorph.prototype); MouseSensorMorph.prototype.constructor = MouseSensorMorph; MouseSensorMorph.uber = BoxMorph.prototype; @@ -6166,7 +6166,7 @@ var TriggerMorph; // InspectorMorph inherits from BoxMorph: -InspectorMorph.prototype = new BoxMorph(); +InspectorMorph.prototype = Object.create(BoxMorph.prototype); InspectorMorph.prototype.constructor = InspectorMorph; InspectorMorph.uber = BoxMorph.prototype; @@ -6661,7 +6661,7 @@ var MenuItemMorph; // MenuMorph inherits from BoxMorph: -MenuMorph.prototype = new BoxMorph(); +MenuMorph.prototype = Object.create(BoxMorph.prototype); MenuMorph.prototype.constructor = MenuMorph; MenuMorph.uber = BoxMorph.prototype; @@ -6956,7 +6956,7 @@ MenuMorph.prototype.popUpCenteredInWorld = function (world) { // StringMorph inherits from Morph: -StringMorph.prototype = new Morph(); +StringMorph.prototype = Object.create(Morph.prototype); StringMorph.prototype.constructor = StringMorph; StringMorph.uber = Morph.prototype; @@ -7491,7 +7491,7 @@ StringMorph.prototype.disableSelecting = function () { // TextMorph inherits from Morph: -TextMorph.prototype = new Morph(); +TextMorph.prototype = Object.create(Morph.prototype); TextMorph.prototype.constructor = TextMorph; TextMorph.uber = Morph.prototype; @@ -8016,7 +8016,7 @@ TextMorph.prototype.inspectIt = function () { // TriggerMorph inherits from Morph: -TriggerMorph.prototype = new Morph(); +TriggerMorph.prototype = Object.create(Morph.prototype); TriggerMorph.prototype.constructor = TriggerMorph; TriggerMorph.uber = Morph.prototype; @@ -8285,7 +8285,7 @@ var MenuItemMorph; // MenuItemMorph inherits from TriggerMorph: -MenuItemMorph.prototype = new TriggerMorph(); +MenuItemMorph.prototype = Object.create(TriggerMorph.prototype); MenuItemMorph.prototype.constructor = MenuItemMorph; MenuItemMorph.uber = TriggerMorph.prototype; @@ -8444,7 +8444,7 @@ MenuItemMorph.prototype.isSelectedListItem = function () { // Frames inherit from Morph: -FrameMorph.prototype = new Morph(); +FrameMorph.prototype = Object.create(Morph.prototype); FrameMorph.prototype.constructor = FrameMorph; FrameMorph.uber = Morph.prototype; @@ -8638,7 +8638,7 @@ FrameMorph.prototype.keepAllSubmorphsWithin = function () { // ScrollFrameMorph //////////////////////////////////////////////////// -ScrollFrameMorph.prototype = new FrameMorph(); +ScrollFrameMorph.prototype = Object.create(FrameMorph.prototype); ScrollFrameMorph.prototype.constructor = ScrollFrameMorph; ScrollFrameMorph.uber = FrameMorph.prototype; @@ -9013,7 +9013,7 @@ ScrollFrameMorph.prototype.toggleTextLineWrapping = function () { // ListMorph /////////////////////////////////////////////////////////// -ListMorph.prototype = new ScrollFrameMorph(); +ListMorph.prototype = Object.create(ScrollFrameMorph.prototype); ListMorph.prototype.constructor = ListMorph; ListMorph.uber = ScrollFrameMorph.prototype; @@ -9151,7 +9151,7 @@ ListMorph.prototype.setExtent = function (aPoint) { // StringFieldMorph inherit from FrameMorph: -StringFieldMorph.prototype = new FrameMorph(); +StringFieldMorph.prototype = Object.create(FrameMorph.prototype); StringFieldMorph.prototype.constructor = StringFieldMorph; StringFieldMorph.uber = FrameMorph.prototype; @@ -9265,7 +9265,7 @@ var BouncerMorph; // Bouncers inherit from Morph: -BouncerMorph.prototype = new Morph(); +BouncerMorph.prototype = Object.create(Morph.prototype); BouncerMorph.prototype.constructor = BouncerMorph; BouncerMorph.uber = Morph.prototype; @@ -9352,7 +9352,7 @@ BouncerMorph.prototype.step = function () { // HandMorph inherits from Morph: -HandMorph.prototype = new Morph(); +HandMorph.prototype = Object.create(Morph.prototype); HandMorph.prototype.constructor = HandMorph; HandMorph.uber = Morph.prototype; @@ -9987,7 +9987,7 @@ HandMorph.prototype.moveBy = function (delta) { // WorldMorph inherits from FrameMorph: -WorldMorph.prototype = new FrameMorph(); +WorldMorph.prototype = Object.create(FrameMorph.prototype); WorldMorph.prototype.constructor = WorldMorph; WorldMorph.uber = FrameMorph.prototype; diff --git a/objects.js b/objects.js index 8cae1c7..462aed2 100644 --- a/objects.js +++ b/objects.js @@ -147,7 +147,7 @@ var SpriteHighlightMorph; // SpriteMorph inherits from PenMorph: -SpriteMorph.prototype = new PenMorph(); +SpriteMorph.prototype = Object.create(PenMorph.prototype); SpriteMorph.prototype.constructor = SpriteMorph; SpriteMorph.uber = PenMorph.prototype; @@ -583,7 +583,7 @@ SpriteMorph.prototype.initBlocks = function () { }, /* migrated to a newer block version: - + receiveClick: { type: 'hat', category: 'control', @@ -3008,7 +3008,7 @@ SpriteMorph.prototype.applyGraphicsEffects = function (canvas) { var i; if (value !== 0) { for (i = 0; i < p.length; i += 4) { - p[i] += value; //255 = 100% of this color + p[i] += value; //255 = 100% of this color p[i + 1] += value; p[i + 2] += value; } @@ -4289,7 +4289,7 @@ SpriteMorph.prototype.doScreenshot = function (imgSource, data) { // SpriteHighlightMorph inherits from Morph: -SpriteHighlightMorph.prototype = new Morph(); +SpriteHighlightMorph.prototype = Object.create(Morph.prototype); SpriteHighlightMorph.prototype.constructor = SpriteHighlightMorph; SpriteHighlightMorph.uber = Morph.prototype; @@ -4307,7 +4307,7 @@ function SpriteHighlightMorph() { // StageMorph inherits from FrameMorph: -StageMorph.prototype = new FrameMorph(); +StageMorph.prototype = Object.create(FrameMorph.prototype); StageMorph.prototype.constructor = StageMorph; StageMorph.uber = FrameMorph.prototype; @@ -5669,7 +5669,7 @@ StageMorph.prototype.replaceDoubleDefinitionsFor // SpriteBubbleMorph inherits from SpeechBubbleMorph: -SpriteBubbleMorph.prototype = new SpeechBubbleMorph(); +SpriteBubbleMorph.prototype = Object.create(SpeechBubbleMorph.prototype); SpriteBubbleMorph.prototype.constructor = SpriteBubbleMorph; SpriteBubbleMorph.uber = SpeechBubbleMorph.prototype; @@ -6168,7 +6168,7 @@ Costume.prototype.isTainted = function () { // SVG_Costume inherits from Costume: -SVG_Costume.prototype = new Costume(); +SVG_Costume.prototype = Object.create(Costume.prototype); 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 = new Morph(); +CostumeEditorMorph.prototype = Object.create(Morph.prototype); CostumeEditorMorph.prototype.constructor = CostumeEditorMorph; CostumeEditorMorph.uber = Morph.prototype; @@ -6454,7 +6454,7 @@ Note.prototype.stop = function () { // CellMorph inherits from BoxMorph: -CellMorph.prototype = new BoxMorph(); +CellMorph.prototype = Object.create(BoxMorph.prototype); CellMorph.prototype.constructor = CellMorph; CellMorph.uber = BoxMorph.prototype; @@ -6794,7 +6794,7 @@ CellMorph.prototype.mouseClickLeft = function (pos) { // WatcherMorph inherits from BoxMorph: -WatcherMorph.prototype = new BoxMorph(); +WatcherMorph.prototype = Object.create(BoxMorph.prototype); WatcherMorph.prototype.constructor = WatcherMorph; WatcherMorph.uber = BoxMorph.prototype; @@ -7281,7 +7281,7 @@ WatcherMorph.prototype.drawNew = function () { // StagePrompterMorph inherits from BoxMorph: -StagePrompterMorph.prototype = new BoxMorph(); +StagePrompterMorph.prototype = Object.create(BoxMorph.prototype); StagePrompterMorph.prototype.constructor = StagePrompterMorph; StagePrompterMorph.uber = BoxMorph.prototype; diff --git a/paint.js b/paint.js index 65ae1f6..b4c55b1 100644 --- a/paint.js +++ b/paint.js @@ -81,7 +81,7 @@ var PaintColorPickerMorph; // A complete paint editor -PaintEditorMorph.prototype = new DialogBoxMorph(); +PaintEditorMorph.prototype = Object.create(DialogBoxMorph.prototype); PaintEditorMorph.prototype.constructor = PaintEditorMorph; PaintEditorMorph.uber = DialogBoxMorph.prototype; @@ -476,7 +476,7 @@ PaintEditorMorph.prototype.getUserColor = function () { // A large hsl color picker -PaintColorPickerMorph.prototype = new Morph(); +PaintColorPickerMorph.prototype = Object.create(Morph.prototype); PaintColorPickerMorph.prototype.constructor = PaintColorPickerMorph; PaintColorPickerMorph.uber = Morph.prototype; @@ -552,7 +552,7 @@ PaintColorPickerMorph.prototype.mouseMove = modify its image, based on a 'tool' property. */ -PaintCanvasMorph.prototype = new Morph(); +PaintCanvasMorph.prototype = Object.create(Morph.prototype); PaintCanvasMorph.prototype.constructor = PaintCanvasMorph; PaintCanvasMorph.uber = Morph.prototype; diff --git a/store.js b/store.js index 5cba3c3..6f3bc23 100644 --- a/store.js +++ b/store.js @@ -246,7 +246,7 @@ var SnapSerializer; // SnapSerializer inherits from XML_Serializer: -SnapSerializer.prototype = new XML_Serializer(); +SnapSerializer.prototype = Object.create(XML_Serializer.prototype); SnapSerializer.prototype.constructor = SnapSerializer; SnapSerializer.uber = XML_Serializer.prototype; diff --git a/widgets.js b/widgets.js index bb250a8..2f96f2c 100644 --- a/widgets.js +++ b/widgets.js @@ -91,7 +91,7 @@ var InputFieldMorph; // PushButtonMorph inherits from TriggerMorph: -PushButtonMorph.prototype = new TriggerMorph(); +PushButtonMorph.prototype = Object.create(TriggerMorph.prototype); PushButtonMorph.prototype.constructor = PushButtonMorph; PushButtonMorph.uber = TriggerMorph.prototype; @@ -476,7 +476,7 @@ PushButtonMorph.prototype.createLabel = function () { // ToggleButtonMorph inherits from PushButtonMorph: -ToggleButtonMorph.prototype = new PushButtonMorph(); +ToggleButtonMorph.prototype = Object.create(PushButtonMorph.prototype); ToggleButtonMorph.prototype.constructor = ToggleButtonMorph; ToggleButtonMorph.uber = PushButtonMorph.prototype; @@ -900,7 +900,7 @@ ToggleButtonMorph.prototype.show = function () { // TabMorph inherits from ToggleButtonMorph: -TabMorph.prototype = new ToggleButtonMorph(); +TabMorph.prototype = Object.create(ToggleButtonMorph.prototype); TabMorph.prototype.constructor = TabMorph; TabMorph.uber = ToggleButtonMorph.prototype; @@ -1022,7 +1022,7 @@ TabMorph.prototype.drawEdges = function ( // ToggleMorph inherits from PushButtonMorph: -ToggleMorph.prototype = new PushButtonMorph(); +ToggleMorph.prototype = Object.create(PushButtonMorph.prototype); ToggleMorph.prototype.constructor = ToggleMorph; ToggleMorph.uber = PushButtonMorph.prototype; @@ -1270,7 +1270,7 @@ ToggleMorph.prototype.show = ToggleButtonMorph.prototype.show; // ToggleElementMorph inherits from TriggerMorph: -ToggleElementMorph.prototype = new TriggerMorph(); +ToggleElementMorph.prototype = Object.create(TriggerMorph.prototype); ToggleElementMorph.prototype.constructor = ToggleElementMorph; ToggleElementMorph.uber = TriggerMorph.prototype; @@ -1440,7 +1440,7 @@ ToggleElementMorph.prototype.mouseClickLeft // DialogBoxMorph inherits from Morph: -DialogBoxMorph.prototype = new Morph(); +DialogBoxMorph.prototype = Object.create(Morph.prototype); DialogBoxMorph.prototype.constructor = DialogBoxMorph; DialogBoxMorph.uber = Morph.prototype; @@ -2866,7 +2866,7 @@ DialogBoxMorph.prototype.outlinePathBody = function (context, radius) { // AlignmentMorph inherits from Morph: -AlignmentMorph.prototype = new Morph(); +AlignmentMorph.prototype = Object.create(Morph.prototype); AlignmentMorph.prototype.constructor = AlignmentMorph; AlignmentMorph.uber = Morph.prototype; @@ -2940,7 +2940,7 @@ AlignmentMorph.prototype.fixLayout = function () { // InputFieldMorph inherits from Morph: -InputFieldMorph.prototype = new Morph(); +InputFieldMorph.prototype = Object.create(Morph.prototype); InputFieldMorph.prototype.constructor = InputFieldMorph; InputFieldMorph.uber = Morph.prototype; diff --git a/xml.js b/xml.js index fb612ce..d1cdf68 100644 --- a/xml.js +++ b/xml.js @@ -166,7 +166,7 @@ ReadStream.prototype.word = function () { // XML_Element inherits from Node: -XML_Element.prototype = new Node(); +XML_Element.prototype = Object.create(Node.prototype); XML_Element.prototype.constructor = XML_Element; XML_Element.uber = Node.prototype; -- cgit v1.3.1 From 013e2740d853b660fbc48cda247b6fe711aecce9 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 17:26:56 -0400 Subject: Fix missing initialization call in SnapSerializer() --- store.js | 1 + 1 file changed, 1 insertion(+) diff --git a/store.js b/store.js index 6f3bc23..a45c801 100644 --- a/store.js +++ b/store.js @@ -274,6 +274,7 @@ SnapSerializer.prototype.watcherLabels = { // SnapSerializer instance creation: function SnapSerializer() { + XML_Serializer.call(this); this.init(); } -- cgit v1.3.1 From c8cbbeb2ada539d8c71a74a000b1eb329ad26bbe Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 18:24:54 -0400 Subject: Optimize HandMorph::morphAtPointer a lot On large morph hierarchies this goes from ~85% CPU usage when moving the mouse around to ~5%. --- morphic.js | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/morphic.js b/morphic.js index 029afd1..88f8c22 100644 --- a/morphic.js +++ b/morphic.js @@ -9392,28 +9392,27 @@ HandMorph.prototype.changed = function () { // HandMorph navigation: -HandMorph.prototype.morphAtPointer = function () { - var morphs = this.world.allChildren().slice(0).reverse(), - myself = this, - result = null; - - morphs.forEach(function (m) { - if (m.visibleBounds().containsPoint(myself.bounds.origin) && - result === null && - m.isVisible && - (m.noticesTransparentClick || - (!m.isTransparentAt(myself.bounds.origin))) && - (!(m instanceof ShadowMorph)) && - m.allParents().every(function (each) { - return each.isVisible; - })) { - result = m; - } - }); - if (result !== null) { - return result; +Morph.prototype.topMorphAt = function (p) { + if (!this.isVisible) return null; + for (var c = this.children, i = c.length; i--;) { + var result = c[i].topMorphAt(p); + if (result) return result; + } + return this.bounds.containsPoint(p) ? this : null; +}; +FrameMorph.prototype.topMorphAt = function (p) { + if (!(this.isVisible && this.bounds.containsPoint(p))) return null; + for (var c = this.children, i = c.length; i--;) { + var result = c[i].topMorphAt(p); + if (result) return result; } - return this.world; + return this; +}; +ShadowMorph.prototype.topMorphAt = function () { + return null; +}; +HandMorph.prototype.morphAtPointer = function () { + return this.world.topMorphAt(this.bounds.origin); }; /* -- cgit v1.3.1 From 7bb046856c765facb348d3f461166599c03103d6 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 18:28:18 -0400 Subject: Remove extra space --- morphic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/morphic.js b/morphic.js index 88f8c22..aca37ed 100644 --- a/morphic.js +++ b/morphic.js @@ -2899,7 +2899,7 @@ Morph.prototype.fullChanged = function () { }; Morph.prototype.childChanged = function () { - // react to a change in one of my children, + // react to a change in one of my children, // default is to just pass this message on upwards // override this method for Morphs that need to adjust accordingly if (this.parent) { -- cgit v1.3.1 From 94687f8e630c5be6f2c82615c1aa1ec5cbee82b8 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 18:39:23 -0400 Subject: Optimize Block::thumbnail() Remove noShadow, because copying is really expensive--you could probably add this in-place with some more complicated logic, but it doesn't seem worth it. Also fix clipping logic so that fades look good on all background colors. --- blocks.js | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/blocks.js b/blocks.js index 3613dae..d373cea 100644 --- a/blocks.js +++ b/blocks.js @@ -2225,7 +2225,7 @@ BlockMorph.prototype.userMenu = function () { ); if (this instanceof CommandBlockMorph && this.nextBlock()) { menu.addItem( - this.thumbnail(0.5, 60, false), + this.thumbnail(0.5, 60), function () { var cpy = this.fullCopy(), nb = cpy.nextBlock(), @@ -3103,38 +3103,34 @@ BlockMorph.prototype.mouseClickLeft = function () { // BlockMorph thumbnail -BlockMorph.prototype.thumbnail = function (scale, clipWidth, noShadow) { - var block = this.fullCopy(), - nb = block.nextBlock(), +BlockMorph.prototype.thumbnail = function (scale, clipWidth) { + var nb = this.nextBlock(), fadeout = 12, ext, trgt, ctx, gradient; - if (nb) {nb.destroy(); } - if (!noShadow) {block.addShadow(); } - ext = block.fullBounds().extent(); - if (!noShadow) { - ext = ext.subtract(this.shadowBlur * - (useBlurredShadows && !MorphicPreferences.isFlat ? 1 : 2)); - } + + if (nb) {nb.isVisible = false; } + ext = this.fullBounds().extent(); trgt = newCanvas(new Point( - Math.min(ext.x * scale, clipWidth || ext.x), + clipWidth ? Math.min(ext.x * scale, clipWidth) : ext.x * scale, ext.y * scale )); ctx = trgt.getContext('2d'); ctx.scale(scale, scale); - ctx.drawImage(block.fullImage(), 0, 0); + ctx.drawImage(this.fullImage(), 0, 0); // draw fade-out - if (trgt.width === clipWidth) { + if (clipWidth && ext.x * scale > clipWidth) { gradient = ctx.createLinearGradient( trgt.width / scale - fadeout, 0, trgt.width / scale, 0 ); - gradient.addColorStop(0, new Color(255, 255, 255, 0).toString()); - gradient.addColorStop(1, 'white'); + gradient.addColorStop(0, 'transparent'); + gradient.addColorStop(1, 'black'); + ctx.globalCompositeOperation = 'destination-out'; ctx.fillStyle = gradient; ctx.fillRect( trgt.width / scale - fadeout, @@ -3143,6 +3139,7 @@ BlockMorph.prototype.thumbnail = function (scale, clipWidth, noShadow) { trgt.height / scale ); } + if (nb) {nb.isVisible = true; } return trgt; }; -- cgit v1.3.1 From 1f52f4f1522c4bc7c24fb19ba66aeaff3bf15b64 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 18:50:56 -0400 Subject: Optimize StringMorph::clearSelection() This was taking a very large chunk of CPU time when copying large scripts. --- morphic.js | 1 + 1 file changed, 1 insertion(+) diff --git a/morphic.js b/morphic.js index aca37ed..737e944 100644 --- a/morphic.js +++ b/morphic.js @@ -7402,6 +7402,7 @@ StringMorph.prototype.selectionStartSlot = function () { }; StringMorph.prototype.clearSelection = function () { + if (!this.currentlySelecting && this.startMark === 0 && this.endMark === 0) return; this.currentlySelecting = false; this.startMark = 0; this.endMark = 0; -- cgit v1.3.1 From 81b9245d25cc7a3027f21fe13bcb653a7a552c09 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 19:10:30 -0400 Subject: Optimize copy() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1356.2 ms before => 73.3 ms after (on a large block stack) --- morphic.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/morphic.js b/morphic.js index 737e944..013660e 100644 --- a/morphic.js +++ b/morphic.js @@ -1266,18 +1266,16 @@ function copy(target) { } if (target instanceof target.constructor && target.constructor !== Object) { - c = clone(target.constructor.prototype); - for (property in target) { - if (Object.prototype.hasOwnProperty.call(target, property)) { - c[property] = target[property]; - } + c = Object.create(target.constructor.prototype); + var keys = Object.keys(target); + for (var l = keys.length, i = 0; i < l; i++) { + property = keys[i]; + c[property] = target[property]; } } else { c = {}; for (property in target) { - if (!c[property]) { - c[property] = target[property]; - } + c[property] = target[property]; } } return c; -- cgit v1.3.1 From 3e613a44090391854c6126d919797911daab2307 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 19:45:31 -0400 Subject: Fix and greatly simplify copying mechanism Due to an error in the original implementation of updateReferences(), Morph subclasses which stored references to other morphs needed to manually override copyRecordingReferences() to update these references (which should have been done automatically by updateReferences). This change fixes updateReferences() and changes the copying mechanism to use Maps, which are much faster. --- morphic.js | 162 +++++++++++++------------------------------------------------ 1 file changed, 34 insertions(+), 128 deletions(-) diff --git a/morphic.js b/morphic.js index 013660e..6ce8559 100644 --- a/morphic.js +++ b/morphic.js @@ -829,12 +829,11 @@ }; If your new morph stores or references other morphs outside of the - submorph tree in other properties, be sure to also override the - default + submorph tree in other properties, you may need to override the default - copyRecordingReferences() + updateReferences() - method accordingly if you want it to support duplication. + method if you want it to support duplication. (6) development and user modes @@ -1268,7 +1267,7 @@ function copy(target) { target.constructor !== Object) { c = Object.create(target.constructor.prototype); var keys = Object.keys(target); - for (var l = keys.length, i = 0; i < l; i++) { + for (var l = keys.length, i = 0; i < l; ++i) { property = keys[i]; c[property] = target[property]; } @@ -3044,45 +3043,49 @@ Morph.prototype.fullCopy = function () { Other properties are also *shallow* copied, so you must override to deep copy Arrays and (complex) Objects */ - var dict = {}, c; - c = this.copyRecordingReferences(dict); + var map = new Map(), c; + c = this.copyRecordingReferences(map); c.forAllChildren(function (m) { - m.updateReferences(dict); + m.updateReferences(map); }); return c; }; -Morph.prototype.copyRecordingReferences = function (dict) { +Morph.prototype.copyRecordingReferences = function (map) { /* Recursively copy this entire composite morph, recording the correspondence between old and new morphs in the given dictionary. This dictionary will be used to update intra-composite references in the copy. See updateReferences(). - Note: This default implementation copies ONLY morphs in the - submorph hierarchy. If a morph stores morphs in other properties - that it wants to copy, then it should override this method to do so. - The same goes for morphs that contain other complex data that - should be copied when the morph is duplicated. + + Note: This default implementation copies ONLY morphs. If a morph + stores morphs in other properties that it wants to copy, then it + should override this method to do so. The same goes for morphs that + contain other complex data that should be copied when the morph is + duplicated. */ var c = this.copy(); - dict[this] = c; + map.set(this, c); this.children.forEach(function (m) { - c.add(m.copyRecordingReferences(dict)); + c.add(m.copyRecordingReferences(map)); }); return c; }; -Morph.prototype.updateReferences = function (dict) { +Morph.prototype.updateReferences = function (map) { /* Update intra-morph references within a composite morph that has been copied. For example, if a button refers to morph X in the orginal composite then the copy of that button in the new composite should refer to the copy of X in new composite, not the original X. */ - var property; - for (property in this) { - if (this[property] && this[property].isMorph && dict[property]) { - this[property] = dict[property]; + var property, value, reference; + for (var properties = Object.keys(this), l = properties.length, i = 0; i < l; ++i) { + property = properties[i]; + value = this[property]; + if (value && value.isMorph) { + reference = map.get(value); + if (reference) this[property] = reference; } } }; @@ -3921,20 +3924,6 @@ HandleMorph.prototype.mouseLeave = function () { this.changed(); }; -// HandleMorph duplicating: - -HandleMorph.prototype.copyRecordingReferences = function (dict) { - // inherited, see comment in Morph - var c = HandleMorph.uber.copyRecordingReferences.call( - this, - dict - ); - if (c.target && dict[this.target]) { - c.target = (dict[this.target]); - } - return c; -}; - // HandleMorph menu: HandleMorph.prototype.attach = function () { @@ -4258,20 +4247,6 @@ ColorPaletteMorph.prototype.updateTarget = function () { } }; -// ColorPaletteMorph duplicating: - -ColorPaletteMorph.prototype.copyRecordingReferences = function (dict) { - // inherited, see comment in Morph - var c = ColorPaletteMorph.uber.copyRecordingReferences.call( - this, - dict - ); - if (c.target && dict[this.target]) { - c.target = (dict[this.target]); - } - return c; -}; - // ColorPaletteMorph menu: ColorPaletteMorph.prototype.developersMenu = function () { @@ -5838,23 +5813,6 @@ SliderMorph.prototype.updateTarget = function () { } }; -// SliderMorph duplicating: - -SliderMorph.prototype.copyRecordingReferences = function (dict) { - // inherited, see comment in Morph - var c = SliderMorph.uber.copyRecordingReferences.call( - this, - dict - ); - if (c.target && dict[this.target]) { - c.target = (dict[this.target]); - } - if (c.button && dict[this.button]) { - c.button = (dict[this.button]); - } - return c; -}; - // SliderMorph menu: SliderMorph.prototype.developersMenu = function () { @@ -8140,20 +8098,6 @@ TriggerMorph.prototype.createLabel = function () { this.add(this.label); }; -// TriggerMorph duplicating: - -TriggerMorph.prototype.copyRecordingReferences = function (dict) { - // inherited, see comment in Morph - var c = TriggerMorph.uber.copyRecordingReferences.call( - this, - dict - ); - if (c.label && dict[this.label]) { - c.label = (dict[this.label]); - } - return c; -}; - // TriggerMorph action: TriggerMorph.prototype.trigger = function () { @@ -8599,20 +8543,6 @@ FrameMorph.prototype.reactToGrabOf = function () { this.adjustBounds(); }; -// FrameMorph duplicating: - -FrameMorph.prototype.copyRecordingReferences = function (dict) { - // inherited, see comment in Morph - var c = FrameMorph.uber.copyRecordingReferences.call( - this, - dict - ); - if (c.frame && dict[this.scrollFrame]) { - c.frame = (dict[this.scrollFrame]); - } - return c; -}; - // FrameMorph menus: FrameMorph.prototype.developersMenu = function () { @@ -8957,32 +8887,22 @@ ScrollFrameMorph.prototype.mouseScroll = function (y, x) { // ScrollFrameMorph duplicating: -ScrollFrameMorph.prototype.copyRecordingReferences = function (dict) { - // inherited, see comment in Morph - var c = ScrollFrameMorph.uber.copyRecordingReferences.call( - this, - dict - ); - if (c.contents && dict[this.contents]) { - c.contents = (dict[this.contents]); - } - if (c.hBar && dict[this.hBar]) { - c.hBar = (dict[this.hBar]); - c.hBar.action = function (num) { - c.contents.setPosition( - new Point(c.left() - num, c.contents.position().y) +ScrollFrameMorph.prototype.updateReferences = function () { + var self = this; + if (this.hBar) { + this.hBar.action = function (num) { + self.contents.setPosition( + new Point(self.left() - num, self.contents.position().y) ); }; } - if (c.vBar && dict[this.vBar]) { - c.vBar = (dict[this.vBar]); - c.vBar.action = function (num) { - c.contents.setPosition( - new Point(c.contents.position().x, c.top() - num) + if (this.vBar) { + this.vBar.action = function (num) { + self.contents.setPosition( + new Point(self.contents.position().x, self.top() - num) ); }; } - return c; }; // ScrollFrameMorph menu: @@ -9242,20 +9162,6 @@ StringFieldMorph.prototype.mouseClickLeft = function (pos) { } }; -// StringFieldMorph duplicating: - -StringFieldMorph.prototype.copyRecordingReferences = function (dict) { - // inherited, see comment in Morph - var c = StringFieldMorph.uber.copyRecordingReferences.call( - this, - dict - ); - if (c.text && dict[this.text]) { - c.text = (dict[this.text]); - } - return c; -}; - // BouncerMorph //////////////////////////////////////////////////////// // I am a Demo of a stepping custom Morph -- cgit v1.3.1 From f54da26e8e4a9d92c93ac58f242ac521b6dbac66 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 20:05:35 -0400 Subject: Don't step SyntaxElementMorphs or their children ~1500 ms before => ~150 ms after (stepping world with large scripts) --- blocks.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/blocks.js b/blocks.js index d373cea..d2a395a 100644 --- a/blocks.js +++ b/blocks.js @@ -621,6 +621,10 @@ SyntaxElementMorph.prototype.topBlock = function () { return this; }; +// SyntaxElementMorph stepping: + +SyntaxElementMorph.prototype.step = null; + // SyntaxElementMorph drag & drop: SyntaxElementMorph.prototype.reactToGrabOf = function (grabbedMorph) { -- cgit v1.3.1 From d5761b074d0c98c047e7319cf2243a39c7a6a303 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore 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(-) 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(-) 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 f20ea6792688b97a8d9b50e9eed783e4773d9a86 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 21:08:12 -0400 Subject: Provide a fallback for browsers that don't support Map --- morphic.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/morphic.js b/morphic.js index 5cc4062..fe2cc8b 100644 --- a/morphic.js +++ b/morphic.js @@ -3077,6 +3077,40 @@ Morph.prototype.updateReferences = function (map) { } }; +if (typeof Map === 'undefined') { + // use normal objects + stringification if Map doesn't exist + + Morph.prototype.fullCopy = function () { + var dict = {}, c; + c = this.copyRecordingReferences(dict); + c.forAllChildren(function (m) { + m.updateReferences(dict); + }); + return c; + }; + + Morph.prototype.copyRecordingReferences = function (dict) { + var c = this.copy(); + dict[this] = c; + this.children.forEach(function (m) { + c.add(m.copyRecordingReferences(dict)); + }); + return c; + }; + + Morph.prototype.updateReferences = function (dict) { + var property, value, reference; + for (var properties = Object.keys(this), l = properties.length, i = 0; i < l; ++i) { + property = properties[i]; + value = this[property]; + if (value && value.isMorph) { + reference = dict[value]; + if (reference) this[property] = reference; + } + } + }; +} + // Morph dragging and dropping: Morph.prototype.rootForGrab = function () { -- cgit v1.3.1 From aaa3c407bc54e61ba2944f97956a89bf76ad22d1 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 21:11:04 -0400 Subject: Add a missing super call in overridden updateReferences() --- morphic.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/morphic.js b/morphic.js index fe2cc8b..0b20eb5 100644 --- a/morphic.js +++ b/morphic.js @@ -8895,8 +8895,9 @@ ScrollFrameMorph.prototype.mouseScroll = function (y, x) { // ScrollFrameMorph duplicating: -ScrollFrameMorph.prototype.updateReferences = function () { +ScrollFrameMorph.prototype.updateReferences = function (map) { var self = this; + ScrollFrameMorph.uber.updateReferences.call(this, map); if (this.hBar) { this.hBar.action = function (num) { self.contents.setPosition( -- cgit v1.3.1 From 836b5d3fd04c4438241c5f53078da2b36f54a9b1 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 21:56:09 -0400 Subject: Add missing init() super calls in paint.js --- paint.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/paint.js b/paint.js index b4c55b1..6e4ae8b 100644 --- a/paint.js +++ b/paint.js @@ -92,6 +92,7 @@ function PaintEditorMorph() { } PaintEditorMorph.prototype.init = function () { + PaintEditorMorph.uber.init.call(this); // additional properties: this.paper = null; // paint canvas this.oncancel = null; @@ -485,6 +486,7 @@ 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(); @@ -561,6 +563,7 @@ 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; @@ -961,6 +964,7 @@ 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); -- cgit v1.3.1 From 95a815b6d63b57f46a72be25b9723366f4af76bd Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 22:21:23 -0400 Subject: Don't redraw label parts unnecessarily --- blocks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocks.js b/blocks.js index d2a395a..6c10354 100644 --- a/blocks.js +++ b/blocks.js @@ -2062,7 +2062,7 @@ BlockMorph.prototype.setSpec = function (spec) { } part = myself.labelPart(word); myself.add(part); - if (!(part instanceof CommandSlotMorph)) { + if (!(part instanceof CommandSlotMorph || part instanceof StringMorph)) { part.drawNew(); } if (part instanceof RingMorph) { -- cgit v1.3.1 From 0245a81fc04cf787bae2f3467f850a07d9791ca7 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Wed, 17 Jun 2015 23:05:34 -0400 Subject: Optimize loading projects a bit more --- blocks.js | 63 ++++++++++++++++++++++++++++++++------------------------------ morphic.js | 6 +++--- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/blocks.js b/blocks.js index 6c10354..8aad311 100644 --- a/blocks.js +++ b/blocks.js @@ -1421,16 +1421,19 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { new Point() : this.embossing; part.drawNew(); } else { - part = new StringMorph(spec); - part.fontName = this.labelFontName; - part.fontStyle = this.labelFontStyle; - part.fontSize = this.fontSize; - part.color = new Color(255, 255, 255); - part.isBold = true; - part.shadowColor = this.color.darker(this.labelContrast); - part.shadowOffset = MorphicPreferences.isFlat ? - new Point() : this.embossing; - part.drawNew(); + part = new StringMorph( + spec, // text + this.fontSize, // fontSize + this.labelFontStyle, // fontStyle + true, // bold + false, // italic + false, // isNumeric + MorphicPreferences.isFlat ? + new Point() : this.embossing, // shadowOffset + this.color.darker(this.labelContrast), // shadowColor + new Color(255, 255, 255), // color + this.labelFontName // fontName + ); } return part; }; @@ -6918,7 +6921,8 @@ InputSlotMorph.prototype.setChoices = function (dict, readonly) { // InputSlotMorph layout: InputSlotMorph.prototype.fixLayout = function () { - var contents = this.contents(), + var width, height, arrowWidth, + contents = this.contents(), arrow = this.arrow(); contents.isNumeric = this.isNumeric; @@ -6935,32 +6939,29 @@ InputSlotMorph.prototype.fixLayout = function () { arrow.setSize(this.fontSize); arrow.show(); } else { - arrow.setSize(0); arrow.hide(); } - this.setHeight( - contents.height() - + this.edge * 2 - // + this.typeInPadding * 2 - ); + arrowWidth = arrow.isVisible ? arrow.width() : 0; + + height = contents.height() + this.edge * 2; // + this.typeInPadding * 2 if (this.isNumeric) { - this.setWidth(contents.width() - + Math.floor(arrow.width() * 0.5) + width = contents.width() + + Math.floor(arrowWidth * 0.5) + this.height() - + this.typeInPadding * 2 - ); + + this.typeInPadding * 2; } else { - this.setWidth(Math.max( + width = Math.max( contents.width() - + arrow.width() + + arrowWidth + this.edge * 2 + this.typeInPadding * 2, contents.rawHeight ? // single vs. multi-line contents - contents.rawHeight() + arrow.width() - : contents.height() / 1.2 + arrow.width(), + contents.rawHeight() + arrowWidth + : contents.height() / 1.2 + arrowWidth, this.minWidth // for text-type slots - )); + ); } + this.setExtent(new Point(width, height)); if (this.isNumeric) { contents.setPosition(new Point( Math.floor(this.height() / 2), @@ -6973,10 +6974,12 @@ InputSlotMorph.prototype.fixLayout = function () { ).add(new Point(this.typeInPadding, 0)).add(this.position())); } - arrow.setPosition(new Point( - this.right() - arrow.width() - this.edge, - contents.top() - )); + if (arrow.isVisible) { + arrow.setPosition(new Point( + this.right() - arrowWidth - this.edge, + contents.top() + )); + } if (this.parent) { if (this.parent.fixLayout) { diff --git a/morphic.js b/morphic.js index 0b20eb5..1552d78 100644 --- a/morphic.js +++ b/morphic.js @@ -2199,7 +2199,7 @@ function Morph() { // Morph initialization: -Morph.prototype.init = function () { +Morph.prototype.init = function (noDraw) { Morph.uber.init.call(this); this.isMorph = true; this.bounds = new Rectangle(0, 0, 50, 40); @@ -2212,7 +2212,7 @@ Morph.prototype.init = function () { this.isTemplate = false; this.acceptsDrops = false; this.noticesTransparentClick = false; - this.drawNew(); + if (!noDraw) this.drawNew(); this.fps = 0; this.customContextMenu = null; this.lastTime = Date.now(); @@ -6999,7 +6999,7 @@ StringMorph.prototype.init = function ( this.markedBackgoundColor = new Color(60, 60, 120); // initialize inherited properties: - StringMorph.uber.init.call(this); + StringMorph.uber.init.call(this, true); // override inherited properites: this.color = color || new Color(0, 0, 0); -- cgit v1.3.1 From 995e782147c202a8afa64cabe204849b955f153b Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Thu, 18 Jun 2015 04:29:26 -0400 Subject: Fix ListWatcherMorph initialization --- lists.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lists.js b/lists.js index be7f933..769b8b3 100644 --- a/lists.js +++ b/lists.js @@ -388,6 +388,13 @@ 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(), @@ -436,13 +443,6 @@ 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,6 +634,7 @@ ListWatcherMorph.prototype.setStartIndex = function (index) { }; ListWatcherMorph.prototype.fixLayout = function () { + if (!this.label) return; Morph.prototype.trackChanges = false; if (this.frame) { this.arrangeCells(); -- cgit v1.3.1 From 82197c7a8c1835048fb6a787c41845049c89ca0c Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Thu, 18 Jun 2015 15:33:25 -0400 Subject: Declare some variables earlier --- morphic.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/morphic.js b/morphic.js index 1552d78..9f6e8c2 100644 --- a/morphic.js +++ b/morphic.js @@ -1244,7 +1244,7 @@ function getDocumentPositionOf(aDOMelement) { function copy(target) { // answer a shallow copy of target - var value, c, property; + var value, c, property, keys, l, i; if (typeof target !== 'object') { return target; @@ -1256,8 +1256,8 @@ function copy(target) { if (target instanceof target.constructor && target.constructor !== Object) { c = Object.create(target.constructor.prototype); - var keys = Object.keys(target); - for (var l = keys.length, i = 0; i < l; ++i) { + keys = Object.keys(target); + for (l = keys.length, i = 0; i < l; ++i) { property = keys[i]; c[property] = target[property]; } -- cgit v1.3.1 From bae22f08044f01adba15608d3885e84e173c8889 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Thu, 18 Jun 2015 15:33:36 -0400 Subject: Add braces --- morphic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/morphic.js b/morphic.js index 9f6e8c2..01220d5 100644 --- a/morphic.js +++ b/morphic.js @@ -2212,7 +2212,7 @@ Morph.prototype.init = function (noDraw) { this.isTemplate = false; this.acceptsDrops = false; this.noticesTransparentClick = false; - if (!noDraw) this.drawNew(); + if (!noDraw) { this.drawNew(); } this.fps = 0; this.customContextMenu = null; this.lastTime = Date.now(); -- cgit v1.3.1 From bc79cd8df2b6c62a80bb6850697d368cf9acebd5 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Thu, 18 Jun 2015 15:33:44 -0400 Subject: Call isTransparentAt --- morphic.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/morphic.js b/morphic.js index 01220d5..aa731ab 100644 --- a/morphic.js +++ b/morphic.js @@ -9312,7 +9312,7 @@ Morph.prototype.topMorphAt = function (p) { var result = c[i].topMorphAt(p); if (result) return result; } - return this.bounds.containsPoint(p) ? this : null; + return this.bounds.containsPoint(p) && (this.noticesTransparentClick || !this.isTransparentAt(p)) ? this : null; }; FrameMorph.prototype.topMorphAt = function (p) { if (!(this.isVisible && this.bounds.containsPoint(p))) return null; @@ -9320,13 +9320,13 @@ FrameMorph.prototype.topMorphAt = function (p) { var result = c[i].topMorphAt(p); if (result) return result; } - return this; + return this.noticesTransparentClick || !this.isTransparentAt(p) ? this : null; }; ShadowMorph.prototype.topMorphAt = function () { return null; }; HandMorph.prototype.morphAtPointer = function () { - return this.world.topMorphAt(this.bounds.origin); + return this.world.topMorphAt(this.bounds.origin) || this.world; }; /* @@ -9913,6 +9913,7 @@ WorldMorph.prototype.init = function (aCanvas, fillPage) { this.isDraggable = false; this.currentKey = null; // currently pressed key code this.worldCanvas = aCanvas; + this.noticesTransparentClick = true; // additional properties: this.stamp = Date.now(); // reference in multi-world setups -- cgit v1.3.1 From e1b104948b5162a014fa752f394d0e722664499c Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Thu, 18 Jun 2015 16:05:27 -0400 Subject: Fix InputSlotMorph::fixLayout() --- blocks.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blocks.js b/blocks.js index 8aad311..d023db8 100644 --- a/blocks.js +++ b/blocks.js @@ -6947,7 +6947,7 @@ InputSlotMorph.prototype.fixLayout = function () { if (this.isNumeric) { width = contents.width() + Math.floor(arrowWidth * 0.5) - + this.height() + + height + this.typeInPadding * 2; } else { width = Math.max( @@ -6964,7 +6964,7 @@ InputSlotMorph.prototype.fixLayout = function () { this.setExtent(new Point(width, height)); if (this.isNumeric) { contents.setPosition(new Point( - Math.floor(this.height() / 2), + Math.floor(height / 2), this.edge ).add(new Point(this.typeInPadding, 0)).add(this.position())); } else { -- cgit v1.3.1 From 6fbd2f27896d9cd749d92cc90495c4c4d7ab0ab0 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Thu, 18 Jun 2015 18:35:20 -0400 Subject: Speed up parser About an order of magnitude faster (268.5 ms => 31.3 ms). --- xml.js | 119 +++++++++++++++++------------------------------------------------ 1 file changed, 30 insertions(+), 89 deletions(-) diff --git a/xml.js b/xml.js index d1cdf68..16b03f0 100644 --- a/xml.js +++ b/xml.js @@ -61,7 +61,7 @@ */ -/*global modules, isString, detect, Node, isNil*/ +/*global modules, detect, Node, isNil*/ // Global stuff //////////////////////////////////////////////////////// @@ -85,7 +85,8 @@ function ReadStream(arrayOrString) { // ReadStream constants: -ReadStream.prototype.space = /[\s]/; +ReadStream.prototype.nonSpace = /\S|$/g; +ReadStream.prototype.nonWord = /[\s\>\/\=]|$/g; // ReadStream accessing: @@ -115,46 +116,26 @@ ReadStream.prototype.atEnd = function () { // ReadStream accessing String contents: -ReadStream.prototype.upTo = function (regex) { - var i, start; - if (!isString(this.contents)) {return ''; } - i = this.contents.substr(this.index).search(regex); - if (i === -1) { - return ''; - } - start = this.index; - this.index += i; - return this.contents.substring(start, this.index); +ReadStream.prototype.upTo = function (str) { + var i = this.contents.indexOf(str, this.index); + return i === -1 ? '' : this.contents.slice(this.index, this.index = i); }; -ReadStream.prototype.peekUpTo = function (regex) { - if (!isString(this.contents)) {return ''; } - var i = this.contents.substr(this.index).search(regex); - if (i === -1) { - return ''; - } - return this.contents.substring(this.index, this.index + i); +ReadStream.prototype.peekUpTo = function (str) { + var i = this.contents.indexOf(str, this.index); + return i === -1 ? '' : this.contents.slice(this.index, i); }; ReadStream.prototype.skipSpace = function () { - if (!isString(this.contents)) {return ''; } - var ch = this.peek(); - while (this.space.test(ch) && ch !== '') { - this.skip(); - ch = this.peek(); - } + this.nonSpace.lastIndex = this.index; + var result = this.nonSpace.exec(this.contents); + if (result) this.index = result.index; }; ReadStream.prototype.word = function () { - var i, start; - if (!isString(this.contents)) {return ''; } - i = this.contents.substr(this.index).search(/[\s\>\/\=]|$/); - if (i === -1) { - return ''; - } - start = this.index; - this.index += i; - return this.contents.substring(start, this.index); + this.nonWord.lastIndex = this.index; + var result = this.nonWord.exec(this.contents); + return result ? this.contents.slice(this.index, this.index = result.index) : ''; }; // XML_Element /////////////////////////////////////////////////////////// @@ -190,9 +171,7 @@ XML_Element.prototype.init = function (tag, contents, parent) { XML_Element.uber.init.call(this); // override inherited properties - if (parent instanceof XML_Element) { - parent.addChild(this); - } + if (parent) parent.addChild(this); }; // XML_Element DOM navigation: (aside from what's inherited from Node) @@ -318,51 +297,18 @@ XML_Element.prototype.escape = function (string, ignoreQuotes) { }; XML_Element.prototype.unescape = function (string) { - var stream = new ReadStream(string), - result = '', - ch, - esc; - - function nextPut(str) { - result += str; - stream.upTo(';'); - stream.skip(); - } - - while (!stream.atEnd()) { - ch = stream.next(); - if (ch === '&') { - esc = stream.peekUpTo(';'); - switch (esc) { - case 'apos': - nextPut('\''); - break; - case 'quot': - nextPut('\"'); - break; - case 'lt': - nextPut('<'); - break; - case 'gt': - nextPut('>'); - break; - case 'amp': - nextPut('&'); - break; - case '#xD': - nextPut('\n'); - break; - case '#126': - nextPut('~'); - break; - default: - result += ch; - } - } else { - result += ch; + return string.replace(/&(amp|apos|quot|lt|gt|#xD|#126);/g, function(_, name) { + switch (name) { + case 'amp': return '&'; + case 'apos': return '\''; + case 'quot': return '"'; + case 'lt': return '<'; + case 'gt': return '>'; + case '#xD': return '\n'; + case '#126': return '~'; + default: console.warn('unreachable'); } - } - return result; + }); }; // XML_Element parsing: @@ -375,10 +321,7 @@ XML_Element.prototype.parseString = function (string) { }; XML_Element.prototype.parseStream = function (stream) { - var key, - value, - ch, - child; + var key, value, ch, child; // tag: this.tag = stream.word(); @@ -395,9 +338,7 @@ XML_Element.prototype.parseStream = function (stream) { stream.skipSpace(); ch = stream.next(); if (ch !== '"' && ch !== "'") { - throw new Error( - 'Expected single- or double-quoted attribute value' - ); + throw new Error('Expected single- or double-quoted attribute value'); } value = stream.upTo(ch); stream.skip(1); @@ -407,7 +348,7 @@ XML_Element.prototype.parseStream = function (stream) { } // empty tag: - if (stream.peek() === '/') { + if (ch === '/') { stream.skip(); if (stream.next() !== '>') { throw new Error('Expected ">" after "/" in empty tag'); -- cgit v1.3.1 From 3aa17f2430c422f59bd50f742ee49d1d86fbcef9 Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Wed, 24 Jun 2015 01:03:12 +0200 Subject: Initial commit for the LaTeX version of the manual --- help/manual/.gitignore | 5 + help/manual/move-10-steps.png | Bin 0 -> 2595 bytes help/manual/snap-manual.tex | 182 +++++++++++++++++++++++++++++++++++ help/manual/snapping-blocks.png | Bin 0 -> 12054 bytes help/manual/typical-script-inner.png | Bin 0 -> 4610 bytes help/manual/typical-script.png | Bin 0 -> 11063 bytes help/manual/window-regions.png | Bin 0 -> 142052 bytes 7 files changed, 187 insertions(+) create mode 100644 help/manual/.gitignore create mode 100644 help/manual/move-10-steps.png create mode 100644 help/manual/snap-manual.tex create mode 100644 help/manual/snapping-blocks.png create mode 100644 help/manual/typical-script-inner.png create mode 100644 help/manual/typical-script.png create mode 100644 help/manual/window-regions.png diff --git a/help/manual/.gitignore b/help/manual/.gitignore new file mode 100644 index 0000000..4c0ef4d --- /dev/null +++ b/help/manual/.gitignore @@ -0,0 +1,5 @@ +*.aux +*.log +*.out +*.toc +*.pdf diff --git a/help/manual/move-10-steps.png b/help/manual/move-10-steps.png new file mode 100644 index 0000000..3d276da Binary files /dev/null and b/help/manual/move-10-steps.png differ diff --git a/help/manual/snap-manual.tex b/help/manual/snap-manual.tex new file mode 100644 index 0000000..6ca387c --- /dev/null +++ b/help/manual/snap-manual.tex @@ -0,0 +1,182 @@ +\documentclass{report} + +\usepackage{baskervald} % Default font +\usepackage{cabin} % Sans serif font +\usepackage[T1]{fontenc} +\usepackage{setspace} \onehalfspacing +\usepackage{graphicx} +\usepackage{textcomp} +\usepackage{hyperref} + +\newcommand{\Snap}{{\sf Snap{\it !}}} +\newcommand{\code}[1]{\textsf{#1}} +\newcommand{\defaultGraphicsScale}{0.6} + +\newcommand{\inlinepic}[1]{% + \raisebox{-4pt}{% + \includegraphics[scale=\defaultGraphicsScale]{#1}% + }% +} + +\newcommand{\bigpic}[1]{ + \begin{center} + \includegraphics[scale=\defaultGraphicsScale]{#1} + \end{center} +} + + +\renewcommand{\thechapter}{\Roman{chapter}} +\renewcommand{\thesection}{\Alph{section}} +\renewcommand{\thesubsection}{} + +\begin{document} + +\title{\Snap{} Reference Manual} +\author{Brian Harvey \and Jens M\"{o}nig} +\date{} + +\maketitle + +\tableofcontents + +\chapter*{} +\section*{Acknowledgements} + +We have been extremely lucky in our mentors. Jens cut his teeth in the company of the Smalltalk pioneers: Alan Kay, Dan Ingalls, and the rest of the gang who invented personal computing and object oriented programming in the great days of Xerox PARC. He worked with John Maloney, of the MIT Scratch Team, who developed the Morphic graphics framework that's still at the heart of \Snap{}. The brilliant design of Scratch, from the Lifelong Kindergarten Group at the MIT Media Lab, is crucial to \Snap{}. + +{\bf\em Our earlier version, BYOB, was a direct modification of the Scratch source code. \Snap{} is a complete rewrite, but its code structure and its user interface remain deeply indebted to Scratch. And the Scratch Team, who could have seen us as rivals, have been entirely supportive and welcoming to us.} + +Brian grew up at the MIT and Stanford Artificial Intelligence Labs, learning from Lisp inventor John McCarthy, Scheme inventors Gerald J. Sussman and Guy Steele, and the authors of the world's best computer science book, \emph{Structure and Interpretation of Computer Programs}, Hal Abelson and Gerald J. Sussman with Julie Sussman, among many other heroes of computer science. + +{\bf\em In the glory days of the MIT Logo Lab, we used to say, ``Logo is Lisp disguised as BASIC.'' Now, with its first class procedures, lexical scope, and first class continuations, \Snap{} is Scheme disguised as Scratch.} + +We have been fortunate to get to know an amazing group of brilliant middle school(!) and high school students through the Scratch Advanced Topics forum, several of whom have contributed code to \Snap{}: Kartik Chandra, Nathan Dinsmore, Connor Hudson, and Ian Reynolds. Many more have contributed ideas and alpha-testing bug reports. UC Berkeley students who've contributed code include Michael Ball, Achal Dave. Kyle Hotchkiss, Ivan Motyashov, and Yuan Yuan. Contributors of translations are too numerous to list here, but they're in the ``About...'' box in \Snap{} itself. This work was supported in part by the National Science Foundation grant 1143566, and in part by MioSoft. + +\begin{titlepage} + +\begin{center} +\bf \Huge \Snap{} Reference Manual \\ \huge Version 4.0 \vspace{40pt} +\end{center} + +\Snap{} (formerly BYOB) is an extended reimplementation of Scratch (\url{http://scratch.mit.edu}) that allows you to Build Your Own Blocks. It also features first class lists, first class procedures, and continuations. These added capabilities make it suitable for a serious introduction to computer science for high school or college students. To run \Snap{}, open a browser window and connect to either \url{http://snap.berkeley.edu/run} to start with a minimal set of blocks or \url{http://snap.berkeley.edu/init} to load a small set of additional blocks (a little slower startup, but recommended for convenience and assumed in this manual). + +\end{titlepage} + +\chapter{Blocks, Scripts, and Sprites} + +This chapter describes the \Snap{} features inherited from Scratch; experienced Scratch users can skip to section B. + +\Snap{} is a programming language---a notation in which you can tell a computer what you want it to do. Unlike most programming languages, though, \Snap{} is a visual language; instead of writing a program using the keyboard, the \Snap{} programmer uses the same drag-and-drop interface familiar to computer users. + +Start \Snap{}. You should see the following arrangement of regions in the window: + +\begin{center} +\includegraphics[width=\textwidth]{window-regions} +\end{center} + +(The proportions of these areas may be different, depending on the size and shape of your browser window.) + +A \Snap{} program consists of one or more \emph{scripts}, each of which is made of \emph{blocks}. Here's a typical script: + +\bigpic{typical-script} + +The five blocks that make up this script have three different colors, corresponding to three of the eight \emph{palettes} in which blocks can be found. The palette area at the left edge of the window shows one palette at a time, chosen with the eight buttons just above the palette area. In this script, the gold blocks are from the Control palette; the green block is from the Pen palette; and the blue blocks are from the Motion palette. A script is assembled by dragging blocks from a palette into the \emph{scripting area} in the middle part of the window. Blocks snap together (hence the name \Snap{} for the language) when you drag a block so that its indentation is near the tab of the one above it: + +\bigpic{snapping-blocks} + +The white horizontal line is a signal that if you let go of the green block it will snap into the tab of the gold one. + +\subsection{Hat Blocks and Command Blocks} + +At the top of the script is a \emph{hat} block, which indicates when the script should be carried out. Hat block names typically start with the word ``\code{when}''; in this example, the script should be run when the green flag near the right end of the \Snap{} tool bar is clicked. (The \Snap{} tool bar is part of the \Snap{} window, not the same as the browser's or operating system's menu bar.) A script isn't required to have a hat block, but if not, then the script will be run only if the user clicks on the script itself. A script can't have more than one hat block, and the hat block can be used only at the top of the script; its distinctive shape is meant to remind you of that. + +The other blocks in this script are \emph{command} blocks. Each command block corresponds to an action that \Snap{} already knows how to carry out. For example, the block \inlinepic{move-10-steps} tells the sprite (the arrowhead shape on the \emph{stage} at the right end of the window) to move ten steps (a step is a very small unit of distance) in the direction in which the arrowhead is pointing. We'll see shortly that there can be more than one sprite, and that each sprite has its own scripts. Also, a sprite doesn't have to look like an arrowhead, but can have any picture as a costume. The shape of the \code{move} block is meant to remind you of a Lego\texttrademark{} brick; a script is a stack of blocks. (The word ``block'' denotes both the graphical shape on the screen and the procedure, the action, that the block carries out.) + +The number 10 in the \code{move} block above is called an \emph{input} to the block. By clicking on the white oval, you can type any number in place of the 10. The sample script on the previous page uses 100 as the input value. We'll see later that inputs can have non-oval shapes that accept values other than numbers. We'll also see that you can compute input values, instead of typing a particular value into the oval. A block can have more than one input slot. For example, the \code{glide} block located about halfway down the Motion palette has three inputs. + +Most command blocks have that brick shape, but some, like the \code{repeat} block in the sample script, are \emph{C-shaped}. Most C-shaped blocks are found in the Control palette. The slot inside the C shape is a special kind of input slot that accepts a \emph{script} as the input. In the sample script, the \code{repeat} block has two inputs: the number 4 and the script + +\bigpic{typical-script-inner} + + + +\section{Sprites and Parallelism} +\subsection{Costumes and Sounds} +\subsection{Inter-Sprite Communication with Broadcast} +\section{Nesting Sprites: Anchors and Parts} +\section{Reporter Blocks and Expressions} +\section{Predicates and Conditional Evaluation} +\section{Variables} +\subsection{Global Variables} +\subsection{Script Variables} +\section{Etcetera} +\chapter{Saving and Loading Projects and Media} +\section{Local Storage} +\subsection{Localstore} +\subsection{XML Export} +\section{Cloud Storage} +\section{Loading Saved Projects} +\chapter{Building a Block} +\section{Simple Blocks} +\subsection{Custom Blocks with Inputs} +\section{Recursion} +\section{Block Libraries} +\chapter{First Class Lists} +\section{The list Block} +\section{Lists of Lists} +\section{Functional and Imperative List Programming} +\section{Higher Order List Operations and Rings} +\chapter{Typed Inputs} +\section{Scratch's Type Notation} +\section{The \Snap{} Input Type Dialog} +\subsection{Procedure Types} +\subsection{Pulldown inputs} +\subsection{Input variants} +\subsection{Prototype Hints} +\subsection{Title Text and Symbols} +\chapter{Procedures as Data} +\section{Call and Run} +\subsection{Call/Run with inputs} +\subsection{Variables in Ring Slots} +\section{Writing Higher Order Procedures} +\subsection{Recursive Calls to Multiple-Input Blocks} +\section{Formal Parameters} +\section{Procedures as Data} +\section{Special Forms} +\subsection{Special Forms in Scratch} +\chapter{Object Oriented Programming} +\section{Local State with Script Variables} +\section{Messages and Dispatch Procedures} +\section{Inheritance via Delegation} +\section{An Implementation of Prototyping OOP} +\chapter{The Outside World} +\section{The World Wide Web} +\section{Hardware Devices} +\section{Date and Time} +\chapter{Continuations} +\section{Continuation Passing Style} +\section{Call/Run w/Continuation} +\subsection{Nonlocal exit} +\chapter{User Interface Elements} +\section{Tool Bar Features} +\subsection{The \Snap{} Logo Menu} +\subsection{The File Menu} +\subsection{The Cloud Menu} +\subsection{The Settings Menu} +\subsection{Stage Resizing Buttons} +\subsection{Project Control Buttons} +\section{The Palette Area} +\subsection{Context Menus for Palette Blocks} +\subsection{Context Menu for the Palette Background} +\section{The Scripting Area} +\subsection{Sprite Appearance and Behavior Controls} +\subsection{Scripting Area Tabs} +\subsection{Scripts and Blocks Within Scripts} +\subsection{Scripting Area Background Context Menu} +\subsection{Controls in the Costumes Tab} +\subsection{The Paint Editor} +\subsection{Controls in the Sounds Tab} +\section{Controls on the Stage} +\section{The Sprite Corral and Sprite Creation Buttons} + +\end{document} diff --git a/help/manual/snapping-blocks.png b/help/manual/snapping-blocks.png new file mode 100644 index 0000000..0dc5922 Binary files /dev/null and b/help/manual/snapping-blocks.png differ diff --git a/help/manual/typical-script-inner.png b/help/manual/typical-script-inner.png new file mode 100644 index 0000000..b5503f7 Binary files /dev/null and b/help/manual/typical-script-inner.png differ diff --git a/help/manual/typical-script.png b/help/manual/typical-script.png new file mode 100644 index 0000000..6763aad Binary files /dev/null and b/help/manual/typical-script.png differ diff --git a/help/manual/window-regions.png b/help/manual/window-regions.png new file mode 100644 index 0000000..7fe4e98 Binary files /dev/null and b/help/manual/window-regions.png differ -- cgit v1.3.1 From 5944c36d5598db663df1af74e212662843eb0dc1 Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Wed, 24 Jun 2015 01:14:59 +0200 Subject: Update .gitignore --- help/manual/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/help/manual/.gitignore b/help/manual/.gitignore index 4c0ef4d..a0bdfac 100644 --- a/help/manual/.gitignore +++ b/help/manual/.gitignore @@ -3,3 +3,4 @@ *.out *.toc *.pdf +*.synctex.gz -- cgit v1.3.1 From b08f7bad1b00e26df910d0fbbfdfe86aded8abec Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Wed, 24 Jun 2015 01:17:46 +0200 Subject: Move the manual to English subdirectory --- help/manual/en/move-10-steps.png | Bin 0 -> 2595 bytes help/manual/en/snap-manual.tex | 182 ++++++++++++++++++++++++++++++++ help/manual/en/snapping-blocks.png | Bin 0 -> 12054 bytes help/manual/en/typical-script-inner.png | Bin 0 -> 4610 bytes help/manual/en/typical-script.png | Bin 0 -> 11063 bytes help/manual/en/window-regions.png | Bin 0 -> 142052 bytes help/manual/move-10-steps.png | Bin 2595 -> 0 bytes help/manual/snap-manual.tex | 182 -------------------------------- help/manual/snapping-blocks.png | Bin 12054 -> 0 bytes help/manual/typical-script-inner.png | Bin 4610 -> 0 bytes help/manual/typical-script.png | Bin 11063 -> 0 bytes help/manual/window-regions.png | Bin 142052 -> 0 bytes 12 files changed, 182 insertions(+), 182 deletions(-) create mode 100644 help/manual/en/move-10-steps.png create mode 100644 help/manual/en/snap-manual.tex create mode 100644 help/manual/en/snapping-blocks.png create mode 100644 help/manual/en/typical-script-inner.png create mode 100644 help/manual/en/typical-script.png create mode 100644 help/manual/en/window-regions.png delete mode 100644 help/manual/move-10-steps.png delete mode 100644 help/manual/snap-manual.tex delete mode 100644 help/manual/snapping-blocks.png delete mode 100644 help/manual/typical-script-inner.png delete mode 100644 help/manual/typical-script.png delete mode 100644 help/manual/window-regions.png diff --git a/help/manual/en/move-10-steps.png b/help/manual/en/move-10-steps.png new file mode 100644 index 0000000..3d276da Binary files /dev/null and b/help/manual/en/move-10-steps.png differ diff --git a/help/manual/en/snap-manual.tex b/help/manual/en/snap-manual.tex new file mode 100644 index 0000000..6ca387c --- /dev/null +++ b/help/manual/en/snap-manual.tex @@ -0,0 +1,182 @@ +\documentclass{report} + +\usepackage{baskervald} % Default font +\usepackage{cabin} % Sans serif font +\usepackage[T1]{fontenc} +\usepackage{setspace} \onehalfspacing +\usepackage{graphicx} +\usepackage{textcomp} +\usepackage{hyperref} + +\newcommand{\Snap}{{\sf Snap{\it !}}} +\newcommand{\code}[1]{\textsf{#1}} +\newcommand{\defaultGraphicsScale}{0.6} + +\newcommand{\inlinepic}[1]{% + \raisebox{-4pt}{% + \includegraphics[scale=\defaultGraphicsScale]{#1}% + }% +} + +\newcommand{\bigpic}[1]{ + \begin{center} + \includegraphics[scale=\defaultGraphicsScale]{#1} + \end{center} +} + + +\renewcommand{\thechapter}{\Roman{chapter}} +\renewcommand{\thesection}{\Alph{section}} +\renewcommand{\thesubsection}{} + +\begin{document} + +\title{\Snap{} Reference Manual} +\author{Brian Harvey \and Jens M\"{o}nig} +\date{} + +\maketitle + +\tableofcontents + +\chapter*{} +\section*{Acknowledgements} + +We have been extremely lucky in our mentors. Jens cut his teeth in the company of the Smalltalk pioneers: Alan Kay, Dan Ingalls, and the rest of the gang who invented personal computing and object oriented programming in the great days of Xerox PARC. He worked with John Maloney, of the MIT Scratch Team, who developed the Morphic graphics framework that's still at the heart of \Snap{}. The brilliant design of Scratch, from the Lifelong Kindergarten Group at the MIT Media Lab, is crucial to \Snap{}. + +{\bf\em Our earlier version, BYOB, was a direct modification of the Scratch source code. \Snap{} is a complete rewrite, but its code structure and its user interface remain deeply indebted to Scratch. And the Scratch Team, who could have seen us as rivals, have been entirely supportive and welcoming to us.} + +Brian grew up at the MIT and Stanford Artificial Intelligence Labs, learning from Lisp inventor John McCarthy, Scheme inventors Gerald J. Sussman and Guy Steele, and the authors of the world's best computer science book, \emph{Structure and Interpretation of Computer Programs}, Hal Abelson and Gerald J. Sussman with Julie Sussman, among many other heroes of computer science. + +{\bf\em In the glory days of the MIT Logo Lab, we used to say, ``Logo is Lisp disguised as BASIC.'' Now, with its first class procedures, lexical scope, and first class continuations, \Snap{} is Scheme disguised as Scratch.} + +We have been fortunate to get to know an amazing group of brilliant middle school(!) and high school students through the Scratch Advanced Topics forum, several of whom have contributed code to \Snap{}: Kartik Chandra, Nathan Dinsmore, Connor Hudson, and Ian Reynolds. Many more have contributed ideas and alpha-testing bug reports. UC Berkeley students who've contributed code include Michael Ball, Achal Dave. Kyle Hotchkiss, Ivan Motyashov, and Yuan Yuan. Contributors of translations are too numerous to list here, but they're in the ``About...'' box in \Snap{} itself. This work was supported in part by the National Science Foundation grant 1143566, and in part by MioSoft. + +\begin{titlepage} + +\begin{center} +\bf \Huge \Snap{} Reference Manual \\ \huge Version 4.0 \vspace{40pt} +\end{center} + +\Snap{} (formerly BYOB) is an extended reimplementation of Scratch (\url{http://scratch.mit.edu}) that allows you to Build Your Own Blocks. It also features first class lists, first class procedures, and continuations. These added capabilities make it suitable for a serious introduction to computer science for high school or college students. To run \Snap{}, open a browser window and connect to either \url{http://snap.berkeley.edu/run} to start with a minimal set of blocks or \url{http://snap.berkeley.edu/init} to load a small set of additional blocks (a little slower startup, but recommended for convenience and assumed in this manual). + +\end{titlepage} + +\chapter{Blocks, Scripts, and Sprites} + +This chapter describes the \Snap{} features inherited from Scratch; experienced Scratch users can skip to section B. + +\Snap{} is a programming language---a notation in which you can tell a computer what you want it to do. Unlike most programming languages, though, \Snap{} is a visual language; instead of writing a program using the keyboard, the \Snap{} programmer uses the same drag-and-drop interface familiar to computer users. + +Start \Snap{}. You should see the following arrangement of regions in the window: + +\begin{center} +\includegraphics[width=\textwidth]{window-regions} +\end{center} + +(The proportions of these areas may be different, depending on the size and shape of your browser window.) + +A \Snap{} program consists of one or more \emph{scripts}, each of which is made of \emph{blocks}. Here's a typical script: + +\bigpic{typical-script} + +The five blocks that make up this script have three different colors, corresponding to three of the eight \emph{palettes} in which blocks can be found. The palette area at the left edge of the window shows one palette at a time, chosen with the eight buttons just above the palette area. In this script, the gold blocks are from the Control palette; the green block is from the Pen palette; and the blue blocks are from the Motion palette. A script is assembled by dragging blocks from a palette into the \emph{scripting area} in the middle part of the window. Blocks snap together (hence the name \Snap{} for the language) when you drag a block so that its indentation is near the tab of the one above it: + +\bigpic{snapping-blocks} + +The white horizontal line is a signal that if you let go of the green block it will snap into the tab of the gold one. + +\subsection{Hat Blocks and Command Blocks} + +At the top of the script is a \emph{hat} block, which indicates when the script should be carried out. Hat block names typically start with the word ``\code{when}''; in this example, the script should be run when the green flag near the right end of the \Snap{} tool bar is clicked. (The \Snap{} tool bar is part of the \Snap{} window, not the same as the browser's or operating system's menu bar.) A script isn't required to have a hat block, but if not, then the script will be run only if the user clicks on the script itself. A script can't have more than one hat block, and the hat block can be used only at the top of the script; its distinctive shape is meant to remind you of that. + +The other blocks in this script are \emph{command} blocks. Each command block corresponds to an action that \Snap{} already knows how to carry out. For example, the block \inlinepic{move-10-steps} tells the sprite (the arrowhead shape on the \emph{stage} at the right end of the window) to move ten steps (a step is a very small unit of distance) in the direction in which the arrowhead is pointing. We'll see shortly that there can be more than one sprite, and that each sprite has its own scripts. Also, a sprite doesn't have to look like an arrowhead, but can have any picture as a costume. The shape of the \code{move} block is meant to remind you of a Lego\texttrademark{} brick; a script is a stack of blocks. (The word ``block'' denotes both the graphical shape on the screen and the procedure, the action, that the block carries out.) + +The number 10 in the \code{move} block above is called an \emph{input} to the block. By clicking on the white oval, you can type any number in place of the 10. The sample script on the previous page uses 100 as the input value. We'll see later that inputs can have non-oval shapes that accept values other than numbers. We'll also see that you can compute input values, instead of typing a particular value into the oval. A block can have more than one input slot. For example, the \code{glide} block located about halfway down the Motion palette has three inputs. + +Most command blocks have that brick shape, but some, like the \code{repeat} block in the sample script, are \emph{C-shaped}. Most C-shaped blocks are found in the Control palette. The slot inside the C shape is a special kind of input slot that accepts a \emph{script} as the input. In the sample script, the \code{repeat} block has two inputs: the number 4 and the script + +\bigpic{typical-script-inner} + + + +\section{Sprites and Parallelism} +\subsection{Costumes and Sounds} +\subsection{Inter-Sprite Communication with Broadcast} +\section{Nesting Sprites: Anchors and Parts} +\section{Reporter Blocks and Expressions} +\section{Predicates and Conditional Evaluation} +\section{Variables} +\subsection{Global Variables} +\subsection{Script Variables} +\section{Etcetera} +\chapter{Saving and Loading Projects and Media} +\section{Local Storage} +\subsection{Localstore} +\subsection{XML Export} +\section{Cloud Storage} +\section{Loading Saved Projects} +\chapter{Building a Block} +\section{Simple Blocks} +\subsection{Custom Blocks with Inputs} +\section{Recursion} +\section{Block Libraries} +\chapter{First Class Lists} +\section{The list Block} +\section{Lists of Lists} +\section{Functional and Imperative List Programming} +\section{Higher Order List Operations and Rings} +\chapter{Typed Inputs} +\section{Scratch's Type Notation} +\section{The \Snap{} Input Type Dialog} +\subsection{Procedure Types} +\subsection{Pulldown inputs} +\subsection{Input variants} +\subsection{Prototype Hints} +\subsection{Title Text and Symbols} +\chapter{Procedures as Data} +\section{Call and Run} +\subsection{Call/Run with inputs} +\subsection{Variables in Ring Slots} +\section{Writing Higher Order Procedures} +\subsection{Recursive Calls to Multiple-Input Blocks} +\section{Formal Parameters} +\section{Procedures as Data} +\section{Special Forms} +\subsection{Special Forms in Scratch} +\chapter{Object Oriented Programming} +\section{Local State with Script Variables} +\section{Messages and Dispatch Procedures} +\section{Inheritance via Delegation} +\section{An Implementation of Prototyping OOP} +\chapter{The Outside World} +\section{The World Wide Web} +\section{Hardware Devices} +\section{Date and Time} +\chapter{Continuations} +\section{Continuation Passing Style} +\section{Call/Run w/Continuation} +\subsection{Nonlocal exit} +\chapter{User Interface Elements} +\section{Tool Bar Features} +\subsection{The \Snap{} Logo Menu} +\subsection{The File Menu} +\subsection{The Cloud Menu} +\subsection{The Settings Menu} +\subsection{Stage Resizing Buttons} +\subsection{Project Control Buttons} +\section{The Palette Area} +\subsection{Context Menus for Palette Blocks} +\subsection{Context Menu for the Palette Background} +\section{The Scripting Area} +\subsection{Sprite Appearance and Behavior Controls} +\subsection{Scripting Area Tabs} +\subsection{Scripts and Blocks Within Scripts} +\subsection{Scripting Area Background Context Menu} +\subsection{Controls in the Costumes Tab} +\subsection{The Paint Editor} +\subsection{Controls in the Sounds Tab} +\section{Controls on the Stage} +\section{The Sprite Corral and Sprite Creation Buttons} + +\end{document} diff --git a/help/manual/en/snapping-blocks.png b/help/manual/en/snapping-blocks.png new file mode 100644 index 0000000..0dc5922 Binary files /dev/null and b/help/manual/en/snapping-blocks.png differ diff --git a/help/manual/en/typical-script-inner.png b/help/manual/en/typical-script-inner.png new file mode 100644 index 0000000..b5503f7 Binary files /dev/null and b/help/manual/en/typical-script-inner.png differ diff --git a/help/manual/en/typical-script.png b/help/manual/en/typical-script.png new file mode 100644 index 0000000..6763aad Binary files /dev/null and b/help/manual/en/typical-script.png differ diff --git a/help/manual/en/window-regions.png b/help/manual/en/window-regions.png new file mode 100644 index 0000000..7fe4e98 Binary files /dev/null and b/help/manual/en/window-regions.png differ diff --git a/help/manual/move-10-steps.png b/help/manual/move-10-steps.png deleted file mode 100644 index 3d276da..0000000 Binary files a/help/manual/move-10-steps.png and /dev/null differ diff --git a/help/manual/snap-manual.tex b/help/manual/snap-manual.tex deleted file mode 100644 index 6ca387c..0000000 --- a/help/manual/snap-manual.tex +++ /dev/null @@ -1,182 +0,0 @@ -\documentclass{report} - -\usepackage{baskervald} % Default font -\usepackage{cabin} % Sans serif font -\usepackage[T1]{fontenc} -\usepackage{setspace} \onehalfspacing -\usepackage{graphicx} -\usepackage{textcomp} -\usepackage{hyperref} - -\newcommand{\Snap}{{\sf Snap{\it !}}} -\newcommand{\code}[1]{\textsf{#1}} -\newcommand{\defaultGraphicsScale}{0.6} - -\newcommand{\inlinepic}[1]{% - \raisebox{-4pt}{% - \includegraphics[scale=\defaultGraphicsScale]{#1}% - }% -} - -\newcommand{\bigpic}[1]{ - \begin{center} - \includegraphics[scale=\defaultGraphicsScale]{#1} - \end{center} -} - - -\renewcommand{\thechapter}{\Roman{chapter}} -\renewcommand{\thesection}{\Alph{section}} -\renewcommand{\thesubsection}{} - -\begin{document} - -\title{\Snap{} Reference Manual} -\author{Brian Harvey \and Jens M\"{o}nig} -\date{} - -\maketitle - -\tableofcontents - -\chapter*{} -\section*{Acknowledgements} - -We have been extremely lucky in our mentors. Jens cut his teeth in the company of the Smalltalk pioneers: Alan Kay, Dan Ingalls, and the rest of the gang who invented personal computing and object oriented programming in the great days of Xerox PARC. He worked with John Maloney, of the MIT Scratch Team, who developed the Morphic graphics framework that's still at the heart of \Snap{}. The brilliant design of Scratch, from the Lifelong Kindergarten Group at the MIT Media Lab, is crucial to \Snap{}. - -{\bf\em Our earlier version, BYOB, was a direct modification of the Scratch source code. \Snap{} is a complete rewrite, but its code structure and its user interface remain deeply indebted to Scratch. And the Scratch Team, who could have seen us as rivals, have been entirely supportive and welcoming to us.} - -Brian grew up at the MIT and Stanford Artificial Intelligence Labs, learning from Lisp inventor John McCarthy, Scheme inventors Gerald J. Sussman and Guy Steele, and the authors of the world's best computer science book, \emph{Structure and Interpretation of Computer Programs}, Hal Abelson and Gerald J. Sussman with Julie Sussman, among many other heroes of computer science. - -{\bf\em In the glory days of the MIT Logo Lab, we used to say, ``Logo is Lisp disguised as BASIC.'' Now, with its first class procedures, lexical scope, and first class continuations, \Snap{} is Scheme disguised as Scratch.} - -We have been fortunate to get to know an amazing group of brilliant middle school(!) and high school students through the Scratch Advanced Topics forum, several of whom have contributed code to \Snap{}: Kartik Chandra, Nathan Dinsmore, Connor Hudson, and Ian Reynolds. Many more have contributed ideas and alpha-testing bug reports. UC Berkeley students who've contributed code include Michael Ball, Achal Dave. Kyle Hotchkiss, Ivan Motyashov, and Yuan Yuan. Contributors of translations are too numerous to list here, but they're in the ``About...'' box in \Snap{} itself. This work was supported in part by the National Science Foundation grant 1143566, and in part by MioSoft. - -\begin{titlepage} - -\begin{center} -\bf \Huge \Snap{} Reference Manual \\ \huge Version 4.0 \vspace{40pt} -\end{center} - -\Snap{} (formerly BYOB) is an extended reimplementation of Scratch (\url{http://scratch.mit.edu}) that allows you to Build Your Own Blocks. It also features first class lists, first class procedures, and continuations. These added capabilities make it suitable for a serious introduction to computer science for high school or college students. To run \Snap{}, open a browser window and connect to either \url{http://snap.berkeley.edu/run} to start with a minimal set of blocks or \url{http://snap.berkeley.edu/init} to load a small set of additional blocks (a little slower startup, but recommended for convenience and assumed in this manual). - -\end{titlepage} - -\chapter{Blocks, Scripts, and Sprites} - -This chapter describes the \Snap{} features inherited from Scratch; experienced Scratch users can skip to section B. - -\Snap{} is a programming language---a notation in which you can tell a computer what you want it to do. Unlike most programming languages, though, \Snap{} is a visual language; instead of writing a program using the keyboard, the \Snap{} programmer uses the same drag-and-drop interface familiar to computer users. - -Start \Snap{}. You should see the following arrangement of regions in the window: - -\begin{center} -\includegraphics[width=\textwidth]{window-regions} -\end{center} - -(The proportions of these areas may be different, depending on the size and shape of your browser window.) - -A \Snap{} program consists of one or more \emph{scripts}, each of which is made of \emph{blocks}. Here's a typical script: - -\bigpic{typical-script} - -The five blocks that make up this script have three different colors, corresponding to three of the eight \emph{palettes} in which blocks can be found. The palette area at the left edge of the window shows one palette at a time, chosen with the eight buttons just above the palette area. In this script, the gold blocks are from the Control palette; the green block is from the Pen palette; and the blue blocks are from the Motion palette. A script is assembled by dragging blocks from a palette into the \emph{scripting area} in the middle part of the window. Blocks snap together (hence the name \Snap{} for the language) when you drag a block so that its indentation is near the tab of the one above it: - -\bigpic{snapping-blocks} - -The white horizontal line is a signal that if you let go of the green block it will snap into the tab of the gold one. - -\subsection{Hat Blocks and Command Blocks} - -At the top of the script is a \emph{hat} block, which indicates when the script should be carried out. Hat block names typically start with the word ``\code{when}''; in this example, the script should be run when the green flag near the right end of the \Snap{} tool bar is clicked. (The \Snap{} tool bar is part of the \Snap{} window, not the same as the browser's or operating system's menu bar.) A script isn't required to have a hat block, but if not, then the script will be run only if the user clicks on the script itself. A script can't have more than one hat block, and the hat block can be used only at the top of the script; its distinctive shape is meant to remind you of that. - -The other blocks in this script are \emph{command} blocks. Each command block corresponds to an action that \Snap{} already knows how to carry out. For example, the block \inlinepic{move-10-steps} tells the sprite (the arrowhead shape on the \emph{stage} at the right end of the window) to move ten steps (a step is a very small unit of distance) in the direction in which the arrowhead is pointing. We'll see shortly that there can be more than one sprite, and that each sprite has its own scripts. Also, a sprite doesn't have to look like an arrowhead, but can have any picture as a costume. The shape of the \code{move} block is meant to remind you of a Lego\texttrademark{} brick; a script is a stack of blocks. (The word ``block'' denotes both the graphical shape on the screen and the procedure, the action, that the block carries out.) - -The number 10 in the \code{move} block above is called an \emph{input} to the block. By clicking on the white oval, you can type any number in place of the 10. The sample script on the previous page uses 100 as the input value. We'll see later that inputs can have non-oval shapes that accept values other than numbers. We'll also see that you can compute input values, instead of typing a particular value into the oval. A block can have more than one input slot. For example, the \code{glide} block located about halfway down the Motion palette has three inputs. - -Most command blocks have that brick shape, but some, like the \code{repeat} block in the sample script, are \emph{C-shaped}. Most C-shaped blocks are found in the Control palette. The slot inside the C shape is a special kind of input slot that accepts a \emph{script} as the input. In the sample script, the \code{repeat} block has two inputs: the number 4 and the script - -\bigpic{typical-script-inner} - - - -\section{Sprites and Parallelism} -\subsection{Costumes and Sounds} -\subsection{Inter-Sprite Communication with Broadcast} -\section{Nesting Sprites: Anchors and Parts} -\section{Reporter Blocks and Expressions} -\section{Predicates and Conditional Evaluation} -\section{Variables} -\subsection{Global Variables} -\subsection{Script Variables} -\section{Etcetera} -\chapter{Saving and Loading Projects and Media} -\section{Local Storage} -\subsection{Localstore} -\subsection{XML Export} -\section{Cloud Storage} -\section{Loading Saved Projects} -\chapter{Building a Block} -\section{Simple Blocks} -\subsection{Custom Blocks with Inputs} -\section{Recursion} -\section{Block Libraries} -\chapter{First Class Lists} -\section{The list Block} -\section{Lists of Lists} -\section{Functional and Imperative List Programming} -\section{Higher Order List Operations and Rings} -\chapter{Typed Inputs} -\section{Scratch's Type Notation} -\section{The \Snap{} Input Type Dialog} -\subsection{Procedure Types} -\subsection{Pulldown inputs} -\subsection{Input variants} -\subsection{Prototype Hints} -\subsection{Title Text and Symbols} -\chapter{Procedures as Data} -\section{Call and Run} -\subsection{Call/Run with inputs} -\subsection{Variables in Ring Slots} -\section{Writing Higher Order Procedures} -\subsection{Recursive Calls to Multiple-Input Blocks} -\section{Formal Parameters} -\section{Procedures as Data} -\section{Special Forms} -\subsection{Special Forms in Scratch} -\chapter{Object Oriented Programming} -\section{Local State with Script Variables} -\section{Messages and Dispatch Procedures} -\section{Inheritance via Delegation} -\section{An Implementation of Prototyping OOP} -\chapter{The Outside World} -\section{The World Wide Web} -\section{Hardware Devices} -\section{Date and Time} -\chapter{Continuations} -\section{Continuation Passing Style} -\section{Call/Run w/Continuation} -\subsection{Nonlocal exit} -\chapter{User Interface Elements} -\section{Tool Bar Features} -\subsection{The \Snap{} Logo Menu} -\subsection{The File Menu} -\subsection{The Cloud Menu} -\subsection{The Settings Menu} -\subsection{Stage Resizing Buttons} -\subsection{Project Control Buttons} -\section{The Palette Area} -\subsection{Context Menus for Palette Blocks} -\subsection{Context Menu for the Palette Background} -\section{The Scripting Area} -\subsection{Sprite Appearance and Behavior Controls} -\subsection{Scripting Area Tabs} -\subsection{Scripts and Blocks Within Scripts} -\subsection{Scripting Area Background Context Menu} -\subsection{Controls in the Costumes Tab} -\subsection{The Paint Editor} -\subsection{Controls in the Sounds Tab} -\section{Controls on the Stage} -\section{The Sprite Corral and Sprite Creation Buttons} - -\end{document} diff --git a/help/manual/snapping-blocks.png b/help/manual/snapping-blocks.png deleted file mode 100644 index 0dc5922..0000000 Binary files a/help/manual/snapping-blocks.png and /dev/null differ diff --git a/help/manual/typical-script-inner.png b/help/manual/typical-script-inner.png deleted file mode 100644 index b5503f7..0000000 Binary files a/help/manual/typical-script-inner.png and /dev/null differ diff --git a/help/manual/typical-script.png b/help/manual/typical-script.png deleted file mode 100644 index 6763aad..0000000 Binary files a/help/manual/typical-script.png and /dev/null differ diff --git a/help/manual/window-regions.png b/help/manual/window-regions.png deleted file mode 100644 index 7fe4e98..0000000 Binary files a/help/manual/window-regions.png and /dev/null differ -- cgit v1.3.1 From 2676521231679cfd24114d38ce6c5b2208568530 Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Wed, 24 Jun 2015 01:27:03 +0200 Subject: Move some stuff to the common directory --- help/manual/common/defs.tex | 23 +++++++++++++++++++++++ help/manual/en/snap-manual.tex | 25 +------------------------ 2 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 help/manual/common/defs.tex diff --git a/help/manual/common/defs.tex b/help/manual/common/defs.tex new file mode 100644 index 0000000..4453b67 --- /dev/null +++ b/help/manual/common/defs.tex @@ -0,0 +1,23 @@ +\usepackage{baskervald} % Default font +\usepackage{cabin} % Sans serif font +\usepackage[T1]{fontenc} +\usepackage{setspace} \onehalfspacing +\usepackage{graphicx} +\usepackage{textcomp} +\usepackage{hyperref} + +\newcommand{\Snap}{{\sf Snap{\it !}}} +\newcommand{\code}[1]{\textsf{#1}} +\newcommand{\defaultGraphicsScale}{0.6} + +\newcommand{\inlinepic}[1]{% + \raisebox{-4pt}{% + \includegraphics[scale=\defaultGraphicsScale]{#1}% + }% +} + +\newcommand{\bigpic}[1]{ + \begin{center} + \includegraphics[scale=\defaultGraphicsScale]{#1} + \end{center} +} \ No newline at end of file diff --git a/help/manual/en/snap-manual.tex b/help/manual/en/snap-manual.tex index 6ca387c..3b5fe98 100644 --- a/help/manual/en/snap-manual.tex +++ b/help/manual/en/snap-manual.tex @@ -1,29 +1,6 @@ \documentclass{report} -\usepackage{baskervald} % Default font -\usepackage{cabin} % Sans serif font -\usepackage[T1]{fontenc} -\usepackage{setspace} \onehalfspacing -\usepackage{graphicx} -\usepackage{textcomp} -\usepackage{hyperref} - -\newcommand{\Snap}{{\sf Snap{\it !}}} -\newcommand{\code}[1]{\textsf{#1}} -\newcommand{\defaultGraphicsScale}{0.6} - -\newcommand{\inlinepic}[1]{% - \raisebox{-4pt}{% - \includegraphics[scale=\defaultGraphicsScale]{#1}% - }% -} - -\newcommand{\bigpic}[1]{ - \begin{center} - \includegraphics[scale=\defaultGraphicsScale]{#1} - \end{center} -} - +\input{../common/defs.tex} \renewcommand{\thechapter}{\Roman{chapter}} \renewcommand{\thesection}{\Alph{section}} -- cgit v1.3.1 From b0995850dabfd95a268cbab0ba5f09cd8dba7a77 Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Wed, 24 Jun 2015 18:33:43 +0200 Subject: First batch of translation --- help/manual/common/defs.tex | 22 ++++- help/manual/en/snap-manual.tex | 8 +- help/manual/pl/move-10-steps.png | Bin 0 -> 2595 bytes help/manual/pl/snap-podrecznik.tex | 157 ++++++++++++++++++++++++++++++++ help/manual/pl/snapping-blocks.png | Bin 0 -> 12054 bytes help/manual/pl/typical-script-inner.png | Bin 0 -> 4610 bytes help/manual/pl/typical-script.png | Bin 0 -> 11063 bytes help/manual/pl/window-regions.png | Bin 0 -> 142052 bytes 8 files changed, 180 insertions(+), 7 deletions(-) create mode 100644 help/manual/pl/move-10-steps.png create mode 100644 help/manual/pl/snap-podrecznik.tex create mode 100644 help/manual/pl/snapping-blocks.png create mode 100644 help/manual/pl/typical-script-inner.png create mode 100644 help/manual/pl/typical-script.png create mode 100644 help/manual/pl/window-regions.png diff --git a/help/manual/common/defs.tex b/help/manual/common/defs.tex index 4453b67..b35b373 100644 --- a/help/manual/common/defs.tex +++ b/help/manual/common/defs.tex @@ -1,15 +1,35 @@ \usepackage{baskervald} % Default font \usepackage{cabin} % Sans serif font \usepackage[T1]{fontenc} +\usepackage[utf8]{inputenc} \usepackage{setspace} \onehalfspacing \usepackage{graphicx} \usepackage{textcomp} \usepackage{hyperref} -\newcommand{\Snap}{{\sf Snap{\it !}}} +% This macro produces a "Snap!" logo. +% +% Note that in Polish (and other languages), nouns are inflected. The form "Snap!" with suffix looks plain stupid, so the macro takes a suffix as argument. If the suffix is non-empty, no exclamation mark is generated, and the suffix is used instead. +\newcommand{\Snap}[1]{% + {% + \sf% + Snap% + \ifx\\#1\\{\it !}% + \else #1% + \fi% + }% +} +\newcommand{\Foo}[1]{ +\ifx\\#1\\foo\else bar\fi +} + \newcommand{\code}[1]{\textsf{#1}} \newcommand{\defaultGraphicsScale}{0.6} +\renewcommand{\thechapter}{\Roman{chapter}} +\renewcommand{\thesection}{\Alph{section}} +\renewcommand{\thesubsection}{} + \newcommand{\inlinepic}[1]{% \raisebox{-4pt}{% \includegraphics[scale=\defaultGraphicsScale]{#1}% diff --git a/help/manual/en/snap-manual.tex b/help/manual/en/snap-manual.tex index 3b5fe98..3b088d7 100644 --- a/help/manual/en/snap-manual.tex +++ b/help/manual/en/snap-manual.tex @@ -2,10 +2,6 @@ \input{../common/defs.tex} -\renewcommand{\thechapter}{\Roman{chapter}} -\renewcommand{\thesection}{\Alph{section}} -\renewcommand{\thesubsection}{} - \begin{document} \title{\Snap{} Reference Manual} @@ -23,11 +19,11 @@ We have been extremely lucky in our mentors. Jens cut his teeth in the company o {\bf\em Our earlier version, BYOB, was a direct modification of the Scratch source code. \Snap{} is a complete rewrite, but its code structure and its user interface remain deeply indebted to Scratch. And the Scratch Team, who could have seen us as rivals, have been entirely supportive and welcoming to us.} -Brian grew up at the MIT and Stanford Artificial Intelligence Labs, learning from Lisp inventor John McCarthy, Scheme inventors Gerald J. Sussman and Guy Steele, and the authors of the world's best computer science book, \emph{Structure and Interpretation of Computer Programs}, Hal Abelson and Gerald J. Sussman with Julie Sussman, among many other heroes of computer science. +Brian grew up at the MIT and Stanford Artificial Intelligence Labs, learning from Lisp inventor John McCarthy, Scheme inventors Gerald J. Sussman and Guy Steele, and the authors of the world's best computer science book, \textit{Structure and Interpretation of Computer Programs}, Hal Abelson and Gerald J. Sussman with Julie Sussman, among many other heroes of computer science. {\bf\em In the glory days of the MIT Logo Lab, we used to say, ``Logo is Lisp disguised as BASIC.'' Now, with its first class procedures, lexical scope, and first class continuations, \Snap{} is Scheme disguised as Scratch.} -We have been fortunate to get to know an amazing group of brilliant middle school(!) and high school students through the Scratch Advanced Topics forum, several of whom have contributed code to \Snap{}: Kartik Chandra, Nathan Dinsmore, Connor Hudson, and Ian Reynolds. Many more have contributed ideas and alpha-testing bug reports. UC Berkeley students who've contributed code include Michael Ball, Achal Dave. Kyle Hotchkiss, Ivan Motyashov, and Yuan Yuan. Contributors of translations are too numerous to list here, but they're in the ``About...'' box in \Snap{} itself. This work was supported in part by the National Science Foundation grant 1143566, and in part by MioSoft. +We have been fortunate to get to know an amazing group of brilliant middle school (!\@) and high school students through the Scratch Advanced Topics forum, several of whom have contributed code to \Snap{}: Kartik Chandra, Nathan Dinsmore, Connor Hudson, and Ian Reynolds. Many more have contributed ideas and alpha-testing bug reports. UC Berkeley students who've contributed code include Michael Ball, Achal Dave, Kyle Hotchkiss, Ivan Motyashov, and Yuan Yuan. Contributors of translations are too numerous to list here, but they're in the ``About...'' box in \Snap{} itself. This work was supported in part by the National Science Foundation grant 1143566, and in part by MioSoft. \begin{titlepage} diff --git a/help/manual/pl/move-10-steps.png b/help/manual/pl/move-10-steps.png new file mode 100644 index 0000000..3d276da Binary files /dev/null and b/help/manual/pl/move-10-steps.png differ diff --git a/help/manual/pl/snap-podrecznik.tex b/help/manual/pl/snap-podrecznik.tex new file mode 100644 index 0000000..69b9e09 --- /dev/null +++ b/help/manual/pl/snap-podrecznik.tex @@ -0,0 +1,157 @@ +\documentclass{report} + +\input{../common/defs.tex} + +\begin{document} + +\title{\Snap{} \\ Podręcznik użytkownika} +\author{Brian Harvey \and Jens M\"{o}nig} +\date{} + +\maketitle + +\tableofcontents + +\chapter*{} +\section*{Acknowledgements} + +Mieliśmy ogromne szczęście do mentorów. Jens zdobył dużo doświadczenia pracując wśród pionierów Smalltalka: Alana Kaya, Dana Ingallsa i reszty ekipy, która wynalazła komputery osobiste i programowanie obiektowe w najlepszych dniach firmy Xerox PARC. Pracował z Johnem Maloneyem z zespołu Scratcha w MIT\footnote{Massachusetts Institute of Technology, amerykańska uczelnia techniczna --- przyp. tłum.} , autorem platformy graficznej Morphic, wciąż stanowiącej fundament \Snap{a}. Znakomity projekt języka Scratch, autorstwa Lifelong Kindergarten Group z MIT Media Lab, odgrywa w \Snap{ie} kluczową rolę. + +{\bf\em Nasza poprzednia wersja, BYOB, była bezpośrednią modyfikacją kodu źródłowego Scratcha. \Snap{} został napisany od zera, lecz struktura jego kodu oraz interfejs użytkownika pozostają mocno zakorzenione w Scratchu. Z kolei zespół Scratcha, który mógłby widzieć w nas rywali, przyjął nas ciepło i okazał nam całkowite wsparcie.} + +Brian zdobywał szlify w MIT oraz Stanford Artificial Intelligence Labs\footnote{Laboratorium sztucznej inteligencji na Uniwersytecie Stanforda --- przyp. tłum.}, gdzie uczył się pod okiem Johna McCarthy'ego, twórcy Lispa, oraz Geralda J. Sussmana i Guya Steele'a, twórców języka Scheme. Zdobywał również wiedzę od wielu innych wybitnych informatyków, w tym autorów najlepszej książki z zakresu informatyki --- \emph{Struktury i interpretacji programów komputerowych}: Hala Abelsona, Geralda J. Sussmana i Julie Sussman. + +{\bf\em Za starych dobrych czasów mawialiśmy w MIT Logo Lab: ,,Język Logo to Lisp w przebraniu BASIC-a''. Dziś, ze swoimi pierwszoklasowymi procedurami, zasięgami leksykalnymi i pierwszoklasowymi kontynuacjami, \Snap{} jest jak Scheme w przebraniu Scratcha.} + +Szczęśliwym zrządzeniem losu, poprzez forum Scratch Advanced Topics, poznaliśmy wspaniałą grupę błyskotliwych uczniów gimnazjów (!) i liceów. Kilku z nich wniosło swój wkład w kod \Snap{a}: Kartik Chandra, Nathan Dinsmore, Connor Hudson i Ian Reynolds. Ponadto, wielu zgłosiło pomysły i raporty błędów podczas testowania wersji alfa. Wśród studentów Uniwersytetu Kalifornijskiego w Berkeley, którzy przyczynili się do rozwoju kodu, znajdują się Michael Ball, Achal Dave, Kyle Hotchkiss, Ivan Motyashov i Yuan Yuan. Wymienianie wszystkich tłumaczy zajeło by zbyt wiele miejsca, ale można ich odnaleźć w okienku ,,O Snap!...'' dostępnym w programie. Niniejsze dzieło powstało częściowo w ramach grantu 1143566 udzielonego przez National Science Foundation, a częściowo przy wsparciu firmy MioSoft. + +\begin{titlepage} + +\begin{center} +\bf \Huge \Snap{} \\ Podręcznik użytkownika \\ \huge Wersja 4.0 \vspace{40pt} +\end{center} + +\Snap{} (dawniej BYOB) to rozszerzona reimplementacja języka Scratch (\url{http://scratch.mit.edu}), która pozwala na tworzenie własnych bloków (ang. \textit{Build Your Own Blocks}). + +\Snap{} (formerly BYOB) is an extended reimplementation of Scratch (\url{http://scratch.mit.edu}) that allows you to Build Your Own Blocks. It also features first class lists, first class procedures, and continuations. These added capabilities make it suitable for a serious introduction to computer science for high school or college students. To run \Snap{}, open a browser window and connect to either \url{http://snap.berkeley.edu/run} to start with a minimal set of blocks or \url{http://snap.berkeley.edu/init} to load a small set of additional blocks (a little slower startup, but recommended for convenience and assumed in this manual). + +\end{titlepage} + +\chapter{Blocks, Scripts, and Sprites} + +This chapter describes the \Snap{} features inherited from Scratch; experienced Scratch users can skip to section B. + +\Snap{} is a programming language---a notation in which you can tell a computer what you want it to do. Unlike most programming languages, though, \Snap{} is a visual language; instead of writing a program using the keyboard, the \Snap{} programmer uses the same drag-and-drop interface familiar to computer users. + +Start \Snap{}. You should see the following arrangement of regions in the window: + +\begin{center} +\includegraphics[width=\textwidth]{window-regions} +\end{center} + +(The proportions of these areas may be different, depending on the size and shape of your browser window.) + +A \Snap{} program consists of one or more \emph{scripts}, each of which is made of \emph{blocks}. Here's a typical script: + +\bigpic{typical-script} + +The five blocks that make up this script have three different colors, corresponding to three of the eight \emph{palettes} in which blocks can be found. The palette area at the left edge of the window shows one palette at a time, chosen with the eight buttons just above the palette area. In this script, the gold blocks are from the Control palette; the green block is from the Pen palette; and the blue blocks are from the Motion palette. A script is assembled by dragging blocks from a palette into the \emph{scripting area} in the middle part of the window. Blocks snap together (hence the name \Snap{} for the language) when you drag a block so that its indentation is near the tab of the one above it: + +\bigpic{snapping-blocks} + +The white horizontal line is a signal that if you let go of the green block it will snap into the tab of the gold one. + +\subsection{Hat Blocks and Command Blocks} + +At the top of the script is a \emph{hat} block, which indicates when the script should be carried out. Hat block names typically start with the word ``\code{when}''; in this example, the script should be run when the green flag near the right end of the \Snap{} tool bar is clicked. (The \Snap{} tool bar is part of the \Snap{} window, not the same as the browser's or operating system's menu bar.) A script isn't required to have a hat block, but if not, then the script will be run only if the user clicks on the script itself. A script can't have more than one hat block, and the hat block can be used only at the top of the script; its distinctive shape is meant to remind you of that. + +The other blocks in this script are \emph{command} blocks. Each command block corresponds to an action that \Snap{} already knows how to carry out. For example, the block \inlinepic{move-10-steps} tells the sprite (the arrowhead shape on the \emph{stage} at the right end of the window) to move ten steps (a step is a very small unit of distance) in the direction in which the arrowhead is pointing. We'll see shortly that there can be more than one sprite, and that each sprite has its own scripts. Also, a sprite doesn't have to look like an arrowhead, but can have any picture as a costume. The shape of the \code{move} block is meant to remind you of a Lego\texttrademark{} brick; a script is a stack of blocks. (The word ``block'' denotes both the graphical shape on the screen and the procedure, the action, that the block carries out.) + +The number 10 in the \code{move} block above is called an \emph{input} to the block. By clicking on the white oval, you can type any number in place of the 10. The sample script on the previous page uses 100 as the input value. We'll see later that inputs can have non-oval shapes that accept values other than numbers. We'll also see that you can compute input values, instead of typing a particular value into the oval. A block can have more than one input slot. For example, the \code{glide} block located about halfway down the Motion palette has three inputs. + +Most command blocks have that brick shape, but some, like the \code{repeat} block in the sample script, are \emph{C-shaped}. Most C-shaped blocks are found in the Control palette. The slot inside the C shape is a special kind of input slot that accepts a \emph{script} as the input. In the sample script, the \code{repeat} block has two inputs: the number 4 and the script + +\bigpic{typical-script-inner} + + + +\section{Sprites and Parallelism} +\subsection{Costumes and Sounds} +\subsection{Inter-Sprite Communication with Broadcast} +\section{Nesting Sprites: Anchors and Parts} +\section{Reporter Blocks and Expressions} +\section{Predicates and Conditional Evaluation} +\section{Variables} +\subsection{Global Variables} +\subsection{Script Variables} +\section{Etcetera} +\chapter{Saving and Loading Projects and Media} +\section{Local Storage} +\subsection{Localstore} +\subsection{XML Export} +\section{Cloud Storage} +\section{Loading Saved Projects} +\chapter{Building a Block} +\section{Simple Blocks} +\subsection{Custom Blocks with Inputs} +\section{Recursion} +\section{Block Libraries} +\chapter{First Class Lists} +\section{The list Block} +\section{Lists of Lists} +\section{Functional and Imperative List Programming} +\section{Higher Order List Operations and Rings} +\chapter{Typed Inputs} +\section{Scratch's Type Notation} +\section{The \Snap{} Input Type Dialog} +\subsection{Procedure Types} +\subsection{Pulldown inputs} +\subsection{Input variants} +\subsection{Prototype Hints} +\subsection{Title Text and Symbols} +\chapter{Procedures as Data} +\section{Call and Run} +\subsection{Call/Run with inputs} +\subsection{Variables in Ring Slots} +\section{Writing Higher Order Procedures} +\subsection{Recursive Calls to Multiple-Input Blocks} +\section{Formal Parameters} +\section{Procedures as Data} +\section{Special Forms} +\subsection{Special Forms in Scratch} +\chapter{Object Oriented Programming} +\section{Local State with Script Variables} +\section{Messages and Dispatch Procedures} +\section{Inheritance via Delegation} +\section{An Implementation of Prototyping OOP} +\chapter{The Outside World} +\section{The World Wide Web} +\section{Hardware Devices} +\section{Date and Time} +\chapter{Continuations} +\section{Continuation Passing Style} +\section{Call/Run w/Continuation} +\subsection{Nonlocal exit} +\chapter{User Interface Elements} +\section{Tool Bar Features} +\subsection{The \Snap{} Logo Menu} +\subsection{The File Menu} +\subsection{The Cloud Menu} +\subsection{The Settings Menu} +\subsection{Stage Resizing Buttons} +\subsection{Project Control Buttons} +\section{The Palette Area} +\subsection{Context Menus for Palette Blocks} +\subsection{Context Menu for the Palette Background} +\section{The Scripting Area} +\subsection{Sprite Appearance and Behavior Controls} +\subsection{Scripting Area Tabs} +\subsection{Scripts and Blocks Within Scripts} +\subsection{Scripting Area Background Context Menu} +\subsection{Controls in the Costumes Tab} +\subsection{The Paint Editor} +\subsection{Controls in the Sounds Tab} +\section{Controls on the Stage} +\section{The Sprite Corral and Sprite Creation Buttons} + +\end{document} diff --git a/help/manual/pl/snapping-blocks.png b/help/manual/pl/snapping-blocks.png new file mode 100644 index 0000000..0dc5922 Binary files /dev/null and b/help/manual/pl/snapping-blocks.png differ diff --git a/help/manual/pl/typical-script-inner.png b/help/manual/pl/typical-script-inner.png new file mode 100644 index 0000000..b5503f7 Binary files /dev/null and b/help/manual/pl/typical-script-inner.png differ diff --git a/help/manual/pl/typical-script.png b/help/manual/pl/typical-script.png new file mode 100644 index 0000000..6763aad Binary files /dev/null and b/help/manual/pl/typical-script.png differ diff --git a/help/manual/pl/window-regions.png b/help/manual/pl/window-regions.png new file mode 100644 index 0000000..7fe4e98 Binary files /dev/null and b/help/manual/pl/window-regions.png differ -- cgit v1.3.1 From 132ccdb35e0d2795cc2353b01c3caaf73b04389a Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Wed, 24 Jun 2015 18:49:13 +0200 Subject: Use Polish typographic conventions --- help/manual/pl/snap-podrecznik.tex | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/help/manual/pl/snap-podrecznik.tex b/help/manual/pl/snap-podrecznik.tex index 69b9e09..a07a889 100644 --- a/help/manual/pl/snap-podrecznik.tex +++ b/help/manual/pl/snap-podrecznik.tex @@ -2,6 +2,11 @@ \input{../common/defs.tex} +\usepackage[polish]{babel} +\usepackage{polski} +\frenchspacing +\usepackage{indentfirst} + \begin{document} \title{\Snap{} \\ Podręcznik użytkownika} @@ -13,17 +18,17 @@ \tableofcontents \chapter*{} -\section*{Acknowledgements} +\section*{Podziękowania} Mieliśmy ogromne szczęście do mentorów. Jens zdobył dużo doświadczenia pracując wśród pionierów Smalltalka: Alana Kaya, Dana Ingallsa i reszty ekipy, która wynalazła komputery osobiste i programowanie obiektowe w najlepszych dniach firmy Xerox PARC. Pracował z Johnem Maloneyem z zespołu Scratcha w MIT\footnote{Massachusetts Institute of Technology, amerykańska uczelnia techniczna --- przyp. tłum.} , autorem platformy graficznej Morphic, wciąż stanowiącej fundament \Snap{a}. Znakomity projekt języka Scratch, autorstwa Lifelong Kindergarten Group z MIT Media Lab, odgrywa w \Snap{ie} kluczową rolę. {\bf\em Nasza poprzednia wersja, BYOB, była bezpośrednią modyfikacją kodu źródłowego Scratcha. \Snap{} został napisany od zera, lecz struktura jego kodu oraz interfejs użytkownika pozostają mocno zakorzenione w Scratchu. Z kolei zespół Scratcha, który mógłby widzieć w nas rywali, przyjął nas ciepło i okazał nam całkowite wsparcie.} -Brian zdobywał szlify w MIT oraz Stanford Artificial Intelligence Labs\footnote{Laboratorium sztucznej inteligencji na Uniwersytecie Stanforda --- przyp. tłum.}, gdzie uczył się pod okiem Johna McCarthy'ego, twórcy Lispa, oraz Geralda J. Sussmana i Guya Steele'a, twórców języka Scheme. Zdobywał również wiedzę od wielu innych wybitnych informatyków, w tym autorów najlepszej książki z zakresu informatyki --- \emph{Struktury i interpretacji programów komputerowych}: Hala Abelsona, Geralda J. Sussmana i Julie Sussman. +Brian zdobywał szlify w MIT oraz Stanford Artificial Intelligence Labs\footnote{Laboratorium sztucznej inteligencji na Uniwersytecie Stanforda --- przyp. tłum.}, gdzie uczył się pod okiem Johna McCarthy'ego, twórcy Lispa, oraz Geralda J. Suss\-mana i Guya Steele'a, twórców języka Scheme. Zdobywał również wiedzę od wielu innych wybitnych informatyków, w tym autorów najlepszej książki z zakresu informatyki --- \emph{Struktury i interpretacji programów komputerowych}: Hala Abelsona, Geralda J. Suss\-mana i Julie Suss\-man. {\bf\em Za starych dobrych czasów mawialiśmy w MIT Logo Lab: ,,Język Logo to Lisp w przebraniu BASIC-a''. Dziś, ze swoimi pierwszoklasowymi procedurami, zasięgami leksykalnymi i pierwszoklasowymi kontynuacjami, \Snap{} jest jak Scheme w przebraniu Scratcha.} -Szczęśliwym zrządzeniem losu, poprzez forum Scratch Advanced Topics, poznaliśmy wspaniałą grupę błyskotliwych uczniów gimnazjów (!) i liceów. Kilku z nich wniosło swój wkład w kod \Snap{a}: Kartik Chandra, Nathan Dinsmore, Connor Hudson i Ian Reynolds. Ponadto, wielu zgłosiło pomysły i raporty błędów podczas testowania wersji alfa. Wśród studentów Uniwersytetu Kalifornijskiego w Berkeley, którzy przyczynili się do rozwoju kodu, znajdują się Michael Ball, Achal Dave, Kyle Hotchkiss, Ivan Motyashov i Yuan Yuan. Wymienianie wszystkich tłumaczy zajeło by zbyt wiele miejsca, ale można ich odnaleźć w okienku ,,O Snap!...'' dostępnym w programie. Niniejsze dzieło powstało częściowo w ramach grantu 1143566 udzielonego przez National Science Foundation, a częściowo przy wsparciu firmy MioSoft. +Szczęśliwym zrządzeniem losu, poprzez forum Scratch Advanced Topics, poznaliśmy wspaniałą grupę błyskotliwych uczniów gimnazjów (!\@) i liceów. Kilku z nich wniosło swój wkład w kod \Snap{a}: Kartik Chandra, Nathan Dinsmore, Connor Hudson i Ian Reynolds. Ponadto, wielu zgłosiło pomysły i raporty błędów podczas testowania wersji alfa. Wśród studentów Uniwersytetu Kalifornijskiego w Berkeley, którzy przyczynili się do rozwoju kodu, znajdują się Michael Ball, Achal Dave, Kyle Hotchkiss, Ivan Motyashov i Yuan Yuan. Wymienianie wszystkich tłumaczy zajeło by zbyt wiele miejsca, ale można ich odnaleźć w okienku ,,O Snap!...'' dostępnym w programie. Niniejsze dzieło powstało częściowo w ramach grantu nr 1143566 udzielonego przez National Science Foundation, a częściowo przy wsparciu firmy MioSoft. \begin{titlepage} -- cgit v1.3.1 From d430bac6d6fa6bfc340fee665185e4ef9ccb9a67 Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Wed, 24 Jun 2015 18:55:24 +0200 Subject: Improve typesetting of Snap logo --- help/manual/common/defs.tex | 8 ++------ help/manual/pl/snap-podrecznik.tex | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/help/manual/common/defs.tex b/help/manual/common/defs.tex index b35b373..50f0c24 100644 --- a/help/manual/common/defs.tex +++ b/help/manual/common/defs.tex @@ -11,17 +11,13 @@ % % Note that in Polish (and other languages), nouns are inflected. The form "Snap!" with suffix looks plain stupid, so the macro takes a suffix as argument. If the suffix is non-empty, no exclamation mark is generated, and the suffix is used instead. \newcommand{\Snap}[1]{% - {% - \sf% + \textsf{% Snap% - \ifx\\#1\\{\it !}% + \ifx\\#1\\\textit{!}% \else #1% \fi% }% } -\newcommand{\Foo}[1]{ -\ifx\\#1\\foo\else bar\fi -} \newcommand{\code}[1]{\textsf{#1}} \newcommand{\defaultGraphicsScale}{0.6} diff --git a/help/manual/pl/snap-podrecznik.tex b/help/manual/pl/snap-podrecznik.tex index a07a889..1e2c78a 100644 --- a/help/manual/pl/snap-podrecznik.tex +++ b/help/manual/pl/snap-podrecznik.tex @@ -36,7 +36,7 @@ Szczęśliwym zrządzeniem losu, poprzez forum Scratch Advanced Topics, poznali \bf \Huge \Snap{} \\ Podręcznik użytkownika \\ \huge Wersja 4.0 \vspace{40pt} \end{center} -\Snap{} (dawniej BYOB) to rozszerzona reimplementacja języka Scratch (\url{http://scratch.mit.edu}), która pozwala na tworzenie własnych bloków (ang. \textit{Build Your Own Blocks}). +\Snap{} (dawniej BYOB) to rozszerzona reimplementacja języka Scratch (\url{http://scratch.mit.edu}), która pozwala na tworzenie własnych bloków (ang. \textit{Build Your Own Blocks}). \Snap{} (formerly BYOB) is an extended reimplementation of Scratch (\url{http://scratch.mit.edu}) that allows you to Build Your Own Blocks. It also features first class lists, first class procedures, and continuations. These added capabilities make it suitable for a serious introduction to computer science for high school or college students. To run \Snap{}, open a browser window and connect to either \url{http://snap.berkeley.edu/run} to start with a minimal set of blocks or \url{http://snap.berkeley.edu/init} to load a small set of additional blocks (a little slower startup, but recommended for convenience and assumed in this manual). -- cgit v1.3.1 From b2fd1ade3133684d6665fcd7002c22b2da304ebb Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Wed, 24 Jun 2015 18:58:51 +0200 Subject: Minor typographic corrections --- help/manual/en/snap-manual.tex | 4 ++-- help/manual/pl/snap-podrecznik.tex | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/help/manual/en/snap-manual.tex b/help/manual/en/snap-manual.tex index 3b088d7..fc1dfc7 100644 --- a/help/manual/en/snap-manual.tex +++ b/help/manual/en/snap-manual.tex @@ -17,11 +17,11 @@ We have been extremely lucky in our mentors. Jens cut his teeth in the company of the Smalltalk pioneers: Alan Kay, Dan Ingalls, and the rest of the gang who invented personal computing and object oriented programming in the great days of Xerox PARC. He worked with John Maloney, of the MIT Scratch Team, who developed the Morphic graphics framework that's still at the heart of \Snap{}. The brilliant design of Scratch, from the Lifelong Kindergarten Group at the MIT Media Lab, is crucial to \Snap{}. -{\bf\em Our earlier version, BYOB, was a direct modification of the Scratch source code. \Snap{} is a complete rewrite, but its code structure and its user interface remain deeply indebted to Scratch. And the Scratch Team, who could have seen us as rivals, have been entirely supportive and welcoming to us.} +\textbf{\emph{Our earlier version, BYOB, was a direct modification of the Scratch source code. \Snap{} is a complete rewrite, but its code structure and its user interface remain deeply indebted to Scratch. And the Scratch Team, who could have seen us as rivals, have been entirely supportive and welcoming to us.}} Brian grew up at the MIT and Stanford Artificial Intelligence Labs, learning from Lisp inventor John McCarthy, Scheme inventors Gerald J. Sussman and Guy Steele, and the authors of the world's best computer science book, \textit{Structure and Interpretation of Computer Programs}, Hal Abelson and Gerald J. Sussman with Julie Sussman, among many other heroes of computer science. -{\bf\em In the glory days of the MIT Logo Lab, we used to say, ``Logo is Lisp disguised as BASIC.'' Now, with its first class procedures, lexical scope, and first class continuations, \Snap{} is Scheme disguised as Scratch.} +\textbf{\emph{In the glory days of the MIT Logo Lab, we used to say, ``Logo is Lisp disguised as BASIC.'' Now, with its first class procedures, lexical scope, and first class continuations, \Snap{} is Scheme disguised as Scratch.}} We have been fortunate to get to know an amazing group of brilliant middle school (!\@) and high school students through the Scratch Advanced Topics forum, several of whom have contributed code to \Snap{}: Kartik Chandra, Nathan Dinsmore, Connor Hudson, and Ian Reynolds. Many more have contributed ideas and alpha-testing bug reports. UC Berkeley students who've contributed code include Michael Ball, Achal Dave, Kyle Hotchkiss, Ivan Motyashov, and Yuan Yuan. Contributors of translations are too numerous to list here, but they're in the ``About...'' box in \Snap{} itself. This work was supported in part by the National Science Foundation grant 1143566, and in part by MioSoft. diff --git a/help/manual/pl/snap-podrecznik.tex b/help/manual/pl/snap-podrecznik.tex index 1e2c78a..8da7eb0 100644 --- a/help/manual/pl/snap-podrecznik.tex +++ b/help/manual/pl/snap-podrecznik.tex @@ -22,11 +22,11 @@ Mieliśmy ogromne szczęście do mentorów. Jens zdobył dużo doświadczenia pracując wśród pionierów Smalltalka: Alana Kaya, Dana Ingallsa i reszty ekipy, która wynalazła komputery osobiste i programowanie obiektowe w najlepszych dniach firmy Xerox PARC. Pracował z Johnem Maloneyem z zespołu Scratcha w MIT\footnote{Massachusetts Institute of Technology, amerykańska uczelnia techniczna --- przyp. tłum.} , autorem platformy graficznej Morphic, wciąż stanowiącej fundament \Snap{a}. Znakomity projekt języka Scratch, autorstwa Lifelong Kindergarten Group z MIT Media Lab, odgrywa w \Snap{ie} kluczową rolę. -{\bf\em Nasza poprzednia wersja, BYOB, była bezpośrednią modyfikacją kodu źródłowego Scratcha. \Snap{} został napisany od zera, lecz struktura jego kodu oraz interfejs użytkownika pozostają mocno zakorzenione w Scratchu. Z kolei zespół Scratcha, który mógłby widzieć w nas rywali, przyjął nas ciepło i okazał nam całkowite wsparcie.} +\textbf{\emph{Nasza poprzednia wersja, BYOB, była bezpośrednią modyfikacją kodu źródłowego Scratcha. \Snap{} został napisany od zera, lecz struktura jego kodu oraz interfejs użytkownika pozostają mocno zakorzenione w Scratchu. Z kolei zespół Scratcha, który mógłby widzieć w nas rywali, przyjął nas ciepło i okazał nam całkowite wsparcie.}} Brian zdobywał szlify w MIT oraz Stanford Artificial Intelligence Labs\footnote{Laboratorium sztucznej inteligencji na Uniwersytecie Stanforda --- przyp. tłum.}, gdzie uczył się pod okiem Johna McCarthy'ego, twórcy Lispa, oraz Geralda J. Suss\-mana i Guya Steele'a, twórców języka Scheme. Zdobywał również wiedzę od wielu innych wybitnych informatyków, w tym autorów najlepszej książki z zakresu informatyki --- \emph{Struktury i interpretacji programów komputerowych}: Hala Abelsona, Geralda J. Suss\-mana i Julie Suss\-man. -{\bf\em Za starych dobrych czasów mawialiśmy w MIT Logo Lab: ,,Język Logo to Lisp w przebraniu BASIC-a''. Dziś, ze swoimi pierwszoklasowymi procedurami, zasięgami leksykalnymi i pierwszoklasowymi kontynuacjami, \Snap{} jest jak Scheme w przebraniu Scratcha.} +\textbf{\emph{Za starych dobrych czasów mawialiśmy w MIT Logo Lab: ,,Język Logo to Lisp w przebraniu BASIC-a''. Dziś, ze swoimi pierwszoklasowymi procedurami, zasięgami leksykalnymi i pierwszoklasowymi kontynuacjami, \Snap{} jest jak Scheme w przebraniu Scratcha.}} Szczęśliwym zrządzeniem losu, poprzez forum Scratch Advanced Topics, poznaliśmy wspaniałą grupę błyskotliwych uczniów gimnazjów (!\@) i liceów. Kilku z nich wniosło swój wkład w kod \Snap{a}: Kartik Chandra, Nathan Dinsmore, Connor Hudson i Ian Reynolds. Ponadto, wielu zgłosiło pomysły i raporty błędów podczas testowania wersji alfa. Wśród studentów Uniwersytetu Kalifornijskiego w Berkeley, którzy przyczynili się do rozwoju kodu, znajdują się Michael Ball, Achal Dave, Kyle Hotchkiss, Ivan Motyashov i Yuan Yuan. Wymienianie wszystkich tłumaczy zajeło by zbyt wiele miejsca, ale można ich odnaleźć w okienku ,,O Snap!...'' dostępnym w programie. Niniejsze dzieło powstało częściowo w ramach grantu nr 1143566 udzielonego przez National Science Foundation, a częściowo przy wsparciu firmy MioSoft. -- cgit v1.3.1 From ca05f779b645485d39df1642e75d9ad2e5066d22 Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Wed, 24 Jun 2015 19:15:41 +0200 Subject: Finish translating introduction --- help/manual/en/snap-manual.tex | 4 +++- help/manual/pl/snap-podrecznik.tex | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/help/manual/en/snap-manual.tex b/help/manual/en/snap-manual.tex index fc1dfc7..f44b713 100644 --- a/help/manual/en/snap-manual.tex +++ b/help/manual/en/snap-manual.tex @@ -28,7 +28,9 @@ We have been fortunate to get to know an amazing group of brilliant middle schoo \begin{titlepage} \begin{center} -\bf \Huge \Snap{} Reference Manual \\ \huge Version 4.0 \vspace{40pt} +\bf \Huge \Snap{} Reference Manual \\ +\huge Version 4.0 +\vspace{40pt} \end{center} \Snap{} (formerly BYOB) is an extended reimplementation of Scratch (\url{http://scratch.mit.edu}) that allows you to Build Your Own Blocks. It also features first class lists, first class procedures, and continuations. These added capabilities make it suitable for a serious introduction to computer science for high school or college students. To run \Snap{}, open a browser window and connect to either \url{http://snap.berkeley.edu/run} to start with a minimal set of blocks or \url{http://snap.berkeley.edu/init} to load a small set of additional blocks (a little slower startup, but recommended for convenience and assumed in this manual). diff --git a/help/manual/pl/snap-podrecznik.tex b/help/manual/pl/snap-podrecznik.tex index 8da7eb0..8d74782 100644 --- a/help/manual/pl/snap-podrecznik.tex +++ b/help/manual/pl/snap-podrecznik.tex @@ -33,12 +33,12 @@ Szczęśliwym zrządzeniem losu, poprzez forum Scratch Advanced Topics, poznali \begin{titlepage} \begin{center} -\bf \Huge \Snap{} \\ Podręcznik użytkownika \\ \huge Wersja 4.0 \vspace{40pt} +\bf \Huge \Snap{} \\ +Podręcznik użytkownika \\ +\huge Wersja 4.0 \vspace{40pt} \end{center} -\Snap{} (dawniej BYOB) to rozszerzona reimplementacja języka Scratch (\url{http://scratch.mit.edu}), która pozwala na tworzenie własnych bloków (ang. \textit{Build Your Own Blocks}). - -\Snap{} (formerly BYOB) is an extended reimplementation of Scratch (\url{http://scratch.mit.edu}) that allows you to Build Your Own Blocks. It also features first class lists, first class procedures, and continuations. These added capabilities make it suitable for a serious introduction to computer science for high school or college students. To run \Snap{}, open a browser window and connect to either \url{http://snap.berkeley.edu/run} to start with a minimal set of blocks or \url{http://snap.berkeley.edu/init} to load a small set of additional blocks (a little slower startup, but recommended for convenience and assumed in this manual). +\Snap{} to rozszerzona reimplementacja języka Scratch (\url{http://scratch.mit.edu}), która pozwala na tworzenie własnych bloków (ang.\ \textit{Build Your Own Blocks}; stąd dawna nazwa \Snap{a} --- BYOB). Opisywany tu język obsługuje pierwszoklasowe listy, procedury i kontynuacje. Te dodatkowe możliwości sprawiają, że nadaje się on do przeprowadzenia poważnego wstępu do informatyki dla uczniów liceów i szkół wyższych. Aby uruchomić środowisko \Snap{}, wystarczy otworzyć przeglądarkę internetową i wpisać adres \url{http://snap.berkeley.edu/run}, aby zacząć pracę z minimalnym zestawem bloków. Można też użyć adresu \url{http://snap.berkeley.edu/init}, aby załadować niewielki zestaw dodatkowych bloków. Wiąże się to z nieco wolniejszym ładowaniem, ale jest zalecane dla wygody użytkowników (w dalszej części podręcznika będziemy zakładali korzystanie z tej właśnie metody). \end{titlepage} -- cgit v1.3.1 From ba062ac14843eb2dc747799c2a522e6622fd542b Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Wed, 24 Jun 2015 19:46:59 +0200 Subject: Add TexStudio language comment --- help/manual/pl/snap-podrecznik.tex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/help/manual/pl/snap-podrecznik.tex b/help/manual/pl/snap-podrecznik.tex index 8d74782..9de4094 100644 --- a/help/manual/pl/snap-podrecznik.tex +++ b/help/manual/pl/snap-podrecznik.tex @@ -1,3 +1,5 @@ +% !TeX spellcheck = pl_PL + \documentclass{report} \input{../common/defs.tex} -- cgit v1.3.1 From 029aaeb82708b67d1dd0b3e86e8980e5caa37b15 Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Wed, 24 Jun 2015 20:09:22 +0200 Subject: Some non-breaking spaces and refs --- help/manual/en/snap-manual.tex | 5 +++-- help/manual/pl/snap-podrecznik.tex | 21 ++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/help/manual/en/snap-manual.tex b/help/manual/en/snap-manual.tex index f44b713..b59e4e3 100644 --- a/help/manual/en/snap-manual.tex +++ b/help/manual/en/snap-manual.tex @@ -19,7 +19,7 @@ We have been extremely lucky in our mentors. Jens cut his teeth in the company o \textbf{\emph{Our earlier version, BYOB, was a direct modification of the Scratch source code. \Snap{} is a complete rewrite, but its code structure and its user interface remain deeply indebted to Scratch. And the Scratch Team, who could have seen us as rivals, have been entirely supportive and welcoming to us.}} -Brian grew up at the MIT and Stanford Artificial Intelligence Labs, learning from Lisp inventor John McCarthy, Scheme inventors Gerald J. Sussman and Guy Steele, and the authors of the world's best computer science book, \textit{Structure and Interpretation of Computer Programs}, Hal Abelson and Gerald J. Sussman with Julie Sussman, among many other heroes of computer science. +Brian grew up at the MIT and Stanford Artificial Intelligence Labs, learning from Lisp inventor John McCarthy, Scheme inventors Gerald~J. Sussman and Guy Steele, and the authors of the world's best computer science book, \textit{Structure and Interpretation of Computer Programs}, Hal Abelson and Gerald~J. Sussman with Julie Sussman, among many other heroes of computer science. \textbf{\emph{In the glory days of the MIT Logo Lab, we used to say, ``Logo is Lisp disguised as BASIC.'' Now, with its first class procedures, lexical scope, and first class continuations, \Snap{} is Scheme disguised as Scratch.}} @@ -39,7 +39,7 @@ We have been fortunate to get to know an amazing group of brilliant middle schoo \chapter{Blocks, Scripts, and Sprites} -This chapter describes the \Snap{} features inherited from Scratch; experienced Scratch users can skip to section B. +This chapter describes the \Snap{} features inherited from Scratch; experienced Scratch users can skip to section~\ref{sec:nesting-sprites}. \Snap{} is a programming language---a notation in which you can tell a computer what you want it to do. Unlike most programming languages, though, \Snap{} is a visual language; instead of writing a program using the keyboard, the \Snap{} programmer uses the same drag-and-drop interface familiar to computer users. @@ -79,6 +79,7 @@ Most command blocks have that brick shape, but some, like the \code{repeat} bloc \subsection{Costumes and Sounds} \subsection{Inter-Sprite Communication with Broadcast} \section{Nesting Sprites: Anchors and Parts} +\label{sec:nesting-sprites} \section{Reporter Blocks and Expressions} \section{Predicates and Conditional Evaluation} \section{Variables} diff --git a/help/manual/pl/snap-podrecznik.tex b/help/manual/pl/snap-podrecznik.tex index 9de4094..d8c1a76 100644 --- a/help/manual/pl/snap-podrecznik.tex +++ b/help/manual/pl/snap-podrecznik.tex @@ -1,4 +1,4 @@ -% !TeX spellcheck = pl_PL +% !TeX spellcheck = pl \documentclass{report} @@ -22,15 +22,15 @@ \chapter*{} \section*{Podziękowania} -Mieliśmy ogromne szczęście do mentorów. Jens zdobył dużo doświadczenia pracując wśród pionierów Smalltalka: Alana Kaya, Dana Ingallsa i reszty ekipy, która wynalazła komputery osobiste i programowanie obiektowe w najlepszych dniach firmy Xerox PARC. Pracował z Johnem Maloneyem z zespołu Scratcha w MIT\footnote{Massachusetts Institute of Technology, amerykańska uczelnia techniczna --- przyp. tłum.} , autorem platformy graficznej Morphic, wciąż stanowiącej fundament \Snap{a}. Znakomity projekt języka Scratch, autorstwa Lifelong Kindergarten Group z MIT Media Lab, odgrywa w \Snap{ie} kluczową rolę. +Mieliśmy ogromne szczęście do mentorów. Jens zdobył dużo doświadczenia pracując wśród pionierów Smalltalka: Alana Kaya, Dana Ingallsa i~reszty ekipy, która wynalazła komputery osobiste i~programowanie obiektowe w~najlepszych dniach firmy Xerox PARC. Pracował z~Johnem Maloneyem z~zespołu Scratcha w~MIT\footnote{Massachusetts Institute of Technology, amerykańska uczelnia techniczna --- przyp. tłum.}, autorem platformy graficznej Morphic, wciąż stanowiącej fundament \Snap{a}. Znakomity projekt języka Scratch, autorstwa Lifelong Kindergarten Group z~MIT Media Lab, odgrywa w~\Snap{ie} kluczową rolę. -\textbf{\emph{Nasza poprzednia wersja, BYOB, była bezpośrednią modyfikacją kodu źródłowego Scratcha. \Snap{} został napisany od zera, lecz struktura jego kodu oraz interfejs użytkownika pozostają mocno zakorzenione w Scratchu. Z kolei zespół Scratcha, który mógłby widzieć w nas rywali, przyjął nas ciepło i okazał nam całkowite wsparcie.}} +\textbf{\emph{Nasza poprzednia wersja, BYOB, była bezpośrednią modyfikacją kodu źródłowego Scratcha. \Snap{} został napisany od zera, lecz struktura jego kodu oraz interfejs użytkownika pozostają mocno zakorzenione w~Scratchu. Z~kolei zespół Scratcha, który mógłby widzieć w~nas rywali, przyjął nas ciepło i~okazał nam całkowite wsparcie.}} -Brian zdobywał szlify w MIT oraz Stanford Artificial Intelligence Labs\footnote{Laboratorium sztucznej inteligencji na Uniwersytecie Stanforda --- przyp. tłum.}, gdzie uczył się pod okiem Johna McCarthy'ego, twórcy Lispa, oraz Geralda J. Suss\-mana i Guya Steele'a, twórców języka Scheme. Zdobywał również wiedzę od wielu innych wybitnych informatyków, w tym autorów najlepszej książki z zakresu informatyki --- \emph{Struktury i interpretacji programów komputerowych}: Hala Abelsona, Geralda J. Suss\-mana i Julie Suss\-man. +Brian zdobywał szlify w~MIT oraz Stanford Artificial Intelligence Labs\footnote{Laboratorium sztucznej inteligencji na Uniwersytecie Stanforda --- przyp. tłum.}, gdzie uczył się pod okiem Johna McCarthy'ego, twórcy Lispa, oraz Geralda~J. Suss\-mana i~Guya Steele'a, twórców języka Scheme. Zdobywał również wiedzę od wielu innych wybitnych informatyków, w~tym autorów najlepszej książki z zakresu informatyki --- \emph{Struktury i~interpretacji programów komputerowych}: Hala Abelsona, Geralda~J. Suss\-mana i~Julie Suss\-man. -\textbf{\emph{Za starych dobrych czasów mawialiśmy w MIT Logo Lab: ,,Język Logo to Lisp w przebraniu BASIC-a''. Dziś, ze swoimi pierwszoklasowymi procedurami, zasięgami leksykalnymi i pierwszoklasowymi kontynuacjami, \Snap{} jest jak Scheme w przebraniu Scratcha.}} +\textbf{\emph{Za starych dobrych czasów mawialiśmy w~MIT Logo Lab: ,,Język Logo to Lisp w przebraniu BASIC-a''. Dziś, ze swoimi pierwszoklasowymi procedurami, zasięgami leksykalnymi~i pierwszoklasowymi kontynuacjami, \Snap{} jest jak Scheme w~przebraniu Scratcha.}} -Szczęśliwym zrządzeniem losu, poprzez forum Scratch Advanced Topics, poznaliśmy wspaniałą grupę błyskotliwych uczniów gimnazjów (!\@) i liceów. Kilku z nich wniosło swój wkład w kod \Snap{a}: Kartik Chandra, Nathan Dinsmore, Connor Hudson i Ian Reynolds. Ponadto, wielu zgłosiło pomysły i raporty błędów podczas testowania wersji alfa. Wśród studentów Uniwersytetu Kalifornijskiego w Berkeley, którzy przyczynili się do rozwoju kodu, znajdują się Michael Ball, Achal Dave, Kyle Hotchkiss, Ivan Motyashov i Yuan Yuan. Wymienianie wszystkich tłumaczy zajeło by zbyt wiele miejsca, ale można ich odnaleźć w okienku ,,O Snap!...'' dostępnym w programie. Niniejsze dzieło powstało częściowo w ramach grantu nr 1143566 udzielonego przez National Science Foundation, a częściowo przy wsparciu firmy MioSoft. +Szczęśliwym zrządzeniem losu, poprzez forum Scratch Advanced Topics, poznaliśmy wspaniałą grupę błyskotliwych uczniów gimnazjów~(!\@) i liceów. Kilku z nich wniosło swój wkład w~kod \Snap{a}: Kartik Chandra, Nathan Dinsmore, Connor Hudson i~Ian Reynolds. Ponadto, wielu zgłosiło pomysły i~raporty błędów podczas testowania wersji alfa. Wśród studentów Uniwersytetu Kalifornijskiego w~Berkeley, którzy przyczynili się do rozwoju kodu, znajdują się Michael Ball, Achal Dave, Kyle Hotchkiss, Ivan Motyashov i~Yuan Yuan. Wymienianie wszystkich tłumaczy zajęłoby zbyt wiele miejsca, ale można ich odnaleźć w~okienku ,,O Snap!...'' dostępnym w~programie. Niniejsze dzieło powstało częściowo w~ramach grantu nr~1143566 udzielonego przez National Science Foundation, a częściowo przy wsparciu firmy MioSoft. \begin{titlepage} @@ -40,11 +40,13 @@ Podręcznik użytkownika \\ \huge Wersja 4.0 \vspace{40pt} \end{center} -\Snap{} to rozszerzona reimplementacja języka Scratch (\url{http://scratch.mit.edu}), która pozwala na tworzenie własnych bloków (ang.\ \textit{Build Your Own Blocks}; stąd dawna nazwa \Snap{a} --- BYOB). Opisywany tu język obsługuje pierwszoklasowe listy, procedury i kontynuacje. Te dodatkowe możliwości sprawiają, że nadaje się on do przeprowadzenia poważnego wstępu do informatyki dla uczniów liceów i szkół wyższych. Aby uruchomić środowisko \Snap{}, wystarczy otworzyć przeglądarkę internetową i wpisać adres \url{http://snap.berkeley.edu/run}, aby zacząć pracę z minimalnym zestawem bloków. Można też użyć adresu \url{http://snap.berkeley.edu/init}, aby załadować niewielki zestaw dodatkowych bloków. Wiąże się to z nieco wolniejszym ładowaniem, ale jest zalecane dla wygody użytkowników (w dalszej części podręcznika będziemy zakładali korzystanie z tej właśnie metody). +\Snap{} to rozszerzona reimplementacja języka Scratch (\url{http://scratch.mit.edu}), która pozwala na tworzenie własnych bloków (ang.\ \textit{Build Your Own Blocks}; stąd dawna nazwa \Snap{a} --- BYOB). Opisywany tu język obsługuje pierwszoklasowe listy, procedury i~kontynuacje. Te dodatkowe możliwości sprawiają, że nadaje się on do przeprowadzenia poważnego wstępu do informatyki dla uczniów liceów i szkół wyższych. Aby uruchomić środowisko \Snap{}, wystarczy otworzyć przeglądarkę internetową i~wpisać adres \url{http://snap.berkeley.edu/run}, aby zacząć pracę z~minimalnym zestawem bloków. Można też użyć adresu \url{http://snap.berkeley.edu/init}, aby załadować niewielki zestaw dodatkowych bloków. Wiąże się to z~nieco wolniejszym ładowaniem, ale jest zalecane dla wygody użytkowników (w~dalszej części podręcznika będziemy zakładali korzystanie z~tej właśnie metody). \end{titlepage} -\chapter{Blocks, Scripts, and Sprites} +\chapter{Bloki, skrypty i duszki} + +W~tym rozdziale poznamy kilka cech języka \Snap{} odziedziczonych po Scratchu; doświadczeni użytkownicy Scratcha powinni przejść od razu do sekcji~\ref{sec:zagnieżdżanie-duszków}. This chapter describes the \Snap{} features inherited from Scratch; experienced Scratch users can skip to section B. @@ -85,7 +87,8 @@ Most command blocks have that brick shape, but some, like the \code{repeat} bloc \section{Sprites and Parallelism} \subsection{Costumes and Sounds} \subsection{Inter-Sprite Communication with Broadcast} -\section{Nesting Sprites: Anchors and Parts} +\section{Zagnieżdżanie duszków: kotwice i części} +\label{sec:zagnieżdżanie-duszków} \section{Reporter Blocks and Expressions} \section{Predicates and Conditional Evaluation} \section{Variables} -- cgit v1.3.1 From aef56afebf1504a9ce09ee5668d00c3c1df17565 Mon Sep 17 00:00:00 2001 From: Nathan Dinsmore Date: Thu, 25 Jun 2015 02:30:06 -0400 Subject: Use associative arrays if Map doesn't exist --- morphic.js | 143 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 70 insertions(+), 73 deletions(-) diff --git a/morphic.js b/morphic.js index aa731ab..e4df8f0 100644 --- a/morphic.js +++ b/morphic.js @@ -3015,101 +3015,98 @@ Morph.prototype.isTransparentAt = function (aPoint) { // Morph duplicating: -Morph.prototype.copy = function () { - var c = copy(this); - c.parent = null; - c.children = []; - c.bounds = this.bounds.copy(); - return c; -}; - -Morph.prototype.fullCopy = function () { - /* - Produce a copy of me with my entire tree of submorphs. Morphs - mentioned more than once are all directed to a single new copy. - Other properties are also *shallow* copied, so you must override - to deep copy Arrays and (complex) Objects - */ - var map = new Map(), c; - c = this.copyRecordingReferences(map); - c.forAllChildren(function (m) { - m.updateReferences(map); - }); - return c; -}; - -Morph.prototype.copyRecordingReferences = function (map) { - /* - Recursively copy this entire composite morph, recording the - correspondence between old and new morphs in the given dictionary. - This dictionary will be used to update intra-composite references - in the copy. See updateReferences(). - - Note: This default implementation copies ONLY morphs. If a morph - stores morphs in other properties that it wants to copy, then it - should override this method to do so. The same goes for morphs that - contain other complex data that should be copied when the morph is - duplicated. - */ - var c = this.copy(); - map.set(this, c); - this.children.forEach(function (m) { - c.add(m.copyRecordingReferences(map)); - }); - return c; -}; - -Morph.prototype.updateReferences = function (map) { - /* - Update intra-morph references within a composite morph that has - been copied. For example, if a button refers to morph X in the - orginal composite then the copy of that button in the new composite - should refer to the copy of X in new composite, not the original X. - */ - var property, value, reference; - for (var properties = Object.keys(this), l = properties.length, i = 0; i < l; ++i) { - property = properties[i]; - value = this[property]; - if (value && value.isMorph) { - reference = map.get(value); - if (reference) this[property] = reference; - } - } -}; - -if (typeof Map === 'undefined') { - // use normal objects + stringification if Map doesn't exist +(function () { + // don't overwrite the global Map with AssociativeMap + var Map = window.Map || AssociativeMap; + + Morph.prototype.copy = function () { + var c = copy(this); + c.parent = null; + c.children = []; + c.bounds = this.bounds.copy(); + return c; + }; Morph.prototype.fullCopy = function () { - var dict = {}, c; - c = this.copyRecordingReferences(dict); + /* + Produce a copy of me with my entire tree of submorphs. Morphs + mentioned more than once are all directed to a single new copy. + Other properties are also *shallow* copied, so you must override + to deep copy Arrays and (complex) Objects + */ + var map = new Map(), c; + c = this.copyRecordingReferences(map); c.forAllChildren(function (m) { - m.updateReferences(dict); + m.updateReferences(map); }); return c; }; - Morph.prototype.copyRecordingReferences = function (dict) { + Morph.prototype.copyRecordingReferences = function (map) { + /* + Recursively copy this entire composite morph, recording the + correspondence between old and new morphs in the given dictionary. + This dictionary will be used to update intra-composite references + in the copy. See updateReferences(). + + Note: This default implementation copies ONLY morphs. If a morph + stores morphs in other properties that it wants to copy, then it + should override this method to do so. The same goes for morphs that + contain other complex data that should be copied when the morph is + duplicated. + */ var c = this.copy(); - dict[this] = c; + map.set(this, c); this.children.forEach(function (m) { - c.add(m.copyRecordingReferences(dict)); + c.add(m.copyRecordingReferences(map)); }); return c; }; - Morph.prototype.updateReferences = function (dict) { + Morph.prototype.updateReferences = function (map) { + /* + Update intra-morph references within a composite morph that has + been copied. For example, if a button refers to morph X in the + orginal composite then the copy of that button in the new composite + should refer to the copy of X in new composite, not the original X. + */ var property, value, reference; for (var properties = Object.keys(this), l = properties.length, i = 0; i < l; ++i) { property = properties[i]; value = this[property]; if (value && value.isMorph) { - reference = dict[value]; + reference = map.get(value); if (reference) this[property] = reference; } } }; -} + + // associative array fallback for Map + + function AssociativeMap() { + this.keys = []; + this.values = []; + } + + AssociativeMap.prototype.get = function(key) { + for (var keys = this.keys, i = keys.length; i--;) { + if (keys[i] === key) return this.values[i]; + } + return undefined; + }; + + AssociativeMap.prototype.set = function(key, value) { + for (var keys = this.keys, i = keys.length; i--;) { + if (keys[i] === key) { + this.values[i] = value; + return; + } + } + keys.push(key); + this.values.push(value); + }; + +}()); // Morph dragging and dropping: -- cgit v1.3.1 From 809e1a4673a275ed2adebb3e1b30610654585d98 Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Thu, 25 Jun 2015 09:50:52 +0200 Subject: Don't treat the exclamation point in Snap logo as sentence-ending character --- help/manual/common/defs.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/help/manual/common/defs.tex b/help/manual/common/defs.tex index 50f0c24..52fe21d 100644 --- a/help/manual/common/defs.tex +++ b/help/manual/common/defs.tex @@ -13,7 +13,7 @@ \newcommand{\Snap}[1]{% \textsf{% Snap% - \ifx\\#1\\\textit{!}% + \ifx\\#1\\\textit{!\@}% \else #1% \fi% }% -- cgit v1.3.1 From 2f0d52d7dbf0a962a986df6226ad3ded58480ab0 Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Thu, 25 Jun 2015 12:03:26 +0200 Subject: Don't use Cabin; it doesn't have Polish characters. --- help/manual/common/defs.tex | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/help/manual/common/defs.tex b/help/manual/common/defs.tex index 52fe21d..d086975 100644 --- a/help/manual/common/defs.tex +++ b/help/manual/common/defs.tex @@ -1,7 +1,6 @@ -\usepackage{baskervald} % Default font -\usepackage{cabin} % Sans serif font \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} +\usepackage{baskervald} % Default font \usepackage{setspace} \onehalfspacing \usepackage{graphicx} \usepackage{textcomp} @@ -36,4 +35,4 @@ \begin{center} \includegraphics[scale=\defaultGraphicsScale]{#1} \end{center} -} \ No newline at end of file +} -- cgit v1.3.1 From 58cae438bbd48f4e08f265917d4aada9e06e6cb6 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 14:43:09 +0200 Subject: Simplify Morphic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * revert to “new” for object creation (for now) * take out fallback for missing Map --- morphic.js | 336 ++++++++++++++++++++++++++----------------------------------- 1 file changed, 143 insertions(+), 193 deletions(-) diff --git a/morphic.js b/morphic.js index e4df8f0..cb2aa32 100644 --- a/morphic.js +++ b/morphic.js @@ -829,7 +829,8 @@ }; If your new morph stores or references other morphs outside of the - submorph tree in other properties, you may need to override the default + submorph tree in other properties, be sure to also override the + default updateReferences() @@ -1035,7 +1036,7 @@ ---------------------- Joe Otto found and fixed many early bugs and taught me some tricks. Nathan Dinsmore contributed mouse wheel scrolling, cached - background texture handling and countless bug fixes. + background texture handling, countless bug fixes and optimizations. Ian Reynolds contributed backspace key handling for Chrome. Davide Della Casa contributed performance optimizations for Firefox. @@ -1047,7 +1048,7 @@ /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, FileList, getBlurredShadowSupport*/ -var morphicVersion = '2015-May-01'; +var morphicVersion = '2015-June-25'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -1257,7 +1258,7 @@ function copy(target) { target.constructor !== Object) { c = Object.create(target.constructor.prototype); keys = Object.keys(target); - for (l = keys.length, i = 0; i < l; ++i) { + for (l = keys.length, i = 0; i < l; i += 1) { property = keys[i]; c[property] = target[property]; } @@ -2158,7 +2159,7 @@ var TextMorph; // Morph inherits from Node: -Morph.prototype = Object.create(Node.prototype); +Morph.prototype = new Node(); Morph.prototype.constructor = Morph; Morph.uber = Node.prototype; @@ -2212,7 +2213,7 @@ Morph.prototype.init = function (noDraw) { this.isTemplate = false; this.acceptsDrops = false; this.noticesTransparentClick = false; - if (!noDraw) { this.drawNew(); } + if (!noDraw) {this.drawNew(); } this.fps = 0; this.customContextMenu = null; this.lastTime = Date.now(); @@ -2405,9 +2406,9 @@ Morph.prototype.moveBy = function (delta) { Morph.prototype.silentMoveBy = function (delta) { this.bounds = this.bounds.translateBy(delta); - for (var children = this.children, i = children.length; i--;) { - children[i].silentMoveBy(delta); - } + this.children.forEach(function (child) { + child.silentMoveBy(delta); + }); }; Morph.prototype.setPosition = function (aPoint) { @@ -2920,6 +2921,18 @@ Morph.prototype.addBack = function (aMorph) { this.addChildFirst(aMorph); }; +Morph.prototype.topMorphAt = function (point) { + var i, result; + if (!this.isVisible) {return null; } + for (i = this.children.length - 1; i >= 0; i -= 1) { + result = this.children[i].topMorphAt(point); + if (result) {return result; } + } + return this.bounds.containsPoint(point) && + (this.noticesTransparentClick || !this.isTransparentAt(point)) ? this + : null; +}; + Morph.prototype.topMorphSuchThat = function (predicate) { var next; if (predicate.call(null, this)) { @@ -2935,30 +2948,6 @@ Morph.prototype.topMorphSuchThat = function (predicate) { return null; }; -Morph.prototype.morphAt = function (aPoint) { - var morphs = this.allChildren().slice(0).reverse(), - result = null; - morphs.forEach(function (m) { - if (m.fullBounds().containsPoint(aPoint) && - (result === null)) { - result = m; - } - }); - return result; -}; - -/* - alternative - more elegant and possibly more - performant - solution for morphAt. - Has some issues, commented out for now - -Morph.prototype.morphAt = function (aPoint) { - return this.topMorphSuchThat(function (m) { - return m.fullBounds().containsPoint(aPoint); - }); -}; -*/ - Morph.prototype.overlappedMorphs = function () { //exclude the World var world = this.world(), @@ -3015,98 +3004,72 @@ Morph.prototype.isTransparentAt = function (aPoint) { // Morph duplicating: -(function () { - // don't overwrite the global Map with AssociativeMap - var Map = window.Map || AssociativeMap; - - Morph.prototype.copy = function () { - var c = copy(this); - c.parent = null; - c.children = []; - c.bounds = this.bounds.copy(); - return c; - }; +Morph.prototype.copy = function () { + var c = copy(this); + c.parent = null; + c.children = []; + c.bounds = this.bounds.copy(); + return c; +}; - Morph.prototype.fullCopy = function () { - /* - Produce a copy of me with my entire tree of submorphs. Morphs - mentioned more than once are all directed to a single new copy. - Other properties are also *shallow* copied, so you must override - to deep copy Arrays and (complex) Objects - */ - var map = new Map(), c; - c = this.copyRecordingReferences(map); - c.forAllChildren(function (m) { - m.updateReferences(map); - }); - return c; - }; +Morph.prototype.fullCopy = function () { + /* + Produce a copy of me with my entire tree of submorphs. Morphs + mentioned more than once are all directed to a single new copy. + Other properties are also *shallow* copied, so you must override + to deep copy Arrays and (complex) Objects + */ + var map = new Map(), c; + c = this.copyRecordingReferences(map); + c.forAllChildren(function (m) { + m.updateReferences(map); + }); + return c; +}; - Morph.prototype.copyRecordingReferences = function (map) { - /* - Recursively copy this entire composite morph, recording the - correspondence between old and new morphs in the given dictionary. - This dictionary will be used to update intra-composite references - in the copy. See updateReferences(). - - Note: This default implementation copies ONLY morphs. If a morph - stores morphs in other properties that it wants to copy, then it - should override this method to do so. The same goes for morphs that - contain other complex data that should be copied when the morph is - duplicated. - */ - var c = this.copy(); - map.set(this, c); - this.children.forEach(function (m) { - c.add(m.copyRecordingReferences(map)); - }); - return c; - }; +Morph.prototype.copyRecordingReferences = function (map) { + /* + Recursively copy this entire composite morph, recording the + correspondence between old and new morphs in the given dictionary. + This dictionary will be used to update intra-composite references + in the copy. See updateReferences(). + + Note: This default implementation copies ONLY morphs. If a morph + stores morphs in other properties that it wants to copy, then it + should override this method to do so. The same goes for morphs that + contain other complex data that should be copied when the morph is + duplicated. + */ + var c = this.copy(); + map.set(this, c); + this.children.forEach(function (m) { + c.add(m.copyRecordingReferences(map)); + }); + return c; +}; - Morph.prototype.updateReferences = function (map) { - /* - Update intra-morph references within a composite morph that has - been copied. For example, if a button refers to morph X in the - orginal composite then the copy of that button in the new composite - should refer to the copy of X in new composite, not the original X. - */ - var property, value, reference; - for (var properties = Object.keys(this), l = properties.length, i = 0; i < l; ++i) { - property = properties[i]; - value = this[property]; - if (value && value.isMorph) { - reference = map.get(value); - if (reference) this[property] = reference; - } +Morph.prototype.updateReferences = function (map) { + /* + Update intra-morph references within a composite morph that has + been copied. For example, if a button refers to morph X in the + orginal composite then the copy of that button in the new composite + should refer to the copy of X in new composite, not the original X. + */ + var properties = Object.keys(this), + l = properties.length, + property, + value, + reference, + i; + for (i = 0; i < l; i += 1) { + property = properties[i]; + value = this[property]; + if (value && value.isMorph) { + reference = map.get(value); + if (reference) { this[property] = reference; } } - }; - - // associative array fallback for Map - - function AssociativeMap() { - this.keys = []; - this.values = []; } - - AssociativeMap.prototype.get = function(key) { - for (var keys = this.keys, i = keys.length; i--;) { - if (keys[i] === key) return this.values[i]; - } - return undefined; - }; - - AssociativeMap.prototype.set = function(key, value) { - for (var keys = this.keys, i = keys.length; i--;) { - if (keys[i] === key) { - this.values[i] = value; - return; - } - } - keys.push(key); - this.values.push(value); - }; - -}()); +}; // Morph dragging and dropping: @@ -3713,7 +3676,7 @@ Morph.prototype.overlappingImage = function (otherMorph) { // ShadowMorph inherits from Morph: -ShadowMorph.prototype = Object.create(Morph.prototype); +ShadowMorph.prototype = new Morph(); ShadowMorph.prototype.constructor = ShadowMorph; ShadowMorph.uber = Morph.prototype; @@ -3723,13 +3686,17 @@ function ShadowMorph() { this.init(); } +ShadowMorph.prototype.topMorphAt = function () { + return null; +}; + // HandleMorph //////////////////////////////////////////////////////// // I am a resize / move handle that can be attached to any Morph // HandleMorph inherits from Morph: -HandleMorph.prototype = Object.create(Morph.prototype); +HandleMorph.prototype = new Morph(); HandleMorph.prototype.constructor = HandleMorph; HandleMorph.uber = Morph.prototype; @@ -3970,7 +3937,7 @@ var PenMorph; // PenMorph inherits from Morph: -PenMorph.prototype = Object.create(Morph.prototype); +PenMorph.prototype = new Morph(); PenMorph.prototype.constructor = PenMorph; PenMorph.uber = Morph.prototype; @@ -4202,7 +4169,7 @@ var ColorPaletteMorph; // ColorPaletteMorph inherits from Morph: -ColorPaletteMorph.prototype = Object.create(Morph.prototype); +ColorPaletteMorph.prototype = new Morph(); ColorPaletteMorph.prototype.constructor = ColorPaletteMorph; ColorPaletteMorph.uber = Morph.prototype; @@ -4320,7 +4287,7 @@ var GrayPaletteMorph; // GrayPaletteMorph inherits from ColorPaletteMorph: -GrayPaletteMorph.prototype = Object.create(ColorPaletteMorph.prototype); +GrayPaletteMorph.prototype = new ColorPaletteMorph(); GrayPaletteMorph.prototype.constructor = GrayPaletteMorph; GrayPaletteMorph.uber = ColorPaletteMorph.prototype; @@ -4351,7 +4318,7 @@ GrayPaletteMorph.prototype.drawNew = function () { // ColorPickerMorph inherits from Morph: -ColorPickerMorph.prototype = Object.create(Morph.prototype); +ColorPickerMorph.prototype = new Morph(); ColorPickerMorph.prototype.constructor = ColorPickerMorph; ColorPickerMorph.uber = Morph.prototype; @@ -4420,7 +4387,7 @@ var BlinkerMorph; // BlinkerMorph inherits from Morph: -BlinkerMorph.prototype = Object.create(Morph.prototype); +BlinkerMorph.prototype = new Morph(); BlinkerMorph.prototype.constructor = BlinkerMorph; BlinkerMorph.uber = Morph.prototype; @@ -4453,7 +4420,7 @@ var CursorMorph; // CursorMorph inherits from BlinkerMorph: -CursorMorph.prototype = Object.create(BlinkerMorph.prototype); +CursorMorph.prototype = new BlinkerMorph(); CursorMorph.prototype.constructor = CursorMorph; CursorMorph.uber = BlinkerMorph.prototype; @@ -4873,7 +4840,7 @@ var BoxMorph; // BoxMorph inherits from Morph: -BoxMorph.prototype = Object.create(Morph.prototype); +BoxMorph.prototype = new Morph(); BoxMorph.prototype.constructor = BoxMorph; BoxMorph.uber = Morph.prototype; @@ -5081,7 +5048,7 @@ var SpeechBubbleMorph; // SpeechBubbleMorph inherits from BoxMorph: -SpeechBubbleMorph.prototype = Object.create(BoxMorph.prototype); +SpeechBubbleMorph.prototype = new BoxMorph(); SpeechBubbleMorph.prototype.constructor = SpeechBubbleMorph; SpeechBubbleMorph.uber = BoxMorph.prototype; @@ -5381,7 +5348,7 @@ var CircleBoxMorph; // CircleBoxMorph inherits from Morph: -CircleBoxMorph.prototype = Object.create(Morph.prototype); +CircleBoxMorph.prototype = new Morph(); CircleBoxMorph.prototype.constructor = CircleBoxMorph; CircleBoxMorph.uber = Morph.prototype; @@ -5501,7 +5468,7 @@ var SliderButtonMorph; // SliderButtonMorph inherits from CircleBoxMorph: -SliderButtonMorph.prototype = Object.create(CircleBoxMorph.prototype); +SliderButtonMorph.prototype = new CircleBoxMorph(); SliderButtonMorph.prototype.constructor = SliderButtonMorph; SliderButtonMorph.uber = CircleBoxMorph.prototype; @@ -5713,7 +5680,7 @@ SliderButtonMorph.prototype.mouseMove = function () { // SliderMorph inherits from CircleBoxMorph: -SliderMorph.prototype = Object.create(CircleBoxMorph.prototype); +SliderMorph.prototype = new CircleBoxMorph(); SliderMorph.prototype.constructor = SliderMorph; SliderMorph.uber = CircleBoxMorph.prototype; @@ -6064,7 +6031,7 @@ var MouseSensorMorph; // MouseSensorMorph inherits from BoxMorph: -MouseSensorMorph.prototype = Object.create(BoxMorph.prototype); +MouseSensorMorph.prototype = new BoxMorph(); MouseSensorMorph.prototype.constructor = MouseSensorMorph; MouseSensorMorph.uber = BoxMorph.prototype; @@ -6138,7 +6105,7 @@ var TriggerMorph; // InspectorMorph inherits from BoxMorph: -InspectorMorph.prototype = Object.create(BoxMorph.prototype); +InspectorMorph.prototype = new BoxMorph(); InspectorMorph.prototype.constructor = InspectorMorph; InspectorMorph.uber = BoxMorph.prototype; @@ -6633,7 +6600,7 @@ var MenuItemMorph; // MenuMorph inherits from BoxMorph: -MenuMorph.prototype = Object.create(BoxMorph.prototype); +MenuMorph.prototype = new BoxMorph(); MenuMorph.prototype.constructor = MenuMorph; MenuMorph.uber = BoxMorph.prototype; @@ -6928,7 +6895,7 @@ MenuMorph.prototype.popUpCenteredInWorld = function (world) { // StringMorph inherits from Morph: -StringMorph.prototype = Object.create(Morph.prototype); +StringMorph.prototype = new Morph(); StringMorph.prototype.constructor = StringMorph; StringMorph.uber = Morph.prototype; @@ -7374,7 +7341,11 @@ StringMorph.prototype.selectionStartSlot = function () { }; StringMorph.prototype.clearSelection = function () { - if (!this.currentlySelecting && this.startMark === 0 && this.endMark === 0) return; + if (!this.currentlySelecting && + this.startMark === 0 && + this.endMark === 0) { + return; + } this.currentlySelecting = false; this.startMark = 0; this.endMark = 0; @@ -7464,7 +7435,7 @@ StringMorph.prototype.disableSelecting = function () { // TextMorph inherits from Morph: -TextMorph.prototype = Object.create(Morph.prototype); +TextMorph.prototype = new Morph(); TextMorph.prototype.constructor = TextMorph; TextMorph.uber = Morph.prototype; @@ -7989,7 +7960,7 @@ TextMorph.prototype.inspectIt = function () { // TriggerMorph inherits from Morph: -TriggerMorph.prototype = Object.create(Morph.prototype); +TriggerMorph.prototype = new Morph(); TriggerMorph.prototype.constructor = TriggerMorph; TriggerMorph.uber = Morph.prototype; @@ -8244,7 +8215,7 @@ var MenuItemMorph; // MenuItemMorph inherits from TriggerMorph: -MenuItemMorph.prototype = Object.create(TriggerMorph.prototype); +MenuItemMorph.prototype = new TriggerMorph(); MenuItemMorph.prototype.constructor = MenuItemMorph; MenuItemMorph.uber = TriggerMorph.prototype; @@ -8403,7 +8374,7 @@ MenuItemMorph.prototype.isSelectedListItem = function () { // Frames inherit from Morph: -FrameMorph.prototype = Object.create(Morph.prototype); +FrameMorph.prototype = new Morph(); FrameMorph.prototype.constructor = FrameMorph; FrameMorph.uber = Morph.prototype; @@ -8459,6 +8430,21 @@ FrameMorph.prototype.fullDrawOn = function (aCanvas, aRect) { }); }; +// FrameMorph navigation: + +FrameMorph.prototype.topMorphAt = function (point) { + var i, result; + if (!(this.isVisible && this.bounds.containsPoint(point))) { + return null; + } + for (i = this.children.length - 1; i >= 0; i -= 1) { + result = this.children[i].topMorphAt(point); + if (result) {return result; } + } + return this.noticesTransparentClick || + !this.isTransparentAt(point) ? this : null; +}; + // FrameMorph scrolling support: FrameMorph.prototype.submorphBounds = function () { @@ -8572,7 +8558,7 @@ FrameMorph.prototype.keepAllSubmorphsWithin = function () { // ScrollFrameMorph //////////////////////////////////////////////////// -ScrollFrameMorph.prototype = Object.create(FrameMorph.prototype); +ScrollFrameMorph.prototype = new FrameMorph(); ScrollFrameMorph.prototype.constructor = ScrollFrameMorph; ScrollFrameMorph.uber = FrameMorph.prototype; @@ -8893,19 +8879,19 @@ ScrollFrameMorph.prototype.mouseScroll = function (y, x) { // ScrollFrameMorph duplicating: ScrollFrameMorph.prototype.updateReferences = function (map) { - var self = this; + var myself = this; ScrollFrameMorph.uber.updateReferences.call(this, map); if (this.hBar) { this.hBar.action = function (num) { - self.contents.setPosition( - new Point(self.left() - num, self.contents.position().y) + myself.contents.setPosition( + new Point(myself.left() - num, myself.contents.position().y) ); }; } if (this.vBar) { this.vBar.action = function (num) { - self.contents.setPosition( - new Point(self.contents.position().x, self.top() - num) + myself.contents.setPosition( + new Point(myself.contents.position().x, myself.top() - num) ); }; } @@ -8938,7 +8924,7 @@ ScrollFrameMorph.prototype.toggleTextLineWrapping = function () { // ListMorph /////////////////////////////////////////////////////////// -ListMorph.prototype = Object.create(ScrollFrameMorph.prototype); +ListMorph.prototype = new ScrollFrameMorph(); ListMorph.prototype.constructor = ListMorph; ListMorph.uber = ScrollFrameMorph.prototype; @@ -9076,7 +9062,7 @@ ListMorph.prototype.setExtent = function (aPoint) { // StringFieldMorph inherit from FrameMorph: -StringFieldMorph.prototype = Object.create(FrameMorph.prototype); +StringFieldMorph.prototype = new FrameMorph(); StringFieldMorph.prototype.constructor = StringFieldMorph; StringFieldMorph.uber = FrameMorph.prototype; @@ -9176,7 +9162,7 @@ var BouncerMorph; // Bouncers inherit from Morph: -BouncerMorph.prototype = Object.create(Morph.prototype); +BouncerMorph.prototype = new Morph(); BouncerMorph.prototype.constructor = BouncerMorph; BouncerMorph.uber = Morph.prototype; @@ -9263,7 +9249,7 @@ BouncerMorph.prototype.step = function () { // HandMorph inherits from Morph: -HandMorph.prototype = Object.create(Morph.prototype); +HandMorph.prototype = new Morph(); HandMorph.prototype.constructor = HandMorph; HandMorph.uber = Morph.prototype; @@ -9290,59 +9276,24 @@ HandMorph.prototype.init = function (aWorld) { this.contextMenuEnabled = false; }; -HandMorph.prototype.changed = -HandMorph.prototype.fullChanged = function () { +HandMorph.prototype.changed = function () { var b; if (this.world !== null) { b = this.fullBounds(); if (!b.extent().eq(new Point())) { - this.world.broken.push(this.fullBounds().spread()); + this.world.broken.push(b.spread()); } } }; +HandMorph.prototype.fullChanged = HandMorph.prototype.changed; + // HandMorph navigation: -Morph.prototype.topMorphAt = function (p) { - if (!this.isVisible) return null; - for (var c = this.children, i = c.length; i--;) { - var result = c[i].topMorphAt(p); - if (result) return result; - } - return this.bounds.containsPoint(p) && (this.noticesTransparentClick || !this.isTransparentAt(p)) ? this : null; -}; -FrameMorph.prototype.topMorphAt = function (p) { - if (!(this.isVisible && this.bounds.containsPoint(p))) return null; - for (var c = this.children, i = c.length; i--;) { - var result = c[i].topMorphAt(p); - if (result) return result; - } - return this.noticesTransparentClick || !this.isTransparentAt(p) ? this : null; -}; -ShadowMorph.prototype.topMorphAt = function () { - return null; -}; HandMorph.prototype.morphAtPointer = function () { return this.world.topMorphAt(this.bounds.origin) || this.world; }; -/* - alternative - more elegant and possibly more - performant - solution for morphAtPointer. - Has some issues, commented out for now - -HandMorph.prototype.morphAtPointer = function () { - var myself = this; - return this.world.topMorphSuchThat(function (m) { - return m.visibleBounds().containsPoint(myself.bounds.origin) && - m.isVisible && - (m.noticesTransparentClick || - (! m.isTransparentAt(myself.bounds.origin))) && - (! (m instanceof ShadowMorph)); - }); -}; -*/ - HandMorph.prototype.allMorphsAtPointer = function () { var morphs = this.world.allChildren(), myself = this; @@ -9881,14 +9832,13 @@ HandMorph.prototype.destroyTemporaries = function () { }); }; - // WorldMorph ////////////////////////////////////////////////////////// // I represent the element // WorldMorph inherits from FrameMorph: -WorldMorph.prototype = Object.create(FrameMorph.prototype); +WorldMorph.prototype = new FrameMorph(); WorldMorph.prototype.constructor = WorldMorph; WorldMorph.uber = FrameMorph.prototype; -- 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 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 8a7bc380a8df03f13133aae98654db6df51ccded Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 15:20:05 +0200 Subject: wrap credits tab in "about" Dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to accommodate for @nathan ’s abundant contributions :-) --- gui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui.js b/gui.js index f50fd47..59d0de7 100644 --- a/gui.js +++ b/gui.js @@ -2648,7 +2648,7 @@ IDE_Morph.prototype.aboutSnap = function () { creditsTxt = localize('Contributors') + '\n\nNathan Dinsmore: Saving/Loading, Snap-Logo Design, ' - + 'countless bugfixes and optimizations' + + '\ncountless bugfixes and optimizations' + '\nKartik Chandra: Paint Editor' + '\nMichael Ball: Time/Date UI, many bugfixes' + '\n"Ava" Yuan Yuan: Graphic Effects' -- cgit v1.3.1 From f4ff1056eae012b9a257c7dea88af3d007012632 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 15:30:58 +0200 Subject: update threads.js version --- threads.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/threads.js b/threads.js index efe9ba4..edbe2cf 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2015-May-01'; +modules.threads = '2015-June-25'; var ThreadManager; var Process; @@ -2641,7 +2641,8 @@ Process.prototype.reportTimer = function () { // Process Dates and times in Snap Process.prototype.reportDate = function (datefn) { - var inputFn = this.inputOption(datefn), + var currDate, func, result, + inputFn = this.inputOption(datefn), // Map block options to built-in functions dateMap = { 'year' : 'getFullYear', @@ -2655,16 +2656,14 @@ Process.prototype.reportDate = function (datefn) { }; if (!dateMap[inputFn]) { return ''; } - - var currDate = new Date(), - func = dateMap[inputFn], - result = currDate[func](); + currDate = new Date(); + func = dateMap[inputFn]; + result = currDate[func](); // Show months as 1-12 and days as 1-7 if (inputFn === 'month' || inputFn === 'day of week') { result += 1; } - return result; }; -- 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(-) 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 From 87c9655335a688bf5ec52127ce1fde46d4c60d58 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 15:48:26 +0200 Subject: add some spaces to satisfy old.jslint.com :-) --- gui.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gui.js b/gui.js index b4f0faa..0fae8d3 100644 --- a/gui.js +++ b/gui.js @@ -84,8 +84,8 @@ var JukeboxMorph; // Get the full url without "snap.html" var baseUrl = document.URL.split('/'); -baseUrl.pop(baseUrl.length-1); -baseUrl = baseUrl.join('/')+'/'; +baseUrl.pop(baseUrl.length - 1); +baseUrl = baseUrl.join('/') + '/'; // IDE_Morph /////////////////////////////////////////////////////////// @@ -4834,8 +4834,7 @@ ProjectDialogMorph.prototype.openProject = function () { if (this.source === 'cloud') { this.openCloudProject(proj); } else if (this.source === 'examples') { - src = this.ide.getURL(baseUrl + 'Examples/' + proj.name + '.xml' - ); + src = this.ide.getURL(baseUrl + 'Examples/' + proj.name + '.xml'); this.ide.openProjectString(src); this.destroy(); } else { // 'local' -- cgit v1.3.1 From 8b9e7ea4eafb86f02db3b8891ee937233d9fa4b0 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 16:00:17 +0200 Subject: update French translation, thanks, Frédéric Bonnaud! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang-fr.js | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- locale.js | 4 +- 2 files changed, 151 insertions(+), 7 deletions(-) diff --git a/lang-fr.js b/lang-fr.js index 4198bf7..20da480 100644 --- a/lang-fr.js +++ b/lang-fr.js @@ -185,7 +185,7 @@ SnapTranslator.dict.fr = { 'translator_e-mail': 'i.scool@mac.com', // optional 'last_changed': - '2014-02-04', // this, too, will appear in the Translators tab + '2015-06-25', // this, too, will appear in the Translators tab // GUI // control bar: @@ -392,7 +392,7 @@ SnapTranslator.dict.fr = { 'clear': 'effacer tout', 'pen down': - 'stylo en position d\u0027\u00EAcriture', + 'stylo en position d\u0027\u00E9criture', 'pen up': 'relever le stylo', 'set pen color to %clr': @@ -419,6 +419,8 @@ SnapTranslator.dict.fr = { 'Quand %keyHat est press\u00E9', 'when I am clicked': 'Quand je suis press\u00E9 ', + 'when I am %interaction': + 'Quand je suis %interaction', 'when I receive %msgHat': 'Quand je re\u00E7ois %msgHat', 'broadcast %msg': @@ -447,6 +449,10 @@ SnapTranslator.dict.fr = { 'arr\u00EAter le bloc', 'stop script': 'arr\u00EAter le script', + 'stop %stopOthersChoices': + 'arr\u00EAter %stopOthersChoices', + 'stop %stopChoices': + 'arr\u00EAter %stopChoices', 'stop all %stop': 'arr\u00EAter tout %stop', 'run %cmdRing %inputs': @@ -469,8 +475,16 @@ SnapTranslator.dict.fr = { 'moi-m\u00EAme', 'delete this clone': 'supprime ce clone', - 'pause all': - 'mettre en pause', + 'pause all %pause': + 'mettre en pause %pause', + 'all but this script': + 'tout sauf ce lutin', + 'other scripts in sprite': + 'les autres scripts de ce lutin', + 'this script': + 'ce script', + 'this block': + 'ce bloc', // sensing: 'touching %col ?': @@ -958,6 +972,8 @@ SnapTranslator.dict.fr = { 'tabulations', 'cr': 'retours de ligne', + 'letter': + 'lettres', // About Snap 'About Snap': @@ -1162,5 +1178,133 @@ SnapTranslator.dict.fr = { 'last': 'dernier', 'any': - 'n\u0027importe quel' + 'n\u0027importe quel', + + // miscellaneous + 'find blocks...': + 'chercher des blocs...', + 'hide primitives': + 'cacher les primitives', + 'show primitives': + 'montrer les primitives', + 'Login...': + 'Connexion...', + 'Signup...': + 'S\u0027enregistrer...', + 'Reset Password...': + 'Remise \u00E0 z\u00E9ro du mot de passe', + 'show all': + 'tout montrer', + 'pic...': + 'image...', + 'open a new window\nwith a picture of the stage': + 'ouvre une nouvelle fen\u00EAtre\navec une image de la sc\u00E8ne', + 'scripts pic...': + 'image des scripts...', + 'open a new window\nwith a picture of all scripts': + 'ouvre une nouvelle fen\u00EAtre\navec une image de tous les scripts', + 'Stage size...': + 'Taille de la sc\u00E8ne...', + 'Zoom blocks...': + 'Agrandir les blocs...', + + 'Plain prototype labels': + '\u00C9tiquettes simples de d\u00E9finition', + 'uncheck to always show (+) symbols\nin block prototype labels': + 'd\u00E9cocher pour montrer en permance le symbole (+)\ndans les \u00e9tiquettes de d\u00E9finition de bloc', + 'check to hide (+) symbols\nin block prototype labels': + 'cocher pour cacher le symbole (+)\ndans les \u00e9tiquettes de d\u00E9finition de bloc', + + 'check for flat ends of lines': + 'cocher pour dessiner des fins de ligne plates', + 'uncheck for round ends of lines': + 'd\u00E9cocher pour dessiner des fins de lignes arrondies', + 'Flat line ends': + 'Fins de ligne plates', + + 'Codification support': + 'Support de la \u00AB codification \u00BB', + 'uncheck to disable\nblock to text mapping features': + 'd\u00E9cocher pour d\u00E9activer\nla fonction de transformation :\nbloc vers texte', + 'check for block\nto text mapping features': + 'cocher pour activer\nla fonction de transformation :\nbloc vers texte', + + 'current %dates': + 'date courante %dates', + 'year':'ann\u00E9e', + 'month':'mois', + 'date':'jour', + 'hour':'heure', + 'minute':'minute', + 'second':'seconde', + 'time in milliseconds': + 'heure en millisecondes', + 'day of week': + 'jour de la semaine', + + 'brightness': + 'luminosit\u00E9', + 'transparence': + 'transparence', + 'negative': + 'n\u00E9gatif', + 'comic': + 'bande dessin\u00E9e', + + 'clicked': + 'cliqu\u00E9', + 'pressed': + 'press\u00E9', + 'dropped': + 'd\u00E9pos\u00E9', + 'mouse-entered': + 'survol\u00E9', + 'mouse-departed': + 'quitt\u00E9', + + 'JavaScript function ( %mult%s ) { %code }': + 'fonction JavaScript ( %mult%s ) { %code }', + + + // Copy / Paste + 'Press CTRL+C one more time to effectively copy to clipboard.': + 'Taper une nouvelle fois sur CTRL+C pour copier effectivement vers le presse-papier.', + 'Press CTRL+V one more time to effectively paste from clipboard.': + 'Taper une nouvelle fois sur CTRL+V pour coller effectivement depuis le presse-papier.', + 'Press CTRL+X one more time to effectively cut to clipboard.': + 'Taper une nouvelle fois sur CTRL+X pour couper effectivement vers le presse-papier.', + + // Paint.js + 'undo':'d\u00E9faire', + 'Paintbrush tool\n(free draw)': + 'Pinceau\n(dessin \u00E0 main lev\u00E9)', + 'Stroked Rectangle\n(shift: square)': + 'Rectangle\n(Maj: carr\u00E9)', + 'Stroked Ellipse\n(shift: circle)': + 'Ellipse\n(Maj: cercle)', + 'Eraser tool': + 'Gomme', + 'Set the rotation center': + 'Fixe le centre de rotation', + 'Line tool\n(shift: vertical/horizontal)': + 'Ligne\n(Maj: verticale/horizontale)', + 'Filled Rectangle\n(shift: square)': + 'Rectangle plein\n(Maj: carr\u00E9)', + 'Filled Ellipse\n(shift: circle)': + 'Ellipse pleine\n(Maj: cercle)', + 'Fill a region': + 'Remplir une r\u00E9gion', + 'Pipette tool\n(pick a color anywhere)': + 'Pipette\n(s\u00E9lectionnez une couleur n\u0027importe o\u00F9', + 'grow':'agrandir', + 'shrink':'r\u00E9duire', + 'flip \u2194': + 'miroir \u2194', + 'flip \u2195': + 'miroir \u2195', + 'Brush size': + 'Taille de pinceau', + 'Constrain proportions of shapes?\n(you can also hold shift)': + 'Contrainte sur les proportions de la forme ?\n(vous pouvez aussi maintenir appuy\u00E9 Maj)' + }; diff --git a/locale.js b/locale.js index 7407180..af1e0f4 100644 --- a/locale.js +++ b/locale.js @@ -42,7 +42,7 @@ /*global modules, contains*/ -modules.locale = '2015-May-18'; +modules.locale = '2015-June-25'; // Global stuff @@ -257,7 +257,7 @@ SnapTranslator.dict.fr = { 'translator_e-mail': 'i.scool@mac.com', 'last_changed': - '2014-02-04' + '2015-06-25' }; SnapTranslator.dict.si = { -- cgit v1.3.1 From de82d373be95a568279f318877760bf7ae11a7e4 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 16:35:00 +0200 Subject: add indentation again to please old.jslint.com :-) --- gui.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gui.js b/gui.js index f711847..eee2bd5 100644 --- a/gui.js +++ b/gui.js @@ -5040,9 +5040,9 @@ ProjectDialogMorph.prototype.shareProject = function () { if (proj.ProjectName === ide.projectName) { var usr = SnapCloud.username, projectId = 'Username=' + - encodeURIComponent(usr.toLowerCase()) + - '&ProjectName=' + - encodeURIComponent(proj.projectName); + encodeURIComponent(usr.toLowerCase()) + + '&ProjectName=' + + encodeURIComponent(proj.projectName); location.hash = projectId; } }, -- cgit v1.3.1 From f39b274fdee8c0a50362945c12bcf2fadd326aeb Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Thu, 25 Jun 2015 23:30:38 +0200 Subject: Translated until section A of chapter I --- help/manual/en/snap-manual.tex | 3 ++- help/manual/pl/snap-podrecznik.tex | 29 ++++++++++++++--------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/help/manual/en/snap-manual.tex b/help/manual/en/snap-manual.tex index b59e4e3..140e552 100644 --- a/help/manual/en/snap-manual.tex +++ b/help/manual/en/snap-manual.tex @@ -53,6 +53,7 @@ Start \Snap{}. You should see the following arrangement of regions in the window A \Snap{} program consists of one or more \emph{scripts}, each of which is made of \emph{blocks}. Here's a typical script: +\label{fig:typical-script} \bigpic{typical-script} The five blocks that make up this script have three different colors, corresponding to three of the eight \emph{palettes} in which blocks can be found. The palette area at the left edge of the window shows one palette at a time, chosen with the eight buttons just above the palette area. In this script, the gold blocks are from the Control palette; the green block is from the Pen palette; and the blue blocks are from the Motion palette. A script is assembled by dragging blocks from a palette into the \emph{scripting area} in the middle part of the window. Blocks snap together (hence the name \Snap{} for the language) when you drag a block so that its indentation is near the tab of the one above it: @@ -67,7 +68,7 @@ At the top of the script is a \emph{hat} block, which indicates when the script The other blocks in this script are \emph{command} blocks. Each command block corresponds to an action that \Snap{} already knows how to carry out. For example, the block \inlinepic{move-10-steps} tells the sprite (the arrowhead shape on the \emph{stage} at the right end of the window) to move ten steps (a step is a very small unit of distance) in the direction in which the arrowhead is pointing. We'll see shortly that there can be more than one sprite, and that each sprite has its own scripts. Also, a sprite doesn't have to look like an arrowhead, but can have any picture as a costume. The shape of the \code{move} block is meant to remind you of a Lego\texttrademark{} brick; a script is a stack of blocks. (The word ``block'' denotes both the graphical shape on the screen and the procedure, the action, that the block carries out.) -The number 10 in the \code{move} block above is called an \emph{input} to the block. By clicking on the white oval, you can type any number in place of the 10. The sample script on the previous page uses 100 as the input value. We'll see later that inputs can have non-oval shapes that accept values other than numbers. We'll also see that you can compute input values, instead of typing a particular value into the oval. A block can have more than one input slot. For example, the \code{glide} block located about halfway down the Motion palette has three inputs. +The number~10 in the \code{move} block above is called an \emph{input} to the block. By clicking on the white oval, you can type any number in place of the 10. The sample script on page~\pageref{fig:typical-script} uses 100 as the input value. We'll see later that inputs can have non-oval shapes that accept values other than numbers. We'll also see that you can compute input values, instead of typing a particular value into the oval. A block can have more than one input slot. For example, the \code{glide} block located about halfway down the Motion palette has three inputs. Most command blocks have that brick shape, but some, like the \code{repeat} block in the sample script, are \emph{C-shaped}. Most C-shaped blocks are found in the Control palette. The slot inside the C shape is a special kind of input slot that accepts a \emph{script} as the input. In the sample script, the \code{repeat} block has two inputs: the number 4 and the script diff --git a/help/manual/pl/snap-podrecznik.tex b/help/manual/pl/snap-podrecznik.tex index d8c1a76..0e0cb16 100644 --- a/help/manual/pl/snap-podrecznik.tex +++ b/help/manual/pl/snap-podrecznik.tex @@ -30,7 +30,7 @@ Brian zdobywał szlify w~MIT oraz Stanford Artificial Intelligence Labs\footnote \textbf{\emph{Za starych dobrych czasów mawialiśmy w~MIT Logo Lab: ,,Język Logo to Lisp w przebraniu BASIC-a''. Dziś, ze swoimi pierwszoklasowymi procedurami, zasięgami leksykalnymi~i pierwszoklasowymi kontynuacjami, \Snap{} jest jak Scheme w~przebraniu Scratcha.}} -Szczęśliwym zrządzeniem losu, poprzez forum Scratch Advanced Topics, poznaliśmy wspaniałą grupę błyskotliwych uczniów gimnazjów~(!\@) i liceów. Kilku z nich wniosło swój wkład w~kod \Snap{a}: Kartik Chandra, Nathan Dinsmore, Connor Hudson i~Ian Reynolds. Ponadto, wielu zgłosiło pomysły i~raporty błędów podczas testowania wersji alfa. Wśród studentów Uniwersytetu Kalifornijskiego w~Berkeley, którzy przyczynili się do rozwoju kodu, znajdują się Michael Ball, Achal Dave, Kyle Hotchkiss, Ivan Motyashov i~Yuan Yuan. Wymienianie wszystkich tłumaczy zajęłoby zbyt wiele miejsca, ale można ich odnaleźć w~okienku ,,O Snap!...'' dostępnym w~programie. Niniejsze dzieło powstało częściowo w~ramach grantu nr~1143566 udzielonego przez National Science Foundation, a częściowo przy wsparciu firmy MioSoft. +Szczęśliwym zrządzeniem losu, poprzez forum Scratch Advanced Topics, poznaliśmy wspaniałą grupę błyskotliwych uczniów gimnazjów~(!\@) i liceów. Kilku z nich wniosło swój wkład w~kod \Snap{a}: Kartik Chandra, Nathan Dinsmore, Connor Hudson i~Ian Reynolds. Ponadto wielu zgłosiło pomysły i~raporty błędów podczas testowania wersji alfa. Wśród studentów Uniwersytetu Kalifornijskiego w~Berkeley, którzy przyczynili się do rozwoju kodu, znajdują się Michael Ball, Achal Dave, Kyle Hotchkiss, Ivan Motyashov i~Yuan Yuan. Wymienianie wszystkich tłumaczy zajęłoby zbyt wiele miejsca, ale można ich odnaleźć w~okienku ,,O Snap!...'' dostępnym w~programie. Niniejsze dzieło powstało częściowo w~ramach grantu nr~1143566 udzielonego przez National Science Foundation, a częściowo przy wsparciu firmy MioSoft. \begin{titlepage} @@ -46,39 +46,38 @@ Podręcznik użytkownika \\ \chapter{Bloki, skrypty i duszki} -W~tym rozdziale poznamy kilka cech języka \Snap{} odziedziczonych po Scratchu; doświadczeni użytkownicy Scratcha powinni przejść od razu do sekcji~\ref{sec:zagnieżdżanie-duszków}. +W~tym rozdziale poznamy kilka cech języka \Snap{} odziedziczonych po Scratchu; doświadczeni użytkownicy Scratcha mogą przejść od razu do sekcji~\ref{sec:zagnieżdżanie-duszków}. -This chapter describes the \Snap{} features inherited from Scratch; experienced Scratch users can skip to section B. +\Snap{} jest językiem programowania --- notacją, przy pomocy której możemy powiedzieć komputerowi, co ma zrobić. Jednak w~odróżnieniu od większości innych, \Snap{} jest językiem wizualnym; programując w~nim, zamiast posługiwać się klawiaturą, używamy metody ,,przeciągnij i~upuść'', dobrze znanej użytkownikom komputerów. -\Snap{} is a programming language---a notation in which you can tell a computer what you want it to do. Unlike most programming languages, though, \Snap{} is a visual language; instead of writing a program using the keyboard, the \Snap{} programmer uses the same drag-and-drop interface familiar to computer users. - -Start \Snap{}. You should see the following arrangement of regions in the window: +Uruchom teraz środowisko \Snap{}. Powinieneś zobaczyć ekran podzielony na kilka obszarów: \begin{center} \includegraphics[width=\textwidth]{window-regions} \end{center} -(The proportions of these areas may be different, depending on the size and shape of your browser window.) +(Proporcje tych stref mogą się różnić, w~zależności od rozmiaru i~kształtu okna przeglądarki.) -A \Snap{} program consists of one or more \emph{scripts}, each of which is made of \emph{blocks}. Here's a typical script: +Program w~języku \Snap{} składa się z~jednego lub więcej \emph{skryptów}, te zaś z~kolei --- z~\emph{bloków}. Oto przykładowy skrypt: +\label{fig:typical-script} \bigpic{typical-script} -The five blocks that make up this script have three different colors, corresponding to three of the eight \emph{palettes} in which blocks can be found. The palette area at the left edge of the window shows one palette at a time, chosen with the eight buttons just above the palette area. In this script, the gold blocks are from the Control palette; the green block is from the Pen palette; and the blue blocks are from the Motion palette. A script is assembled by dragging blocks from a palette into the \emph{scripting area} in the middle part of the window. Blocks snap together (hence the name \Snap{} for the language) when you drag a block so that its indentation is near the tab of the one above it: +Na powyższy skrypt składa się pięć bloków w~trzech różnych kolorach, odpowiadających trzem z~ośmiu \emph{palet} z~blokami. Obszar palet, znajdujący się po lewej stronie okna, pokazuje jedną paletę na raz. Do zmiany widocznej palety służy osiem przycisków znajdujących się tuż nad tym obszarem. Bloki ciemnożółte, widoczne w~naszym skrypcie, pochodzą z~palety Kontrola; zielone z~palety Pisak, a~niebieskie --- z~palety Ruch. Aby złożyć taki skrypt, należy poprzeciągać odpowiednie bloki z~palet do \emph{obszaru skryptu}, umiejscowionego na środku okna. Kiedy układamy jeden blok pod drugim w~taki sposób, aby wcięcie dolnego bloku znalazło się w~pobliżu wypustki tego powyżej, bloki łączą się ze sobą (ang. \textit{snap together}; stąd nazwa języka \Snap{}): \bigpic{snapping-blocks} -The white horizontal line is a signal that if you let go of the green block it will snap into the tab of the gold one. +Pozioma biała linia sygnalizuje, że jeśli puścimy zielony blok, połączy się on z~wypustką ciemnożółtego. -\subsection{Hat Blocks and Command Blocks} +\subsection{Bloki-czapki i bloki poleceń} -At the top of the script is a \emph{hat} block, which indicates when the script should be carried out. Hat block names typically start with the word ``\code{when}''; in this example, the script should be run when the green flag near the right end of the \Snap{} tool bar is clicked. (The \Snap{} tool bar is part of the \Snap{} window, not the same as the browser's or operating system's menu bar.) A script isn't required to have a hat block, but if not, then the script will be run only if the user clicks on the script itself. A script can't have more than one hat block, and the hat block can be used only at the top of the script; its distinctive shape is meant to remind you of that. +Na górze skryptu znajduje się \emph{blok-czapka}, który określa, kiedy skrypt ma zostać wykonany. Nazwy bloków-czapek zazwyczaj zaczynają się słowem ,,\code{kiedy}''; nasz przykładowy skrypt powinien zostać uruchomiony w~momencie kliknięcia zielonej flagi, znajdującej się w pobliżu prawej strony paska narzędzi \Snap{a}. (Pasek ten jest częścią okna programu \Snap{}; nie chodzi tutaj o pasek menu przeglądarki lub systemu operacyjnego.) Skrypt nie musi posiadać czapki, jednak w~takim przypadku zostanie wykonany tylko wtedy, gdy użytkownik sam go kliknie. Skrypt nie może mieć więcej niż jednej czapki; jej charakterystyczny kształt służy łatwiejszemu zapamiętaniu tej szczególnej własności. -The other blocks in this script are \emph{command} blocks. Each command block corresponds to an action that \Snap{} already knows how to carry out. For example, the block \inlinepic{move-10-steps} tells the sprite (the arrowhead shape on the \emph{stage} at the right end of the window) to move ten steps (a step is a very small unit of distance) in the direction in which the arrowhead is pointing. We'll see shortly that there can be more than one sprite, and that each sprite has its own scripts. Also, a sprite doesn't have to look like an arrowhead, but can have any picture as a costume. The shape of the \code{move} block is meant to remind you of a Lego\texttrademark{} brick; a script is a stack of blocks. (The word ``block'' denotes both the graphical shape on the screen and the procedure, the action, that the block carries out.) +Pozostałe bloki w naszym skrypcie to \emph{bloki poleceń}. Każdy z~nich oznacza jakąś akcję, którą \Snap{} potrafi wykonać. Na przykład blok \inlinepic{move-10-steps} nakazuje duszkowi\footnote{W grafice komputerowej słowem ,,duszek'' (ang. \textit{sprite}) nazywa się ruchomy obiekt na ekranie --- przyp. tłum.}, czyli strzałce na \emph{scenie} po prawej stronie okna, aby przesunął się o~dziesięć kroków do przodu w~kierunku, w~którym jest zwrócony. Każdy krok to niewielka odległość na ekranie. Wkrótce przekonamy się, że na scenie może być więcej duszków, a~każdy z nich może mieć własne skrypty. Ponadto duszki nie muszą wyglądać jak strzałki; ich kostiumy mogą być dowolnymi obrazkami. Kształt bloku \code{przesuń} ma za zadanie przypominać klocek, skrypt zaś jest jak wieża z klocków. Słowa ,,blok'' będziemy używać dla oznaczenia zarówno graficznego symbolu na ekranie, jak i~procedury (akcji) jaką ten blok wykonuje. -The number 10 in the \code{move} block above is called an \emph{input} to the block. By clicking on the white oval, you can type any number in place of the 10. The sample script on the previous page uses 100 as the input value. We'll see later that inputs can have non-oval shapes that accept values other than numbers. We'll also see that you can compute input values, instead of typing a particular value into the oval. A block can have more than one input slot. For example, the \code{glide} block located about halfway down the Motion palette has three inputs. +Liczbę 10 w powyższym bloku \code{przesuń} nazywamy jego \emph{parametrem}. Kliknąwszy na białym, zaokrąglonym polu, możemy wpisać w~jej miejsce dowolną inną. W przykładowym skrypcie ze strony \pageref{fig:typical-script} parametrem jest liczba 100. Jak się później okaże, pola parametrów mogą mieć kształty inne od zaokrąglonych; oznacza to wtedy, że akceptują one wartości inne niż liczby. Zobaczymy również, że zamiast wpisywać konkretne wartości w~pola, możemy nakazać komputerowi je obliczać. Ponadto blok może mieć więcej niż jeden parametr. Na przykład blok \code{leć}, znajdujący się mniej więcej w~połowie palety Ruch, przyjmuje trzy parametry. -Most command blocks have that brick shape, but some, like the \code{repeat} block in the sample script, are \emph{C-shaped}. Most C-shaped blocks are found in the Control palette. The slot inside the C shape is a special kind of input slot that accepts a \emph{script} as the input. In the sample script, the \code{repeat} block has two inputs: the number 4 and the script +Większość bloków poleceń ma kształt klocków, lecz niektóre, jak \code{powtórz} z~tego samego przykładu, wyglądają jak \emph{klamry}. Większość bloków klamrowych można znaleźć na palecie Kontrola. Wnętrze klamry jest szczególnym rodzajem pola parametru, który przyjmuje \emph{skrypt} jako parametr. W przykładowym skrypcie blok \code{powtórz} ma dwa parametry: liczbę 4 oraz skrypt \bigpic{typical-script-inner} -- cgit v1.3.1 From 7c3d3decdb296acb5d821360f25026ece694458b Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Thu, 25 Jun 2015 23:31:12 +0200 Subject: W --- help/manual/pl/snap-podrecznik.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/help/manual/pl/snap-podrecznik.tex b/help/manual/pl/snap-podrecznik.tex index 0e0cb16..03675dd 100644 --- a/help/manual/pl/snap-podrecznik.tex +++ b/help/manual/pl/snap-podrecznik.tex @@ -77,7 +77,7 @@ Pozostałe bloki w naszym skrypcie to \emph{bloki poleceń}. Każdy z~nich oznac Liczbę 10 w powyższym bloku \code{przesuń} nazywamy jego \emph{parametrem}. Kliknąwszy na białym, zaokrąglonym polu, możemy wpisać w~jej miejsce dowolną inną. W przykładowym skrypcie ze strony \pageref{fig:typical-script} parametrem jest liczba 100. Jak się później okaże, pola parametrów mogą mieć kształty inne od zaokrąglonych; oznacza to wtedy, że akceptują one wartości inne niż liczby. Zobaczymy również, że zamiast wpisywać konkretne wartości w~pola, możemy nakazać komputerowi je obliczać. Ponadto blok może mieć więcej niż jeden parametr. Na przykład blok \code{leć}, znajdujący się mniej więcej w~połowie palety Ruch, przyjmuje trzy parametry. -Większość bloków poleceń ma kształt klocków, lecz niektóre, jak \code{powtórz} z~tego samego przykładu, wyglądają jak \emph{klamry}. Większość bloków klamrowych można znaleźć na palecie Kontrola. Wnętrze klamry jest szczególnym rodzajem pola parametru, który przyjmuje \emph{skrypt} jako parametr. W przykładowym skrypcie blok \code{powtórz} ma dwa parametry: liczbę 4 oraz skrypt +Większość bloków poleceń ma kształt klocków, lecz niektóre, jak \code{powtórz} z~tego samego przykładu, wyglądają jak \emph{klamry}. Większość bloków klamrowych można znaleźć na palecie Kontrola. Wnętrze klamry jest szczególnym rodzajem pola parametru, który przyjmuje \emph{skrypt} jako parametr. W~przykładowym skrypcie blok \code{powtórz} ma dwa parametry: liczbę 4 oraz skrypt \bigpic{typical-script-inner} -- cgit v1.3.1 From 58187d0c67ebaddb4297edbe1b4b107d01f9f901 Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Thu, 25 Jun 2015 23:36:29 +0200 Subject: Fix page numbering --- help/manual/en/snap-manual.tex | 4 ++-- help/manual/pl/snap-podrecznik.tex | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/help/manual/en/snap-manual.tex b/help/manual/en/snap-manual.tex index 140e552..036ad1e 100644 --- a/help/manual/en/snap-manual.tex +++ b/help/manual/en/snap-manual.tex @@ -25,7 +25,7 @@ Brian grew up at the MIT and Stanford Artificial Intelligence Labs, learning fro We have been fortunate to get to know an amazing group of brilliant middle school (!\@) and high school students through the Scratch Advanced Topics forum, several of whom have contributed code to \Snap{}: Kartik Chandra, Nathan Dinsmore, Connor Hudson, and Ian Reynolds. Many more have contributed ideas and alpha-testing bug reports. UC Berkeley students who've contributed code include Michael Ball, Achal Dave, Kyle Hotchkiss, Ivan Motyashov, and Yuan Yuan. Contributors of translations are too numerous to list here, but they're in the ``About...'' box in \Snap{} itself. This work was supported in part by the National Science Foundation grant 1143566, and in part by MioSoft. -\begin{titlepage} +\clearpage \begin{center} \bf \Huge \Snap{} Reference Manual \\ @@ -35,7 +35,7 @@ We have been fortunate to get to know an amazing group of brilliant middle schoo \Snap{} (formerly BYOB) is an extended reimplementation of Scratch (\url{http://scratch.mit.edu}) that allows you to Build Your Own Blocks. It also features first class lists, first class procedures, and continuations. These added capabilities make it suitable for a serious introduction to computer science for high school or college students. To run \Snap{}, open a browser window and connect to either \url{http://snap.berkeley.edu/run} to start with a minimal set of blocks or \url{http://snap.berkeley.edu/init} to load a small set of additional blocks (a little slower startup, but recommended for convenience and assumed in this manual). -\end{titlepage} +\clearpage \chapter{Blocks, Scripts, and Sprites} diff --git a/help/manual/pl/snap-podrecznik.tex b/help/manual/pl/snap-podrecznik.tex index 03675dd..2ab21cd 100644 --- a/help/manual/pl/snap-podrecznik.tex +++ b/help/manual/pl/snap-podrecznik.tex @@ -32,7 +32,7 @@ Brian zdobywał szlify w~MIT oraz Stanford Artificial Intelligence Labs\footnote Szczęśliwym zrządzeniem losu, poprzez forum Scratch Advanced Topics, poznaliśmy wspaniałą grupę błyskotliwych uczniów gimnazjów~(!\@) i liceów. Kilku z nich wniosło swój wkład w~kod \Snap{a}: Kartik Chandra, Nathan Dinsmore, Connor Hudson i~Ian Reynolds. Ponadto wielu zgłosiło pomysły i~raporty błędów podczas testowania wersji alfa. Wśród studentów Uniwersytetu Kalifornijskiego w~Berkeley, którzy przyczynili się do rozwoju kodu, znajdują się Michael Ball, Achal Dave, Kyle Hotchkiss, Ivan Motyashov i~Yuan Yuan. Wymienianie wszystkich tłumaczy zajęłoby zbyt wiele miejsca, ale można ich odnaleźć w~okienku ,,O Snap!...'' dostępnym w~programie. Niniejsze dzieło powstało częściowo w~ramach grantu nr~1143566 udzielonego przez National Science Foundation, a częściowo przy wsparciu firmy MioSoft. -\begin{titlepage} +\clearpage \begin{center} \bf \Huge \Snap{} \\ @@ -42,7 +42,7 @@ Podręcznik użytkownika \\ \Snap{} to rozszerzona reimplementacja języka Scratch (\url{http://scratch.mit.edu}), która pozwala na tworzenie własnych bloków (ang.\ \textit{Build Your Own Blocks}; stąd dawna nazwa \Snap{a} --- BYOB). Opisywany tu język obsługuje pierwszoklasowe listy, procedury i~kontynuacje. Te dodatkowe możliwości sprawiają, że nadaje się on do przeprowadzenia poważnego wstępu do informatyki dla uczniów liceów i szkół wyższych. Aby uruchomić środowisko \Snap{}, wystarczy otworzyć przeglądarkę internetową i~wpisać adres \url{http://snap.berkeley.edu/run}, aby zacząć pracę z~minimalnym zestawem bloków. Można też użyć adresu \url{http://snap.berkeley.edu/init}, aby załadować niewielki zestaw dodatkowych bloków. Wiąże się to z~nieco wolniejszym ładowaniem, ale jest zalecane dla wygody użytkowników (w~dalszej części podręcznika będziemy zakładali korzystanie z~tej właśnie metody). -\end{titlepage} +\clearpage \chapter{Bloki, skrypty i duszki} -- cgit v1.3.1 From f35e6f1922dff2f5afb3333708bb9fcb08ae4749 Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Fri, 26 Jun 2015 01:36:34 +0200 Subject: Polish version of the widnow regions drawing --- help/manual/.gitignore | 3 +- help/manual/common/defs.tex | 1 + help/manual/pl/obszary-okna.pdf | Bin 0 -> 65091 bytes help/manual/pl/obszary-okna.pdf_tex | 59 ++ help/manual/pl/obszary-okna.svg | 1388 +++++++++++++++++++++++++++++++++++ help/manual/pl/snap-podrecznik.tex | 5 +- help/manual/pl/window-regions.png | Bin 142052 -> 0 bytes 7 files changed, 1453 insertions(+), 3 deletions(-) create mode 100644 help/manual/pl/obszary-okna.pdf create mode 100644 help/manual/pl/obszary-okna.pdf_tex create mode 100644 help/manual/pl/obszary-okna.svg delete mode 100644 help/manual/pl/window-regions.png diff --git a/help/manual/.gitignore b/help/manual/.gitignore index a0bdfac..cb5f3c2 100644 --- a/help/manual/.gitignore +++ b/help/manual/.gitignore @@ -2,5 +2,6 @@ *.log *.out *.toc -*.pdf +en/snap-manual.pdf +pl/snap-podrecznik.pdf *.synctex.gz diff --git a/help/manual/common/defs.tex b/help/manual/common/defs.tex index d086975..bb4d785 100644 --- a/help/manual/common/defs.tex +++ b/help/manual/common/defs.tex @@ -3,6 +3,7 @@ \usepackage{baskervald} % Default font \usepackage{setspace} \onehalfspacing \usepackage{graphicx} +\usepackage{color} \usepackage{textcomp} \usepackage{hyperref} diff --git a/help/manual/pl/obszary-okna.pdf b/help/manual/pl/obszary-okna.pdf new file mode 100644 index 0000000..d4e5800 Binary files /dev/null and b/help/manual/pl/obszary-okna.pdf differ diff --git a/help/manual/pl/obszary-okna.pdf_tex b/help/manual/pl/obszary-okna.pdf_tex new file mode 100644 index 0000000..6fc4bdf --- /dev/null +++ b/help/manual/pl/obszary-okna.pdf_tex @@ -0,0 +1,59 @@ +%% Creator: Inkscape inkscape 0.48.4, www.inkscape.org +%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010 +%% Accompanies image file 'obszary-okna.pdf' (pdf, eps, ps) +%% +%% To include the image in your LaTeX document, write +%% \input{.pdf_tex} +%% instead of +%% \includegraphics{.pdf} +%% To scale the image, write +%% \def\svgwidth{} +%% \input{.pdf_tex} +%% instead of +%% \includegraphics[width=]{.pdf} +%% +%% Images with a different path to the parent latex file can +%% be accessed with the `import' package (which may need to be +%% installed) using +%% \usepackage{import} +%% in the preamble, and then including the image with +%% \import{}{.pdf_tex} +%% Alternatively, one can specify +%% \graphicspath{{/}} +%% +%% For more information, please see info/svg-inkscape on CTAN: +%% http://tug.ctan.org/tex-archive/info/svg-inkscape +%% +\begingroup% + \makeatletter% + \providecommand\color[2][]{% + \errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}% + \renewcommand\color[2][]{}% + }% + \providecommand\transparent[1]{% + \errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}% + \renewcommand\transparent[1]{}% + }% + \providecommand\rotatebox[2]{#2}% + \ifx\svgwidth\undefined% + \setlength{\unitlength}{855.2bp}% + \ifx\svgscale\undefined% + \relax% + \else% + \setlength{\unitlength}{\unitlength * \real{\svgscale}}% + \fi% + \else% + \setlength{\unitlength}{\svgwidth}% + \fi% + \global\let\svgwidth\undefined% + \global\let\svgscale\undefined% + \makeatother% + \begin{picture}(1,0.60243218)% + \put(0,0){\includegraphics[width=\unitlength]{obszary-okna.pdf}}% + \put(0.37031041,0.03597468){\color[rgb]{1,0,0}\makebox(0,0)[b]{\smash{\emph{\Large Obszar skryptów}}}}% + \put(0.42733084,0.57941921){\color[rgb]{1,0,0}\makebox(0,0)[b]{\smash{\emph{\small Pasek narzędzi}}}}% + \put(0.77489765,0.03597473){\color[rgb]{1,0,0}\makebox(0,0)[b]{\smash{\emph{\Large Zagroda duszków}}}}% + \put(0.09676227,0.03597473){\color[rgb]{1,0,0}\makebox(0,0)[b]{\smash{\emph{\Large Paleta}}}}% + \put(0.77708296,0.27919271){\color[rgb]{1,0,0}\makebox(0,0)[b]{\smash{\emph{\Large Scena}}}}% + \end{picture}% +\endgroup% diff --git a/help/manual/pl/obszary-okna.svg b/help/manual/pl/obszary-okna.svg new file mode 100644 index 0000000..f593e27 --- /dev/null +++ b/help/manual/pl/obszary-okna.svg @@ -0,0 +1,1388 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + \emph{\Large Obszar skryptów} + \emph{\small Pasek narzędzi} + + + + + \emph{\Large Zagroda duszków} + \emph{\Large Paleta} + \emph{\Large Scena} + + diff --git a/help/manual/pl/snap-podrecznik.tex b/help/manual/pl/snap-podrecznik.tex index 2ab21cd..121ec9c 100644 --- a/help/manual/pl/snap-podrecznik.tex +++ b/help/manual/pl/snap-podrecznik.tex @@ -53,7 +53,8 @@ W~tym rozdziale poznamy kilka cech języka \Snap{} odziedziczonych po Scratchu; Uruchom teraz środowisko \Snap{}. Powinieneś zobaczyć ekran podzielony na kilka obszarów: \begin{center} -\includegraphics[width=\textwidth]{window-regions} +\def\svgwidth{\textwidth} +\input{obszary-okna.pdf_tex} \end{center} (Proporcje tych stref mogą się różnić, w~zależności od rozmiaru i~kształtu okna przeglądarki.) @@ -63,7 +64,7 @@ Program w~języku \Snap{} składa się z~jednego lub więcej \emph{skryptów}, t \label{fig:typical-script} \bigpic{typical-script} -Na powyższy skrypt składa się pięć bloków w~trzech różnych kolorach, odpowiadających trzem z~ośmiu \emph{palet} z~blokami. Obszar palet, znajdujący się po lewej stronie okna, pokazuje jedną paletę na raz. Do zmiany widocznej palety służy osiem przycisków znajdujących się tuż nad tym obszarem. Bloki ciemnożółte, widoczne w~naszym skrypcie, pochodzą z~palety Kontrola; zielone z~palety Pisak, a~niebieskie --- z~palety Ruch. Aby złożyć taki skrypt, należy poprzeciągać odpowiednie bloki z~palet do \emph{obszaru skryptu}, umiejscowionego na środku okna. Kiedy układamy jeden blok pod drugim w~taki sposób, aby wcięcie dolnego bloku znalazło się w~pobliżu wypustki tego powyżej, bloki łączą się ze sobą (ang. \textit{snap together}; stąd nazwa języka \Snap{}): +Na powyższy skrypt składa się pięć bloków w~trzech różnych kolorach, odpowiadających trzem z~ośmiu \emph{palet} z~blokami. Obszar palet, znajdujący się po lewej stronie okna, pokazuje jedną paletę na raz. Do zmiany widocznej palety służy osiem przycisków znajdujących się tuż nad tym obszarem. Bloki ciemnożółte, widoczne w~naszym skrypcie, pochodzą z~palety Kontrola; zielone z~palety Pisak, a~niebieskie --- z~palety Ruch. Aby złożyć taki skrypt, należy poprzeciągać odpowiednie bloki z~palet do \emph{obszaru skryptów}, umiejscowionego na środku okna. Kiedy układamy jeden blok pod drugim w~taki sposób, aby wcięcie dolnego bloku znalazło się w~pobliżu wypustki tego powyżej, bloki łączą się ze sobą (ang. \textit{snap together}; stąd nazwa języka \Snap{}): \bigpic{snapping-blocks} diff --git a/help/manual/pl/window-regions.png b/help/manual/pl/window-regions.png deleted file mode 100644 index 7fe4e98..0000000 Binary files a/help/manual/pl/window-regions.png and /dev/null differ -- cgit v1.3.1 From 7d1db3dfe933498f59d8d61ea6baa7febdb2a96a Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 26 Jun 2015 13:04:27 +0200 Subject: update Morphic to the latest version --- morphic.js | 38 +++++++++++++++++++++++++++++++------- morphic.txt | 37 +++++++++++++++++++++++++------------ 2 files changed, 56 insertions(+), 19 deletions(-) diff --git a/morphic.js b/morphic.js index cb2aa32..f26c7bf 100644 --- a/morphic.js +++ b/morphic.js @@ -828,8 +828,8 @@ // use context to paint stuff here }; - If your new morph stores or references other morphs outside of the - submorph tree in other properties, be sure to also override the + If your new morph stores or references to other morphs outside of + the submorph tree in other properties, be sure to also override the default updateReferences() @@ -1048,7 +1048,7 @@ /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, FileList, getBlurredShadowSupport*/ -var morphicVersion = '2015-June-25'; +var morphicVersion = '2015-June-26'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -2405,10 +2405,13 @@ Morph.prototype.moveBy = function (delta) { }; Morph.prototype.silentMoveBy = function (delta) { + var children = this.children, + i = children.length; this.bounds = this.bounds.translateBy(delta); - this.children.forEach(function (child) { - child.silentMoveBy(delta); - }); + // ugly optimization avoiding forEach() + for (i; i > 0; i -= 1) { + children[i - 1].silentMoveBy(delta); + } }; Morph.prototype.setPosition = function (aPoint) { @@ -6502,7 +6505,7 @@ InspectorMorph.prototype.setExtent = function (aPoint) { this.fixLayout(); }; -//InspectorMorph editing ops: +// InspectorMorph editing ops: InspectorMorph.prototype.save = function () { var txt = this.detail.contents.children[0].text.toString(), @@ -6592,6 +6595,15 @@ InspectorMorph.prototype.step = function () { this.fixLayout(); }; +// InspectorMorph duplicating: + +InspectorMorph.prototype.updateReferences = function (map) { + var active = this.list.activeIndex(); + InspectorMorph.uber.updateReferences.call(this, map); + this.buildPanes(); + this.list.activateIndex(active); +}; + // MenuMorph /////////////////////////////////////////////////////////// // MenuMorph: referenced constructors @@ -9058,6 +9070,18 @@ ListMorph.prototype.setExtent = function (aPoint) { ListMorph.uber.setExtent.call(this, aPoint); }; +ListMorph.prototype.activeIndex = function () { + return this.listContents.children.indexOf(this.active); +}; + +ListMorph.prototype.activateIndex = function (idx) { + var item = this.listContents.children[idx]; + if (!item) {return; } + item.image = item.pressImage; + item.changed(); + item.trigger(); +}; + // StringFieldMorph //////////////////////////////////////////////////// // StringFieldMorph inherit from FrameMorph: diff --git a/morphic.txt b/morphic.txt index 042b7e5..11a323d 100755 --- a/morphic.txt +++ b/morphic.txt @@ -7,9 +7,9 @@ written by Jens Mönig jens@moenig.org - Copyright (C) 2012 by Jens Mönig + Copyright (C) 2015 by Jens Mönig - this documentation last changed: April 07, 2013 + this documentation last changed: June 26, 2015 This file is part of Snap!. @@ -465,9 +465,15 @@ MyMorph.prototype.mouseMove = function(pos) {}; - The only optional parameter of such a method is a Point object + All of these methods have as optional parameter a Point object indicating the current position of the Hand inside the World's - coordinate system. + coordinate system. The + + mouseMove(pos, button) + + event method has an additional optional parameter indicating the + currently pressed mouse button, which is either 'left' or 'right'. + You can use this to let users interact with 3D environments. Events may be "bubbled" up a morph's owner chain by calling @@ -522,6 +528,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), @@ -817,13 +829,13 @@ // use context to paint stuff here }; - If your new morph stores or references other morphs outside of the - submorph tree in other properties, be sure to also override the + If your new morph stores or references to other morphs outside of + the submorph tree in other properties, be sure to also override the default - copyRecordingReferences() + updateReferences() - method accordingly if you want it to support duplication. + method if you want it to support duplication. (6) development and user modes @@ -1015,16 +1027,17 @@ 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 ---------------------- Joe Otto found and fixed many early bugs and taught me some tricks. Nathan Dinsmore contributed mouse wheel scrolling, cached - background texture handling and countless bug fixes. + background texture handling, countless bug fixes and optimizations. Ian Reynolds contributed backspace key handling for Chrome. Davide Della Casa contributed performance optimizations for Firefox. -- cgit v1.3.1 From 53068ea25954431c174dca1e76ca924b00243c2f Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 26 Jun 2015 14:16:20 +0200 Subject: update version history --- history.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/history.txt b/history.txt index 9d9c00c..74d6d1f 100755 --- a/history.txt +++ b/history.txt @@ -2522,4 +2522,8 @@ ______ * 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 === +=== Start with v4.0.1 === + +150626 +------ +* Morphic: Fix Inspector duplication, update documentation -- cgit v1.3.1 From 12671a1fbd6044f22ba037347b6af1bf170af9da Mon Sep 17 00:00:00 2001 From: Bartosz Leper Date: Fri, 26 Jun 2015 20:29:21 +0200 Subject: Polish translations of other pictures --- help/manual/pl/laczenie-blokow.png | Bin 0 -> 5025 bytes help/manual/pl/move-10-steps.png | Bin 2595 -> 0 bytes help/manual/pl/przesun-o-10-krokow.png | Bin 0 -> 3149 bytes help/manual/pl/snap-podrecznik.tex | 16 ++++++++-------- help/manual/pl/snapping-blocks.png | Bin 12054 -> 0 bytes help/manual/pl/typical-script-inner.png | Bin 4610 -> 0 bytes help/manual/pl/typical-script.png | Bin 11063 -> 0 bytes help/manual/pl/typowy-skrypt-wnetrze.png | Bin 0 -> 5211 bytes help/manual/pl/typowy-skrypt.png | Bin 0 -> 12764 bytes 9 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 help/manual/pl/laczenie-blokow.png delete mode 100644 help/manual/pl/move-10-steps.png create mode 100644 help/manual/pl/przesun-o-10-krokow.png delete mode 100644 help/manual/pl/snapping-blocks.png delete mode 100644 help/manual/pl/typical-script-inner.png delete mode 100644 help/manual/pl/typical-script.png create mode 100644 help/manual/pl/typowy-skrypt-wnetrze.png create mode 100644 help/manual/pl/typowy-skrypt.png diff --git a/help/manual/pl/laczenie-blokow.png b/help/manual/pl/laczenie-blokow.png new file mode 100644 index 0000000..b640b5f Binary files /dev/null and b/help/manual/pl/laczenie-blokow.png differ diff --git a/help/manual/pl/move-10-steps.png b/help/manual/pl/move-10-steps.png deleted file mode 100644 index 3d276da..0000000 Binary files a/help/manual/pl/move-10-steps.png and /dev/null differ diff --git a/help/manual/pl/przesun-o-10-krokow.png b/help/manual/pl/przesun-o-10-krokow.png new file mode 100644 index 0000000..ece840c Binary files /dev/null and b/help/manual/pl/przesun-o-10-krokow.png differ diff --git a/help/manual/pl/snap-podrecznik.tex b/help/manual/pl/snap-podrecznik.tex index 121ec9c..f041a17 100644 --- a/help/manual/pl/snap-podrecznik.tex +++ b/help/manual/pl/snap-podrecznik.tex @@ -61,12 +61,12 @@ Uruchom teraz środowisko \Snap{}. Powinieneś zobaczyć ekran podzielony na kil Program w~języku \Snap{} składa się z~jednego lub więcej \emph{skryptów}, te zaś z~kolei --- z~\emph{bloków}. Oto przykładowy skrypt: -\label{fig:typical-script} -\bigpic{typical-script} +\label{fig:typowy-skrypt} +\bigpic{typowy-skrypt} -Na powyższy skrypt składa się pięć bloków w~trzech różnych kolorach, odpowiadających trzem z~ośmiu \emph{palet} z~blokami. Obszar palet, znajdujący się po lewej stronie okna, pokazuje jedną paletę na raz. Do zmiany widocznej palety służy osiem przycisków znajdujących się tuż nad tym obszarem. Bloki ciemnożółte, widoczne w~naszym skrypcie, pochodzą z~palety Kontrola; zielone z~palety Pisak, a~niebieskie --- z~palety Ruch. Aby złożyć taki skrypt, należy poprzeciągać odpowiednie bloki z~palet do \emph{obszaru skryptów}, umiejscowionego na środku okna. Kiedy układamy jeden blok pod drugim w~taki sposób, aby wcięcie dolnego bloku znalazło się w~pobliżu wypustki tego powyżej, bloki łączą się ze sobą (ang. \textit{snap together}; stąd nazwa języka \Snap{}): +Na powyższy skrypt składa się pięć bloków w~trzech różnych kolorach, odpowiadających trzem z~ośmiu \emph{palet} z~blokami. Obszar palet, znajdujący się po lewej stronie okna, pokazuje jedną paletę na raz. Do zmiany widocznej palety służy osiem przycisków znajdujących się tuż nad tym obszarem. Bloki ciemnożółte, widoczne w~naszym skrypcie, pochodzą z~palety ,,Kontrola''; zielone z~palety ,,Pisak'', a~niebieskie --- z~palety ,,Ruch''. Aby złożyć taki skrypt, należy poprzeciągać odpowiednie bloki z~palet do \emph{obszaru skryptów}, umiejscowionego na środku okna. Kiedy układamy jeden blok pod drugim w~taki sposób, aby wcięcie dolnego bloku znalazło się w~pobliżu wypustki tego powyżej, bloki łączą się ze sobą (ang. \textit{snap together}; stąd nazwa języka \Snap{}): -\bigpic{snapping-blocks} +\bigpic{laczenie-blokow} Pozioma biała linia sygnalizuje, że jeśli puścimy zielony blok, połączy się on z~wypustką ciemnożółtego. @@ -74,13 +74,13 @@ Pozioma biała linia sygnalizuje, że jeśli puścimy zielony blok, połączy si Na górze skryptu znajduje się \emph{blok-czapka}, który określa, kiedy skrypt ma zostać wykonany. Nazwy bloków-czapek zazwyczaj zaczynają się słowem ,,\code{kiedy}''; nasz przykładowy skrypt powinien zostać uruchomiony w~momencie kliknięcia zielonej flagi, znajdującej się w pobliżu prawej strony paska narzędzi \Snap{a}. (Pasek ten jest częścią okna programu \Snap{}; nie chodzi tutaj o pasek menu przeglądarki lub systemu operacyjnego.) Skrypt nie musi posiadać czapki, jednak w~takim przypadku zostanie wykonany tylko wtedy, gdy użytkownik sam go kliknie. Skrypt nie może mieć więcej niż jednej czapki; jej charakterystyczny kształt służy łatwiejszemu zapamiętaniu tej szczególnej własności. -Pozostałe bloki w naszym skrypcie to \emph{bloki poleceń}. Każdy z~nich oznacza jakąś akcję, którą \Snap{} potrafi wykonać. Na przykład blok \inlinepic{move-10-steps} nakazuje duszkowi\footnote{W grafice komputerowej słowem ,,duszek'' (ang. \textit{sprite}) nazywa się ruchomy obiekt na ekranie --- przyp. tłum.}, czyli strzałce na \emph{scenie} po prawej stronie okna, aby przesunął się o~dziesięć kroków do przodu w~kierunku, w~którym jest zwrócony. Każdy krok to niewielka odległość na ekranie. Wkrótce przekonamy się, że na scenie może być więcej duszków, a~każdy z nich może mieć własne skrypty. Ponadto duszki nie muszą wyglądać jak strzałki; ich kostiumy mogą być dowolnymi obrazkami. Kształt bloku \code{przesuń} ma za zadanie przypominać klocek, skrypt zaś jest jak wieża z klocków. Słowa ,,blok'' będziemy używać dla oznaczenia zarówno graficznego symbolu na ekranie, jak i~procedury (akcji) jaką ten blok wykonuje. +Pozostałe bloki w naszym skrypcie to \emph{bloki poleceń}. Każdy z~nich oznacza jakąś akcję, którą \Snap{} potrafi wykonać. Na przykład blok \inlinepic{przesun-o-10-krokow} nakazuje duszkowi\footnote{W grafice komputerowej słowem ,,duszek'' (ang. \textit{sprite}) nazywa się ruchomy obiekt na ekranie --- przyp. tłum.}, czyli strzałce na \emph{scenie} po prawej stronie okna, aby przesunął się o~dziesięć kroków do przodu w~kierunku, w~którym jest zwrócony. Każdy krok to niewielka odległość na ekranie. Wkrótce przekonamy się, że na scenie może być więcej duszków, a~każdy z nich może mieć własne skrypty. Ponadto duszki nie muszą wyglądać jak strzałki; ich kostiumy mogą być dowolnymi obrazkami. Kształt bloku \code{przesuń} ma za zadanie przypominać klocek, skrypt zaś jest jak wieża z klocków. Słowa ,,blok'' będziemy używać dla oznaczenia zarówno graficznego symbolu na ekranie, jak i~procedury (akcji) jaką ten blok wykonuje. -Liczbę 10 w powyższym bloku \code{przesuń} nazywamy jego \emph{parametrem}. Kliknąwszy na białym, zaokrąglonym polu, możemy wpisać w~jej miejsce dowolną inną. W przykładowym skrypcie ze strony \pageref{fig:typical-script} parametrem jest liczba 100. Jak się później okaże, pola parametrów mogą mieć kształty inne od zaokrąglonych; oznacza to wtedy, że akceptują one wartości inne niż liczby. Zobaczymy również, że zamiast wpisywać konkretne wartości w~pola, możemy nakazać komputerowi je obliczać. Ponadto blok może mieć więcej niż jeden parametr. Na przykład blok \code{leć}, znajdujący się mniej więcej w~połowie palety Ruch, przyjmuje trzy parametry. +Liczbę 10 w powyższym bloku \code{przesuń} nazywamy jego \emph{parametrem}. Kliknąwszy na białym, zaokrąglonym polu, możemy wpisać w~jej miejsce dowolną inną. W przykładowym skrypcie ze strony \pageref{fig:typowy-skrypt} parametrem jest liczba 100. Jak się później okaże, pola parametrów mogą mieć kształty inne od zaokrąglonych; oznacza to wtedy, że akceptują one wartości inne niż liczby. Zobaczymy również, że zamiast wpisywać konkretne wartości w~pola, możemy nakazać komputerowi je obliczać. Ponadto blok może mieć więcej niż jeden parametr. Na przykład blok \code{leć}, znajdujący się mniej więcej w~połowie palety ,,Ruch'', przyjmuje trzy parametry. -Większość bloków poleceń ma kształt klocków, lecz niektóre, jak \code{powtórz} z~tego samego przykładu, wyglądają jak \emph{klamry}. Większość bloków klamrowych można znaleźć na palecie Kontrola. Wnętrze klamry jest szczególnym rodzajem pola parametru, który przyjmuje \emph{skrypt} jako parametr. W~przykładowym skrypcie blok \code{powtórz} ma dwa parametry: liczbę 4 oraz skrypt +Większość bloków poleceń ma kształt klocków, lecz niektóre, jak \code{powtórz} z~tego samego przykładu, wyglądają jak \emph{klamry}. Większość bloków klamrowych można znaleźć na palecie ,,Kontrola'. Wnętrze klamry jest szczególnym rodzajem pola parametru, który przyjmuje \emph{skrypt} jako parametr. W~przykładowym skrypcie blok \code{powtórz} ma dwa parametry: liczbę 4 oraz skrypt -\bigpic{typical-script-inner} +\bigpic{typowy-skrypt-wnetrze} diff --git a/help/manual/pl/snapping-blocks.png b/help/manual/pl/snapping-blocks.png deleted file mode 100644 index 0dc5922..0000000 Binary files a/help/manual/pl/snapping-blocks.png and /dev/null differ diff --git a/help/manual/pl/typical-script-inner.png b/help/manual/pl/typical-script-inner.png deleted file mode 100644 index b5503f7..0000000 Binary files a/help/manual/pl/typical-script-inner.png and /dev/null differ diff --git a/help/manual/pl/typical-script.png b/help/manual/pl/typical-script.png deleted file mode 100644 index 6763aad..0000000 Binary files a/help/manual/pl/typical-script.png and /dev/null differ diff --git a/help/manual/pl/typowy-skrypt-wnetrze.png b/help/manual/pl/typowy-skrypt-wnetrze.png new file mode 100644 index 0000000..c3618ca Binary files /dev/null and b/help/manual/pl/typowy-skrypt-wnetrze.png differ diff --git a/help/manual/pl/typowy-skrypt.png b/help/manual/pl/typowy-skrypt.png new file mode 100644 index 0000000..6e2efe0 Binary files /dev/null and b/help/manual/pl/typowy-skrypt.png differ -- cgit v1.3.1