[Win] Enabled Image+Text button ignores alignment #3277#3282
Conversation
|
Are there any objections for this PR? |
Do we know when the behavior changed? So do we need to guard this behavior with a specific Windows version constraint at which the default button style changed? |
|
Unfortunately, I don't have older Windows 10 versions to test. |
|
Did you take a look into the original bug report to maybe find out why that code was introduced, i.e., how the strange default behavior of Windows buttons was detected? There might be some pointer to where you could look up if/when that behavior changed. Or maybe there is at least some information that can be used as input for an AI agent making according research. |
|
I just want to mention that there is a general problem with the alignment when both text and image is set. See #519. Perhaps something was missed in that fix? |
|
That's a great pointer, thank you. I just reverted the referenced change for the sake of testing and see the disabled buttons not considering the alignment again (using the snippet from #3277). |
There was a problem hiding this comment.
Pull request overview
This PR updates Win32 button custom drawing so enabled buttons with both image and text can honor SWT text alignment instead of always forcing left-aligned text.
Changes:
- Adds extra text margin when a non-check/radio button has an image.
- Removes the special-case image path that forced
DT_LEFT, allowing existing left/right/center alignment logic to apply.
HeikoKlare
left a comment
There was a problem hiding this comment.
In general, the change looks sound to me. We do not need to guard this behavior in any way, now that we understood that the inconsistency came from:
I further tested with Issue0519_ButtonAlignmentExample added in the mentioned PR. I extended it with setting foreground for the buttons as done in the snippet for the issue to be solved by this PR, and I added a checkbox to enable/disable the buttons. You can see that the alignment of texts in enabled and disabled buttons does not fit for every alignment setting:


@tmssngr can you please extend the mentioned example for this PR to reflect the issue to be solved as well and further enhance the PR so that we see the alignment issues fixed there?
This aligns the custom-drawn (enabled) text drawing with the system rendering (disabled).
d3b5ec6 to
c373a8b
Compare
|
@HeikoKlare I've updated |
It looks like the old comment
The default button with an image doesn't respect the text alignment. So we do the same for styled buttons.is outdated.