From f308c23824fcb48e25d2296ddc44a3ab4bcbef64 Mon Sep 17 00:00:00 2001 From: tonychenr Date: Tue, 7 Oct 2014 19:15:08 -0700 Subject: Fixed range 1 slider bug issue # 301 --- morphic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'morphic.js') diff --git a/morphic.js b/morphic.js index 4e18482..b19d390 100644 --- a/morphic.js +++ b/morphic.js @@ -5754,7 +5754,7 @@ SliderMorph.prototype.rangeSize = function () { }; SliderMorph.prototype.ratio = function () { - return this.size / this.rangeSize(); + return this.size / (this.rangeSize() + 1); }; SliderMorph.prototype.unitSize = function () { -- cgit v1.3.1 From 7b96be6c40fac46bb53752531f24878425eb9330 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 6 Nov 2014 17:03:51 +0100 Subject: enable mouseMove events with right button pressed to support user interactions in 3D environments, such as CAD systems or Beetleblocks --- morphic.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'morphic.js') diff --git a/morphic.js b/morphic.js index 4e18482..0115c82 100644 --- a/morphic.js +++ b/morphic.js @@ -464,9 +464,15 @@ MyMorph.prototype.mouseMove = function(pos) {}; - The only optional parameter of such a method is a Point object + All of these methods have as optional parameter a Point object indicating the current position of the Hand inside the World's - coordinate system. + coordinate system. The + + mouseMove(pos, button) + + event method has an additional optional parameter indicating the + currently pressed mouse button, which is either 'left' or 'right'. + You can use this to let users interact with 3D environments. Events may be "bubbled" up a morph's owner chain by calling @@ -1035,7 +1041,7 @@ /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, FileList, getBlurredShadowSupport*/ -var morphicVersion = '2014-September-30'; +var morphicVersion = '2014-November-06'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -9346,11 +9352,11 @@ HandMorph.prototype.init = function (aWorld) { this.world = aWorld; this.mouseButton = null; this.mouseOverList = []; - this.mouseDownMorph = null; this.morphToGrab = null; this.grabOrigin = null; this.temporaries = []; this.touchHoldTimeout = null; + this.contextMenuEnabled = false; }; HandMorph.prototype.changed = function () { @@ -9494,9 +9500,10 @@ HandMorph.prototype.drop = function () { */ HandMorph.prototype.processMouseDown = function (event) { - var morph, expectedClick, actualClick; + var morph, actualClick; this.destroyTemporaries(); + this.contextMenuEnabled = true; this.morphToGrab = null; if (this.children.length !== 0) { this.drop(); @@ -9529,15 +9536,9 @@ HandMorph.prototype.processMouseDown = function (event) { if (event.button === 2 || event.ctrlKey) { this.mouseButton = 'right'; actualClick = 'mouseDownRight'; - expectedClick = 'mouseClickRight'; } else { this.mouseButton = 'left'; actualClick = 'mouseDownLeft'; - expectedClick = 'mouseClickLeft'; - } - this.mouseDownMorph = morph; - while (!this.mouseDownMorph[expectedClick]) { - this.mouseDownMorph = this.mouseDownMorph.parent; } while (!morph[actualClick]) { morph = morph.parent; @@ -9596,7 +9597,7 @@ HandMorph.prototype.processMouseUp = function () { expectedClick = 'mouseClickLeft'; } else { expectedClick = 'mouseClickRight'; - if (this.mouseButton) { + if (this.mouseButton && this.contextMenuEnabled) { context = morph; contextMenu = context.contextMenu(); while ((!contextMenu) && @@ -9654,16 +9655,18 @@ HandMorph.prototype.processMouseMove = function (event) { // mouseOverNew = this.allMorphsAtPointer(); mouseOverNew = this.morphAtPointer().allParents(); - if ((this.children.length === 0) && - (this.mouseButton === 'left')) { + if (!this.children.length && this.mouseButton) { topMorph = this.morphAtPointer(); morph = topMorph.rootForGrab(); if (topMorph.mouseMove) { - topMorph.mouseMove(pos); + topMorph.mouseMove(pos, this.mouseButton); + if (this.mouseButton === 'right') { + this.contextMenuEnabled = false; + } } // if a morph is marked for grabbing, just grab it - if (this.morphToGrab) { + if (this.mouseButton === 'left' && this.morphToGrab) { if (this.morphToGrab.isDraggable) { morph = this.morphToGrab; this.grab(morph); -- cgit v1.3.1 From 3cc28b1f1ce44f053399686e58be860f9c4a7018 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 20 Nov 2014 15:40:20 +0100 Subject: push morphic.js version date --- history.txt | 1 + morphic.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'morphic.js') diff --git a/history.txt b/history.txt index c44a57b..110ea89 100755 --- a/history.txt +++ b/history.txt @@ -2331,3 +2331,4 @@ ______ * GUI: Updated the “About” Dialog with a mention of support from CDG (SAP Labs) * BYOB: Percent sign fix for block labels, thanks, @natashasandy! * Threads: fix ‘line’ option in ‘split’ block for Windows files, thanks, @brianharvey! +* Morphic: fix slider range 1, thanks, @tonychenr ! diff --git a/morphic.js b/morphic.js index b9d834f..763a196 100644 --- a/morphic.js +++ b/morphic.js @@ -1041,7 +1041,7 @@ /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, FileList, getBlurredShadowSupport*/ -var morphicVersion = '2014-November-06'; +var morphicVersion = '2014-November-20'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug -- cgit v1.3.1 From d94d9ff4e85b50ce57e4c62d63250994c4b9b4c7 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 3 Dec 2014 12:42:46 +0100 Subject: Cache actual bounding box of the Pen arrow shape for improved collision detection --- morphic.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'morphic.js') diff --git a/morphic.js b/morphic.js index 763a196..a001c6f 100644 --- a/morphic.js +++ b/morphic.js @@ -1041,7 +1041,7 @@ /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, FileList, getBlurredShadowSupport*/ -var morphicVersion = '2014-November-20'; +var morphicVersion = '2014-December-03'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -3978,6 +3978,7 @@ PenMorph.prototype.init = function () { this.size = 1; this.wantsRedraw = false; this.penPoint = 'tip'; // or 'center" + this.penBounds = null; // rect around the visible arrow shape HandleMorph.uber.init.call(this); this.setExtent(new Point(size, size)); @@ -4000,11 +4001,9 @@ PenMorph.prototype.changed = function () { // PenMorph display: PenMorph.prototype.drawNew = function (facing) { -/* - my orientation can be overridden with the "facing" parameter to - implement Scratch-style rotation styles + // my orientation can be overridden with the "facing" parameter to + // implement Scratch-style rotation styles -*/ var context, start, dest, left, right, len, direction = facing || this.heading; @@ -4027,6 +4026,15 @@ PenMorph.prototype.drawNew = function (facing) { right = start.distanceAngle(len * 0.33, direction - 230); } + // cache penBounds + this.penBounds = new Rectangle( + Math.min(start.x, dest.x, left.x, right.x), + Math.min(start.y, dest.y, left.y, right.y), + Math.max(start.x, dest.x, left.x, right.x), + Math.max(start.y, dest.y, left.y, right.y) + ); + + // draw arrow shape context.fillStyle = this.color.toString(); context.beginPath(); @@ -4043,7 +4051,6 @@ PenMorph.prototype.drawNew = function (facing) { context.lineWidth = 1; context.stroke(); context.fill(); - }; // PenMorph access: -- cgit v1.3.1 From 6608d1098ffe6d6b5f23ba85ea842754724ec277 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 5 Dec 2014 12:53:02 +0100 Subject: Avoid auto-scaling artefacts in Safari on retina displays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (resulting in “traces” when dragging items) --- history.txt | 4 ++++ morphic.js | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'morphic.js') diff --git a/history.txt b/history.txt index 5be35f0..f1baa92 100755 --- a/history.txt +++ b/history.txt @@ -2382,3 +2382,7 @@ ______ ------ * Threads, Objects: Experimental “ForEach” primitive (hidden in dev mode) * GUI: Another attempt at pointing the project dialog to the cloud if signed in + +141205 +------ +* Morphic: Avoid auto-scaling artefacts in Safari on retina displays (resulting in “traces” when dragging items) diff --git a/morphic.js b/morphic.js index a001c6f..9616897 100644 --- a/morphic.js +++ b/morphic.js @@ -1041,7 +1041,7 @@ /*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio, FileList, getBlurredShadowSupport*/ -var morphicVersion = '2014-December-03'; +var morphicVersion = '2014-December-05'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -1931,7 +1931,9 @@ Rectangle.prototype.round = function () { Rectangle.prototype.spread = function () { // round me by applying floor() to my origin and ceil() to my corner - return this.origin.floor().corner(this.corner.ceil()); + // expand by 1 to be on the safe side, this eliminates rounding + // artefacts caused by Safari's auto-scaling on retina displays + return this.origin.floor().corner(this.corner.ceil()).expandBy(1); }; Rectangle.prototype.amountToTranslateWithin = function (aRect) { -- cgit v1.3.1