Skip to content

Improve inline-size text creation.

This MR does a few things to make creating texts with inline size nicer:

  1. It ensures that the first x and y on a <text/> are interpreted as the position. This is in accordance with the SVG spec.
  2. It allows for creating inline-size texts without ctrl being pressed: when the rect-size is above the font-size it'll become an inline-size wrapped shape.
  3. The text-creation command now tests against tablet pressure. This is because it was previously too easy to accidentally create a text with a tablet. The pressure threshold needs testing however.
  4. Both inline-size handles now do something, with for text-anchor:start/end, one moving and the other resizing, and the anchor being flipped when one handle passes the other. For text-anchor:center, both handles move and resize.
  5. I've added the ability to create vertical and rtl texts.

image

  1. I've implemented snapping for text-creation and inline size handle movement, as well as enabled the drawing of the snap guide.

Some thoughts:

  • The cursors switching is a bit weird now. I think we might need to make the whole SVG text tool into a KoInteractionTool like the Default/Shape Selection tool is, as that has some better mechanisms for tracking which interactionstrategy is active as well as switching cursors.
  • I would like to differentiate the non-wrapped and wrapped text modes during creation better. This can either be through cursors, which would need the KoInteractionTool stuff, or by changing the way the decoration of the text-creation strategy looks.

Test Plan

  • Create a text with a mouse click: this should be a non-wrapping text.
  • Create a text with a mouse click+drag: this should lead to a wrapping text provided the wrap area is bigger than the fontsize.
  • Create a text with a press of a tablet stylus: very soft presses should not create a text, more decisive press will create a non-wrapping text.
  • Create a wrapping text, move the handles around, play with different anchor options here.
  • Use the buttons in the tool options to create texts for horizontal/vertical-rl/vertical-lr and ltr and rtl modes.

@alvinwong -- I'm setting you as the reviewer, given I'm mostly editing your code. If you don't have time, just unassign yourself. @timotheegiet -- I've taken icons from the breeze set. If you want to test this, get the 'linuxbuild:archive' from the MR artifacts when it is done building.

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.

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.

Edited by Wolthera van Hövell

Merge request reports