diff --git a/editor/images/go-down.png b/editor/images/go-down.png
new file mode 100644
index 00000000..3dd7fccd
Binary files /dev/null and b/editor/images/go-down.png differ
diff --git a/editor/images/go-up.png b/editor/images/go-up.png
new file mode 100644
index 00000000..fa9a7d71
Binary files /dev/null and b/editor/images/go-up.png differ
diff --git a/editor/images/view-refresh.png b/editor/images/view-refresh.png
new file mode 100644
index 00000000..3fd71d6e
Binary files /dev/null and b/editor/images/view-refresh.png differ
diff --git a/editor/svg-editor.html b/editor/svg-editor.html
index 4930ed55..7f854d8a 100644
--- a/editor/svg-editor.html
+++ b/editor/svg-editor.html
@@ -36,18 +36,17 @@
Layers
-
-
-
By default, this panel will be collapsed. It will be expandable by some button/handle.
-
diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js
index a2c4d3f0..5bb5fdf7 100644
--- a/editor/svgcanvas.js
+++ b/editor/svgcanvas.js
@@ -557,12 +557,14 @@ function BatchCommand(text) {
var shape = svgdoc.getElementById(data.attr.id);
// if shape is a path but we need to create a rect/ellipse, then remove the path
if (shape && data.element != shape.tagName) {
- svgzoom.removeChild(shape);
+ current_layer.removeChild(shape);
shape = null;
}
if (!shape) {
shape = svgdoc.createElementNS(svgns, data.element);
- svgzoom.appendChild(shape);
+ if (current_layer) {
+ current_layer.appendChild(shape);
+ }
}
assignAttributes(shape, data.attr, 100);
cleanupElement(shape);
@@ -592,7 +594,11 @@ function BatchCommand(text) {
svgroot.appendChild(svgzoom);
var comment = svgdoc.createComment(" created with SVG-edit - http://svg-edit.googlecode.com/ ");
svgzoom.appendChild(comment);
-
+ // associative array of layer names to elements
+ var all_layers = {};
+ // pointer to the current layer
+ var current_layer = null;
+
var d_attr = null;
var started = false;
var obj_num = 1;
@@ -674,7 +680,7 @@ function BatchCommand(text) {
var resultList = null;
try {
- resultList = svgroot.getIntersectionList(rect, null);
+ resultList = current_layer.getIntersectionList(rect, null);
} catch(e) { }
if (resultList == null || typeof(resultList.item) != "function") {
@@ -1378,11 +1384,10 @@ function BatchCommand(text) {
started = true;
current_resize_mode = "none";
var t = evt.target;
- // if this element is in a group, go up until we reach the top-level group
- // TODO: once we implement Layers, the top-level groups will be layers so
- // we will want to stop just before then (parentNode.parentNode)
+ // if this element is in a group, go up until we reach the top-level group
+ // just below the layer groups
// TODO: once we implement links, we also would have to check for elements
- while (t.parentNode.tagName == "g") {
+ while (t.parentNode.parentNode.tagName == "g") {
t = t.parentNode;
}
// WebKit returns