diff options
Diffstat (limited to 'altoslib/AltosMap.java')
-rw-r--r-- | altoslib/AltosMap.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java index adf52ab9..8d12a180 100644 --- a/altoslib/AltosMap.java +++ b/altoslib/AltosMap.java @@ -391,6 +391,10 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { AltosPointInt drag_start; + boolean dragged; + + static final double drag_far = 20; + private void drag(int x, int y) { if (drag_start == null) return; @@ -398,6 +402,11 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { int dx = x - drag_start.x; int dy = y - drag_start.y; + double distance = Math.hypot(dx, dy); + + if (distance > drag_far) + dragged = true; + if (transform == null) { debug("Transform not set in drag\n"); return; @@ -410,6 +419,12 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { private void drag_start(int x, int y) { drag_start = new AltosPointInt(x, y); + dragged = false; + } + + private void drag_stop(int x, int y) { + if (!dragged) + map_interface.select_object (transform.screen_lat_lon(new AltosPointInt(x,y))); } private void line_start(int x, int y) { @@ -442,6 +457,12 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { line(x, y); } + public void touch_stop(int x, int y, boolean is_drag) { + notice_user_input(); + if (is_drag) + drag_stop(x, y); + } + public AltosMap(AltosMapInterface map_interface) { this.map_interface = map_interface; cache = new AltosMapCache(map_interface); |