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

Fix label color blending #4203

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Sep 27, 2024

Problem

If you apply multiple labels to the same mod, some weird visual artifacts can happen; the affected row can have the text of multiple mods overlapping each other:

image

Causes

  • Apparently DataGridView can only handle row colors with an alpha channel of 0 or 255; if you set anything in between, it gets confused and basically seems to not paint the row
  • If a label has a transparent background color, blending it with a solid color produces an alpha channel of 127, which confuses the grid as per above
  • Util.BlendColors is implemented in terms of Util.AlphaBlendWith, which uses a floating point alpha channel to compute what it would look like if one color was overlaid over the other with the given level of transparency. Unfortunately, even for two colors with an alpha channel of 255, this can produce a blended color with an alpha channel of 254, which is still enough to confuse the grid.

Changes

  • Now when we blend label colors, transparent labels are excluded
  • Now label color blending is done with integer math only, so no rounding errors can creep into the alpha channel

Fixes #4202.

@HebaruSan HebaruSan added Bug Something is not working as intended Easy This is easy to fix GUI Issues affecting the interactive GUI labels Sep 27, 2024
@HebaruSan HebaruSan merged commit aa22570 into KSP-CKAN:master Sep 27, 2024
3 of 4 checks passed
@HebaruSan HebaruSan deleted the fix/label-color-blending branch September 27, 2024 21:22
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 Easy This is easy to fix GUI Issues affecting the interactive GUI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Display problem when multiple labels are used
1 participant