-
Notifications
You must be signed in to change notification settings - Fork 53
feat(ui): add cropping tool (#55) #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
The current behavior is that dragging anywhere on the image while the cropping tool is active starts dragging on the closest corner of the cropping area, or, when the user is holding I feel like that behaviour could be polished – feel free to suggest changes @jtheoof. Edit: Changed |
|
Changed the behavior slightly so that the initial rectangle is drawn as-if This felt more natural to me and is indicated by the cursor. |
|
I'm also thinking maybe the rectangle could actually be split into thirds, like so: and drag actions would be: |
|
Hi and thank you for your contribution! I like the way you implemented it! I guess implementing this feature will finally get swappy one of the preferred tool to use in combination with grim.
Personally I would prefer a smaller size of thirds, current are big enough for this task. Also I would like to suggest to start painting a new rectangle if the user start to draw it outside of the current one - this was expected behaviour for me, but I got resizing current. |
|
Thanks for the input, @itsTurnip!
Do you mean the current state is fine by you or are you proposing to make them even smaller? Currently, they are not thirds, they are actually quarters (as I, too, thought thirds were too big).
Sounds like a good idea. The current behaviour is that when you hold |
Yup, that was what I tried to say. Actually, I think it should be a fixed size (just for e.g., 15px). It's not really necessary for this zones to be adjustable after the size of the rectangle. Like for a window managers: a zone to start a windows resize usually have a fixed size. |
Makes sense, yeah, just as I was playing around with it some now, I also thought maybe I should make the zone fixed-size. One thing to consider is that windows generally have more controls inside of them, as opposed to this crop rectangle, so perhaps the case could be made for the zones to be bigger. But yeah, having the zone size be a fraction is probably not the best UX – not that I personally actually notice in day-to-day use, but it is something to think about. Anyway, in the meantime I changed the behaviour to be so that when dragging outside of the rectangle, you draw a whole new one. I agree that this is probably more intuitive, I like it. |
|
(I left the |
I tested it. Liked this too 👍 Another thing that I would suggest is to change border dragging. Here's how it works right now: recording.mp4You see this: when I try to change the size of the current rectangle it resizes to my cursor position. But I would like to start moving the current position of the border, not to start a new one. There's also a visual bug I found. When you start moving the border inside the rectangle the cursor changes it's appearance from cross-hair to the angle. It looks fun when you try to lower the width and higher the height: it starts to blink 😄 recording.1.mp4 |
|
Right, relative movement is probably better. Done it now. The cursor flicker is fixed now as well. Thanks for your inputs so far! |
|
Note: I've put TODOs about what I want to definitely have done before I consider this PR finished. It may not be exhaustive – feel free to suggest more fixes/improvements. |
|
Alright, I just pushed the change that makes it so that the rectangle does not change its size when it's being dragged against the edges. |
|
Actually, scratch that, there are two more things that probably need doing before this is final:
|
|
Thank you for this @Spiffyk I'm gonna try to review this soon |
|
Hey, awesome extension on the tool !! I think a way to specify that the tool always start in crop mode in the config file would be super helpful too. Really nice implementation there !! |
That's already supported, see |
|
Thank you for this @Spiffyk really nice effort was put here. I finally had time to look into it. After testing it, my first feedback is that perhaps we should consider a simplified approach. Not allowing the user to "edit" the crop as you did here, which looks a bit odd as the cursor seems to move away the more I edit the crop (see below) What I suggest instead is to apply the crop on mouse button release (and updating the paint buffer completely) but plugging it with the undo system, so it's easy to go back to previous state and do a new crop if we messed up. |
|
I've update the CI, it's been a while and github actions were not up to date. Can you please rebase when you get a chance? Some code did not pass the |
|
Hi, sorry about the delay, @jtheoof! I just rebased the branch, added a missing dependency declaration (build on NixOS would fail without it), and reformatted.
Right, that sounds like a very reasonable approach to me! I'll go ahead and look into adapting the behaviour. |
|
So I've reworked the tool quite a bit, merging it into the other paint types (as it should have been all along). This way, it integrates with the existing undo-redo mechanism. The editing logic is now gone. |
|
Right, I changed the keybind from |
|
I cleaned up a bit and squashed the history, removing the For now, it's two commits, with the state before and after the rework, but I plan on squashing it up into a single commit once we reach definite agreement on how it's supposed to work. |
Closes #55
Closes #155
TODO:
Better cursor position handling: make it regions around the crop rectangle's edges, not fractions of the sides. Also probably let the regions be slightly outside of the rectangle as wellMove the crop rectangle by dragging it by its middleDo not resize the rectangle while clampinghow did that happen?– ah, a very trivial typo, oops)