diff --git a/docs/todo.txt b/docs/todo.txt index acf2a66e4..36e56b1ac 100755 --- a/docs/todo.txt +++ b/docs/todo.txt @@ -1,10 +1,9 @@ DrawWay to do: -* make junctions +* start from a POI node ("convert into way?") * still allow dragging the map Drag and drop to do: -* icon grid -* improve 'avatar' +* presentation * cope with dragging onto anything, not just blank areas of the map Next to do: @@ -34,9 +33,6 @@ Events - the Controller gets the message and invokes a redraw - no need for anything else to listen -General code -* Do the ***doSetLatLon*** and ***_setLatLon*** naming convention - ------------------------------------------------ Modes: diff --git a/js/iD/actions/AddNodeToWayAction.js b/js/iD/actions/AddNodeToWayAction.js index bba42de19..0be001040 100644 --- a/js/iD/actions/AddNodeToWayAction.js +++ b/js/iD/actions/AddNodeToWayAction.js @@ -34,9 +34,10 @@ declare("iD.actions.AddNodeToWayAction", [iD.actions.UndoableEntityAction], { // add the node if (this.index==-1) this.index=this.nodeList.length; this.node.addParent(way); + this.node.connection.unregisterPOI(this.node); this.nodeList.splice(this.index, 0, this.node); this.markDirty(); -// way.expandBbox(this.node); + way.expandBbox(this.node); way.refresh(); return this.SUCCESS; diff --git a/js/iD/controller/shape/SelectedWay.js b/js/iD/controller/shape/SelectedWay.js index 13190d49e..c0b4504c5 100644 --- a/js/iD/controller/shape/SelectedWay.js +++ b/js/iD/controller/shape/SelectedWay.js @@ -7,23 +7,83 @@ */ -define(['dojo/_base/declare', +define(['dojo/_base/declare','dojo/_base/lang', 'iD/actions/UndoableAction', 'iD/controller/ControllerState', - ], function(declare){ + ], function(declare,lang){ // ---------------------------------------------------------------------- // SelectedWayNode class declare("iD.controller.shape.SelectedWay", [iD.controller.ControllerState], { - constructor:function() { + way: null, + wayUI: null, + + constructor:function(_way) { + this.way=_way; + }, + enterState:function() { + this.wayUI=this.controller.map.getUI(this.way); + this.wayUI.setStateClass('selected'); + this.wayUI.setStateClass('shownodes'); + this.wayUI.redraw(); + this.controller.stepper.setSteps({ + begin: "Click anywhere on the map to start drawing there", + startpoint: "Click the point on the way where you want to start your new way", + draw: "Keep clicking to add each point, and press Enter or double-click when you're done", + tag: "Set the type of the road or shape" + },['begin','startpoint','draw','tag']).highlight('startpoint'); + }, + exitState:function() { + this.wayUI.resetStateClass('selected'); + this.wayUI.resetStateClass('shownodes'); + this.wayUI.redraw(); }, processMouseEvent:function(event,entityUI) { var entity=entityUI ? entityUI.entity : null; var entityType=entity ? entity.entityType : null; + if (event.type=='click') { + switch (entityType) { + case null: + return new iD.controller.shape.NoSelection(); + case 'node': + var ways=entity.parentWays(); + if (entity.hasParent(this.way)) { + // start a branching way from an existing point + var way = this.getConnection().createWay({}, [entity], lang.hitch(this,this.undoAdder) ); + this.controller.map.createUI(way); + return new iD.controller.shape.DrawWay(way); + } else if (ways.length==0) { + // convert POI into way + return this; + } else { + // select another way + return new iD.controller.shape.SelectedWay(entity.getParents()[0]); + } + case 'way': + if (entity==this.way) { + // start a branching way from a new point + var map = this.controller.map; + var undo = new iD.actions.CompositeUndoableAction(); + var startNode = this.getConnection().createNode( + {}, + map.coord2lat(map.mouseY(event)), + map.coord2lon(map.mouseX(event)), lang.hitch(undo,undo.push) ); + entity.doInsertNodeAtClosestPosition(startNode, true, lang.hitch(undo,undo.push)); + var way = this.getConnection().createWay({}, [startNode], lang.hitch(undo,undo.push) ); + this.controller.undoStack.addAction(undo); + this.controller.map.createUI(way); + return new iD.controller.shape.DrawWay(way); + } else { + // select another way + return new iD.controller.shape.SelectedWay(entity); + } + } + } else { + } return this; },