From 13e13a0b05c3684088d72cfca0113c4814e7484b Mon Sep 17 00:00:00 2001 From: jmoenig Date: Tue, 26 Oct 2021 15:34:30 +0200 Subject: [PATCH] new "showingExtensions" session setting for showing extension prims in the palette --- HISTORY.md | 1 + snap.html | 2 +- src/gui.js | 14 +++++++++++++- src/objects.js | 52 +++++++++++++++++++++++++++++++------------------- 4 files changed, 47 insertions(+), 22 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index bc9bf5b9..961361b3 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -48,6 +48,7 @@ ### 2021-10-26 * objects: don't show codification and js-func blocks in search results unless enabled +* gui, objects: new "showingExtensions" session setting for showing extension prims in the palette ### 2021-10-25 * byob: fixed #2902 diff --git a/snap.html b/snap.html index 663d0abc..94835487 100755 --- a/snap.html +++ b/snap.html @@ -20,7 +20,7 @@ - + diff --git a/src/gui.js b/src/gui.js index b71cc9a9..17b0d1a3 100644 --- a/src/gui.js +++ b/src/gui.js @@ -85,7 +85,7 @@ Animation, BoxMorph, BlockDialogMorph, RingMorph, Project, ZERO, BLACK*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2021-October-20'; +modules.gui = '2021-October-26'; // Declarations @@ -3808,6 +3808,18 @@ IDE_Morph.prototype.settingsMenu = function () { 'NOTE: You will have to manually\n' + 'sign in again to access your account.' */ ); + addPreference( + 'Extension blocks', + () => { + SpriteMorph.prototype.showingExtensions = + !SpriteMorph.prototype.showingExtensions; + this.flushBlocksCache('variables'); + this.refreshPalette(); + }, + SpriteMorph.prototype.showingExtensions, + 'uncheck to hide extension\nprimitives in the palette', + 'check to show extension\nprimitives in the palette' + ); addPreference( 'Add scenes', () => this.isAddingScenes = !this.isAddingScenes, diff --git a/src/objects.js b/src/objects.js index a1786228..e5908176 100644 --- a/src/objects.js +++ b/src/objects.js @@ -183,6 +183,7 @@ SpriteMorph.prototype.isCachingPrimitives = true; SpriteMorph.prototype.enableNesting = true; SpriteMorph.prototype.enableFirstClass = true; +SpriteMorph.prototype.showingExtensions = false; SpriteMorph.prototype.useFlatLineEnds = false; SpriteMorph.prototype.highlightColor = new Color(250, 200, 130); SpriteMorph.prototype.highlightBorder = 8; @@ -2743,13 +2744,8 @@ SpriteMorph.prototype.blockTemplates = function ( blocks.push(block('doInsertInList')); blocks.push(block('doReplaceInList')); - // for debugging: /////////////// - if (devMode) { - blocks.push('-'); - blocks.push(this.devModeText()); - blocks.push('-'); - blocks.push(block('doShowTable')); - blocks.push('-'); + if (SpriteMorph.prototype.showingExtensions) { + blocks.push('='); blocks.push(block('doApplyExtension')); blocks.push(block('reportApplyExtension')); } @@ -2762,6 +2758,14 @@ SpriteMorph.prototype.blockTemplates = function ( blocks.push('-'); blocks.push(block('reportMappedCode')); } + + // for debugging: /////////////// + if (this.world().isDevMode) { + blocks.push('-'); + blocks.push(this.devModeText()); + blocks.push('-'); + blocks.push(block('doShowTable')); + } } return blocks; @@ -3194,6 +3198,12 @@ SpriteMorph.prototype.isDisablingBlock = function (aBlock) { if (sel === 'reportJSFunction') { return !Process.prototype.enableJS; } + if ( + sel === 'doApplyExtension' || + sel === 'reportApplyExtension' + ) { + return !SpriteMorph.prototype.showingExtensions; + } if ( sel === 'doMapCodeOrHeader' || sel === 'doMapValueCode' || @@ -8998,25 +9008,27 @@ StageMorph.prototype.blockTemplates = function ( blocks.push(block('doInsertInList')); blocks.push(block('doReplaceInList')); + if (SpriteMorph.prototype.showingExtensions) { + blocks.push('='); + blocks.push(block('doApplyExtension')); + blocks.push(block('reportApplyExtension')); + } + + if (StageMorph.prototype.enableCodeMapping) { + blocks.push('='); + blocks.push(block('doMapCodeOrHeader')); + blocks.push(block('doMapValueCode')); + blocks.push(block('doMapListCode')); + blocks.push('-'); + blocks.push(block('reportMappedCode')); + } + // for debugging: /////////////// if (this.world().isDevMode) { blocks.push('-'); blocks.push(this.devModeText()); blocks.push('-'); blocks.push(block('doShowTable')); - blocks.push('-'); - blocks.push(block('doApplyExtension')); - blocks.push(block('reportApplyExtension')); - } - - blocks.push('='); - - if (StageMorph.prototype.enableCodeMapping) { - blocks.push(block('doMapCodeOrHeader')); - blocks.push(block('doMapValueCode')); - blocks.push(block('doMapListCode')); - blocks.push('-'); - blocks.push(block('reportMappedCode')); } }