From 04168220bde4cdfa82e570dcb8d098653a4fcb7a Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 17 Sep 2014 14:40:39 +0200 Subject: Refactor variables handling introducing Variable objects, all functionality stays the same at this time --- objects.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'objects.js') diff --git a/objects.js b/objects.js index fbb9e84..2ed20f2 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-July-30'; +modules.objects = '2014-September-17'; var SpriteMorph; var StageMorph; @@ -6735,7 +6735,8 @@ WatcherMorph.prototype.update = function () { if (this.target && this.getter) { this.updateLabel(); if (this.target instanceof VariableFrame) { - newValue = this.target.vars[this.getter]; + newValue = this.target.vars[this.getter] ? + this.target.vars[this.getter].value : undefined; } else { newValue = this.target[this.getter](); } @@ -6820,7 +6821,7 @@ WatcherMorph.prototype.fixLayout = function () { this.sliderMorph.button.pressColor.b += 100; this.sliderMorph.setHeight(fontSize); this.sliderMorph.action = function (num) { - myself.target.vars[myself.getter] = Math.round(num); + myself.target.vars[myself.getter].value = Math.round(num); }; this.add(this.sliderMorph); } -- cgit v1.3.1 From 29b47cc2d2ebb87eec7a40313992181d5e99c95d Mon Sep 17 00:00:00 2001 From: jmoenig Date: Tue, 30 Sep 2014 09:26:50 +0200 Subject: fixed #593 match broadcast numbers with event hat blocks containing strings that can be parsed as numbers --- history.txt | 4 ++++ objects.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index ec1b9cb..7c61c63 100755 --- a/history.txt +++ b/history.txt @@ -2282,3 +2282,7 @@ ______ * Portuguese translation update, thanks, Manuel! * fixed #590 (Russian translation syntax glitches) Thanks @alexf2000 ! * Paint: flood fill issue fixed, thanks, Kartik! + +140930 +------ +* Objects: fixed #593 match broadcast numbers with event hat blocks containing strings that can be parsed as numbers diff --git a/objects.js b/objects.js index 2ed20f2..a36cfae 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-September-17'; +modules.objects = '2014-September-30'; var SpriteMorph; var StageMorph; @@ -3457,6 +3457,7 @@ SpriteMorph.prototype.allMessageNames = function () { }; SpriteMorph.prototype.allHatBlocksFor = function (message) { + if (typeof message === 'number') {message = message.toString(); } return this.scripts.children.filter(function (morph) { var event; if (morph.selector) { -- cgit v1.3.1 From 71c9103503691285191e024c8ae30200240d54cc Mon Sep 17 00:00:00 2001 From: jmoenig Date: Tue, 30 Sep 2014 10:31:13 +0200 Subject: fixed #378 disable context menus for boolean representations --- history.txt | 1 + objects.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index 1e1ccee..2b0f73f 100755 --- a/history.txt +++ b/history.txt @@ -2288,4 +2288,5 @@ ______ * Objects: fixed #593 match broadcast numbers with event hat blocks containing strings that can be parsed as numbers * BYOB: allow percent symbols in custom block texts (fix #361), thanks, @Gubolin!! * Morphic: allow negative min/max values for sliders (fix #285), thanks, @Gubolin!! +* Objects: fixed #378 (disable context menus for boolean representations) diff --git a/objects.js b/objects.js index a36cfae..cca5439 100644 --- a/objects.js +++ b/objects.js @@ -6408,10 +6408,14 @@ CellMorph.prototype.drawNew = function () { } this.contentsMorph.setColor(new Color(255, 255, 255)); } else if (typeof this.contents === 'boolean') { - this.contentsMorph = SpriteMorph.prototype.booleanMorph.call( + img = SpriteMorph.prototype.booleanMorph.call( null, this.contents - ); + ).fullImage(); + this.contentsMorph = new Morph(); + this.contentsMorph.silentSetWidth(img.width); + this.contentsMorph.silentSetHeight(img.height); + this.contentsMorph.image = img; } else if (this.contents instanceof HTMLCanvasElement) { this.contentsMorph = new Morph(); this.contentsMorph.silentSetWidth(this.contents.width); -- cgit v1.3.1 From 86672fec4a5684c1d33a75cc3ff9ec5ee13fced3 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 1 Oct 2014 10:12:37 +0200 Subject: fixed #599 disable IDE keyboard shortcuts in presentation mode --- history.txt | 1 + objects.js | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index fb2c065..19b962a 100755 --- a/history.txt +++ b/history.txt @@ -2294,3 +2294,4 @@ ______ 140930 ------ * Threads: workaround for some REPORT issues +* Objects: fixed #599 (disable IDE keyboard shortcuts in presentation mode) diff --git a/objects.js b/objects.js index cca5439..905b3d1 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-September-30'; +modules.objects = '2014-October-01'; var SpriteMorph; var StageMorph; @@ -4675,6 +4675,7 @@ StageMorph.prototype.fireKeyEvent = function (key) { var evt = key.toLowerCase(), hats = [], procs = [], + ide = this.parentThatIsA(IDE_Morph), myself = this; this.keysPressed[evt] = true; @@ -4682,19 +4683,24 @@ StageMorph.prototype.fireKeyEvent = function (key) { return this.fireGreenFlagEvent(); } if (evt === 'ctrl f') { - return this.parentThatIsA(IDE_Morph).currentSprite.searchBlocks(); + if (!ide.isAppMode) {ide.currentSprite.searchBlocks(); } + return; } if (evt === 'ctrl n') { - return this.parentThatIsA(IDE_Morph).createNewProject(); + if (!ide.isAppMode) {ide.createNewProject(); } + return; } if (evt === 'ctrl o') { - return this.parentThatIsA(IDE_Morph).openProjectsBrowser(); + if (!ide.isAppMode) {ide.openProjectsBrowser(); } + return; } if (evt === 'ctrl s') { - return this.parentThatIsA(IDE_Morph).save(); + if (!ide.isAppMode) {ide.save(); } + return; } if (evt === 'ctrl shift s') { - return this.parentThatIsA(IDE_Morph).saveProjectsBrowser(); + if (!ide.isAppMode) {return ide.saveProjectsBrowser(); } + return; } if (evt === 'esc') { return this.fireStopAllEvent(); -- cgit v1.3.1 From 2ae675132a52b8fdb3bd52e80db858500de9f265 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 6 Oct 2014 10:34:56 +0200 Subject: fixed #604. Thanks, @Gubolin! --- gui.js | 3 ++- history.txt | 4 ++++ objects.js | 10 +++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'objects.js') diff --git a/gui.js b/gui.js index 2456277..04481cc 100644 --- a/gui.js +++ b/gui.js @@ -69,7 +69,7 @@ SpeechBubbleMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2014-October-02'; +modules.gui = '2014-October-06'; // Declarations @@ -3354,6 +3354,7 @@ IDE_Morph.prototype.toggleStageSize = function (isSmall) { myself.stageRatio += (1 - myself.stageRatio) / 2; myself.setExtent(world.extent()); if (myself.stageRatio > 0.9) { + myself.stageRatio = 1; myself.isSmallStage = false; myself.setExtent(world.extent()); myself.controlBar.stageSizeButton.refresh(); diff --git a/history.txt b/history.txt index 00dc07e..5999536 100755 --- a/history.txt +++ b/history.txt @@ -2301,3 +2301,7 @@ ______ 141002 ------ * GUI: New feature - minimal stage mode (shift-click on small-stage button) + +141006 +------ +* GUI, Objects: fixed #604. Thanks, @Gubolin! diff --git a/objects.js b/objects.js index 905b3d1..17450dd 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-October-01'; +modules.objects = '2014-October-06'; var SpriteMorph; var StageMorph; @@ -4378,8 +4378,12 @@ StageMorph.prototype.drawOn = function (aCanvas, aRect) { ); // pen trails - ws = w / this.scale; - hs = h / this.scale; + ws = Math.floor( + Math.min(w / this.scale, this.image.width * this.scale) + ); + hs = Math.floor( + Math.min(h / this.scale, this.image.height * this.scale) + ); context.save(); context.scale(this.scale, this.scale); context.drawImage( -- cgit v1.3.1 From 5f3279990be3478fde79b94f7dbd5d7da80df84b Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 8 Oct 2014 11:21:49 +0200 Subject: fixed #608, #610 --- history.txt | 4 ++++ objects.js | 48 ++++++++++++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 18 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index 5999536..28116b9 100755 --- a/history.txt +++ b/history.txt @@ -2305,3 +2305,7 @@ ______ 141006 ------ * GUI, Objects: fixed #604. Thanks, @Gubolin! + +141008 +------ +* Objects: fixed #608, #610 diff --git a/objects.js b/objects.js index 17450dd..4be213a 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-October-06'; +modules.objects = '2014-October-08'; var SpriteMorph; var StageMorph; @@ -4378,25 +4378,37 @@ StageMorph.prototype.drawOn = function (aCanvas, aRect) { ); // pen trails - ws = Math.floor( - Math.min(w / this.scale, this.image.width * this.scale) - ); - hs = Math.floor( - Math.min(h / this.scale, this.image.height * this.scale) - ); + ws = w / this.scale; + hs = h / this.scale; context.save(); context.scale(this.scale, this.scale); - context.drawImage( - this.penTrails(), - src.left() / this.scale, - src.top() / this.scale, - ws, - hs, - area.left() / this.scale, - area.top() / this.scale, - ws, - hs - ); + try { + context.drawImage( + this.penTrails(), + src.left() / this.scale, + src.top() / this.scale, + ws, + hs, + area.left() / this.scale, + area.top() / this.scale, + ws, + hs + ); + } catch (err) { // sometimes triggered only by Firefox + // console.log(err); + context.restore(); + context.drawImage( + this.penTrails(), + 0, + 0, + this.dimensions.x, + this.dimensions.y, + this.left(), + this.top(), + this.dimensions.x * this.scale, + this.dimensions.y * this.scale + ); + } context.restore(); } }; -- cgit v1.3.1 From 927448d7ab4f7069661eb73018463fbf0e40651a Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 24 Nov 2014 10:05:19 +0100 Subject: Fixed #416 --- history.txt | 1 + objects.js | 50 +++++++++++++++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 19 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index 4d17e3e..9d977ad 100755 --- a/history.txt +++ b/history.txt @@ -2345,4 +2345,5 @@ ______ 1411214 ------- * Threads: Fixed #318 +* Objects: Fixed #416 diff --git a/objects.js b/objects.js index 4be213a..3b2c07b 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-October-08'; +modules.objects = '2014-November-24'; var SpriteMorph; var StageMorph; @@ -1674,6 +1674,20 @@ SpriteMorph.prototype.blockTemplates = function (category) { return menu; } + function addVar(pair) { + if (pair) { + if (myself.variables.silentFind(pair[0])) { + myself.inform('that name is already in use'); + } else { + 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(); + } + } + } + if (cat === 'motion') { blocks.push(block('forward')); @@ -1967,15 +1981,7 @@ SpriteMorph.prototype.blockTemplates = function (category) { function () { new VariableDialogMorph( null, - function (pair) { - if (pair && !myself.variables.silentFind(pair[0])) { - 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(); - } - }, + addVar, myself ).prompt( 'Variable name', @@ -4858,6 +4864,20 @@ StageMorph.prototype.blockTemplates = function (category) { ); } + function addVar(pair) { + if (pair) { + if (myself.variables.silentFind(pair[0])) { + myself.inform('that name is already in use'); + } else { + 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(); + } + } + } + if (cat === 'motion') { txt = new TextMorph(localize( @@ -5099,15 +5119,7 @@ StageMorph.prototype.blockTemplates = function (category) { function () { new VariableDialogMorph( null, - function (pair) { - if (pair && !myself.variables.silentFind(pair[0])) { - 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(); - } - }, + addVar, myself ).prompt( 'Variable name', -- cgit v1.3.1 From 0d8cc567e7f04a9416fc2518646f2d9187840d70 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 24 Nov 2014 10:43:53 +0100 Subject: Fixed #372 --- history.txt | 2 +- objects.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index 9d977ad..2d7e53e 100755 --- a/history.txt +++ b/history.txt @@ -2346,4 +2346,4 @@ ______ ------- * Threads: Fixed #318 * Objects: Fixed #416 - +* Objects: Fixed #372 diff --git a/objects.js b/objects.js index 3b2c07b..69376c8 100644 --- a/objects.js +++ b/objects.js @@ -2170,8 +2170,8 @@ SpriteMorph.prototype.freshPalette = function (category) { var defs = SpriteMorph.prototype.blocks, hiddens = StageMorph.prototype.hiddenPrimitives; return Object.keys(hiddens).some(function (any) { - return defs[any].category === category || - contains((more[category] || []), any); + return !isNil(defs[any]) && (defs[any].category === category + || contains((more[category] || []), any)); }); } @@ -2210,7 +2210,7 @@ SpriteMorph.prototype.freshPalette = function (category) { var hiddens = StageMorph.prototype.hiddenPrimitives, defs = SpriteMorph.prototype.blocks; Object.keys(hiddens).forEach(function (sel) { - if (defs[sel].category === category) { + if (defs[sel] && (defs[sel].category === category)) { delete StageMorph.prototype.hiddenPrimitives[sel]; } }); -- cgit v1.3.1 From 1f5934c81f494e897c78f5dde0885e16af913e4d Mon Sep 17 00:00:00 2001 From: jmoenig Date: Mon, 1 Dec 2014 11:25:28 +0100 Subject: Don't show hidden elements in the project thumbnail --- history.txt | 4 ++++ objects.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index 39a801d..34f967c 100755 --- a/history.txt +++ b/history.txt @@ -2362,3 +2362,7 @@ ______ 1411225 ------- * Threads: Fixed #656 + +141201 +------ +* Objects: Hide hidden elements in the project thumbnail diff --git a/objects.js b/objects.js index 69376c8..f0fe942 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-November-24'; +modules.objects = '2014-December-01'; var SpriteMorph; var StageMorph; @@ -5333,7 +5333,7 @@ StageMorph.prototype.thumbnail = function (extentPoint, excludedSprite) { this.dimensions.y * this.scale ); this.children.forEach(function (morph) { - if (morph !== excludedSprite) { + if (morph.isVisible && (morph !== excludedSprite)) { fb = morph.fullBounds(); fimg = morph.fullImage(); if (fimg.width && fimg.height) { -- cgit v1.3.1 From 17b6ae839b5c15c942440f38fc07bfcc45bc0811 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 3 Dec 2014 12:48:31 +0100 Subject: Improve edge-collision detection of default sprite “arrow” shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- history.txt | 5 +++++ objects.js | 9 ++++++--- threads.js | 14 ++++++++++---- 3 files changed, 21 insertions(+), 7 deletions(-) (limited to 'objects.js') diff --git a/history.txt b/history.txt index 986bcc4..b8af0f0 100755 --- a/history.txt +++ b/history.txt @@ -2372,3 +2372,8 @@ ______ 141202 ------ * New Kannada translation. Yay!! Thanks, Vinayakumar R!! + +141203 +------ +* Morphic: Cache actual bounding box of the Pen arrow shape +* Threads, Objects: Improve edge-collision detection of default sprite “arrow” shape diff --git a/objects.js b/objects.js index f0fe942..4ad376c 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-December-01'; +modules.objects = '2014-December-03'; var SpriteMorph; var StageMorph; @@ -3238,8 +3238,11 @@ SpriteMorph.prototype.setCenter = function (aPoint, justMe) { SpriteMorph.prototype.nestingBounds = function () { // same as fullBounds(), except that it uses "parts" instead of children - var result; - result = this.bounds; + // and special cases the costume-less "arrow" shape's bounding box + var result = this.bounds; + if (!this.costume && this.penBounds) { + result = this.penBounds.translateBy(this.position()); + } this.parts.forEach(function (part) { if (part.isVisible) { result = result.merge(part.nestingBounds()); diff --git a/threads.js b/threads.js index 59dd23a..9f9a221 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2014-November-26'; +modules.threads = '2014-December-03'; var ThreadManager; var Process; @@ -2368,6 +2368,7 @@ Process.prototype.objectTouchingObject = function (thisObj, name) { var myself = this, those, stage, + box, mouse; if (this.inputOption(name) === 'mouse-pointer') { @@ -2379,9 +2380,14 @@ Process.prototype.objectTouchingObject = function (thisObj, name) { } else { stage = thisObj.parentThatIsA(StageMorph); if (stage) { - if (this.inputOption(name) === 'edge' && - !stage.bounds.containsRectangle(thisObj.bounds)) { - return true; + if (this.inputOption(name) === 'edge') { + box = thisObj.bounds; + if (!thisObj.costume && thisObj.penBounds) { + box = thisObj.penBounds.translateBy(thisObj.position()); + } + if (!stage.bounds.containsRectangle(box)) { + return true; + } } if (this.inputOption(name) === 'pen trails' && thisObj.isTouching(stage.penTrailsMorph())) { -- cgit v1.3.1 From ad1fe34d1ed900e1e4fd75e5c5666f6ab28b9c80 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 4 Dec 2014 15:45:18 +0100 Subject: Experimental “ForEach” primitive (hidden in dev mode) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- objects.js | 13 ++++++++++++- threads.js | 22 +++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) (limited to 'objects.js') diff --git a/objects.js b/objects.js index 4ad376c..7277719 100644 --- a/objects.js +++ b/objects.js @@ -125,7 +125,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-December-03'; +modules.objects = '2014-December-04'; var SpriteMorph; var StageMorph; @@ -1151,6 +1151,13 @@ SpriteMorph.prototype.initBlocks = function () { category: 'lists', spec: 'map %repRing over %l' }, + doForEach: { + dev: true, + type: 'command', + category: 'lists', + spec: 'for %upvar in %l %cs', + defaults: [localize('each item')] + }, // Code mapping - experimental doMapCodeOrHeader: { // experimental @@ -2063,6 +2070,8 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push(txt); blocks.push('-'); blocks.push(block('reportMap')); + blocks.push('-'); + blocks.push(block('doForEach')); } ///////////////////////////////// @@ -5198,6 +5207,8 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push(txt); blocks.push('-'); blocks.push(block('reportMap')); + blocks.push('-'); + blocks.push(block('doForEach')); } ///////////////////////////////// diff --git a/threads.js b/threads.js index 9f9a221..c21375e 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2014-December-03'; +modules.threads = '2014-December-04'; var ThreadManager; var Process; @@ -1679,6 +1679,26 @@ Process.prototype.reportMap = function (reporter, list) { } }; +Process.prototype.doForEach = function (upvar, list, script) { + // perform a script for each element of a list, assigning the + // current iteration's element to a variable with the name + // specified in the "upvar" parameter, so it can be referenced + // within the script. Uses the context's - unused - fourth + // element as temporary storage for the current list index + + if (isNil(this.context.inputs[3])) {this.context.inputs[3] = 1; } + var index = this.context.inputs[3]; + this.context.outerContext.variables.addVar(upvar); + this.context.outerContext.variables.setVar( + upvar, + list.at(index) + ); + if (index > list.length()) {return; } + this.context.inputs[3] += 1; + this.pushContext(); + this.evaluate(script, new List(), true); +}; + // Process interpolated primitives Process.prototype.doWait = function (secs) { -- cgit v1.3.1