-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Changed ui.disable()
to modify opacity.
#6765
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
base: main
Are you sure you want to change the base?
Conversation
It previously tinted elements, which could have lackluster effects.
This has far-reaching consequences for the visual of existing egui apps other than just fixing the linked issue. I think this change should be configurable; otherwise, significant considerations should be put into messing up existing visuals. |
That's a fair viewpoint. What other possible solutions to this issue do you recommend? I tried modifying the Relevant method: Lines 1055 to 1060 in 5d6aaa2
Out of interest in which situations will this be an issue for (so I could potentially work on solving them)? |
The problem is exactly what you mentioned in the I believe that a method of fading out (color or transparency) should be an option in the style. Maybe as an enum variant akin to
the exact shape of variants and naming should be discussed ofc |
I agree with being able to override the fade out colour, but that does lean towards a more major change, as Also adding more default colours increases the maintenance burden in the future. i'm not sure if that would be needed if the user can customise the fade out colour. |
A possible option for setting a custom fade out colour would be to add a feild like |
Preview available at https://egui-pr-preview.github.io/pr/6765-defaultaffectsopacity |
@@ -521,8 +521,7 @@ impl Ui { | |||
pub fn disable(&mut self) { | |||
self.enabled = false; | |||
if self.is_visible() { | |||
self.painter | |||
.set_fade_to_color(Some(self.visuals().fade_out_to_color())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also remove Visuals::fade_out_to_color
too, and replace it with fn fade_out_opacity(&self) -> f32 { 0.5 }
and use it for Visuals::gray_out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be best to deprecate it or completely remove it?
If so what should the deprecation message be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be best to deprecate it or completely remove it? If so what should the deprecation message be?
I chose to remove it completely as there was no other calls to it.
"fade_out_to_color" was replaced by "fade_out_opacity" for this purpose.
Will it be a good idea to add an attribute to Because currently the value is hard-coded, so it cannot be changed. |
I have added the option for user-customization that i suggested & created a pull request against the branch in my fork for anyone to look at. I can easily merge these changes into the branch in this egui pull request. |
It previously tinted elements, which could have lackluster effects.
New looks
(I say new but I tried to keep them as similar as possible to previous)
Light mode
light_mode.webm
Dark mode
dark_mode.webm
Additional remarks
Since the opacity is being change, elements that are on-top of other elements now show some of the underneath element (this can be seen with the slider in the sent videos).