mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-17 08:26:28 +00:00
Merge pull request #8238 from dotCooCoo/feat/blend-options-id-fields
Blend: options on several blends set only the values given; `id` edits one blend
This commit is contained in:
@@ -92,7 +92,7 @@ pub(super) fn blend_make(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
_ => defaults,
|
||||
};
|
||||
let spacing = spacing_param(p, C, cur.spacing)?;
|
||||
let orientation = orientation_param(p, cur.orientation);
|
||||
let orientation = orientation_param(p, C, cur.orientation)?;
|
||||
let (ease0, color0, no_spine) = match base.as_ref().map(|n| &n.kind) {
|
||||
Some(NodeKind::Blend { spec, .. }) => (spec.ease, spec.color_shift, spec.no_spine),
|
||||
_ => (Default::default(), 0.0, !create_spine.creates_spine()),
|
||||
@@ -364,29 +364,91 @@ fn selected_spec(s: &Session) -> Option<(NodeId, BlendSpec, Vec<NodeId>)> {
|
||||
|
||||
pub(super) fn blend_options(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
const C: &str = "object.blend.options";
|
||||
let Some((_, cur, _)) = selected_spec(s) else {
|
||||
let id = crate::cmd::object_param(p, "id", C)?;
|
||||
let target = match id {
|
||||
Some(id) => {
|
||||
let doc = &s.doc()?.doc;
|
||||
match doc.node(id).map(|n| &n.kind) {
|
||||
Some(NodeKind::Blend { .. }) if !doc.is_editable(id) => return Err(bad(C, "the object is hidden or locked")),
|
||||
Some(NodeKind::Blend { spec, children }) => Some((id, (**spec).clone(), children.iter().map(|c| c.id).collect())),
|
||||
_ => return Err(bad(C, "not a blend")),
|
||||
}
|
||||
}
|
||||
None => selected_spec(s),
|
||||
};
|
||||
let Some((_, cur, _)) = target else {
|
||||
if ["easingType", "ramp", "colorShift"].iter().any(|key| p.get(*key).is_some_and(|v| !v.is_null())) {
|
||||
return Err(bad(C, "select a blend to set easing or color shift"));
|
||||
}
|
||||
// Nothing to set them on: the options new blends start with (easing is per blend).
|
||||
let d = s.prefs.blend_options.unwrap_or_default();
|
||||
let spacing = spacing_param(p, C, d.spacing)?;
|
||||
s.prefs.blend_options = Some(BlendDefaults { spacing, orientation: orientation_param(p, d.orientation), ..d });
|
||||
let orientation = orientation_param(p, C, d.orientation)?;
|
||||
s.prefs.blend_options = Some(BlendDefaults { spacing, orientation, ..d });
|
||||
return Ok(json!({ "defaults": true }));
|
||||
};
|
||||
if gives_easing(p) && any_without_spine(s) {
|
||||
let no_spine = if id.is_some() { cur.no_spine } else { any_without_spine(s) };
|
||||
if gives_easing(p) && no_spine {
|
||||
return Err(bad(C, "the blend has no spine"));
|
||||
}
|
||||
// Every value is checked before anything changes. Each blend then takes only the values that
|
||||
// were given and keeps its own for the rest, so editing several blends does not copy the first
|
||||
// one's options onto the others.
|
||||
let given = |key: &str| p.get(key).is_some_and(|v| !v.is_null());
|
||||
let has_count = given("value") || given("steps") || given("distance");
|
||||
let has_spacing = given("spacing") || has_count || p.get("smooth").and_then(Value::as_bool) == Some(true);
|
||||
let spacing = spacing_param(p, C, cur.spacing)?;
|
||||
let orientation = orientation_param(p, cur.orientation);
|
||||
let orientation = orientation_param(p, C, cur.orientation)?;
|
||||
let ease = ease_param(p, C, cur.ease)?;
|
||||
let color_shift = percent_param(p, C, "colorShift", cur.color_shift, -100.0)?;
|
||||
edit_blends(s, "Blend Options", |_, spec| {
|
||||
spec.spacing = spacing;
|
||||
spec.orientation = orientation;
|
||||
spec.ease = ease;
|
||||
spec.color_shift = color_shift;
|
||||
})
|
||||
let (has_orientation, has_kind, has_ramp, has_shift) = (given("orientation"), given("easingType"), given("ramp"), given("colorShift"));
|
||||
let set = |spec: &mut BlendSpec| {
|
||||
// A spacing mode without a count keeps the count of a blend already in that mode.
|
||||
let same_mode = std::mem::discriminant(&spacing) == std::mem::discriminant(&spec.spacing);
|
||||
if has_spacing && (has_count || !same_mode) {
|
||||
spec.spacing = spacing;
|
||||
}
|
||||
if has_orientation {
|
||||
spec.orientation = orientation;
|
||||
}
|
||||
if has_kind {
|
||||
spec.ease.kind = ease.kind;
|
||||
}
|
||||
if has_ramp {
|
||||
spec.ease.ramp = ease.ramp;
|
||||
}
|
||||
if has_shift {
|
||||
spec.color_shift = color_shift;
|
||||
}
|
||||
};
|
||||
let targets = match id {
|
||||
Some(id) => vec![id],
|
||||
None => selected_of(s, is_blend),
|
||||
};
|
||||
let doc = &s.doc()?.doc;
|
||||
let changes = |b: &NodeId| match doc.node(*b).map(|n| &n.kind) {
|
||||
Some(NodeKind::Blend { spec, .. }) => {
|
||||
let mut next = (**spec).clone();
|
||||
set(&mut next);
|
||||
next != **spec
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
if !targets.iter().any(changes) {
|
||||
return ok();
|
||||
}
|
||||
match id {
|
||||
Some(id) => {
|
||||
s.edit("Blend Options", |d, _| {
|
||||
if let Some(NodeKind::Blend { spec, .. }) = d.node_mut(id).map(|n| &mut n.kind) {
|
||||
set(spec);
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
ok()
|
||||
}
|
||||
None => edit_blends(s, "Blend Options", |_, spec| set(spec)),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn blend_set_easing(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
|
||||
@@ -36,7 +36,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Blend Options…",
|
||||
["Object", "Blend"],
|
||||
None,
|
||||
"{spacing?: smooth|steps|distance, value?: n, steps?: n, distance?: pt, orientation?: page|path, smooth?: bool, easingType?: easeIn|easeOut|easeInOut|easeOutIn, ramp?: pct, colorShift?: pct} set the options of the selected blends; easingType chooses the distribution, ramp sets its strength (0..100; 0 = even), colorShift (-100..100; 0 = even) shifts colours independently of shape/position easing (omitted ones keep their value; out of range is an error); with no blend selected, the options new blends start with (spacing and orientation only; a tool setting, not an undo step) → {defaults?: true}",
|
||||
"{id?: id, spacing?: smooth|steps|distance, value?: n, steps?: n, distance?: pt, orientation?: page|path, smooth?: bool, easingType?: easeIn|easeOut|easeInOut|easeOutIn, ramp?: pct, colorShift?: pct} set the options of the selected blends (or of the blend `id` alone; a hidden or locked one is an error); easingType chooses the distribution, ramp sets its strength (0..100; 0 = even), colorShift (-100..100; 0 = even) shifts colours independently of shape/position easing (each blend keeps its own value for every option omitted; out of range is an error and changes nothing; no undo step when nothing changes); with no blend selected and no `id`, the options new blends start with (spacing and orientation only; a tool setting, not an undo step) → {defaults?: true}",
|
||||
always,
|
||||
blend_options
|
||||
),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::mesh::whole;
|
||||
use super::{
|
||||
Arc, BlendEase, BlendEaseType, BlendOrientation, BlendSpacing, Document, EngineError, Node, NodeId, NodeKind, Result, Selection, Session, Value,
|
||||
bad, check_numbers, has_selection, json, named_ids, selected_roots, str_param, switch_or,
|
||||
bad, check_numbers, has_selection, json, named_ids, selected_roots, switch_or, text_param,
|
||||
};
|
||||
|
||||
pub(super) fn ids_json(ids: &[NodeId]) -> Value {
|
||||
@@ -128,8 +128,11 @@ pub(super) fn spacing_param(p: &Value, cmd: &str, current: BlendSpacing) -> Resu
|
||||
let smooth = switch_or(p, "smooth", false, cmd)?;
|
||||
let num = |k: &str| p.get(k).and_then(Value::as_f64);
|
||||
let steps = |k: &str, n: f64| whole(n, k, cmd).map(|n| BlendSpacing::Steps(n as u32));
|
||||
let mode = str_param(p, "spacing");
|
||||
let mode = text_param(p, "spacing", cmd)?;
|
||||
let value = num("value");
|
||||
if mode.is_none() && value.is_some() {
|
||||
return Err(bad(cmd, "`value` needs `spacing` (steps|distance)"));
|
||||
}
|
||||
let sp = match mode {
|
||||
Some("smooth") | Some("smoothColor") => BlendSpacing::SmoothColor,
|
||||
Some("steps") => match value {
|
||||
@@ -157,11 +160,15 @@ pub(super) fn spacing_param(p: &Value, cmd: &str, current: BlendSpacing) -> Resu
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn orientation_param(p: &Value, current: BlendOrientation) -> BlendOrientation {
|
||||
match str_param(p, "orientation") {
|
||||
Some("path") | Some("alignToPath") => BlendOrientation::AlignToPath,
|
||||
Some("page") | Some("alignToPage") => BlendOrientation::AlignToPage,
|
||||
_ => current,
|
||||
/// `orientation`: `page` or `path`; missing or null keeps `current`, and any other value is an error.
|
||||
pub(super) fn orientation_param(p: &Value, cmd: &str, current: BlendOrientation) -> Result<BlendOrientation> {
|
||||
match p.get("orientation").filter(|v| !v.is_null()) {
|
||||
None => Ok(current),
|
||||
Some(v) => match v.as_str() {
|
||||
Some("path") | Some("alignToPath") => Ok(BlendOrientation::AlignToPath),
|
||||
Some("page") | Some("alignToPage") => Ok(BlendOrientation::AlignToPage),
|
||||
_ => Err(bad(cmd, "orientation must be page or path")),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -772,3 +772,142 @@ fn whether_a_blend_has_a_spine_is_saved_and_old_blends_have_one() {
|
||||
assert!(!v.no_spine, "{odd}");
|
||||
}
|
||||
}
|
||||
|
||||
fn undo_len(s: &Session) -> usize {
|
||||
s.doc().unwrap().history.undo.len()
|
||||
}
|
||||
|
||||
/// Two blends with different options, both selected: the first (Steps 3, along the path, Ease
|
||||
/// Out at 20%, Shift 10%) and the second (Distance 12 pt, along the page, Ease In Out at 60%,
|
||||
/// Shift -40%).
|
||||
fn two_different_blends(s: &mut Session) -> (NodeId, NodeId) {
|
||||
let b1 = make(s, 0.0, json!({"spacing": "steps", "orientation": "path"}));
|
||||
let b2 = make(s, 100.0, json!({"spacing": "distance", "value": 12, "orientation": "path"}));
|
||||
s.execute("object.blend.setEasing", &json!({"id": b1.0, "easingType": "easeOut", "ramp": 20, "colorShift": 10})).unwrap();
|
||||
s.execute("object.blend.setEasing", &json!({"id": b2.0, "easingType": "easeInOut", "ramp": 60, "colorShift": -40})).unwrap();
|
||||
sel(s, &[b2]);
|
||||
s.execute("object.blend.options", &json!({"orientation": "page"})).unwrap();
|
||||
sel(s, &[b1, b2]);
|
||||
(b1, b2)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn options_on_several_blends_set_only_the_values_given() {
|
||||
let mut s = session();
|
||||
let (b1, b2) = two_different_blends(&mut s);
|
||||
let (before1, before2) = (spec(&s, b1).1, spec(&s, b2).1);
|
||||
assert_ne!(before1.spacing, before2.spacing);
|
||||
// Each value given goes to every selected blend; each keeps its own for the others.
|
||||
for (p, apply) in [
|
||||
(json!({"colorShift": 30}), (|sp: &mut BlendSpec| sp.color_shift = 30.0) as fn(&mut BlendSpec)),
|
||||
(json!({"ramp": 45}), |sp| sp.ease.ramp = 0.45),
|
||||
(json!({"easingType": "easeOutIn"}), |sp| sp.ease.kind = vectorcraft_doc::BlendEaseType::OutIn),
|
||||
(json!({"orientation": "path"}), |sp| sp.orientation = BlendOrientation::AlignToPath),
|
||||
(json!({"spacing": "steps", "value": 7}), |sp| sp.spacing = BlendSpacing::Steps(7)),
|
||||
] {
|
||||
let (mut want1, mut want2) = (spec(&s, b1).1, spec(&s, b2).1);
|
||||
apply(&mut want1);
|
||||
apply(&mut want2);
|
||||
s.execute("object.blend.options", &p).unwrap();
|
||||
assert_eq!((spec(&s, b1).1, spec(&s, b2).1), (want1, want2), "{p}");
|
||||
}
|
||||
// A spacing mode without a count keeps the count of a blend already in that mode; a blend in
|
||||
// another mode takes the mode's starting count.
|
||||
s.execute("object.blend.options", &json!({"id": b2.0, "spacing": "distance", "value": 12})).unwrap();
|
||||
s.execute("object.blend.options", &json!({"spacing": "steps"})).unwrap();
|
||||
assert_eq!((spec(&s, b1).1.spacing, spec(&s, b2).1.spacing), (BlendSpacing::Steps(7), BlendSpacing::Steps(5)));
|
||||
s.execute("object.blend.options", &json!({"id": b2.0, "spacing": "steps", "value": 12})).unwrap();
|
||||
s.execute("object.blend.options", &json!({"spacing": "steps"})).unwrap();
|
||||
assert_eq!((spec(&s, b1).1.spacing, spec(&s, b2).1.spacing), (BlendSpacing::Steps(7), BlendSpacing::Steps(12)));
|
||||
// The whole edit of both blends is one undo step.
|
||||
let depth = undo_len(&s);
|
||||
s.execute("object.blend.options", &json!({"colorShift": -5, "ramp": 5})).unwrap();
|
||||
assert_eq!(undo_len(&s), depth + 1);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!((spec(&s, b1).1.color_shift, spec(&s, b2).1.color_shift), (30.0, 30.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn options_with_an_id_edit_that_blend_alone() {
|
||||
let mut s = session();
|
||||
let (b1, b2) = two_different_blends(&mut s);
|
||||
let before2 = spec(&s, b2).1;
|
||||
let mut want1 = spec(&s, b1).1;
|
||||
s.execute("object.blend.options", &json!({"id": b1.0, "spacing": "distance", "value": 15, "ramp": 50, "colorShift": -20})).unwrap();
|
||||
want1.spacing = BlendSpacing::Distance(15.0);
|
||||
want1.ease.ramp = 0.5;
|
||||
want1.color_shift = -20.0;
|
||||
assert_eq!(spec(&s, b1).1, want1, "only the values given change");
|
||||
assert_eq!(spec(&s, b2).1, before2, "a selected blend that is not `id` stays as it was");
|
||||
// `id` works with nothing selected, and does not set the options new blends start with.
|
||||
s.execute("select.none", &json!({})).unwrap();
|
||||
let defaults = s.execute("object.blend.info", &json!({})).unwrap();
|
||||
s.execute("object.blend.options", &json!({"id": b2.0, "orientation": "path"})).unwrap();
|
||||
assert_eq!(spec(&s, b2).1.orientation, BlendOrientation::AlignToPath);
|
||||
assert_eq!(s.execute("object.blend.info", &json!({})).unwrap(), defaults);
|
||||
// A hidden or locked blend and an object that is not a blend are errors that change nothing.
|
||||
for (visible, locked) in [(false, false), (true, true)] {
|
||||
s.edit("state", |d, _| {
|
||||
let n = d.node_mut(b1).unwrap();
|
||||
(n.visible, n.locked) = (visible, locked);
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let (before, depth) = (spec(&s, b1).1, undo_len(&s));
|
||||
let error = s.execute("object.blend.options", &json!({"id": b1.0, "colorShift": 25})).unwrap_err().to_string();
|
||||
assert!(error.contains("the object is hidden or locked"), "{error}");
|
||||
assert_eq!((spec(&s, b1).1, undo_len(&s)), (before, depth));
|
||||
}
|
||||
let other = rect(&mut s, 300.0, 0.0, 10.0);
|
||||
for id in [json!(other.0), json!(999_999)] {
|
||||
let error = s.execute("object.blend.options", &json!({"id": id, "colorShift": 25})).unwrap_err().to_string();
|
||||
assert!(error.contains("not a blend"), "{error}");
|
||||
}
|
||||
// The blend's own spine decides whether easing is allowed, whatever is selected.
|
||||
s.execute("object.blend.createSpine", &json!({"mode": "never"})).unwrap();
|
||||
let bare = make(&mut s, 300.0, json!({}));
|
||||
sel(&mut s, &[b2]);
|
||||
let error = s.execute("object.blend.options", &json!({"id": bare.0, "ramp": 30})).unwrap_err().to_string();
|
||||
assert!(error.contains("the blend has no spine"), "{error}");
|
||||
s.execute("object.blend.options", &json!({"id": b2.0, "ramp": 30})).unwrap();
|
||||
assert_eq!(spec(&s, b2).1.ease.ramp, 0.3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn options_that_change_nothing_or_are_refused_record_no_undo_step() {
|
||||
let mut s = session();
|
||||
let (b1, b2) = two_different_blends(&mut s);
|
||||
let before = (spec(&s, b1).1, spec(&s, b2).1);
|
||||
let depth = undo_len(&s);
|
||||
// Values the blends already have, and no values at all.
|
||||
for p in [json!({}), json!({"smooth": false}), json!({"orientation": "page", "id": b2.0}), json!({"colorShift": 10, "id": b1.0})] {
|
||||
s.execute("object.blend.options", &p).unwrap();
|
||||
assert_eq!(undo_len(&s), depth, "{p}");
|
||||
}
|
||||
// An invalid value anywhere stops the whole call before anything changes.
|
||||
for p in [
|
||||
json!({"colorShift": 50, "ramp": 101}),
|
||||
json!({"colorShift": 50, "ramp": -1}),
|
||||
json!({"colorShift": 50, "ramp": "half"}),
|
||||
json!({"ramp": 50, "colorShift": -101}),
|
||||
json!({"ramp": 50, "easingType": "linear"}),
|
||||
json!({"ramp": 50, "spacing": "steps", "value": 0}),
|
||||
json!({"ramp": 50, "spacing": "distance", "value": -3}),
|
||||
json!({"ramp": 50, "id": "b1"}),
|
||||
json!({"ramp": 50, "orientation": "sideways"}),
|
||||
json!({"ramp": 50, "orientation": 1}),
|
||||
json!({"ramp": 50, "value": 3}),
|
||||
json!({"ramp": 50, "spacing": 123}),
|
||||
] {
|
||||
assert!(s.execute("object.blend.options", &p).is_err(), "{p}");
|
||||
assert_eq!((spec(&s, b1).1, spec(&s, b2).1, undo_len(&s)), (before.0.clone(), before.1.clone(), depth), "{p}");
|
||||
}
|
||||
// Make and the options new blends start with refuse an unknown orientation too.
|
||||
let error = s.execute("object.blend.make", &json!({"orientation": "sideways"})).unwrap_err().to_string();
|
||||
assert!(error.contains("orientation must be page or path"), "{error}");
|
||||
assert_eq!(undo_len(&s), depth);
|
||||
s.execute("select.none", &json!({})).unwrap();
|
||||
let defaults = s.execute("object.blend.info", &json!({})).unwrap();
|
||||
assert!(s.execute("object.blend.options", &json!({"orientation": "sideways"})).is_err());
|
||||
assert_eq!(s.execute("object.blend.info", &json!({})).unwrap(), defaults);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ pub fn open(app: &mut VectorcraftApp) -> Result<Value, String> {
|
||||
let target = fields["target"].clone();
|
||||
let Some(o) = fields.as_object_mut() else { return Err("no blend options".into()) };
|
||||
o.retain(|k, _| matches!(k.as_str(), "spacing" | "steps" | "distance" | "orientation"));
|
||||
let opened = Value::Object(o.clone());
|
||||
o.insert("__opened".into(), opened);
|
||||
o.insert("__target".into(), target);
|
||||
o.insert("preview".into(), json!(true));
|
||||
app.ui.dialog = Some(Dialog::new(KIND, fields));
|
||||
@@ -47,13 +49,33 @@ fn on_blend(d: &Dialog) -> bool {
|
||||
d.str("__target") == "blend"
|
||||
}
|
||||
|
||||
/// `object.blend.options` parameters from the fields.
|
||||
/// The field set when the spacing or its count is picked or typed in the dialog: OK then applies
|
||||
/// it to every selected blend, even when it matches the first blend's.
|
||||
const SET_SPACING: &str = "__setSpacing";
|
||||
|
||||
/// The field set when an orientation button is clicked, as [`SET_SPACING`] for the orientation.
|
||||
const SET_ORIENTATION: &str = "__setOrientation";
|
||||
|
||||
/// `object.blend.options` parameters from the fields set in the dialog or differing from the
|
||||
/// values it opened with, so each selected blend keeps its own values for the rest.
|
||||
fn params(d: &Dialog) -> Value {
|
||||
let mut p = json!({"spacing": d.str("spacing"), "orientation": d.str("orientation")});
|
||||
match d.str("spacing").as_str() {
|
||||
"steps" => p["steps"] = json!(d.f64("steps", 5.0).round().clamp(1.0, 1000.0)),
|
||||
"distance" => p["distance"] = json!(d.f64("distance", 10.0)),
|
||||
_ => {}
|
||||
let opened = |k: &str| d.fields.get("__opened").and_then(|o| o.get(k)).cloned().unwrap_or(Value::Null);
|
||||
let mode = d.str("spacing");
|
||||
let count = match mode.as_str() {
|
||||
"steps" => Some(("steps", d.f64("steps", 5.0).round().clamp(1.0, 1000.0))),
|
||||
"distance" => Some(("distance", d.f64("distance", 10.0))),
|
||||
_ => None,
|
||||
};
|
||||
let mut p = json!({});
|
||||
if d.bool(SET_SPACING) || opened("spacing") != json!(mode) || count.is_some_and(|(k, v)| opened(k).as_f64() != Some(v)) {
|
||||
p["spacing"] = json!(mode);
|
||||
if let Some((k, v)) = count {
|
||||
p[k] = json!(v);
|
||||
}
|
||||
}
|
||||
let orientation = d.str("orientation");
|
||||
if d.bool(SET_ORIENTATION) || opened("orientation") != json!(orientation) {
|
||||
p["orientation"] = json!(orientation);
|
||||
}
|
||||
p
|
||||
}
|
||||
@@ -66,11 +88,14 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool {
|
||||
widgets::label_row(ui, tl!("Spacing:"), LABEL_W, |ui| {
|
||||
if let Some((value, _)) = widgets::dropdown(ui, "blend-spacing", shown, &labels, 150.0).and_then(|i| SPACING.get(i)) {
|
||||
d.fields.insert("spacing".into(), json!(value));
|
||||
d.fields.insert(SET_SPACING.into(), json!(true));
|
||||
}
|
||||
ui.add_space(6.0);
|
||||
match mode.as_str() {
|
||||
"distance" => {
|
||||
form::length(ui, d, "distance", unit, 72.0);
|
||||
if form::length(ui, d, "distance", unit, 72.0) {
|
||||
d.fields.insert(SET_SPACING.into(), json!(true));
|
||||
}
|
||||
}
|
||||
// Smooth Color picks the count itself: the field shows the steps, disabled.
|
||||
m => {
|
||||
@@ -78,6 +103,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool {
|
||||
ui.add_enabled_ui(m == "steps", |ui| {
|
||||
if let Some(n) = widgets::range_field(ui, "blend-steps", steps, 1.0..=1000.0, "", 0, 72.0) {
|
||||
d.fields.insert("steps".into(), json!(n));
|
||||
d.fields.insert(SET_SPACING.into(), json!(true));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -89,6 +115,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool {
|
||||
for (value, along, tip) in [("page", false, tl!("Align to Page")), ("path", true, tl!("Align to Path"))] {
|
||||
if orientation_button(ui, along, path == along, tip) {
|
||||
d.fields.insert("orientation".into(), json!(value));
|
||||
d.fields.insert(SET_ORIENTATION.into(), json!(true));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -193,6 +220,52 @@ mod tests {
|
||||
assert_eq!(app.session.doc().unwrap().history.undo.len(), depth + 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn on_several_blends_ok_sets_only_the_fields_changed() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 300, "height": 300})).unwrap();
|
||||
let blend = |app: &mut VectorcraftApp, y: f64, options: Value| {
|
||||
let ids: Vec<Value> =
|
||||
[0.0, 200.0].map(|x| app.run("shape.rectangle", json!({"x": x, "y": y, "width": 20, "height": 20})).unwrap()["id"].clone()).into();
|
||||
app.run("select.set", json!({ "ids": ids })).unwrap();
|
||||
app.run("object.blend.make", options).unwrap()["id"].as_u64().unwrap()
|
||||
};
|
||||
let a = blend(&mut app, 0.0, json!({"spacing": "steps", "steps": 3}));
|
||||
let b = blend(&mut app, 100.0, json!({"spacing": "distance", "distance": 12, "orientation": "path"}));
|
||||
let both = |app: &VectorcraftApp| {
|
||||
let (sa, sb) = (spec(app, a), spec(app, b));
|
||||
((sa.spacing, sa.orientation), (sb.spacing, sb.orientation))
|
||||
};
|
||||
app.run("select.set", json!({"ids": [a, b]})).unwrap();
|
||||
// The dialog shows the first blend's options; changing only the orientation leaves each
|
||||
// blend's spacing as it was.
|
||||
app.run("ui.blendOptions", json!({})).unwrap();
|
||||
app.ui.dialog.as_mut().unwrap().fields.insert("orientation".into(), json!("path"));
|
||||
frame(&mut app);
|
||||
crate::dialogs::confirm(&mut app).unwrap();
|
||||
let path = BlendOrientation::AlignToPath;
|
||||
assert_eq!(both(&app), ((BlendSpacing::Steps(3), path), (BlendSpacing::Distance(12.0), path)));
|
||||
// Changing only the step count gives both blends that count and keeps their orientation.
|
||||
app.run("object.blend.options", json!({"id": b, "orientation": "page"})).unwrap();
|
||||
app.run("ui.blendOptions", json!({})).unwrap();
|
||||
app.ui.dialog.as_mut().unwrap().fields.insert("steps".into(), json!(8));
|
||||
frame(&mut app);
|
||||
crate::dialogs::confirm(&mut app).unwrap();
|
||||
assert_eq!(both(&app), ((BlendSpacing::Steps(8), path), (BlendSpacing::Steps(8), BlendOrientation::AlignToPage)));
|
||||
// Clicking the orientation the first blend already has applies it to every selected blend.
|
||||
app.run("ui.blendOptions", json!({})).unwrap();
|
||||
app.ui.dialog.as_mut().unwrap().fields.insert(SET_ORIENTATION.into(), json!(true));
|
||||
frame(&mut app);
|
||||
crate::dialogs::confirm(&mut app).unwrap();
|
||||
assert_eq!(both(&app), ((BlendSpacing::Steps(8), path), (BlendSpacing::Steps(8), path)));
|
||||
// OK without changes changes nothing and records no undo step.
|
||||
let depth = app.session.doc().unwrap().history.undo.len();
|
||||
app.run("ui.blendOptions", json!({})).unwrap();
|
||||
frame(&mut app);
|
||||
crate::dialogs::confirm(&mut app).unwrap();
|
||||
assert_eq!(app.session.doc().unwrap().history.undo.len(), depth);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn with_nothing_selected_it_sets_what_new_blends_start_with() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
|
||||
@@ -16,7 +16,7 @@ use vectorcraft_doc::live::BlendSpineMode;
|
||||
use super::selection_len;
|
||||
use crate::VectorcraftApp;
|
||||
use crate::dialogs::blend_options::{SPACING, orientation_button};
|
||||
use crate::widgets;
|
||||
use crate::widgets::{self, Live};
|
||||
|
||||
pub const ID: &str = "blend";
|
||||
|
||||
@@ -50,10 +50,19 @@ fn available(app: &VectorcraftApp, cmd: &str) -> bool {
|
||||
&& (cmd != "object.blend.reverseSpine" || !selects_blend_without_spine(app))
|
||||
}
|
||||
|
||||
/// Is a blend made without a spine selected?
|
||||
/// Is a blend made without a spine selected? Each selected object counts as its nearest blend,
|
||||
/// itself or an ancestor, as the Object › Blend commands resolve it, so a key selected with Direct
|
||||
/// Selection counts as its blend.
|
||||
fn selects_blend_without_spine(app: &VectorcraftApp) -> bool {
|
||||
let Ok(st) = app.session.doc() else { return false };
|
||||
st.selection.objects.iter().any(|id| matches!(st.doc.node(*id).map(|n| &n.kind), Some(NodeKind::Blend { spec, .. }) if spec.no_spine))
|
||||
let Some(st) = app.session.active().filter(|st| st.selection.symbol_part.is_none()) else { return false };
|
||||
st.selection.objects.iter().any(|id| {
|
||||
let ancestry = st.doc.ancestry(*id).unwrap_or_default();
|
||||
let blend = ancestry.iter().rev().find_map(|a| match st.doc.node(*a).map(|n| &n.kind) {
|
||||
Some(NodeKind::Blend { spec, .. }) => Some(spec.no_spine),
|
||||
_ => None,
|
||||
});
|
||||
blend == Some(true)
|
||||
})
|
||||
}
|
||||
|
||||
/// `object.blend.options` parameters for spacing mode `mode`, with the step count and distance
|
||||
@@ -66,6 +75,22 @@ fn spacing_params(mode: &str, steps: f64, distance: f64) -> Value {
|
||||
}
|
||||
}
|
||||
|
||||
/// The Ramp or Shift slider: `key` of `object.blend.options` as a percentage from `min` to 100.
|
||||
/// A drag, a press on the rail included, previews the selected blends and its release records one
|
||||
/// undo step; a change without a drag, from the keyboard, records one at once.
|
||||
fn percent_slider(app: &mut VectorcraftApp, ui: &mut Ui, key: &str, value: Option<f64>, min: f64) {
|
||||
let mut v = value.unwrap_or(0.0).clamp(min, 100.0);
|
||||
let resp = widgets::slider(ui, egui::Slider::new(&mut v, min..=100.0).suffix("%"));
|
||||
let phase = if resp.drag_stopped() || (resp.changed() && !resp.dragged()) {
|
||||
Live::Released
|
||||
} else if resp.changed() {
|
||||
Live::Dragging
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
crate::panels::live_run(app, "Blend Options", "object.blend.options", json!({ key: v }), phase);
|
||||
}
|
||||
|
||||
/// Spacing and Orientation, as `object.blend.info` reports them; a change runs
|
||||
/// `object.blend.options`.
|
||||
fn settings(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
@@ -108,8 +133,9 @@ fn settings(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
});
|
||||
let selected = info["target"] == "blend";
|
||||
// Position easing needs a spine to run along: a replaced one, or Align to Path. A blend made
|
||||
// without a spine has none.
|
||||
let spined = info["hasSpine"] != false && (info["spine"]["explicit"] == true || info["orientation"] == "path");
|
||||
// without a spine has none, and easing is refused while one is selected.
|
||||
let spined =
|
||||
info["hasSpine"] != false && (info["spine"]["explicit"] == true || info["orientation"] == "path") && !selects_blend_without_spine(app);
|
||||
ui.add_enabled_ui(selected && spined, |ui| {
|
||||
let modes = ["easeIn", "easeOut", "easeInOut", "easeOutIn"];
|
||||
let labels = [tl!("Ease In"), tl!("Ease Out"), tl!("Ease In Out"), tl!("Ease Out In")];
|
||||
@@ -122,20 +148,10 @@ fn settings(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
change = Some(json!({"easingType": mode}));
|
||||
}
|
||||
});
|
||||
widgets::label_row(ui, tl!("Ramp:"), LABEL_W, |ui| {
|
||||
let mut ramp = info["ramp"].as_f64().unwrap_or(0.0);
|
||||
if ui.add(egui::Slider::new(&mut ramp, 0.0..=100.0).suffix("%")).changed() {
|
||||
change = Some(json!({"ramp": ramp}));
|
||||
}
|
||||
});
|
||||
widgets::label_row(ui, tl!("Ramp:"), LABEL_W, |ui| percent_slider(app, ui, "ramp", info["ramp"].as_f64(), 0.0));
|
||||
});
|
||||
ui.add_enabled_ui(selected, |ui| {
|
||||
widgets::label_row(ui, tl!("Shift:"), LABEL_W, |ui| {
|
||||
let mut shift = info["colorShift"].as_f64().unwrap_or(0.0);
|
||||
if ui.add(egui::Slider::new(&mut shift, -100.0..=100.0).suffix("%")).changed() {
|
||||
change = Some(json!({"colorShift": shift}));
|
||||
}
|
||||
});
|
||||
widgets::label_row(ui, tl!("Shift:"), LABEL_W, |ui| percent_slider(app, ui, "colorShift", info["colorShift"].as_f64(), -100.0));
|
||||
});
|
||||
if let Some(p) = change {
|
||||
app.run("object.blend.options", p).ok();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//! `object.blend.options`, and each other button runs its Object › Blend command.
|
||||
|
||||
use egui::{Event, Pos2, Rect, pos2, vec2};
|
||||
use serde_json::json;
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_doc::live::{BlendOrientation, BlendSpacing};
|
||||
use vectorcraft_doc::{BlendSpec, NodeId, NodeKind};
|
||||
use vectorcraft_engine::Session;
|
||||
@@ -78,6 +78,34 @@ impl Frames {
|
||||
self.run(app, vec![]);
|
||||
}
|
||||
|
||||
/// Press at `from` and move to `to` in four steps, a frame each, keeping the button down.
|
||||
fn press_and_move(&mut self, app: &mut VectorcraftApp, from: Pos2, to: Pos2) {
|
||||
self.run(app, vec![Event::PointerMoved(from)]);
|
||||
self.run(app, vec![primary(from, true)]);
|
||||
for i in 1..=4 {
|
||||
self.run(app, vec![Event::PointerMoved(from + (to - from) * (i as f32 / 4.0))]);
|
||||
}
|
||||
}
|
||||
|
||||
/// Release the button at `at`.
|
||||
fn release(&mut self, app: &mut VectorcraftApp, at: Pos2) {
|
||||
self.run(app, vec![primary(at, false)]);
|
||||
self.run(app, vec![]);
|
||||
}
|
||||
|
||||
/// The Ramp (`index` 0) or Shift (1) slider's rail: its left and right ends at mid-height.
|
||||
fn slider(&mut self, app: &mut VectorcraftApp, index: usize) -> (Pos2, Pos2) {
|
||||
self.run(app, vec![]);
|
||||
let out = self.run(app, vec![]);
|
||||
let nodes = &out.platform_output.accesskit_update.as_ref().expect("an accessibility tree").nodes;
|
||||
let mut sliders: Vec<_> = nodes.iter().filter(|(_, n)| n.role() == egui::accesskit::Role::Slider).collect();
|
||||
// The tree is not in layout order: Ramp sits above Shift.
|
||||
sliders.sort_by(|a, b| a.1.bounds().unwrap().y0.total_cmp(&b.1.bounds().unwrap().y0));
|
||||
let b = sliders[index].1.bounds().expect("bounds");
|
||||
let y = ((b.y0 + b.y1) * 0.5) as f32;
|
||||
(pos2(b.x0 as f32, y), pos2(b.x1 as f32, y))
|
||||
}
|
||||
|
||||
/// Click the text `label` the panel draws.
|
||||
fn click_text(&mut self, app: &mut VectorcraftApp, label: &str) {
|
||||
let at = self.text(app, label);
|
||||
@@ -85,6 +113,11 @@ impl Frames {
|
||||
}
|
||||
}
|
||||
|
||||
/// A press (`pressed`) or release of the primary button at `pos`.
|
||||
fn primary(pos: Pos2, pressed: bool) -> Event {
|
||||
Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE }
|
||||
}
|
||||
|
||||
/// A document with two 20 pt squares 200 pt apart, both selected.
|
||||
fn app() -> VectorcraftApp {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
@@ -309,3 +342,126 @@ fn panel_easing_type_ramp_and_shift_edit_the_blend_and_undo() {
|
||||
let text = crate::tests_labels::painted_text(&mut app, |app, ui| crate::dialogs::show(app, ui.ctx()));
|
||||
assert!(!text.contains("Ease In:") && !text.contains("Ramp:") && !text.contains("Color Ease"), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_ramp_or_shift_drag_is_one_undo_step() {
|
||||
let mut app = app();
|
||||
let id = NodeId(app.run("object.blend.make", json!({"smooth": true, "orientation": "path"})).unwrap()["id"].as_u64().unwrap());
|
||||
let mut f = Frames::new();
|
||||
for index in [0, 1] {
|
||||
let (left, right) = f.slider(&mut app, index);
|
||||
let (before, depth) = (spec(&app, id), undo_depth(&app));
|
||||
let (from, to) = (left + (right - left) * 0.6, left + (right - left) * 0.9);
|
||||
f.press_and_move(&mut app, from, to);
|
||||
// While the button is down the blend shows the new value, and no undo step is recorded yet.
|
||||
assert!(app.session.in_interaction(), "the drag is in progress");
|
||||
assert_ne!(spec(&app, id), before, "the drag previews on the blend");
|
||||
assert_eq!(undo_depth(&app), depth);
|
||||
f.release(&mut app, to);
|
||||
let after = spec(&app, id);
|
||||
assert!(!app.session.in_interaction(), "the release ends the drag");
|
||||
if index == 0 {
|
||||
assert!(after.ease.ramp > before.ease.ramp, "{after:?}");
|
||||
} else {
|
||||
assert!(after.color_shift > before.color_shift, "{after:?}");
|
||||
}
|
||||
assert_eq!(undo_depth(&app), depth + 1, "the whole drag is one undo step");
|
||||
app.run("edit.undo", json!({})).unwrap();
|
||||
assert_eq!(spec(&app, id), before);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ramp_and_shift_edit_every_selected_blend_and_keep_their_other_options() {
|
||||
let mut app = app();
|
||||
let a = NodeId(app.run("object.blend.make", json!({"spacing": "steps", "steps": 3, "orientation": "path"})).unwrap()["id"].as_u64().unwrap());
|
||||
let ids: Vec<Value> =
|
||||
[0, 200].map(|x| app.run("shape.rectangle", json!({"x": x, "y": 100, "width": 20, "height": 20})).unwrap()["id"].clone()).into();
|
||||
app.run("select.set", json!({"ids": ids})).unwrap();
|
||||
let b =
|
||||
NodeId(app.run("object.blend.make", json!({"spacing": "distance", "distance": 12, "orientation": "path"})).unwrap()["id"].as_u64().unwrap());
|
||||
app.run("object.blend.setEasing", json!({"id": b.0, "easingType": "easeInOut", "colorShift": -40})).unwrap();
|
||||
app.run("select.set", json!({"ids": [a.0, b.0]})).unwrap();
|
||||
let mut f = Frames::new();
|
||||
for index in [0, 1] {
|
||||
let (left, right) = f.slider(&mut app, index);
|
||||
let (before_a, before_b, depth) = (spec(&app, a), spec(&app, b), undo_depth(&app));
|
||||
f.click(&mut app, left + (right - left) * 0.75);
|
||||
let (after_a, after_b) = (spec(&app, a), spec(&app, b));
|
||||
assert_eq!(undo_depth(&app), depth + 1, "one undo step for both blends");
|
||||
// The value the slider set goes to both; each keeps its own spacing, type and the other value.
|
||||
if index == 0 {
|
||||
assert!(after_a.ease.ramp > 0.0 && after_a.ease.ramp == after_b.ease.ramp, "{after_a:?} {after_b:?}");
|
||||
assert_eq!((after_a.color_shift, after_b.color_shift), (before_a.color_shift, before_b.color_shift));
|
||||
} else {
|
||||
assert!(after_a.color_shift > 0.0 && after_a.color_shift == after_b.color_shift, "{after_a:?} {after_b:?}");
|
||||
assert_eq!((after_a.ease.ramp, after_b.ease.ramp), (before_a.ease.ramp, before_b.ease.ramp));
|
||||
}
|
||||
assert_eq!((after_a.spacing, after_b.spacing), (BlendSpacing::Steps(3), BlendSpacing::Distance(12.0)));
|
||||
assert_eq!((after_a.ease.kind, after_b.ease.kind), (before_a.ease.kind, before_b.ease.kind));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ramp_is_dimmed_while_a_selected_blend_has_no_spine() {
|
||||
// The first selected blend has a spine and the second has none: the engine refuses easing for
|
||||
// the pair, so the Ramp slider does not take a drag; Shift still edits both.
|
||||
let mut app = app();
|
||||
let a = NodeId(app.run("object.blend.make", json!({"smooth": true, "orientation": "path"})).unwrap()["id"].as_u64().unwrap());
|
||||
let ids: Vec<Value> =
|
||||
[0, 200].map(|x| app.run("shape.rectangle", json!({"x": x, "y": 100, "width": 20, "height": 20})).unwrap()["id"].clone()).into();
|
||||
app.run("select.set", json!({"ids": ids})).unwrap();
|
||||
let b = NodeId(app.run("object.blend.make", json!({"smooth": true, "createSpine": "never"})).unwrap()["id"].as_u64().unwrap());
|
||||
app.run("select.set", json!({"ids": [a.0, b.0]})).unwrap();
|
||||
let mut f = Frames::new();
|
||||
let (left, right) = f.slider(&mut app, 0);
|
||||
let (before_a, before_b, depth) = (spec(&app, a), spec(&app, b), undo_depth(&app));
|
||||
let (from, to) = (left + (right - left) * 0.6, left + (right - left) * 0.9);
|
||||
f.press_and_move(&mut app, from, to);
|
||||
f.release(&mut app, to);
|
||||
assert_eq!((spec(&app, a), spec(&app, b), undo_depth(&app), app.ui.status.as_str()), (before_a, before_b, depth, ""), "Ramp did nothing");
|
||||
let (left, right) = f.slider(&mut app, 1);
|
||||
f.click(&mut app, left + (right - left) * 0.75);
|
||||
assert!(spec(&app, a).color_shift > 0.0 && spec(&app, b).color_shift == spec(&app, a).color_shift);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ramp_and_reverse_spine_are_dimmed_while_a_selected_key_belongs_to_a_blend_with_no_spine() {
|
||||
// A key of each blend is selected, as Direct Selection does: the commands act on the keys'
|
||||
// blends, and the second has no spine, so Ramp and Reverse Spine do nothing.
|
||||
let mut app = app();
|
||||
let a = NodeId(app.run("object.blend.make", json!({"smooth": true, "orientation": "path"})).unwrap()["id"].as_u64().unwrap());
|
||||
let ids: Vec<Value> =
|
||||
[0, 200].map(|x| app.run("shape.rectangle", json!({"x": x, "y": 100, "width": 20, "height": 20})).unwrap()["id"].clone()).into();
|
||||
app.run("select.set", json!({"ids": ids})).unwrap();
|
||||
let b = NodeId(app.run("object.blend.make", json!({"smooth": true, "createSpine": "never"})).unwrap()["id"].as_u64().unwrap());
|
||||
let key = |app: &VectorcraftApp, blend: NodeId| match &app.session.active().unwrap().doc.node(blend).unwrap().kind {
|
||||
NodeKind::Blend { children, .. } => children[0].id,
|
||||
k => panic!("not a blend: {k:?}"),
|
||||
};
|
||||
let keys = [key(&app, a).0, key(&app, b).0];
|
||||
app.run("select.set", json!({"ids": keys})).unwrap();
|
||||
assert_eq!(app.session.execute("object.blend.info", &json!({})).unwrap()["target"], "blend");
|
||||
let mut f = Frames::new();
|
||||
let (left, right) = f.slider(&mut app, 0);
|
||||
let (before_a, before_b, depth) = (spec(&app, a), spec(&app, b), undo_depth(&app));
|
||||
let (from, to) = (left + (right - left) * 0.6, left + (right - left) * 0.9);
|
||||
f.press_and_move(&mut app, from, to);
|
||||
f.release(&mut app, to);
|
||||
f.click_text(&mut app, "Reverse Spine");
|
||||
assert_eq!((spec(&app, a), spec(&app, b), undo_depth(&app), app.ui.status.as_str()), (before_a, before_b, depth, ""), "nothing ran");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fractional_ramp_and_shift_stay_as_they_are_while_the_panel_draws() {
|
||||
let mut app = app();
|
||||
let id = NodeId(app.run("object.blend.make", json!({"smooth": true, "orientation": "path"})).unwrap()["id"].as_u64().unwrap());
|
||||
app.run("object.blend.options", json!({"id": id.0, "ramp": 42.5, "colorShift": 12.5})).unwrap();
|
||||
let depth = undo_depth(&app);
|
||||
let mut f = Frames::new();
|
||||
f.run(&mut app, vec![]);
|
||||
f.run(&mut app, vec![]);
|
||||
let info = app.session.execute("object.blend.info", &json!({})).unwrap();
|
||||
assert_eq!((&info["ramp"], &info["colorShift"]), (&json!(42.5), &json!(12.5)));
|
||||
assert_eq!(undo_depth(&app), depth);
|
||||
}
|
||||
|
||||
+11
@@ -11825,6 +11825,17 @@ so its point at `t` moves by (dx, dy), turning a straight spine into a curve (`p
|
||||
{"name":"run_command","arguments":{"command":"object.blend.spine.moveAnchor","params":{"id":40,"anchor":1,"x":150,"y":20}}}
|
||||
```
|
||||
|
||||
`object.blend.options {id?, spacing?, value?, steps?, distance?, orientation?, smooth?, easingType?, ramp?, colorShift?}`
|
||||
sets the options of every selected blend, or of the blend `id` alone. Each blend takes only the options given and
|
||||
keeps its own value for the others, so a call with `colorShift` alone leaves each blend's spacing, orientation, type
|
||||
and ramp as they were. `spacing` without `value`, `steps` or `distance` keeps the count of a blend already in that
|
||||
mode, and a blend in another mode takes 5 steps or 10 pt. A hidden or locked `id`, an `id` that is not a blend, a
|
||||
value out of range, a `spacing` that is not a string, an `orientation` other than `page` or `path`, and `value`
|
||||
without `spacing` are errors that change
|
||||
nothing, and a call that changes no blend records no undo step. With no blend selected and no `id`, the call sets the
|
||||
spacing and orientation new blends start with. The Blend panel's Ramp and Shift sliders run it on the selected blends:
|
||||
a drag previews and its release records one undo step. Blend Options sends only the spacing or orientation set in the dialog.
|
||||
|
||||
`object.blend.setEasing {id?, easingType?, ramp?, colorShift?}` sets one blend's easing and color shift (the
|
||||
first selected blend without `id`) and returns `{id, easingType, ramp, colorShift, changed}`; omitted values are kept.
|
||||
`easingType` is `easeIn`, `easeOut`, `easeInOut` or `easeOutIn`, `ramp` is 0 to 100 and `colorShift` -100 to 100.
|
||||
|
||||
@@ -1677,6 +1677,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
When the object the Blend tool picked first is deleted or undone away before the second click, the next click on an object picks that object first instead of doing nothing. Regression tests: `blend_tool_picks_again_when_its_first_pick_is_gone` in `meshblend.rs` and `the_blend_tool_picks_again_when_its_first_pick_is_deleted` in `tests/blendopts.rs`.
|
||||
Window › Blend opens the Blend panel: Make, the selected blend's Spacing and Orientation (with no blend selected, the options new blends start with), Reverse Front to Back, Reverse Spine, Replace Spine, Expand and Release, each running its Object › Blend command. Make is dimmed until two or more objects are selected. Spacing and Orientation are dimmed until a blend or two or more objects are selected, and the other buttons are dimmed until a blend is selected.
|
||||
The Blend panel's Create Spine menu (Auto, Always, Never; `object.blend.createSpine`) sets whether new blends get a spine, from the Blend tool, Make and `object.blend.make` alike ([Blend panel overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/blend-panel-overview.html)). Auto and Always give every new blend a straight spine, as before; Never makes blends without one, which keep their steps on the straight lines between the keys, have Type and Ramp dimmed, refuse Reverse Spine and spine edits, release without a spine path, and get a spine from Replace Spine. The setting is kept with the preferences and leaves blends already made as they are; Auto as the starting value and keeping the setting across sessions are VectorCraft's own rules. Builds on #5177 by adambelis. Evidence: `tests::blendopts::{create_spine_sets_whether_new_blends_get_a_spine, a_blend_without_a_spine_has_none_to_edit_reverse_ease_or_release, whether_a_blend_has_a_spine_is_saved_and_old_blends_have_one}` and `panels::tests_blend::create_spine_sets_what_new_blends_get_whatever_is_selected`.
|
||||
Blend Options on several selected blends (the Blend Options dialog, the Blend panel's Type, Ramp and Shift, and `object.blend.options`) sets only the values given or set in the dialog, and each blend keeps its own spacing, orientation, type, ramp and shift for the rest instead of taking the first blend's; a spacing mode given without a count keeps the count of a blend already in that mode. `object.blend.options {id}` edits that blend alone; a hidden or locked blend, an object that is not a blend, a value out of range and an unknown orientation are errors that change nothing, and a call that changes nothing records no undo step. A drag of the panel's Ramp or Shift slider previews on the canvas and records one undo step on release, and Type, Ramp and Reverse Spine are dimmed while a selected blend, or the blend of a key selected with Direct Selection, has no spine. Builds on #8022 by ruchirguitar. Evidence: `tests::blendopts::{options_on_several_blends_set_only_the_values_given, options_with_an_id_edit_that_blend_alone, options_that_change_nothing_or_are_refused_record_no_undo_step}`, `dialogs::blend_options::tests::on_several_blends_ok_sets_only_the_fields_changed` and `panels::tests_blend::{a_ramp_or_shift_drag_is_one_undo_step, ramp_and_shift_edit_every_selected_blend_and_keep_their_other_options, ramp_is_dimmed_while_a_selected_blend_has_no_spine, ramp_and_reverse_spine_are_dimmed_while_a_selected_key_belongs_to_a_blend_with_no_spine}`.
|
||||
With the Blend tool, Escape drops the object clicked first and stops the next click adding to the blend just made, so the next click picks a new first object; the document and the selection stay as they are. Regression tests: `escape_drops_the_blend_tools_first_pick` in `meshblend.rs` and `tests/blendopts.rs`.
|
||||
Objects on Path (#2545): a click with the Objects on Path tool (in Edit Toolbar's Modify section and the Blend tool's flyout; Object › Objects on Path › Attach and the context menu with two or more objects selected choose it) attaches the selected objects to the path clicked, open or closed, in an Objects on Path group with the path at its bottom. The objects go along the path column by column from left to right, spread evenly from its first anchor (the last one sits on the end of an open path), each turned to the path at its attachment point; Pivot and Rotate set where each one attaches and how far it tilts (`object.objectsOnPath.attach`, `object.objectsOnPath.options`), and with Objects on Path groups selected the Properties panel's Objects on Path Options section shows them as a nine-point Pivot grid and a Rotate field with common angles, each change one undo step for every selected group. Editing the path moves the objects, an object moved on its own goes back, objects moved into or out of the group in the Layers panel join or leave the path, and Object › Objects on Path › Expand leaves a plain group. The group saves and reopens live and exports as plain art. With one Objects on Path group selected, the Selection and Objects on Path tools show the Rotate All widget beside its first object: dragging it turns every object about its attachment point by the angle the pointer turns, adding it to the group's Rotate in one undo step, in 15° steps with Shift ([Objects on Path](https://helpx.adobe.com/illustrator/using/objects-on-path.html)). Detach is in its own entry below.
|
||||
Objects on Path Space widget: with one Objects on Path group of two or more objects selected, the Selection and Objects on Path tools show a square handle beyond its last object; dragging it along the path, round its bends, sets the distance between the objects' attachment points in one undo step, the first object staying where it is, and with Alt (Option on macOS) the objects spread from both ends toward the center; the distance shows next to the pointer during the drag, in the document's units ([Rearrange and edit objects on a path](https://helpx.adobe.com/illustrator/desktop/manage-objects/arrange-objects/rearrange-and-edit-objects-on-a-path.html), [Objects on Path](https://helpx.adobe.com/illustrator/using/objects-on-path.html)). The group keeps the distance (`object.objectsOnPath.options {spacing, start}`) through Pivot and Rotate changes, path edits, copies, saving and reopening, and scales it with the group; by default (`"auto"`) the objects are spread evenly as before. Evidence: `objects_on_path::tests::{space_sets_the_distance_between_the_stops, space_on_a_closed_path_wraps_at_the_first_anchor_and_stops_short_of_the_first_object}` in `crates/doc`, `tests::objects_on_path::space_sets_the_distance_between_the_objects_in_one_undo_step` in `crates/engine`, `objects_on_path::tests::dragging_the_space_widget_spaces_the_objects_from_the_first_one` in `crates/tools`.
|
||||
|
||||
Reference in New Issue
Block a user