Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Show text stroke options in the Stroke panel when text is selected (#1265)

MarekSpodBiedry551886c13303
diff --git a/crates/ui-egui/src/panels/properties.rs b/crates/ui-egui/src/panels/properties.rs
index fded030b9..44acf6e2c 100644
--- a/crates/ui-egui/src/panels/properties.rs
+++ b/crates/ui-egui/src/panels/properties.rs
@@ -1864,6 +1864,12 @@ pub fn stroke_panel(app: &mut DesignApp, ui: &mut egui::Ui) {
super::cell_stroke::panel(app, ui);
return;
}
+ if super::colors_affect_text(app)
+ && let Some(a) = text_attrs(app)
+ {
+ text_stroke_panel(app, ui, &a["chars"]);
+ return;
+ }
let Some(i) = sel_info(app) else {
crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Select an object."));
return;
@@ -1985,6 +1991,27 @@ pub fn stroke_panel(app: &mut DesignApp, ui: &mut egui::Ui) {
});
}
+/// Stroke panel while text is selected: the text's outline colour, weight and whether it sits behind the fill.
+fn text_stroke_panel(app: &mut DesignApp, ui: &mut egui::Ui, c: &Value) {
+ let swatch = c["stroke"].as_str().unwrap_or(designcraft_color::swatch::NONE).to_string();
+ egui::Grid::new("text_stroke_panel").num_columns(2).spacing(vec2(8.0, 6.0)).show(ui, |ui| {
+ caption(ui, crate::i18n::tr(&app.ui.language, "Weight:"));
+ if let Some(v) = number(ui, "tsw_panel", c["strokeWeight"].as_f64(), " pt", 60.0, 3) {
+ let _ = app.run("type.char", json!({"attrs": {"strokeWeight": v}}));
+ }
+ ui.end_row();
+ caption(ui, crate::i18n::tr(&app.ui.language, "Color:"));
+ super::swatch_picker(app, ui, "tspick", Some(swatch), |app, n| {
+ let _ = super::apply_swatch(app, true, &n, None);
+ });
+ ui.end_row();
+ });
+ let mut behind = c["strokeBehindFill"].as_bool().unwrap_or(false);
+ if ui.checkbox(&mut behind, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "Stroke Behind Fill"))).changed() {
+ let _ = app.run("type.char", json!({"attrs": {"strokeBehindFill": behind}}));
+ }
+}
+
/// A short line ending in arrowhead `a` (pointing left for Start, right for End).
fn arrow_preview(ui: &mut egui::Ui, a: Arrowhead, start: bool, color: egui::Color32) {
use designcraft_geom::kurbo;
@@ -2915,6 +2942,30 @@ mod tests {
h
}
+ /// With the caret in text, the Stroke panel offers the text's stroke options, not an empty panel.
+ #[test]
+ fn stroke_panel_shows_the_text_stroke_options_while_text_is_selected() {
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({})).unwrap();
+ app.run("frame.create", json!({"rect": [72, 72, 400, 400], "content": "text", "caret": true})).unwrap();
+ let mut ready = false;
+ let mut h = Harness::builder().with_size(vec2(320.0, 400.0)).build_ui_state(
+ move |ui, app: &mut DesignApp| {
+ if !ready {
+ crate::theme::install_fonts(ui.ctx(), "");
+ crate::theme::apply(ui.ctx(), &Tokens::for_brightness(Default::default()));
+ ready = true;
+ return;
+ }
+ stroke_panel(app, ui);
+ },
+ app,
+ );
+ h.run_steps(3);
+ assert!(h.query_by_label("Select an object.").is_none());
+ h.get_by_label("Stroke Behind Fill");
+ }
+
/// As InDesign's: Edit Page takes the Page tool to the page in view, and Properties sets that
/// page alone; Back returns to the document.
#[test]
diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md
index 4a7e9b99f..9e9ec6c39 100644
--- a/docs/target-app-parity.md
+++ b/docs/target-app-parity.md
@@ -439,7 +439,7 @@ It is evidence of breadth: each item exists. It is not a claim of InDesign-level
- Gradients: the Gradient Swatch tool (G) drags a gradient's start and end across objects (Shift: 45°); the Gradient panel (InDesign's layout: thumbnail, Type, Location, Angle, Reverse) sets type, angle, reverse and edits stops and midpoints on a ramp (drag, add, drag off to remove, location; drop a swatch from the Swatches panel on a stop or the ramp; stops keep their CMYK), and follows the Fill/Stroke proxy. Edited gradients are unnamed swatches until the Swatches panel's New Swatch names one "New Gradient Swatch" (`swatch.new`, which also duplicates a named swatch); `swatch.create {gradient}` builds one from colour swatches; `object.gradient` (`target: stroke` for a stroke's gradient, drawn across the path's box on screen and in PDF); the vector round-trips through IDML (`GradientFill…`/`GradientStroke…`). A radial gradient stretches with the object's box as InDesign's does (an ellipse reaching the sides of a non-square frame, on screen and in PDF). Text takes a gradient swatch as its fill or stroke, laid across its frame's box as in InDesign (screen and PDF).
- New Document (⌘N) as in InDesign: Recent, Saved, Print, Web and Mobile tabs of page cards (double-click creates) beside the preset's details: document name, size with arrows, units, orientation, pages, start page #, facing pages, primary text frame, columns, margins, bleed and slug per edge (linked or not); Save Document Preset (`file.savePreset`, `file.deletePreset`; saved presets are kept with the preferences, listed by `file.presets` and made by `file.new {preset: name}`); `file.new` takes `intent`, `units`, `startPage` and per-edge `bleed`/`slug`. Preview shows a document with the window's settings in the workspace while it is open; Create keeps it, Close removes it.
- Document Setup (⌥⌘P), laid out like InDesign's: intent, number of pages, start page # (an even start begins with a left page), facing pages, binding, Page Size (presets keeping the orientation, width and height with arrows, orientation), margins for every page and parent page, bleed and slug per edge (each group linked or not), and Adjust Layout (objects follow the new page size and margins), all in one undo step; measures are read in the document's units, and a value that can't be read keeps the dialog open; `layout.documentSetup {}` reports the setup, margins included.
-- Stroke panel: cap, join, miter limit, alignment, type, Start/End arrowheads (12 kinds, drawn on screen and in PDF; the path is shortened under pointed heads) and gap colour under dashes and dots.
+- Stroke panel: cap, join, miter limit, alignment, type, Start/End arrowheads (12 kinds, drawn on screen and in PDF; the path is shortened under pointed heads) and gap colour under dashes and dots; with text selected (or text frames selected with Formatting Affects Text on) it shows the text's stroke weight, colour and Stroke Behind Fill.
- Preferences (⌘K: General, Type, Units & Increments, Grids, Guides & Pasteboard, Display Performance) backed by `prefs.set` (application) and `document.preferences` (units, increments, grids — undoable, saved with the document; right-click a ruler to pick its units, the horizontal and vertical rulers each have their own); scaling applies to content and scales stroke weights (Include Stroke Weight), and X/Y/W/H measure the stroke's outer edge (Dimensions Include Stroke Weight). Quick Apply (⌘Return) finds paragraph, character and object styles as well as commands.
- Parent item overrides: Cmd+Shift-click a parent item on a page (or Override All Parent Page Items, ⌥⇧⌘L) makes an editable local copy that hides the parent's; Remove All Local Overrides and Detach All Objects from Parent in the Pages panel menu.
- Based on Parent (`layout.parents.options {parent, basedOn}`): a parent shows its base parent's items under its own, on its pages and on the parent itself; chains work, cycles are refused, and items from any parent in the chain can be overridden. IDML carries it as the parent pages' `AppliedMaster`; a cycle or missing base in a file is cleared with a warning on open. The Pages panel has no Parent Options dialog yet.