refactored mouseX / mouseY to use generic coordinate conversion

pull/95/head
jmoenig 2020-12-02 14:55:24 +01:00
rodzic 782d27f155
commit bc57936238
4 zmienionych plików z 16 dodań i 18 usunięć

Wyświetl plik

@ -22,6 +22,7 @@
* threads, blocks: added SIGN function to monadic dropdown
* Catalan translation update, thanks, Joan!
* Morphic: prevent browser override for ctrl+o gesture
* objects, threads: refactored mouseX / mouseY to use generic coordinate conversion
### 2020-12-01
* threads, objects: added hyperdyadic MIN and MAX primitives reachable via "relabel"

Wyświetl plik

@ -10,7 +10,7 @@
<script src="src/widgets.js?version=2020-10-06"></script>
<script src="src/blocks.js?version=2020-12-02"></script>
<script src="src/threads.js?version=2020-12-02"></script>
<script src="src/objects.js?version=2020-12-01"></script>
<script src="src/objects.js?version=2020-12-02"></script>
<script src="src/gui.js?version=2020-12-01"></script>
<script src="src/paint.js?version=2020-05-17"></script>
<script src="src/lists.js?version=2020-12-01"></script>

Wyświetl plik

@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph,
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
AlignmentMorph, Process, WorldMap, copyCanvas, useBlurredShadows*/
modules.objects = '2020-December-01';
modules.objects = '2020-December-02';
var SpriteMorph;
var StageMorph;
@ -9303,6 +9303,11 @@ StageMorph.prototype.getLastAnswer
StageMorph.prototype.reportThreadCount
= SpriteMorph.prototype.reportThreadCount;
// StageMorph coordinate conversion
StageMorph.prototype.snapPoint
= SpriteMorph.prototype.snapPoint;
// StageMorph dimension getters
StageMorph.prototype.xCenter = function () {

Wyświetl plik

@ -5193,30 +5193,22 @@ Process.prototype.reportContextFor = function (context, otherObj) {
};
Process.prototype.reportMouseX = function () {
var stage, world;
var world;
if (this.homeContext.receiver) {
stage = this.homeContext.receiver.parentThatIsA(StageMorph);
if (stage) {
world = stage.world();
if (world) {
return (world.hand.position().x - stage.center().x)
/ stage.scale;
}
world = this.homeContext.receiver.world();
if (world) {
return this.homeContext.receiver.snapPoint(world.hand.position()).x;
}
}
return 0;
};
Process.prototype.reportMouseY = function () {
var stage, world;
var world;
if (this.homeContext.receiver) {
stage = this.homeContext.receiver.parentThatIsA(StageMorph);
if (stage) {
world = stage.world();
if (world) {
return (stage.center().y - world.hand.position().y)
/ stage.scale;
}
world = this.homeContext.receiver.world();
if (world) {
return this.homeContext.receiver.snapPoint(world.hand.position()).y;
}
}
return 0;