Repository navigation
feat(main-editor): resizable text boxes - #898
Merged
Merged
Conversation
…effects - A box handle on a layer with keyframes kept the edge opposite it only on the rest offset: the resize now starts from where the keyframes show the layer and writes the keyframe at the playhead, like the other transform gestures. - TextLayerBox.toMap rounds its size to maxDecimalPlaces, which toMap and toMapFromReference pass on; fromMap also reads sizes written as text. - A box that shrinks its text shrinks the outline and the shadows with it. - Add the 14.15.0 CHANGELOG entry and version.
Owner
|
Thanks a lot for the PR, @saif-ellafi! 🙌 I tested it in the example and in the editor, and everything worked flawlessly. I added a small follow-up commit on top:
It will be released in 14.15.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request has been AI assisted, I have tested and designed the solution manually. I hope you like the approach.
As it is, this is a backend component only, to enable clients implement this as necessary, existing and default functionality is not affected. An example has been included.
Description
Adds an optional fixed-size text box for
TextLayer, like a text field on a form. A boxed layer lays its text out inside a box of a set size instead of growing with the text. Its edges can be dragged to resize the box without scaling the text. Everything is opt-in: layers without a box, and editors that don't enable the handles, behave exactly as before.Model
TextLayerBox(size,verticalAlign,overflow) onTextLayer.box. It is nullable and defaults tonull.sizeis in the layer's own units, beforeLayer.scale, the same asmaxTextWidth. The box therefore scales together with the layer.verticalAlign:top/center/bottom, for text shorter than the box.overflow:clip, orshrink. Withshrink, the font is scaled down until the text fits, to at leastminShrinkFactor(25%), and anything still left over is clipped.toMap/fromMap/toMapFromReference(minified keytb) and carried bycopyWith, layer copies anddebugFillProperties. Older exports, which have noboxkey, load as unboxed layers.TextLayerBox.resize(...)returns the new size and offset for a handle drag. It keeps the opposite edge fixed and accounts for rotation, flips, scale andlayerFractionalOffset.TextLayerBox.fit(...)sizes a box around some text so that it looks unchanged.Rendering
RoundedBackgroundText/RoundedBackgroundPaintertake an optionalbox. With a box:Interaction
LayerInteractionConfigs.enableTextBoxResize(defaultfalse). When it is on, the default selection overlay shows edge handles on boxed text layers.TextLayerBoxHandleswidget, plus theLayerItemInteractions.textBoxResizeDown/textBoxResizeUpcallbacks (no-ops by default), so customoverlayChildBuilders can show their own handles.Text editor
TextEditorState.boxEnabled/setBoxEnabled(bool)let a custom UI turn thtor gains no new built-in button.Tests
New tests cover:
fit;Related Issue: Related to #411 and #446 (text box feature requests).
Type of Change