double-click to create new POIs
authorRichard Fairhurst <richard@systemed.net>
Mon, 30 Nov 2009 09:02:31 +0000 (09:02 +0000)
committerRichard Fairhurst <richard@systemed.net>
Mon, 30 Nov 2009 09:02:31 +0000 (09:02 +0000)
TODO.txt
net/systemeD/halcyon/WayUI.as
net/systemeD/halcyon/connection/Way.as
net/systemeD/potlatch2/controller/DrawWay.as
resources/potlatch.css

index 7f3c0ca..2c31e1e 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -12,7 +12,7 @@ Potlatch 2: main outstanding issues
 
 * Delete points and ways
 * Split and merge ways
-* POI drawing (drag and drop/double-click)
+* Drag-and-drop POIs
 * Undo/redo
 * Reverse way direction
 
index 9cbfa6a..ced3c61 100755 (executable)
@@ -114,6 +114,7 @@ package net.systemeD.halcyon {
 
                override public function redraw(sl:StyleList=null):Boolean {
                        removeSprites();
+                       if (way.length==0) { return false; }
 
             // Copy tags object, and add states
             var tags:Object = way.getTagsCopy();
index 9604dae..735284c 100644 (file)
@@ -17,7 +17,7 @@ package net.systemeD.halcyon.connection {
                        updateEntityProperties(version,tags,loaded); this.nodes=nodes;
                        for each (node in nodes) { node.addParent(this); }
                }
-
+               
         public function get length():uint {
             return nodes.length;
         }
@@ -52,6 +52,20 @@ package net.systemeD.halcyon.connection {
             dispatchEvent(new WayNodeEvent(Connection.WAY_NODE_REMOVED, removed[0], this, index));
         }
 
+               public function removeAllNodes():void {
+                       var node:Node;
+                       while (nodes.length) { 
+                               node=nodes.pop();
+                               dispatchEvent(new WayNodeEvent(Connection.WAY_NODE_REMOVED, node, this, 0));
+                               // ** the event mechanism calls redraw once per wayNodeRemoved, which isn't too efficient
+                               //    so we should probably add a 'redraw' flag to WayNodeEvent
+                               node.removeParent(this);
+                       }
+                       // ** we should send an event to delete the entire way
+               }
+
+
+
         /**
          * Finds the 1st way segment which intersects the projected
          * coordinate and adds the node to that segment. If snap is
index de89fdc..67f0be9 100644 (file)
@@ -17,6 +17,11 @@ package net.systemeD.potlatch2.controller {
                        super(way);
                        this.editEnd = editEnd;
                        this.leaveNodeSelected = leaveNodeSelected;
+                       if (way.length==1 && way.getNode(0).parentWays.length==1) {
+                               // drawing new way, so keep track of click in case creating a POI
+                               lastClick=way.getNode(0);
+                               lastClickTime=new Date();
+                       }
                }
                
                override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
@@ -31,7 +36,16 @@ package net.systemeD.potlatch2.controller {
                                        lastClick=node;
                                } else if ( entity is Node ) {
                                        if (entity==lastClick && (new Date().getTime()-lastClickTime.getTime())<1000) {
-                                               return stopDrawing();
+                                               if (selectedWay.length==1 && selectedWay.getNode(0).parentWays.length==1) {
+                                                       // double-click to create new POI
+                                                       node=selectedWay.getNode(0);
+                                                       stopDrawing();
+                                                       controller.connection.registerPOI(node);
+                                                       return new SelectedPOINode(node);
+                                               } else {
+                                                       // double-click at end of way
+                                                       return stopDrawing();
+                                               }
                                        } else {
                                                appendNode(entity as Node);
                                                controller.map.setHighlight(focus, { showNodesHover: false });
@@ -83,6 +97,7 @@ package net.systemeD.potlatch2.controller {
                        if ( selectedWay.length<2) {
                                // ** probably needs to call a proper 'delete way' method
                                controller.map.setHighlight(selectedWay, { showNodes: false });
+                               selectedWay.removeAllNodes();
                                delete controller.map.ways[selectedWay.id];
                                return new NoSelection();
                        } else if ( leaveNodeSelected ) {
index fccb9ae..0d86ce1 100644 (file)
@@ -63,8 +63,8 @@ way[public_transport=pay_scale_area] :area  { color: gray;    width: 1; fill-col
 /* POIs, too, can have bitmap icons - they can even be transparent */
 
 node[amenity=pub] { icon-image: icons/pub.png; text-offset: 7; font-family: DejaVu; text: name; font-size: 9; }
-node[place] { icon-image: icons/place.png; text-offset: 10; font-family: DejaVu; text: name; font-size: 9; font-weight: bold; text-decoration: underline; }
-node[railway=station] { icon-image: icons/station.png; text-offset: 10; font-family: DejaVu; text: name; font-size: 9; font-weight: bold; }
+node[place] { icon-image: icons/place.png; text-offset: 17; font-family: DejaVu; text: name; font-size: 9; font-weight: bold; text-decoration: underline; }
+node[railway=station] { icon-image: icons/station.png; text-offset: 13; font-family: DejaVu; text: name; font-size: 9; font-weight: bold; }
 way node[barrier=gate], way node[highway=gate] { icon-image: icons/gate.png; }
        
 /* We can stack styles at different z-index (depth) */
@@ -86,8 +86,8 @@ way !:drawn { z-index:10; width: 0.5; color: gray; }
 
 node :selectedway { z-index: 9; icon-image: square; icon-width: 7; color: red; }
 node :hoverway { z-index: 9; icon-image: square; icon-width: 7; color: blue; }
-node !:drawn :poi { z-index: 2; icon-image: circle; icon-width: 4; color: green; casing-color: black; }
-node :selected { z-index: 1; icon-image: square; icon-width: 12; color: yellow; }
+node !:drawn :poi { z-index: 2; icon-image: circle; icon-width: 4; color: green; casing-color: black; casing-width: 1; }
+node :selected { z-index: 1; icon-image: square; icon-width: 15; color: yellow; }
 
 /* Descendant selectors provide an easy way to style relations: this example means "any way
    which is part of a relation whose type=route". */