ShadowTheAge / yafc

Powerful Factorio calculator/analyser that works with mods
GNU General Public License v3.0
167 stars 54 forks source link

[BUG] Minimum window size is too big for unusual screen setups #132

Open tornewuff opened 3 years ago

tornewuff commented 3 years ago

Using YAFC 0.5.8 on Linux.

The default size of the YAFC window appears to also be the minimum size, at least on Linux (haven't tried on Windows). I'm trying to use YAFC on my second monitor with Factorio on the main one, but my second monitor is in portrait 1080x1920 configuration and the YAFC window is too wide to fit. I realise there will likely be a lot of ingredient/product wrapping with a narrower window, but the current minimum size limit seems unnecessary. :)

ShadowTheAge commented 3 years ago

The minimum size is there for windows like recipe explorer to fit (they have fixed size). I actually downscale everything if a desktop is too small but if you have one screen that is "enough" and another that is not, that wouldn't work here. I suppose I can try to scale on a per-screen basis but I wouldn't be able to test this on linux.

ShadowTheAge commented 3 years ago

BTW what if you move the initial "welcome" window to the second screen before loading the project? It should (in theory) open the main screen on the second window and downscale it to fit the required width

tornewuff commented 3 years ago

OK, I experimented a bit more and realised that I set up my arcane screen config so long ago now that I missed some.. even more unusual details that affect the behaviour here

I have a large 3840x2160 monitor and a much smaller 1080x1920 portrait monitor. They have pretty different pixel sizes and X11 doesn't support mixed DPI rendering, so my desktop is set to 200% UI scale for the benefit of the 4K monitor... and then the second monitor is configured to pretend to be 1215x2160 and then downscale to 1080x1920 for output to the actual hardware. Without doing that 200% scale on it makes everything too big. It's a pretty cursed display setup.

Trying things out again with YAFC has some real interesting results that I missed before, and some different results with your suggestion too:

1) Loading the project on the main monitor gives me a "normal" size window (roughly half the screen size in each axis) and it's rendering at a comparable scale to other apps. Dragging the window far enough onto the other display then shrinks all the rendered contents of the window to what looks like half size but is so small that it's pretty much unreadable. The window is still the same size and too wide to fit on the display but the content inside the window is now narrow enough that it actually does fit, but it's not really usable like this.

2) Dragging the welcome window over to the second monitor shrinks both the window and the contents of the window by half (again making it pretty much unreadable), and then loading the project gives me a smaller window with the same shrunk rendered content as in 1) - still unreadable but now the window is appropriately sized for the contents. Dragging the project window back to the main monitor makes the contents scale up again but doesn't change the window size so I end up with a window that is much too small and cannot fit the entire recipe explorer UI in it unless I make it bigger myself.

I reconfigured things to not rescale the second monitor to see what happens without that weird variable, and it doesn't change the behaviour of YAFC from the above. In this setup starting YAFC on the second monitor is just about usable: it's being rendered at the same actual pixel size which is very very tiny and only just readable, but since it's no longer being scaled down by 35% by my video driver it remains just barely readable instead of becoming so tiny it's illegible.

Changing my UI scale doesn't affect YAFC at all; I assume your code or the SDL is calculating its own UI scale based purely on the screen resolution and not my desktop settings.

So, yeah. If parts of your UI have fixed size then the minimum window size does make sense but ends up with the app not being usable in this monitor configuration regardless of how I configure things, and even if the minimum size wasn't enforced then the main project UI still wouldn't really be that usable because of the app's rendering scale being so tiny on the second display.

If it's your code that's calculating the scale then I think ideally it should be using the desktop UI scale instead; that would stop it from changing size when dragged from one monitor to another which isn't likely to have desirable results regardless of the monitor setup. I have no idea how hard that would be to do though, and it wouldn't really solve my problem anyway, so hey. If you can support non-integer scales then being able to adjust it manually would probably work?

Totally fine if you just want to close this though :) It's probably not worth much effort; this kind of config is not very common. Though later on I can try it in Windows as well just to see if it's any different; Windows does (sort of) support mixed UI scale on different monitors...

tornewuff commented 3 years ago

On Windows I have a different cursed set of settings; main monitor is 150% UI scale and second is UI 100% scale, no weird post-render rescaling.

YAFC generally behaves the same, because I assume it's not paying attention to UI scale on Windows either - the UI on the main monitor is exactly the same size/scale as in Linux and on the second monitor it's the same very small size/scale as in Linux without the rescaling configured. So, yeah, this isn't Linux-specific, unfortunately I think the scale calculation in YAFC just isn't picking a usable result for a 1080x1920 monitor because your minimum UI width from the fixed UI dialogs is just too big to fit comfortably.

ShadowTheAge commented 3 years ago

I am using the DPI property to make yafc fixed real size, with a downscale if it doesn't fit. That however does not recalculate if settings change while the app is opened. I am not sure how X11 reports its dpi per display. On windows I report that I am aware about per-screen DPI but that works only on windows 10 (and maybe 8, but not 7)

I also have that setup with main monitor having 150% scale and the second having 100% scale and it works just about right regardless of moving welcome or main screen between screens (with exception of minimum screen size may be incorrect in those cases)

Just checked, there are only two usable properties that I can get from SDL about user screen: DPI and size in pixels. I don't see how can I make more use of those than now. I am calculating the scale based on these two. (My gui is measured in units with one unit being the height of a normal line of text, it is designed to be scaleable)

ShadowTheAge commented 3 years ago

By your description it looks like it reports the correct dpi per screen (that is low on your second screen) that causes yafc to rescale to be smaller, but also applies the system-wide scaling, making things too small.