mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-31 04:09:33 +02:00
Select new node on add
This commit is contained in:
@@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
|
||||
define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/array','dojox/gfx/shape','iD/controller/ControllerState'],
|
||||
function(declare,lang,array,shape){
|
||||
define(['dojo/_base/declare', 'dojo/_base/lang', 'dojox/gfx/shape', 'iD/controller/ControllerState'],
|
||||
function(declare, lang, shape){
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// DrawWay class
|
||||
@@ -44,25 +44,28 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
|
||||
.redraw();
|
||||
},
|
||||
|
||||
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;
|
||||
var ways, undo, action;
|
||||
|
||||
if (event.type=='mouseover' && entityType=='way' && entityUI!=this.wayUI) {
|
||||
// Mouse over way, show hover highlight
|
||||
entityUI.setStateClass('shownodeshover');
|
||||
entityUI.redraw();
|
||||
this.wayUI.redraw();
|
||||
this.updateElastic(event);
|
||||
return this;
|
||||
if (event.type=='mouseover' && entityType=='way' &&
|
||||
entityUI !== this.wayUI) {
|
||||
|
||||
} else if (event.type=='mouseout' && entityType=='way' && entityUI!=this.wayUI) {
|
||||
// Mouse left way, remove hover highlight
|
||||
// Find what object we're moving into
|
||||
var into=shape.byId((event.hasOwnProperty('toElement') ? event.toElement : event.relatedTarget).__gfxObject__);
|
||||
// If it's a nodeUI that belongs to a hovering way, don't deselect
|
||||
// Mouse over way, show hover highlight
|
||||
entityUI.setStateClass('shownodeshover')
|
||||
.redraw();
|
||||
this.wayUI.redraw();
|
||||
this.updateElastic(event);
|
||||
return this;
|
||||
|
||||
} else if (event.type=='mouseout' && entityType=='way' &&
|
||||
entityUI !== this.wayUI) {
|
||||
// Mouse left way, remove hover highlight
|
||||
// Find what object we're moving into
|
||||
var into = shape.byId((event.hasOwnProperty('toElement') ? event.toElement : event.relatedTarget).__gfxObject__);
|
||||
// If it's a nodeUI that belongs to a hovering way, don't deselect
|
||||
if (into &&
|
||||
into.hasOwnProperty('source') &&
|
||||
into.source.hasStateClass('hoverway') &&
|
||||
|
||||
@@ -37,7 +37,11 @@ declare("iD.controller.shape.NoSelection", [iD.controller.ControllerState], {
|
||||
|
||||
enterState: function() {
|
||||
this.controller.map.div.className = 'state-drawing';
|
||||
this.controller.stepper.show().step(0);
|
||||
if (this.intent === 'way') {
|
||||
this.controller.stepper.show().step(0);
|
||||
} else if (this.intent === 'node') {
|
||||
this.controller.stepper.show().message('Click on the map to add a place');
|
||||
}
|
||||
},
|
||||
|
||||
processMouseEvent:function(event, entityUI) {
|
||||
@@ -59,15 +63,28 @@ declare("iD.controller.shape.NoSelection", [iD.controller.ControllerState], {
|
||||
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);
|
||||
if (this.intent === 'way') {
|
||||
// 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);
|
||||
} else if (this.intent === 'node') {
|
||||
var action = new iD.actions.CreatePOIAction(this.getConnection(), {},
|
||||
map.coord2lat(map.mouseY(event)),
|
||||
map.coord2lon(map.mouseX(event)));
|
||||
this.controller.undoStack.addAction(action);
|
||||
var node = action.getNode();
|
||||
this.controller.map.createUI(node);
|
||||
var state = new iD.controller.edit.SelectedPOINode(node);
|
||||
state.controller = this.controller;
|
||||
state.enterState();
|
||||
return state;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user