space-drag for backgrounds, plus D to dim (au revoir caps lock)
[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         import net.systemeD.halcyon.Globals;
7
8     public class DragBackground extends ControllerState {
9
10         private var downX:Number;
11         private var downY:Number;
12         
13         public function DragBackground(event:MouseEvent) {
14                         trace ("starting DragBackground");
15             downX = event.localX;
16             downY = event.localY;
17         }
18  
19        override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
20
21             if (event.type==MouseEvent.MOUSE_UP) {
22                 return previousState;
23
24                         } else if ( event.type == MouseEvent.MOUSE_MOVE) {
25                                 // dragging
26                                 controller.map.nudgeBackground(event.localX-downX, event.localY-downY);
27                     downX = event.localX;
28                     downY = event.localY;
29                                 return this;
30
31                         } else {
32                                 // event not handled
33                 return this;
34                         }
35         }
36
37         override public function enterState():void {
38                         controller.map.draggable=false;
39                         Globals.vars.root.addDebug("**** -> "+this);
40         }
41         override public function exitState():void {
42                         controller.map.draggable=true;
43                         Globals.vars.root.addDebug("**** <- "+this);
44         }
45         override public function toString():String {
46             return "DragBackground";
47         }
48     }
49 }