Jumping to transform after pasting

Authored by langkamp on Sep 24 2018, 10:01 PM.


Group Reviewers

Following the discussion in T9722, I have implemented the basic functionality to jump inte the transform tool from pasting a layer. After insert a paint layer, it deselects if there is a selection and jumps into the tranform tool starting a new Transform.

The code is not finished, but rather a starting point for the discussion about the behavior. I had some trouble to activate the tranform tool with an active stroke, so had to make a slight hack with the delayed activation. Any idea if there is a way to solve that better?

No idea if this is the best way to approach this. It has been a while since I did hack on Krita ;)

Diff Detail

Lint Skipped
Unit Tests Skipped
langkamp created this revision.Sep 24 2018, 10:01 PM
Restricted Application added a reviewer: Krita. · View Herald TranscriptSep 24 2018, 10:01 PM
Restricted Application added a project: Krita. · View Herald Transcript

I'll try to check the patch a bit later today :)

Hi, @langkamp!

The patch kind of works. I cannot say I really like the UIX of the thing, but if the behavior is optional (even if it is on by default), it can be acceptable.

To avoid the hacking the layers, you can just add a command that emits a signal to the input manager that switches the tool. Signal/slot framework will do all threads syncing work for you.

There is also an open question: should we switch back into the original tool after the transform tool action is finished? If yes, it might be a bit complicated.

langkamp updated this revision to Diff 42566.Sep 29 2018, 7:34 PM

Updated the diff to use the commands. However that work less good than the previous patch, as it doesn't always have the signals in the right order. Dmitry was this what you meant?

Hi, @langkamp!

It looks like this patch fixes the problem, could you check?

Basically, it makes the command a barrier, that is all the updates are finished before the start of the command. And it makes the transform tool not skip starting because of empty layer :)

1diff --git a/libs/ui/KisViewManager.cpp b/libs/ui/KisViewManager.cpp
2index a3f325f..6d6bc61 100644
3--- a/libs/ui/KisViewManager.cpp
4+++ b/libs/ui/KisViewManager.cpp
5@@ -1400,7 +1400,7 @@ void KisViewManager::slotActivateTransformTool()
6 // Start a new stroke
7 tool->deactivate();
8 tool->activate(KoToolBase::DefaultActivation, dummy);
9+ } else {
10+ KoToolManager::instance()->switchToolRequested("KisToolTransform");
11 }
13- KoToolManager::instance()->switchToolRequested("KisToolTransform");
14 }
15diff --git a/libs/ui/actions/KisPasteActionFactory.cpp b/libs/ui/actions/KisPasteActionFactory.cpp
16index c72b54f..55a3f27 100644
17--- a/libs/ui/actions/KisPasteActionFactory.cpp
18+++ b/libs/ui/actions/KisPasteActionFactory.cpp
19@@ -248,7 +248,7 @@ void KisPasteActionFactory::run(bool pasteAtCursorPosition, KisViewManager *view
20 ap->applyCommand(deselectCmd, KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::NORMAL);
22 KUndo2Command *transformToolCmd = new KisTransformToolActivationCommand(view);
23- ap->applyCommand(transformToolCmd, KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::NORMAL);
24+ ap->applyCommand(transformToolCmd, KisStrokeJobData::BARRIER, KisStrokeJobData::NORMAL);
26 endAction(ap, KisOperationConfiguration(id()).toXML());
27 } else {

langkamp updated this revision to Diff 42777.Oct 3 2018, 11:28 AM

Added config option and added barrier to prevent signals from getting in the wrong order.

dkazakov added inline comments.Oct 3 2018, 12:30 PM

This function seem to be unused

langkamp updated this revision to Diff 42789.Oct 3 2018, 1:09 PM

Removed unused code.

rempt accepted this revision.Oct 3 2018, 2:12 PM
This revision is now accepted and ready to land.Oct 3 2018, 2:12 PM
langkamp closed this revision.Oct 3 2018, 4:14 PM