Display scaling factor on Windows

Hi!

Coming from plug-in development on Mac, first thing I noticed when testing a project on Windows (after making standard c++17 features compile :roll_eyes:) was that the plug-in window size is too big. Height and width are around 135 % bigger compared to Mac on the same display. So I thought, maybe I just have to change DPI or other settings of the OS first. But then I realized that none of the OS settings affect the plug-in window size. So…

  1. Congratulations on making iplug2 look-and-feel agnostic to view scaling factors.
  2. Why is my plug-in so big? Which settings do I have to tweak?
  3. Could it be that the scaling is not calculated correctly by iplug2?
  4. Is there a programmatic way to compensate for the scaling? (I have a user option for resize with different scaling factors, which is good, but I don’t want the default setting to already look like a tool for the blind).

Interestingly, a screen shot of the window has the expected dimensions in terms of pixels, which is (PLUG_WIDTH*2) * (PLUG_HEIGHT*2).

Cheers
Peat

what is your OS “scale and layout” %?

I have a high DPI “retina” screen that I use in windows set at 200%, my other 2 screens are regular DPI and are set at 100%. I dual boot mac and windows and the UIs of my iPlug2 plugins are the same dimensions.

Counting the pixels revealed that my assumption of a 200% scaling on the “retina” display was wrong. The default value on the macbook pro is less, making my plug-in appear smaller on Mac than on Windows where I tested with 200%. This seems to be a hard design decision: For which display+scaling do I optimize my default plug-in size?..

But now to another related topic (point 1 on my list above). I think I found an issue, because on Windows the plug-in window size does not change for scaling values 150…250 %. For values below this range the plug-in window has half the size. This smells like an implicit conversion to int problem. Can you confirm this behavior? Is it intended?

int mScreenScale = 1; // the scaling of the display that the UI is currently on e.g. 2 for retina
Why int? And, as stated in my previous post, for the default scaling on the macbook pro is less than 2.

I believe this works correctly on mac. On windows I think it’s currently only correct for 100% and 200% scaling, if you have screen scale set to something in between e.g. 150% the UI is the wrong size. This may involve making screen scale a float value. Maybe @AlexHarker has something to add.

iplug2 supports two kinds of scaling - scaling for DPI (int only - ScreenScale) and scaling for drawing (arbitrary - DrawScale). The only one that happens automatically is the first one.

The int assumption relates to the use of bitmaps and ensuring that at draw scaling of 1 one IGraphcs pixel is always an integer number of real pixels (this also helps for things like setting the window size). It’s not a strong limitation of how we’re doing things, but changing it now would be quite a bit of work, although something we can consider - if you feel strongly that it is incorrect behaviour please make an issue of GitHub to discuss it.

More generally, it sounds like you are expecting the size to consistent in terms of physical size, which is not the case - the screen scaling is designed to compensate for high DPI in general by doubling the number of pixels, and not to compensate for OS-level scaling options. As physical size of pixels will be highly variable I’d suggest adding scaling options to your plugin to allow the user to select the size they want, as you describe - sounds like you’d need to detect the OS scaling in order to default that to what you want, which we haven’t addressed. If someone wanted to attempt an API for detecting that we could take a look at including it, but I think we’re unlikely to do that ourselves.

Hey Alex, thank you for explaining the reasoning behind integer based scaling. Your answer makes sense. What I do not understand, however, is the fact that on Mac the “physical” dimensions of the plug-ins on screen change according to the setting of the operating system, which can be (and typically is) a fractional number, whereas on Windows only 100%, 200%, 300%… make a difference.
I agree that having a user option for resize makes all of this somehow irrelevant, especially for vector based graphics, but it’s a little bit confusing that win+mac behave differently in that regard. Cheers