Fixed Issue 279 by hiding bottom tools on pathedit mode, also fixed other minor problems
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@871 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -47,19 +47,34 @@ function svg_edit_setup() {
|
|||||||
// if elems[1] is present, then we have more than one element
|
// if elems[1] is present, then we have more than one element
|
||||||
selectedElement = (elems.length == 1 || elems[1] == null ? elems[0] : null);
|
selectedElement = (elems.length == 1 || elems[1] == null ? elems[0] : null);
|
||||||
multiselected = (elems.length >= 2 && elems[1] != null);
|
multiselected = (elems.length >= 2 && elems[1] != null);
|
||||||
|
var is_node = false;
|
||||||
if (selectedElement != null) {
|
if (selectedElement != null) {
|
||||||
// unless we're already in always set the mode of the editor to select because
|
// unless we're already in always set the mode of the editor to select because
|
||||||
// upon creation of a text element the editor is switched into
|
// upon creation of a text element the editor is switched into
|
||||||
// select mode and this event fires - we need our UI to be in sync
|
// select mode and this event fires - we need our UI to be in sync
|
||||||
|
|
||||||
var is_node = selectedElement.id && selectedElement.id.indexOf('pathpointgrip') == 0;
|
is_node = selectedElement.id && selectedElement.id.indexOf('pathpointgrip') == 0;
|
||||||
|
|
||||||
if (svgCanvas.getMode() != "multiselect" && !is_node) {
|
if (svgCanvas.getMode() != "multiselect" && !is_node) {
|
||||||
setSelectMode();
|
setSelectMode();
|
||||||
updateToolbar();
|
updateToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // if (elem != null)
|
} // if (elem != null)
|
||||||
|
|
||||||
|
|
||||||
|
// Deal with pathedit mode
|
||||||
|
$('#path_node_panel').toggle(is_node);
|
||||||
|
$('#tools_bottom_2,#tools_bottom_3').toggle(!is_node);
|
||||||
|
if(is_node) {
|
||||||
|
// Change select icon
|
||||||
|
$('.tool_button').removeClass('tool_button_current');
|
||||||
|
$('#tool_select').attr('src','images/select_node.png').addClass('tool_button_current');
|
||||||
|
} else {
|
||||||
|
$('#tool_select').attr('src','images/select.png');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
updateContextPanel();
|
updateContextPanel();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -74,7 +89,7 @@ function svg_edit_setup() {
|
|||||||
parseInt(vb[3]));
|
parseInt(vb[3]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we update the contextual panel with potentially new
|
// we update the contextual panel with potentially new
|
||||||
// positional/sizing information (we DON'T want to update the
|
// positional/sizing information (we DON'T want to update the
|
||||||
// toolbar here as that creates an infinite loop)
|
// toolbar here as that creates an infinite loop)
|
||||||
@@ -91,7 +106,6 @@ function svg_edit_setup() {
|
|||||||
var img = bg_img.find('img');
|
var img = bg_img.find('img');
|
||||||
var zoomlevel = svgCanvas.getZoom();
|
var zoomlevel = svgCanvas.getZoom();
|
||||||
img.width(zoomlevel*100 + '%');
|
img.width(zoomlevel*100 + '%');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var zoomChanged = function(window, bbox) {
|
var zoomChanged = function(window, bbox) {
|
||||||
@@ -202,7 +216,6 @@ function svg_edit_setup() {
|
|||||||
var updateContextPanel = function() {
|
var updateContextPanel = function() {
|
||||||
var elem = selectedElement;
|
var elem = selectedElement;
|
||||||
var currentLayer = svgCanvas.getCurrentLayer();
|
var currentLayer = svgCanvas.getCurrentLayer();
|
||||||
$('#tool_select').attr('src','images/select.png');
|
|
||||||
|
|
||||||
// No need to update anything else in rotate mode
|
// No need to update anything else in rotate mode
|
||||||
if (svgCanvas.getMode() == 'rotate' && elem != null) {
|
if (svgCanvas.getMode() == 'rotate' && elem != null) {
|
||||||
@@ -213,17 +226,13 @@ function svg_edit_setup() {
|
|||||||
var is_node = elem ? (elem.id && elem.id.indexOf('pathpointgrip') == 0) : false;
|
var is_node = elem ? (elem.id && elem.id.indexOf('pathpointgrip') == 0) : false;
|
||||||
|
|
||||||
$('#selected_panel, #multiselected_panel, #g_panel, #rect_panel, #circle_panel,\
|
$('#selected_panel, #multiselected_panel, #g_panel, #rect_panel, #circle_panel,\
|
||||||
#ellipse_panel, #line_panel, #text_panel, #image_panel, #path_node_panel').hide();
|
#ellipse_panel, #line_panel, #text_panel, #image_panel').hide();
|
||||||
if (elem != null) {
|
if (elem != null) {
|
||||||
$('#angle').val(svgCanvas.getRotationAngle(elem));
|
$('#angle').val(svgCanvas.getRotationAngle(elem));
|
||||||
|
|
||||||
if(!is_node) {
|
if(!is_node) {
|
||||||
$('#selected_panel').show();
|
$('#selected_panel').show();
|
||||||
} else {
|
} else {
|
||||||
$('#path_node_panel').show();
|
|
||||||
// Change select icon
|
|
||||||
$('.tool_button').removeClass('tool_button_current');
|
|
||||||
$('#tool_select').attr('src','images/select_node.png').addClass('tool_button_current');
|
|
||||||
var point = svgCanvas.getNodePoint();
|
var point = svgCanvas.getNodePoint();
|
||||||
if(point) {
|
if(point) {
|
||||||
var seg_type = $('#seg_type');
|
var seg_type = $('#seg_type');
|
||||||
|
|||||||
@@ -2041,7 +2041,6 @@ function BatchCommand(text) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
selectorManager.requestSelector(selected).resize(selectedBBox);
|
selectorManager.requestSelector(selected).resize(selectedBBox);
|
||||||
break;
|
break;
|
||||||
case "zoom":
|
case "zoom":
|
||||||
@@ -2487,7 +2486,7 @@ function BatchCommand(text) {
|
|||||||
grip.setAttribute("cx", mouse_x);
|
grip.setAttribute("cx", mouse_x);
|
||||||
grip.setAttribute("cy", mouse_y);
|
grip.setAttribute("cy", mouse_y);
|
||||||
}
|
}
|
||||||
call("selected", [grip]);
|
call("changed", [grip]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_first) cur_type = last_type;
|
if(is_first) cur_type = last_type;
|
||||||
@@ -4040,12 +4039,11 @@ function BatchCommand(text) {
|
|||||||
return cur_properties.stroke_width;
|
return cur_properties.stroke_width;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: this seems like two bugs - if val is 0 and current_mode is NOT line/scribble, then
|
// When attempting to set a line's width to 0, change it to 1 instead
|
||||||
// we RECURSIVELY call setStrokeWidth(1) and then the rest of the function continues and
|
|
||||||
// stroke_width is set to 0 and selected element's stroke-width is set to 0
|
|
||||||
this.setStrokeWidth = function(val) {
|
this.setStrokeWidth = function(val) {
|
||||||
if(val == 0 && $.inArray(current_mode, ['line', 'path']) == -1) {
|
if(val == 0 && $.inArray(current_mode, ['line', 'path']) != -1) {
|
||||||
canvas.setStrokeWidth(1);
|
canvas.setStrokeWidth(1);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
cur_properties.stroke_width = val;
|
cur_properties.stroke_width = val;
|
||||||
this.changeSelectedAttribute("stroke-width", val);
|
this.changeSelectedAttribute("stroke-width", val);
|
||||||
@@ -4408,8 +4406,26 @@ function BatchCommand(text) {
|
|||||||
if (oldval == null) oldval = "";
|
if (oldval == null) oldval = "";
|
||||||
if (oldval != newValue) {
|
if (oldval != newValue) {
|
||||||
if (attr == "#text") {
|
if (attr == "#text") {
|
||||||
|
var old_w = elem.getBBox().width;
|
||||||
elem.textContent = newValue;
|
elem.textContent = newValue;
|
||||||
elem = canvas.quickClone(elem);
|
elem = canvas.quickClone(elem);
|
||||||
|
|
||||||
|
// Hoped to solve the issue of moving text with text-anchor="start",
|
||||||
|
// but this doesn't actually fix it. Hopefully on the right track, though. -Fyrd
|
||||||
|
|
||||||
|
// var box=canvas.getBBox(elem), left=box.x, top=box.y, width=box.width,
|
||||||
|
// height=box.height, dx = width - old_w, dy=0;
|
||||||
|
// var angle = canvas.getRotationAngle(elem);
|
||||||
|
// if (angle) {
|
||||||
|
// var r = Math.sqrt( dx*dx + dy*dy );
|
||||||
|
// var theta = Math.atan2(dy,dx) - angle * Math.PI / 180.0;
|
||||||
|
// dx = r * Math.cos(theta);
|
||||||
|
// dy = r * Math.sin(theta);
|
||||||
|
//
|
||||||
|
// elem.setAttribute('x', elem.getAttribute('x')-dx);
|
||||||
|
// elem.setAttribute('y', elem.getAttribute('y')-dy);
|
||||||
|
// }
|
||||||
|
|
||||||
} else if (attr == "#href") {
|
} else if (attr == "#href") {
|
||||||
elem.setAttributeNS(xlinkns, "href", newValue);
|
elem.setAttributeNS(xlinkns, "href", newValue);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user