move up a level
[potlatch2.git] / net / systemeD / potlatch2 / controller / NoSelection.as
1 package net.systemeD.potlatch2.controller {
2         import flash.events.*;
3         import flash.display.*;
4         import net.systemeD.potlatch2.EditController;
5         import net.systemeD.halcyon.connection.*;
6         import net.systemeD.halcyon.Map;
7         import net.systemeD.halcyon.MapPaint;
8         import net.systemeD.halcyon.Globals;
9
10         public class NoSelection extends ControllerState {
11
12                 public function NoSelection() {
13                 }
14
15                 override public function isSelectionState():Boolean {
16                         return false;
17                 }
18                 
19                 override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
20                         var focus:Entity = getTopLevelFocusEntity(entity);
21
22                         if (event.type==MouseEvent.MOUSE_UP && focus==null && map.dragstate!=map.DRAGGING) {
23                                 map.dragstate=map.NOT_DRAGGING;
24                                 var undo:CompositeUndoableAction = new CompositeUndoableAction("Begin way");
25                                 var startNode:Node = controller.connection.createNode(
26                                         {}, 
27                                         controller.map.coord2lat(event.localY),
28                                         controller.map.coord2lon(event.localX), undo.push);
29                                 var way:Way = controller.connection.createWay({}, [startNode], undo.push);
30                                 MainUndoStack.getGlobalStack().addAction(undo);
31                                 return new DrawWay(way, true, false);
32                         }
33                         var cs:ControllerState = sharedMouseEvents(event, entity);
34                         return cs ? cs : this;
35                 }
36                 
37                 override public function processKeyboardEvent(event:KeyboardEvent):ControllerState {
38                         var cs:ControllerState = sharedKeyboardEvents(event);
39                         return cs ? cs : this;
40                 }
41                 
42         override public function enterState():void {
43                         Globals.vars.root.addDebug("**** -> "+this);
44         }
45         override public function exitState(newState:ControllerState):void {
46                         Globals.vars.root.addDebug("**** <- "+this);
47         }
48                 override public function toString():String {
49                         return "NoSelection";
50                 }
51
52         }
53 }