mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-17 15:46:58 +00:00
A: guides on layers — hidden and locked with their layer
Also records the Pencil tool in ROADMAP and the parity catalog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cc33d0ba15
commit
0dc6a03979
5 files changed
+56
-10
No files matched your search
@@ -30,6 +30,8 @@ DesignCraft aims at full Adobe InDesign parity — and to be better: faster, ope
|
||||
- Edit › Paste Into (copied objects become a frame's content, clipped by it; rendered, PDF and IDML both ways — verified in InDesign 2026); Polygon Settings (sides, star inset; double-click the Polygon tool).
|
||||
- Color panel (fill/stroke proxy, CMYK/RGB/Lab sliders with channel ramps, tint slider for swatches, spectrum ramp, Add to Swatches) and Color Picker (double-click the proxy); mixed colours are unnamed (not listed in Swatches until added); `object.color`, `swatch.addToSwatches`, `swatch.addUnnamed`.
|
||||
- Place text files: Word (.docx: styles by name with their attributes, bold/italic/underline/size/font, footnotes, tables, tabs, breaks), RTF and plain text, into the insertion point, the selected frame or a new frame; autoflow adds pages and threaded frames until the text fits; Remove Styles option (`designcraft-textimport`).
|
||||
- Guides belong to the active layer: hidden with it (or with its Show Guides off) and locked with it.
|
||||
- Pencil tool (N): freehand strokes simplified to smooth paths (Alt closes); Smooth and Erase are still to come.
|
||||
- Edit › Keyboard Shortcuts: every command, click and press the new keys, conflicts shown, per-command and global reset; `window.setShortcut`.
|
||||
- Primary Text Frame (New Document) and Smart Text Reflow: pages are added while the primary story oversets and empty ones at the end removed, in the same undo step (Preferences › Type).
|
||||
- Glyphs panel: every character of any font (rendered by our renderer), search by character or U+code, click to insert, recently used.
|
||||
|
||||
@@ -60,6 +60,20 @@ pub struct Guide {
|
||||
pub spread: bool,
|
||||
#[serde(default)]
|
||||
pub locked: bool,
|
||||
/// The layer the guide is on: hidden with it, locked with it (`None` = always shown).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub layer: Option<crate::LayerId>,
|
||||
}
|
||||
|
||||
impl Guide {
|
||||
/// Shown when its layer is visible with Show Guides on.
|
||||
pub fn visible_in(&self, d: &crate::Document) -> bool {
|
||||
self.layer.is_none_or(|l| d.layer(l).is_none_or(|l| l.visible && l.show_guides))
|
||||
}
|
||||
/// Can be dragged: neither it nor its layer is locked.
|
||||
pub fn editable_in(&self, d: &crate::Document) -> bool {
|
||||
!self.locked && self.layer.is_none_or(|l| d.layer(l).is_none_or(|l| !l.locked && l.visible && l.show_guides))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
|
||||
@@ -88,10 +88,11 @@ fn add(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
page_at(d, r, x)
|
||||
}
|
||||
};
|
||||
let layer = s.doc()?.active_layer;
|
||||
s.edit(|d, _| {
|
||||
let sp = d.spread_mut(r).ok_or_else(|| bad("guide.add", "no such spread"))?;
|
||||
let pg = sp.pages.get_mut(pi).ok_or_else(|| bad("guide.add", "no such page"))?;
|
||||
pg.guides.push(Guide { orientation: o, position: pos, spread: spread_guide, locked: false });
|
||||
pg.guides.push(Guide { orientation: o, position: pos, spread: spread_guide, locked: false, layer: Some(layer) });
|
||||
Ok(json!({"page": pi, "index": pg.guides.len() - 1}))
|
||||
})
|
||||
}
|
||||
@@ -157,6 +158,7 @@ fn create_guides(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let remove = p.get("removeExisting").and_then(Value::as_bool).unwrap_or(false);
|
||||
let r = spread_param(p, "spread");
|
||||
let only = p.get("page").and_then(Value::as_u64).map(|v| v as usize);
|
||||
let layer = s.doc()?.active_layer;
|
||||
s.edit(|d, _| {
|
||||
let sp = d.spread_mut(r).ok_or_else(|| bad("layout.createGuides", "no such spread"))?;
|
||||
let mut n = 0;
|
||||
@@ -169,11 +171,11 @@ fn create_guides(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
let area: Rect = if to_page { pg.bounds() } else { pg.margin_rect() };
|
||||
for y in grid_positions(area.y0, area.y1, rows, rg) {
|
||||
pg.guides.push(Guide { orientation: Orientation::Horizontal, position: y, spread: false, locked: false });
|
||||
pg.guides.push(Guide { orientation: Orientation::Horizontal, position: y, spread: false, locked: false, layer: Some(layer) });
|
||||
n += 1;
|
||||
}
|
||||
for x in grid_positions(area.x0, area.x1, cols, cg) {
|
||||
pg.guides.push(Guide { orientation: Orientation::Vertical, position: x, spread: false, locked: false });
|
||||
pg.guides.push(Guide { orientation: Orientation::Vertical, position: x, spread: false, locked: false, layer: Some(layer) });
|
||||
n += 1;
|
||||
}
|
||||
}
|
||||
@@ -215,3 +217,28 @@ mod tests {
|
||||
assert_eq!(s.doc().unwrap().doc.spreads[0].pages[0].guides.len(), 5);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod layer_tests {
|
||||
use serde_json::json;
|
||||
|
||||
use crate::Session;
|
||||
|
||||
#[test]
|
||||
fn guides_follow_their_layer() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({})).unwrap();
|
||||
let l = s.execute("layer.new", &json!({"name": "Grid"})).unwrap()["id"].as_u64().unwrap();
|
||||
s.execute("layer.activate", &json!({"id": l})).unwrap();
|
||||
s.execute("guide.add", &json!({"orientation": "vertical", "position": 100})).unwrap();
|
||||
let g = |s: &Session| s.doc().unwrap().doc.spreads[0].pages[0].guides[0].clone();
|
||||
assert_eq!(g(&s).layer.map(|x| x.0), Some(l));
|
||||
assert!(g(&s).visible_in(&s.doc().unwrap().doc));
|
||||
s.execute("layer.set", &json!({"id": l, "visible": false})).unwrap();
|
||||
let d = s.doc().unwrap().doc.clone();
|
||||
assert!(!g(&s).visible_in(&d) && !g(&s).editable_in(&d));
|
||||
s.execute("layer.set", &json!({"id": l, "visible": true, "locked": true})).unwrap();
|
||||
let d = s.doc().unwrap().doc.clone();
|
||||
assert!(g(&s).visible_in(&d) && !g(&s).editable_in(&d));
|
||||
}
|
||||
}
|
||||
@@ -496,7 +496,7 @@ fn draw_guides(app: &DesignApp, painter: &egui::Painter, xf: &Xf, doc: &Document
|
||||
}
|
||||
}
|
||||
}
|
||||
for g in &p.guides {
|
||||
for g in p.guides.iter().filter(|g| g.visible_in(doc)) {
|
||||
// Spread guides cross the pasteboard; page guides their page.
|
||||
let span = if g.spread { layout.pasteboard } else { pr };
|
||||
let (a, bb) = match g.orientation {
|
||||
@@ -1359,6 +1359,9 @@ fn guide_at(app: &DesignApp, xf: &Xf, p: Pos2) -> Option<(designcraft_doc::Sprea
|
||||
for (pi, pg) in sp.pages.iter().enumerate() {
|
||||
let pr = if pg.guides.iter().any(|g| g.spread) { layout.pasteboard - slot.offset } else { pg.bounds() };
|
||||
for (gi, g) in pg.guides.iter().enumerate() {
|
||||
if !g.editable_in(&st.doc) {
|
||||
continue;
|
||||
}
|
||||
let r = if g.spread { pr } else { pg.bounds() };
|
||||
let hit = match g.orientation {
|
||||
designcraft_doc::Orientation::Horizontal => (local.y - g.position).abs() <= tol && local.x >= r.x0 && local.x <= r.x1,
|
||||
|
||||
+6
-6
@@ -5,20 +5,20 @@ The summary is generated by `cargo xtask parity` from the table at the bottom of
|
||||
Each row of the InDesign feature catalogue is scored **D** (done), **P** (partial: works but lacks options or UI) or **M** (missing), weighted by priority (**P0** core = 3, **P1** = 2, **P2** = 1). Out-of-scope rows (Adobe cloud services, plug-ins, Typekit, Flash) are excluded.
|
||||
|
||||
<!-- SUMMARY -->
|
||||
**Weighted breadth parity: 76%** over 275 features.
|
||||
**Weighted breadth parity: 77%** over 275 features.
|
||||
|
||||
| Priority | Features | Done | Partial | Missing | Parity |
|
||||
|---|---|---|---|---|---|
|
||||
| P0 | 102 | 99 | 3 | 0 | 99% |
|
||||
| P1 | 97 | 52 | 23 | 22 | 65% |
|
||||
| P1 | 97 | 53 | 24 | 20 | 67% |
|
||||
| P2 | 76 | 8 | 7 | 61 | 15% |
|
||||
|
||||
| Area | Parity |
|
||||
|---|---|
|
||||
| Application shell & workspace | 80% |
|
||||
| Documents, pages, spreads | 74% |
|
||||
| Documents, pages, spreads | 77% |
|
||||
| Layers | 95% |
|
||||
| Frames, shapes & paths | 85% |
|
||||
| Frames, shapes & paths | 87% |
|
||||
| Transform | 93% |
|
||||
| Fill, stroke, colour | 74% |
|
||||
| Effects & transparency | 50% |
|
||||
@@ -82,7 +82,7 @@ Open P0 items: Preferences, Vector/page formats (PDF/AI/SVG/EPS place), Export t
|
||||
| Documents, pages, spreads | Alternate layouts | P2 | M |
|
||||
| Documents, pages, spreads | Document grid & baseline grid | P0 | D |
|
||||
| Documents, pages, spreads | Ruler guides | P0 | D |
|
||||
| Documents, pages, spreads | Guides on layers | P1 | M |
|
||||
| Documents, pages, spreads | Guides on layers | P1 | D |
|
||||
| Documents, pages, spreads | Liquid guides | P2 | M |
|
||||
| Documents, pages, spreads | Smart guides | P0 | D |
|
||||
| Documents, pages, spreads | Snap to guides / grid / baseline | P0 | D |
|
||||
@@ -99,7 +99,7 @@ Open P0 items: Preferences, Vector/page formats (PDF/AI/SVG/EPS place), Export t
|
||||
| Frames, shapes & paths | Polygon settings | P0 | D |
|
||||
| Frames, shapes & paths | Line tool | P0 | D |
|
||||
| Frames, shapes & paths | Pen, add/delete anchor, convert direction | P0 | D |
|
||||
| Frames, shapes & paths | Pencil, Smooth, Erase | P1 | M |
|
||||
| Frames, shapes & paths | Pencil, Smooth, Erase | P1 | P |
|
||||
| Frames, shapes & paths | Scissors | P1 | D |
|
||||
| Frames, shapes & paths | Content type | P0 | D |
|
||||
| Frames, shapes & paths | Convert Shape | P1 | P |
|
||||
|
||||
Reference in new issue
Block a user