File: mouse_layerctl.js

package info (click to toggle)
freej 0.10git20080824-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 13,504 kB
  • ctags: 19,398
  • sloc: ansic: 135,255; cpp: 32,550; sh: 9,318; perl: 2,932; asm: 2,355; yacc: 1,178; makefile: 1,119; java: 136; lex: 94; python: 16
file content (41 lines) | stat: -rw-r--r-- 808 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
m = new MouseController();
register_controller(m);

m.zoomx = 1; m.zoomy = 1; m.maxzoom=4;

// MouseController.button(button, state, x, y)
m.button = function(b, s, x, y) {
	echo("b"+b+" s"+s+" x"+x+" y"+y);
	this.grab(s);

	if (s == 1)
		this.l=selected_layer();
	else
		delete this.l;
	
	return true;
}

// MouseController.motion(buttonmask, x, y, xrel, yrel)
m.motion = function(b, x, y, dx, dy) {
	echo("b"+b+" x"+x+" y"+y+" dx"+dx+" dy"+dy);
	
	var l = this.l
	if (!l)
		return false;
	
	if (b & 1) {
		l.set_position(l.x() + dx, l.y() + dy);
	}
	if (b & 2) {
	}
	if (b & 4) {
		this.zoomx += dx/100; 
		this.zoomy += dy/100;
		if (Math.abs(this.zoomx)>this.maxzoom)
			this.zoomx=this.maxzoom;
		if (Math.abs(this.zoomy)>this.maxzoom)
			this.zoomy=this.maxzoom;
		l.zoom(this.zoomx, this.zoomy);
	}
}