From 0bcbaf55dedeb4d780f965fefda88ead6a4aadb3 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 24 Jul 2020 16:34:59 +0200 Subject: [PATCH] tweaked block representations in widgets for fading --- HISTORY.md | 3 ++- snap.html | 8 ++++---- src/blocks.js | 19 ++++++++++++++++--- src/byob.js | 11 ++++++++--- src/threads.js | 10 ++++++++-- src/widgets.js | 31 ++++++++++++++++++++++++------- 6 files changed, 62 insertions(+), 20 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 24405408..ded5e855 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -5,7 +5,8 @@ ### 2020-07-24 * gui: cleaned up block-fading pre-sets * updated German translation -* tweaked IDE colors for block-fading +* gui: tweaked IDE colors for block-fading +* blocks, threads, byob, widgets: tweaked block representations in widgets for fading ### 2020-07-23 * morphic: fixed mouseDown events for touch devices diff --git a/snap.html b/snap.html index ea608326..ef528cc4 100755 --- a/snap.html +++ b/snap.html @@ -6,14 +6,14 @@ - - - + + + - + diff --git a/src/blocks.js b/src/blocks.js index 85000a69..3aff6390 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -158,7 +158,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2020-July-23'; +modules.blocks = '2020-July-24'; var SyntaxElementMorph; var BlockMorph; @@ -3481,7 +3481,6 @@ BlockMorph.prototype.showHelp = function () { if (comment) { block = def.blockInstance(); block.refreshDefaults(def); - block.addShadow(); comment = comment.fullCopy(); comment.contents.parse(); help = ''; @@ -3492,7 +3491,13 @@ BlockMorph.prototype.showHelp = function () { 'Help', help.substr(1), myself.world(), - block.fullImage() + block.doWithAlpha( + 1, + () => { + block.addShadow(); + return block.fullImage(); + } + ) ); return; } @@ -4053,6 +4058,14 @@ BlockMorph.prototype.scriptPic = function () { return pic; }; +BlockMorph.prototype.clearAlpha = function () { + this.forAllChildren(m => { + if (m instanceof BlockMorph) { + delete m.alpha; + } + }); +}; + // BlockMorph drawing BlockMorph.prototype.render = function (ctx) { diff --git a/src/byob.js b/src/byob.js index dae33982..b4402984 100644 --- a/src/byob.js +++ b/src/byob.js @@ -108,7 +108,7 @@ BooleanSlotMorph, XML_Serializer, SnapTranslator*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2020-July-01'; +modules.byob = '2020-July-24'; // Declarations @@ -1228,7 +1228,6 @@ CustomCommandBlockMorph.prototype.deleteBlockDefinition = function () { method = this.isGlobal? this.definition : rcvr.getLocalMethod(this.blockSpec); block = method.blockInstance(); - block.addShadow(); new DialogBoxMorph( this, () => { @@ -1264,7 +1263,13 @@ CustomCommandBlockMorph.prototype.deleteBlockDefinition = function () { 'Delete Custom Block', localize('block deletion dialog text'), // long string lookup this.world(), - block.fullImage() + block.doWithAlpha( + 1, + () => { + block.addShadow(); + return block.fullImage(); + } + ) ); }; diff --git a/src/threads.js b/src/threads.js index adb0b126..5d4d8fef 100644 --- a/src/threads.js +++ b/src/threads.js @@ -61,7 +61,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy, Map, isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph, BLACK, TableFrameMorph, ColorSlotMorph, isSnapObject, newCanvas, Symbol, SVG_Costume*/ -modules.threads = '2020-July-22'; +modules.threads = '2020-July-24'; var ThreadManager; var Process; @@ -6114,7 +6114,13 @@ Context.prototype.image = function () { } } ring.embed(block, this.inputs); - return ring.doWithAlpha(1, () => ring.fullImage()); + return ring.doWithAlpha( + 1, + () => { + ring.clearAlpha(); + return ring.fullImage(); + } + ); } if (this.expression instanceof Array) { block = this.expression[this.pc].fullCopy(); diff --git a/src/widgets.js b/src/widgets.js index 21a1a99b..d1069657 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -85,7 +85,7 @@ HTMLCanvasElement, fontHeight, SymbolMorph, localize, SpeechBubbleMorph, ArrowMorph, MenuMorph, isString, isNil, SliderMorph, MorphicPreferences, ScrollFrameMorph, MenuItemMorph, Note*/ -modules.widgets = '2020-July-21'; +modules.widgets = '2020-July-24'; var PushButtonMorph; var ToggleButtonMorph; @@ -1351,7 +1351,15 @@ ToggleElementMorph.prototype.init = function ( // ToggleElementMorph drawing: ToggleElementMorph.prototype.render = function (ctx) { - var shading = !MorphicPreferences.isFlat || this.is3D; + var shading = !MorphicPreferences.isFlat || this.is3D, + shadow = () => { + if (shading) { + this.element.addShadow( + this.shadowOffset, + this.userState === 'normal' ? 0 : this.shadowAlpha + ); + } + }; this.color = this.element.color; this.element.removeShadow(); @@ -1366,13 +1374,22 @@ ToggleElementMorph.prototype.render = function (ctx) { this.element[this.builder](this.contrast); } } - if (shading) { - this.element.addShadow( - this.shadowOffset, - this.userState === 'normal' ? 0 : this.shadowAlpha + if (this.element.doWithAlpha) { + ctx.drawImage( + this.element.doWithAlpha( + 1, + () => { + shadow(); + return this.element.fullImage(); + } + ), + 0, + 0 ); + } else { + shadow(); + ctx.drawImage(this.element.fullImage(), 0, 0); } - ctx.drawImage(this.element.fullImage(), 0, 0); // reset element this.element.removeShadow();