Skip to content

WIP: Add options to create reference image from current layer/visible canvas

Per a wishlist item (https://bugs.kde.org/show_bug.cgi?id=399058), this patch introduces a new button in the Reference Image Tool that creates a reference image from the active layer:

image

UPDATE1: New context menu entry:

image

UPDATE2: To address a similar wishbug (https://bugs.kde.org/show_bug.cgi?id=403111), I've added another button and context menu item to add a reference image from the visible canvas:

image image

For clarity, I modified the "Create Reference Image from Layer" icon to be image The original icon is now being used for the new "Create Reference Image from Visible" button.

I have documented some limitations to this feature in the TODOs section below.

TODOs:

  • In a second commit, I plan to provide a context menu option to convert a selected layer to a reference image as an alternative way to access this functionality.
  • "Convert" menu options are now implemented in the second commit and tested. (See screenshots above.) However, there's still a limitation that the current layer must be unlocked to use this feature, which I'd like to provide a workaround for. UPDATE: This feature now works regardless of a layer's lock status.
  • Activate the Reference Image Tool programmatically?
  • UPDATE1: Refactored out from the second commit... I'm using a "code-hack" to call ToolReferenceImages::addReferenceImageFromLayer, which allow the project to build. It would be good to get a conventional method call to work. (See TODOs in KisLayerManager::convertLayerToReferenceImage.)
  • UPDATE2: See the third commit. Add another button/menu option to create a reference image from the visible canvas.
  • Figure out why key unbinding is not working for these actions. (Binding/rebinding work just fine.) UPDATE: Newly assigned shortcuts don't generally "want" to be unbound until the next restart of Krita... May just be a quirk on Windows machines.
  • Document any new functions in code.

NOTE: This merge request replaces !635 (closed), which was based on krita/4.4.2 instead of master.

Test Plan

  1. Open any .kra file (ideally one with multiple layers), and select any layer.
  2. Open the Reference Image Tool, and click on the button circled in red shown in the first screenshot. You should now see a new reference image identical to the current layer appear on top of the canvas.
  3. Alternatively, right-click on an entry in the layers docker, and select the "Reference Image from Layer" option. Behavior should be the same as #2.

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.
Edited by Agata Cacko

Merge request reports