-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drawing custom menu items for Menu Bar **Dark Theme Only** #1405
Drawing custom menu items for Menu Bar **Dark Theme Only** #1405
Conversation
1829a6d
to
2d1a006
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the changes with different scale factors and auto-scale settings (quarter/integer200). The scaling results look fine, in constrast to the existing scaling behavior that was broken.
I have some detailed comments and a general question: are there snippets to test the behavior also in combination with images? Our default applications only have menus with text but it would also be interested to test the changes with images, so we should either have or provide a snippet with images for validation.
Please also improve the commit message according to the recommendations, such that it explains the existing issue and more precisely describes the fix. E.g., it currently sounds as if the menu is always draw in a custom way by this change, but it only affects the behavior when using dark theme.
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
Outdated
Show resolved
Hide resolved
2d1a006
to
a9d2293
Compare
e7017c6
to
e10a814
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the recent improvements. There are several improvements in the new version, that's great. In particular, this change also improves the visualization of menus with images. This is how it looked before:
And this is how it looks now:
Only problem is that the left margin is always applied to the text, even if an image is present. But in that case, the margin should be applied to the image (and maybe some additional small margin needs to be placed beetween image and text). This is, e.g., how it looks for the light theme:
One additional issue I found concerns the handling of mnemonics, i.e., when pressing Alt+$ for accesing menu item with menmonic $.
- The visualization is broken: the background color of the menu items does not fit when pressing the "Alt" button (it is black while the rest of the menu is grayish). See the screenshot below.
- Mnemonics are always displayed (underlined) and not only when Alt is pressed. This is, actually, existing behvior, but differs from default behavior, such as in light theme, where the mnemonics are only underlined when Alt is pressed. Maybe we could address this as a follow up, as no regression is introduced. On the contrary, in the current behavior, pressing Alt hides the mnemonics, so badly inverts the intended behavior.
- Most severe issue: there is no reaction to key bindings for mnemonics. E.g., pressing Alt+F should open the "File" menu, but does nothing.
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
Outdated
Show resolved
Hide resolved
9949dbc
to
3d1c1ce
Compare
Something seems to be wrong with the PR now. No matter whether I rebase on #1349, I see two issues:
Can you please check that, @ShahzaibIbrahim? |
674c379
to
3c16e7e
Compare
5ee53ab
to
e0d0e5b
Compare
db0f7f1
to
14830a6
Compare
e197195
to
8490a8f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, when doing another final testing after rebasing, I found a further issue. To reproduce, do the following:
- Have a primary monitor with >100% scaling (e.g., 125%), have a secondary monitor with 100% scaling
- Start an application with PerMonitorV2 DPI awareness in dark mode
- Move the application from 125% monitor (on which it looks fine) to 100% monitor.
The sizes seem to be calculated properly, but the font is too small (probably 100% instead of 125%):
@akoch-yatta @ShahzaibIbrahim can you please have a look? Maybe this is easy to resolve by using proper scale values at some place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HeikoKlare Sorry for all that back and forth, we need to improve the test protocol on our side, so you don't have that much work retesting changes. It is not yet properly working on all scenarios, as you mentioned. We'll have a look on that tomorrow. |
b1bbcd6
to
2fe01bf
Compare
In each of the following screenshot there is an adapted version of Snippet373 started with commit 2fe01bf, 4 times each. The title gives the info of the configuration:
Setup: Primary 125%, secondary 175% Setup: Primary 175%, secondary 125% Setup: Primary 150%, secondary 200% |
347ffb3
to
cd3bb9b
Compare
Hmm, I cannot reproduce any vertical spacing issue, neither with quarter nor with int200. Regarding the horizontal indentation: I agree, that int direct comparision positioning could be improved. I tweaked some statics in cd3bb9b to achieve the following result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look fine to me and I didn't find any regressions/bugs while testing.
I only have 2 nit-picky comments regarding readability but aside from that, this PR is good to go on my account.
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ShahzaibIbrahim please squash your commits and this one is good to go on my account. @HeikoKlare should I merge or do you want to take another look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've retested this and did not find any issues anymore. In particular with existing HiDPI support (i.e., without per-monitor rescaling at runtime) and all combinations of settings (integer200 or quarter scaling, DPI awareness set to PerMonitorV2 or System, two monitors with different scalings between 100% and 200%).
The general appearance is also better than with the existing implementation (placement/spacing and highlight color). There is still some room for slight improvements on vertical alignment (with 100% is slightly off to the top while at 175% it is slightly off to the bottom), but that's rather nitpicky and, as said, the proposed state is still far better than the existing one.
@ShahzaibIbrahim can you please check the code formatting again (see, e.g., the comments I made) and squash the commits, so that we can merge this for M2?
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
Outdated
Show resolved
Hide resolved
885fc63
to
c895e4f
Compare
2a88c65
to
5ba361d
Compare
I would like to merge this PR but I'm not sure that every check ran. I only see 7 on the Other PRs have also checks from Jenkins I also noticed that https://ci.eclipse.org/releng is currently offline Is there a |
https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/issues/5131 |
you mean "outage"? |
When switched to Dark Theme, using gc to draw menu item, moving the responsibility from OS due to wrong scaling of menu bar vertically. Also changing the text color from a grayish tone to white. Also when ALT key is pressed mnemonics are underlined and work as a toggle, the behavior which was missing from dark theme previously.
5ba361d
to
bd3cf3a
Compare
Jenkins is still unavailable, but (Jenkins) builds before latest update were successful and without new issues. Since only formatting changes have been performed since then, this is still safe to merge. |
Using gc to draw menu item, moving the responsibility from OS due to wrong scaling of menu bar horizontally in Dark Theme. Snippet 373 can be used to test menuItems with images.
Additional points covered in this PR:
Screenshot of the fix:
HOW TO TEST
RunTimeWorkspace
with the following VM ArgumentsSCENARIOS TESTED
autoscale.updateOnRuntime = false && autoscale=int200 (Prevent regressions)
100% (Primary), 175% (Second)
150% (Primary), 200% (Second)
175% (Primary), 125% (Second)
200% (Primary), 100% (Second)
200% (Primary), 150% (Second)
autoscale.updateOnRuntime = false && autoscale=quarter (Prevent regressions)
150% (Primary), 200% (Second)
175% (Primary), 125% (Second)
autoscale.updateOnRuntime = true && autoscale=int200
100% (Primary), 175% (Second)
150% (Primary), 200% (Second)
175% (Primary), 125% (Second)
200% (Primary), 100% (Second)
autoscale.updateOnRuntime = true && autoscale=quarter
150% (Primary), 200% (Second)
175% (Primary), 125% (Second)
EXPECTED BEHAVIOUR
The menu bar should be scaled properly.
contributes to #62 and #127