Pixel density management

Got an idea for enhancing SpiderBasic? New command(s) you'd like to see?
mdp
Posts: 31
Joined: Fri Oct 06, 2017 10:37 am

Pixel density management

Post by mdp »

UI must be designed in consideration of the size of the monitor display.

Some way is needed to regulate the UI according to the screen size, which is equivalent to regulating according to the pixel density.

One proposal could be: a flag in SpiderBasic that modifies the pixel metrics accordingly: if the flag is set, a 1280x800 screen that has (linearly) 2 real pixels per "default-sized" pixel is returned as 640x400 by the relevant SB libraries. So one may set some font to be sized 24px, and it would be rendered as 48px - effectively the same size of the same font in 24px size on a low density screen.

To get those density values, there should be functions in the native host systems. For example, the DisplayMetrics object that is filled in by (in Java for Android) a getWindowManager().getDefaultDisplay().getMetrics( DisplayMetrics metrics ) contains a (float) density field, which the Android documentation defines as
The logical density of the display. This is a scaling factor for the Density Independent Pixel unit, where one DIP is one pixel on an approximately 160 dpi screen (for example a 240x320, 1.5"x2" screen), providing the baseline of the system's display. Thus on a 160dpi screen this density value will be 1; on a 120 dpi screen it would be .75; etc. [...]
This value does not exactly follow the real screen size (as given by xdpi and ydpi, [...]
So SB could base its multiplier on that density or maybe on the average of xdpi and ydpi. The latter is more precise. Nonetheless, I want my screens to be something like 480x512 or 11520x16384, not 5477.8x12345.67 .

Please see my Device independent pixels, http://forums.spiderbasic.com/viewtopic.php?f=6&t=1320 in the coding questions.