Bug 456364

Summary: Marching ants for selection is not visible on 4k 27 inch screen
Product: [Applications] krita Reporter: Hologram <intuos5>
Component: Tools/SelectionAssignee: Halla Rempt <halla>
Status: RESOLVED FIXED    
Severity: normal CC: griffinvalley, halla
Priority: NOR Keywords: triaged
Version: 5.1.0-beta1   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Attachments: Systeminfo
This is the way it looks on my main monitor (the selection is much clearer on a screenshot than how I see it).
On my laptop screen, the marching ants are much more pronounced.
Scaling settings (copy from imgur)

Description Hologram 2022-07-05 19:36:26 UTC
SUMMARY
***
I have been experiencing major difficulties using Krita, since I cannot see my selection well. Depending on the background, I can sometimes guess that something is selected, but I cannot really see it. This is because the Marching ants do not scale with High DPI screens. 
***

STEPS TO REPRODUCE
1. Perform a selection with medium grey background

OBSERVED RESULT
The marching ants are almost entirely neutralised by the colour of the background. This is especially clear in the recording below:
![2022-06-23 13-45-50|video](upload://uvh2qNSPneLB3mcUEuefAOLeNNZ.mp4)

SOFTWARE/OS VERSIONS
Windows: 10.19044

ADDITIONAL INFORMATION
Also mentioned here: https://krita-artists.org/t/display-selection-highlight-size-setting/32353/18

P.S. For follow up, it may be better to tag me there, since I will be checking over on the forums more often.
Comment 1 Halla Rempt 2022-07-06 08:53:52 UTC
I worked on this before, made the ants longer, but deevad couldn't work with that, so that got reverted.
Comment 2 Halla Rempt 2022-07-06 08:56:40 UTC
Could you please also attach the contents of help->system information for bug reports?
Comment 3 Hologram 2022-07-06 09:02:42 UTC
Created attachment 150434 [details]
Systeminfo

Earlier on in the Krita-artists thread, Deevad made a suggestion to have a DPI sensitive solution, see: https://krita-artists.org/t/display-selection-highlight-size-setting/32353/14
Comment 4 Hologram 2022-07-06 09:05:50 UTC
(In reply to Halla Rempt from comment #1)
> I worked on this before, made the ants longer, but deevad couldn't work with
> that, so that got reverted.
Yes I recall that. 

To me, the issue is not necessarily only about the length of the marching ants. Their width is also too small for me to actually notice them (as you may be able to tell from the video I posted on Krita-artists, so I would personally prefer to see an increase in both length and width of the marching ants.
Comment 5 Bug Janitor Service 2022-07-06 11:33:09 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1505
Comment 6 Dmitry Kazakov 2022-07-12 11:47:27 UTC
Git commit 88d9cb822e61d202cb9fa7b997dd375aa9e7aae9 by Dmitry Kazakov, on behalf of Halla Rempt.
Committed on 12/07/2022 at 11:47.
Pushed by dkazakov into branch 'master'.

Set the size of the marching ants based on the dpi of the screen

This also handles moving the Krita window from screen to screen and
interactively changing the resolution of the screen.

M  +63   -7    libs/ui/kis_selection_decoration.cc
M  +8    -0    libs/ui/kis_selection_decoration.h

https://invent.kde.org/graphics/krita/commit/88d9cb822e61d202cb9fa7b997dd375aa9e7aae9
Comment 7 Dmitry Kazakov 2022-07-12 11:52:13 UTC
Git commit f1e5035d59102f6a9c6eac8896cc202745dae31b by Dmitry Kazakov, on behalf of Halla Rempt.
Committed on 12/07/2022 at 11:52.
Pushed by dkazakov into branch 'krita/5.1'.

Set the size of the marching ants based on the dpi of the screen

This also handles moving the Krita window from screen to screen and
interactively changing the resolution of the screen.


(cherry picked from commit 88d9cb822e61d202cb9fa7b997dd375aa9e7aae9)

M  +63   -7    libs/ui/kis_selection_decoration.cc
M  +8    -0    libs/ui/kis_selection_decoration.h

https://invent.kde.org/graphics/krita/commit/f1e5035d59102f6a9c6eac8896cc202745dae31b
Comment 8 Hologram 2022-08-20 09:23:43 UTC
Sorry it slipped my mind to mention this earlier, I wasn't quite sure when this was merged and in which build it would be available for testing, since I hadn't seen  any notable changes to the marching ants on Windows.

So with the release of 5.1, I tried all available builds today, which includes the 5.1 release, 5.1 + and the latest nightly (5.2.0-prealpha-6789e584cf). The marching ants remain as small as they were when I initially made this report. I also checked the options, enabled/ disabled HiDPI support and tried enabling fractional scale factor. Apart from the UI scaling, they do not affect the marching ants for me. 

Any idea what else I could do to help diagnose the issue?
Comment 9 Halla Rempt 2022-08-20 09:28:26 UTC
It worked for me on my windows, linux and macos systems... The only other solution would be to make it an option after all, and Dmitry didn't want that.
Comment 10 Hologram 2022-08-20 09:35:21 UTC
Strange... 

Is there any settings file that I could remove/ reset to default that might affect this?
I am using 175% scaling on my monitor, could that affect the DPI calculation?

Actually, now that I am looking into it, on my laptop screen (15,6 inch, 4k and 250% scaling) the marching ants are very clear. I actually don't recall how it was on my laptop since I usually just use my main monitor.

Should I download an older version of Krita to verify that the marching ants changed on my laptop screen?
Comment 11 Hologram 2022-08-20 09:43:05 UTC
Created attachment 151443 [details]
This is the way it looks on my main monitor (the selection is much clearer on a screenshot than how I see it).
Comment 12 Hologram 2022-08-20 09:47:19 UTC
Created attachment 151446 [details]
On my laptop screen, the marching ants are much more pronounced.

I have added two screenshots to show the comparison. The difference in DPI scaling between the monitor (175%) and my laptop screen (250%) make a big difference. So I tried setting the 250% scale on my monitor, though the marching ants remain just as tiny, so I can rule out that Windows scaling affects their size.
Comment 13 Halla Rempt 2022-08-20 10:11:21 UTC
The "calculation" we use is like this. It calculates the dots per inch, and then picks the scale. Looks like your monito at 175% falls in the < 220 dpi range?

    if (dotsPerInch < 220) {
        screenScale = 1;
    }
    else if (dotsPerInch < 300) {
        screenScale = 2;
    }
    else if (dotsPerInch < 500) {
        screenScale = 3;
    }
    else {
        screenScale = 4;
    }
Comment 14 Hologram 2022-08-20 11:24:16 UTC
That could indeed be the case. With a DPI calculator (https://www.sven.de/dpi/):
Laptop - 15,6 inch screen - Display size: 13.6" × 7.65" = 103.99in² (34.54cm × 19.43cm = 670.89cm²) = 282.42 PPI 
Monitor - 27 inch screen - Display size: 23.53" × 13.24" = 311.5in² (59.77cm × 33.62cm = 2009.68cm²) at 163.18 PPI

So, that would indeed mean that my laptop screen uses screen scale 2 and monitor screen scale 1. 

By default, the marching ants were 4px wide at what is now screen scale 1. 
When you changed it to be 8px wide (screen scale 2) it was fine for me. 

So for reference:
24 inch - 1080p - Display size: 20.92" × 11.77" = 246.12in² (53.13cm × 29.89cm = 1587.9cm²) = 91.79 PPI
15.6 inch - 1080p - Display size: 13.6" × 7.65" = 103.99in² (34.54cm × 19.43cm = 670.89cm²) = 141.21 PPI 
14 inch - 1080p - Display size: 12.2" × 6.86" = 83.75in² (30.99cm × 17.43cm = 540.33cm²) = 157.35 PPI
10 inch - 1080p - Display size: 8.72" × 4.9" = 42.73in² (22.14cm × 12.45cm = 275.68cm²) = 220.29 PPI

^This indicates that tablets would default to screen scale 2, and 1080p monitors would always use scale 2 if they are at least 1080p resolution. Only budget model tablets at €130,- range use screen scale 1 (they are below 1080p res) - from a quick look at the most popular devices page 1-4 on the Tweakers Pricewatch. 

27inch - 1440p - Display size: 23.53" × 13.24" = 311.5in² (59.77cm × 33.62cm = 2009.68cm²) = 108.79 PPI
24inch - 1440p - Display size: 20.92" × 11.77" = 246.12in² (53.13cm × 29.89cm = 1587.9cm²) = 122.38 PPI

^Any 1440p screen would use screen scale 1. 

So I am thinking, what do you think about adding a new screen scale around the 150-160 dpi range? That would not affect most common screen resolutions of a lower DPI, most notably 1080p. Perhaps the scaling in between 155-220 could be 1,5 for the marching ants? But 2 also be fine. 

So maybe like this then?

  if (dotsPerInch < 155) {
        screenScale = 1;
    }
else if (dotsPerInch < 220) {
        screenScale = 1.5;
    }
    else if (dotsPerInch < 300) {
        screenScale = 2;
    }
    else if (dotsPerInch < 500) {
        screenScale = 3;
    }
    else {
        screenScale = 4;
    }
Comment 15 Hologram 2022-09-08 15:57:31 UTC
Sorry to ping you on this @Halla, hope you enjoyed your vacation. :)
I was wondering what you think about the range I proposed in the previous post? If that's okay, it would, hopefully, be a simple change to implement.

If not, could this possibly be solved with a slider option in the preferences to increase/ decrease Marching Ants in width if you don't want to change the current DPI range. I'm thinking something like this: https://imgur.com/a/7PsMx3K (Illustrator has these sliders, whereas Affinity has click buttons, for Krita, there might be an input box with a pixel offset value to increase/ decrease the size relative to the default).

P.S. I think such a setting could be useful, in the future, for Vector handles/ assistant handles, but that's outside the scope of this bug report. I didn't have any issues with those either.
Comment 16 Halla Rempt 2022-09-14 08:42:08 UTC
Ah, well, my vacation was mostly spent in bed, one day of activity followed by three days of out-and-out tiredness. 

I agree that a slider to settle the size of ants and other canvas elements would be good, but the hard part is convincing the others in the team that it would be a good idea.
Comment 17 Halla Rempt 2022-09-14 09:18:00 UTC
Created attachment 152043 [details]
Scaling settings (copy from imgur)
Comment 18 wolthera 2023-01-19 12:37:14 UTC
Ok, setting this to confirmed
Comment 19 Dmitry Kazakov 2023-03-30 15:28:58 UTC
Git commit 83aef95faa60799c3cdea7ef419e8ca5610def5b by Dmitry Kazakov, on behalf of Carsten Hartenfels.
Committed on 30/03/2023 at 15:24.
Pushed by dkazakov into branch 'master'.

Use device pixel ratio for selection outline width

Instead of messing around with physical screen size, since that breaks
when UI scaling gets involved. For example, on a 4K screen, you'd
probably run Krita with a scale factor of 2, which causes the entire UI
to be scaled, but the selection outline is impossible to make out
because it's just one pixel wide. With this change, it the outline just
scales like the rest of the user interface.

M  +4    -26   libs/ui/kis_selection_decoration.cc

https://invent.kde.org/graphics/krita/commit/83aef95faa60799c3cdea7ef419e8ca5610def5b