more path conditions fixes

master
Mark MacKay 2012-07-28 22:56:15 -05:00
parent 07461d3a2f
commit d712680411
9 changed files with 1158 additions and 1160 deletions

View File

@ -313,7 +313,8 @@ svgedit.path.getSegSelector = function(seg, update) {
'id': "segline_" + index,
'display': 'none',
'fill': "none",
'stroke': "#0FF",
'stroke': "#0ff",
"shape-rendering": "crispEdges",
'stroke-width': 2,
'style':'pointer-events:none',
'd': 'M0,0 0,0'

View File

@ -537,39 +537,33 @@
};
// called when we've selected a different element
var selectedChanged = function(window,elems) {
var selectedChanged = function(window,elems) {
var mode = svgCanvas.getMode();
if(mode === "select") setSelectMode();
var is_node = (mode == "pathedit");
if (mode === "pathedit") return updateContextPanel();
// if elems[1] is present, then we have more than one element
if (!is_node) {
selectedElement = (elems.length == 1 || elems[1] == null ? elems[0] : null);
elems = elems.filter(Boolean)
multiselected = (elems.length >= 2) ? elems : false;
if (svgCanvas.elementsAreSame(multiselected)) selectedElement = multiselected[0]
if (selectedElement != null) {
if (!is_node) {
$('#multiselected_panel').hide()
updateToolbar();
}
if (multiselected.length) {//multiselected elements are the same
$('#tools_top').addClass('multiselected')
}
}
else if (multiselected.length) {
$('.context_panel').hide()
$('#tools_top').removeClass('multiselected')
$('#multiselected_panel').show()
}
else {
$('.context_panel').hide()
$('#canvas_panel').show()
$('#tools_top').removeClass('multiselected')
}
selectedElement = (elems.length == 1 || elems[1] == null ? elems[0] : null);
elems = elems.filter(Boolean)
multiselected = (elems.length >= 2) ? elems : false;
if (svgCanvas.elementsAreSame(multiselected)) selectedElement = multiselected[0]
if (selectedElement != null) {
$('#multiselected_panel').hide()
updateToolbar();
if (multiselected.length) {//multiselected elements are the same
$('#tools_top').addClass('multiselected')
}
}
else if (multiselected.length) {
$('.context_panel').hide()
$('#tools_top').removeClass('multiselected')
$('#multiselected_panel').show()
}
else {
$('.context_panel').hide()
$('#canvas_panel').show()
$('#tools_top').removeClass('multiselected')
}
togglePathEditMode(is_node, elems);
svgCanvas.runExtensions("selectedChanged", {
elems: elems,
selectedElement: selectedElement,
@ -1388,7 +1382,7 @@
// updates the context panel tools based on the selected element
var updateContextPanel = function(e) {
var elem = selectedElement;
var elem = selectedElement;
// If element has just been deleted, consider it null
if(elem != null && !elem.parentNode) elem = null;
if (multiselected && multiselected[0] != null && !multiselected[0].parentNode) multiselected = false;
@ -1396,8 +1390,40 @@
var currentLayerName = svgCanvas.getCurrentDrawing().getCurrentLayerName();
var currentMode = svgCanvas.getMode();
var unit = curConfig.baseUnit !== 'px' ? curConfig.baseUnit : null;
var is_node = currentMode == 'pathedit'; //elem ? (elem.id && elem.id.indexOf('pathpointgrip') == 0) : false;
if (is_node) {
$('.context_panel').hide();
$('#path_node_panel').show();
$('#stroke_panel').hide();
var point = path.getNodePoint();
$('#tool_add_subpath').removeClass('push_button_pressed').addClass('tool_button');
$('#tool_node_delete').toggleClass('disabled', !path.canDeleteNodes);
// Show open/close button based on selected point
setIcon('#tool_openclose_path', path.closed_subpath ? 'open_path' : 'close_path');
if(point) {
var seg_type = $('#seg_type');
if(unit) {
point.x = svgedit.units.convertUnit(point.x);
point.y = svgedit.units.convertUnit(point.y);
}
$('#path_node_x').val(Math.round(point.x));
$('#path_node_y').val(Math.round(point.y));
if(point.type) {
seg_type.val(point.type).removeAttr('disabled');
} else {
seg_type.val(4).attr('disabled','disabled');
}
}
$("#tools_top").removeClass("multiselected")
$("#stroke_panel").hide();
$("#canvas_panel").hide();
return;
}
var menu_items = $('#cmenu_canvas li');
$('.context_panel').hide();
$('.menu_item', '#edit_menu').addClass('disabled');
@ -1410,13 +1436,12 @@
elem = (svgCanvas.elementsAreSame(multiselected)) ? multiselected[0] : null
if (elem) $("#tools_top").addClass("multiselected")
}
if (!elem && !multiselected) {
$("#tools_top").removeClass("multiselected")
$("#stroke_panel").hide();
$("#canvas_panel").show();
}
if (elem != null) {
$("#stroke_panel").show();
@ -1426,7 +1451,6 @@
var blurval = svgCanvas.getBlur(elem);
$('#blur').val(blurval);
if(!is_node && currentMode != 'pathedit') {
$('#selected_panel').show();
$('.action_selected').removeClass('disabled');
@ -1458,31 +1482,6 @@
if (no_path) $('.action_path_convert_selected').removeClass('disabled');
if (elname === "path") $('.action_path_selected').removeClass('disabled');
} else {
$('#path_node_panel').show();
$('#stroke_panel').hide();
var point = path.getNodePoint();
$('#tool_add_subpath').removeClass('push_button_pressed').addClass('tool_button');
$('#tool_node_delete').toggleClass('disabled', !path.canDeleteNodes);
// Show open/close button based on selected point
setIcon('#tool_openclose_path', path.closed_subpath ? 'open_path' : 'close_path');
if(point) {
var seg_type = $('#seg_type');
if(unit) {
point.x = svgedit.units.convertUnit(point.x);
point.y = svgedit.units.convertUnit(point.y);
}
$('#path_node_x').val(Math.round(point.x));
$('#path_node_y').val(Math.round(point.y));
if(point.type) {
seg_type.val(point.type).removeAttr('disabled');
} else {
seg_type.val(4).attr('disabled','disabled');
}
}
return;
}
var link_href = null;
@ -2249,7 +2248,7 @@
svgCanvas.setMode("pathedit")
path.toEditMode(elems[0]);
svgCanvas.clearSelection();
selectedChanged()
updateContextPanel();
}
}

View File

@ -4253,7 +4253,7 @@ var pathActions = canvas.pathActions = function() {
element = newpath;
drawn_path = null;
started = false;
if(subpath) {
if(svgedit.path.path.matrix) {
remapElement(newpath, {}, svgedit.path.path.matrix.inverse());

File diff suppressed because it is too large Load Diff

View File

@ -192,7 +192,7 @@ $(function(){
</div>
</label>
<label class="draginput">
<div class="draginput">
<span>Sizes</span>
<select id="resolution">
<option id="selectedPredefined" selected="selected">Custom</option>
@ -205,7 +205,7 @@ $(function(){
</select>
<div class="caret"></div>
<label id="resolution_label">Custom</label>
</label>
</div>
</div>
@ -328,7 +328,7 @@ $(function(){
<span>Y</span>
</label>
<label class="toolset draginput select twocol" id="tool_font_family">
<div class="toolset draginput select twocol" id="tool_font_family">
<!-- Font family -->
<span>Font</span>
<div id="preview_font" style="font-family: Helvetica, Arial, sans-serif;">Helvetica</div>
@ -349,7 +349,7 @@ $(function(){
</select>
<div class="tool_button" id="tool_bold" data-title="Bold Text [B]">B</div>
<div class="tool_button" id="tool_italic" data-title="Italic Text [I]">i</div>
</label>
</div>
<label id="tool_font_size" data-title="Change Font Size">
<input id="font_size" size="3" value="0" />
@ -396,7 +396,7 @@ $(function(){
<span>Y</span>
</label>
<label id="segment_type" class="draginput label">
<div id="segment_type" class="draginput label">
<span>Segment Type</span>
<select id="seg_type" data-title="Change Segment type">
<option id="straight_segments" selected="selected" value="4">Straight</option>
@ -404,7 +404,7 @@ $(function(){
</select>
<div class="caret"></div>
<label id="seg_type_label">Straight</label>
</label>
</div>
<label class="draginput checkbox" id="tool_node_link" data-title="Link Control Points">
<span>Linked Control Points</span>
@ -498,7 +498,7 @@ $(function(){
<span class="icon_label">Stroke Width</span>
</label>
</div>
<label class="stroke_tool draginput">
<div class="stroke_tool draginput">
<span>Stroke Dash</span>
<select id="stroke_style" data-title="Change stroke dash style">
<option selected="selected" value="none">&mdash;</option>
@ -509,7 +509,7 @@ $(function(){
</select>
<div class="caret"></div>
<label id="stroke_style_label">&mdash;</label>
</label>
</div>
<label style="display: none;">
<span class="icon_label">Stroke Join</span>
@ -560,7 +560,7 @@ $(function(){
<!-- Zoom buttons -->
<div id="zoom_panel" class="toolset" title="Change zoom level">
<label class="draginput select" id="zoom_label">
<div class="draginput select" id="zoom_label">
<span id="zoomLabel" class="zoom_tool icon_label"></span>
<select id="zoom_select">
<option value="6">6%</option>
@ -580,7 +580,7 @@ $(function(){
</select>
<div class="caret"></div>
<input id="zoom" size="3" value="100%" type="text" readonly="readonly" />
</label>
</div>
</div>
<div id="tools_bottom_3">

View File

@ -313,7 +313,8 @@ svgedit.path.getSegSelector = function(seg, update) {
'id': "segline_" + index,
'display': 'none',
'fill': "none",
'stroke': "#0FF",
'stroke': "#0ff",
"shape-rendering": "crispEdges",
'stroke-width': 2,
'style':'pointer-events:none',
'd': 'M0,0 0,0'

View File

@ -537,39 +537,33 @@
};
// called when we've selected a different element
var selectedChanged = function(window,elems) {
var selectedChanged = function(window,elems) {
var mode = svgCanvas.getMode();
if(mode === "select") setSelectMode();
var is_node = (mode == "pathedit");
if (mode === "pathedit") return updateContextPanel();
// if elems[1] is present, then we have more than one element
if (!is_node) {
selectedElement = (elems.length == 1 || elems[1] == null ? elems[0] : null);
elems = elems.filter(Boolean)
multiselected = (elems.length >= 2) ? elems : false;
if (svgCanvas.elementsAreSame(multiselected)) selectedElement = multiselected[0]
if (selectedElement != null) {
if (!is_node) {
$('#multiselected_panel').hide()
updateToolbar();
}
if (multiselected.length) {//multiselected elements are the same
$('#tools_top').addClass('multiselected')
}
}
else if (multiselected.length) {
$('.context_panel').hide()
$('#tools_top').removeClass('multiselected')
$('#multiselected_panel').show()
}
else {
$('.context_panel').hide()
$('#canvas_panel').show()
$('#tools_top').removeClass('multiselected')
}
selectedElement = (elems.length == 1 || elems[1] == null ? elems[0] : null);
elems = elems.filter(Boolean)
multiselected = (elems.length >= 2) ? elems : false;
if (svgCanvas.elementsAreSame(multiselected)) selectedElement = multiselected[0]
if (selectedElement != null) {
$('#multiselected_panel').hide()
updateToolbar();
if (multiselected.length) {//multiselected elements are the same
$('#tools_top').addClass('multiselected')
}
}
else if (multiselected.length) {
$('.context_panel').hide()
$('#tools_top').removeClass('multiselected')
$('#multiselected_panel').show()
}
else {
$('.context_panel').hide()
$('#canvas_panel').show()
$('#tools_top').removeClass('multiselected')
}
togglePathEditMode(is_node, elems);
svgCanvas.runExtensions("selectedChanged", {
elems: elems,
selectedElement: selectedElement,
@ -1388,7 +1382,7 @@
// updates the context panel tools based on the selected element
var updateContextPanel = function(e) {
var elem = selectedElement;
var elem = selectedElement;
// If element has just been deleted, consider it null
if(elem != null && !elem.parentNode) elem = null;
if (multiselected && multiselected[0] != null && !multiselected[0].parentNode) multiselected = false;
@ -1396,8 +1390,40 @@
var currentLayerName = svgCanvas.getCurrentDrawing().getCurrentLayerName();
var currentMode = svgCanvas.getMode();
var unit = curConfig.baseUnit !== 'px' ? curConfig.baseUnit : null;
var is_node = currentMode == 'pathedit'; //elem ? (elem.id && elem.id.indexOf('pathpointgrip') == 0) : false;
if (is_node) {
$('.context_panel').hide();
$('#path_node_panel').show();
$('#stroke_panel').hide();
var point = path.getNodePoint();
$('#tool_add_subpath').removeClass('push_button_pressed').addClass('tool_button');
$('#tool_node_delete').toggleClass('disabled', !path.canDeleteNodes);
// Show open/close button based on selected point
setIcon('#tool_openclose_path', path.closed_subpath ? 'open_path' : 'close_path');
if(point) {
var seg_type = $('#seg_type');
if(unit) {
point.x = svgedit.units.convertUnit(point.x);
point.y = svgedit.units.convertUnit(point.y);
}
$('#path_node_x').val(Math.round(point.x));
$('#path_node_y').val(Math.round(point.y));
if(point.type) {
seg_type.val(point.type).removeAttr('disabled');
} else {
seg_type.val(4).attr('disabled','disabled');
}
}
$("#tools_top").removeClass("multiselected")
$("#stroke_panel").hide();
$("#canvas_panel").hide();
return;
}
var menu_items = $('#cmenu_canvas li');
$('.context_panel').hide();
$('.menu_item', '#edit_menu').addClass('disabled');
@ -1410,13 +1436,12 @@
elem = (svgCanvas.elementsAreSame(multiselected)) ? multiselected[0] : null
if (elem) $("#tools_top").addClass("multiselected")
}
if (!elem && !multiselected) {
$("#tools_top").removeClass("multiselected")
$("#stroke_panel").hide();
$("#canvas_panel").show();
}
if (elem != null) {
$("#stroke_panel").show();
@ -1426,7 +1451,6 @@
var blurval = svgCanvas.getBlur(elem);
$('#blur').val(blurval);
if(!is_node && currentMode != 'pathedit') {
$('#selected_panel').show();
$('.action_selected').removeClass('disabled');
@ -1458,31 +1482,6 @@
if (no_path) $('.action_path_convert_selected').removeClass('disabled');
if (elname === "path") $('.action_path_selected').removeClass('disabled');
} else {
$('#path_node_panel').show();
$('#stroke_panel').hide();
var point = path.getNodePoint();
$('#tool_add_subpath').removeClass('push_button_pressed').addClass('tool_button');
$('#tool_node_delete').toggleClass('disabled', !path.canDeleteNodes);
// Show open/close button based on selected point
setIcon('#tool_openclose_path', path.closed_subpath ? 'open_path' : 'close_path');
if(point) {
var seg_type = $('#seg_type');
if(unit) {
point.x = svgedit.units.convertUnit(point.x);
point.y = svgedit.units.convertUnit(point.y);
}
$('#path_node_x').val(Math.round(point.x));
$('#path_node_y').val(Math.round(point.y));
if(point.type) {
seg_type.val(point.type).removeAttr('disabled');
} else {
seg_type.val(4).attr('disabled','disabled');
}
}
return;
}
var link_href = null;
@ -2249,7 +2248,7 @@
svgCanvas.setMode("pathedit")
path.toEditMode(elems[0]);
svgCanvas.clearSelection();
selectedChanged()
updateContextPanel();
}
}

View File

@ -4253,7 +4253,7 @@ var pathActions = canvas.pathActions = function() {
element = newpath;
drawn_path = null;
started = false;
if(subpath) {
if(svgedit.path.path.matrix) {
remapElement(newpath, {}, svgedit.path.path.matrix.inverse());

File diff suppressed because it is too large Load Diff