Skip to content

Text boxes: fonts for empty and new boxes, move and rotate while typing (#470) - #493

Open
NikitkaRa wants to merge 1 commit into
storytold:mainfrom
NikitkaRa:issue-470
Open

NikitkaRa wants to merge 1 commit into
storytold:mainfrom
NikitkaRa:issue-470

Conversation

@NikitkaRa

Copy link
Copy Markdown
Contributor

Summary

Reproduced the issue with engine pointer/command tests on main:

  • Font on an empty box: format.font on a selected empty text box did store the font (on the paragraph's end mark), but format.state read only the first run, so the ribbon kept showing the theme font and the pick looked like it did nothing. An empty box's state now comes from its end mark.
  • Font before a box exists: the font and size dropdowns were disabled with nothing selected. format.font/format.size are now enabled whenever a document is open. With nothing selected, the pick becomes the font/size new text boxes start with (Session::text_default, for the session, on every slide, until another pick), and the ribbon shows it (else the theme body font).
  • Moving and rotating: once typing in a text box, the whole box was a text target, so it couldn't be dragged, and the rotation handle was neither drawn nor hit while editing. Now a press within the hit tolerance of the dashed edge grabs the box and moves it (as in PowerPoint), the rotation handle is drawn and works while editing, and presses inside the edge still place the caret and select text. Unselected text boxes already moved with a click-drag.
  • No unwrap/panic in non-test code.

Test plan

  • Empty text box: the picked font shows in format.state and applies to typed text
  • Nothing selected: the picked font and size show in format.state and go to typed-into and created-with-text boxes on later slides, while existing text is untouched
  • Editing a text box: dragging inside selects text, dragging the top edge moves the box, dragging the rotation handle turns it 90°
  • cargo xtask ci (fmt, clippy, test, assets, layers, wasm)
  • Manual: check the edge-drag cursor and the rotation handle drawing while editing in the desktop app

Closes #470

…ng (storytold#470)

- A selected empty text box keeps its font on the end mark; the ribbon
  now shows that font instead of the theme's, so picking one no longer
  looks like it did nothing.
- Font and size are enabled with nothing selected: the pick becomes the
  font and size new text boxes start with (this session), and the ribbon
  shows it.
- While typing in a text box, dragging its dashed edge moves it and the
  rotation handle (now drawn) turns it, as in PowerPoint; presses inside
  the edge still place the caret and select text.

Co-authored-by: Cursor <cursoragent@cursor.com>

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReviewerA — source-read COMMENT (not an approval)

I read the head of the diff: text boxes get fonts for empty and new boxes, and can be moved and rotated while typing (#470). With nothing selected, format.size sets the size that new text boxes start with, and the CLI test and the command description say so ("with nothing selected: the size new text boxes start with"). PowerPoint has this behaviour (a default for the next new text box), so the oracle matches. Two features are combined (defaults for new boxes and move/rotate while typing), and the second involves the keyboard and pointer handling during text editing, where gridcraft#2040 and deckcraft#320 show how subtle focus is. A test for each would help. I read the CLI changes only. I have not run it, and no exact-head CI result exists for this head. Nothing was run.

I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.

Status: waiting_author.

@aiongg aiongg added the bugfix Fixes something that is broken: wrong result, crash, data loss label Nov 4, 2026

@aiongg aiongg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review (Opus). Not a maintainer decision.

Changes needed:

Three changes in one PR: the ribbon now shows the font of an empty text box, the rotation handle works while typing, and a font/size picked with nothing selected becomes the default for new text boxes. The first two are small and look correct. The third adds new session-wide behaviour.

  • crates/engine/src/cmd/format.rs:247 reads an empty box's formatting from its end mark. This matches what format_all stores (crates/model/src/edit.rs:212), so the ribbon now shows the picked font.
  • crates/engine/src/tools.rs:403 and crates/ui-egui/src/canvas.rs:878 hit-test and draw the rotation handle while a box is being edited. This is consistent with the resize handles, which already worked mid-edit.
  • Moving a box by its edge while editing is not new in this diff. The Frame hit at crates/engine/src/tools.rs:413-419 is unchanged.
  • Session::text_default (crates/engine/src/lib.rs:462) is not saved with the document, cannot be undone, and carries over to every presentation opened in the same session.
  • apply_text_default runs inside insert.textBox (crates/engine/src/cmd/insert.rs:286), so pasted plain text (crates/engine/src/cmd/edit.rs:415) and photo album text, captions and titles (crates/engine/src/cmd/insert.rs:1146, 1169, 1173) also get the picked font and size.
  • With format.font/format.size switched to has_doc, a script that calls them with nothing selected now succeeds without changing the document, where it used to report that text or shapes must be selected.
  • The check sh.ph.as_ref().is_none_or(|_| true) at crates/ui-egui/src/canvas.rs:878 is always true and could be removed.
  • Splitting the empty-box state fix and the rotate-while-editing change from the new-box default would keep each topic separate.

Claims checked:

  • verified: format.state on a selected empty text box now shows the font stored on its end mark (crates/engine/src/cmd/format.rs:247 falls back to para.end_props when there are no runs; format_all writes end_props at crates/model/src/edit.rs:212)
  • verified: format.font/format.size are enabled whenever a document is open, and with nothing selected the pick becomes the font/size new text boxes start with, on every slide, and the ribbon shows it (crates/engine/src/cmd/format.rs:40-49 switch to has_doc; format.rs:315-326 store into s.text_default; insert.…
  • contradicted: Only new text boxes get the picked default; existing text is untouched (crates/engine/src/cmd/insert.rs:286 applies it inside insert.textBox, which is also called by plain paste (crates/engine/src/cmd/edit.rs:415) and photo album text, captions and titles (crates/engine/src/cmd/insert.rs:1146,1169,…
  • verified: While editing, a press on the dashed edge grabs and moves the box (crates/engine/src/tools.rs:413-419 returns Hit::Frame for the edited box's frame zone; this code is not changed by the diff, so the behaviour already existed)
  • verified: The rotation handle is drawn and works while editing (crates/engine/src/tools.rs:403 no longer requires selection.text to be none; crates/ui-egui/src/canvas.rs:878 drops the !editing_this check)
  • verified: Presses inside the edge still place the caret and select text (crates/engine/src/tools.rs:414-416 only takes EditZone::Frame; other presses fall through to hit_shape at tools.rs:422-428, unchanged)
  • verified: No unwrap/panic in non-test code (the non-test hunks in crates/engine/src/cmd/format.rs:315-349, crates/engine/src/cmd/insert.rs:286-288 and crates/engine/src/tools.rs:403 use Option combinators only)

Recommendation: update the pull request; it will be reviewed again.

Reviewed at 9f193b0.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes something that is broken: wrong result, crash, data loss

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text Box and Layouts

3 participants