mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 13:27:56 +00:00
Merge main into #7822
# Conflicts: # docs/gaps.md # docs/roadmap.md # docs/target-app-parity.md # docs/ui-parity.md
This commit is contained in:
@@ -218,12 +218,32 @@ pub(super) fn align(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let ids = selected_roots(s)?;
|
||||
let m = measure(s, p, "object.align")?;
|
||||
let (h, v) = direction(p, "object.align")?;
|
||||
choice(p, "object.align", "to", &["selection", "artboard", "key"])?;
|
||||
let to = choice(p, "object.align", "to", &["selection", "artboard", "key", "auto"])?;
|
||||
check_switches(p, &["patterns"], "object.align")?;
|
||||
check_numbers(p, &["artboard"], "object.align")?;
|
||||
if h.is_none() && v.is_none() {
|
||||
return Err(bad("object.align", "give horizontal or vertical"));
|
||||
}
|
||||
// Resolve only the explicit automatic target at this step, without changing the caller's
|
||||
// parameters or selection. The existing reference/anchor/guide paths receive a concrete target.
|
||||
let automatic_params = if to == Some("auto") {
|
||||
let selection = &s.doc()?.selection;
|
||||
let to = if selection.has_key() {
|
||||
"key"
|
||||
} else if selection.anchors.is_empty() && selection.len() == 1 {
|
||||
"artboard"
|
||||
} else {
|
||||
"selection"
|
||||
};
|
||||
let Some(mut params) = p.as_object().cloned() else {
|
||||
return Err(bad("object.align", "expected an object of align parameters"));
|
||||
};
|
||||
params.insert("to".into(), Value::String(to.into()));
|
||||
Some(Value::Object(params))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let p = automatic_params.as_ref().unwrap_or(p);
|
||||
// Anchor points selected with Direct Selection align themselves, as in Illustrator (#1180).
|
||||
if !s.doc()?.selection.anchors.is_empty() {
|
||||
return align_anchors(s, p, &ids, (h, v));
|
||||
|
||||
@@ -334,6 +334,9 @@ pub(super) fn isolate(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if matches!(st.doc.node(id).ok_or(EngineError::NoNode(id))?.kind, NodeKind::Text(_)) {
|
||||
return Err(bad("object.isolate", "type objects can't be isolated"));
|
||||
}
|
||||
if st.doc.node(id).is_some_and(|n| n.is_ruler_guide()) {
|
||||
return Err(bad("object.isolate", "ruler guides can't be isolated"));
|
||||
}
|
||||
let isolation =
|
||||
st.doc.node(id).filter(|n| n.extras().shaper.is_some()).and_then(|n| n.children()).and_then(|c| c.first()).map_or(id, |n| n.id);
|
||||
// A hidden or locked object, one in a hidden or locked group or layer, and a guide path while
|
||||
|
||||
@@ -241,7 +241,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Enter Isolation Mode",
|
||||
[],
|
||||
None,
|
||||
"{id?} isolate a group, a layer or a single object (default: the first selected object); type, a hidden or locked object, an object in a hidden or locked group or layer, and a guide path while Lock Guides is on are refused, and so is every object while an opacity mask is edited",
|
||||
"{id?} isolate a group, a layer or a single object (default: the first selected object); type, a ruler guide, a hidden or locked object, an object in a hidden or locked group or layer, and a guide path while Lock Guides is on are refused, and so is every object while an opacity mask is edited",
|
||||
crate::cmd::maskedit::outside_mask_editing,
|
||||
isolate
|
||||
),
|
||||
@@ -268,7 +268,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Align",
|
||||
["Window", "Align"],
|
||||
None,
|
||||
"{horizontal?: \"left\"|\"center\"|\"right\", vertical?: \"top\"|\"center\"|\"bottom\", to?: \"selection\"|\"artboard\"|\"key\" (default: the key object when the selection has one, select.key, else the selection; a key guide, select.key {guide}, stays put and the objects line up on its line: a vertical guide sets where left, center and right go and vertical alignment leaves them, a horizontal one the other way round; aligning to the key, the other selected ruler guides move too: a vertical guide to the key's left edge, center or right edge, a horizontal one to its top, center or bottom; aligning to the artboard moves selected guides to its edges too (#3463), and with only guides selected aligning to the selection moves them to their collective bounds), artboard?: index (0-based; with to: \"artboard\", the artboard to align to; the app passes the active one; default: the artboard under the center of the selection, else the first), bounds?: \"preview\"|\"geometric\" (default: the Use Preview Bounds preference; preview bounds take in strokes, geometry effects and projected 3D art), patterns?: bool (Transform Patterns: pattern fills and strokes transform with the art; default: prefs transformPatternTiles)} With anchor points selected (Direct Selection), the points align instead: to their own bounds, to the artboard (#1180), or, aligning to the key with a key anchor (select.key {id, anchor}), to the key anchor, which stays put",
|
||||
"{horizontal?: \"left\"|\"center\"|\"right\", vertical?: \"top\"|\"center\"|\"bottom\", to?: \"selection\"|\"artboard\"|\"key\"|\"auto\" (\"auto\": resolve at each call from the current selection: the key object, key anchor or key guide while set, else the artboard for exactly one selected object without selected anchors, else the selection; default: the key object when the selection has one, select.key, else the selection; a key guide, select.key {guide}, stays put and the objects line up on its line: a vertical guide sets where left, center and right go and vertical alignment leaves them, a horizontal one the other way round; aligning to the key, the other selected ruler guides move too: a vertical guide to the key's left edge, center or right edge, a horizontal one to its top, center or bottom; aligning to the artboard moves selected guides to its edges too (#3463), and with only guides selected aligning to the selection moves them to their collective bounds), artboard?: index (0-based; with to: \"artboard\", or \"auto\" choosing the artboard, the artboard to align to; the app passes the active one; default: the artboard under the center of the selection, else the first), bounds?: \"preview\"|\"geometric\" (default: the Use Preview Bounds preference; preview bounds take in strokes, geometry effects and projected 3D art), patterns?: bool (Transform Patterns: pattern fills and strokes transform with the art; default: prefs transformPatternTiles)} With anchor points selected (Direct Selection), the points align instead: to their own bounds, to the artboard (#1180), or, aligning to the key with a key anchor (select.key {id, anchor}), to the key anchor, which stays put",
|
||||
has_selection_or_guides,
|
||||
align
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user