Temporary straight ruler action for freehand brush strokes
Summary
This adds a hold-to-activate temporary straight ruler for painting. While holding the configured shortcut key, Krita shows a temporary straight-line constraint. The first pen/mouse press locks the line direction, and all strokes while the key remains held are constrained to that same line. Releasing the key removes the ruler.
Motivation
This workflow is useful for quick straight-line painting without switching tools or creating a persistent assistant. It is similar to the temporary ruler workflow in Rebelle: hold a key, define a direction, paint constrained strokes, release the key to return to normal painting.
This is especially useful for sketching, and perspective/detail work where the artist needs temporary straight strokes without interrupting the brush workflow. Personally I use it to define a constrained for my subject I want to draw/sketch, as well as sketch and find out perspetive for my paintings. Its cumbersome to do otherwise.
The existing Line Tool on V is not suitable for this workflow because it requires switching away from the active brush workflow into a separate tool interaction. It creates one explicit line stroke at a time, instead of temporarily constraining normal brush painting while preserving the current brush behavior, pressure, texture, opacity, and repeated stroke flow. The temporary ruler is meant to be a hold-to-use constraint: define a direction once, make several natural brush strokes along it, then release the key and immediately continue freehand painting.
Behavior
- Hold shortcut key: temporary preview line appears.
- Move cursor: preview direction updates.
- First pen/mouse press: line is locked.
- Release pen/mouse: line remains locked while the key is still held.
- Move cursor while locked: marker shows the projected brush position on the line.
- Press again: draw another stroke on the same temporary line.
- Release shortcut key: temporary ruler is removed.
Showcase
Implementation Notes
The feature adds a temporary paint constraint owned by the painting assistants decoration. Freehand painting checks this constraint and projects brush positions onto the locked line when active.
The temporary ruler action uses an event filter only for preview/marker/key-release tracking. Painting itself continues through Krita's normal tool invocation path.
Testing
Tested manually with:
- Mouse painting.
- Pen/tablet painting.
- Multiple strokes while holding the shortcut.
- Releasing the shortcut to clear the ruler.
- Brush resizing before reusing the ruler.
I also added test for the temporary paint constraint projection and locked-line behavior.
Todo
- Implementing code improvements/suggestions.
- Implement being able to adjust the straight ruler on an fixed angle. (By holding shift)
- Adding user feedback for the pivot point.
- Fixing Anti-aliasing issue.
- Implementing constrained only for multibrush and brush tool.
- Making the v-shortcut the default for new krita profiles.
- Cleanup and fixing some bugs
Discussion
Forum discussion: Temporary straight ruler action for freehand brush strokes
Test Plan
- Define a key for the action under
Configure Krita / Canvas Input Settings / Temporary Straight Ruler. - Press the defined key, while selecting a brush.
- Click on a second point to lock in the line constrain to draw on.
- You now can only draw on that line.
- Releasing the define key, removes the line contrain.
Formalities Checklist
- I confirmed this builds.
- I confirmed Krita ran and the relevant functions work.
- I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
- I made sure my commits build individually and have good descriptions as per KDE guidelines.
- I made sure my code conforms to the standards set in the HACKING file.
- I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.
- Does the patch add a user-visible feature? If yes, is there a documentation MR ready for it at Krita Documentation Repository?
Reminder: the reviewer is responsible for merging the patch, this is to ensure at the least two people can build the patch. In case a patch breaks the build, both the author and the reviewer should be contacted to fix the build. If this is not possible, the commits shall be reverted, and a notification with the reasoning and any relevant logs shall be sent to the mailing list, kimageshop@kde.org.
