drag ways (still needs undo though)
authorRichard Fairhurst <richard@systemed.net>
Sun, 2 May 2010 08:20:06 +0000 (08:20 +0000)
committerRichard Fairhurst <richard@systemed.net>
Sun, 2 May 2010 08:20:06 +0000 (08:20 +0000)
TODO.txt
net/systemeD/halcyon/EntityUI.as
net/systemeD/halcyon/WayUI.as
net/systemeD/halcyon/connection/Connection.as
net/systemeD/halcyon/connection/WayDraggedEvent.as [new file with mode: 0644]
net/systemeD/potlatch2/controller/NoSelection.as
net/systemeD/potlatch2/controller/SelectedWay.as

index 98bcdf62497dd90ede31f08ec6e4d47daa6e7182..4c66d0d4e72d384ca675924de6659b46dad07270 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -9,15 +9,15 @@ Potlatch 2: main outstanding issues
 
 == Core geometry ==
 
-* Undo/redo: split, draw
-* Drag ways
+* Undo/redo: split, drag
+* Remove node from this way only
+* Backspace
 
 
 == Vector background layers ==
 
-* Remove existing interaction and add alt-click
 * TagTransform (cf http://wiki.openstreetmap.org/wiki/Osmosis/TagTransform)
-* Import from GPX
+* Simplify (e.g. GPX files)
 * Import from OSM (is this worth sharing with the XML API stuff?)
 
 
index 5ec4b538aea0578e8b16f862e7c35399edba022f..c50a0ad50ae146779cd9c4eca5a6227cdbe8de09 100644 (file)
@@ -68,6 +68,12 @@ package net.systemeD.halcyon {
                        listenSprite.hitArea=null;
                }
 
+               protected function offsetSprites(x:Number, y:Number):void {
+                       for each (var d:DisplayObject in sprites) {
+                               d.x=x; d.y=y;
+                       }
+               }
+
                protected function setListenSprite(hitzone:Sprite):void {
                        if (!listenSprite.parent) { addToLayer(listenSprite, CLICKSPRITE); }
             listenSprite.hitArea = hitzone;
index 94a52df231869e237c546415d6f0d16d24e18b22..e8bcb5afcafdc7d879303020271b56c64dcf0acd 100755 (executable)
@@ -36,6 +36,7 @@ package net.systemeD.halcyon {
             way.addEventListener(Connection.WAY_NODE_REMOVED, wayNodeRemoved);
             way.addEventListener(Connection.WAY_REORDERED, wayReordered);
                        way.addEventListener(Connection.WAY_DELETED, wayDeleted);
+            way.addEventListener(Connection.WAY_DRAGGED, wayDragged);
                        way.addEventListener(Connection.ADDED_TO_RELATION, wayRelationAdded);
                        way.addEventListener(Connection.REMOVED_FROM_RELATION, wayRelationRemoved);
                        way.addEventListener(Connection.SUSPEND_REDRAW, suspendRedraw);
@@ -92,10 +93,12 @@ package net.systemeD.halcyon {
                private function wayDeleted(event:EntityEvent):void {
                        redraw();
                }
-        
         private function wayReordered(event:EntityEvent):void {
             redraw();
         }
+               private function wayDragged(event:WayDraggedEvent):void {
+                       offsetSprites(event.xDelta,event.yDelta);
+               }
 
                private function init():void {
                        recalculate();
index c7d327ff319d69d1e269577d501e2d7f6b32f0a1..c7b9ab57842b2870c5a6ae11e4b55c657bf9fe89 100755 (executable)
@@ -69,6 +69,7 @@ package net.systemeD.halcyon.connection {
         public static var WAY_NODE_ADDED:String = "way_node_added";
         public static var WAY_NODE_REMOVED:String = "way_node_removed";
         public static var WAY_REORDERED:String = "way_reordered";
+        public static var WAY_DRAGGED:String = "way_dragged";
                public static var NODE_DELETED:String = "node_deleted";
                public static var WAY_DELETED:String = "way_deleted";
                public static var RELATION_DELETED:String = "relation_deleted";
diff --git a/net/systemeD/halcyon/connection/WayDraggedEvent.as b/net/systemeD/halcyon/connection/WayDraggedEvent.as
new file mode 100644 (file)
index 0000000..1eb2a1b
--- /dev/null
@@ -0,0 +1,27 @@
+package net.systemeD.halcyon.connection {
+
+    import flash.events.Event;
+
+    public class WayDraggedEvent extends EntityEvent {
+        private var _way:Way;
+               private var _xDelta:Number;
+               private var _yDelta:Number;
+
+        public function WayDraggedEvent(type:String, way:Way, xDelta:Number, yDelta:Number) {
+            super(type, way);
+            this._way = way;
+            this._xDelta = xDelta;
+            this._yDelta = yDelta;
+        }
+
+        public function get way():Way { return _way; }
+        public function get xDelta():Number { return _xDelta; }
+        public function get yDelta():Number { return _yDelta; }
+
+        public override function toString():String {
+            return super.toString() + " in "+_way+" by "+_xDelta+","+_yDelta;
+        }
+    }
+
+}
+
index 69149aedb29073540f0f5290b96a78fe73026081..e4300f27811003edd7f10990302c7791531640cb 100644 (file)
@@ -21,7 +21,7 @@ package net.systemeD.potlatch2.controller {
                                if ( entity is Way && event.altKey && paint.isBackground ) {
                                        return new SelectedWay(paint.findSource().pullThrough(entity,controller.connection));
                                } else if ( entity is Way ) {
-                                       return new SelectedWay(focus as Way);
+                                       return new DragWay(focus as Way,event);
                 } else if ( focus is Node ) {
                                        return new DragPOINode(entity as Node,event,false);
                 } else if ( entity is Node && focus is Way ) {
index 651d666ef7e6784310b3d664a555ef9c6d23ffe3..3e4ff8e7d9a9921239b7adaa31ea47ff56c56c2d 100644 (file)
@@ -48,9 +48,6 @@ package net.systemeD.potlatch2.controller {
                                } else if ( entity is Way && event.ctrlKey ) {
                                        // merge way
                                        mergeWith(entity as Way);
-                               } else if ( entity is Way ) {
-                                       // select way
-                    selectWay(entity as Way);
                 } else if ( focus == null && map.dragstate!=map.DRAGGING ) {
                     return new NoSelection();
                                }
@@ -65,6 +62,8 @@ package net.systemeD.potlatch2.controller {
                     var d:DragWayNode=new DragWayNode(selectedWay, addNode(event), event, true);
                                        d.forceDragStart();
                                        return d;
+                               } else if ( entity is Way ) {
+                                       return new DragWay(focus as Way, event);
                                } else if ( entity is Node && entity.hasParent(selectedWay) ) {
                                        // select node within this way
                     return new DragWayNode(selectedWay, Node(entity), event, false);