Add Stroke Selection Edge function
ClosedPublic

Authored by akapustin on Jul 27 2016, 1:59 PM.

Details

Test Plan

Bug: https://bugs.kde.org/show_bug.cgi?id=306182
Plan of work: https://phabricator.kde.org/T3281
At now work:

  • Gui-prototype
  • Line stroke
  • Choose size of line selection
  • Choose color of line selection and brush selection
  • Brush selection

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.
akapustin updated this revision to Diff 5527.Jul 27 2016, 1:59 PM
akapustin retitled this revision from to Add Stroke Selection Edge function.
akapustin updated this object.
akapustin edited the test plan for this revision. (Show Details)
akapustin set the repository for this revision to R37 Krita.
akapustin updated this revision to Diff 5530.Jul 27 2016, 9:41 PM

Rework color selection for lines

akapustin updated this revision to Diff 5532.Jul 27 2016, 11:21 PM
akapustin edited the test plan for this revision. (Show Details)
akapustin added a reviewer: dkazakov.

Rework color selection for brushes.
Fix bug with Krita's crash.

dkazakov edited edge metadata.Jul 28 2016, 9:10 AM

Hi, Alexey!

The patch is very nice, and it kind of works! :)

There are four small troubles right now:

  1. It is better to pass the color to the helper-resources_snapshot directly instead of editing the global resource temporarily.
  2. From the user point of view, I would expect the initial color of the color selector to be equal to the current global Krita color.
  3. It would be nice if the GUI elements would save their state into config. Though it can be postponed for later.
  4. [BIGGEST ONE] Right now the stroke you do with the brush is cut off by the selection, because it is taken into account :) The solution for this would be to add setSelectionOverride(KisSelectionSP selection) methods for both, KisFigureToolHelper and KisResourcesSnapshot.
libs/ui/actions/kis_selection_action_factories.cpp
594

I would prefer passing a color to the helper and then to its internal KisResourcesSnapshot member object. Modifying global resources may cause really weird troubles with multithreading sometimes :(

akapustin updated this revision to Diff 5563.Jul 29 2016, 8:47 PM
akapustin edited edge metadata.
akapustin removed R37 Krita as the repository for this revision.

Remarks fixed

dkazakov requested changes to this revision.Jul 31 2016, 7:14 AM
dkazakov edited edge metadata.
dkazakov added a subscriber: scottpetrovic.

Hi, Alexey!

The stroking with the current brush works now. But I would really suggest talking to @scottpetrovic about the GUI :)

As I wrote before I would expect the default fill color to be equal to the current foreground color. And the selection of the coloring option should be not a set of checkboxes, but either a radiobutton or a combobox.

It might be a good idea to add the following options:

  1. Foreground Color
  2. Background Color
  3. Custom Color

If you do it this way, then the color of the "Custom Color" option can be saved into the config file. You can even make the GUI perfect if you let the user always click on the color button in any moment of time and the option will be switched automatically accordingly.

This revision now requires changes to proceed.Jul 31 2016, 7:14 AM
akapustin updated this revision to Diff 5613.Aug 1 2016, 7:23 PM
akapustin edited edge metadata.
akapustin set the repository for this revision to R37 Krita.

Rework gui

dkazakov requested changes to this revision.Aug 5 2016, 8:56 AM
dkazakov edited edge metadata.

Hi, Alexey!

The patch works fine now, except it creates shape layers, when the user selects "Use line selection". It should paint on the raster layer instead. You can use KisPainter::drawPainterPath for that.

And there is a couple of small issues in the code. Speaking truly I would not create two separate actions, for vectors and raster painting. I would just create a single action and choose the painting method depending on the type of the layer selected. That is, if a paint layer is selected, paint with raster lines. If a vector layer is selected, just add a vector shape.

And we should still talk to @scottpetrovic about the design of the GUI :)

libs/ui/actions/kis_selection_action_factories.cpp
543

It would be better to split the params into a small struct, to break the dependency of the operation from a GUI object.
E.g. create a struct:

struct StrokeSelectionParams {
    KoColor color;
    int width;
    bool useBrush;
    ....
};

Then you can just add a method to KisDlgStrokeSelection that returns this params object. With this split three problems will be solved:

  1. There is no dependency from the GUI class in the operation
  2. You can call the operation directly without creating fake GUI opjects
  3. In the future we will be able to add runFromXML() method seamlessly.
libs/ui/actions/kis_selection_action_factories.h
128

The IDs of the actions should be unique :) We still don't have a registry for them, but can do in the future.

This revision now requires changes to proceed.Aug 5 2016, 8:56 AM
scottpetrovic added a comment.EditedAug 5 2016, 1:46 PM

I am not sure how many of these features are going to be implemented, but this is the direction I would go for the UI. I think showing everything at the same time might be too much for most people, so I think putting all of that styling information in another tab might be a good idea.

For the colors, I would default the color picked to the foreground or background color, but not have people actually pick "foreground color" from a drop-down

akapustin updated this revision to Diff 6045.Aug 18 2016, 8:12 PM
akapustin edited edge metadata.

Rework design and added shape selection.
It dont work with vector layers.

Hi, @akapustin!

I have tested the patch. It basically works, but I have two comments for which I would like to get a @scottpetrovic feedback:

  1. The user has no way to select the currently active foreground color as the stroke color. Once you changed it, the saved custom color will be always selected. It might be a good idea to have a combo box like the one near the fill color selector. @scottpetrovic, your GUI draft doesn't have such selector, can it be added somehow? Or, probably, we need some different UIX?
  1. The filling works strange, more precisely, the filling is painted on the top of the stroke, covering some parts of it. I would expect it be painted behind the stroke. Though I would like to hear @scottpetrovic input about it.

How it works:

How I would expect it to work:

Scott, what do you think about it?

akapustin updated this revision to Diff 6091.Aug 20 2016, 2:37 PM
akapustin edited edge metadata.

Remake last patch via git format-patch

akapustin updated this revision to Diff 6093.Aug 20 2016, 5:43 PM

Fix problems with cmakefiles

akapustin updated this revision to Diff 6197.Aug 23 2016, 12:30 PM

Added combobox-menu for choosing color of line.

dkazakov requested changes to this revision.Aug 24 2016, 4:59 AM
dkazakov edited edge metadata.

Hi, @akapustin!

The patch works fine now. Except of the one thing. You use QColor everywhere, which causes your strokes be not color-managed. It can cause very difficult to find problems when the user works with linear gamma (*-g10) or HDR color spaces.

Please change all the interfaces (except the main GUI ones, like KColorButton) to work with KoColor instead of QColor. And when converting the color from KColorButton's QColor, please use KisCanvas2::displayColorConverter()::approximateFromRenderedQColor() to do the color conversion right.

Yes, I agree that the interface of KoColor might be a bit misleading providing a call for the direct conversion, but that is what we have here.

KisDisplayColorConverter also takes into account the HDR settings of the canvas, like exposure and other conversions done by OCIO engine, which is not available in pigment. Therefore we should use such long way for a workaround.

So, basically, you need to do the following:

  1. Get a QColor from KColorButton
  2. Convert (approximate) it into KoColor using KisDisplayColorConverter
  3. Use the resulting KoColor everywhere you need.

The only exception is a QPen which you pass to the painter. Here we cannot do anything, just convert the KoColor into QColor right before the constructor call using KoColor::toQColor(). In all higher level interfaces we should use KoColor.

libs/ui/actions/kis_selection_action_factories.cpp
587

This conversion between KoColor<->QColor is really wrong.

See the main comment

libs/ui/tool/strokes/freehand_stroke.cpp
134

Why did you add a special method for this? You can just use the existing "Background" color. In a usual "painter" pattern, foreground and background colors mean just the colors of the stroke and the filling, they need not correspond to the real selected colors in the GUI.

I guess, setCustomColor() could be deleted.

This revision now requires changes to proceed.Aug 24 2016, 4:59 AM
akapustin updated this revision to Diff 6213.Aug 24 2016, 12:16 PM
akapustin edited edge metadata.

I deleted setCustomColor().
There was problems with KisCanvas2::displayColorConverter()::approximateFromRenderedQColor() . It gives approximate result.
It is bad for comparing color, which obtained from KColorButton. There was troubles with GUI :(
Where is possible, I replaced QColor to KoColor.

akapustin updated this revision to Diff 6219.Aug 24 2016, 1:34 PM
akapustin edited edge metadata.

Codestyle fixes

scottpetrovic added a comment.EditedAug 25 2016, 3:37 PM

Dmitry helped me get the patch to apply. I wasn't doing right...now for the feedback about the UI. It looks pretty good for the most part.

If the current brush is selected, it doesn't look like you can change the brush size. You can probably just hide the labels and the input box since they aren't needed.

The whole thing is in a structure grouping. I think you can remove that since there are no other groups. It simplifies it a bit too.

This revision was automatically updated to reflect the committed changes.