Hello; I’m aware that for users with high resolution displays, the approach for Haiku is to increase the font size by the increase in resolution from “standard definition” and the UI should scale too via the layout manager. I am using this to derive this scaling factor;
MAX(1.0f, be_plain_font->Size() / 12.0f)
However @waddlesplash made this comment on a PR where I had accidentally included the above C macro recently;
This should not be needed; the font size can just be used directly, or the values from BControlLook used otherwise.
I see in BControlLook::ComposeIconSize(...) there is a similar calculation happening; interestingly with a literal as the denominator too.
Can I confirm the best way to establish the correct scaling factor? Would it be a good idea to add a method BControlLook:ScaleFactor()?
There are actually two methods in Haiku that determine the UI size. One is the factor from the font size, and this indeed usually is not needed direclty since UI most UI elements actually contain text already and scale acordingly.
Some elements that used the calculation directly have been fixed, for example the StatusView used to do this, now it instead calculates a proper text size.
The idea with all these is to leave it up to the controlLook, your code should not need to deal with it. And especially not need some random factor, if it is laid out correctly that should already work.
This has been discussed before, you can take a look at the mailing list about it. The basic ideas are that (1) 12.0f is merely the default font size, and should that be changed in the future for any reason, having it hardcoded anywhere will mean we need to change it (in BControlLook it’s just an internal API and we can easily modify it), and (2) for the most part, a “scale factor” should not be needed. All GUI metrics should be computed off of either the font metrics, spacing metrics, or the available screen size, none of which directly have a “scale factor” (though internally in BControlLook they may be handled that way.)