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

Add ability to hide button backgrounds #2621

Merged
merged 13 commits into from
Jan 24, 2023
Merged

Conversation

emilk
Copy link
Owner

@emilk emilk commented Jan 23, 2023

With this PR you can turn off background for buttons.

This required a bit of work. We want to be able to turn off background colors for buttons, comboboxes, dragvalues, etc, but keep them for checkbox-boxes, radiobutton-circles, slider-backgrounds, etc. Previously these were all controlled by WidgetVisuals::bg_fill. Now a new WidgetVisuals::optional_bg_fill WidgetVisuals::weak_bg_fill has been added, which is used by buttons, comboboxes, dragvalues etc. weak_bg_fill can be safely set to Color32::TRANSPARENT without messing up checkboxes, radiobuttons, sliders, etc. I don't really like the name optional_bg_fill, and suggestions are welcome. I kept the old bg_fill named as-is, to avoid breaking to much 3rd party code.

Turning off the background on ComboBoxes requires making them tighter, to keep the arrow close to the text, so Spacing::combo_width was added.

En example of this style:

image

@emilk emilk changed the title Styling improvements Add ability to hide button backgrounds Jan 23, 2023
@Wumpf Wumpf self-requested a review January 23, 2023 19:21
Copy link
Collaborator

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

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

weak_bg_fill? then one could distinguish between elements having regular vs weak backgrounds. Essentially it comes down to having different kinds of backgrounds that can be styled individually, less so much about them being allowed to be transparent, no?

crates/egui/src/containers/combo_box.rs Outdated Show resolved Hide resolved
emilk and others added 2 commits January 24, 2023 09:50
Co-authored-by: Andreas Reich <andreas@rerun.io>
@emilk emilk merged commit 4bd4eca into master Jan 24, 2023
@emilk emilk deleted the emilk/styling-improvements branch January 24, 2023 09:11
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.

None yet

2 participants