Merge pull request #2007 from markx77/fix/1994-hidden-character-visibility

Hide character marks with hidden frames and layers (#1994)
This commit is contained in:
FredApps authored and GitHub committed 2026-11-26 13:46:02 +01:00
commit 37fac22e96
4 files changed
+132 -3

No files matched your search

+6 -1
View File
@@ -1,12 +1,17 @@
# DesignCraft roadmap
- 2026-11-19: Arabic UI glyphs use installed Arabic fonts when the optional craft-fonts input is absent; Arabic-specific families keep letters and spaces in the same fallback face (#3018).
- **2026-11-18 · UI1994:** Hidden-character marks follow frame, layer and containing-group
visibility. Locked, visible layers still show marks; showing a hidden layer restores them.
Visibility checks and painting reuse one frame lookup. The canvas painter has synthetic
regression coverage, including table cells and spreads excluded from the canvas layout.
No readiness percentage change.
**Stage: pre-alpha** · next: alpha, ~5–7 h away; beta ~28 points and ~420–750 h beyond that (the core-workflow gate, not the percentage: ready for real work is already ~47%)
- 2026-10-23: placed-artwork layer options survive IDML and native round trips per placement, independently of shared assets. Unsupported visibility overrides are explicit import/preflight/PDF warnings; format 4 prevents older native readers from silently discarding them. Rendering parity is still open; see [graphic-layer-options.md](docs/graphic-layer-options.md).
- FID1: PDF export normalizes mixed emitted gradient color spaces to RGB with an explicit warning; homogeneous device-space gradients retain their components. Linear/radial, midpoint, archival and print policies have synthetic regression coverage.
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-11-15 · **Change:** minor (obsolete CI gap removed; tracked-change selection mapping; Pages panel parents and alternate layouts; File ▸ Export Layouts and Versions; placed graphic layer-option preservation and explicit rendering warnings; File ▸ Open Recent; .indd and .indt open through indd-utils; text threads by hand; the alpha gate waits on Primary Text Frame page fixes; Japanese print, import and table controls localized; Live corners (#186); Optical kerning from outlines (#181); window and menu quit confirmation; failed writes preserve live save and collection state; spring-loaded Zoom navigation; orderly native exit recovery; Pages panel parents; cancelable macOS Dock Quit; text stroke behind fill; Based on Parent; object styles carry effects; table anchors keep their own paragraphs; grouped HTML/EPUB reading order; Links source paths; XLSX cached cell values retain numeric precision and text; automation roots refuse superscript COM/LPT names and a device name before a colon) · **Target:** Adobe InDesign 2026
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-11-19 · **Change:** minor (hidden characters follow frame, group and layer visibility (#1994); obsolete CI gap removed; tracked-change selection mapping; Pages panel parents and alternate layouts; File ▸ Export Layouts and Versions; placed graphic layer-option preservation and explicit rendering warnings; File ▸ Open Recent; .indd and .indt open through indd-utils; text threads by hand; the alpha gate waits on Primary Text Frame page fixes; Japanese print, import and table controls localized; Live corners (#186); Optical kerning from outlines (#181); window and menu quit confirmation; failed writes preserve live save and collection state; spring-loaded Zoom navigation; orderly native exit recovery; Pages panel parents; cancelable macOS Dock Quit; text stroke behind fill; Based on Parent; object styles carry effects; table anchors keep their own paragraphs; grouped HTML/EPUB reading order; Links source paths; XLSX cached cell values retain numeric precision and text; automation roots refuse superscript COM/LPT names and a device name before a colon) · **Target:** Adobe InDesign 2026
- AR1.1: Kashida justification tests verify space fallback without Tatweel fonts using an isolated font database, while retaining elongation assertions when fonts support it.
- AR1: Arabic IDML controls now retain character direction, kashida switches, diacritic offsets/forms, paragraph policy values and independent story/table directions. Shaping preserves joining context and script/language selection; paragraph-level bidi, contextual digit conversion, mark-safe elongation, RTL columns/tables and physical column insertion have regression coverage. Vendor-specific justification and diacritic presets remain explicit preflight warnings; see docs/arabic-typography.md.
+99
View File
@@ -3409,6 +3409,105 @@ fn trailing_spaces_show_dots_before_the_paragraph_mark() {
}
}
/// Capture the text shapes emitted by the hidden-character painter for the supplied canvas.
fn painted_hidden_character_marks(app: &DesignApp, doc: &Document, layout: &CanvasLayout) -> Vec<String> {
let ctx = egui::Context::default();
let xf = Xf::new(Rect::from_min_size(Pos2::ZERO, vec2(1440.0, 900.0)), &View::default());
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| {
draw_hidden_characters(app, ui.painter(), &xf, doc, layout);
});
out.textures_delta.clear();
out.shapes
.iter()
.filter_map(|s| match &s.shape {
egui::Shape::Text(t) => Some(t.galley.text().to_owned()),
_ => None,
})
.collect()
}
/// #1994: hiding a frame or its layer must also hide the separately painted marks.
#[test]
fn hidden_characters_follow_frame_layer_and_group_visibility() {
let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
app.run("file.new", json!({})).unwrap();
let frame = app.run("frame.create", json!({"rect": [36, 36, 336, 136], "content": "text", "text": "a b\tc\nd"})).unwrap();
let id = designcraft_doc::ItemId(frame["id"].as_u64().unwrap());
let mut doc = (*app.session.active().unwrap().doc).clone();
let layer = doc.item(id).unwrap().layer;
let marks = |app: &DesignApp, doc: &Document| painted_hidden_character_marks(app, doc, &CanvasLayout::new(doc, false));
let expected = marks(&app, &doc);
for mark in ["·", "»", "", "#"] {
assert!(expected.iter().any(|m| m == mark), "visible text draws {mark}: {expected:?}");
}
doc.layer_mut(layer).unwrap().visible = false;
assert!(marks(&app, &doc).is_empty(), "hidden layers draw no marks");
doc.layer_mut(layer).unwrap().visible = true;
assert_eq!(marks(&app, &doc), expected, "showing the layer restores its marks");
doc.item_mut(id).unwrap().hidden = true;
assert!(marks(&app, &doc).is_empty(), "hidden frames draw no marks");
doc.item_mut(id).unwrap().hidden = false;
doc.layer_mut(layer).unwrap().locked = true;
assert_eq!(marks(&app, &doc), expected, "locked but visible layers still show marks");
// A child stays individually visible when its containing group is hidden.
let sibling = app.run("frame.create", json!({"rect": [400, 36, 450, 86]})).unwrap();
app.run("selection.set", json!({"ids": [id.0, sibling["id"]]})).unwrap();
let group = app.run("object.group", json!({})).unwrap();
let group_id = designcraft_doc::ItemId(group["id"].as_u64().unwrap());
let mut grouped = (*app.session.active().unwrap().doc).clone();
assert_eq!(marks(&app, &grouped), expected);
grouped.item_mut(group_id).unwrap().hidden = true;
assert!(marks(&app, &grouped).is_empty(), "hidden groups draw no child marks");
}
/// Parent editing and viewport culling must not paint marks for a spread absent from the layout.
#[test]
fn hidden_characters_only_paint_laid_out_spreads() {
let app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
let mut doc = Document::new(&designcraft_doc::build::NewDocument::default());
let layer = doc.default_layer();
let rect = DRect::new(36.0, 36.0, 336.0, 136.0);
doc.add_text_frame(SpreadRef::Doc(0), rect, layer, "a b", Default::default()).unwrap();
let document_layout = CanvasLayout::new(&doc, false);
let parent_layout = CanvasLayout::new(&doc, true);
assert!(!painted_hidden_character_marks(&app, &doc, &document_layout).is_empty());
assert!(painted_hidden_character_marks(&app, &doc, &parent_layout).is_empty(), "document marks stay off the parent canvas");
doc.add_text_frame(SpreadRef::Parent(0), rect, layer, "a\tb", Default::default()).unwrap();
let document_marks = painted_hidden_character_marks(&app, &doc, &document_layout);
let parent_marks = painted_hidden_character_marks(&app, &doc, &parent_layout);
assert_eq!(document_marks, ["·", "#"], "parent marks stay off the document canvas");
assert_eq!(parent_marks, ["»", "#"], "only the parent frame is painted while editing parents");
let mut culled = document_layout;
culled.slots.clear();
assert!(painted_hidden_character_marks(&app, &doc, &culled).is_empty(), "culled spreads have no marks");
}
/// Table-cell marks use the same frame and layer visibility checks as ordinary story marks.
#[test]
fn hidden_characters_in_table_cells_follow_frame_visibility() {
let app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
let mut doc = Document::new(&designcraft_doc::build::NewDocument::default());
let layer = doc.default_layer();
let (frame, story) = doc.add_text_frame(SpreadRef::Doc(0), DRect::new(36.0, 36.0, 336.0, 336.0), layer, "", Default::default()).unwrap();
let data = vec![vec!["a b\tc\nd".to_owned(), String::new()]];
let table = designcraft_doc::Table::from_strings(doc.alloc(), &data, 200.0, &Default::default(), &Default::default());
doc.story_mut(story).unwrap().insert_table(0, table);
let layout = CanvasLayout::new(&doc, false);
let expected = painted_hidden_character_marks(&app, &doc, &layout);
for mark in ["·", "»", "", "#"] {
assert!(expected.iter().any(|m| m == mark), "visible table cells draw {mark}: {expected:?}");
}
assert!(expected.iter().filter(|m| *m == "#").count() >= 2, "including the empty cell's end mark");
doc.item_mut(frame).unwrap().hidden = true;
assert!(painted_hidden_character_marks(&app, &doc, &layout).is_empty(), "hidden frames hide cell marks too");
doc.item_mut(frame).unwrap().hidden = false;
doc.layer_mut(layer).unwrap().visible = false;
assert!(painted_hidden_character_marks(&app, &doc, &layout).is_empty(), "hidden layers hide cell marks too");
doc.layer_mut(layer).unwrap().visible = true;
assert_eq!(painted_hidden_character_marks(&app, &doc, &layout), expected, "showing the layer restores every cell mark");
}
/// As InDesign: an end-of-story # in every cell (after its text), a ¶ where a cell paragraph
/// ends, and the table paragraph's ¶ just after the table's bottom right corner.
#[test]
+20 -1
View File
@@ -274,7 +274,10 @@ pub(super) fn draw_hidden_characters(app: &DesignApp, painter: &egui::Painter, x
for story in doc.stories.values() {
let cs = app.session.cache.get(doc, story.id, None);
for ft in &cs.frames {
let (Some((a, _)), Some(it)) = (item_canvas_xf(doc, layout, ft.frame), doc.item(ft.frame)) else { continue };
let Some((loc, it)) = hidden_characters_frame(doc, ft.frame) else { continue };
// Parent editing and viewport culling can leave this spread off the canvas.
let Some(slot) = layout.slot(loc.spread) else { continue };
let a = slot.xf * doc.parent_xf(&loc);
let m = a * doc.text_xf(it);
let col = layer_color(doc, it);
for (p, mark, centered, ascent) in frame_hidden_marks(&story.text, ft) {
@@ -286,6 +289,22 @@ pub(super) fn draw_hidden_characters(app: &DesignApp, painter: &egui::Painter, x
}
}
/// Resolve a visible frame once for both the visibility check and painting, including its groups.
fn hidden_characters_frame(doc: &Document, frame: designcraft_doc::ItemId) -> Option<(designcraft_doc::ItemLoc, &designcraft_doc::Item)> {
let loc = doc.find(frame)?;
let spread = doc.spread(loc.spread)?;
let mut items = spread.items.as_slice();
for &index in &loc.path {
let item = items.get(index)?;
if item.hidden || doc.layer(item.layer).is_some_and(|layer| !layer.visible) {
return None;
}
items = item.children();
}
let item = doc.item_at(&loc)?;
Some((loc, item))
}
/// A frame's hidden-character marks in frame space (position at the baseline, mark, centered,
/// the line's ascent): its lines' marks, then its tables' — each text cell's own marks (nested
/// tables included) with its # where its text ends, and a table paragraph's ¶ after the last
+7 -1
View File
@@ -1,6 +1,12 @@
# UI and interaction parity
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-02 · **Change:** patch (the Pen previews the curve while a smooth point is dragged and curves the rubber band after one, #1438; a Custom text variable defined with a number shows its digits, #2093; Table of Contents dialog: title field keeps its width, More Options toggles without losing hidden settings; Story panel; text Control panel Character/Paragraph modes; Properties ••• expands Character and Paragraph; live corners work; document views row: scrollbars, Alt pans while editing text; Tabs panel listed as present (#343); spring-loaded Zoom navigation; paragraph style override feedback and clearing) · **Target:** Adobe InDesign 2026 (21.6, Medium Dark, macOS)
- **2026-11-18 · UI1994:** Show Hidden Characters no longer paints marks for hidden text
frames, hidden layers or children of hidden groups. Visible locked layers retain their marks.
Visibility checks and painting share the resolved frame location and item.
Canvas-painter regressions check emitted marks and hide/show transitions, including table
cells, parent editing and culled spreads (#1994).
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** patch (hidden characters follow frame, group and layer visibility (#1994); the Pen previews the curve while a smooth point is dragged and curves the rubber band after one, #1438; a Custom text variable defined with a number shows its digits, #2093; Table of Contents dialog: title field keeps its width, More Options toggles without losing hidden settings; Story panel; text Control panel Character/Paragraph modes; Properties ••• expands Character and Paragraph; live corners work; document views row: scrollbars, Alt pans while editing text; Tabs panel listed as present (#343); spring-loaded Zoom navigation; paragraph style override feedback and clearing) · **Target:** Adobe InDesign 2026 (21.6, Medium Dark, macOS)
Tools, handles, snapping, nudging, modifiers, shortcuts, panels, menus, context menus and feel,
against InDesign 2026. The look was measured from the running app