Made selection of middle arrow for lines convert them to polylines, made extension tools more easy to add, fixed opacity selection on selected connector
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1347 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -382,12 +382,23 @@ function svg_edit_setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var extAdded = function(window, ext) {
|
var extAdded = function(window, ext) {
|
||||||
|
|
||||||
|
var cb_called = false;
|
||||||
|
|
||||||
|
var runCallback = function() {
|
||||||
|
if(ext.callback && !cb_called) {
|
||||||
|
cb_called = true;
|
||||||
|
ext.callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(ext.buttons) {
|
if(ext.buttons) {
|
||||||
var fallback_obj = {},
|
var fallback_obj = {},
|
||||||
placement_obj = {},
|
placement_obj = {},
|
||||||
svgicons = ext.svgicons;
|
svgicons = ext.svgicons;
|
||||||
|
|
||||||
var holders = {};
|
var holders = {};
|
||||||
|
|
||||||
|
|
||||||
// Add buttons given by extension
|
// Add buttons given by extension
|
||||||
$.each(ext.buttons, function(i, btn) {
|
$.each(ext.buttons, function(i, btn) {
|
||||||
@@ -514,32 +525,70 @@ function svg_edit_setup() {
|
|||||||
setIconSize('m');
|
setIconSize('m');
|
||||||
setIconSize(old);
|
setIconSize(old);
|
||||||
}
|
}
|
||||||
|
runCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(ext.context_panels) {
|
if(ext.context_tools) {
|
||||||
$.each(ext.context_panels, function(i, panel) {
|
$.each(ext.context_tools, function(i, tool) {
|
||||||
// Add select panel
|
// Add select tool
|
||||||
|
var cont_id = tool.container_id?(' id="' + tool.container_id + '"'):"";
|
||||||
|
|
||||||
// TODO: Allow support for other types, or adding to existing panel
|
var panel = $('#' + tool.panel);
|
||||||
if(panel.type == "select") {
|
|
||||||
var html = '<div id="' + panel.id + '"><label>'
|
if(!panel.length) {
|
||||||
+ '<select id="' + panel.list_id + '">';
|
panel = $('<div>', {id: tool.panel}).appendTo("#tools_top");
|
||||||
$.each(panel.options, function(val, text) {
|
|
||||||
var sel = (val == panel.defopt) ? " selected":"";
|
|
||||||
html += '<option value="'+val+'"' + sel + '>' + text + '</option>';
|
|
||||||
});
|
|
||||||
html += "</select></label></div>";
|
|
||||||
// Creates the panel, hides & adds it, returns the select element
|
|
||||||
var sel = $(html).hide().appendTo("#tools_top").find("select");
|
|
||||||
$.each(panel.events, function(evt, func) {
|
|
||||||
$(sel).bind(evt, func);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Allow support for other types, or adding to existing tool
|
||||||
|
switch (tool.type) {
|
||||||
|
case 'select':
|
||||||
|
var html = '<label' + cont_id + '>'
|
||||||
|
+ '<select id="' + tool.id + '">';
|
||||||
|
$.each(tool.options, function(val, text) {
|
||||||
|
var sel = (val == tool.defval) ? " selected":"";
|
||||||
|
html += '<option value="'+val+'"' + sel + '>' + text + '</option>';
|
||||||
|
});
|
||||||
|
html += "</select></label>";
|
||||||
|
// Creates the tool, hides & adds it, returns the select element
|
||||||
|
var sel = $(html).appendTo(panel).find('select');
|
||||||
|
|
||||||
|
$.each(tool.events, function(evt, func) {
|
||||||
|
$(sel).bind(evt, func);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'input':
|
||||||
|
var html = '<label' + cont_id + '">'
|
||||||
|
+ '<span id="' + tool.id + '_label">'
|
||||||
|
+ tool.label + ':</span>'
|
||||||
|
+ '<input id="' + tool.id + '" title="' + tool.title
|
||||||
|
+ '" size="' + (tool.size || "4") + '" value="' + (tool.defval || "") + '" type="text"/></label>'
|
||||||
|
|
||||||
|
// Creates the tool, hides & adds it, returns the select element
|
||||||
|
|
||||||
|
// Add to given tool.panel
|
||||||
|
var inp = $(html).appendTo(panel).find('input');
|
||||||
|
|
||||||
|
if(tool.spindata) {
|
||||||
|
inp.SpinButton(tool.spindata);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tool.events) {
|
||||||
|
$.each(tool.events, function(evt, func) {
|
||||||
|
$(sel).bind(evt, func);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runCallback();
|
||||||
};
|
};
|
||||||
|
|
||||||
var getPaint = function(color, opac) {
|
var getPaint = function(color, opac) {
|
||||||
|
|||||||
@@ -6541,6 +6541,9 @@ function BatchCommand(text) {
|
|||||||
// selector if the element is in that array
|
// selector if the element is in that array
|
||||||
if ($.inArray(elem, selectedElements) != -1) {
|
if ($.inArray(elem, selectedElements) != -1) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
// Due to element replacement, this element may no longer
|
||||||
|
// be part of the DOM
|
||||||
|
if(!elem.parentNode) return;
|
||||||
selectorManager.requestSelector(elem).resize();
|
selectorManager.requestSelector(elem).resize();
|
||||||
},0);
|
},0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,10 +135,11 @@ $(function() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
name: "Arrows",
|
name: "Arrows",
|
||||||
context_panels: [{
|
context_tools: [{
|
||||||
type: "select",
|
type: "select",
|
||||||
id: "arrow_panel",
|
panel: "arrow_panel",
|
||||||
list_id: "arrow_list",
|
title: "Select arrow type",
|
||||||
|
id: "arrow_list",
|
||||||
options: {
|
options: {
|
||||||
none: "No arrow",
|
none: "No arrow",
|
||||||
end: "---->",
|
end: "---->",
|
||||||
@@ -147,11 +148,14 @@ $(function() {
|
|||||||
mid: "-->--",
|
mid: "-->--",
|
||||||
mid_bk: "--<--"
|
mid_bk: "--<--"
|
||||||
},
|
},
|
||||||
defopt: "none",
|
defval: "none",
|
||||||
events: {
|
events: {
|
||||||
change: setArrow
|
change: setArrow
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
callback: function() {
|
||||||
|
$('#arrow_panel').hide();
|
||||||
|
},
|
||||||
addLangData: function(lang) {
|
addLangData: function(lang) {
|
||||||
return {
|
return {
|
||||||
data: lang_list[lang]
|
data: lang_list[lang]
|
||||||
|
|||||||
@@ -473,6 +473,7 @@ $(function() {
|
|||||||
se_ns = svgCanvas.getEditorNS(true);
|
se_ns = svgCanvas.getEditorNS(true);
|
||||||
cur_line.setAttributeNS(se_ns, "se:connector", conn_str);
|
cur_line.setAttributeNS(se_ns, "se:connector", conn_str);
|
||||||
cur_line.setAttribute('class', conn_sel.substr(1));
|
cur_line.setAttribute('class', conn_sel.substr(1));
|
||||||
|
cur_line.setAttribute('opacity', 1);
|
||||||
svgCanvas.addToSelection([cur_line]);
|
svgCanvas.addToSelection([cur_line]);
|
||||||
svgCanvas.moveToBottomSelectedElement();
|
svgCanvas.moveToBottomSelectedElement();
|
||||||
selManager.requestSelector(cur_line).showGrips(false);
|
selManager.requestSelector(cur_line).showGrips(false);
|
||||||
@@ -522,11 +523,40 @@ $(function() {
|
|||||||
elem.getAttribute("marker-end")
|
elem.getAttribute("marker-end")
|
||||||
)) {
|
)) {
|
||||||
var start = elem.getAttribute("marker-start");
|
var start = elem.getAttribute("marker-start");
|
||||||
|
var mid = elem.getAttribute("marker-mid");
|
||||||
var end = elem.getAttribute("marker-end");
|
var end = elem.getAttribute("marker-end");
|
||||||
cur_line = elem;
|
cur_line = elem;
|
||||||
$(elem)
|
$(elem)
|
||||||
.data("start_off", !!start)
|
.data("start_off", !!start)
|
||||||
.data("end_off", !!end);
|
.data("end_off", !!end);
|
||||||
|
|
||||||
|
if(elem.tagName == "line" && mid) {
|
||||||
|
// Convert to polyline to accept mid-arrow
|
||||||
|
|
||||||
|
var x1 = elem.getAttribute('x1')-0;
|
||||||
|
var x2 = elem.getAttribute('x2')-0;
|
||||||
|
var y1 = elem.getAttribute('y1')-0;
|
||||||
|
var y2 = elem.getAttribute('y2')-0;
|
||||||
|
var id = elem.id;
|
||||||
|
|
||||||
|
var mid_pt = (' '+((x1+x2)/2)+','+((y1+y2)/2) + ' ');
|
||||||
|
var pline = addElem({
|
||||||
|
"element": "polyline",
|
||||||
|
"attr": {
|
||||||
|
"points": (x1+','+y1+ mid_pt +x2+','+y2),
|
||||||
|
"stroke": elem.getAttribute('stroke'),
|
||||||
|
"stroke-width": elem.getAttribute('stroke-width'),
|
||||||
|
"marker-mid": mid,
|
||||||
|
"fill": "none",
|
||||||
|
"opacity": elem.getAttribute('opacity') || 1
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$(elem).after(pline).remove();
|
||||||
|
svgCanvas.clearSelection();
|
||||||
|
pline.id = id;
|
||||||
|
svgCanvas.addToSelection([pline]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
updateConnectors();
|
updateConnectors();
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user