Skip to content
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

Zoom for the editor (Feature-84) #201

Merged
merged 26 commits into from May 10, 2020

Conversation

KillyMXI
Copy link
Contributor

@KillyMXI KillyMXI commented Apr 26, 2020

Zoom implementation

image

Notes:

  • Shortcuts Ctrl+ +,- were used for another feature. Considering these shortcuts are wastly more common for the Zoom feature, I suggest to move the previously existing feature to Ctrl+ Shift + +,-

  • Shortcuts for Actual size (100%) and Best Fit (Ctrl+/ and Ctrl+*) are chosen for the proximity on the keyboard and because of possible collisions for other choices. Of the software I use, Ctrl+/ for actual size is also used in XnView MP.

  • "Zoom" menu instead of "View" menu - because there are no other View features so far, I think it's more accessible this way.

  • Zoom display on the bottom right shows the same menu on click. Menu lists all possible values for quick access. I think this UI solution makes a good balance between usability and code complexity.

Update:

Summary of behavior changes:

  • New Zoom submenu in the main menu;
  • Zoom value display in the status bar, opens the same Zoom submenu on click;
  • New shortcuts Ctrl++ and Ctrl+- for Zoon In and Out, Ctrl+0 for actual size, Ctrl+9 for Best Fit (find a zoom value where no scroll is needed to see the entire image);
  • Feature previously existing on the same shortcuts is now moved to Ctrl+Shift++ and Ctrl+Shift+- - add empty borders to image, trim borders;
  • Clipboard paste (text and images) is now aligned based on currently visible area of image;
  • Editor window, when opened, is sized to fit on screen;

@jklingen
Copy link
Member

Hey, thanks for the PR 👍 I'll do some testing.

I agree that we should re-assign Ctrl + + and -, the other feature is not widely known anyway.

Personally I'd prefer Ctrl + 0 for 100%, I think that's what most popular browsers do and should known for most users.

@KillyMXI
Copy link
Contributor Author

KillyMXI commented Apr 26, 2020

Yeah, I've got another response about Ctrl+0 already.
Personally, I would prefer to avoid using digits for zoom shortcuts.
When I was considering Ctrl+0, I figured I don't like it when icon says 1 inside a magnifier.
Changing the icon to = inside a magnifier (which is also available in Fugue set) will make it possible to confuse with =+ key on keyboard.
And then, there might be more natural uses for shortcuts with digits.

On the other hand, 0 ) is closer to other keys on main part of keyboard and might be more natural for users with short keyboards without numerical part...
One more opinion to convince me?

@jklingen
Copy link
Member

jklingen commented Apr 26, 2020

Thanks again, so I did some testing, the implementation works great in most situations - good job 🙇 I have just found some smaller issues, and a few points open for discussion (this includes the shortcuts already mentioned above). Adding these as tasks here (we could also consider to make separate tickets for these, in case any of them takes longer or needs a lot of discussion):

Issues:

  • Dual monitor setup: on secondary screen, zoom to best fit zooms to 0%; after moving window back to primary screen zoom to best fit always zooms to 100%

  • Zoom factor < 100% with text box on screen: selecting the textbox seems to redraw everything on top and left of it, making text look pixelated (also happens when dragging tail of a speechbubble) - probably not an issue with your implementation, but we should have a look at it.

  • Zoom 50% with speech bubble: tail can only be dragged on the upper left quadrant of the screenshot - with Zoom set to 75%, the draggable area is the the top / left 75% of the screenshot

Open for discussion:

  • Should the window be resized with the screenshot? I somehow expected it to remain at the same size, similar to a browser or Paint. Especially the window should not grow out of the visual area, because then the zoom controls in the bottom right are suddenly gone (yeah, there are still other ways, but it is confusing).

  • Likewise: should "zoom to best fit" zoom window to fit screen, or screenshot to fit window? Personally, I expected the latter.

  • Maybe add Ctrl + Mousewheel support, too?

  • Shortcut Actual Size - Change to Ctrl + 0? Note: on German keyboard, Ctrl + / and Ctrl + * only work on keypad (because otherwise both / and * require holding down Shift.

  • If above shortcut is changed: Shortcut Best Fit could be Ctrl + 9 (next to 0 and numerically, 9 is "best fit" for a single character, sort of ;-) )

@mischlrebl
Copy link
Contributor

@KillyMXI Great PR!

Ctrl + 0 would make sense, but I agree that digit shortcuts sould be reserved for other features: line thickness, colors, ...

What about the spacebar? Nowhere used so far and I do not see a use case

@jklingen
Copy link
Member

@Lakritzator would you like to have a look at the code? You're the one with the deepest insight into the current codebase.

@KillyMXI
Copy link
Contributor Author

KillyMXI commented Apr 26, 2020

Dual monitor setup

I have to figure out something to test this. I was hoping I handled this well. But this sounds like .Net might not return what I expect it to.

Zoom factor < 100% with text box on screen: selecting the textbox seems to redraw everything on top and left of it, making text look pixelated (also happens when dragging tail of a speechbubble)

Can't reproduce this. Maybe sensitive to DPI settings? Have to check on a different device.
Upd: got it.
Yeah, I might have an idea what part of code contributes to this. The effect was just less prominent on actual size.

I also found an omission on my side:

  • Make sure context menus are shown where they should.

Zoom 50% with speech bubble: tail can only be dragged on the upper left quadrant of the screenshot

How I missed this... I'll look into it.

Should the window be resized with the screenshot? I somehow expected it to remain at the same size, similar to a browser or Paint.

I would prefer it to take least amount of screen space. The main goal of Greenshot is capturing what's going on in other apps, after all.

Especially the window should not grow out of the visual area

And this is a good point. I'll look into it.

Likewise: should "zoom to best fit" zoom window to fit screen, or screenshot to fit window?

Latter is kinda pointless for me. As I mentioned above, I don't see a point of Greenshot editor taking more space than it needs to show the screenshot.
My idea behind this feature:
Screenshot first opened in 100% zoom, showing it "As Is". And this shortcut allows to fit it completely on screen. There is another related question:

  • Should the editor open with 100% zoom (exact capture, but might not fit on screen completely) or with Best Fit (full overview, but less details). If latter, I most likely need to make a provision for a stop value (of 100%), so it won't zoom in before requested explicitly.

Maybe add Ctrl + Mousewheel support, too?

I'm not a fan of it. It annoys me more often than it helps, when I accidentally trigger zoom with scroll in any apps. And the way different mice emit scroll events - is a pain on it's own.

Note: on German keyboard ...

Yeah, I'm kinda afraid of what might be happening on different layouts. Good point for Ctrl+0.

Shortcut Best Fit could be Ctrl+9

Agree, it looks best from the proximity on the main keyboard. Although it hurts me from how otherwise senseless it is.

... digit shortcuts sould be reserved for other features: line thickness, colors, ...

Yeah, I had that in mind.
I was wondering how important it is to keep 0 with other digits. Sequential features usually start from 1...
At this point I don't think 9 will also be an issue. Human memory is only good for 3-5 things, anything above that will probably be unusable. I would only ensure there is a gap between sequential features at 1-... and specific features at the end or digits row.

@Lakritzator
Copy link
Member

I just checked out the PR, and am now working with it.
Didn't look at the code yet, just wanted to have an initial feeling about it.

It gives me a good vibe, and I'm very impressed so far!!!

Most of the issues have been stated by Jens already. About the zoom with the ctrl + mousewheel, I myself am a big fan of this!

I will now take a look at the code.

@Lakritzator
Copy link
Member

Ah the first issue I found, is that the range of the speech bubble tail is limited when the zoom < 100%

@Lakritzator
Copy link
Member

When I am at < 100% the crop doesn't crop the correct (selected) area.

@KillyMXI
Copy link
Contributor Author

Yeah. jklingen pointed at this already. My bad, will fix soon.

@Lakritzator
Copy link
Member

Sorry, I somehow missed that... :)
Please, by all means, take your time!!! People have been waiting for ages allready.

@KillyMXI
Copy link
Contributor Author

When I am at < 100% the crop doesn't crop the correct (selected) area.

This is mysterious. I think I had it at some moment, but I can't reproduce it since.

@Lakritzator
Copy link
Member

I like best fit, but it doesn't work after I rotate the capture.

@KillyMXI
Copy link
Contributor Author

KillyMXI commented Apr 26, 2020

Hmm. Can't reproduce again. Might be same cause with that crop issue?

Upd: found a way to consistently reproduce the crop issue, but not the "Best Fit after rotate" issue.

@jklingen
Copy link
Member

jklingen commented Apr 26, 2020

I can have a deeper look at the first two issues I reported, the ones you cannot reproduce. Probably tomorrow.

@Lakritzator
Copy link
Member

Lakritzator commented Apr 26, 2020

About the best fit issue I mention before, I think I understand what is the issue.

I captured a screenshot with 650x400 px, if I use best fit, it will enlarge to 200%
Now I go back to 100%, and rotate the capture, best fit will do nothing.

What is the issue? I was expecting that the zoom can use arbitrary sizes, but it will probably try find one of the predefines sizes which has the best fit. And as 200% doesn't fit, it sticks with 100%.
I was somehow expecting it will zoom so it fits, and than have something like 133%.

You could say, it works as designed. But I'm not sure if this makes sense...

@Lakritzator
Copy link
Member

I finally managed to do a review.

First this: I'm amazed at what you did! You managed to understand the not quite simple Greenshot editor, and made a not trivial change to it. And on top of this, you managed to do this in such a way that it even looks like how we would do it.

Chapeau! Well done!!!

I was only able to do minor nit-picking, all my remarks have little value...

@KillyMXI
Copy link
Contributor Author

You could say, it works as designed. But I'm not sure if this makes sense...

Anything between full hundreds (e.g. 150% or 133%) can't be shown "pixel-perfect" - it looks really distorted.
I think with screenshots it's more important to show accurate representation of the original rather than allowing to show any size but with smoothing.

I just checked what Paint.NET does. It enables smoothing for 150%.
I can make the same in principle, but I'm not sure it's what should be done in the screenshot editor.

@Lakritzator
Copy link
Member

You brought up a good point (therefore the 👍 )

Right now you convinced me that it doesn't make sense, but I will talk about it with the guys and I have the right to change my mind. 😄

@Lakritzator
Copy link
Member

Lakritzator commented Apr 26, 2020

Just a side note... it will not be an easy merge into develop 😢
But the changes are quite simple, I don't know why we didn't get to this yet.

We should also look at adding tabs to the editor 😁

@KillyMXI
Copy link
Contributor Author

In fact, I started this in the develop branch and switched to release/1.3 half way through 😅

@Lakritzator
Copy link
Member

That was the right choice, 2.0 is far from finished. Maybe partly due to some of the dotnet core 3.x short comings but mainly because there are still a lot of bugs and things to do.

- better interface for coordinate translation;
- correct context menu location;
- speech bubble tail can be dragged over the whole image.
@KillyMXI
Copy link
Contributor Author

KillyMXI commented May 1, 2020

I think I'm done.

@Lakritzator
Copy link
Member

🎉

I'll check out the funny jitter, which definitely was already there before.

Today was a German holiday and we planned to renovate a room for my kid, which I started in the evenings of this week and will finish tomorrow.

I'll check the code as soon as I have some time behind my pc. I believe it's awesome!!

@jklingen
Copy link
Member

jklingen commented May 2, 2020

Wow, you're quick 😲 thanks for the update. I gave it another test, and from my perspective it looks great. Thanks for fixing the very-tall-screenshot issue; and I can no longer see jumping pixels 🎉

Also:

Smarter zoom - keep selected elements in sight

great idea - that's an awesome addition to the feature 👍

@mischlrebl
Copy link
Contributor

I am eager for a test release :-)

It is not clearly visible from the initial screenshot, but shouldn't the four most important zoom features - which have an own icon - in, out, best fit and actual size be available on the tool menu to? as an own section after the redo.

thanks to all for the efforts!

@KillyMXI
Copy link
Contributor Author

KillyMXI commented May 2, 2020

I would argue against adding zoom icons to the top toolbar at this time.

  • fugue icons are not well readable in this case, and nearly identical icons without text will be confusing;
  • proper implementation is a whole lot of new design questions, it will still add clutter the toolbar, and the gain is rather small.

I thought about adding extra icons to the status bar, but I decided that current design is very straightforward and sufficient for practical use.
At least until enough evidence is collected to see where to move from here. (And then it will be better to apply the new knowledge to hopefully coming new editor instead of spending too much time perfecting the legacy one...)

@Lakritzator Lakritzator added this to In progress in Greenshot 1.3 May 3, 2020
@KillyMXI
Copy link
Contributor Author

KillyMXI commented May 5, 2020

Just to avoid any time waste due to miscommunication, I would love to know:

What exactly is "In progress" now?

I'm not aware of any blocking issues or features left. So in case you expect something - be sure to state it.

@Lakritzator
Copy link
Member

Sorry, I was really dead tired yesterday... having a 4yo is not without penalty in this time. I wanted to start my work at 07:00, due to him it was 09:45, so now at ~22 hours I finally finished work and I can review your changes... long days.

About your final question: I just added this issue to the things I want to have in 1.3 and while I didn't finish the review yet, it is automatically on "in progress". I just finished reviewing all the code, amazing job!

During my test I found more weird drawing artifacts, I am sure that they were already there before this PR, at least 99%. Just amazed about how tough it is to test such things.

I do wonder where the Fraction struct comes from, not that we receive code which is under a conflicting license. Without having this cleared I'm afraid I cannot merge yet, do you remember?

Due to that question, and the size of the PR, we are finally activating the CLA bot, to protect us both. Not that you wonder, we had this on our roadmap for quite some time now.

@KillyMXI
Copy link
Contributor Author

KillyMXI commented May 5, 2020

Fraction struct is completely mine.
I did a quick look for Nuget packages that might offer Fractional/Rational numbers but found all of them not quite fitting the basic task.
It was easier for me just to write it from scratch.
Thinking about it retrospectively, maybe I should've called it "Ratio" instead of "Fraction" - this might make the purpose and distinction clearer.

I also briefly thought about making a more fleshed out analogue as a Nuget package, but I will probably find no motivation for that unless I run into another use for it.

@KillyMXI
Copy link
Contributor Author

KillyMXI commented May 9, 2020

Any time estimates?

@jklingen
Copy link
Member

@KillyMXI we have finally set up the CLA Assistent today, but we want to give it another test. If everything is fine, from my point of view we're ready to merge.

@Lakritzator
Copy link
Member

Lakritzator commented May 10, 2020

I tested the CLA-Assistant in another PR

I am somehow trying to make the assistant check this PR... if you wonder where all the SPAM came from 🤷

@CLAassistant
Copy link

CLAassistant commented May 10, 2020

CLA assistant check
All committers have signed the CLA.

@KillyMXI
Copy link
Contributor Author

Signed

@Lakritzator
Copy link
Member

(This was started before your signed, I was busy putting my kid to bed, he still doesn't sleep and it'S 23:00 hours)

@KillyMXI so we got it working, your PR is really cool but we found we need to protect you and us from contributions which cause discussions.

You only need to confirm the CLA once, no matter how many PRs you made, it's just for our cooperation.

Why we stated with this now? Nobody made us a PR as big as you did!!!
You must also let us know how you would like to be mentioned in the blog entry we are going to write.

@Lakritzator Lakritzator merged commit 10f227d into greenshot:release/1.3 May 10, 2020
Greenshot 1.3 automation moved this from In progress to Done May 10, 2020
@KillyMXI
Copy link
Contributor Author

how you would like to be mentioned in the blog entry we are going to write.

"KillyMXI", linked to my GitHub profile, should be good enough.

@KillyMXI KillyMXI deleted the feature/zoom branch May 10, 2020 21:29
@nicorac
Copy link

nicorac commented May 12, 2020

@KillyMXI your PR is awesome. I really missed the Zoom feature, thank you so much.
I usually work with very large screenshots and I'm now finally able to edit them more accurately.

Maybe add Ctrl + Mousewheel support, too?

I'm not a fan of it. It annoys me more often than it helps, when I accidentally trigger zoom with scroll in any apps. And the way different mice emit scroll events - is a pain on it's own.

Well, let me put my 2 cents:
I was waiting zoom so much that, just after upgrading to latest (unstable) version, I took a screenshot and tried CTRL+Zoom... nothing 😢.
My first thought was "there's something wrong, this is still the old version", then I noticed the Zoom menu and the bottom-right and said "ok, not yet implemented".

IMHO CTRL+Wheel is really natural (and widespread), and all the softwares I use day-by-day have it: Firefox, Chrome, paint.NET, GIMP, Kdenlive, Shotcut, Notepad++, Office, LibreOffice, VisualStudio, VSCode to name a few.

I respect your opinion and work, but please reconsider adding it, maybe with an option to enable/disable it.

@KillyMXI
Copy link
Contributor Author

KillyMXI commented May 12, 2020

I suggest to open a separate issue to track mouse scroll zoom.
I see some design challenges there. I would've added it already if it was as straightforward as keyboard hotkeys.
I also have a few other tasks piled up while working on this - non-sponsored work will have to wait.

@mischlrebl
Copy link
Contributor

Thank you @KillyMXI - great work!

Scrolling on the windows up and down as well left and right - nice implemenation with the shift + scroll - isn't so handy.
Probably shift + mouse pressing to get a hand tool like in Acrobat to move the whole canvas would be useful.

@mischlrebl
Copy link
Contributor

appologize, dragging the canvas in Acrobat Reader is SPACE + mouse (not shift)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Greenshot 1.3
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

6 participants