Color Slider Docker
Needs RevisionPublic

Authored by tusooaw on Mar 29 2019, 12:10 AM.

Details

Reviewers
rbreu
dkazakov
Group Reviewers
Krita
Summary
Test Plan
  1. Build Krita with the patch.
  2. Start Krita. In Settings -> Configure Krita -> Python Plugin Manager, enable Mixer Slider Docker. Restart Krita.
  3. Right-click on menu bar, and enable Mixer Slider Docker.

    Expected: The docker appears in the window. You may need to adjust its size and/or position. A button with S should appear on the left. On the right there is a slider from blue to black between blue and black colored squares. (Test default color is correctly displayed)
  4. Create a new document.
  5. Click the S button on the left of the docker.

    Expected: A dialog with a label and a line edit appears.
  6. In the line edit, replace the number with 0. Click OK button.

    Expected: The docker has only the S button in the center. (Test the docker can correctly remove lines)
  7. Click the S button. In the dialog, replace 0 with 4. Click OK.

    Expected: 4 lines of color gradient from blue to black appear. (Test the docker can correctly add lines)
  8. Click some point on one slider.

    Expected: The foreground color should be set to the color at that point. A white triangle appears at the cursor point.
  9. Choose some foreground color from another color selector (pop-up palette, advanced color selector, etc.).
  10. Click the square on the left of one slider.

    Expected: The color of the square becomes the current foreground color. The white triangle appears at the left-most of the slider.
  11. Chose some other foreground color from another color selector. Click the square on the right of that slider.

    Expected: Similar to the above, but the white triangle appears at the right-most. The slider has a gradient between the two colors.
  12. Press the mouse inside that slider, and move the mouse to the right-most.

    Expected: If you have advanced color selector, the color shown on it should not change. (The right-most color should be the one on the right button.) This step is to check that there is no error converting between ManagedColor and QColor.
  13. Set the left color to a color with a hue (blue, green, yellow, etc.) and the right one to a graytone (with Hue=-1).

    Expected: The gradient should not have a change in hue.
  14. Set the left color to red and the right color to blue-ish cyan. (So that the two hues on the advanced-color-selector HSV ring goes through the arc at the bottom (magenta and blue), which is a minor arc (<180 degrees).)

    Expected: Magenta and blue appear on the slider. No yellow or green.
  15. Swap the left and right colors. (set the left color to blue-ish cyan and the right to red, don't need to be exactly the same, just ensure the minor arc between them goes through magenta and blue)

    Expected: Same (direction should flip, though).
  16. Set the left color to red and the right color to green-ish cyan.

    Expected: Yellow and green appear on the slider. No magenta or blue.
  17. Swap the left and right colors.

    Expected: Same.
  18. Restart Krita.

    Expected: The docker appears the same as the one before restarting, except there is no triangle cursors. (Test that all settings are saved.)

Diff Detail

Repository
R37 Krita
Lint
Lint Skipped
Unit
Unit Tests Skipped
tusooaw requested review of this revision.Mar 29 2019, 12:10 AM
tusooaw created this revision.
tusooaw edited the test plan for this revision. (Show Details)
woltherav added a subscriber: woltherav.

Hm, I have yet got to test it, but maybe it should be renamed to 'mixer slider'? Color slider docker was the name of the HSV color sliders which have been removed but should make a comeback at some point.

Also adding rebecca as she's got the most python experience.

tusooaw updated this revision to Diff 55036.Mar 29 2019, 4:10 PM
tusooaw edited the test plan for this revision. (Show Details)

Rename the docker as suggested by Wolthera.
Fixed a bug where the docker could not display the left and right colors correctly if there is no config available.

tusooaw edited the test plan for this revision. (Show Details)Mar 29 2019, 4:13 PM
tusooaw set the repository for this revision to R37 Krita.
rbreu added a comment.Mar 30 2019, 9:59 PM

I just tested this and it works. I can see the use of this. What do other people think of this feature? I like how little space the docker takes. Would be neat if the "S" button had a tooltip.

Code-wise it looks good to me, except for a couple of nitpicky remarks. Btw, I'm currently working on getting all existing Python modules PEP8 compliant. I'm not expecting new submits to follow this as long as it's still a work in progress (some python plugins are already done, some aren't), but if you are interested, here's how to set up code checks: https://phabricator.kde.org/D18404

plugins/python/mixer_slider_docker/color_slider.py
75

Debug prints should be removed, I guess. Otherwise the command line gets very wordy.

plugins/python/mixer_slider_docker/mixer_slider_docker.py
112

I think this were easier to read if you build a list of all the strings first and then use join once, instead of this concatenation of two joins. Took me a bit to understand where all the commas end up.

tusooaw updated this revision to Diff 55095.EditedMar 30 2019, 11:02 PM

Simplified logic in color_to_settings()
pep8 naming
Suppressed debug output
Reduced unnecessary imports
Added tooltip for settings button

tusooaw added a comment.EditedMar 30 2019, 11:14 PM

I just tested this and it works. I can see the use of this. What do other people think of this feature? I like how little space the docker takes. Would be neat if the "S" button had a tooltip.

Code-wise it looks good to me, except for a couple of nitpicky remarks. Btw, I'm currently working on getting all existing Python modules PEP8 compliant. I'm not expecting new submits to follow this as long as it's still a work in progress (some python plugins are already done, some aren't), but if you are interested, here's how to set up code checks: https://phabricator.kde.org/D18404

Thank you for reviewing this.

I asked on IRC. One commented it is useful; another remarked that it is just another Digital Colors Mixer. However, this docker is more convenient and intuitive than Digital Colors Mixer. In addition, this feature is inspired by a similar one in PaintToolSai, so I guess former SAI users might be happy to see it. When I was using SAI, I did find it useful.

On PEP8: Lowercase with underscore naming cannot be applied to some functions, as they are overriding functions in C++, which use camel case naming. PyQt5 document does not seem to provide a way to make both lint and app happy. @pyqtSlot does make a different signature from the python one, but it seems it should be only used with slots. The from xxx import * in __init__.py seems to be a convention in Python plugins here, so I am currently sticking to that. Application and i18n are things that do not need an import so I do not think I can do anything with the warning that they are undefined.
Also, according to the HACKING file, 79 characters per line can be ignored to improve code readability. Except these, the code conforms to PEP8.

BTW: Krita does not seem to have i18nc function to provide a comment for translators, so I just used a comment on the previous line, which KDE community wiki says is okay. But I still want to make sure whether it really works.

tusooaw marked 2 inline comments as done.Mar 30 2019, 11:26 PM

Closing the two inline comments as the issues are fixed.

dkazakov accepted this revision.Jun 12 2019, 4:13 PM
dkazakov added a subscriber: dkazakov.

The patch works as expected :)

I have found only two minor issues:

  1. The settings dialog should use QSpinBox instead of QLineEdit
  2. [DISPUTABLE] The arrow looks as if it is offset to the top. Was it expected?

Please fix at least the first point and push the patch into master without any further review :)

plugins/python/mixer_slider_docker/ui_mixer_slider_docker.py
48

Please use QSpinBox instead of the a raw textbox. Spinbox also supports mouse wheel events processing :)

This revision is now accepted and ready to land.Jun 12 2019, 4:13 PM

The patch works as expected :)

I have found only two minor issues:

  1. The settings dialog should use QSpinBox instead of QLineEdit
  2. [DISPUTABLE] The arrow looks as if it is offset to the top. Was it expected?

Please fix at least the first point and push the patch into master without any further review :)

Thank you for the review. But I think it would be prudent not to push this commit for now. The plugin only works with RGBA color space, not others. To fix this, we will have to add to the Python API, namely ManagedColor.fromQColor() function.

And yes, (2) is expected.

dkazakov requested changes to this revision.Jun 13 2019, 7:34 AM

Okay. Actually, I don't think it should actually "support" non-rgb color spaces. It just show colors correctly when image color space is non-rgb. For that it must use KisDisplayColorConverter class, converts image colors into a correct QColor.

And, yes, there is a bug when working with RGBA F32 color spaces. R and B channels are swapped :(

This revision now requires changes to proceed.Jun 13 2019, 7:34 AM
rempt added a subscriber: rempt.Jun 13 2019, 7:40 AM

That's because floating point RGB colorspaces are RGB, while integer are BGR. As for KisDisplayConverter, we don't expose that to Python yet.

That's because floating point RGB colorspaces are RGB, while integer are BGR. As for KisDisplayConverter, we don't expose that to Python yet.

I mean it might not be necessary to expose KisDisplayConverter, just getting the inverse of colorForCanvas() is okay.