Skip to content

Conversation

@pieleric
Copy link
Member

@pieleric pieleric commented Dec 8, 2025

When the scaling of the scaling is not 100%, the bitmap size is
automatically adjusted (ie, rescaled proportionally). However, the
toolbar used this information to adjust the toolbar size, which is in
"DIP" (Device Independent Pixel), meaning the value should be passed
assuming it's not scaled.
This caused the toolbar to be shown too large when the scaling > 100%.

Mostly noticeable on Ubuntu 24.04, with multiple screens,
where the scaling is automatically adjusted based on the screen DPI.

Before:
image
After:
image

…ling

When the scaling of the scaling is not 100%, the bitmap size is
automatically adjusted (ie, rescaled proportionally). However, the
toolbar used this information to adjust the toolbar size, which is in
"DIP" (Device Independent Pixel), meaning the value should be passed
assuming it's not scaled.
This caused the toolbar to be shown too large when the scaling > 100%.

Mostly noticeable on Ubuntu 24.04, with multiple screens,
where the scaling is automatically adjusted based on the screen DPI.
@pieleric pieleric changed the title [fix] GUI toolbar incorrect positionning when screen has High DPI scaling [SWM-202][fix] GUI toolbar incorrect positionning when screen has High DPI scaling Dec 8, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 8, 2025

📝 Walkthrough

Walkthrough

The changes refactor how bitmap controls are created and added to the toolbar in src/odemis/gui/cont/tools.py. Instead of immediately wrapping bitmap objects in wx.StaticBitmap controls, the code now creates raw bitmap objects and defers StaticBitmap control creation until the bitmaps are added to the sizer. The minimum-size calculation logic is updated to access bitmap dimensions directly rather than through StaticBitmap properties, improving DPI and scaling behavior. Additionally, the orientation condition is changed from an equality check to a bitwise AND operation for vertical layout detection.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the fix for GUI toolbar incorrect positioning when high DPI scaling is applied, directly matching the main change in the pull request.
Description check ✅ Passed The PR description clearly explains the issue (toolbar too large with >100% scaling), provides context (Ubuntu 24.04, DIP pixels), and includes before/after visual evidence of the fix.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a GUI toolbar positioning issue that occurs when the display uses High DPI scaling (scaling > 100%). The problem was that bitmap sizes were being accessed after they were scaled by the display, but the toolbar sizing logic required Device Independent Pixel (DIP) values.

Key Changes:

  • Refactored bitmap loading to store wx.Bitmap objects directly instead of immediately wrapping them in wx.StaticBitmap
  • Changed size calculations to use bitmap dimensions directly (first_bmp.Width/Height) to get unscaled DIP values
  • Simplified orientation check logic using bitwise AND operator

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tepals
Copy link
Contributor

tepals commented Dec 9, 2025

@pieleric I don't see how this PR relates to the Jira issue, could you add some screenshots here on in Jira to show what this fix does? https://delmic.atlassian.net/browse/SWM-202
Or is this "too large" you mention in the commit message, the glitch in the Jira ticket? Just a before and after screenshot would help me 😅

@pieleric
Copy link
Member Author

@pieleric I don't see how this PR relates to the Jira issue, could you add some screenshots here on in Jira to show what this fix does? https://delmic.atlassian.net/browse/SWM-202 Or is this "too large" you mention in the commit message, the glitch in the Jira ticket? Just a before and after screenshot would help me 😅

Yes, it's the middle (vertically) of the tool bar which was too wide. I've added screenshots in the description.

@pieleric pieleric merged commit c7e2f02 into delmic:master Jan 8, 2026
11 checks passed
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.

3 participants