From fabd10b9e4cf00e45837b6f67a9700738dd5ade4 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 20 Feb 2020 16:11:40 +0100 Subject: [PATCH] shallow permanent shadows for dialog box widgets --- src/morphic.js | 10 +++++++--- src/widgets.js | 12 ++++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/morphic.js b/src/morphic.js index 3e8518df..f9553515 100644 --- a/src/morphic.js +++ b/src/morphic.js @@ -68,6 +68,7 @@ * keyboard navigation can be activated for any visible menu by pressing an arbitrary key + * new "noDropShadow" property for Morphs that already have built-in shadows (Menus, SpeechBubbles) documentation contents ---------------------- @@ -1176,7 +1177,7 @@ /*global window, HTMLCanvasElement, FileReader, Audio, FileList, Map*/ -var morphicVersion = '2020-February-18'; +var morphicVersion = '2020-February-20'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -3060,6 +3061,7 @@ Morph.prototype.init = function () { this.isTemplate = false; this.acceptsDrops = false; this.isFreeForm = false; + this.noDropShadow = false; this.fps = 0; this.customContextMenu = null; this.lastTime = Date.now(); @@ -5974,6 +5976,7 @@ SpeechBubbleMorph.prototype.init = function ( border || ((border === 0) ? 0 : 1), borderColor || new Color(140, 140, 140) ); + this.noDropShadow = true; this.color = color || new Color(230, 230, 230); this.fixLayout(); }; @@ -7820,6 +7823,7 @@ MenuMorph.prototype.init = function (target, title, environment, fontSize) { // override inherited properties: this.isDraggable = false; + this.noDropShadow = true; // immutable properties: this.border = null; @@ -11039,7 +11043,7 @@ HandMorph.prototype.grab = function (aMorph) { if (this.children.length === 0) { this.world.stopEditing(); this.grabOrigin = aMorph.situation(); - if (!(aMorph instanceof MenuMorph)) { + if (!aMorph.noDropShadow) { aMorph.addShadow(); } if (aMorph.prepareToBeGrabbed) { @@ -11062,7 +11066,7 @@ HandMorph.prototype.drop = function () { this.changed(); target.add(morphToDrop); morphToDrop.changed(); - if (!(morphToDrop instanceof MenuMorph)) { + if (!morphToDrop.noDropShadow) { morphToDrop.removeShadow(); } this.children = []; diff --git a/src/widgets.js b/src/widgets.js index 840186bf..fac3d158 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -1521,6 +1521,7 @@ DialogBoxMorph.prototype.init = function (target, action, environment) { // override inherited properites: this.isDraggable = true; + this.noDropShadow = true; this.color = PushButtonMorph.prototype.color; this.createLabel(); this.createButtons(); @@ -2465,8 +2466,8 @@ DialogBoxMorph.prototype.addBody = function (aMorph) { // DialogBoxMorph layout -DialogBoxMorph.prototype.addShadow = function () {nop(); }; -DialogBoxMorph.prototype.removeShadow = function () {nop(); }; +// +++ DialogBoxMorph.prototype.addShadow = function () {nop(); }; +// +++ DialogBoxMorph.prototype.removeShadow = function () {nop(); }; DialogBoxMorph.prototype.fixLayout = function () { // determine by extent and arrange my components @@ -2544,6 +2545,11 @@ DialogBoxMorph.prototype.fixLayout = function () { this.buttons.setCenter(this.center()); this.buttons.setBottom(this.bottom() - this.padding); } + + // refresh a shallow shadow + this.removeShadow(); + this.addShadow(new Point(2, 2), 80); + }; // DialogBoxMorph shadow @@ -2553,6 +2559,7 @@ DialogBoxMorph.prototype.fixLayout = function () { conflicted by the scrolling scripts pane */ +/* DialogBoxMorph.prototype.shadowImage = function (off, color) { // flat mode var fb, img, outline, sha, ctx, @@ -2607,6 +2614,7 @@ DialogBoxMorph.prototype.shadowImageBlurred = function (off, color) { ); return sha; }; +*/ // DialogBoxMorph keyboard events