Skip to content

[Win] Enabled Image+Text button ignores alignment #3277#3282

Open
tmssngr wants to merge 2 commits into
eclipse-platform:masterfrom
syntevo:feature/3277-image-button-ignores-alignment
Open

[Win] Enabled Image+Text button ignores alignment #3277#3282
tmssngr wants to merge 2 commits into
eclipse-platform:masterfrom
syntevo:feature/3277-image-button-ignores-alignment

Conversation

@tmssngr
Copy link
Copy Markdown
Contributor

@tmssngr tmssngr commented May 5, 2026

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Test Results (win32)

   30 files  ±0     30 suites  ±0   5m 8s ⏱️ +11s
4 697 tests ±0  4 622 ✅ ±0  75 💤 ±0  0 ❌ ±0 
1 227 runs  ±0  1 203 ✅ ±0  24 💤 ±0  0 ❌ ±0 

Results for commit d3b5ec6. ± Comparison against base commit 65f43d4.

@tmssngr
Copy link
Copy Markdown
Contributor Author

tmssngr commented May 13, 2026

Are there any objections for this PR?

@HeikoKlare
Copy link
Copy Markdown
Contributor

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.

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?
The code was introduced with 0822f20 and 82b8cf4, which was after the original Windows 10 release, of which we still support some later versions.

@tmssngr
Copy link
Copy Markdown
Contributor Author

tmssngr commented May 15, 2026

Unfortunately, I don't have older Windows 10 versions to test.

@HeikoKlare
Copy link
Copy Markdown
Contributor

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.

@ptziegler
Copy link
Copy Markdown
Contributor

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?

@HeikoKlare
Copy link
Copy Markdown
Contributor

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).
So it seems like it was not a change on OS side that fixed the default button behavior but the mentioned SWT-side fix. The change proposed here may thus be considered a follow-up change to that PR to make the behavior consistent again.

Copy link
Copy Markdown

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 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.

Copy link
Copy Markdown
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

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

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:
Image
Image

@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?

Thomas Singer added 2 commits May 19, 2026 13:19
This aligns the custom-drawn (enabled) text drawing with the system
rendering (disabled).
@tmssngr tmssngr force-pushed the feature/3277-image-button-ignores-alignment branch from d3b5ec6 to c373a8b Compare May 19, 2026 11:19
@tmssngr
Copy link
Copy Markdown
Contributor Author

tmssngr commented May 19, 2026

@HeikoKlare I've updated Issue0519_ButtonAlignmentExample (like you've did) and fixed also the tiny text movements between enabled and disabled state.

@github-actions
Copy link
Copy Markdown
Contributor

Test Results

  182 files  ±0    182 suites  ±0   25m 32s ⏱️ - 1m 36s
4 723 tests ±0  4 700 ✅ ±0   23 💤 ±0  0 ❌ ±0 
6 812 runs  ±0  6 649 ✅ ±0  163 💤 ±0  0 ❌ ±0 

Results for commit c373a8b. ± Comparison against base commit 7f9089e.

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.

[Win] Enabled Image+Text button ignores alignment

4 participants