Repository navigation
Make text layers easier to drag - #14
Merged
Merged
Conversation
hitTestLayer rejected any pixel with alpha below 10, and a text raster is mostly transparent between glyphs, so the layer slipped out from under the cursor unless you grabbed a stroke exactly. Text layers are now picked by their bounding box. The trade-off is that a text layer captures clicks across its whole box, including the gaps; picking a layer underneath means clicking outside the text bounds. Fixes #2
Adds a little slop around the text bounds so a near miss at the edge still grabs the layer, and documents that the same box drives both dragging and click-to-edit - which is the behaviour being asked for: click anywhere in the text rectangle rather than hunting for a glyph. Verified by measuring the rendered text box and probing a grid inside it: all fifteen points grab the layer, gaps between letters included, and clicking a gap with the Text tool reopens the text for editing. Fixes #2
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.
Fixes #2
hitTestLayerrejected any pixel with alpha below 10. A text raster is mostly transparent between the glyphs, so unless you grabbed a letter stroke exactly, the layer slipped out from under the cursor. Text layers are now picked by their bounding box instead.Image and paint layers keep the per-pixel test, so clicking through the transparent part of a photo layer still behaves as before.
Trade-off worth knowing: a text layer now captures clicks across its whole box, gaps included. Picking a layer underneath means clicking outside the text bounds. That is the usual bargain for making text grabbable, and it is the behaviour the issue asks for.
Verification
Driven in a browser against the running editor: place a text layer, switch to Move, drag starting from a gap between two letters, then sample the canvas. The origin reads white and the drop point reads dark, so the layer followed the drag. Before the change that same drag did nothing.
pnpm test(21) andpnpm exec tsc --noEmitare clean.Branched off
masterand independent of #13, so the two can merge in either order.