diff --git a/HISTORY.md b/HISTORY.md index a7c6d78f..a9560b47 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,7 @@ ## in development: * **New Features:** + * added selectors for sprites' bounding box (left, right, top, bottom) to MY dropdown * **Notable Changes:** * running STOP ALL now also toggles (pauses and resumes) all generic WHEN hat blocks (just like pressing the stop button) * **Notable Fixes:** @@ -9,6 +10,9 @@ * assert that dimensions given for STRETCH are finite numbers (avoid crash) * **Translation Updates:** +### 2019-10-17 +* objects, blocks, threads: added selectors for sprites' bounding box (left, right, top, bottom) to MY dropdown + ### 2019-10-16 * new dev version * morphic: added "enableLinks" flag to text elements, off by default diff --git a/snap.html b/snap.html index 5e91fd7c..0142633e 100755 --- a/snap.html +++ b/snap.html @@ -6,9 +6,9 @@ - - - + + + diff --git a/src/blocks.js b/src/blocks.js index 5b09fab3..70585c95 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -148,7 +148,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2019-August-07'; +modules.blocks = '2019-October-17'; var SyntaxElementMorph; var BlockMorph; @@ -8975,6 +8975,10 @@ InputSlotMorph.prototype.gettablesMenu = function () { dict['draggable?'] = ['draggable?']; dict.width = ['width']; dict.height = ['height']; + dict.left = ['left']; + dict.right = ['right']; + dict.top = ['top']; + dict.bottom = ['bottom']; dict['rotation style'] = ['rotation style']; dict['rotation x'] = ['rotation x']; dict['rotation y'] = ['rotation y']; diff --git a/src/objects.js b/src/objects.js index f4a6591a..df872d79 100644 --- a/src/objects.js +++ b/src/objects.js @@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph, localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph, HandleMorph, AlignmentMorph, Process, XML_Element, WorldMap*/ -modules.objects = '2019-October-14'; +modules.objects = '2019-October-17'; var SpriteMorph; var StageMorph; @@ -5575,6 +5575,8 @@ SpriteMorph.prototype.setPivot = function (worldCoordinate) { } }; +// SpriteMorph dimension getters + SpriteMorph.prototype.xCenter = function () { var stage = this.parentThatIsA(StageMorph); @@ -5599,6 +5601,54 @@ SpriteMorph.prototype.yCenter = function () { return this.center().y; }; +SpriteMorph.prototype.xLeft = function () { + var stage = this.parentThatIsA(StageMorph); + + if (!stage && this.parent.grabOrigin) { // I'm currently being dragged + stage = this.parent.grabOrigin.origin; + } + if (stage) { + return (this.left() - stage.center().x) / stage.scale; + } + return this.left(); +}; + +SpriteMorph.prototype.xRight = function () { + var stage = this.parentThatIsA(StageMorph); + + if (!stage && this.parent.grabOrigin) { // I'm currently being dragged + stage = this.parent.grabOrigin.origin; + } + if (stage) { + return (this.right() - stage.center().x) / stage.scale; + } + return this.right(); +}; + +SpriteMorph.prototype.yTop = function () { + var stage = this.parentThatIsA(StageMorph); + + if (!stage && this.parent.grabOrigin) { // I'm currently being dragged + stage = this.parent.grabOrigin.origin; + } + if (stage) { + return (stage.center().y - this.top()) / stage.scale; + } + return this.top(); +}; + +SpriteMorph.prototype.yBottom = function () { + var stage = this.parentThatIsA(StageMorph); + + if (!stage && this.parent.grabOrigin) { // I'm currently being dragged + stage = this.parent.grabOrigin.origin; + } + if (stage) { + return (stage.center().y - this.bottom()) / stage.scale; + } + return this.bottom(); +}; + // SpriteMorph message broadcasting SpriteMorph.prototype.allMessageNames = function () { diff --git a/src/threads.js b/src/threads.js index 48cf4bc0..d9763051 100644 --- a/src/threads.js +++ b/src/threads.js @@ -61,7 +61,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy, isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph, Color, TableFrameMorph, ColorSlotMorph, isSnapObject, Map, newCanvas, Symbol*/ -modules.threads = '2019-October-16'; +modules.threads = '2019-October-17'; var ThreadManager; var Process; @@ -4347,6 +4347,14 @@ Process.prototype.reportGet = function (query) { return thisObj.xCenter(); case 'center y': return thisObj.yCenter(); + case 'left': + return thisObj.xLeft(); + case 'right': + return thisObj.xRight(); + case 'top': + return thisObj.yTop(); + case 'bottom': + return thisObj.yBottom(); case 'name': return thisObj.name; case 'stage':