Current working version

This commit is contained in:
Richard Fairhurst
2012-07-11 14:27:30 +01:00
parent 790d71bba4
commit 22fab3eb1d
48 changed files with 4088 additions and 2 deletions
+45
View File
@@ -0,0 +1,45 @@
Coding standards and advice for iD
==================================
Classes
-------
All constructors must initialise objects and arrays. It is not enough to say
array:[],
constructor:function() {
},
but rather, you should do
array: null, // effectively a placeholder
constructor:function() {
this.array=[],
},
or bad things will happen. You should still declare the object outside the constructor, but for clarity rather than functionality.
(This doesn't apply to simple types - numbers, strings, booleans - which you can declare as normal.)
Function names
--------------
Anything that creates and calls an Action should be prefixed with do:
doSetLatLon(lat,lon)
Anything that is called by an Action, to do the actual work, should be prefixed with an underscore:
_setLatLon(lat,lon)
and commented as such.
File naming
-----------
The filename should be the name of the base class. You can add subclasses within that file for clarity. Don't add extra classes that aren't subclasses, unless they're not referenced from elsewhere.
Class and variable names
------------------------
You can prefix function arguments with an underscore to make it clear where they've come from.
Layout
------
* Hard tabs, indent of 4.
* Do not indent the root level of the module. Add an 'End of module' comment instead.
Useful stuff to know about Dojo
-------------------------------
* The array and lang modules are full of useful add-ons to basic JavaScript functionality. lang/hitch will save your life with scopes.
+7
View File
@@ -0,0 +1,7 @@
Each ControllerState represents a UI state.
They are grouped into folders:
- 'edit' is all states within the 'Edit object' mode
- 'shape' is all states within the 'Add shape' mode
- 'point' is all states within the 'Add point' mode
+14
View File
@@ -0,0 +1,14 @@
== Entities ==
Listeners are created in NodeUI and WayUI for each item's hitzone.
MouseEvents proceed like this:
* Event triggered on EntityUI, calling EntityUI.entityMouseEvent(event)
* This calls Controller.entityMouseEvent(event,entityUI)
* This updates the state from ControllerState.processMouseEvent(event,entityUI)
== Non-entities ==
* onmousemove in Map.js calls processMove, which calls Controller.entityMouseEvent(event,null)
* onclick in Map.js calls clickSurface, which calls Controller.entityMouseEvent(event,null)
Executable
+63
View File
@@ -0,0 +1,63 @@
DrawWay to do:
* make junctions
* still allow dragging the map
Drag and drop to do:
* icon grid
* improve 'avatar'
* cope with dragging onto anything, not just blank areas of the map
Next to do:
* drag nodes
* remove trailing commas (for IE!)
Renderer to do
* hover!
* NodeUI renderer needs a default width/height so that clicking a POI without them still shows the highlight
* Fix 'special values' in RuleSet - they're not really special for SVG etc.
* Labels other than text-on-path
* Node headings (for locks etc.)
* Dragging needs tolerance (i.e. less than n pixels and n seconds)
ControllerStates to do:
* Try to share as much code as possible
* Draw way controller states:
- NoSelection (next click starts, or selects)
- SelectedWay (next click starts, or selects)
- SelectedPOINode (next click starts, or selects)
- DrawWay (next click continues, or completes and edits)
Events
* EntityMouseEvent seems to get called twice most of the time when moving the mouse around in DrawWay
* Maybe we should just broadcast to the Controller, and the Controller knows what to do. In other words:
- undo says "the following entities have changed: way 5, node 3, way 7, relation 8"
- 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:
1. Add point
2. Add street or shape
3. Edit object
3a. edit tags (and relation memberships, etc.)
3b. move object
3c. delete object
3d. extend way
3e. geometry operations (like P2 Toolbox)
In 'edit': double-clicking goes into "draw shape"; double-clicking then Enter creates POI
Needs greyed-out "step-by-step" window for draw modes:
Click at the start point to begin drawing
Add each point, click by click
Double-click when you've finished
Then choose what it is
With buttons at the bottom:
Finish
Cancel
Undo last