Bug 407160

Summary: Unexpected hiding and offsetting behaviour of active selection after performing a move action on layer with move tool
Product: [Applications] krita Reporter: vanyossi <ghevan>
Component: UsabilityAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: normal CC: dimula73, halla, raghu
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Compiled Sources   
OS: macOS   
Latest Commit: Version Fixed In:

Description vanyossi 2019-05-02 16:38:52 UTC
This bug might be intended behaviour, but it is weird so I make report.

First described in https://bugs.kde.org/show_bug.cgi?id=387557

Original words
"
What issue I see with selecting then Copy+Paste and Move Tool:
- select some small rectangle on Layer1
- Copy
- Paste (what creates new Layer2)
- Move Tool (move this small pasted part somewhere out copied part)
- Paste AGAIN - this!
- Move Tool - you can't!
"

Detailed instructions
- create new document and draw a small circle in a layer with only alpha info.
- Select rectangular so only the circle is in the area
- Copy & Paste
    this pastes new circle in the same spot, the selection is still active
- Move new circle to spot outside of the original selection rectangle
- Paste again (paste will occur on the original area, but selection is still previous move coordinates [expected])
- Move <- this will move the selection again, but no content, and will make the selection dissapear (but its still active)

OBSERVED RESULT
Nothing will appear to move because the selection is still active but there is nothing in it

THE PROBLEM: after moving the second time, selection can end up outside the canvas which can lead to confusion and histeria. As nothing will appeat to work.

EXPECTED RESULT
If selection is still active:
1. Paste content inside the selection. (New coordinates).
Or
2. don't paste anything

On another question:
Should we destroy the selection if it goes outside the canvas?
Comment 1 Raghavendra kamath 2019-05-04 06:05:07 UTC
I can confirm this in master. In addition to the above data, i would like to add that selection that appears after moving has an offset to it. And after the second move you can get the selection to appear again if you re- activate any one of the selection tools.

The problem here seems like
- Using move tool offsets the selection a bit
- After the move action with the move tool, selection hides itself until you activate another tool. 

My opinion on the questions and suggestion in comment1

-  Paste content inside the selection. (New coordinates).
No , since I had copied the object when it was in the previous location I would expect the copy to pasted in it's original location.

- don't paste anything
This is also a No. Since one would not expect paste to not work.

- Should we destroy the selection if it goes outside the canvas?
This is also a No, since it is inconsistent with the behaviour that we have selection outside of the canvas, and in previous discussion on IRC (if i remember correctly) we had agreed to allow selection outside the canvas.


Possible solutions from my opinion

- Don't hide selection after move action is completed, and also don't offset the selection after move(i think this is different problem along with hiding).
If the selection is not hidden then it doesn't matter if it goes beyond canvas boundary, user will see it.
Comment 2 Raghavendra kamath 2019-05-04 06:10:04 UTC
To add more, the bug is just that selection gets hidden and has offset after move action on the layer. regardless of paste or copy. Paste is working correctly and it is not related. 

To reproduce, 

- draw something on a new layer
- draw a selection
- move the layer with move tool

The selection will be hidden until you select the selection tool again and also will have offset.
Comment 3 Halla Rempt 2019-05-04 08:39:40 UTC
Krita has behaved like this at least since Krita 3.0, so it might be safe to say it has behaved like this always.
Comment 4 Dmitry Kazakov 2020-06-03 12:58:19 UTC
I can add the following:

That surely should be fixed:
1) MoveSelectionStrokeStrategy should reject starting a stroke when there is no content inside the selection.
2) It should also notify the user that the selection is empty

Possible solution to the original bug:

I guess it would be logical to say that, when copy/pasting a "selection", the selection outline should also be pasted? I mean, if we paste some object into Krita, then the object should become selected right after the paste. Does it look sane?
Comment 5 Raghavendra kamath 2020-06-04 05:42:13 UTC
No need for pasting selection outline. Rather than pasting we just need to show selection even when moving or after moving. Currently the problem arises when we stop showing the selection and user is not aware where the selection is.

So to summarise.-
- keep show selection outline after the move is completed, do not hide it.
Comment 6 Dmitry Kazakov 2020-06-04 10:01:50 UTC
Git commit c30616ba926f26852f083289ad647215923dc39e by Dmitry Kazakov.
Committed on 04/06/2020 at 10:01.
Pushed by dkazakov into branch 'master'.

Don't start move-selection stroke if selection is empty

If selected are is empty, we shouldn't start any stroke, because
it'll be hightly confusing for the user.

We should also show a warning to the user, but we cannot add strings
to krita/4.3

M  +3    -0    plugins/tools/basictools/kis_tool_move.cc
M  +6    -1    plugins/tools/basictools/strokes/move_selection_stroke_strategy.cpp
M  +1    -0    plugins/tools/basictools/strokes/move_selection_stroke_strategy.h

https://invent.kde.org/graphics/krita/commit/c30616ba926f26852f083289ad647215923dc39e
Comment 7 Dmitry Kazakov 2020-06-04 10:01:51 UTC
Git commit 89c9b8c85b033df457ab777d034188c02d30d6c7 by Dmitry Kazakov.
Committed on 04/06/2020 at 10:01.
Pushed by dkazakov into branch 'master'.

Add notification that move-selection stroke ended unexpectedly

M  +12   -0    plugins/tools/basictools/kis_tool_move.cc

https://invent.kde.org/graphics/krita/commit/89c9b8c85b033df457ab777d034188c02d30d6c7
Comment 8 Dmitry Kazakov 2020-06-04 10:02:20 UTC
Git commit bd3ccff1e364cb175578ea8c7892f5b2ac436403 by Dmitry Kazakov.
Committed on 04/06/2020 at 10:02.
Pushed by dkazakov into branch 'krita/4.3'.

Don't start move-selection stroke if selection is empty

If selected are is empty, we shouldn't start any stroke, because
it'll be hightly confusing for the user.

We should also show a warning to the user, but we cannot add strings
to krita/4.3

M  +3    -0    plugins/tools/basictools/kis_tool_move.cc
M  +6    -1    plugins/tools/basictools/strokes/move_selection_stroke_strategy.cpp
M  +1    -0    plugins/tools/basictools/strokes/move_selection_stroke_strategy.h

https://invent.kde.org/graphics/krita/commit/bd3ccff1e364cb175578ea8c7892f5b2ac436403
Comment 9 Dmitry Kazakov 2020-06-04 10:21:52 UTC
Hi, Raghavendra!

Could you please test this package and tell if it work okay now?
https://yadi.sk/d/wdJtIT1EROsgxA
Comment 10 Dmitry Kazakov 2020-06-04 15:55:08 UTC
Updates packages with selection outline visible inside the move action:

Windows: https://yadi.sk/d/ZBmsj1iRzvtGSA
Linux: https://yadi.sk/d/8F7Uuh-7L3CSJA
Comment 11 Raghavendra kamath 2020-06-05 08:25:34 UTC
Hi Dmitry, the appimage shared in your #comment10 is working perfectly, Only suggestion would be to retain the warning stating that the selection area is empty from the previous appimage you shared
Comment 12 Dmitry Kazakov 2020-06-05 20:30:36 UTC
Git commit 79ff7fac767cffbf294841c47b539388b1c255f2 by Dmitry Kazakov.
Committed on 05/06/2020 at 20:28.
Pushed by dkazakov into branch 'krita/4.3'.

Add notification that move-selection stroke ended unexpectedly

M  +12   -0    plugins/tools/basictools/kis_tool_move.cc

https://invent.kde.org/graphics/krita/commit/79ff7fac767cffbf294841c47b539388b1c255f2
Comment 13 Dmitry Kazakov 2020-06-05 20:30:36 UTC
Git commit ca6dcad2643f672bf803cbe699cf08008c4e14f8 by Dmitry Kazakov.
Committed on 05/06/2020 at 19:49.
Pushed by dkazakov into branch 'krita/4.3'.

Show selection outline when moving with move-selection-stroke

That might be a bit more logical for people not expecting move selection
to trigger when they try to move after paste.

M  +15   -2    plugins/tools/basictools/kis_tool_move.cc
M  +20   -7    plugins/tools/basictools/strokes/move_selection_stroke_strategy.cpp
M  +12   -0    plugins/tools/basictools/strokes/move_selection_stroke_strategy.h

https://invent.kde.org/graphics/krita/commit/ca6dcad2643f672bf803cbe699cf08008c4e14f8
Comment 14 Dmitry Kazakov 2020-06-05 20:31:08 UTC
Git commit 9efd1d1379ec89bfcb9049d39df676b5fa061be1 by Dmitry Kazakov.
Committed on 05/06/2020 at 20:30.
Pushed by dkazakov into branch 'master'.

Show selection outline when moving with move-selection-stroke

That might be a bit more logical for people not expecting move selection
to trigger when they try to move after paste.

M  +15   -2    plugins/tools/basictools/kis_tool_move.cc
M  +20   -7    plugins/tools/basictools/strokes/move_selection_stroke_strategy.cpp
M  +12   -0    plugins/tools/basictools/strokes/move_selection_stroke_strategy.h

https://invent.kde.org/graphics/krita/commit/9efd1d1379ec89bfcb9049d39df676b5fa061be1
Comment 15 Dmitry Kazakov 2020-06-05 21:29:35 UTC
The bug is fixed now.