Merge outside PR #621 into the third issue batch (M8)

This commit is contained in:
Tanish Manku committed 2026-11-27 18:30:35 -07:00
commit cea8f7b493
8 files changed
+290 -9

No files matched your search

+5
View File
@@ -173,6 +173,11 @@
* One step further back in the undo history is redrawn when you return to it (a few
milliseconds) instead of being found in memory.
* **Create Object in Properties** (#614). With raw (merge-drawing) shapes selected, Properties
now shows a **Create Object** button (also **Modify › Combine Objects › Create Object**,
`modify.create_object`) that turns one or more selected raw shapes on the active layer—including
a partial marquee selection—into a drawing object in one undo step (or a group of the merged
pieces when they have several colours or keep lines, as Union does).
* **Timeline and panel bugs from the tracker** (M8, backlog P-009 and P-010, ADR 0131).
* **Several layers selected at once** (#512). **Ctrl**-click a layer's name to add it or take
it out, **Shift**-click for every layer from the active one, or **Shift+Up** and
+62 -4
View File
@@ -10,7 +10,7 @@
use crate::merge::{Part, remerge_with};
use crate::params::*;
use crate::{CommandSpec, EngineError, Result, Session};
use anicraft_doc::{ColorEffect, Element, ElementId, ElementKind, LayerId, MAX_GROUP_DEPTH, Shape};
use anicraft_doc::{ColorEffect, Element, ElementId, ElementKind, LayerId, MAX_GROUP_DEPTH, Paint, Shape};
use anicraft_geom::planar::{self, Item};
use anicraft_geom::{Affine, FillRule, Path, Rect, Vec2};
use serde_json::{Value, json};
@@ -51,6 +51,15 @@ pub fn specs() -> Vec<CommandSpec> {
c("modify.intersect", "Intersect", "Modify/Combine Objects", None, "{} combine with op intersect", true, |s, _| combine(s, Op::Intersect)),
c("modify.punch", "Punch", "Modify/Combine Objects", None, "{} combine with op punch", true, |s, _| combine(s, Op::Punch)),
c("modify.crop", "Crop", "Modify/Combine Objects", None, "{} combine with op crop", true, |s, _| combine(s, Op::Crop)),
c(
"modify.create_object",
"Create Object",
"Modify/Combine Objects",
None,
"{} turns the selected raw shapes on the active layer into a drawing object (a group of the merged pieces when they have more than one colour or keep lines) → {created}",
true,
create_object,
),
]
}
@@ -299,10 +308,14 @@ fn result_of(s: &mut Session, pieces: Vec<Arc<Element>>) -> Option<Element> {
const TOO_LARGE: &str = "the shapes are too complex to combine at once";
fn combine(s: &mut Session, op: Op) -> Result<Value> {
/// A keyframe's elements and the selected shapes among them, bottom to top, with their index.
type SelectedShapes = (Vec<Arc<Element>>, Vec<(usize, Arc<Element>)>);
/// The selected shapes on the active layer, bottom to top, with their index in the keyframe.
fn selected_shapes(s: &mut Session, one_layer_err: &str) -> Result<SelectedShapes> {
let sel = s.selection.on(s.layer);
if s.selected_layers().len() > 1 {
return Err(EngineError::State("Combine Objects works on one layer: select shapes on one layer".into()));
return Err(EngineError::State(one_layer_err.into()));
}
let els = s.editable_keyframe()?.elements.clone();
// The selected shapes, bottom to top, with their index.
@@ -313,9 +326,51 @@ fn combine(s: &mut Session, op: Op) -> Result<Value> {
_ => return Err(EngineError::State("Combine Objects works on shapes and drawing objects: break symbols, text and groups apart first (Ctrl+B)".into())),
}
}
Ok((els, shapes))
}
fn create_object(s: &mut Session, _: &Value) -> Result<Value> {
let (els, shapes) = selected_shapes(s, "Create Object works on one layer: select raw shapes on one layer")?;
if shapes.is_empty() {
return Err(EngineError::State("select raw shapes to turn into a drawing object".into()));
}
if !shapes.iter().any(|(_, e)| crate::merge::mergeable(e).is_some()) {
return Err(EngineError::State("the selection is drawing objects already: select raw shapes to turn into a drawing object".into()));
}
if shapes.iter().any(|(_, e)| matches!(&e.kind, ElementKind::Shape(sh) if !sh.merge && sh.warp.is_some() && matches!(sh.fill, Some(Paint::Bitmap { .. })))) {
return Err(EngineError::State("Create Object can't keep the warp of a warped bitmap fill: remove its warp first (Modify › Asset Warp › Remove Warp)".into()));
}
if shapes.len() == 1 {
let Some((i, e)) = shapes.into_iter().next() else {
return Err(EngineError::State("select raw shapes to turn into a drawing object".into()));
};
let mut obj = Arc::unwrap_or_clone(e);
if let ElementKind::Shape(sh) = &mut obj.kind {
sh.merge = false;
}
let id = obj.id;
let mut out = els;
if let Some(slot) = out.get_mut(i) {
*slot = Arc::new(obj);
}
s.editable_keyframe()?.elements = out;
s.select_only([id]);
return Ok(json!({"created": [id.0]}));
}
let created = combine_shapes(s, Op::Union, els, shapes)?;
Ok(json!({"created": created.iter().map(|e| e.0).collect::<Vec<_>>()}))
}
fn combine(s: &mut Session, op: Op) -> Result<Value> {
let (els, shapes) = selected_shapes(s, "Combine Objects works on one layer: select shapes on one layer")?;
if shapes.len() < 2 {
return Err(EngineError::State("select two or more shapes to combine".into()));
}
let created = combine_shapes(s, op, els, shapes)?;
Ok(json!({"op": format!("{op:?}").to_ascii_lowercase(), "created": created.iter().map(|e| e.0).collect::<Vec<_>>()}))
}
fn combine_shapes(s: &mut Session, op: Op, els: Vec<Arc<Element>>, shapes: Vec<(usize, Arc<Element>)>) -> Result<Vec<ElementId>> {
let shape = |e: &Element| match &e.kind {
ElementKind::Shape(sh) => Some(sh.clone()),
_ => None,
@@ -367,6 +422,9 @@ fn combine(s: &mut Session, op: Op) -> Result<Value> {
}
}
}
if open_groups(s) + 1 > MAX_GROUP_DEPTH && results.iter().any(|(_, r)| r.as_ref().is_some_and(|e| matches!(e.kind, ElementKind::Group { .. }))) {
return Err(EngineError::State(format!("groups nest at most {MAX_GROUP_DEPTH} deep")));
}
// The sources go; each result takes its source's place.
let gone: HashSet<usize> = shapes.iter().map(|x| x.0).collect();
let mut created = Vec::new();
@@ -386,7 +444,7 @@ fn combine(s: &mut Session, op: Op) -> Result<Value> {
}
s.editable_keyframe()?.elements = out;
s.select_only(created.iter().copied());
Ok(json!({"op": format!("{op:?}").to_ascii_lowercase(), "created": created.iter().map(|e| e.0).collect::<Vec<_>>()}))
Ok(created)
}
/// The area `path` fills even-odd, from its flattening: each loop's area, added or taken away by
+207
View File
@@ -327,6 +327,213 @@ fn combine_refuses_what_it_cannot_combine() {
assert!(s.execute("modify.punch", &json!({})).is_err());
}
#[test]
fn create_object_turns_one_raw_shape_into_a_drawing_object_and_undoes() {
let mut s = Session::new(anicraft_doc::Document::default());
run(&mut s, "draw.object_drawing", json!({"on": false}));
run(&mut s, "draw.rect", json!({"x": 20, "y": 30, "w": 100, "h": 60, "fill": "#ff0000", "stroke": null}));
run(&mut s, "edit.select_all", json!({}));
assert!(matches!(&top(&s)[0].kind, ElementKind::Shape(sh) if sh.merge), "starts as raw");
let before_bounds = s.selection_bounds();
let before_pic = picture(&s);
let v = run(&mut s, "modify.create_object", json!({}));
let created: Vec<u64> = v["created"].as_array().into_iter().flatten().filter_map(Value::as_u64).collect();
assert_eq!(created.len(), 1, "{v}");
let els = top(&s);
assert_eq!(els.len(), 1);
assert!(matches!(&els[0].kind, ElementKind::Shape(sh) if !sh.merge), "became a drawing object");
assert_eq!(s.selection.id_list(), created, "new drawing object stays selected");
let after_bounds = s.selection_bounds();
assert!(after_bounds.min.distance(before_bounds.min) < 1e-3 && after_bounds.max.distance(before_bounds.max) < 1e-3, "bounds {after_bounds:?} vs {before_bounds:?}");
assert_eq!(picture(&s), before_pic, "look unchanged");
// Undo restores the raw shape.
run(&mut s, "edit.undo", json!({}));
assert_eq!(top(&s).len(), 1);
assert!(matches!(&top(&s)[0].kind, ElementKind::Shape(sh) if sh.merge), "undo restores raw");
// Partial raw selection cut out by a marquee becomes a drawing object, and undo heals the cut.
run(&mut s, "raw.select_rect", json!({"x0": 70, "y0": 0, "x1": 150, "y1": 120}));
let total_before: f64 = areas(&s).into_iter().sum();
let v = run(&mut s, "modify.create_object", json!({}));
let cut_id = v["created"][0].as_u64().unwrap_or(0);
assert_eq!(s.selection.id_list(), vec![cut_id]);
let els = top(&s);
assert_eq!(els.len(), 2);
assert!(els.iter().any(|e| e.id.0 == cut_id && matches!(&e.kind, ElementKind::Shape(sh) if !sh.merge)), "marquee part became drawing object");
assert!(els.iter().any(|e| e.id.0 != cut_id && matches!(&e.kind, ElementKind::Shape(sh) if sh.merge)), "rest stays raw");
let total_after: f64 = areas(&s).into_iter().sum();
assert!((total_after - total_before).abs() < 1.0, "{total_after} vs {total_before}");
run(&mut s, "edit.undo", json!({}));
assert_eq!(top(&s).len(), 1, "undo heals the marquee cut in one step");
assert!(matches!(&top(&s)[0].kind, ElementKind::Shape(sh) if sh.merge));
}
#[test]
fn create_object_combines_two_separate_raw_shapes() {
// Two separate raw shapes of the same fill become one drawing object.
let mut s = Session::new(anicraft_doc::Document::default());
run(&mut s, "draw.object_drawing", json!({"on": false}));
run(&mut s, "draw.rect", json!({"x": 0, "y": 0, "w": 60, "h": 60, "fill": "#ff0000", "stroke": null}));
run(&mut s, "draw.rect", json!({"x": 120, "y": 0, "w": 60, "h": 60, "fill": "#ff0000", "stroke": null}));
run(&mut s, "edit.select_all", json!({}));
assert_eq!(top(&s).len(), 2);
let before_bounds = s.selection_bounds();
let before_area: f64 = areas(&s).into_iter().sum();
let v = run(&mut s, "modify.create_object", json!({}));
let created: Vec<u64> = v["created"].as_array().into_iter().flatten().filter_map(Value::as_u64).collect();
assert_eq!(created.len(), 1, "{v}");
let els = top(&s);
assert_eq!(els.len(), 1);
assert!(matches!(&els[0].kind, ElementKind::Shape(sh) if !sh.merge), "one drawing object");
assert_eq!(s.selection.id_list(), created);
let after_bounds = s.selection_bounds();
assert!(after_bounds.min.distance(before_bounds.min) < 1e-3 && after_bounds.max.distance(before_bounds.max) < 1e-3);
assert!((areas(&s).into_iter().sum::<f64>() - before_area).abs() < 1.0);
run(&mut s, "edit.undo", json!({}));
assert_eq!(top(&s).len(), 2);
// Two separate raw shapes of different fills become a group per Union's rule.
let mut s = Session::new(anicraft_doc::Document::default());
run(&mut s, "draw.object_drawing", json!({"on": false}));
run(&mut s, "draw.rect", json!({"x": 0, "y": 0, "w": 60, "h": 60, "fill": "#ff0000", "stroke": null}));
run(&mut s, "draw.rect", json!({"x": 120, "y": 0, "w": 60, "h": 60, "fill": "#0000ff", "stroke": null}));
run(&mut s, "edit.select_all", json!({}));
let before_area: f64 = areas(&s).into_iter().sum();
let v = run(&mut s, "modify.create_object", json!({}));
let created: Vec<u64> = v["created"].as_array().into_iter().flatten().filter_map(Value::as_u64).collect();
assert_eq!(created.len(), 1, "{v}");
assert_eq!(top(&s).len(), 1);
assert!(matches!(top(&s)[0].kind, ElementKind::Group { .. }), "multi-colour union becomes a group");
assert_eq!(s.selection.id_list(), created);
assert!((areas(&s).into_iter().sum::<f64>() - before_area).abs() < 1.0);
}
#[test]
fn create_object_refuses_drawing_objects_and_non_shapes() {
let mut s = Session::new(anicraft_doc::Document::default());
run(&mut s, "draw.rect", json!({"x": 0, "y": 0, "w": 80, "h": 80, "fill": "#ff0000", "object": true}));
run(&mut s, "edit.select_all", json!({}));
let before = s.doc.clone();
assert!(matches!(s.execute("modify.create_object", &json!({})), Err(crate::EngineError::State(_))), "only a drawing object selected");
assert_eq!(s.doc, before, "document unchanged on refusal");
// A symbol in the selection is refused like Combine Objects.
run(&mut s, "modify.convert_to_symbol", json!({"name": "Sym"}));
run(&mut s, "draw.rect", json!({"x": 100, "y": 0, "w": 50, "h": 50, "fill": "#00ff00", "object": false}));
run(&mut s, "edit.select_all", json!({}));
let before = s.doc.clone();
assert!(matches!(s.execute("modify.create_object", &json!({})), Err(crate::EngineError::State(_))), "symbol in selection");
assert_eq!(s.doc, before, "document unchanged on symbol refusal");
}
#[test]
fn combine_and_create_object_refuse_groups_past_max_depth() {
let mut s = Session::new(anicraft_doc::Document::default());
run(&mut s, "draw.rect", json!({"x": 0, "y": 0, "w": 40, "h": 40, "fill": "#ff0000", "stroke": null}));
for _ in 0..anicraft_doc::MAX_GROUP_DEPTH {
run(&mut s, "edit.select_all", json!({}));
let g = id_of(&run(&mut s, "modify.group", json!({})), "group");
run(&mut s, "symbol.edit", json!({"id": g.0}));
}
assert_eq!(crate::cmds_group::open_groups(&s), anicraft_doc::MAX_GROUP_DEPTH);
// Two disjoint raw shapes with different fills would produce a group at depth MAX_GROUP_DEPTH + 1.
run(&mut s, "edit.select_all", json!({}));
run(&mut s, "edit.delete", json!({}));
run(&mut s, "draw.object_drawing", json!({"on": false}));
run(&mut s, "draw.rect", json!({"x": 0, "y": 0, "w": 40, "h": 40, "fill": "#ff0000", "stroke": null}));
run(&mut s, "draw.rect", json!({"x": 80, "y": 0, "w": 40, "h": 40, "fill": "#0000ff", "stroke": null}));
run(&mut s, "edit.select_all", json!({}));
let before = s.doc.clone();
for cmd in ["modify.create_object", "modify.union"] {
assert!(matches!(s.execute(cmd, &json!({})), Err(crate::EngineError::State(ref m)) if m.contains("groups nest at most")), "{cmd} should refuse past max depth");
assert_eq!(s.doc, before, "{cmd} leaves document unchanged on refusal");
}
// Punch and Crop on a stroked shape (fill + stroke produces a group) must also refuse.
run(&mut s, "edit.select_all", json!({}));
run(&mut s, "edit.delete", json!({}));
run(&mut s, "draw.object_drawing", json!({"on": true}));
run(&mut s, "draw.rect", json!({"x": 0, "y": 0, "w": 100, "h": 100, "fill": "#ff0000", "stroke": "#000000"}));
run(&mut s, "draw.rect", json!({"x": 50, "y": 50, "w": 100, "h": 100, "fill": "#0000ff", "stroke": null}));
run(&mut s, "edit.select_all", json!({}));
let before = s.doc.clone();
for cmd in ["modify.punch", "modify.crop"] {
assert!(matches!(s.execute(cmd, &json!({})), Err(crate::EngineError::State(ref m)) if m.contains("groups nest at most")), "{cmd} should refuse past max depth");
assert_eq!(s.doc, before, "{cmd} leaves document unchanged on refusal");
}
// Results that stay a single drawing object (not a group) remain allowed at MAX_GROUP_DEPTH.
run(&mut s, "edit.select_all", json!({}));
run(&mut s, "edit.delete", json!({}));
run(&mut s, "draw.object_drawing", json!({"on": false}));
run(&mut s, "draw.rect", json!({"x": 0, "y": 0, "w": 40, "h": 40, "fill": "#ff0000", "stroke": null}));
run(&mut s, "draw.rect", json!({"x": 80, "y": 0, "w": 40, "h": 40, "fill": "#ff0000", "stroke": null}));
run(&mut s, "edit.select_all", json!({}));
run(&mut s, "modify.create_object", json!({}));
assert_eq!(top(&s).len(), 1);
assert!(matches!(&top(&s)[0].kind, ElementKind::Shape(sh) if !sh.merge), "same-fill create_object produces a drawing object");
// Single-shape Create Object also stays allowed at MAX_GROUP_DEPTH.
run(&mut s, "draw.rect", json!({"x": 200, "y": 0, "w": 40, "h": 40, "fill": "#00ff00", "stroke": null}));
let raw_id = top(&s).iter().find(|e| matches!(&e.kind, ElementKind::Shape(sh) if sh.merge)).map(|e| e.id).unwrap_or_else(|| panic!("raw"));
run(&mut s, "element.select", json!({"ids": [raw_id.0]}));
run(&mut s, "modify.create_object", json!({}));
assert!(top(&s).iter().all(|e| matches!(&e.kind, ElementKind::Shape(sh) if !sh.merge)), "single raw shape became a drawing object");
}
#[test]
fn create_object_refuses_warped_bitmap_fill_but_allows_warped_solid_fill() {
// Mixed selection with a raw shape and a warped bitmap-fill drawing object: refused,
// leaving the document, selection and undo history untouched.
let mut s = Session::new(anicraft_doc::Document::default());
let bm = anicraft_doc::BitmapId(s.doc.alloc_id());
let mut rgba = Vec::with_capacity(40 * 20 * 4);
for y in 0..20u32 {
for x in 0..40u32 {
rgba.extend_from_slice(&[(x * 6) as u8, (y * 12) as u8, 128, 255]);
}
}
let png = anicraft_render::encode_png(40, 20, &rgba).unwrap_or_else(|e| panic!("encode_png: {e}"));
s.doc.bitmaps.push(Arc::new(anicraft_doc::Bitmap::from_png(bm, "ramp.png", png).unwrap_or_else(|| panic!("bitmap"))));
let bmp = id_of(&run(&mut s, "library.place", json!({"bitmap": bm.0, "x": 300, "y": 230})), "element");
run(&mut s, "warp.pin_add", json!({"element": bmp.0, "x": 285, "y": 230}));
let pin = run(&mut s, "warp.pin_add", json!({"element": bmp.0, "x": 315, "y": 230}))["pin"].as_u64().unwrap_or_else(|| panic!("pin"));
run(&mut s, "warp.pin_move", json!({"element": bmp.0, "pin": pin, "x": 315, "y": 270}));
assert!(
top(&s).iter().any(|e| e.id == bmp && matches!(&e.kind, ElementKind::Shape(sh) if !sh.merge && sh.warp.is_some() && matches!(sh.fill, Some(anicraft_doc::Paint::Bitmap { .. })))),
"placed bitmap must be a warped bitmap-fill drawing object"
);
run(&mut s, "draw.rect", json!({"x": 20, "y": 20, "w": 60, "h": 60, "fill": "#ff0000", "stroke": null, "object": false}));
run(&mut s, "edit.select_all", json!({}));
let before_doc = s.doc.clone();
let before_sel = s.selection.id_list();
let before_hist = s.history_len();
assert!(
matches!(s.execute("modify.create_object", &json!({})), Err(crate::EngineError::State(ref m)) if m.contains("warped bitmap")),
"warped bitmap fill in mixed selection must be refused"
);
assert_eq!(s.doc, before_doc, "document unchanged on warped bitmap refusal");
assert_eq!(s.selection.id_list(), before_sel, "selection unchanged on warped bitmap refusal");
assert_eq!(s.history_len(), before_hist, "no undo step recorded on warped bitmap refusal");
// Mixed selection with a raw shape and a warped solid-fill drawing object: still converts,
// preserving the bent outline.
let mut s = Session::new(anicraft_doc::Document::default());
let solid = id_of(&run(&mut s, "draw.rect", json!({"x": 100, "y": 100, "w": 200, "h": 80, "fill": "#3080ff", "stroke": null, "object": true})), "element");
run(&mut s, "warp.pin_add", json!({"element": solid.0, "x": 110, "y": 140}));
let pin = run(&mut s, "warp.pin_add", json!({"element": solid.0, "x": 290, "y": 140}))["pin"].as_u64().unwrap_or_else(|| panic!("pin"));
run(&mut s, "warp.pin_move", json!({"element": solid.0, "pin": pin, "x": 290, "y": 200}));
let bent_bounds = top(&s)[0].bounds(&s.doc);
assert!(bent_bounds.max.y > 180.0, "solid drawing object was bent downward: {bent_bounds:?}");
run(&mut s, "draw.rect", json!({"x": 10, "y": 10, "w": 50, "h": 50, "fill": "#3080ff", "stroke": null, "object": false}));
run(&mut s, "edit.select_all", json!({}));
let before_area: f64 = areas(&s).into_iter().sum();
let v = run(&mut s, "modify.create_object", json!({}));
let created: Vec<u64> = v["created"].as_array().into_iter().flatten().filter_map(Value::as_u64).collect();
assert_eq!(created.len(), 1, "{v}");
let els = top(&s);
assert_eq!(els.len(), 1);
assert!(matches!(&els[0].kind, ElementKind::Shape(sh) if !sh.merge), "warped solid + raw same fill becomes a drawing object");
assert_eq!(s.selection.id_list(), created);
assert!(els[0].bounds(&s.doc).max.y >= bent_bounds.max.y - 1.0, "bent outline kept after Create Object");
let after_area: f64 = areas(&s).into_iter().sum();
assert!((after_area - before_area).abs() < 1.0, "combined area preserved: {after_area} vs {before_area}");
}
#[test]
fn ctrl_drag_pulls_a_sharp_corner_out_of_a_line() {
// What the Selection tool's Ctrl-drag runs (issue #200): a point where the edge was grabbed,
+7 -2
View File
@@ -70,8 +70,10 @@ Properties. The setting applies to the Rectangle, Oval, PolyStar, Line, Pen, Pen
tools.
The Eraser only erases merged drawing. Drawing objects, symbols and text are left alone by
it. To turn a drawing object back into merged drawing, select it and choose **Modify › Break
Apart** (**Ctrl+B**): it merges with the merged shapes it touches.
it. To turn merged shapes into a drawing object, select them and click **Create Object** in
Properties (or choose **Modify › Combine Objects › Create Object**). To turn a drawing object
back into merged drawing, select it and choose **Modify › Break Apart** (**Ctrl+B**): it
merges with the merged shapes it touches.
To change a drawing object's shape, **double-click** it (or select it and press **Ctrl+E**).
It opens in place, as a group does (see [Grouping](#grouping)): the rest of the stage dims, and
@@ -592,6 +594,9 @@ topmost shape is the one on top in the stacking order.
* **Punch** cuts the top shape's area out of the shapes under it, and removes the top shape.
* **Crop** keeps only the parts of the shapes under it that are inside the top shape, and
removes the top shape.
* **Create Object** turns one or more selected merged shapes on the active layer into a drawing
object (or a group of the merged pieces when they have several colours or keep lines). With
raw shapes selected, **Create Object** also appears in **Properties**.
The top shape cuts with its fill, so it needs one. Break symbols, text and groups apart first
(**Ctrl+B**).
+2 -2
View File
@@ -143,10 +143,10 @@ The **Headless** column at the end of each table says whether `anicraft-cli` and
| Feature | Status | Notes | Headless |
|---|---|---|---|
| Merge drawing: raw strokes and fills that cut and join | **done** | [ADR 0031](adr/0031-merge-drawing.md), [ADR 0041](adr/0041-selection-tool-on-raw-drawings.md), [ADR 0042](adr/0042-subselection-and-merging-everywhere.md), [ADR 0045](adr/0045-raw-points-and-raw-shapes-inside-symbols.md); [drawing](guide/drawing.md). Open bug: a hairline between merged curved fills ([#182](https://github.com/storytold/anicraft/issues/182), P-013). |
| Object drawing | **done** | Edit inside by double-click. Editing without opening is missing ([#181](https://github.com/storytold/anicraft/issues/181)). |
| Object drawing | **done** | Edit inside by double-click; **Create Object** in Properties or Modify › Combine Objects turns raw shapes into a drawing object ([#614](https://github.com/storytold/anicraft/issues/614)). Editing without opening is missing ([#181](https://github.com/storytold/anicraft/issues/181)). |
| Groups, nested, edited in place | **done** | [ADR 0073](adr/0073-groups-combine-objects-and-selection-modifiers.md). |
| Break Apart | **done** | |
| Combine Objects: Union, Intersect, Punch, Crop | **done** | [ADR 0073](adr/0073-groups-combine-objects-and-selection-modifiers.md). One layer at a time. |
| Combine Objects: Union, Intersect, Punch, Crop | **done** | [ADR 0073](adr/0073-groups-combine-objects-and-selection-modifiers.md), plus **Create Object** for raw shapes ([#614](https://github.com/storytold/anicraft/issues/614)). One layer at a time. |
| Arrange (front, back, forward, backward) | **done** | |
| Align, distribute | **done** | |
| Match Size, Space evenly | **done** | `align.match_width`, `align.match_height`, `align.match_size`, `align.space_h`, `align.space_v` (#566). |
+1
View File
@@ -465,6 +465,7 @@ fn enabled(app: &App, id: &str) -> bool {
"modify.group" => !app.s.selection.is_empty(),
"modify.ungroup" => app.s.selected_elements().iter().any(|(_, e)| matches!(e.kind, anicraft_engine::doc::ElementKind::Group { .. })),
"modify.union" | "modify.intersect" | "modify.punch" | "modify.crop" => app.s.selected_elements().iter().filter(|(_, e)| matches!(e.kind, anicraft_engine::doc::ElementKind::Shape(_))).count() >= 2,
"modify.create_object" => selected_shape(app, |sh| sh.merge),
"scene.prev" | "scene.move_up" => app.s.scene > 0,
"view.guides_clear" => !app.s.guides().is_empty(),
"scene.next" | "scene.move_down" => app.s.scene + 1 < app.s.doc.scenes.len(),
+5
View File
@@ -1474,6 +1474,11 @@ fn selection_props(app: &mut App, ui: &mut egui::Ui, e: &anicraft_engine::doc::E
}
ui.add_space(6.0);
ui.horizontal_wrapped(|ui| {
if all.iter().any(|el| matches!(&el.kind, ElementKind::Shape(sh) if sh.merge))
&& ui.button(tr!("Create Object")).on_hover_text(tr!("Turn the selected raw shapes into a drawing object")).clicked()
{
app.invoke("modify.create_object");
}
for (label, id) in [(tr!("Convert to Symbol"), "modify.convert_to_symbol"), (tr!("Break Apart"), "modify.break_apart"), (tr!("Duplicate"), "edit.duplicate"), (tr!("Delete"), "edit.delete")] {
if ui.button(label).clicked() {
app.invoke(id);
+1 -1
View File
@@ -1004,7 +1004,7 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) {
}
// Modify › Combine Objects (ADR 0073), as in Animate's menu.
ui.menu_button(tr!("Combine Objects"), |ui| {
for id in ["modify.union", "modify.intersect", "modify.punch", "modify.crop"] {
for id in ["modify.union", "modify.intersect", "modify.punch", "modify.crop", "modify.create_object"] {
crate::menus::cmd_item(app, ui, id);
}
});