Add the "align object" tool#961
Conversation
|
Right now i'm blocking on two things:
edit: actually, it's probably best to have two checkboxes, "Align inside selection only" and "Object from selection only". |
|
Thanks for looking at this! I think having either the option to align within the bounding box of the selection, or aligning the selection contents within the image, could be useful. Ignoring the selection seems like the user could just do that beforehand by deselecting? With implementing this as an effect, I think you might run into challenges with modifying the whole image since the result of your effect will be masked by the selection afterwards (normally, effects are only applied to the selection's contents). So it might be easier to implement it more like the Auto Crop tool if you need a lot more flexibility, or we can figure out the right API for effects to indicate they need to modify the whole image. |
Indeed, i ran into that exact problem of selection masking the effect a few hours ago 😅 On another note, when trying to implement the selection-related options, the only way i could find to access the selection was with the "rois" parameter, which seems to just be an array of rectangle, so i'm not too sure how to deal with things like a circular selection. Or does that array of rectangle already represent a circle? |
|
Right now I don't think the document's actual selection is passed down through the effect's API (similarly, because the masking against the selection is done implicitly afterwards) |
|
That's not too much of an issue for the "align within the selection" option (since we just use the bounds anyways), but it is an issue for the "align selection within the image" option. Maybe i should only implement "align within the selection" for now, and leave "align selection within the image" for a later PR? |
|
Yeah, that sounds like a good approach to take 👍 |
|
Should be all good, adding support for selection was surprisingly easy |
|
went ahead with it for now, we can always revert the commit if you would rather have it somewhere else |
cameronwhite
left a comment
There was a problem hiding this comment.
This is looking great so far! I left a couple notes and suggestions in the comments.
- The new
Objectcategory sounds good to me, and theFeathereffect could also probably be shifted there - It would also be great to add a unit test for the effect. Similar to the note in #953, feel free to extend the
TestEffectAPI if you need to use a different input image.
| MarginBottom = 12 | ||
| }; | ||
|
|
||
| topLeft = CreateCheckButton ("Top Left", AlignPosition.TopLeft); |
There was a problem hiding this comment.
These strings labels would need to become e.g. Translations.GetString("Top Left") in order for translations to work
One other idea for the UI though would be to use the same alignment buttons as the Resize Canvas dialog - what do you think about that approach? It might be less cluttered if there are other options added in the future, e.g. aligning only horizontally or only vertically
There was a problem hiding this comment.
Indeed, that was the approach i originally wanted to take, but i didn't know if we had icons we could use for it.
I switched to that, although the center icon isn't that fitting, it should probably be something like a dot / circle.
There was a problem hiding this comment.
Looks good! I think the remaining fix is just to use Translations.GetString() for all the tooltips so they are translatable
There was a problem hiding this comment.
completely slipped my mind 😅
should be good now!
There was a problem hiding this comment.
I should have been more clear, sorry :)
Doing Translations.GetString (tooltip) isn't exactly right - the problem is that those tooltip strings won't be picked up automatically and added to the translation template (po/messages.pot) as strings that can be translated (https://github.com/PintaProject/Pinta/wiki/Translations)
So the approach is to explicitly do Translations.GetString("Top Left"), Translations.GetString("Top Center") so that those strings are automatically picked up for translations
There was a problem hiding this comment.
Makes sense, moved the GetString calls to use literals
|
Added tests and took the comments into account |
Thanks! Updating the feather effect category is fine to add into this PR since it's a trivial change |
cameronwhite
left a comment
There was a problem hiding this comment.
Looks good, thanks for your contribution!
|
Aligning object to selection (as bounding box) is still not implemented. 2026-03-23.13-42-55.mp4 |
I believe what you're looking for is already implemented. In your video, the object is outside the selection, so it is ignored. |
It should work even if the object is outside the selection too. |
This aims to add the feature discussed in #936 and #813
This is a pretty barebone implementation for now (especially UI-wise).
I'm still really new to C#, so i would appreciate any tips if i'm doing anything the wrong way ^^