A little more work on the closepath extension (still doesn't show SVG icons yet)

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1412 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Jeff Schiller 2010-02-19 16:55:08 +00:00
parent 7236577141
commit 796cee60e1
4 changed files with 76 additions and 12 deletions

View File

@ -0,0 +1,44 @@
<svg xmlns="http://www.w3.org/2000/svg">
<g id="tool_closepath">
<svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<marker viewBox="0 0 10 10" id="close_arrow_fw2" refY="5" markerUnits="strokeWidth" markerWidth="5" markerHeight="5" orient="auto" refX="8">
<path d="m0,0l10,5l-10,5l5,-5l-5,-5z" fill="#f00"/>
</marker>
</defs>
<g>
<title>Layer 1</title>
<path stroke="#000" stroke-width="15" fill="#ffc8c8" d="m121.5,40l-84,106l27,115l166,2l29,-111"/>
<line x1="240" y1="136" x2="169.5" y2="74" stroke="#f00" stroke-width="15" fill="none" marker-end="url(#close_arrow_fw2)"/>
<g stroke-width="15" stroke="#00f" fill="#00ffff">
<circle r="30" cy="41" cx="123"/>
<circle r="30" cy="146" cx="40"/>
<circle r="30" cy="260" cx="69"/>
<circle r="30" cy="260" cx="228"/>
<circle r="30" cy="148" cx="260"/>
</g>
</g>
</svg>
</g>
<g id="tool_openpath">
<svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g>
<title>Layer 1</title>
<path stroke="#000" stroke-width="15" fill="#ffc8c8" d="m123.5,38l-84,106l27,115l166,2l29,-111"/>
<line x1="276.5" y1="153" x2="108.5" y2="24" stroke="#000" stroke-width="10" fill="none"/>
<g stroke-width="15" stroke="#00f" fill="#0ff">
<circle r="30" cy="41" cx="123"/>
<circle r="30" cy="146" cx="40"/>
<circle r="30" cy="260" cx="69"/>
<circle r="30" cy="260" cx="228"/>
<circle r="30" cy="148" cx="260"/>
</g>
<g stroke="#f00" stroke-width="20" fill="none">
<line x1="168" y1="24.00001" x2="210" y2="150"/>
<line x1="210" y1="24.00001" x2="168" y2="150"/>
</g>
</g>
</svg>
</g>
<g id="svg_eof"/>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -14,8 +14,11 @@ $(function() {
var selElems, var selElems,
updateButton = function(path) { updateButton = function(path) {
var seglist = path.pathSegList, var seglist = path.pathSegList,
button = $('#closepath_panel > div.tool_button')[0]; closed = seglist.getItem(seglist.numberOfItems - 1).pathSegType==1,
$(button).html(seglist.getItem(seglist.numberOfItems - 1).pathSegType==1 ? "open":"close"); showbutton = closed ? '#tool_openpath' : '#tool_closepath',
hidebutton = closed ? '#tool_closepath' : '#tool_openpath';
$(hidebutton).hide();
$(showbutton).show();
}, },
showPanel = function(on) { showPanel = function(on) {
$('#closepath_panel').toggle(on); $('#closepath_panel').toggle(on);
@ -43,12 +46,28 @@ $(function() {
return { return {
name: "ClosePath", name: "ClosePath",
context_tools: [{ svgicons: "extensions/closepath-icons.svg",
type: "tool_button", buttons: [{
id: "tool_openpath",
type: "context",
panel: "closepath_panel", panel: "closepath_panel",
title: "Open or Close path", title: "Open path",
id: "close", events: {
events: { mousedown: toggleClosed } 'click': function() {
toggleClosed();
}
}
},
{
id: "tool_closepath",
type: "context",
panel: "closepath_panel",
title: "Close path",
events: {
'click': function() {
toggleClosed();
}
}
}], }],
callback: function() { callback: function() {
$('#closepath_panel').hide(); $('#closepath_panel').hide();

View File

@ -21,7 +21,7 @@
<script type="text/javascript" src="extensions/ext-closepath.js"></script> <script type="text/javascript" src="extensions/ext-closepath.js"></script>
<script type="text/javascript" src="extensions/ext-arrows.js"></script> <script type="text/javascript" src="extensions/ext-arrows.js"></script>
<script type="text/javascript" src="extensions/ext-connector.js"></script> <script type="text/javascript" src="extensions/ext-connector.js"></script>
<!-- <script type="text/javascript" src="extensions/ext-foreignobject.js"></script> --> <script type="text/javascript" src="extensions/ext-foreignobject.js"></script>
<!-- Release version of script tags: > <!-- Release version of script tags: >
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>

View File

@ -423,9 +423,9 @@ function svg_edit_setup() {
var panel = $('#' + tool.panel); var panel = $('#' + tool.panel);
if(!panel.length) { // create the panel if it doesn't exist
if(!panel.length)
panel = $('<div>', {id: tool.panel}).appendTo("#tools_top"); panel = $('<div>', {id: tool.panel}).appendTo("#tools_top");
}
// TODO: Allow support for other types, or adding to existing tool // TODO: Allow support for other types, or adding to existing tool
switch (tool.type) { switch (tool.type) {
@ -487,7 +487,6 @@ function svg_edit_setup() {
var fallback_obj = {}, var fallback_obj = {},
placement_obj = {}, placement_obj = {},
svgicons = ext.svgicons; svgicons = ext.svgicons;
var holders = {}; var holders = {};
@ -520,6 +519,9 @@ function svg_edit_setup() {
case 'context': case 'context':
cls = 'tool_button'; cls = 'tool_button';
parent = "#" + btn.panel; parent = "#" + btn.panel;
// create the panel if it doesn't exist
if(!$(parent).length)
$('<div>', {id: btn.panel}).appendTo("#tools_top");
break; break;
} }
@ -527,7 +529,6 @@ function svg_edit_setup() {
.attr("id", id) .attr("id", id)
.attr("title", btn.title) .attr("title", btn.title)
.addClass(cls); .addClass(cls);
if(!btn.includeWith) { if(!btn.includeWith) {
button.appendTo(parent); button.appendTo(parent);
} else { } else {