diff --git a/ASSETS.md b/ASSETS.md
index a74a9a29a4..0f8647fb61 100644
--- a/ASSETS.md
+++ b/ASSETS.md
@@ -255,6 +255,7 @@ Generated-in-code art is original and has no file to list. This covers the defau
| `assets/icons/dc-new-fill.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-new-item.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-new-stroke.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
+| `assets/icons/dc-new-sublayer.svg` | VectorCraft contributors | Original work, drawn for VectorCraft: a layer row with a new-item square nested under it | MIT OR Apache-2.0 | |
| `assets/icons/dc-objects-on-path.svg` | VectorCraft contributors | Original work, drawn for VectorCraft: three small squares along a curve | MIT OR Apache-2.0 | |
| `assets/icons/dc-options.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
| `assets/icons/dc-para-bullets.svg` | VectorCraft contributors | Original work, drawn for VectorCraft: three dots, each before a line | MIT OR Apache-2.0 | |
diff --git a/assets/icons/dc-new-sublayer.svg b/assets/icons/dc-new-sublayer.svg
new file mode 100644
index 0000000000..0efcbf48c0
--- /dev/null
+++ b/assets/icons/dc-new-sublayer.svg
@@ -0,0 +1 @@
+
diff --git a/crates/ui-egui/src/icon_data.rs b/crates/ui-egui/src/icon_data.rs
index eb2a544af8..46a6128396 100644
--- a/crates/ui-egui/src/icon_data.rs
+++ b/crates/ui-egui/src/icon_data.rs
@@ -124,6 +124,7 @@ pub static ICONS: &[(&str, &[u8])] = &[
("dc-new-fill", include_bytes!("../../../assets/icons/dc-new-fill.svg")),
("dc-new-item", include_bytes!("../../../assets/icons/dc-new-item.svg")),
("dc-new-stroke", include_bytes!("../../../assets/icons/dc-new-stroke.svg")),
+ ("dc-new-sublayer", include_bytes!("../../../assets/icons/dc-new-sublayer.svg")),
("dc-objects-on-path", include_bytes!("../../../assets/icons/dc-objects-on-path.svg")),
("dc-options", include_bytes!("../../../assets/icons/dc-options.svg")),
("dc-para-bullets", include_bytes!("../../../assets/icons/dc-para-bullets.svg")),
diff --git a/crates/ui-egui/src/panels/layers/controls.rs b/crates/ui-egui/src/panels/layers/controls.rs
index 890208141d..3c438f7915 100644
--- a/crates/ui-egui/src/panels/layers/controls.rs
+++ b/crates/ui-egui/src/panels/layers/controls.rs
@@ -458,8 +458,8 @@ pub(crate) fn footer(tree: &DocLayers, ui: &mut Ui, out: &mut Vec<(String, Value
.takes_drops_disabled(true)
.accepts_drops(move |d: &LayersDrag| own(d) && !d.layers().is_empty())
.also_accepts_drops(move |d: &PanelDrag| d.appearance_for(uid, reverts).is_some()),
- FooterAction::new(icon("file-plus"), tl!("Create New Layer").to_string()).enabled(new_layer_ok).accepts_drops(duplicate),
- FooterAction::new(icon("plus"), tl!("Create New Sublayer").to_string()).enabled(new_sublayer_ok),
+ FooterAction::new(icon("dc-new-item"), tl!("Create New Layer").to_string()).enabled(new_layer_ok).accepts_drops(duplicate),
+ FooterAction::new(icon("dc-new-sublayer"), tl!("Create New Sublayer").to_string()).enabled(new_sublayer_ok),
FooterAction::new(icon("frame"), tl!("Make/Release Clipping Mask").to_string()),
FooterAction::new(icon("search"), if layers_only { tl!("Locate Layer").to_string() } else { tl!("Locate Object").to_string() })
.enabled(locate_ok),
diff --git a/crates/ui-egui/src/panels/layers/tests.rs b/crates/ui-egui/src/panels/layers/tests.rs
index ef54366ba5..6aba351c34 100644
--- a/crates/ui-egui/src/panels/layers/tests.rs
+++ b/crates/ui-egui/src/panels/layers/tests.rs
@@ -1571,3 +1571,55 @@ fn the_order_revision_follows_what_the_display_order_reads() {
name_row(&mut app, a, "A");
assert_ne!(order(&app), closed, "an edit moves it");
}
+
+/// The Layers panel beside the Swatches panel, for comparing their footer icons.
+fn layers_and_swatches(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
+ show(app, ui);
+ crate::panels::swatches::show(app, ui);
+}
+
+/// The texture of the icon drawn inside `rect`.
+fn icon_texture(shapes: &[egui::Shape], rect: egui::Rect) -> egui::TextureId {
+ shapes
+ .iter()
+ .find_map(|shape| match shape {
+ egui::Shape::Mesh(mesh) if mesh.texture_id != egui::TextureId::default() && rect.contains_rect(mesh.calc_bounds()) => {
+ Some(mesh.texture_id)
+ }
+ _ => None,
+ })
+ .unwrap_or_else(|| panic!("no icon drawn in {rect:?}"))
+}
+
+/// Create New Layer shows the icon the other panels' new-item buttons show (here New Swatch), and Create New
+/// Sublayer shows a different one, so the generic new-item glyph adds a layer rather than a sublayer. A click on
+/// each makes a layer directly above the current one and a sublayer inside it.
+#[test]
+fn the_new_item_icon_makes_a_layer_and_the_sublayer_button_has_its_own() {
+ use crate::tests::panel_harness::Panel;
+
+ let (app, layer, _) = two_rects();
+ let mut panel = Panel::new(app, layers_and_swatches);
+ let (shapes, _) = panel.paint_at(2.0);
+ let new_item = icon_texture(&shapes, panel.rect("New Swatch"));
+ let new_layer = icon_texture(&shapes, panel.rect("Create New Layer"));
+ let new_sublayer = icon_texture(&shapes, panel.rect("Create New Sublayer"));
+ assert_eq!(new_layer, new_item, "Create New Layer shows the new-item icon");
+ assert_ne!(new_sublayer, new_item, "Create New Sublayer does not show the new-item icon");
+
+ panel.click("Create New Layer");
+ let added = {
+ let app = panel.app();
+ let doc = &app.session.active().unwrap().doc;
+ let ids: Vec = doc.layers.iter().map(|l| l.id).collect();
+ assert_eq!(ids.len(), 2, "a top-level layer is added");
+ assert_eq!(ids[0], layer, "directly above the current layer");
+ assert!(doc.node(layer).unwrap().children().into_iter().flatten().all(|c| !c.is_layer()), "and not inside it");
+ ids[1]
+ };
+ panel.click("Create New Sublayer");
+ let app = panel.app();
+ let doc = &app.session.active().unwrap().doc;
+ assert_eq!(doc.layers.len(), 2, "no top-level layer is added");
+ assert!(doc.node(added).unwrap().children().into_iter().flatten().any(|c| c.is_layer()), "a sublayer goes inside the current layer");
+}