Mercurial > MadButterfly
comparison nodejs/phone.js @ 789:9b2d803701e0
Phone UI example
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 31 Aug 2010 02:36:42 +0800 |
parents | |
children | 85c5949352bb |
comparison
equal
deleted
inserted
replaced
788:7ec13634c97d | 789:9b2d803701e0 |
---|---|
1 // -*- indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*- | |
2 // vim: sw=4:ts=8:sts=4:ai | |
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; | |
13 | |
14 for(r = 0; r < 4; r++) { | |
15 for(c = 0; c < 5; c++) { | |
16 mbname = "icon" + r + "" + c; | |
17 icons.push(app.get(mbname)); | |
18 } | |
19 } | |
20 | |
21 var overhint, presshint; | |
22 var overholder, pressholder; | |
23 overhint = app.get("overhint"); | |
24 presshint = app.get("presshint"); | |
25 overholder = new animate.holder(app, overhint); | |
26 pressholder = new animate.holder(app, presshint); | |
27 | |
28 var dock; | |
29 var dockholder; | |
30 dock = app.get("dock"); | |
31 dockholder = new animate.holder(app, dock); | |
32 | |
33 var i; | |
34 var icon; | |
35 for(i = 0; i < icons.length; i++) { | |
36 icon = icons[i]; | |
37 icon.mouse_event.add_event_observer(1, function(evt) { | |
38 var tgt = evt.cur_tgt; | |
39 | |
40 overholder.go_center(tgt); | |
41 }); | |
42 icon.mouse_event.add_event_observer(2, function(evt) { | |
43 overholder.home(); | |
44 }); | |
45 icon.mouse_event.add_event_observer(4, function(evt) { | |
46 var tgt = evt.cur_tgt; | |
47 | |
48 pressholder.go_center(tgt); | |
49 }); | |
50 } | |
51 | |
52 var sw = 0; | |
53 dock.mouse_event.add_event_observer(4, function(evt) { | |
54 if(sw == 0) | |
55 dockholder.shift(0, -300); | |
56 else | |
57 dockholder.home(); | |
58 sw = (sw + 1) % 2; | |
59 }); | |
60 | |
61 app.loop(); |