Skip to content

Scaling Revisited

Andy Williams edited this page Apr 2, 2024 · 3 revisions

Note

This document is archived as it refers to a design process.

The ability to scale an entire application smoothly is a core part of the Fyne design - but can it be better? Yes :)

Background

Scale is a factor that determines how many pixels are used for each Fyne "DIP" (device independent pixel) - used in all coordinate manipulation, such as fyne.NewSize and fyne.NewPos. A scale of 2.0 will be twice the width and height of one at 1.0 and 0.5 could be used to "zoom out" further.

Originally the toolkit used "auto" by default - this means that the correct scale would be based upon the DPI of the current monitor. Moving a window to another display could cause the window to change scale so that it's size is consistent on each screen. This was changed more recently so that 1.0 was the default - this is due to many systems not correctly reporting values based on hardware issues and/or having their own scaling built in.

Problem

The problem with this approach is that if you want to scale up your UI (for example to 1.5x) it will preclude the use of scaling depending on hardware when it's supported. A Linux computer with a low-res and high-res display works OK in "auto" but in "1.5" either the small or large screen will be badly scaled, depending on resolutions.

Proposal

On Windows and macOS we should leave "1" as the default - but Linux users are keen that we adapt to DPI as hardware is more variable. The value of scale should then be used to "multiply" the hardware default / detected scale so that 1.5 would be equivalent of "50% larger on all screens" so that it is always consistent.

To illustrate this here are some possible values

OS detected user scale result notes
Windows 1.0 1.0 1.0 this would remain the default for Windows
" 1.0 1.5 1.5 scale up by 50% from the windows standard size
macOS 1.0 1.0 1.0 this would remain the default for macOS
" 1.0 1.3 1.3 scale up by 30% based on user preference
Linux auto (1.1) 1.0 1.1 default user scale is 1.0, this is a lowDPI screen
" auto (1.7) 1.0 1.7 default user scale for a hypothetical highDPI screen
" auto (1.1) 1.5 1.6 user requests 50% bigger UI on a lowDPI screen (rounded from 1.65 to reduce possible blur)
" auto (1.7) 1.5 2.5 user requests 50% bigger UI on hypothetical highDPI screen (rounded from 2.55 to reduce possible blur)

Implications

  1. Badly reported hardware on Linux will be caught by a "detected must be between 0.1 and 10" for now
  2. The old "auto" or "-1" will become a "1x" multiplier so that the system scale - static or detected - is respected)
  3. Stored user preference scale will change in meaning. No problem on Windows and macOS but on Linux this could lead to some unexpected scaling... probably a minimal impact at this stage as the configuration is not widely tweaked until FyneDesk gains popularity
  4. We could put a nicer display on top of these numbers such as "smaller": 0.75, "small": 0.9: "normal": 1.0, "big": 1.25 and "bigger" 1.5. Of course it could be a sliding scale as well!

The same FYNE_SCALE and configuration item will be looked up - no proposal to move to a new name as noted above.

Welcome to the Fyne wiki.

Project documentation

Getting involved

Platform details

Clone this wiki locally