Gamut masking for the artistic color selector
ClosedPublic

Authored by amedonosova on Jun 14 2018, 5:09 AM.

Details

Summary

Implementation of bug 391210.

There is a feature that was not in the design document: the user can set mask strictness in the selector settings to either enforcing (only swatches inside the mask are available for the user to choose) or permissive, "just show the shapes", which only paints the shapes on top of the wheel but does not restrict color picking in any way.

Contrary to the design document, there is no stand-alone mask editor. Instead, when user clicks the edit button, a template opens as a regular view which can be modified, previewed and saved.

Bugs

  • ArtColorSel: When initializing the selector for the first time (empty configuration), the wheel segment values are not right
  • GamutMask: [crash] Start editing the mask, then remove all shape layers of the mask document, then press save

Features

  • creating an empty new mask

Smaller tweaks

  • icon for gamut masking
  • GamutMask: better template design, usability fixes
    • group layer, gray l. with vector on top set to erase
    • set explicit stroke (black) and background (solid transparent) for shapes on preview/save; set fill to white on load to editor, so the erase blend mode works
    • hide editing controls, when user switches out of template document

Pre-launch

  • Create user documentation
  • Create pre-made masks, some for basic color harmonies and something fancy to showcase the possibilities

Diff Detail

Repository
R37 Krita
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
amedonosova created this revision.Jun 14 2018, 5:09 AM
Restricted Application added a project: Krita. · View Herald TranscriptJun 14 2018, 5:09 AM
amedonosova requested review of this revision.Jun 14 2018, 5:09 AM

The original diff did not compile, due to my morning sloppiness, sorry for that.

rempt added a subscriber: rempt.Jun 15 2018, 9:14 AM

Nice work! I must be missing something though, since I cannot seem to create a new mask and save it. Pressing the edit button doesn't seem to do anything for me?

In cooperation with Ahmed Hussein, I started preparing the code to be reused by other color selectors (bug 373922).

Mask selection and management were moved to separate docker, "Gamut Masks". A color selector can subscribe to signals from resource provider to get mask updates.

There is still a crash when the color selector docker repaints after the user cancels mask edit.

In the new docker, the user can now duplicate, edit and delete masks.

amedonosova edited the summary of this revision. (Show Details)Jun 19 2018, 5:51 AM
rempt added a comment.Jun 19 2018, 6:49 AM

Great to hear that you're working together!

dkazakov requested changes to this revision.Jun 22 2018, 9:43 AM
dkazakov added a subscriber: dkazakov.

I've tried to test the patch, but I failed. Then trying to click "Mask" button in the Artistic color selector, it just crashes. I'll wait for updated version of the patch :)

This revision now requires changes to proceed.Jun 22 2018, 9:43 AM

Sorry, I made a clean build and the crash has gone! Now I can press the Mask button, but still cannot create any mask (I don't know how to do that) :)

Anyway, I will wait till the updated version of the patch :)

Thanks for the report, the bug was indeed there (due to use of an uninitialized pointer), I have fixed it. I am working on fixing other crashes, I will update the diff after that.

For selecting a mask (or editing, deleting, etc.), you have to enable the "Gamut Masks" docker, select a mask in the list and press "set" button in the docker bottom. The selector then sets the mask and you can toggle it on to display it.

I will work on the UI to make it clear for the user. The UI is still rather experimental :)

amedonosova edited the summary of this revision. (Show Details)Jun 27 2018, 2:54 PM

I have fixed several crashes and further improved the mask resource type for sharing among multiple selectors. I have also changed the UI to be more straightforward to use and more user-friendly. Gamut masks can be now previewed in the color selector while being edited (though not live, only when the preview button is clicked).

I have updated the summary with items that need to be yet done.

rempt added a comment.Jun 29 2018, 8:00 AM

I'm sorry, but this patch doesn't seem to apply to current master. Could you please rebase it?

amedonosova edited the summary of this revision. (Show Details)

The following patch should be applied to make it compile (looks like there were some local changes not included into the diff :) ):

1diff --git a/plugins/dockers/artisticcolorselector/CMakeLists.txt b/plugins/dockers/artisticcolorselector/CMakeLists.txt
2index e8b23b6..a74c3c9 100644
3--- a/plugins/dockers/artisticcolorselector/CMakeLists.txt
4+++ b/plugins/dockers/artisticcolorselector/CMakeLists.txt
5@@ -9,7 +9,6 @@ ki18n_wrap_ui(kritaartisticcolorselector_SOURCES
6 forms/wdgArtisticColorSelector.ui
7 forms/wdgARCSSettings.ui
8 forms/wdgWheelPreferencesPopup.ui
9- forms/wdgGamutMaskChooserPopup.ui
10 )
11
12 add_library(kritaartisticcolorselector MODULE ${kritaartisticcolorselector_SOURCES})

Hi, @amedonosova!

I have managed to build your patch, but either I don't understand something, or it is impossible to create a mask. Could you please tell how can I create a mask?

Here is what I tried:

Hi, @dkazakov ,

thank you for testing my diff.

You should have three testing masks visible in the gamut masks docker, like this:

The resources should be installed into share/gamutmasks, but for some reason they are not showing up. I will try to reproduce this bug here.

The buttons do nothing, unless a mask is selected. To create a new one, you select a mask, edit and save as new. The idea is that the artist has some basic color harmony templates available to either use directly, or build upon.

It fails to load the resources for some reason with the following debug output:

QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-appimage'
QXcbConnection: XCB error: 148 (Unknown), sequence: 180, resource id: 0, major code: 140 (Unknown), minor code: 20
krita.lib.widgets: Loading resource  "/home/appimage/appimage-workspace/krita-inst/share/krita/gamutmasks/new_mask.kgm" failed
krita.lib.widgets: Loading resource  "/home/appimage/appimage-workspace/krita-inst/share/krita/gamutmasks/testing1.kgm" failed
krita.lib.widgets: Loading resource  "/home/appimage/appimage-workspace/krita-inst/share/krita/gamutmasks/testing2.kgm" failed

Good evening, @dkazakov,

I ran a clean build on my computer and cannot reproduce the problem. However, I'm think the problem might be that my patch does not contain the binary files needed, just mentions that they exist (when I try to apply the patch, git tells me it cannot apply "without full index line"). I'm not sure how to solve it, so for now I'm uploading them here:

Can you please confirm that it is the case? If it is, could you try with the files I uploaded here, until I find a solution to the patch problem?

I'm sorry for the inconvenience.

rempt added a comment.Jun 30 2018, 8:14 AM

Hm, that is strange -- how do you create the patch? Do you make a commit with git that you export with git format-patch?

Hi, @amedonosova!

Yes, the files were empty for some reason. I have downloaded them manually and managed to test. Here are my notes:

  1. In general, the patch works very nicely and I like the idea of it.
  2. [UIX] I would really prefer to have some button to start editing of an empty circular mask. Just to avoid the cases like I faced before. It is also much more intiutuve for a user to press "Create now gamut mask" button, then to edit something :)
  3. [UIX] I'm not sure about the correct place for a button "Apply gamut mask to a selector". I would expect this button to be in the selector itself, not in the editor. Are you going to extend these gamut masks to other color selectors? If so, such placement would create troubles.
  4. It general the patch looks very solid. I tried to make some nasty things, like closing/switching/saving the "edit gamut mask document" during editing. The docker handled this case correctly, without any troubles :) Although it might be a good idea to hide editing mode controls when the user switches out of the gamut mask document. Right now it looks a bit non-obvious :)
  5. [crash] Start editing the mask, then remove all shape layers of the mask document, then press save -> crash :)
  6. Are you going to extend this feature to more popular color selectors like Advanced Color Selector?

Hm, that is strange -- how do you create the patch? Do you make a commit with git that you export with git format-patch?

I have, quite naively, created the diff like this "git diff master my-branch > file.diff". On my next update I will try either binary patch from format-patch, or uploading with arcanist.

  1. In general, the patch works very nicely and I like the idea of it.

Thanks.

  1. [UIX] I would really prefer to have some button to start editing of an empty circular mask. Just to avoid the cases like I faced before. It is also much more intiutuve for a user to press "Create now gamut mask" button, then to edit something :)

Yes, you are right, I will work on it. There are some other usability issues, which are partly connected to this (mainly that the editing is really fragile right now, if the user doesn't create the shape with solid, but transparent, background, she will end up with a mask not showing in the selector).

  1. [UIX] I'm not sure about the correct place for a button "Apply gamut mask to a selector". I would expect this button to be in the selector itself, not in the editor. Are you going to extend these gamut masks to other color selectors? If so, such placement would create troubles.

The plan is to extend it to other selectors. I was in contact with Ahmed Hussein, who wanted to reuse my code for bug 373922. I don't know about his progress so far.

Maybe we could have a toolbar for mask selection, that could be reused in the selectors. Or something, that would replace the masks docker altogether (like the current toolbar in the selector, but with a button that would show a popup with what now is in the masks docker; or something totally different). I would have to think about that some more. If you have any ideas, please share :)

  1. It general the patch looks very solid. I tried to make some nasty things, like closing/switching/saving the "edit gamut mask document" during editing. The docker handled this case correctly, without any troubles :) Although it might be a good idea to hide editing mode controls when the user switches out of the gamut mask document. Right now it looks a bit non-obvious :)

I will implement the hiding. Also, if you see anything subpar in the code, please, let me know. I'm rather a beginner coder, there are still things I do not understand well and I'm not always able to think through all the consequences :)

  1. [crash] Start editing the mask, then remove all shape layers of the mask document, then press save -> crash :)

Thanks, I will fix that.

  1. Are you going to extend this feature to more popular color selectors like Advanced Color Selector?

That's the plan (though, I did not plan to do it myself :). Please, see pt. 3).

amedonosova edited the summary of this revision. (Show Details)Jul 2 2018, 7:09 AM
dkazakov accepted this revision.Jul 2 2018, 3:07 PM

Hi, @amedonosova!

Thank you for very extensive replies to my questions! I have just looked through the patch code and it looks perfectly fine! :) I will push it into a separate branch, so you could continue working further without the need to put it for review again :)

libs/flake/resources/KoGamutMask.cpp
158

Please use KIS_ASSERT or KIS_SAFE_ASSERT_RECOVER or KIS_SAFE_ASSERT_RECOVER_RETURN here.

Q_ASSERTS's are disabled on 99% of the systems, so we prefer not to use them.

plugins/dockers/artisticcolorselector/artisticcolorselector_dock.cpp
275

Just a personal recommendation: always initialize variables, even when they are going to be changed soon. It makes the code a bit more error-proof against future generations of developers :)

plugins/dockers/artisticcolorselector/artisticcolorselector_dock.h
31

Avoid commented out code :)

plugins/dockers/artisticcolorselector/kis_color_selector.cpp
564

Is it okay that it is commented-out?

This revision is now accepted and ready to land.Jul 2 2018, 3:07 PM
This revision was automatically updated to reflect the committed changes.

Hi, @amedonosova!

I have pushed your patch into a separate branch amedonosova/gamut-masking. Please base your next patches on the top of it :)

https://commits.kde.org/krita/dbe05327705fde0b0d6b56451322e4deddc6fc24