# HG changeset patch # User Thinker K.F. Li # Date 1283193402 -28800 # Node ID 9b2d803701e0cfbcb5ecdd788f1bc3fc8023a9b2 # Parent 7ec13634c97dac0280b7f0168e0a2c8f8636c67b Phone UI example diff -r 7ec13634c97d -r 9b2d803701e0 nodejs/phone.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/phone.js Tue Aug 31 02:36:42 2010 +0800 @@ -0,0 +1,61 @@ +// -*- indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4:ai +var mbapp = require("./mbapp"); +var sys=require("sys"); +var animate=require("./animate"); + +app = new mbapp.app(":0.0", 320, 480); +app.loadSVG("phone_ui.svg"); + +var icons = []; +var r, c; +var mbname; + +for(r = 0; r < 4; r++) { + for(c = 0; c < 5; c++) { + mbname = "icon" + r + "" + c; + icons.push(app.get(mbname)); + } +} + +var overhint, presshint; +var overholder, pressholder; +overhint = app.get("overhint"); +presshint = app.get("presshint"); +overholder = new animate.holder(app, overhint); +pressholder = new animate.holder(app, presshint); + +var dock; +var dockholder; +dock = app.get("dock"); +dockholder = new animate.holder(app, dock); + +var i; +var icon; +for(i = 0; i < icons.length; i++) { + icon = icons[i]; + icon.mouse_event.add_event_observer(1, function(evt) { + var tgt = evt.cur_tgt; + + overholder.go_center(tgt); + }); + icon.mouse_event.add_event_observer(2, function(evt) { + overholder.home(); + }); + icon.mouse_event.add_event_observer(4, function(evt) { + var tgt = evt.cur_tgt; + + pressholder.go_center(tgt); + }); +} + +var sw = 0; +dock.mouse_event.add_event_observer(4, function(evt) { + if(sw == 0) + dockholder.shift(0, -300); + else + dockholder.home(); + sw = (sw + 1) % 2; + }); + +app.loop(); diff -r 7ec13634c97d -r 9b2d803701e0 nodejs/phone_ui.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/phone_ui.svg Tue Aug 31 02:36:42 2010 +0800 @@ -0,0 +1,484 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +