Start work on tuning noselection for intents

Reversing the order of decisions for those adding nodes.
This commit is contained in:
Tom MacWright
2012-10-18 13:01:29 -04:00
parent e3f7e68eed
commit 3e7df5acae
4 changed files with 43 additions and 42 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ text {
}
#map.state-drawing {
cursor: pointer;
cursor: crosshair;
}
.currentMode {
+32 -31
View File
@@ -26,8 +26,9 @@ define(['dojo/_base/declare','dojo/_base/lang',
declare("iD.controller.shape.NoSelection", [iD.controller.ControllerState], {
constructor:function() {
constructor: function(intent) {
// summary: In 'Draw shape' mode but nothing is selected.
this.intent = intent;
},
exitState: function() {
@@ -39,38 +40,38 @@ declare("iD.controller.shape.NoSelection", [iD.controller.ControllerState], {
this.controller.stepper.show().step(0);
},
processMouseEvent:function(event, entityUI) {
var entity = entityUI ? entityUI.entity : null;
var entityType = entity ? entity.entityType : null;
var map = this.controller.map;
processMouseEvent:function(event, entityUI) {
var entity = entityUI ? entityUI.entity : null;
var entityType = entity ? entity.entityType : null;
var map = this.controller.map;
if (event.type === 'click') {
switch (entityType) {
case 'node':
// Click to select a node
var ways = entity.parentWays();
if (!ways.length) { return new iD.controller.shape.SelectedPOINode(entity); }
// else { return new iD.controller.shape.SelectedWayNode(entity,ways[0]); }
// ** FIXME: ^^^ the above should start a new branching way, not select the node
return this;
case 'way':
if (event.type === 'click') {
if (entityType === 'node') {
// Click to select a node
var ways = entity.parentWays();
if (!ways.length) { return new iD.controller.shape.SelectedPOINode(entity); }
// else { return new iD.controller.shape.SelectedWayNode(entity,ways[0]); }
// ** FIXME: ^^^ the above should start a new branching way, not select the node
return this;
} else if (entityType === 'way') {
if (this.intent === 'way') {
// Click to select a way
return new iD.controller.shape.SelectedWay(entityUI.entity);
default:
// Click to start a new way
var undo = new iD.actions.CompositeUndoableAction();
var startNode = this.getConnection().doCreateNode(
{},
map.coord2lat(map.mouseY(event)),
map.coord2lon(map.mouseX(event)), lang.hitch(undo,undo.push) );
var way = this.getConnection().doCreateWay({}, [startNode], lang.hitch(undo,undo.push) );
this.controller.undoStack.addAction(undo);
this.controller.map.createUI(way);
return new iD.controller.shape.DrawWay(way);
}
}
return this;
}
return new iD.controller.shape.SelectedWay(entityUI.entity);
}
} else {
// Click to start a new way
var undo = new iD.actions.CompositeUndoableAction();
var startNode = this.getConnection().doCreateNode({},
map.coord2lat(map.mouseY(event)),
map.coord2lon(map.mouseX(event)), lang.hitch(undo,undo.push) );
var way = this.getConnection().doCreateWay({}, [startNode], lang.hitch(undo,undo.push) );
this.controller.undoStack.addAction(undo);
this.controller.map.createUI(way);
return new iD.controller.shape.DrawWay(way);
}
}
return this;
}
});
// ----------------------------------------------------------------------
+2 -2
View File
@@ -54,7 +54,7 @@ declare("iD.controller.shape.SelectedWay", [iD.controller.ControllerState], {
var ways = entity.entity.parentWays();
if (entity.entity.hasParent(this.way)) {
// start a branching way from an existing point
way = this.getConnection().doCreateWay({}, [entity], lang.hitch(this,this.undoAdder) );
way = this.getConnection().doCreateWay({}, [entity], lang.hitch(this, this.undoAdder));
this.controller.map.createUI(way);
return new iD.controller.shape.DrawWay(way);
} else if (ways.length===0) {
@@ -66,7 +66,7 @@ declare("iD.controller.shape.SelectedWay", [iD.controller.ControllerState], {
}
break;
case 'way':
if (entity==this.way) {
if (entity === this.way) {
// start a branching way from a new point
var map = this.controller.map;
var undo = new iD.actions.CompositeUndoableAction();
+8 -8
View File
@@ -30,8 +30,8 @@ declare("iD.renderer.NodeUI", [iD.renderer.EntityUI], {
this.refreshStyleList(tags);
// Iterate through each subpart, drawing any styles on that layer
var drawn=false;
var s,p,t,w,h;
var drawn = false;
var s, p, t, w, h;
for (i = 0; i < this.styleList.subparts.length; i++) {
var subpart=this.styleList.subparts[i];
p = this.styleList.pointStyles[subpart];
@@ -50,7 +50,7 @@ declare("iD.renderer.NodeUI", [iD.renderer.EntityUI], {
}
switch (p.icon_image) {
case 'square':
case 'circle': shape.setStroke(s.shapeStrokeStyler()).setFill(s.shapeFillStyler()); break;
case 'circle': shape.setStroke(s.shapeStrokeStyler()).setFill(s.shapeFillStyler()); break;
}
this.recordSprite(shape);
@@ -64,11 +64,11 @@ declare("iD.renderer.NodeUI", [iD.renderer.EntityUI], {
hit.setFill([0,1,0,0]).setStroke( { width:2, color:[0,0,0,0] } );
this.recordSprite(hit);
hit.source= this;
hit.connect("onclick" , lang.hitch(this,this.entityMouseEvent));
hit.connect("onmousedown" , lang.hitch(this,this.entityMouseEvent));
hit.connect("onmouseup" , lang.hitch(this,this.entityMouseEvent));
hit.connect("onmouseenter", lang.hitch(this,this.entityMouseEvent));
hit.connect("onmouseleave", lang.hitch(this,this.entityMouseEvent));
hit.connect("onclick", _.bind(this.entityMouseEvent, this));
hit.connect("onmousedown", _.bind(this.entityMouseEvent, this));
hit.connect("onmouseup", _.bind(this.entityMouseEvent, this));
hit.connect("onmouseenter", _.bind(this.entityMouseEvent, this));
hit.connect("onmouseleave", _.bind(this.entityMouseEvent, this));
}
}
});