Skip to content

Support DPI-dependent units #951

@jonhoo

Description

@jonhoo

Currently, properties such as width and height only support pixel values or percentages. However, this is pretty limiting for users who wish to use the same bar across different monitors. To give a specific use-case, I have three setups I switch between regularly:

  • Bar is on a high-DPI (144) monitor with resolution 2560x1440
  • Bar is on a regular-DPI (96) monitor with resolution 1920x1080
  • Bar is on a rotated regular-DPI (96) monitor with resolution 1200x1920

Picking a single value for height here becomes really difficult: a pixel value will cause the bar to either be way too small when the DPI is high, or way too tall when the DPI is low, but a percentage value will cause the bar to be really strangely sized on the rotated monitor. Even if the monitor isn't rotated, different aspect ratios can cause a height of 3% to look very different (compare 1920x1080 and 1920x1200 for example).

It would be very useful to have a DPI-dependent unit for these properties to complement the existing two attributes. We can probably draw some inspiration from CSS length units here, and add a unit like em, which is scaled relative to the current font size, which in turn is affected by the DPI (or should be if it isn't already). Alternatively, we could go with in/mm, though this would break with CSS, in which 1in == 96px.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions