Mercurial > MadButterfly
annotate nodejs/phone.js @ 936:a9abcdac0ae5
Fix issue of moving lightbar of testsvg.js.
The lightbar does not move as expectation. It caused by compute
trasnforming matrix that transform saved points from the space when
saving points to current space. The transform matrix should not
include matric of the owner of saved points.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Fri, 12 Nov 2010 16:53:03 +0800 |
parents | 3136db0ac01b |
children |
rev | line source |
---|---|
794 | 1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- |
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
800
diff
changeset
|
2 // vim: sw=4:ts=8:sts=4 |
789 | 3 var mbapp = require("./mbapp"); |
4 var sys=require("sys"); | |
5 var animate=require("./animate"); | |
6 | |
7 app = new mbapp.app(":0.0", 320, 480); | |
8 app.loadSVG("phone_ui.svg"); | |
9 | |
10 var icons = []; | |
11 var r, c; | |
12 var mbname; | |
796
0b1764cd53b0
Fix missed naming for variables
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
13 for(c = 0; c < 4; c++) { // 4 columns |
0b1764cd53b0
Fix missed naming for variables
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
14 for(r = 0; r < 5; r++) { // 5 rows |
0b1764cd53b0
Fix missed naming for variables
Thinker K.F. Li <thinker@codemud.net>
parents:
795
diff
changeset
|
15 mbname = "icon" + c + "" + r; |
789 | 16 icons.push(app.get(mbname)); |
17 } | |
18 } | |
19 | |
20 var overhint, presshint; | |
21 var overholder, pressholder; | |
22 overhint = app.get("overhint"); | |
23 presshint = app.get("presshint"); | |
24 overholder = new animate.holder(app, overhint); | |
25 pressholder = new animate.holder(app, presshint); | |
26 | |
27 var dock; | |
28 var dockholder; | |
29 dock = app.get("dock"); | |
30 dockholder = new animate.holder(app, dock); | |
31 | |
32 var i; | |
33 var icon; | |
34 for(i = 0; i < icons.length; i++) { | |
35 icon = icons[i]; | |
36 icon.mouse_event.add_event_observer(1, function(evt) { | |
792
bf2794eed702
Remove redundant code
Thinker K.F. Li <thinker@codemud.net>
parents:
791
diff
changeset
|
37 overholder.go_center(evt.cur_tgt); |
789 | 38 }); |
39 icon.mouse_event.add_event_observer(2, function(evt) { | |
40 overholder.home(); | |
41 }); | |
42 icon.mouse_event.add_event_observer(4, function(evt) { | |
792
bf2794eed702
Remove redundant code
Thinker K.F. Li <thinker@codemud.net>
parents:
791
diff
changeset
|
43 pressholder.go_center(evt.cur_tgt); |
895
3136db0ac01b
Merged from default branch
Thinker K.F. Li <thinker@branda.to>
parents:
893
diff
changeset
|
44 var rotate = new animate.rotate(app, evt.cur_tgt, 2 * 3.1415); |
3136db0ac01b
Merged from default branch
Thinker K.F. Li <thinker@branda.to>
parents:
893
diff
changeset
|
45 animate.run([rotate], 0, 0.7); |
789 | 46 }); |
47 } | |
48 | |
49 var sw = 0; | |
895
3136db0ac01b
Merged from default branch
Thinker K.F. Li <thinker@branda.to>
parents:
893
diff
changeset
|
50 var dock_up = new animate.shift(app, dock, 0, -300); |
3136db0ac01b
Merged from default branch
Thinker K.F. Li <thinker@branda.to>
parents:
893
diff
changeset
|
51 var dock_down = new animate.shift(app, dock, 0, 0); |
789 | 52 dock.mouse_event.add_event_observer(4, function(evt) { |
791
85c5949352bb
Slide the dock of phone UI
Thinker K.F. Li <thinker@codemud.net>
parents:
789
diff
changeset
|
53 if(sw == 0) { |
895
3136db0ac01b
Merged from default branch
Thinker K.F. Li <thinker@branda.to>
parents:
893
diff
changeset
|
54 animate.run([dock_up], 0, 0.5); |
791
85c5949352bb
Slide the dock of phone UI
Thinker K.F. Li <thinker@codemud.net>
parents:
789
diff
changeset
|
55 } else { |
895
3136db0ac01b
Merged from default branch
Thinker K.F. Li <thinker@branda.to>
parents:
893
diff
changeset
|
56 animate.run([dock_down], 0, 0.2); |
791
85c5949352bb
Slide the dock of phone UI
Thinker K.F. Li <thinker@codemud.net>
parents:
789
diff
changeset
|
57 } |
793 | 58 sw = sw ^ 1; |
789 | 59 }); |
60 | |
61 app.loop(); |