Make Closepath Icons Work

This commit is contained in:
Jacques Distler 2010-02-19 16:37:20 -06:00
parent dab8e5daa1
commit f84b4370fa
3 changed files with 39 additions and 18 deletions

View file

@ -1,15 +1,15 @@
<svg xmlns="http://www.w3.org/2000/svg">
<g id="close">
<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">
<marker viewBox="0 0 10 10" id="close_arrow_fw256" 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)"/>
<line x1="240" y1="136" x2="169.5" y2="74" stroke="#f00" stroke-width="15" fill="none" marker-end="url(#close_arrow_fw256)"/>
<g stroke-width="15" stroke="#00f" fill="#00ffff">
<circle r="30" cy="41" cx="123"/>
<circle r="30" cy="146" cx="40"/>
@ -20,7 +20,7 @@
</g>
</svg>
</g>
<g id="open">
<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>
@ -40,4 +40,6 @@
</g>
</svg>
</g>
<g id="svg_eof"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

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

View file

@ -423,9 +423,9 @@ function svg_edit_setup() {
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");
}
// TODO: Allow support for other types, or adding to existing tool
switch (tool.type) {
@ -487,7 +487,6 @@ function svg_edit_setup() {
var fallback_obj = {},
placement_obj = {},
svgicons = ext.svgicons;
var holders = {};
@ -520,6 +519,9 @@ function svg_edit_setup() {
case 'context':
cls = 'tool_button';
parent = "#" + btn.panel;
// create the panel if it doesn't exist
if(!$(parent).length)
$('<div>', {id: btn.panel}).appendTo("#tools_top");
break;
}
@ -527,7 +529,6 @@ function svg_edit_setup() {
.attr("id", id)
.attr("title", btn.title)
.addClass(cls);
if(!btn.includeWith) {
button.appendTo(parent);
} else {
@ -1823,7 +1824,7 @@ function svg_edit_setup() {
var cancelOverlays = function() {
$('#dialog_box').hide();
if (!editingsource && !editingforeign && !docprops) return;
if (!editingsource && !docprops) return;
if (editingsource) {
var oldString = svgCanvas.getSvgString();
@ -2763,7 +2764,7 @@ function svg_edit_setup() {
updateCanvas(true);
});
// var revnums = "svg-editor.js ($Rev: 1402 $) ";
// var revnums = "svg-editor.js ($Rev: 1414 $) ";
// revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute("title", revnums);
return svgCanvas;