Skip to content
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

Suppress wrapping of status bar in Mono #2607

Merged
merged 1 commit into from
Dec 12, 2018

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Dec 8, 2018

Problem

If the status bar contains a string beyond a certain length in Mono, it'll be wrapped near the end, splitting off the last word and chopping off pieces of the letters, even if there's plenty of space in the status bar to fit:

image

image

Cause

I poked around in the mono source for a while trying to figure out what's going on, but I wasn't able to identify a clear cause. There are many layers of rendering code involved here:

  • ToolStripStatusLabel
  • ToolStripLabel
  • ToolStripItem
  • TextRenderer
  • ToolStripRenderer

At least two of these have their own special data structure for handling fonts, padding, etc., so I suspect there's a discrepancy somewhere in all of that translation between different assumptions and contexts. Specifically, I suspect they're calculating the exact size needed for the text and then passing it to a function that expects to receive a size that includes padding (and then subtracts it), but I wasn't able to confirm that. Or maybe there's simply a bug in the code that calculates the size of the text.

Interestingly, there's a one-line hack commented out (from 12 years ago!) that fixes the problem if you uncomment it:

https://github.com/mono/mono/blob/449e36638fc0b7188b2e9fbd9734a5b263ba9d22/mcs/class/System.Windows.Forms/System.Windows.Forms/ToolStripItem.cs#L1521

I think this adds enough padding to make room for the text. However, I can't guarantee that this fix wouldn't break anything else because this code is shared with controls other than the status bar label, so I've decided not to do a mono pull request for that. But this does suggest that someone was aware of this problem at one point and never got around to formulating a proper fix.

Changes

Now the font is slightly smaller and fits without wrapping:

image

I wish I could explain exactly why this fixes it, but so far all I have is, "It just does."

@HebaruSan HebaruSan added Bug Something is not working as intended GUI Issues affecting the interactive GUI Pull request Mono Issues specific for Mono labels Dec 8, 2018
@HebaruSan HebaruSan changed the title Suppress wrapping of status bar Suppress wrapping of status bar in Mono Dec 8, 2018
@politas politas merged commit 919366e into KSP-CKAN:master Dec 12, 2018
politas added a commit that referenced this pull request Dec 12, 2018
@HebaruSan HebaruSan deleted the fix/status-bar-wrap branch December 12, 2018 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended GUI Issues affecting the interactive GUI Mono Issues specific for Mono
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants