mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 14:49:18 +00:00
Merge pull request #8382 from dotCooCoo/fix/undo-keeps-view-state
Undo: undo and redo keep the settings changed without an undo step
This commit is contained in:
@@ -826,7 +826,7 @@ pub use addons::{fold_source, print_hidden};
|
||||
/// Document Info's category titles and the Objects category's count labels.
|
||||
pub use docinfo::{CATEGORIES, OBJECT_LABELS};
|
||||
pub use docmenu::guide_indexes;
|
||||
pub(crate) use edit::{settle_interaction, typing_in_progress};
|
||||
pub(crate) use edit::{Unrecorded, settle_interaction, typing_in_progress};
|
||||
pub(crate) use object::bounds_rewrite;
|
||||
pub(crate) use object::{keep_aligned_in, refresh_pixel_aligned};
|
||||
pub use plugin_call::{Location, ParamsPlace, key_location, location_in, location_keys};
|
||||
|
||||
@@ -6,6 +6,7 @@ use std::sync::Arc;
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_doc::{Document, Node, NodeId, NodeKind, RulerMode, Unit};
|
||||
use vectorcraft_geom::{Affine, Point, Vec2};
|
||||
use vectorcraft_tools::distort::perspective::{PerspectiveGrid, Plane};
|
||||
|
||||
use super::clipboard::SwatchChoices;
|
||||
use super::{
|
||||
@@ -713,6 +714,85 @@ pub(crate) fn settle_interaction(s: &mut Session) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The document state that commands also change without an undo step: the perspective grid's view
|
||||
/// options (whether it shows, Lock Grid, Lock Station Point, Snap to Grid and Show Rulers), its
|
||||
/// active plane, the grid preferences, the export settings, and the current brush and symbol. Each
|
||||
/// undo and redo step keeps it as the document on its other side had it
|
||||
/// ([`crate::HistoryEntry::unrecorded`]).
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub(crate) struct Unrecorded {
|
||||
grid: vectorcraft_doc::GridPrefs,
|
||||
export_settings: serde_json::Map<String, Value>,
|
||||
brush: Option<Value>,
|
||||
symbol: Option<Value>,
|
||||
options: [bool; 5],
|
||||
plane: Plane,
|
||||
}
|
||||
|
||||
impl Unrecorded {
|
||||
pub(crate) fn of(d: &Document) -> Self {
|
||||
let g = PerspectiveGrid::current(d);
|
||||
Unrecorded {
|
||||
grid: d.grid.clone(),
|
||||
export_settings: d.export_settings.clone(),
|
||||
brush: d.unknown.get(vectorcraft_brush::CURRENT_KEY).cloned(),
|
||||
symbol: d.unknown.get(super::brushsym::CURRENT_SYMBOL).cloned(),
|
||||
options: [g.visible, g.locked, g.lock_station, g.snap, g.rulers],
|
||||
plane: g.plane,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Undo and redo bring back `d`; `step` is that state as the document on the step's other side had
|
||||
/// it. A part the step did not change (`d` has it as `step` does) stays as it is in `now`, the
|
||||
/// document before the undo or redo, since it changed after the step without an undo step. A part
|
||||
/// the step changed comes back with `d`. A current brush or symbol that `d` does not hold also
|
||||
/// comes back with `d`. The point Automatic Plane Positioning holds comes back with `d`, and is let go when the
|
||||
/// active plane kept is not the one it holds.
|
||||
fn keep_unrecorded(now: &Document, step: &Unrecorded, d: &mut Arc<Document>) {
|
||||
fn pick<T: Clone + PartialEq>(back: &T, step: &T, now: &T) -> T {
|
||||
if back == step { now.clone() } else { back.clone() }
|
||||
}
|
||||
let back = Unrecorded::of(d);
|
||||
let cur = Unrecorded::of(now);
|
||||
let mut want = Unrecorded {
|
||||
grid: pick(&back.grid, &step.grid, &cur.grid),
|
||||
export_settings: pick(&back.export_settings, &step.export_settings, &cur.export_settings),
|
||||
brush: pick(&back.brush, &step.brush, &cur.brush),
|
||||
symbol: pick(&back.symbol, &step.symbol, &cur.symbol),
|
||||
options: std::array::from_fn(|i| pick(&back.options[i], &step.options[i], &cur.options[i])),
|
||||
plane: pick(&back.plane, &step.plane, &cur.plane),
|
||||
};
|
||||
if want.brush != back.brush && want.brush.as_ref().and_then(Value::as_str).is_some_and(|n| vectorcraft_brush::find(d, n).is_none()) {
|
||||
want.brush = back.brush.clone();
|
||||
}
|
||||
if want.symbol != back.symbol && want.symbol.as_ref().and_then(Value::as_str).is_some_and(|n| !d.symbols.iter().any(|s| s.name == n)) {
|
||||
want.symbol = back.symbol.clone();
|
||||
}
|
||||
if want == back {
|
||||
return;
|
||||
}
|
||||
let m = Arc::make_mut(d);
|
||||
for (key, v) in [(vectorcraft_brush::CURRENT_KEY, &want.brush), (super::brushsym::CURRENT_SYMBOL, &want.symbol)] {
|
||||
match v {
|
||||
Some(v) => m.unknown.insert(key.into(), v.clone()),
|
||||
None => m.unknown.remove(key),
|
||||
};
|
||||
}
|
||||
if (want.options, want.plane) != (back.options, back.plane) {
|
||||
let mut g = PerspectiveGrid::current(m);
|
||||
[g.visible, g.locked, g.lock_station, g.snap, g.rulers] = want.options;
|
||||
if g.plane != want.plane {
|
||||
g.plane = want.plane;
|
||||
g.inferred = None;
|
||||
}
|
||||
g.keep_positioning_valid();
|
||||
super::distortcmds::store_grid(m, &g);
|
||||
}
|
||||
m.grid = want.grid;
|
||||
m.export_settings = want.export_settings;
|
||||
}
|
||||
|
||||
fn undo(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
settle_interaction(s)?;
|
||||
let menu = s.menu.clone();
|
||||
@@ -723,6 +803,7 @@ fn undo(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
let editing = st.doc.mask_edit.map(|m| m.layer);
|
||||
let editing_symbol = st.doc.symbol_edit.clone();
|
||||
let doc = std::mem::replace(&mut st.doc, e.doc);
|
||||
keep_unrecorded(&doc, &e.unrecorded, &mut st.doc);
|
||||
let selection = std::mem::replace(&mut st.selection, Arc::unwrap_or_clone(e.selection));
|
||||
let selection = shared_selection(selection, st.history.redo.last());
|
||||
let mut turned = crate::HistoryEntry::turned(e.label, doc, selection, &st.doc, costs);
|
||||
@@ -758,6 +839,7 @@ fn redo(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
let editing = st.doc.mask_edit.map(|m| m.layer);
|
||||
let editing_symbol = st.doc.symbol_edit.clone();
|
||||
let doc = std::mem::replace(&mut st.doc, e.doc);
|
||||
keep_unrecorded(&doc, &e.unrecorded, &mut st.doc);
|
||||
let selection = std::mem::replace(&mut st.selection, Arc::unwrap_or_clone(e.selection));
|
||||
let selection = shared_selection(selection, st.history.undo.last());
|
||||
let mut turned = crate::HistoryEntry::turned(e.label, doc, selection, &st.doc, costs);
|
||||
|
||||
@@ -32,6 +32,9 @@ pub struct HistoryEntry {
|
||||
pub(crate) color_mode_paints: Option<(vectorcraft_tools::PaintDefaults, vectorcraft_tools::PaintDefaults)>,
|
||||
/// Owned new-art snapshots included in both directional estimates.
|
||||
color_mode_bytes: usize,
|
||||
/// The state that changes without an undo step as the next state had it: undo and redo compare
|
||||
/// it with `doc` to tell what the step changed.
|
||||
pub(crate) unrecorded: Arc<crate::cmd::Unrecorded>,
|
||||
}
|
||||
|
||||
impl Clone for HistoryEntry {
|
||||
@@ -49,6 +52,7 @@ impl Clone for HistoryEntry {
|
||||
serial: self.serial,
|
||||
color_mode_paints: self.color_mode_paints.clone(),
|
||||
color_mode_bytes: self.color_mode_bytes,
|
||||
unrecorded: self.unrecorded.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,6 +98,7 @@ impl HistoryEntry {
|
||||
serial: next_serial(),
|
||||
color_mode_paints: None,
|
||||
color_mode_bytes: 0,
|
||||
unrecorded: Arc::new(crate::cmd::Unrecorded::of(next)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +131,7 @@ impl HistoryEntry {
|
||||
serial: next_serial(),
|
||||
color_mode_paints: None,
|
||||
color_mode_bytes: 0,
|
||||
unrecorded: Arc::new(crate::cmd::Unrecorded::of(now)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,6 +343,7 @@ impl History {
|
||||
e.next_bytes = after.saturating_add(e.color_mode_bytes);
|
||||
e.next = std::ptr::from_ref(now) as usize;
|
||||
e.serial = next_serial();
|
||||
e.unrecorded = Arc::new(crate::cmd::Unrecorded::of(now));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,6 +302,23 @@ fn the_shared_settings_drive_the_export_and_arent_an_undo_step() {
|
||||
assert_eq!(run(&mut s, "document.exportSettings", json!({}))["settings"]["formats"][0]["format"], "jpg");
|
||||
}
|
||||
|
||||
/// The shared settings are not an undo step, so undo and redo of the steps before them leave them
|
||||
/// as they are.
|
||||
#[test]
|
||||
fn undo_and_redo_keep_the_shared_settings() {
|
||||
let mut s = session();
|
||||
let a = rect(&mut s, 10.0, 10.0, 20.0, 20.0);
|
||||
run(&mut s, "assets.add", json!({"ids": [a]}));
|
||||
run(&mut s, "assets.settings.set", json!({"formats": [{"format": "svg"}], "prefix": "ic_"}));
|
||||
let settings = run(&mut s, "document.exportSettings", json!({}))["settings"].clone();
|
||||
run(&mut s, "edit.undo", json!({}));
|
||||
assert_eq!(run(&mut s, "document.exportSettings", json!({}))["settings"], settings);
|
||||
run(&mut s, "assets.settings.set", json!({"formats": [{"format": "jpg"}], "prefix": ""}));
|
||||
let settings = run(&mut s, "document.exportSettings", json!({}))["settings"].clone();
|
||||
run(&mut s, "edit.redo", json!({}));
|
||||
assert_eq!(run(&mut s, "document.exportSettings", json!({}))["settings"], settings);
|
||||
}
|
||||
|
||||
/// An export preset sets the shared settings as the Asset Export panel applies one: its rows (or
|
||||
/// mobile/density), its format settings over the saved ones, its prefix and its sub-folders.
|
||||
#[test]
|
||||
|
||||
@@ -1400,6 +1400,40 @@ fn paintbrush_tool_uses_the_current_brush() {
|
||||
assert!(s.execute("brush.setCurrent", &json!({"name": "Nope"})).is_err());
|
||||
}
|
||||
|
||||
/// The current brush and symbol are not undo steps, so undo and redo of other steps leave them as
|
||||
/// they are. With nothing else changed outside the history, undo back to the saved document leaves
|
||||
/// it saved.
|
||||
#[test]
|
||||
fn undo_and_redo_keep_the_current_brush_and_symbol() {
|
||||
let mut s = session();
|
||||
rect(&mut s, 10.0, 10.0, 20.0, 20.0);
|
||||
s.execute("symbol.new", &json!({"name": "A"})).unwrap();
|
||||
rect(&mut s, 40.0, 10.0, 20.0, 20.0);
|
||||
s.execute("symbol.new", &json!({"name": "B"})).unwrap();
|
||||
s.doc_mut().unwrap().mark_saved();
|
||||
rect(&mut s, 70.0, 10.0, 20.0, 20.0);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!(!s.doc().unwrap().is_dirty(), "back at the saved document");
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
s.execute("brush.setCurrent", &json!({"name": "Arrow"})).unwrap();
|
||||
s.execute("symbol.setCurrent", &json!({"name": "A"})).unwrap();
|
||||
let current = |s: &mut Session| {
|
||||
let brush = s.execute("brush.list", &json!({})).unwrap()["current"].clone();
|
||||
(brush, s.execute("symbol.list", &json!({})).unwrap()["current"].clone())
|
||||
};
|
||||
let want = (json!("Arrow"), json!("A"));
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(current(&mut s), want);
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert_eq!(current(&mut s), want);
|
||||
// A symbol made current between undoing and redoing its deletion is not kept as current.
|
||||
s.execute("symbol.delete", &json!({"name": "B"})).unwrap();
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
s.execute("symbol.setCurrent", &json!({"name": "B"})).unwrap();
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert_eq!(s.doc().unwrap().doc.unknown.get("currentSymbol"), Some(&json!("A")));
|
||||
}
|
||||
|
||||
/// A Size: Pressure variant of "3 pt. Round" (3 ± 3 pt).
|
||||
fn pressure_round(s: &mut Session) {
|
||||
let params = json!({"variation": [0, 0, 3], "modes": ["fixed", "fixed", "pressure"]});
|
||||
|
||||
@@ -5689,3 +5689,20 @@ fn crop_image_trim_leaves_a_cmyk_image_alone() {
|
||||
let r = s.execute("object.cropImage", &json!({"trim": true})).unwrap();
|
||||
assert_eq!((r["trimmed"].as_bool(), r["width"].as_u64(), r["height"].as_u64()), (Some(false), Some(4), Some(2)), "{r}");
|
||||
}
|
||||
|
||||
/// Lock Guides is not an undo step: it adds none, and undo and redo of the steps before it leave
|
||||
/// the guides locked.
|
||||
#[test]
|
||||
fn lock_guides_is_not_an_undo_step() {
|
||||
let mut s = session();
|
||||
let g = rect(&mut s, 200.0, 0.0, 10.0, 10.0);
|
||||
sel(&mut s, &[g]);
|
||||
s.execute("view.guides.make", &json!({})).unwrap();
|
||||
let steps = s.doc().unwrap().history.undo.len();
|
||||
s.execute("view.guides.lock", &json!({"locked": true})).unwrap();
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), steps);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!(s.guides_locked());
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert!(s.guides_locked());
|
||||
}
|
||||
|
||||
@@ -312,6 +312,91 @@ fn view_options_toggle_without_undo_steps_and_survive_presets() {
|
||||
assert_eq!(PerspectiveGrid::from_doc(&back), Some(g));
|
||||
}
|
||||
|
||||
/// The view options are not undo steps, so undo and redo of other steps leave them as they are:
|
||||
/// Lock Grid, Lock Station Point, Snap to Grid, Show Rulers and whether the grid shows. Undoing a
|
||||
/// grid definition brings back the old grid with the current view options.
|
||||
#[test]
|
||||
fn undo_and_redo_keep_the_view_options() {
|
||||
let mut s = session();
|
||||
run(&mut s, "perspective.grid.preset", json!({"kind": 2}));
|
||||
let old = grid(&s);
|
||||
run(&mut s, "shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 40}));
|
||||
run(&mut s, "perspective.grid.preset", json!({"kind": 1}));
|
||||
let n = undo_len(&s);
|
||||
for (id, on) in
|
||||
[("perspective.grid.lock", true), ("perspective.grid.lockStation", true), ("perspective.grid.snap", false), ("perspective.grid.rulers", true)]
|
||||
{
|
||||
run(&mut s, id, json!({"on": on}));
|
||||
}
|
||||
run(&mut s, "perspective.grid.show", json!({"visible": false}));
|
||||
assert_eq!(undo_len(&s), n);
|
||||
let view = |g: &PerspectiveGrid| (g.locked, g.lock_station, g.snap, g.rulers, g.visible);
|
||||
let want = (true, true, false, true, false);
|
||||
assert_eq!(view(&grid(&s)), want);
|
||||
// Undo the one-point preset: the two-point grid comes back with today's view options.
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
let g = grid(&s);
|
||||
assert_eq!((g.kind, g.vp_left, view(&g)), (old.kind, old.vp_left, want));
|
||||
// Undo the rectangle, which left the grid alone.
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(view(&grid(&s)), want);
|
||||
// An option changed now holds through the redo steps.
|
||||
run(&mut s, "perspective.grid.lock", json!({"on": false}));
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
let g = grid(&s);
|
||||
assert_eq!((g.kind, view(&g)), (1, (false, true, false, true, false)));
|
||||
}
|
||||
|
||||
/// The view options set on a document whose steps hold no grid yet stay as they are when undo
|
||||
/// brings back a step without one, and the active plane chosen without an undo step stays too.
|
||||
#[test]
|
||||
fn undo_keeps_the_view_options_of_a_grid_no_step_defined() {
|
||||
let mut s = session();
|
||||
run(&mut s, "shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 40}));
|
||||
run(&mut s, "shape.rectangle", json!({"x": 100, "y": 10, "width": 50, "height": 40}));
|
||||
assert!(!s.doc().unwrap().doc.unknown.contains_key(vectorcraft_tools::distort::perspective::DOC_KEY));
|
||||
run(&mut s, "perspective.grid.show", json!({"visible": true}));
|
||||
run(&mut s, "perspective.grid.lock", json!({"on": true}));
|
||||
run(&mut s, "perspective.grid.snap", json!({"on": false}));
|
||||
run(&mut s, "perspective.plane.set", json!({"plane": "ground"}));
|
||||
let view = |g: &PerspectiveGrid| (g.visible, g.locked, g.snap, g.plane);
|
||||
let want = (true, true, false, vectorcraft_tools::distort::perspective::Plane::Ground);
|
||||
assert_eq!(view(&grid(&s)), want);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(view(&grid(&s)), want);
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert_eq!(view(&grid(&s)), want);
|
||||
}
|
||||
|
||||
/// A step that changed a view option itself takes it back on undo and sets it again on redo: a
|
||||
/// preset shows the grid, and a grid definition can lock it.
|
||||
#[test]
|
||||
fn undo_takes_back_the_view_options_a_step_changed() {
|
||||
let mut s = session();
|
||||
run(&mut s, "perspective.grid.preset", json!({"kind": 2}));
|
||||
run(&mut s, "perspective.grid.show", json!({"visible": false}));
|
||||
run(&mut s, "perspective.grid.preset", json!({"kind": 1}));
|
||||
assert!(grid(&s).visible);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!(!grid(&s).visible, "the preset showed the grid");
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert!(grid(&s).visible);
|
||||
let cell = grid(&s).cell;
|
||||
run(&mut s, "perspective.grid.set", json!({"locked": true, "cell": cell + 10.0}));
|
||||
assert!(grid(&s).locked);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!((grid(&s).locked, grid(&s).cell), (false, cell));
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert_eq!((grid(&s).locked, grid(&s).cell), (true, cell + 10.0));
|
||||
// An option the step left alone and changed after it stays as it is.
|
||||
run(&mut s, "perspective.grid.snap", json!({"on": false}));
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!((grid(&s).locked, grid(&s).snap), (false, false));
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert_eq!((grid(&s).locked, grid(&s).snap), (true, false));
|
||||
}
|
||||
|
||||
/// Lock Grid, Lock Station Point, Snap to Grid and Show Rulers refuse an `on` given as text or as
|
||||
/// another value that is not true or false: the grid and the undo history stay as they were. Null is
|
||||
/// read as the key left out, so it toggles the option.
|
||||
|
||||
@@ -109,6 +109,23 @@ fn grid_prefs_apply_to_open_documents() {
|
||||
assert_eq!((g.spacing, g.subdivisions), (36.0, 4));
|
||||
}
|
||||
|
||||
/// The grid preferences are not an undo step in the documents they apply to, so undo and redo
|
||||
/// leave the grid as the preferences set it.
|
||||
#[test]
|
||||
fn undo_and_redo_keep_the_grid_prefs() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap();
|
||||
s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 50, "height": 40})).unwrap();
|
||||
s.execute("prefs.set", &json!({"values": {"gridlineEvery": 36, "gridSubdivisions": 4}})).unwrap();
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
let g = &s.doc().unwrap().doc.grid;
|
||||
assert_eq!((g.spacing, g.subdivisions), (36.0, 4));
|
||||
s.execute("prefs.set", &json!({"values": {"gridlineEvery": 18, "gridSubdivisions": 3}})).unwrap();
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
let g = &s.doc().unwrap().doc.grid;
|
||||
assert_eq!((g.spacing, g.subdivisions), (18.0, 3));
|
||||
}
|
||||
|
||||
/// Guides & Grid › Gridline every and Subdivisions (#394): set with no document open, as the
|
||||
/// desktop app restores them at launch, they give `file.new`'s document their grid.
|
||||
#[test]
|
||||
|
||||
+1
-1
@@ -717,7 +717,7 @@ ends the wait, so the sampler can be shown again. The BSDs and headless sessions
|
||||
| `transform` | `{ids?, dx?, dy?, rotate?, scale?, scaleX?, scaleY?, reflect?, shear?, origin?, copy?}` | Runs move, rotate, scale, reflect, shear in that order. `rotate` is in degrees counter-clockwise; a positive `shear` moves the top to the right. With `copy`, the first step duplicates. |
|
||||
| `create_graph` | `{type?, x, y, width, height, csv? \| series?, categories?, rows?}` | The nine Illustrator graph types: column, stacked column, bar, stacked bar, line, area, scatter, pie and radar. An empty CSV cell or a `null` in `rows` is a blank value; a number in straight quotes is a label. Edit later with `graph.setData` / `graph.setType` via `run_command`. `graph.column {design, columnType: vertical\|uniform\|repeating\|sliding, each, fractions: chop\|scale}` draws the columns or bars of the series picked with Group Selection (or `seriesIndexes`, or all of them) with a graph design saved by `graph.design`; with no `design` it returns the series' current design and options. Type in the design that holds a `%` followed by two digits shows each column's value, with at least the first digit's places before the decimal point and the second digit's places after it. |
|
||||
| `text_wrap` | `{ids?, offset?, invert?, release?}` | Area type below the objects (same layer) flows around them. `offset` is in points, from -1000 to 1000 (default 6). An offset outside that range or not a number, or an `invert` or `release` that is not true or false, is an error and changes nothing; `object.textWrap.make` and `object.textWrap.options` refuse the same values. |
|
||||
| `undo` / `redo` | `{}` | Many calls that change nothing record no undo step, for example `object.align` with nothing to move, `object.move` by 0 without `copy` and `object.showAll` with nothing hidden. `undo` (`edit.undo`) after such a call undoes the step before it. `inspect_document` lists the undo steps as `history`. `run_command` with `edit.clearHistory` removes every undo and redo step of the active document and returns `{cleared}`, the number of steps removed; the document stays as it is, and the command records no undo step. `run_command` with `edit.newDocumentFromState` and `{index?, created?}` makes a new document holding the art as it was at that state and makes it the active document, and returns `{index, title}`. `index` is a row of the History panel, with 0 the oldest state kept, and an omitted or null `index` uses the current state. An `index` that names no state fails with `no history state N`, one that is not a whole number with `` `index` must be a whole number ``, and either changes nothing. `created` is File Info's created date in Unix seconds or null, and defaults to now. The new document takes the next `Untitled-N` name, is marked unsaved, has nothing selected and has no steps to undo or redo. It is out of symbol, opacity-mask and pattern editing, and the art drawn in a pattern's tile is stored in the pattern, as `object.pattern.done` stores it. The source document and its steps stay as they are, except that typing or a drag in progress is first kept as a step. When a command keeps a drag whose preview Real-time Drawing off had not applied yet (`edit.undo`, `edit.redo`, `edit.clearHistory`, `edit.newDocumentFromState` and the other commands that end a drag first), and applying that preview gives a warning, the command's result carries it as `previewWarning`, and as `warning` too when the command gives no warning of its own; the app's status bar shows `warning`. While the Type tool edits type, `undo` and `redo` put its caret, with no characters selected, at the end of the text the step changed: after the text it puts back or retypes, or where the text it takes out was. A step that changes no characters, such as a formatting change, leaves the caret and the selection where they are. |
|
||||
| `undo` / `redo` | `{}` | Many calls that change nothing record no undo step, for example `object.align` with nothing to move, `object.move` by 0 without `copy` and `object.showAll` with nothing hidden. `undo` (`edit.undo`) after such a call undoes the step before it. Settings that change without an undo step stay as they are when `undo` or `redo` brings back a step that did not change them: the perspective grid's view options and active plane, the grid preferences (`gridlineEvery`, `gridSubdivisions`), the export settings (`assets.settings.set`), and the current brush and symbol. A step that changed one of them, such as a perspective grid preset that shows the grid, takes that change back. The point Automatic Plane Positioning holds comes back with the step, and is let go when the active plane kept is another one. `inspect_document` lists the undo steps as `history`. `run_command` with `edit.clearHistory` removes every undo and redo step of the active document and returns `{cleared}`, the number of steps removed; the document stays as it is, and the command records no undo step. `run_command` with `edit.newDocumentFromState` and `{index?, created?}` makes a new document holding the art as it was at that state and makes it the active document, and returns `{index, title}`. `index` is a row of the History panel, with 0 the oldest state kept, and an omitted or null `index` uses the current state. An `index` that names no state fails with `no history state N`, one that is not a whole number with `` `index` must be a whole number ``, and either changes nothing. `created` is File Info's created date in Unix seconds or null, and defaults to now. The new document takes the next `Untitled-N` name, is marked unsaved, has nothing selected and has no steps to undo or redo. It is out of symbol, opacity-mask and pattern editing, and the art drawn in a pattern's tile is stored in the pattern, as `object.pattern.done` stores it. The source document and its steps stay as they are, except that typing or a drag in progress is first kept as a step. When a command keeps a drag whose preview Real-time Drawing off had not applied yet (`edit.undo`, `edit.redo`, `edit.clearHistory`, `edit.newDocumentFromState` and the other commands that end a drag first), and applying that preview gives a warning, the command's result carries it as `previewWarning`, and as `warning` too when the command gives no warning of its own; the app's status bar shows `warning`. While the Type tool edits type, `undo` and `redo` put its caret, with no characters selected, at the end of the text the step changed: after the text it puts back or retypes, or where the text it takes out was. A step that changes no characters, such as a formatting change, leaves the caret and the selection where they are. |
|
||||
|
||||
For example, create editable Japanese area type with the engine's vertical writing mode:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user