Mercurial > MadButterfly
changeset 1044:5d4bc2a93c09
Merge from refine_backend_if branch
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 23 Nov 2010 11:58:04 +0800 |
parents | 18329b6f77a4 (diff) 769921baf111 (current diff) |
children | bf5adf1e275e |
files | |
diffstat | 12 files changed, 1189 insertions(+), 661 deletions(-) [+] |
line wrap: on
line diff
--- a/nodejs/examples/mce/epg.js Tue Nov 23 11:55:12 2010 +0800 +++ b/nodejs/examples/mce/epg.js Tue Nov 23 11:58:04 2010 +0800 @@ -122,7 +122,8 @@ if (ext != "png") { fields.push("png"); newf = fields.join("."); - os.spawn("convert",[file,newf]); + sys.puts("cachepath="+cachepath+" newf="+newf); + os.spawn("convert",[cachepath,newf]); } else { newf = cachepath; }
--- a/nodejs/examples/mce/main.svg Tue Nov 23 11:55:12 2010 +0800 +++ b/nodejs/examples/mce/main.svg Tue Nov 23 11:58:04 2010 +0800 @@ -14,8 +14,9 @@ height="1052.3622047" id="svg2" version="1.1" - inkscape:version="0.47 r22583" - sodipodi:docname="main.svg"> + inkscape:version="0.48+devel r9764 custom" + sodipodi:docname="main.svg" + xmlns:ns0="http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd"> <defs id="defs4"> <inkscape:perspective @@ -55,16 +56,16 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="0.35" - inkscape:cx="941.26757" + inkscape:cx="574.12471" inkscape:cy="483.73232" inkscape:document-units="px" - inkscape:current-layer="layer1" + inkscape:current-layer="Layer 1s235" showgrid="false" - inkscape:window-width="1274" - inkscape:window-height="705" - inkscape:window-x="225" - inkscape:window-y="167" - inkscape:window-maximized="0" /> + inkscape:window-width="1680" + inkscape:window-height="976" + inkscape:window-x="0" + inkscape:window-y="25" + inkscape:window-maximized="1" /> <metadata id="metadata7"> <rdf:RDF> @@ -76,11 +77,19 @@ <dc:title /> </cc:Work> </rdf:RDF> + <ns0:scenes> + <ns0:scene + start="1" + ref="Layer 1s1841" /> + <ns0:scene + start="2" + ref="Layer 1s235" /> + </ns0:scenes> </metadata> <g - inkscape:label="Layer 1" inkscape:groupmode="layer" - id="layer1"> + id="layer2" + inkscape:label="Background"> <image y="-27.637817" x="0" @@ -88,258 +97,257 @@ inkscape:bbox-width="1920" inkscape:bbox-y="0" inkscape:bbox-x="0" - inkscape:transform-center-y="0" - inkscape:transform-center-x="0" id="image2977" height="1080" width="1920" xlink:href="file:///home/wycc/devel/md6/MadButterfly/nodejs/examples/mce/background.png" /> + </g> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> <g - id="g2999" - inkscape:label="lightbar" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="107.14287" - inkscape:bbox-y="49.999969" - inkscape:bbox-width="228.57144" - inkscape:bbox-height="865.71429"> - <image - xlink:href="file:///home/wycc/devel/md6/MadButterfly/nodejs/examples/mce/vod1-select.png" - width="228.57144" - height="865.71429" - id="image2995" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" + id="Layer 1s1841" + inkscape:groupmode="layer" + style="display:none"> + <g + transform="translate(7.14163,8.5714057)" + id="g2999" + inkscape:label="lightbar" inkscape:bbox-x="107.14287" inkscape:bbox-y="49.999969" inkscape:bbox-width="228.57144" - inkscape:bbox-height="865.71429" - x="107.14287" - y="136.64792" /> - </g> - <g - id="g2922" - inkscape:label="cat0" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="117.64285" - inkscape:bbox-y="462.7648" - inkscape:bbox-width="200" - inkscape:bbox-height="286.7168"> - <image - sodipodi:absref="/home/wycc/devel/md6/MadButterfly/nodejs/examples/mce/./cat0.png" - xlink:href="./cat0.png" - y="302.88058" - x="117.64285" - id="image3058" - height="286.7168" - width="200" - inkscape:label="" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" + inkscape:bbox-height="865.71429"> + <image + xlink:href="file:///home/wycc/devel/md6/MadButterfly/nodejs/examples/mce/vod1-select.png" + width="228.57144" + height="865.71429" + id="image2995" + inkscape:bbox-x="107.14287" + inkscape:bbox-y="49.999969" + inkscape:bbox-width="228.57144" + inkscape:bbox-height="865.71429" + x="107.14287" + y="136.64792" /> + </g> + <g + transform="translate(7.14163,8.5714057)" + id="g2922" + inkscape:label="cat0" inkscape:bbox-x="117.64285" inkscape:bbox-y="462.7648" inkscape:bbox-width="200" - inkscape:bbox-height="286.7168" /> - </g> - <g - id="g2923" - inkscape:label="cat1" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="359.21432" - inkscape:bbox-y="455.42856" - inkscape:bbox-width="200" - inkscape:bbox-height="291.09415"> - <image - sodipodi:absref="/home/wycc/devel/md6/MadButterfly/nodejs/examples/mce/./cat1.png" - xlink:href="./cat1.png" - y="305.83948" - x="359.21432" - id="image3116" - height="291.09415" - width="200" - inkscape:label="" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" + inkscape:bbox-height="286.7168"> + <image + inkscape:bbox-height="286.7168" + inkscape:bbox-width="200" + inkscape:bbox-y="462.7648" + inkscape:bbox-x="117.64285" + inkscape:label="" + width="200" + height="286.7168" + id="image3058" + x="117.64285" + y="302.88058" + xlink:href="./cat0.png" + sodipodi:absref="./cat0.png" /> + </g> + <g + transform="translate(7.14163,8.5714057)" + id="g2923" + inkscape:label="cat1" inkscape:bbox-x="359.21432" inkscape:bbox-y="455.42856" inkscape:bbox-width="200" - inkscape:bbox-height="291.09415" /> - </g> - <g - id="g2926" - inkscape:label="cat2" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="599.07141" - inkscape:bbox-y="458.28571" - inkscape:bbox-width="200" - inkscape:bbox-height="286.7168"> - <image - sodipodi:absref="/home/wycc/devel/md6/MadButterfly/nodejs/examples/mce/./cat2.png" - xlink:href="./cat2.png" - y="307.35968" - x="599.07141" - id="image3174" - height="286.7168" - width="200" - inkscape:label="" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" + inkscape:bbox-height="291.09415"> + <image + inkscape:bbox-height="291.09415" + inkscape:bbox-width="200" + inkscape:bbox-y="455.42856" + inkscape:bbox-x="359.21432" + inkscape:label="" + width="200" + height="291.09415" + id="image3116" + x="359.21432" + y="305.83948" + xlink:href="./cat1.png" + sodipodi:absref="./cat1.png" /> + </g> + <g + transform="translate(7.14163,8.5714057)" + id="g2926" + inkscape:label="cat2" inkscape:bbox-x="599.07141" inkscape:bbox-y="458.28571" inkscape:bbox-width="200" - inkscape:bbox-height="286.7168" /> - </g> - <g - id="g2929" - inkscape:label="cat3" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="821.35712" - inkscape:bbox-y="456.71426" - inkscape:bbox-width="200" - inkscape:bbox-height="289.10892"> - <image - sodipodi:absref="/home/wycc/devel/md6/MadButterfly/nodejs/examples/mce/./cat3.png" - xlink:href="./cat3.png" - y="306.539" - x="821.35712" - id="image3232" - height="289.10892" - width="200" - inkscape:label="" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" + inkscape:bbox-height="286.7168"> + <image + inkscape:bbox-height="286.7168" + inkscape:bbox-width="200" + inkscape:bbox-y="458.28571" + inkscape:bbox-x="599.07141" + inkscape:label="" + width="200" + height="286.7168" + id="image3174" + x="599.07141" + y="307.35968" + xlink:href="./cat2.png" + sodipodi:absref="./cat2.png" /> + </g> + <g + transform="translate(7.14163,8.5714057)" + id="g2929" + inkscape:label="cat3" inkscape:bbox-x="821.35712" inkscape:bbox-y="456.71426" inkscape:bbox-width="200" - inkscape:bbox-height="289.10892" /> - </g> - <path - sodipodi:type="star" - style="fill:#00c280;fill-opacity:1" - id="path3235" - sodipodi:sides="3" - sodipodi:cx="-171.42857" - sodipodi:cy="186.6479" - sodipodi:r1="48.760139" - sodipodi:r2="24.38007" - sodipodi:arg1="1.0153026" - sodipodi:arg2="2.0625001" - inkscape:flatsided="false" - inkscape:rounded="0" - inkscape:randomized="0" - d="m -145.71429,228.07648 -37.22481,-19.93682 -37.22481,-19.93682 35.87819,-22.26922 35.8782,-22.26923 1.34662,42.20604 1.34661,42.20605 z" - inkscape:transform-center-x="11.746635" - inkscape:transform-center-y="-0.50892793" - transform="matrix(0.9999393,0.01101845,-0.01101845,0.9999393,239.18902,264.75735)" - inkscape:label="leftarrow" - inkscape:bbox-x="16.964767" - inkscape:bbox-y="561.14775" - inkscape:bbox-width="74.005762" - inkscape:bbox-height="84.436636" /> - <path - transform="matrix(-0.99874276,-0.05012887,0.05012887,-0.99874276,1659.4305,613.03905)" - inkscape:transform-center-y="-0.445031" - inkscape:transform-center-x="-11.802598" - d="m -145.71429,228.07648 -37.22481,-19.93682 -37.22481,-19.93682 35.87819,-22.26922 35.8782,-22.26923 1.34662,42.20604 1.34661,42.20605 z" - inkscape:randomized="0" - inkscape:rounded="0" - inkscape:flatsided="false" - sodipodi:arg2="2.0625001" - sodipodi:arg1="1.0153026" - sodipodi:r2="24.38007" - sodipodi:r1="48.760139" - sodipodi:cy="186.6479" - sodipodi:cx="-171.42857" - sodipodi:sides="3" - id="path4005" - style="fill:#00c280;fill-opacity:1" - sodipodi:type="star" - inkscape:label="rightarrow" - inkscape:bbox-x="1814.8532" - inkscape:bbox-y="575.3674" - inkscape:bbox-width="73.898841" - inkscape:bbox-height="84.440967" /> - <g - inkscape:bbox-height="289.10892" - inkscape:bbox-width="200" - inkscape:bbox-y="456.71426" - inkscape:bbox-x="1035.3571" - inkscape:transform-center-y="0" - inkscape:transform-center-x="0" - inkscape:label="cat4" - id="g2931" - transform="translate(214,0)"> - <image - sodipodi:absref="/home/wycc/devel/md6/MadButterfly/nodejs/examples/mce/./cat4.png" - xlink:href="./cat4.png" + inkscape:bbox-height="289.10892"> + <image + inkscape:bbox-height="289.10892" + inkscape:bbox-width="200" + inkscape:bbox-y="456.71426" + inkscape:bbox-x="821.35712" + inkscape:label="" + width="200" + height="289.10892" + id="image3232" + x="821.35712" + y="306.539" + xlink:href="./cat3.png" + sodipodi:absref="./cat3.png" /> + </g> + <path + sodipodi:type="star" + style="fill:#00c280;fill-opacity:1" + id="path3235" + sodipodi:sides="3" + sodipodi:cx="-171.42857" + sodipodi:cy="186.6479" + sodipodi:r1="48.760139" + sodipodi:r2="24.38007" + sodipodi:arg1="1.0153026" + sodipodi:arg2="2.0625001" + inkscape:flatsided="false" + inkscape:rounded="0" + inkscape:randomized="0" + d="m -145.71429,228.07648 -37.22481,-19.93682 -37.22481,-19.93682 35.87819,-22.26922 35.8782,-22.26923 1.34662,42.20604 z" + inkscape:transform-center-x="11.746635" + inkscape:transform-center-y="-0.50892793" + transform="matrix(0.9999393,0.01101845,-0.01101845,0.9999393,246.33065,273.32876)" + inkscape:label="leftarrow" + inkscape:bbox-x="16.964767" + inkscape:bbox-y="561.14775" + inkscape:bbox-width="74.005762" + inkscape:bbox-height="84.436636" /> + <path + transform="matrix(-0.99874276,-0.05012887,0.05012887,-0.99874276,1666.5721,621.61046)" + inkscape:transform-center-y="-0.445031" + inkscape:transform-center-x="-11.802598" + d="m -145.71429,228.07648 -37.22481,-19.93682 -37.22481,-19.93682 35.87819,-22.26922 35.8782,-22.26923 1.34662,42.20604 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="false" + sodipodi:arg2="2.0625001" + sodipodi:arg1="1.0153026" + sodipodi:r2="24.38007" + sodipodi:r1="48.760139" + sodipodi:cy="186.6479" + sodipodi:cx="-171.42857" + sodipodi:sides="3" + id="path4005" + style="fill:#00c280;fill-opacity:1" + sodipodi:type="star" + inkscape:label="rightarrow" + inkscape:bbox-x="1814.8532" + inkscape:bbox-y="575.3674" + inkscape:bbox-width="73.898841" + inkscape:bbox-height="84.440967" /> + <g inkscape:bbox-height="289.10892" inkscape:bbox-width="200" inkscape:bbox-y="456.71426" inkscape:bbox-x="1035.3571" - inkscape:transform-center-y="0" - inkscape:transform-center-x="0" - inkscape:label="" - width="200" - height="289.10892" - id="image2933" - x="821.35712" - y="306.539" /> - </g> - <g - transform="translate(438,0)" - id="g2935" - inkscape:label="cat5" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="1259.3571" - inkscape:bbox-y="456.71426" - inkscape:bbox-width="200" - inkscape:bbox-height="289.10892"> - <image - sodipodi:absref="/home/wycc/devel/md6/MadButterfly/nodejs/examples/mce/./cat5.png" - xlink:href="./cat5.png" - y="306.539" - x="821.35712" - id="image2937" - height="289.10892" - width="200" - inkscape:label="" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" + inkscape:label="cat4" + id="g2931" + transform="translate(221.14163,8.5714057)"> + <image + y="306.539" + x="821.35712" + id="image2933" + height="289.10892" + width="200" + inkscape:label="" + inkscape:bbox-x="1035.3571" + inkscape:bbox-y="456.71426" + inkscape:bbox-width="200" + inkscape:bbox-height="289.10892" + xlink:href="./cat4.png" + sodipodi:absref="./cat4.png" /> + </g> + <g + transform="translate(445.14163,8.5714057)" + id="g2935" + inkscape:label="cat5" inkscape:bbox-x="1259.3571" inkscape:bbox-y="456.71426" inkscape:bbox-width="200" - inkscape:bbox-height="289.10892" /> - </g> - <g - inkscape:bbox-height="289.10892" - inkscape:bbox-width="200" - inkscape:bbox-y="456.71426" - inkscape:bbox-x="1475.3571" - inkscape:transform-center-y="0" - inkscape:transform-center-x="0" - inkscape:label="cat6" - id="g2939" - transform="translate(654,0)"> - <image - sodipodi:absref="/home/wycc/devel/md6/MadButterfly/nodejs/examples/mce/./cat6.png" - xlink:href="./cat6.png" + inkscape:bbox-height="289.10892"> + <image + inkscape:bbox-height="289.10892" + inkscape:bbox-width="200" + inkscape:bbox-y="456.71426" + inkscape:bbox-x="1259.3571" + inkscape:label="" + width="200" + height="289.10892" + id="image2937" + x="821.35712" + y="306.539" + xlink:href="./cat5.png" + sodipodi:absref="./cat5.png" /> + </g> + <g inkscape:bbox-height="289.10892" inkscape:bbox-width="200" inkscape:bbox-y="456.71426" inkscape:bbox-x="1475.3571" - inkscape:transform-center-y="0" - inkscape:transform-center-x="0" - inkscape:label="" - width="200" - height="289.10892" - id="image2941" - x="821.35712" - y="306.539" /> + inkscape:label="cat6" + id="g2939" + transform="translate(661.14163,8.5714057)"> + <image + y="306.539" + x="821.35712" + id="image2941" + height="289.10892" + width="200" + inkscape:label="" + inkscape:bbox-x="1475.3571" + inkscape:bbox-y="456.71426" + inkscape:bbox-width="200" + inkscape:bbox-height="289.10892" + xlink:href="./cat6.png" + sodipodi:absref="./cat6.png" /> + </g> + </g> + <g + id="Layer 1s235" + inkscape:groupmode="layer" + style="display:inline"> + <rect + x="0" + y="0" + width="100" + height="100" + id="rect3181" /> + <image + y="-27.637817" + x="0" + id="image3245" + xlink:href="./background2.png" + height="1080" + width="1920" /> </g> </g> </svg>
--- a/nodejs/examples/mce/mainmenu.js Tue Nov 23 11:55:12 2010 +0800 +++ b/nodejs/examples/mce/mainmenu.js Tue Nov 23 11:58:04 2010 +0800 @@ -21,6 +21,7 @@ MainMenu.prototype.init=function() { app.loadSVG("main.svg"); + app.changeScene(1); var i; var self = this; @@ -150,7 +151,7 @@ } MainMenu.prototype.changePage=function() { - this.app.loadSVG("preview.svg"); + this.app.changeScene(2); } exports.MainMenu=MainMenu;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/scene/mainmenu.js Tue Nov 23 11:58:04 2010 +0800 @@ -0,0 +1,60 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var svg = require("svg"); +var mbapp = require("mbapp"); +var sys=require("sys"); +var animate=require("animate"); +var fs = require("fs"); +/** + * We will fetch the EPG file from the server and fetch all images required for the main category from it. + * If these files are cached, we will not fetch it again. Otherwise, we will fetch them. The EPG class is + * responsible for the cache management. + */ +function MainMenu(app) +{ + var self = this; + this.n = 1; + this.app = app; + self.init(app); +} +MainMenu.prototype.init=function(app) +{ + var self = this; + app.loadSVG("mbtest.svg"); + + app.addKeyListener(mbapp.KEY_LEFT, function() { self.key_left();}); + app.addKeyListener(mbapp.KEY_RIGHT, function() { self.key_right();}); + app.addKeyListener(mbapp.KEY_UP, function() {self.key_up();}); + app.addKeyListener(mbapp.KEY_DOWN, function() {self.key_down();}); + app.addKeyListener(mbapp.KEY_ENTER, function() {self.key_enter();}); + app.changeScene(this.n); +} + +MainMenu.prototype.key_left=function () +{ + this.n = this.n - 1; + this.app.changeScene(this.n); + sys.puts("scene "+this.n); +} + +MainMenu.prototype.key_right=function() +{ + this.n = this.n + 1; + this.app.changeScene(this.n); + sys.puts("scene "+this.n); +} + +MainMenu.prototype.key_up=function() +{ +} + + +MainMenu.prototype.key_down=function () +{ +} + +MainMenu.prototype.key_enter=function() +{ +} + +exports.MainMenu=MainMenu;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/scene/mbtest.svg Tue Nov 23 11:58:04 2010 +0800 @@ -0,0 +1,374 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:ns0="http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="640px" + height="480px" + id="svg2383" + sodipodi:version="0.32" + inkscape:version="0.48+devel r9764 custom" + sodipodi:docname="mbtest.svg" + inkscape:output_extension="org.inkscape.output.svg.inkscape" + version="1.1"> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="1.6029106" + inkscape:cx="69.206233" + inkscape:cy="290.40921" + inkscape:current-layer="layer2" + inkscape:document-units="px" + showgrid="false" + inkscape:window-width="1400" + inkscape:window-height="974" + inkscape:window-x="271" + inkscape:window-y="25" + inkscape:window-maximized="0" /> + <defs + id="defs2385"> + <linearGradient + inkscape:collect="always" + id="linearGradient3211"> + <stop + style="stop-color:#001dff;stop-opacity:1;" + offset="0" + id="stop3213" /> + <stop + style="stop-color:#001dff;stop-opacity:0;" + offset="1" + id="stop3215" /> + </linearGradient> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="0 : 240 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="640 : 240 : 1" + inkscape:persp3d-origin="320 : 160 : 1" + id="perspective2391" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3211" + id="linearGradient3217" + x1="31.940987" + y1="28.009715" + x2="104.68548" + y2="28.009715" + gradientUnits="userSpaceOnUse" /> + <filter + inkscape:collect="always" + id="filter3295"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="0.67110109" + id="feGaussianBlur3297" /> + </filter> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3211" + id="linearGradient3316" + gradientUnits="userSpaceOnUse" + x1="31.940987" + y1="28.009715" + x2="104.68548" + y2="28.009715" /> + <linearGradient + y2="28.009715" + x2="104.68548" + y1="28.009715" + x1="31.940987" + gradientUnits="userSpaceOnUse" + id="linearGradient3542" + xlink:href="#linearGradient3211" + inkscape:collect="always" /> + <linearGradient + y2="28.009715" + x2="104.68548" + y1="28.009715" + x1="31.940987" + gradientUnits="userSpaceOnUse" + id="linearGradient3544" + xlink:href="#linearGradient3211" + inkscape:collect="always" /> + <linearGradient + inkscape:collect="always" + id="linearGradient3211-0"> + <stop + style="stop-color:#001dff;stop-opacity:1;" + offset="0" + id="stop3213-3" /> + <stop + style="stop-color:#001dff;stop-opacity:0;" + offset="1" + id="stop3215-9" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3211-0" + id="linearGradient3316-4" + gradientUnits="userSpaceOnUse" + x1="31.940987" + y1="28.009714" + x2="104.68548" + y2="28.009714" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3211-0" + id="linearGradient3217-6" + x1="31.940987" + y1="28.009714" + x2="104.68548" + y2="28.009714" + gradientUnits="userSpaceOnUse" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3211-0-5" + id="linearGradient3316-4-8" + gradientUnits="userSpaceOnUse" + x1="31.940987" + y1="28.009714" + x2="104.68548" + y2="28.009714" /> + <linearGradient + inkscape:collect="always" + id="linearGradient3211-0-5"> + <stop + style="stop-color:#001dff;stop-opacity:1;" + offset="0" + id="stop3213-3-8" /> + <stop + style="stop-color:#001dff;stop-opacity:0;" + offset="1" + id="stop3215-9-4" /> + </linearGradient> + <filter + color-interpolation-filters="sRGB" + inkscape:collect="always" + id="filter3295-1-3"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="0.67110109" + id="feGaussianBlur3297-9-7" /> + </filter> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3211-0-5" + id="linearGradient3217-6-1" + x1="31.940987" + y1="28.009714" + x2="104.68548" + y2="28.009714" + gradientUnits="userSpaceOnUse" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3211-0-5" + id="linearGradient3237" + gradientUnits="userSpaceOnUse" + x1="31.940987" + y1="28.009714" + x2="104.68548" + y2="28.009714" /> + </defs> + <metadata + id="metadata2388"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + <ns0:scenes> + <ns0:scene + start="1" + ref="g3189" + end="15" /> + <ns0:scene + start="1" + ref="s4427" /> + <ns0:scene + start="2" + ref="s4159" /> + <ns0:scene + start="5" + ref="s9524" + end="10" /> + <ns0:scene + start="15" + ref="s6546" /> + </ns0:scenes> + </metadata> + <g + inkscape:groupmode="layer" + id="layer2" + inkscape:label="Background" + style="display:inline"> + <g + id="g3189" + style=""> + <rect + style="fill:#00ffff;fill-opacity:1;stroke:#000000;stroke-opacity:1;display:inline" + id="rect2437" + width="641.95721" + height="481.62387" + x="0.93578684" + y="-10.98185" /> + <rect + style="fill:#ffcc1d;fill-opacity:1;stroke:none" + id="rect3698" + width="624.48901" + height="46.789886" + x="6.8625164" + y="5.8625031" + rx="10" + ry="10" /> + <g + style="display:inline" + transform="translate(-11.385541,2.6514388)" + id="g3303"> + <rect + y="15.22048" + x="32.440987" + height="25.57847" + width="71.744492" + id="rect2439" + style="fill:url(#linearGradient3237);fill-opacity:1;stroke:none;filter:url(#filter3295-1-3)" /> + <text + id="text3299" + y="33.312569" + x="39.927368" + style="font-size:24px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + style="font-size:16px" + y="33.312569" + x="39.927368" + id="tspan3301" + sodipodi:role="line">Action</tspan></text> + </g> + <g + style="display:inline" + id="g3308" + transform="translate(76.891374,2.9633707)"> + <rect + y="15.22048" + x="32.440987" + height="25.57847" + width="71.744492" + id="rect3310" + style="fill:url(#linearGradient3316-4-8);fill-opacity:1;stroke:none;filter:url(#filter3295-1-3)" /> + <text + id="text3312" + y="33.312569" + x="39.927368" + style="font-size:24px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + style="font-size:16px" + y="33.312569" + x="39.927368" + id="tspan3314" + sodipodi:role="line">Select</tspan></text> + </g> + </g> + <g + id="s4393" + style="" /> + </g> + <g + inkscape:groupmode="layer" + id="layer3" + inkscape:label="Buton" + style="display:inline"> + <g + id="s4427" + style="display:none" /> + <g + id="s4159" + transform="translate(170.31517,0.62386544)" + style="display:none"> + <g + transform="translate(4.9909171,0.3119319)" + id="g3370"> + <rect + style="fill:url(#linearGradient3542);fill-opacity:1;stroke:none;filter:url(#filter3295)" + id="rect3372" + width="71.744492" + height="25.57847" + x="32.440987" + y="15.22048" /> + <text + xml:space="preserve" + style="font-size:24px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + x="35.927368" + y="33.312569" + id="text3374"><tspan + sodipodi:role="line" + id="tspan3376" + x="35.927368" + y="33.312569" + style="font-size:16px">GNOME</tspan></text> + </g> + <g + transform="translate(102.93775,-0.9357981)" + id="g3380"> + <rect + style="fill:url(#linearGradient3544);fill-opacity:1;stroke:none;filter:url(#filter3295)" + id="rect3382" + width="71.744492" + height="25.57847" + x="32.440987" + y="15.22048" /> + <text + xml:space="preserve" + style="font-size:24px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + x="39.927368" + y="33.312569" + id="text3384"><tspan + sodipodi:role="line" + id="tspan3386" + x="39.927368" + y="33.312569" + style="font-size:16px">AAA</tspan></text> + </g> + </g> + <g + id="s9524" + transform="translate(90.460441,64.258106)" + style="display:none"> + <rect + x="0" + y="0" + width="100" + height="100" + id="rect3118" /> + </g> + <g + id="s6546" + style="display:none"> + <rect + x="0" + y="0" + width="100" + height="100" + style="fill:#ff00" + id="rect3116" /> + </g> + </g> + <g + id="layer1" + inkscape:label="Layer 1" + inkscape:groupmode="layer" + style="display:inline" /> +</svg>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/scene/scene.js Tue Nov 23 11:58:04 2010 +0800 @@ -0,0 +1,11 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var svg = require("svg"); +var mbapp = require("mbapp"); +var sys=require("sys"); +var animate=require("animate"); +var fs = require("fs"); +var main=require("./mainmenu"); +app = new mbapp.app(":0.0",800,600); +scene=new main.MainMenu(app); +app.loop();
--- a/nodejs/mbapp.js Tue Nov 23 11:55:12 2010 +0800 +++ b/nodejs/mbapp.js Tue Nov 23 11:58:04 2010 +0800 @@ -145,6 +145,34 @@ } } + +app.prototype.changeScene=function(s) { + var nth; + if (typeof(s)=='number') { + var i; + nth = s; + } else { + nth = this.svg.getFrameNumber(s); + if (nth == -1) return; + } + var scenes = this.svg.scenes; + for(i=0;i<scenes.length;i++) { + try { + if (nth >=scenes[i].start && nth <=scenes[i].end) { + this.get(scenes[i].ref).show(); + } else { + this.get(scenes[i].ref).hide(); + } + } catch(e) { + sys.puts(e); + sys.puts(scenes[i].ref); + } + } +} +app.prototype.addSceneListener=function(n, cb) { + sys.puts("This is not implemented yet") +} + var app_with_win = function(display, win) { var self = this; var mb_rt;
--- a/nodejs/svg.js Tue Nov 23 11:55:12 2010 +0800 +++ b/nodejs/svg.js Tue Nov 23 11:58:04 2010 +0800 @@ -72,12 +72,16 @@ var n = nodes[k].name(); if (n == "defs") { this.parseDefs(coord,nodes[k]); + } else if (n == "metadata") { + this.parseMetadata(coord,nodes[k]); } else if (n == "g") { this.parseGroup(accu,coord,'root_coord',nodes[k]); } } } + + loadSVG.prototype.leaveSVG=function() { var p = this.pgstack.pop(); @@ -104,6 +108,12 @@ name = mbname.value(); mb_rt.mbnames[name] = obj; } + try { + var gname = n.attr('id').value(); + sys.puts(gname); + mb_rt.mbnames[gname] = obj; + } catch(e) { + } } function getInteger(n,name) @@ -1117,7 +1127,8 @@ href = href.value(); var hrefid = href.substring(1); pstops = this.stop_ref[hrefid]; - stops = pstops.concat(stops); + if (pstops) + stops = pstops.concat(stops); var hrefgr = this.gradients[hrefid]; if(typeof x1 == "undefined") @@ -1191,6 +1202,44 @@ this.stop_ref[id] = stops; } +loadSVG.prototype.parseScenes=function(coord,node) { + var nodes = node.childNodes(); + + for(k in nodes) { + var name = nodes[k].name(); + if (name == 'scene') { + var node = nodes[k]; + + scene = new Object(); + scene.start = parseInt(node.attr('start').value()); + try { + scene.end = parseInt(node.attr('end').value()); + } catch(e) { + scene.end = scene.start; + } + scene.ref = node.attr('ref').value(); + + try { + this.scenenames[node.attr('name').value()] = scene.start; + } catch(e) { + } + this.scenes.push(scene); + } + } +} + +loadSVG.prototype.parseMetadata=function(coord,node) { + var nodes = node.childNodes(); + + for(k in nodes) { + var name = nodes[k].name(); + if (name == 'scenes') { + this.scenes=[]; + this.scenenames={}; + this.parseScenes(coord,nodes[k]); + } + } +} loadSVG.prototype.parseDefs=function(root,n) { var k;
--- a/pyink/MBScene.py Tue Nov 23 11:55:12 2010 +0800 +++ b/pyink/MBScene.py Tue Nov 23 11:58:04 2010 +0800 @@ -7,6 +7,7 @@ from lxml import etree import random import traceback +import time # Please refer to # http://www.assembla.com/wiki/show/MadButterfly/Inkscape_extention @@ -93,11 +94,13 @@ for n in node.childList(): if n.repr.name() == 'ns0:scenes': self.scenemap={} - cur = int(n.repr.attribute("current")) + try: + cur = int(n.repr.attribute("current")) + except: + cur = 1 self.current = cur for s in n.childList(): - print '--->',s.repr.name() if s.repr.name() == 'ns0:scene': try: start = int(s.repr.attribute("start")) @@ -124,6 +127,23 @@ pass pass pass + if self.scenemap==None: + self.desktop.doc().root().repr.setAttribute("xmlns:ns0","http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd",True) + scenes = self.desktop.doc().rdoc.createElement("ns0:scenes") + node.repr.appendChild(scenes) + def update(self): + doc = self.desktop.doc().root() + rdoc = self.desktop.doc().rdoc + for node in doc.childList(): + if node.repr.name() == 'svg:metadata': + for t in node.childList(): + if t.repr.name() == "ns0:scenes": + node.repr.removeChild(t.repr) + ns = rdoc.createElement("ns0:scenes") + node.repr.appendChild(ns) + for layer in range(0,len(self._framelines)): + lobj = self._framelines[layer] + lobj.addScenes(rdoc,ns) def parseScene(self): @@ -153,10 +173,6 @@ if scmap == None: lyobj.current_scene.append(scene) continue - if self.current <= scmap[1] and \ - self.current >= scmap[0]: - oldscene = scene - pass except: lyobj.current_scene.append(scene) continue @@ -167,16 +183,10 @@ lyobj.current_scene.append(scene) pass pass - - if oldscene != None: - # Put the objects back to the current scene - # for o in lyobj.current_scene: - # print o.tag - # oldscene.append(o) - pass pass pass + self.collectID() self.dumpID() pass @@ -207,7 +217,6 @@ def dumpID(self): for a,v in self.ID.items(): - print a pass pass @@ -228,273 +237,158 @@ new scene. """ - nth = self.last_cell.nScene - layer = self.getLayer(self.last_cell.layer) - x = self.last_cell.nScene - y = self.last_cell.nLayer - if layer == None: return - for i in range(0,len(layer.scenes)): - s = layer.scenes[i] - if nth >= s.start and nth <= s.end: - if nth == s.start: return - newscene = Scene(DuplicateNode(s.node),nth,s.end) - newscene.node.setId(self.newID()) - layer.scenes.insert(i+1,newscene) - layer.scenes[i].end = nth-1 - btn = self.newCell('start.png') - btn.nScene = nth - btn.layer = layer - btn.nLayer = y - self.grid.remove(self.last_cell) - self.grid.attach(btn, x,x+1,y,y+1,0,0,0,0) - return - pass - - if len(layer.scenes) > 0: - last = nth - lastscene = None - for s in layer.scenes: - if s.end < nth and last < s.end: - last = s.end - lastscene = s - pass - pass - - for x in range(last+1, nth): - btn = self.newCell('fill.png') - btn.nScene = x - btn.layer = layer.node.getId() - btn.nLayer = y - self.grid.attach(btn, x, x+1, y , y+1,0,0,0,0) - pass - - if lastscene == None: - node = etree.Element(_scene) - node.setId(self.newID()) - newscene = Scene(node,nth,nth) - else: - lastscene.end = nth-1 - newscene = Scene(DuplicateNode(lastscene.node),nth,nth) - newscene.node.setId(self.newID()) - pass - - layer.scenes.append(newscene) - btn = self.newCell('start.png') - x = self.last_cell.nScene - y = self.last_cell.nLayer - btn.nScene = nth - btn.layer = layer.node.getId() - btn.nLayer = y - self.grid.attach(btn, x, x+1, y, y+1,0,0,0,0) - else: - # This is the first scene in the layer - node = etree.Element(_scene) - node.repr.setId(self.newID()) - newscene = Scene(node,nth,nth) - layer.scenes.append(newscene) - btn = self.newCell('start.png') - btn.nScene = nth - btn.layer = layer.node.getId() - btn.nLayer = y - self.grid.attach(btn, x, x+1, y, y+1,0,0,0,0) - pass - pass + x = self.last_frame + y = self.last_line + rdoc = self.desktop.doc().rdoc + ns = rdoc.createElement("svg:g") + txt = rdoc.createElement("svg:rect") + txt.setAttribute("x","0",True) + txt.setAttribute("y","0",True) + txt.setAttribute("width","100",True) + txt.setAttribute("height","100",True) + txt.setAttribute("style","fill:#ff00",True) + ns.appendChild(txt) + gid = self.last_line.node.label()+self.newID() + self.ID[gid]=1 + ns.setAttribute("id",gid,True) + ns.setAttribute("inkscape:groupmode","layer",True) + self.last_line.node.repr.appendChild(ns) + print 'Add key ', x + self.last_line.add_keyframe(x,ns) + self.update() + self.last_line.update() def removeKeyScene(self): - nth = self.last_cell.nScene - try: - layer = self.getLayer(self.last_cell.layer) - except: - return - x = self.last_cell.nScene - y = self.last_cell.nLayer - for i in range(0,len(layer.scenes)): - s = layer.scenes[i] - if nth == s.start: - if i == 0: - for j in range(s.start,s.end+1): - btn = self.newCell('empty.png') - btn.nScene = nth - btn.layer = layer - btn.nLayer = y - self.grid.attach(btn, j,j+1,y,y+1,0,0,0,0) - pass - layer.scenes.remove(s) + nth = self.last_frame + y = self.last_line + rdoc = self.desktop.doc().rdoc + i = 0 + layer = self.last_line + while i < len(layer._keys): + s = layer._keys[i] + print "nth:%d idx %d" % (nth,s.idx) + if nth > s.idx: + if i == len(layer._keys)-1: + return + if nth == s.idx: + if s.left_tween: + # This is left tween, we move the keyframe one frame ahead + if s.idx == layer._keys[i-1].idx: + layer._keys[i].ref.parent().removeChild(layer._keys[i].ref) + self.last_line.rm_keyframe(nth) + self.last_line.rm_keyframe(nth-1) + else: + s.idx = s.idx-1 else: - if s.start == layer.scenes[i-1].end+1: - # If the start of the delete scene segment is - # the end of the last scene segmenet, convert - # all scenes in the deleted scene segmenet to - # the last one - layer.scenes[i-1].end = s.end - layer.scenes.remove(s) - btn = self.newCell('fill.png') + layer._keys[i].ref.parent().removeChild(layer._keys[i].ref) + if s.right_tween: + self.last_line.rm_keyframe(layer._keys[i+1].idx) + self.last_line.rm_keyframe(nth) + else: + self.last_line.rm_keyframe(nth) - btn.nScene = nth - btn.layer = layer - btn.nLayer = y - self.grid.attach(btn, x,x+1,y,y+1,0,0,0,0) + self.update() + self.last_line._draw_all_frames() + self.last_line.update() + return + i = i + 1 + def extendScene(self): + nth = self.last_frame + layer = self.last_line + i = 0 + while i < len(layer._keys): + s = layer._keys[i] + if s.right_tween: + if nth > s.idx: + if nth <= layer._keys[i+1].idx: + return + try: + if nth <= layer._keys[i+2].idx: + layer._keys[i+1].idx = nth + layer.draw_all_frames() + self.update() + self.setCurrentScene(nth) + self.last_line.update() + return + else: + # We may in the next scene + i = i + 2 + pass + except: + # This is the last keyframe, extend the keyframe by + # relocate the location of the keyframe + layer._keys[i+1].idx = nth + layer._draw_all_frames() + self.update() + self.last_line.update() + self.setCurrentScene(nth) + return + else: + # We are in the front of all keyframes + return + else: + # This is a single keyframe + if nth < s.idx: + return + if nth == s.idx: + return + try: + if nth < layer._keys[i+1].idx: + # We are after a single keyframe and no scene is + # available here. Create a new tween here + idx = layer._keys[i].idx + layer.add_keyframe(nth,layer._keys[i].ref) + layer.tween(idx) + layer._draw_all_frames() + self.update() + self.setCurrentScene(nth) + self.last_line.update() + return else: - # Convert all scenes into empty cell - layer.scenes.remove(s) - for j in range(s.start,s.end+1): - btn = self.newCell('empty.png') - btn.nScene = nth - btn.layer = layer - btn.nLayer = y - self.grid.attach(btn, j,j+1,y,y+1,0,0,0,0) - pass + # We may in the next scene + i = i + 1 pass pass - return + except: + # This is the last scene, create a new one + idx = layer._keys[i].idx + layer.add_keyframe(nth,layer._keys[i].ref) + layer.tween(idx) + layer._draw_all_frames() + self.update() + self.setCurrentScene(nth) + self.last_line.update() + return + pass pass pass - def extendScene(self): - nth = self.last_cell.nScene - try: - layer = self.getLayer(self.last_cell.layer) - except: - traceback.print_exc() - return - x = self.last_cell.nScene - y = self.last_cell.nLayer - if layer == None: - return - - for i in range(0,len(layer.scenes)-1): - s = layer.scenes[i] - if nth >= layer.scenes[i].start and nth <= layer.scenes[i].end: - return - pass - - for i in range(0,len(layer.scenes)-1): - s = layer.scenes[i] - if nth >= layer.scenes[i].start and nth < layer.scenes[i+1].start: - for j in range(layer.scenes[i].end+1, nth+1): - btn = self.newCell('fill.png') - btn.nScene = nth - btn.nLayer = y - btn.layer = self.last_cell.layer - self.grid.attach(btn, j,j+1,y,y+1,0,0,0,0) - layer.scenes[i].end = nth - return - pass - if len(layer.scenes) > 0 and \ - nth > layer.scenes[len(layer.scenes)-1].end: - for j in range(layer.scenes[len(layer.scenes)-1].end+1, nth+1): - btn = self.newCell('fill.png') - btn.nScene = nth - btn.nLayer = y - btn.layer = self.last_cell.layer - self.grid.attach(btn, j,j+1,y,y+1,0,0,0,0) - pass - layer.scenes[len(layer.scenes)-1].end = nth - pass - pass - pass def setCurrentScene(self,nth): self.current = nth - for layer in self.layers: - for s in layer.scenes: - if nth >= s.start and nth <= s.end: - s.node.repr.setAttribute("style","",True) - # print "Put the elemenets out" - layer.nodes = [] - - # for o in s.node: - # print " ",o.tag - # layer.nodes.append(o) - # for o in s.node: - # s.node.remove(o) + for layer in self._framelines: + i=0 + while i < len(layer._keys): + s = layer._keys[i] + print s.ref.attribute("id"),s.idx,s.left_tween,s.right_tween + if s.right_tween is False: + if nth == s.idx+1: + s.ref.setAttribute("style","",True) + else: + s.ref.setAttribute("style","display:none",True) + i = i + 1 + continue + + if nth >= (s.idx+1) and nth <= (layer._keys[i+1].idx+1): + s.ref.setAttribute("style","",True) else: - s.node.repr.setAttribute("style","display:none",True) - pass + s.ref.setAttribute("style","display:none",True) + i = i + 2 pass pass pass - def generate(self): - newdoc = deepcopy(self.document) - root = newdoc.getroot() - has_scene = False - for n in root: - if n.tag == '{http://www.w3.org/2000/svg}metadata': - for nn in n: - if nn.tag == _scenes: - nn.clear() - nn.set("current", "%d" % self.current) - scenes = [] - for l in self.layers: - for s in l.scenes: - id = s.node.get("id") - scene = etree.Element(_scene) - scene.set("ref", id) - if s.start == s.end: - scene.set("start", "%d" % s.start) - else: - scene.set("start", "%d" % s.start) - scene.set("end", "%d" % s.end) - pass - - scenes.append(scene) - pass - pass - for s in scenes: - nn.append(s) - pass - has_scene = True - pass - pass - if has_scene == False: - scenes = etree.Element(_scenes) - scenes.set("current","%d" % self.current) - for l in self.layers: - for s in l.scenes: - scene = etree.Element(_scene) - scene.set("ref", s.node.get("id")) - if s.start == s.end: - scene.set("start", "%d" % s.start) - else: - scene.set("start", "%d" % s.start) - scene.set("end", "%d" % s.end) - pass - scenes.append(scene) - pass - pass - n.append(scenes) - pass - pass - if n.tag == '{http://www.w3.org/2000/svg}g': - root.remove(n) - pass - pass - - for l in self.layers: - # Duplicate all attribute of the layer - lnode = etree.Element("{http://www.w3.org/2000/svg}g") - for a,v in l.node.attrib.items(): - lnode.set(a,v) - pass - for n in l.nodes: - lnode.append(n) - pass - root.append(lnode) - for s in l.scenes: - snode = etree.Element("{http://www.w3.org/2000/svg}g") - for a,v in s.node.attrib.items(): - snode.set(a,v) - pass - for n in s.node: - snode.append(deepcopy(n)) - pass - lnode.append(snode) - pass - pass - self.document = newdoc - pass def newCell(self,file): img = gtk.Image() @@ -505,6 +399,22 @@ btn.modify_bg(gtk.STATE_NORMAL, btn.get_colormap().alloc_color("gray")) return btn + def onCellClick(self,line,frame,but): + self.last_line = line + self.last_frame = frame + self.last_line.active_frame(frame) + self.doEditScene(frame) + + + def _remove_active_frame(self,widget,event): + """ + Hide all hover frames. This is a hack. We should use the lost focus event + instead in the future to reduce the overhead. + """ + for f in self._framelines: + if f != widget: + f.hide_hover() + def _create_framelines(self): import frameline self.scrollwin = gtk.ScrolledWindow() @@ -520,29 +430,47 @@ ruler = frameline.frameruler(nframes) ruler.set_size_request(nframes * 10, 20) ruler.show() - vbox.pack_start(ruler, False) + hbox = gtk.HBox() + label=gtk.Label('') + label.set_size_request(100,0) + hbox.pack_start(label,expand=False,fill=True) + hbox.pack_start(ruler) + vbox.pack_start(hbox, False) # # Add a frameline for each layer # self._framelines = [] - for i in range(len(self.layers)): + for i in range(len(self.layers)-1,-1,-1): line = frameline.frameline(nframes) + hbox = gtk.HBox() + label = gtk.Label(self.layers[i].node.label()) + label.set_size_request(100,0) + hbox.pack_start(label,expand=False,fill=True) + hbox.pack_start(line) line.set_size_request(nframes * 10, 20) - vbox.pack_start(line, False) + vbox.pack_start(hbox, False) + line.label = label self._framelines.append(line) + line.connect(line.FRAME_BUT_PRESS, self.onCellClick) + line.nLayer = i + line.node = self.layers[i].node + line.layer = self.layers[i] + line.connect('motion-notify-event', self._remove_active_frame) pass pass ## \brief Update conetent of frameliens according layers. # def _update_framelines(self): - for layer_i, layer in enumerate(self.layers): + for frameline in self._framelines: + layer = frameline.layer + frameline.label.set_text(frameline.node.label()) for scene in layer.scenes: - frameline = self._framelines[layer_i] - for scene_i in range(scene.start, scene.stop + 1): - frameline.add_keyframe(scene_i) - pass + frameline.add_keyframe(scene.start-1,scene.node.repr) + if scene.start != scene.end: + frameline.add_keyframe(scene.end-1,scene.node.repr) + frameline.tween(scene.start-1) pass pass pass @@ -559,30 +487,28 @@ pass def doEditScene(self,w): - self.setCurrentScene(self.last_cell.nScene) + self.setCurrentScene(self.last_frame+1) pass def doInsertKeyScene(self,w): - # self.insertKeyScene() + self.insertKeyScene() # self.grid.show_all() return def doRemoveScene(self,w): - # self.removeKeyScene() - # self.grid.show_all() - # self.generate() + self.removeKeyScene() return def doExtendScene(self,w): self.extendScene() - self.grid.show_all() + #self.grid.show_all() pass def addButtons(self,hbox): - btn = gtk.Button('Edit') - btn.connect('clicked', self.doEditScene) - hbox.pack_start(btn,expand=False,fill=False) + #btn = gtk.Button('Edit') + #btn.connect('clicked', self.doEditScene) + #hbox.pack_start(btn,expand=False,fill=False) btn = gtk.Button('Insert Key') btn.connect('clicked',self.doInsertKeyScene) hbox.pack_start(btn,expand=False,fill=False) @@ -604,26 +530,6 @@ gtk.main_quit() pass - def onConfirmDelete(self): - if self.scenemap == None: - vbox = gtk.VBox(False,0) - vbox.pack_start(gtk.Label('Convert the SVG into a MadButterfly' - ' SVG file. All current element will' - ' be delted')) - hbox = gtk.HBox(False,0) - self.button = gtk.Button('OK') - hbox.pack_start(self.button,expand=False,fill=False) - self.button.connect('clicked', self.onOK) - self.button = gtk.Button('Cancel') - hbox.pack_start(self.button,expand=False,fill=False) - self.button.connect("clicked", self.onQuit) - vbox.pack_start(hbox,expand=False,fill=False) - self.window.add(vbox) - self.window.show_all() - gtk.main() - self.window.remove(vbox) - pass - pass def show(self): self.OK = True @@ -633,24 +539,17 @@ vbox = gtk.VBox(False,0) self.desktop.getToplevel().child.child.pack_end(vbox,expand=False) self.window = vbox + vbox = gtk.VBox(False,0) + self.window.pack_start(vbox,expand=False) + vbox.pack_start(self.scrollwin,expand=False) + self.vbox = vbox + hbox=gtk.HBox(False,0) + self.addButtons(hbox) + vbox.pack_start(hbox,expand=False) + # self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) # self.window.connect("destroy", gtk.main_quit) # self.window.set_position(gtk.WIN_POS_MOUSE) - if self.scenemap == None: - self.onConfirmDelete() - pass - if self.OK: - vbox = gtk.VBox(False,0) - self.window.pack_start(vbox,expand=False) - vbox.pack_start(self.scrollwin,expand=False) - self.vbox = vbox - hbox=gtk.HBox(False,0) - self.addButtons(hbox) - vbox.pack_start(hbox,expand=False) - else: - return - - # self.window.set_size_request(600,200) self.window.show_all() pass
--- a/pyink/frameline.py Tue Nov 23 11:55:12 2010 +0800 +++ b/pyink/frameline.py Tue Nov 23 11:58:04 2010 +0800 @@ -16,6 +16,7 @@ self.left_tween = False self.right_tween = False self.right_tween_type = 0 + self.ref='' pass pass @@ -121,6 +122,10 @@ _normal_border = 0xaaaaaa # border color of normal frames. _active_border = 0xff3030 # border color of an active frame _hover_border_color = 0xa0a0a0 # border when the pointer over a frame + # tween types + _tween_type_none=0 + _tween_type_shape=3 + FRAME_BUT_PRESS = 'frame-button-press' @@ -154,9 +159,13 @@ but = event.button self.emit(frameline.FRAME_BUT_PRESS, frame, but) pass + def hide_hover(self): + if self._active_frame != self._last_hover: + self._draw_normal_frame(self._last_hover) def _motion_hdl(self, widget, event): frame = int(event.x / self._frame_width) + if frame < self._num_frames and frame >= 0: self._draw_hover(frame) pass @@ -299,6 +308,12 @@ i = last_tween_key.idx + 1 pass else: + if key.idx == i: + key_i=key_i+1 + try: + key = self._keys[key_i] + except: + key = keyframe(self._num_frames) self._draw_normal_frame(i) i = i + 1 pass @@ -343,11 +358,15 @@ gc.set_rgb_fg_color(color) for key in self._keys: + if key.left_tween is True and lastkey.right_tween_type == frameline._tween_type_none: + continue + mark_sz = self._key_mark_sz mark_x = int((key.idx + 0.5) * self._frame_width - mark_sz / 2) mark_y = w_h * 2 / 3 - mark_sz / 2 win.draw_rectangle(gc, True, mark_x, mark_y, mark_sz, mark_sz) + lastkey = key pass pass @@ -393,7 +412,7 @@ last_pos = last_pos + 1 pass - return first_pox, last_pos + return first_pos, last_pos ## \brief Redraw a frame specified by an index. # @@ -432,7 +451,9 @@ for i in range(first_pos, last_pos + 1): key = self._keys[i] - self._draw_keyframe(key.idx) + if key.left_tween is False or lastkey.right_tween_type != frameline._tween_type_none: + self._draw_keyframe(key.idx) + lastkey = key pass pass else: # not in tween @@ -481,7 +502,6 @@ win = self.window x, y, w, h, depth = win.get_geometry() - self._draw_all_frames() self._draw_keyframes() if self._active_frame != -1: @@ -493,7 +513,7 @@ # # A key frame is the frame that user specify actions. For # example, move a object or add new objects at the frame. - def add_keyframe(self, idx): + def add_keyframe(self, idx,ref=None): key_indic = [key.idx for key in self._keys] if idx in key_indic: return @@ -503,6 +523,7 @@ insert_pos = key_indic.index(idx) key = keyframe(idx) + key.ref = ref self._keys[insert_pos:insert_pos] = [key] if insert_pos > 0 and self._keys[insert_pos - 1].right_tween: key.left_tween = True @@ -516,8 +537,14 @@ pass def rm_keyframe(self, idx): + found=False + for i in range(0,len(self._keys)): + if self._keys[i].idx == idx: + idx = i + found = True + break + if not found: return key = self._keys[idx] - del self._keys[idx] if key.right_tween ^ key.left_tween: # @@ -526,13 +553,12 @@ if key.right_tween: right_key = self._keys[idx] right_key.left_tween = False - rdraw_range = (right_key.idx, idx + 1) + redraw_range = (right_key.idx, idx + 1) else: left_key = self._keys[idx - 1] left_key.right_key = False redraw_range = (idx, left_key.idx + 1) pass - for i in range(*redraw_range): self._redraw_frame(i) pass @@ -540,6 +566,7 @@ self._redraw_frame(idx) pass + del self._keys[idx] self._draw_active() pass @@ -589,6 +616,23 @@ self._keys = [] pass + def addScenes(self,rdoc,node): + for i in range(0,len(self._keys)): + key = self._keys[i] + if key.left_tween is True: continue + if key.right_tween is True: + ss = rdoc.createElement("ns0:scene") + node.appendChild(ss) + ss.setAttribute("start", str(key.idx+1),True) + ss.setAttribute("ref",key.ref.attribute("id"),True) + ss.setAttribute("end", str(self._keys[i+1].idx+1),True) + else: + ss = rdoc.createElement("ns0:scene") + node.appendChild(ss) + ss.setAttribute("start", str(key.idx+1),True) + ss.setAttribute("ref",key.ref.attribute("id"),True) + + ## \brief Start future drawing actions # def start_drawing(self): @@ -616,13 +660,14 @@ fl = frameline(40) fl.set_size_request(300, 20) + fl.add_keyframe(15) fl.add_keyframe(3) + fl.tween(3) fl.add_keyframe(9) - fl.add_keyframe(15) fl.add_keyframe(20) - fl.tween(3) - fl.tween(15, 1) - fl.active_frame(15) + fl.tween(9) + fl.active_frame(1) + fl.rm_keyframe(15) print 'num of frames: %d' % (len(fl)) def press_sig(fl, frame, but):
--- a/pyink/mbtest.svg Tue Nov 23 11:55:12 2010 +0800 +++ b/pyink/mbtest.svg Tue Nov 23 11:58:04 2010 +0800 @@ -15,7 +15,7 @@ height="480px" id="svg2383" sodipodi:version="0.32" - inkscape:version="0.48+devel r9760 custom" + inkscape:version="0.48+devel r9764 custom" sodipodi:docname="mbtest.svg" inkscape:output_extension="org.inkscape.output.svg.inkscape" version="1.1"> @@ -27,14 +27,14 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1.6029106" - inkscape:cx="229.53957" - inkscape:cy="240.5" - inkscape:current-layer="g3380" + inkscape:cx="69.206233" + inkscape:cy="290.40921" + inkscape:current-layer="layer2" inkscape:document-units="px" showgrid="false" inkscape:window-width="1400" inkscape:window-height="974" - inkscape:window-x="0" + inkscape:window-x="271" inkscape:window-y="25" inkscape:window-maximized="0" /> <defs @@ -102,18 +102,6 @@ id="linearGradient3544" xlink:href="#linearGradient3211" inkscape:collect="always" /> - <filter - height="1.34432" - y="-0.17216" - width="1.0257982" - x="-0.012899101" - id="filter3854" - inkscape:collect="always"> - <feGaussianBlur - id="feGaussianBlur3856" - stdDeviation="3.3563945" - inkscape:collect="always" /> - </filter> <linearGradient inkscape:collect="always" xlink:href="#linearGradient3211-0" @@ -135,15 +123,6 @@ offset="1" id="stop3215-9" /> </linearGradient> - <filter - color-interpolation-filters="sRGB" - inkscape:collect="always" - id="filter3295-1"> - <feGaussianBlur - inkscape:collect="always" - stdDeviation="0.67110109" - id="feGaussianBlur3297-9" /> - </filter> <linearGradient inkscape:collect="always" xlink:href="#linearGradient3211-0" @@ -153,6 +132,54 @@ x2="104.68548" y2="28.009714" gradientUnits="userSpaceOnUse" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3211-0-5" + id="linearGradient3316-4-8" + gradientUnits="userSpaceOnUse" + x1="31.940987" + y1="28.009714" + x2="104.68548" + y2="28.009714" /> + <linearGradient + inkscape:collect="always" + id="linearGradient3211-0-5"> + <stop + style="stop-color:#001dff;stop-opacity:1;" + offset="0" + id="stop3213-3-8" /> + <stop + style="stop-color:#001dff;stop-opacity:0;" + offset="1" + id="stop3215-9-4" /> + </linearGradient> + <filter + color-interpolation-filters="sRGB" + inkscape:collect="always" + id="filter3295-1-3"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="0.67110109" + id="feGaussianBlur3297-9-7" /> + </filter> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3211-0-5" + id="linearGradient3217-6-1" + x1="31.940987" + y1="28.009714" + x2="104.68548" + y2="28.009714" + gradientUnits="userSpaceOnUse" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3211-0-5" + id="linearGradient3237" + gradientUnits="userSpaceOnUse" + x1="31.940987" + y1="28.009714" + x2="104.68548" + y2="28.009714" /> </defs> <metadata id="metadata2388"> @@ -164,97 +191,100 @@ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> </cc:Work> </rdf:RDF> - <ns0:scenes - current="1"> + <ns0:scenes> <ns0:scene - end="2" start="1" - ref="s4393" /> + ref="g3189" + end="15" /> <ns0:scene start="1" ref="s4427" /> <ns0:scene start="2" ref="s4159" /> + <ns0:scene + start="5" + ref="s9524" + end="10" /> + <ns0:scene + start="15" + ref="s6546" /> </ns0:scenes> </metadata> <g inkscape:groupmode="layer" id="layer2" inkscape:label="Background" - style="display:none"> - <rect - style="fill:#00ffff;fill-opacity:1;stroke:#000000;stroke-opacity:1" - id="rect2437" - width="641.95721" - height="481.62387" - x="0" - y="-0.37614822" /> - <rect - ry="10" - rx="10" - y="10.780138" - x="8.5505733" - height="46.789886" - width="624.48901" - id="rect3700" - style="fill:#ff831d;fill-opacity:1;stroke:none;filter:url(#filter3854)" /> - <rect - ry="10" - rx="10" - y="5.8625031" - x="6.8625164" - height="46.789886" - width="624.48901" - id="rect3698" - style="fill:#ffcc1d;fill-opacity:1;stroke:none" /> + style="display:inline"> + <g + id="g3189" + style=""> + <rect + style="fill:#00ffff;fill-opacity:1;stroke:#000000;stroke-opacity:1;display:inline" + id="rect2437" + width="641.95721" + height="481.62387" + x="0.93578684" + y="-10.98185" /> + <rect + style="fill:#ffcc1d;fill-opacity:1;stroke:none" + id="rect3698" + width="624.48901" + height="46.789886" + x="6.8625164" + y="5.8625031" + rx="10" + ry="10" /> + <g + style="display:inline" + transform="translate(-11.385541,2.6514388)" + id="g3303"> + <rect + y="15.22048" + x="32.440987" + height="25.57847" + width="71.744492" + id="rect2439" + style="fill:url(#linearGradient3237);fill-opacity:1;stroke:none;filter:url(#filter3295-1-3)" /> + <text + id="text3299" + y="33.312569" + x="39.927368" + style="font-size:24px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + style="font-size:16px" + y="33.312569" + x="39.927368" + id="tspan3301" + sodipodi:role="line">Action</tspan></text> + </g> + <g + style="display:inline" + id="g3308" + transform="translate(76.891374,2.9633707)"> + <rect + y="15.22048" + x="32.440987" + height="25.57847" + width="71.744492" + id="rect3310" + style="fill:url(#linearGradient3316-4-8);fill-opacity:1;stroke:none;filter:url(#filter3295-1-3)" /> + <text + id="text3312" + y="33.312569" + x="39.927368" + style="font-size:24px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + style="font-size:16px" + y="33.312569" + x="39.927368" + id="tspan3314" + sodipodi:role="line">Select</tspan></text> + </g> + </g> <g id="s4393" style="" /> - <g - transform="translate(-8.8900812,0.1559783)" - id="g3303"> - <rect - y="15.22048" - x="32.440987" - height="25.57847" - width="71.744492" - id="rect2439" - style="fill:url(#linearGradient3217-6);fill-opacity:1;stroke:none;filter:url(#filter3295-1)" /> - <text - id="text3299" - y="33.312569" - x="39.927368" - style="font-size:24px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - style="font-size:16px" - y="33.312569" - x="39.927368" - id="tspan3301" - sodipodi:role="line">Action</tspan></text> - </g> - <g - id="g3308" - transform="translate(79.386834,0.4679103)"> - <rect - y="15.22048" - x="32.440987" - height="25.57847" - width="71.744492" - id="rect3310" - style="fill:url(#linearGradient3316-4);fill-opacity:1;stroke:none;filter:url(#filter3295-1)" /> - <text - id="text3312" - y="33.312569" - x="39.927368" - style="font-size:24px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - style="font-size:16px" - y="33.312569" - x="39.927368" - id="tspan3314" - sodipodi:role="line">Select</tspan></text> - </g> </g> <g inkscape:groupmode="layer" @@ -267,7 +297,7 @@ <g id="s4159" transform="translate(170.31517,0.62386544)" - style=""> + style="display:none"> <g transform="translate(4.9909171,0.3119319)" id="g3370"> @@ -313,6 +343,28 @@ style="font-size:16px">AAA</tspan></text> </g> </g> + <g + id="s9524" + transform="translate(90.460441,64.258106)" + style="display:none"> + <rect + x="0" + y="0" + width="100" + height="100" + id="rect3118" /> + </g> + <g + id="s6546" + style="display:none"> + <rect + x="0" + y="0" + width="100" + height="100" + style="fill:#ff00" + id="rect3116" /> + </g> </g> <g id="layer1"