diff --git a/HISTORY.md b/HISTORY.md index 62c6c7e7..56a43d91 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,6 +4,7 @@ * **New Features:** * support dragging blocks out from result bubbles, and from speech balloons and variable watchers when in edit mode + * support dragging costumes and sounds out from result bubbles * support deleting and inserting individual variadic slots, script vars & ring params * **Notable Changes:** * **Notable Fixes:** @@ -14,6 +15,9 @@ * Hungarian, thank you, Attila Faragó, for this HUGE update! * German +### 2022-01-27 +* blocks, gui: support dragging costumes and sounds out from result bubbles + ### 2022-01-26 * blocks: refactored slot context menus * blocks: support for deleting and inserting individual script vars & ring params diff --git a/snap.html b/snap.html index 3c6df643..0965af14 100755 --- a/snap.html +++ b/snap.html @@ -16,11 +16,11 @@ - + - + diff --git a/src/blocks.js b/src/blocks.js index 63cdc41d..2b42b1a0 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -154,13 +154,14 @@ fontHeight, TableFrameMorph, SpriteMorph, Context, ListWatcherMorph, Rectangle, DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, WHITE, BLACK, Costume, IDE_Morph, BlockDialogMorph, BlockEditorMorph, localize, CLEAR, Point, isSnapObject, PushButtonMorph, SpriteIconMorph, Process, AlignmentMorph, List, -CustomCommandBlockMorph, ToggleButtonMorph, DialMorph, SnapExtensions*/ +CustomCommandBlockMorph, ToggleButtonMorph, DialMorph, SnapExtensions, +CostumeIconMorph, SoundIconMorph*/ /*jshint esversion: 6*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2022-January-26'; +modules.blocks = '2022-January-27'; var SyntaxElementMorph; var BlockMorph; @@ -2250,8 +2251,56 @@ SyntaxElementMorph.prototype.showBubble = function (value, exportPic, target) { morphToShow.bounds.setWidth(img.width); morphToShow.bounds.setHeight(img.height); morphToShow.cachedImage = img; + + // support costumes to be dragged out of result bubbles: + morphToShow.isDraggable = true; + + morphToShow.selectForEdit = function () { + var cst = value.copy(), + icon, + prepare; + + cst.name = ide.currentSprite.newCostumeName(cst.name); + icon = new CostumeIconMorph(cst); + prepare = icon.prepareToBeGrabbed; + + icon.prepareToBeGrabbed = function (hand) { + hand.grabOrigin = { + origin: ide.palette, + position: ide.palette.center() + }; + this.prepareToBeGrabbed = prepare; + }; + + icon.setCenter(this.center()); + return icon; + }; } else if (value instanceof Sound) { morphToShow = new SymbolMorph('notes', 30); + + // support sounds to be dragged out of result bubbles: + morphToShow.isDraggable = true; + + morphToShow.selectForEdit = function () { + var snd = value.copy(), + icon, + prepare; + + snd.name = ide.currentSprite.newSoundName(snd.name); + icon = new SoundIconMorph(snd); + prepare = icon.prepareToBeGrabbed; + + icon.prepareToBeGrabbed = function (hand) { + hand.grabOrigin = { + origin: ide.palette, + position: ide.palette.center() + }; + this.prepareToBeGrabbed = prepare; + }; + + icon.setCenter(this.center()); + return icon; + }; } else if (value instanceof Context) { img = value.image(); morphToShow = new Morph(); diff --git a/src/gui.js b/src/gui.js index 801bb194..75bf3182 100644 --- a/src/gui.js +++ b/src/gui.js @@ -86,7 +86,7 @@ BlockVisibilityDialogMorph, ThreadManager*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2022-January-21'; +modules.gui = '2022-January-27'; // Declarations @@ -1564,7 +1564,7 @@ IDE_Morph.prototype.createPalette = function (forSearching) { droppedMorph.destroy(); this.removeSprite(droppedMorph.object); } else if (droppedMorph instanceof CostumeIconMorph) { - this.currentSprite.wearCostume(null); + // this.currentSprite.wearCostume(null); // do we need this? droppedMorph.perish(myself.isAnimating ? 200 : 0); } else if (droppedMorph instanceof BlockMorph) { this.stage.threads.stopAllForBlock(droppedMorph); @@ -1764,6 +1764,7 @@ IDE_Morph.prototype.createSpriteBar = function () { // tab bar tabBar.tabTo = function (tabString) { var active; + myself.world().hand.destroyTemporaries(); myself.currentTab = tabString; this.children.forEach(each => { each.refresh(); @@ -1890,12 +1891,6 @@ IDE_Morph.prototype.createSpriteEditor = function () { this.spriteEditor.acceptsDrops = false; this.spriteEditor.contents.acceptsDrops = false; - - this.spriteEditor.contents.mouseEnterDragging = (morph) => { - if (morph instanceof BlockMorph) { - this.spriteBar.tabBar.tabTo('scripts'); - } - }; } else if (this.currentTab === 'sounds') { this.spriteEditor = new JukeboxMorph( this.currentSprite, @@ -1906,12 +1901,6 @@ IDE_Morph.prototype.createSpriteEditor = function () { this.spriteEditor.updateSelection(); this.spriteEditor.acceptDrops = false; this.spriteEditor.contents.acceptsDrops = false; - - this.spriteEditor.contents.mouseEnterDragging = (morph) => { - if (morph instanceof BlockMorph) { - this.spriteBar.tabBar.tabTo('scripts'); - } - }; } else { this.spriteEditor = new Morph(); this.spriteEditor.color = this.groupColor; @@ -1927,6 +1916,16 @@ IDE_Morph.prototype.createSpriteEditor = function () { }; this.add(this.spriteEditor); } + + this.spriteEditor.contents.mouseEnterDragging = (morph) => { + if (morph instanceof BlockMorph) { + this.spriteBar.tabBar.tabTo('scripts'); + } else if (morph instanceof CostumeIconMorph) { + this.spriteBar.tabBar.tabTo('costumes'); + } else if (morph instanceof SoundIconMorph) { + this.spriteBar.tabBar.tabTo('sounds'); + } + }; }; IDE_Morph.prototype.createCorralBar = function () {