From b9509766753cbe03575afb4d1a764eb489cf1e60 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 6 Feb 2019 20:35:54 +0100 Subject: [PATCH] enable dropping commands into all rings, experimental, under construction --- HISTORY.md | 4 ++- snap.html | 2 +- src/blocks.js | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/gui.js | 20 ++++++++++++--- 4 files changed, 88 insertions(+), 6 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 59a86959..37288bbf 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -26,6 +26,7 @@ * optimized in-project storage of atomic-data lists (more efficient, less space) * remove all clones when the Green Flag is clicked * adjust bottom of STOP block to reflect the menu selection (show / hide bottom notch) + * enable dropping commands into all rings, experimental, under construction * Notable Fixes: * "relabel" blocks with translated drop-down choices * transforming arrayed to linked lists without loosing the last element @@ -39,7 +40,8 @@ ### 2019-02-06 * Blocks, BYOB: refactored custom block input options and drop-down menus -* Blocks: adjust bottom of STOP block to reflect the menu selection (show / hide bottom notch) +* Blocks: adjust bottom of STOP block to reflect the menu selection (show / hide bottom notch) +* Blocks: enable dropping commands into all rings, under constructions ### 2019-02-05 * BYOB: radio button symbols for special slot / drop-down menu options diff --git a/snap.html b/snap.html index 4f308e9c..8916384b 100755 --- a/snap.html +++ b/snap.html @@ -9,7 +9,7 @@ - + diff --git a/src/blocks.js b/src/blocks.js index 5b155402..a59898fc 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -4692,6 +4692,18 @@ CommandBlockMorph.prototype.snap = function (hand) { } }; +CommandBlockMorph.prototype.prepareToBeGrabbed = function (handMorph) { + // +++ + var oldPos = this.position(); + + nop(handMorph); + if (this.parent instanceof RingReporterSlotMorph) { + this.parent.revertToDefaultInput(this); + this.setPosition(oldPos); + } + CommandBlockMorph.uber.prepareToBeGrabbed.call(this, handMorph); +}; + CommandBlockMorph.prototype.isStop = function () { var choice; if (this.selector === 'doStopThis') { // this could be cached... @@ -11594,6 +11606,8 @@ RingReporterSlotMorph.prototype.rfBorder RingReporterSlotMorph.prototype.edge = RingCommandSlotMorph.prototype.edge; +RingReporterSlotMorph.prototype.enableCommandDrops = false; // +++ not finished + // RingReporterSlotMorph instance creation: function RingReporterSlotMorph(isPredicate) { @@ -11620,6 +11634,60 @@ RingReporterSlotMorph.prototype.replaceInput = function (source, target) { } }; +///* under construction +++ +// RingReporterSlotMorph attach targets for commands: + +RingReporterSlotMorph.prototype.slotAttachPoint = + CommandSlotMorph.prototype.slotAttachPoint; + +RingReporterSlotMorph.prototype.dentLeft = + CommandSlotMorph.prototype.dentLeft; + +RingReporterSlotMorph.prototype.dentCenter = + CommandSlotMorph.prototype.dentCenter; + +RingReporterSlotMorph.prototype.attachTargets = function () { + if (!RingReporterSlotMorph.prototype.enableCommandDrops || + this.contents() instanceof ReporterBlockMorph + ) { + // don't let commands "kick out" embedded reporters + return []; + } + return CommandSlotMorph.prototype.attachTargets.call(this); +}; + +// RingReporterSlotMorph nesting for commands: + +RingReporterSlotMorph.prototype.nestedBlock = function (block) { + if (block) { + var nb = this.nestedBlock(); + this.contents().destroy(); + this.add(block); + if (nb) { + block.bottomBlock().nextBlock(nb); + } + this.fixLayout(); + } else { + return detect( + this.children, + function (child) { + return child instanceof BlockMorph; + } + ); + } +}; + +// RingReporterSlotMorph layout: + +RingReporterSlotMorph.prototype.fixLayout = function () { + if (this.contents() instanceof CommandBlockMorph) { + CommandSlotMorph.prototype.fixLayout.call(this); + } else { + RingReporterSlotMorph.uber.fixLayout.call(this); + } +}; +//*/ + // RingReporterSlotMorph drawing: RingReporterSlotMorph.prototype.drawRounded = function (context) { diff --git a/src/gui.js b/src/gui.js index fc778261..062ca16e 100644 --- a/src/gui.js +++ b/src/gui.js @@ -61,13 +61,13 @@ /*global modules, Morph, SpriteMorph, SyntaxElementMorph, Color, Cloud, ListWatcherMorph, TextMorph, newCanvas, useBlurredShadows, VariableFrame, StringMorph, Point, MenuMorph, morphicVersion, DialogBoxMorph,normalizeCanvas, -ToggleButtonMorph, contains, ScrollFrameMorph, StageMorph, PushButtonMorph, +ToggleButtonMorph, contains, ScrollFrameMorph, StageMorph, PushButtonMorph, sb, InputFieldMorph, FrameMorph, Process, nop, SnapSerializer, ListMorph, detect, AlignmentMorph, TabMorph, Costume, MorphicPreferences, Sound, BlockMorph, -ToggleMorph, InputSlotDialogMorph, ScriptsMorph, isNil, SymbolMorph, +ToggleMorph, InputSlotDialogMorph, ScriptsMorph, isNil, SymbolMorph, fontHeight, BlockExportDialogMorph, BlockImportDialogMorph, SnapTranslator, localize, List, ArgMorph, Uint8Array, HandleMorph, SVG_Costume, TableDialogMorph, -fontHeight, sb, CommentMorph, CommandBlockMorph, BooleanSlotMorph, +CommentMorph, CommandBlockMorph, BooleanSlotMorph, RingReporterSlotMorph, BlockLabelPlaceHolderMorph, Audio, SpeechBubbleMorph, ScriptFocusMorph, XML_Element, WatcherMorph, BlockRemovalDialogMorph, saveAs, TableMorph, isSnapObject, isRetinaEnabled, disableRetinaSupport, enableRetinaSupport, @@ -75,7 +75,7 @@ isRetinaSupported, SliderMorph, Animation, BoxMorph, MediaRecorder*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2019-January-28'; +modules.gui = '2019-February-06'; // Declarations @@ -3141,6 +3141,18 @@ IDE_Morph.prototype.settingsMenu = function () { 'check to enable\nsaving linked sublist identities', true ); + addPreference( + 'Enable command drops in all rings', + function () { + RingReporterSlotMorph.prototype.enableCommandDrops = + !RingReporterSlotMorph.prototype.enableCommandDrops; + }, + RingReporterSlotMorph.prototype.enableCommandDrops, + 'UNDER CONSTRUCTION!\nuncheck to disable\ndropping commands in ' + + 'reporter rings', + 'UNDER CONSTRUCTION!\ncheck to enable\ndropping commands in all rings', + true + ); menu.popup(world, pos); };