Skip to content

topbar: balance the padding in the quick-settings tiles - #137

Open
kingfree wants to merge 2 commits into
Lemxy:mainfrom
kingfree:quick-tile-padding
Open

kingfree wants to merge 2 commits into
Lemxy:mainfrom
kingfree:quick-tile-padding

Conversation

@kingfree

Copy link
Copy Markdown

The state line of a quick-settings tile ("Off", "开") ended 1.5 px above the tile's bottom edge, while the badge in the same tile started 12 px below the top: the text looked glued to the edge.

The tile was 76 px tall and its parts took all of it — 12 px of air, the 32 px badge, 4.5 px, the 12 px title, 3 px, the 11 px state line = 74.5. There was no room left to fix this by nudging the text, so the tile is 84 px tall now (row pitch 84 → 92, which moves the slider card and the bottom edge down 16 px in total). The text is 26 px deep and the tile now leaves it the same air under it as the badge has above it.

Measured (logical px, air between the lowest ink of the state line and the tile's bottom edge; the badge keeps its 12 px above):

before after
English 3.0 11.0
Russian 3.0 11.0
Japanese 2.5 10.5
Portuguese (BR) 1.0 9.0
Simplified Chinese 1.5 9.5

Portuguese is the tightest because of the descender in "Desligado"; the live-captions tile, which has no state line, goes from 14 to 22.

before and after, Chinese

The Bluetooth tile at 2× (before left, after right):

the tile at 2x

All five languages, rendered with the panel's own code at 200 %:

the tile grid in en, ru, ja, pt, zh

Also in here. The tile's parts moved into QT_* and qt_tile / qt_badge / qt_label / qt_state: rects() (the hit test) and the painter had the same numbers written out twice, and the geometry a test checks has to be the geometry that is drawn. paint() is split into draw(dc, k) (the panel into a DC) and paint(hw, k) (BeginPaint, the double buffer), so a test can render the real panel and measure it. While doing that I noticed topbar --preview quick|wifi never set SCALE, so the preview drew its flyout at 100 % on a HiDPI screen; it reads the DPI now like the bar does.

Tests (cargo test -p topbar, 16 pass):

  • quick_tiles_keep_air_under_the_text — the panel is drawn by draw() into a memory DC at 100, 125, 150, 175, 200 and 250 %, read back pixel by pixel, and every tile's state line has to leave it 8–14 px (11 px in the test's language). With the old 76 px tile this fails with "ends 3 px above the tile's edge".
  • every_languages_state_word_keeps_its_air — the state words of en, ru, ja, pt and zh drawn with the tile's own font into the tile's own rect, the same 8–14 px rule.

The state line of a tile ("Off", "开") ended 1.5 px above the tile's bottom edge while the badge above it started 12 px
below the top, so the text looked glued to the edge. The tile was 76 px tall and its parts took all of it: 12 (air) + 32
(badge) + 4.5 + 12 (title) + 3 + 11 (state) = 74.5.

The tile is 84 px tall now, which leaves the text about the same air under it as the badge has above it. The row pitch
grows with it (84 -> 92), so the slider card and the panel move down 16 px in total.

The tile's parts also moved into QT_* and qt_tile/qt_badge/qt_label/qt_state: the hit test in rects() and the painter had
the same numbers written out twice, and the geometry a test checks has to be the geometry that is drawn. paint() is
split into draw(dc, k) (the panel into a DC) and paint(hw, k) (BeginPaint, the double buffer) so the panel can be
rendered into a memory DC and measured.

Tests (cargo test -p topbar, 16 pass):

- quick_tiles_keep_air_under_the_text - the real panel, drawn by draw(), is read back pixel by pixel at 100, 125, 150,
  175, 200 and 250 %: each tile's state line leaves 8-14 px under it (11 px in the test's language).
- every_languages_state_word_keeps_its_air - the state words of en, ru, ja, pt and zh in the tile's own font and rect;
  Portuguese "Desligado", whose g descends lowest, keeps over 8 px as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant