remove a huge load of pseudo-traces
[potlatch2.git] / net / systemeD / potlatch2 / controller / DragBackground.as
1 package net.systemeD.potlatch2.controller {
2         import flash.events.*;
3     import net.systemeD.potlatch2.EditController;
4     import net.systemeD.halcyon.connection.*;
5     import net.systemeD.halcyon.MapEvent;
6
7     /** The state of realigning the background imagery by holding down a key and moving the mouse. This moves the background, but 
8     * doesn't move the map, thereby adjusting the offset between the background and the map. */
9     public class DragBackground extends ControllerState {
10
11         private var downX:Number;
12         private var downY:Number;
13         
14         /** Start the drag by recording the location of the mouse. */
15         public function DragBackground(event:MouseEvent) {
16             downX = event.localX;
17             downY = event.localY;
18         }
19  
20        /** Respond to dragging and end drag. */
21        override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
22
23             if (event.type==MouseEvent.MOUSE_UP) {
24                 return previousState;
25
26                         } else if ( event.type == MouseEvent.MOUSE_MOVE) {
27                                 // dragging
28                                 controller.map.nudgeBackground(event.localX-downX, event.localY-downY);
29                     downX = event.localX;
30                     downY = event.localY;
31                                 return this;
32
33                         } else {
34                                 // event not handled
35                 return this;
36                         }
37         }
38
39         /** Prevent map panning while background is being dragged. */
40         override public function enterState():void {
41                         controller.map.draggable=false;
42         }
43         
44         /** Re-allow map panning. */
45         override public function exitState(newState:ControllerState):void {
46                         controller.map.draggable=true;
47         }
48         
49         /** "DragBackground" */
50         override public function toString():String {
51             return "DragBackground";
52         }
53     }
54 }