diff --git a/HISTORY.md b/HISTORY.md index e162874d..467b52ba 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -66,6 +66,7 @@ ### 2021-11-24 * threads: fixed #2918 +* gui, objects, scenes: added scene-setting to hide/show buttons in the unified palette ### 2021-11-23 * byob: refresh category buttons when hiding / showing blocks diff --git a/snap.html b/snap.html index 92003d1a..29860f01 100755 --- a/snap.html +++ b/snap.html @@ -18,9 +18,9 @@ - - - + + + diff --git a/src/gui.js b/src/gui.js index 3e43f6be..2b9acf53 100644 --- a/src/gui.js +++ b/src/gui.js @@ -86,7 +86,7 @@ BlockVisibilityDialogMorph, ThreadManager*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2021-November-23'; +modules.gui = '2021-November-24'; // Declarations @@ -4219,6 +4219,13 @@ IDE_Morph.prototype.settingsMenu = function () { 'uncheck to hide\ncategory names\nin the palette', 'check to show\ncategory names\nin the palette' ); + addPreference( + 'Show buttons', + () => this.togglePaletteButtons(), + this.scene.showPaletteButtons, + 'uncheck to hide buttons\nin the palette', + 'check to show buttons\nin the palette' + ); } addPreference( 'Persist linked sublist IDs', @@ -6363,6 +6370,12 @@ IDE_Morph.prototype.toggleCategoryNames = function () { this.recordUnsavedChanges(); }; +IDE_Morph.prototype.togglePaletteButtons = function () { + this.scene.showPaletteButtons = !this.scene.showPaletteButtons; + this.flushBlocksCache(); + this.refreshPalette(); + this.recordUnsavedChanges(); +}; IDE_Morph.prototype.setPaletteWidth = function (newWidth) { var msecs = this.isAnimating ? 100 : 0, diff --git a/src/objects.js b/src/objects.js index 99ebb83f..2982f8e9 100644 --- a/src/objects.js +++ b/src/objects.js @@ -87,7 +87,7 @@ BlockVisibilityDialogMorph*/ /*jshint esversion: 6*/ -modules.objects = '2021-November-19'; +modules.objects = '2021-November-24'; var SpriteMorph; var StageMorph; @@ -3003,8 +3003,10 @@ SpriteMorph.prototype.palette = function (category) { SpriteMorph.prototype.freshPalette = function (category) { var myself = this, palette = new ScrollFrameMorph(null, null, this.sliderColor), - showCategories, unit = SyntaxElementMorph.prototype.fontSize, + ide, + showCategories, + showButtons, x = 0, y = 5, ry = 0, @@ -3090,7 +3092,9 @@ SpriteMorph.prototype.freshPalette = function (category) { if (category === 'unified') { // In a Unified Palette custom blocks appear following each category, // but there is only 1 make a block button (at the end). - showCategories = this.parentThatIsA(IDE_Morph).scene.showCategories; + ide = this.parentThatIsA(IDE_Morph); + showCategories = ide.scene.showCategories; + showButtons = ide.scene.showPaletteButtons; blocks = SpriteMorph.prototype.allCategories().reduce( (blocks, category) => { let header = [this.categoryText(category), '-'], @@ -3101,11 +3105,19 @@ SpriteMorph.prototype.freshPalette = function (category) { (primitives.some(item => item instanceof BlockMorph) || customs.length); + // hide category names if (!showCategories && category !== 'variables') { primitives = primitives.filter(each => each !== '-' && each !== '='); } + // hide "make / delete a variable" buttons + if (!showButtons && category === 'variables') { + primitives = primitives.filter(each => + !(each instanceof PushButtonMorph && + !(each instanceof ToggleMorph))); + } + return blocks.concat( showHeader ? header : [], primitives, @@ -3120,8 +3132,11 @@ SpriteMorph.prototype.freshPalette = function (category) { // ensure we do not modify the cached array blocks = this.getPrimitiveTemplates(category).slice(); } - blocks.push('='); - blocks.push(this.makeBlockButton(category)); + + if (category !== 'unified' || showButtons) { + blocks.push('='); + blocks.push(this.makeBlockButton(category)); + } if (category !== 'unified') { blocks.push('='); diff --git a/src/scenes.js b/src/scenes.js index b71beeb5..90a83772 100644 --- a/src/scenes.js +++ b/src/scenes.js @@ -53,7 +53,7 @@ normalizeCanvas, SnapSerializer, Costume, ThreadManager*/ // Global stuff //////////////////////////////////////////////////////// -modules.scenes = '2021-November-12'; +modules.scenes = '2021-November-24'; // Projecct ///////////////////////////////////////////////////////// @@ -120,6 +120,7 @@ function Scene(aStageMorph) { this.hasUnsavedEdits = false; this.unifiedPalette = false; this.showCategories = true; + this.showPaletteButtons = true; // cached IDE state this.sprites = new List();