Implement rotation for masks.
ClosedPublic

Authored by anikethgirish on Feb 22 2017, 1:44 PM.

Details

Summary

When we do Rotate, Layer only gets rotated. But we need to select the node itself rather than Layer alone.

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.
anikethgirish created this revision.Feb 22 2017, 1:44 PM
anikethgirish edited the summary of this revision. (Show Details)Feb 22 2017, 7:31 PM
anikethgirish edited the test plan for this revision. (Show Details)
scottpetrovic edited edge metadata.Feb 23 2017, 3:56 AM

Better...

I did have to update the version number in the krita.xmlgui for it to go into my install directory. That might need to be changed (103 to 104).

After compiling it, the "rotate mask" option is disabled if I select a Transparency mask and go to Layer > Transform > Rotate > Rotate Mask option. So I can't use it. Try to figure out why the menu option is getting disabled. The menu option should only be available if the layer is a mask. A smarter way might be that "Rotate Mask" should just be part of "Rotate Layer". If the layer is a mask, rotate the mask. If the layer is a normal layer, do what it does now. That way we won't need more menu items.

So there are three things to be done now right.

  1. Change the kpartgui version to 104.
  2. Make rotate mask effect even if the mask is transparent. ( But I am not getting what could be the use of this. Becuase rotating a mask could only be benefited if that mask is visible. So if it visible this should work should be the option. I guess the same happens with layers also. It would restrict the rotation of layer if it's transparent. I see that if the transparency is on, then we can't rotate layer also. Please enlighten me if this is really relevant.)
  3. That is a good idea to implement it. But as far as someone like me who is a begineer to krita, and don't get how to rotate a mask would be benifited with this approach. At first, the user might not get it, how this rotating of mask could be done according to your approach. But it is an overkill on the amount of menu items, that's true. I assume we could implement something like, if the layer is not a mask then we could restrict Rotate Layer not to function, it cannot be not selected, else then it could be selected. According to what happens now is that, rotation of mask is possible even if it's not a mask.

So will start of fixing out here. So please do tell me, that what should be done in the other following things you mentioned.

I cannot get a mask to rotate. Can you explain what steps you are doing in krita to make a mask rotate. When I try, the closest thing I can get to makes the entire paint layer + mask rotate

dkazakov edited edge metadata.Feb 27 2017, 8:03 AM

Hi, @scottpetrovic, @anikethgirish!

I'm wondering, why we need a special action for rotating the masks? I have a feeling that having a single action that rotates a node and all its children would be more intuitive and useful from the user point of view. It would demand only one keyboard shortcut, we drastically lack of the non-assigned keys already :)

I would propose the following scheme:

  1. Rotate action rotates the node and all its siblings including the masks
  2. If you want to rotate the mask, just select the mask and rotate it.
  3. If you want to rotate the layer only (without the masks attached), just lock the mask and rotate the layer (locking can be easily be implemented on a level of KisProcessingApplicator)

This would solve quite a lot of usecases for people

anikethgirish edited the summary of this revision. (Show Details)
anikethgirish edited the test plan for this revision. (Show Details)
dkazakov requested changes to this revision.Mar 16 2017, 5:36 PM
  1. This patch ignores all the barrier things present in the original KisLayerManager::rotateLayer(). That should be cared about.
  2. The original method in the layer manager now not used anywhere and can be removed
This revision now requires changes to proceed.Mar 16 2017, 5:36 PM
rempt requested changes to this revision.EditedMar 16 2017, 6:25 PM

Some more things in addition to what Dmitry has added::

  • you should test the code before posting a diff -- and I'm pretty sure you didn't because the rotate actions in the layer menu are still disabled if the current node is a mask
  • you left dead code in KisLayerManager -- or did you check that KisLayerManager::rotateLayer is called from other places? And if it is, is that actually correct?
  • you didn't fix KisImage::rotateNode's undo text to be dependent on whether the node is a layer or mask.
  • apart from the barrier things, what's going to happen if there isn't an activeNode?
  • and keep to the coding guidelines. Variables don't start with a capital letter.
anikethgirish edited edge metadata.

This update of diff has removed the rotateLayer function which was no longer been used for. Some conditions were set, they are actually implemented here.

anikethgirish added a comment.EditedMar 17 2017, 2:25 PM

@dkazakov, @rempt Hey,

Thanks for helping me out first of all.

So as @dkazakov told me the changes, I have done that. I actually forgot to remove the functions which were no longer used. '

@rempt, I have not that much idea about kundo2_i18n() that how it works and especially how it could be implemented to do the work you mentioned. Actually, I didn't understand what you told. Are you mentioning that I should put a condition that if the node is Layer it's undo message should come as RotateLayer else RotateMask? Correct me if am wrong.

Let me clarify my testing procedure also here,

I create a new file (CTRL+N). Draw something up. Try to rotate(layer/transform/rotate*). Next, create a Mask over it. I create a transformation Mask. Then select the whole Layer+Mask like a group and do the rotate again.

Now it seems to work for me.

You should also be able to rotate the mask when it's not selected together with the layer. For that, you need to change the activation flags for the KisAction.

The undo stuff -- the text needs to change depending on whether the user rotated a layer or a mask. So, if the node inherits KisMask, it's a mask, if it inherits KisLayer, it's a layer.

rempt accepted this revision.Mar 23 2017, 10:27 AM

Okay, this looks good to land.

This comment was removed by anikethgirish.
This revision was automatically updated to reflect the committed changes.