Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bugfix] Adjust scale bar position based on font_size when at top (na…
…pari#7018) # References and relevant issues Closes: napari#7009 # Description This PR aims to fix the visual issues with the scale bar text when the scale bar is positioned at the top, instead of default down. If the size of the text is changed, the offset from the top of the canvas is increased proportionally. In the process, this PR does two main things: - accounts for the canvas DPI when scaling the text size. The defaults (font_size, box height, etc.) were all hard coded around 96 dpi. This PR corrects for that by getting the actual canvas DPI from vispy. A side effect of this is that users with >96 DPI will see the text get smaller -- we may wish to bump up the default from 10 to 11 or 12. This has another side effect: partially addressing napari#7516 but just for default font_size, not when font_size is increased. - computes the logical pixel height of the text in order to account for it in the y_offset from the top of the screen. Default settings with this PR (just setting top_right): <img width="852" alt="image" src="https://github.com/user-attachments/assets/a1fd9aa7-1c53-4b97-8e9e-06f112e8d3ac" /> Current napari main: <img width="836" alt="image" src="https://github.com/napari/napari/assets/76622105/af6e66a6-93b0-4bba-9283-544a8476241e"> Change to font_size 30 with this PR: <img width="869" alt="image" src="https://github.com/user-attachments/assets/0a59a9e3-b333-4aa7-aacc-aca6f74d5deb" /> versus current napari main: <img width="841" alt="image" src="https://github.com/napari/napari/assets/76622105/b590855d-baf6-4f78-abb3-30f18b97d226"> Edit: I tested this with my personal mac DPI 149 and with an external display 108. The rendering of the scale_bar was identical to my eyes, side by side. --------- Co-authored-by: Juan Nunez-Iglesias <[email protected]>
- Loading branch information