1 module ws.gui.dragger;
2 
3 
4 import
5 	ws.gui.base;
6 
7 
8 class Draggable {
9 
10 	Base handle(){
11 		assert(0);
12 	}
13 
14 	void move(int x, int y){
15 
16 	}
17 
18 	Base shadow(){
19 		assert(0);
20 	}
21 
22 }
23 
24 
25 class Dragger {
26 
27 	Base root;
28 	Draggable grabbed;
29 	Base shadowHolder;
30 
31 	this(Base root){
32 		this.root = root;
33 	}
34 
35 	void grab(int x, int y){
36 		if(grabbed)
37 			return;
38 		grabbed = root.grab(x, y);
39 	}
40 
41 	void drop(int x, int y){
42 		if(shadowHolder){
43 			shadowHolder.receive(grabbed);
44 			grabbed = null;
45 		}
46 	}
47 
48 	void draw(){
49 		if(grabbed)
50 			grabbed.shadow.onDraw;
51 	}
52 
53 	void move(int x, int y){
54 		if(grabbed){
55 			grabbed.move(x, y);
56 		}
57 		if(shadowHolder)
58 			shadowHolder.receiveShadow(null, x, y);
59 		shadowHolder = root.receiveShadow(grabbed, x, y);
60 	}
61 }
62 
63