mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-31 04:09:33 +02:00
Use an object with keys to keep track of tiles.
instead of a multidimensional array. this simplifies code and boosts performance upon dragging.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
Add road or shape -> DrawWay
|
||||
|
||||
The user is drawing a way.
|
||||
|
||||
|
||||
Goes to:
|
||||
-> click empty area: adds point, continues
|
||||
-> click way: adds junction, continues
|
||||
@@ -26,8 +26,8 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
|
||||
wayUI: null,
|
||||
editEnd: false,
|
||||
|
||||
constructor:function(_way) {
|
||||
this.way=_way;
|
||||
constructor: function(way) {
|
||||
this.way = way;
|
||||
},
|
||||
enterState:function() {
|
||||
this.wayUI=this.controller.map.getUI(this.way);
|
||||
@@ -42,14 +42,14 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
|
||||
this.wayUI.resetStateClass('shownodes');
|
||||
this.wayUI.redraw();
|
||||
},
|
||||
|
||||
|
||||
processMouseEvent:function(event,entityUI) {
|
||||
var entity=entityUI ? entityUI.entity : null;
|
||||
var entityType=entity ? entity.entityType : null;
|
||||
var map=this.controller.map;
|
||||
var ways;
|
||||
|
||||
if (event.type=='mouseover' && entityType=='way' && entityUI!=this.wayUI) {
|
||||
if (event.type=='mouseover' && entityType=='way' && entityUI!=this.wayUI) {
|
||||
// Mouse over way, show hover highlight
|
||||
entityUI.setStateClass('shownodeshover');
|
||||
entityUI.redraw();
|
||||
@@ -57,7 +57,7 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
|
||||
this.updateElastic(event);
|
||||
return this;
|
||||
|
||||
} else if (event.type=='mouseout' && 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__);
|
||||
@@ -117,7 +117,7 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
|
||||
var action=this.undoAdder(); action(undo);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
} else if (event.type=='click') {
|
||||
// Click on empty space, add new node to way
|
||||
var undo=new iD.actions.CompositeUndoableAction();
|
||||
@@ -137,15 +137,15 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
|
||||
map.mouseX(event), map.mouseY(event)
|
||||
);
|
||||
},
|
||||
|
||||
|
||||
getDrawingNode:function() {
|
||||
return (this.editEnd ? this.way.nodes[this.way.length()-1] : this.way.nodes[0]);
|
||||
},
|
||||
|
||||
|
||||
getStartNode:function() {
|
||||
return (this.editEnd ? this.way.nodes[0] : this.way.nodes[this.way.length()-1]);
|
||||
},
|
||||
|
||||
|
||||
appendNode:function(node, performAction) {
|
||||
if (this.editEnd) { this.way.doAppendNode(node, performAction); }
|
||||
else { this.way.doPrependNode(node, performAction); }
|
||||
@@ -154,13 +154,13 @@ declare("iD.controller.shape.DrawWay", [iD.controller.ControllerState], {
|
||||
appendNewNode:function(event, undo) {
|
||||
var map=this.controller.map;
|
||||
var node=this.getConnection().doCreateNode(
|
||||
{},
|
||||
{},
|
||||
map.coord2lat(map.mouseY(event)),
|
||||
map.coord2lon(map.mouseX(event)), lang.hitch(undo,undo.push) );
|
||||
this.appendNode(node, lang.hitch(undo,undo.push));
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Add road or shape -> NoSelection
|
||||
|
||||
The user has clicked 'Add road or shape', but hasn't yet started drawing.
|
||||
|
||||
|
||||
Goes to:
|
||||
-> click empty area: goes to shape/DrawWay
|
||||
-> click way: goes to shape/SelectedWay
|
||||
@@ -37,7 +37,7 @@ declare("iD.controller.shape.NoSelection", [iD.controller.ControllerState], {
|
||||
tag: "Set the type of the road or shape"
|
||||
},['begin','draw','tag']).highlight('begin');
|
||||
},
|
||||
|
||||
|
||||
processMouseEvent:function(event,entityUI) {
|
||||
var entity=entityUI ? entityUI.entity : null;
|
||||
var entityType=entity ? entity.entityType : null;
|
||||
@@ -70,7 +70,6 @@ declare("iD.controller.shape.NoSelection", [iD.controller.ControllerState], {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user