# HG changeset patch # User wycc # Date 1239508733 -28800 # Node ID 45e04408fc19168cacb458a8c5719dcfb768d838 # Parent f3e6ac47752c3dca260fd57dac684cd0673f6fbe Implement stub functions for the MadSwatter integration. diff -r f3e6ac47752c -r 45e04408fc19 inkscape/firefox/content/inkscape.js --- a/inkscape/firefox/content/inkscape.js Fri Apr 10 22:46:01 2009 +0800 +++ b/inkscape/firefox/content/inkscape.js Sun Apr 12 11:58:53 2009 +0800 @@ -9,6 +9,17 @@ return reg.test(str); } +function dumpXML(xml) +{ + return (new XMLSerializer()).serializeToString(xml); +} + + +function showInWindow(content) +{ + $('#debug').append("
"+content+"
"); +} + function dumpObj(obj, name, indent, depth) { if (depth > MAX_DUMP_DEPTH) { return indent + name + ": \n"; @@ -84,6 +95,7 @@ ink.innerHTML = ""; this.isInProgress = 0; this.callback = null; + this.animation = new MadSwatter(this); setTimeout("inkscape.fetchDocument()",4000); } @@ -123,6 +135,7 @@ { mbsvg = new MBSVGString(resp.Body[0].GETDOCResponse[0].Result[0].Text); mbsvg.renderUI(); + this.mbsvg = mbsvg; if (this.callback) this.callback(mbsvg); @@ -286,6 +299,35 @@ $('#newsymbolname').val(val); } +Inkscape.prototype.editAnimation=function () { + inkscape.fetchDocument(inkscape.editAnimationCallback); +} + +Inkscape.prototype.editAnimationCallback=function(mbsvg) { + + inkscape.animation.edit(mbsvg); + return; + + + var sodi = mbsvg.getElementsByTag('sodipodi:namedview')[0]; + + var layer=sodi.getAttribute('inkscape:current-layer'); + var animation = mbsvg.getElementsByTag('animationlist')[0]; + var alist = animation.getElementsByTag('animation'); + var len = alist.length; + var dialog = $('animation'); + dialog.dialog('open'); + var html = new Array(); + html.append(''); + $('animation_list').html(html.join("\n")); + dialog.show(); +} + + Inkscape.prototype.loadSymbolScreen=function (mbsvg) { // Swap the left side to be the SVG element tree. var i,l; @@ -352,6 +394,8 @@ function MBSVG_loadFromDoc(self,xmlDoc) { + var top = xmlDoc.getElementsByTagNameNS("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","scenes")[0]; + self.current = top.getAttribute("current"); var scenesNode = xmlDoc.getElementsByTagNameNS("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","scene"); if (scenesNode == null) { alert('This is not a valid scene file'); @@ -465,6 +509,65 @@ } + +/** + * Return a new XML document that all objects which is not in the current scene are deleted. + * + * This function will traverse all scenes. For each scene which is not in the current scene, we will delete the reference group. + */ + +function deepcopy(obj) +{ + var seenObjects = []; + var mappingArray = []; + var f = function(simpleObject) { + var indexOf = seenObjects.indexOf(simpleObject); + if (indexOf == -1) { + switch (Ext.type(simpleObject)) { + case 'object': + seenObjects.push(simpleObject); + var newObject = {}; + mappingArray.push(newObject); + for (var p in simpleObject) + newObject[p] = f(simpleObject[p]); + newObject.constructor = simpleObject.constructor; + return newObject; + + case 'array': + seenObjects.push(simpleObject); + var newArray = []; + mappingArray.push(newArray); + for(var i=0,len=simpleObject.length; i this.current || scenes[i].end < this.current) { + var obj = newcopy.find('#'+scenes[i].ref); + obj.remove(); + } + } + return newcopy; +} + + /** * UI for madbuilder.html to build the scene editor */ @@ -521,6 +624,19 @@ project_run(); } else { } + } else if (id == 'Open') { + filedialog = jQuery('#filedialog'); + filedialog.dialog({width:500, + modal: true, + autoOpen:false, + title:'Please select a file'}); + filedialog.show(); + filedialog.html('Please select the project file
'); + filedialog.append(''); + filedialog.append(''); + filedialog.dialog("open"); + } else if (id == 'EditAnimation') { + inkscape.editAnimation(); } else { alert(id+' has not been implemented yet'); } @@ -930,6 +1046,7 @@ function loadOldProject() { + return -1; var f = system_open_read("/tmp/madbuilder.ws"); if (f == null) return -1; var s = f.read(f.available()); @@ -948,26 +1065,3 @@ } -var last_select = null; -var wizard = new Wizard(); -wizard.cb = onLoadProject; -$('#filedialog').dialog({ width:500}); -jQuery(document).ready(function() { - if (loadOldProject()) { - filedialog = jQuery('#filedialog'); - filedialog.dialog({width:500, - modal: true, - autoOpen:false, - title:'Please select a file'}); - filedialog.show(); - filedialog.html('Please select the project file
'); - filedialog.append(''); - filedialog.append(''); - filedialog.dialog("open"); - } - }); - -$('#frame').draggable(); -$('#btns').draggable({cursor:'crosshair'}); -$('#list').tabs(); -$('#display').tabs(); diff -r f3e6ac47752c -r 45e04408fc19 inkscape/firefox/content/madbuilder.html --- a/inkscape/firefox/content/madbuilder.html Fri Apr 10 22:46:01 2009 +0800 +++ b/inkscape/firefox/content/madbuilder.html Sun Apr 12 11:58:53 2009 +0800 @@ -10,6 +10,9 @@ + + + @@ -67,32 +73,37 @@ Test Save Wizard + Open

-
+
+
@@ -127,7 +138,5 @@
- diff -r f3e6ac47752c -r 45e04408fc19 inkscape/firefox/content/madswatter.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inkscape/firefox/content/madswatter.js Sun Apr 12 11:58:53 2009 +0800 @@ -0,0 +1,27 @@ +asdasd=1; +function MadSwatter(inkscape) +{ + this.inkscape = inkscape; +} + + +function MadSwatter_callback(mbsvg,self) +{ + + $(self.inkscape.mbsvg.doc).find("channels").replaceWith(mbsvg.find("channels")); + $('#display').tabs('select',0); + //self.inkscape.updateDocument(); +} + +MadSwatter.prototype.edit=function() +{ + // Generate a new document with the current scene + // FIXME: Do we need to do animation filter here? + // FIXME: Do we need to support hiearchical animation? + $('#display').tabs('select',2); + var kk = this.inkscape.mbsvg.generateCurrentSVG(); + //MadSwatter_invoke(kk,MadSwatter_callback,this); + // Simulate the MadSwatter + kk.find("metadata").append(""); + setTimeout(function () { MadSwatter_callback(kk,this);}, 3000); +} diff -r f3e6ac47752c -r 45e04408fc19 inkscape/firefox/content/main.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/inkscape/firefox/content/main.js Sun Apr 12 11:58:53 2009 +0800 @@ -0,0 +1,25 @@ +var last_select; +var wizard; +jQuery(document).ready(function() { + if (loadOldProject()) { + filedialog = jQuery('#filedialog'); + filedialog.dialog({width:500, + modal: true, + autoOpen:false, + title:'Please select a file'}); + filedialog.show(); + filedialog.html('Please select the project file
'); + filedialog.append(''); + filedialog.append(''); + filedialog.dialog("open"); + last_select = null; + wizard = new Wizard(); + wizard.cb = onLoadProject; + $('#filedialog').dialog({ width:500}); + $('#frame').draggable(); + $('#btns').draggable({cursor:'crosshair'}); + $('#list').tabs(); + $('#display').tabs(); + } + }); +