mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Add helper methods on Visibility
(#14898)
Fixes #14825 Edit: After feedback, these are the updated methods: - `toggle_inherited_visible(&mut self)` - Toggles between `Visibility::Inherited` and `Visibility::Visible`. If the value is `Visibility::Hidden`, it remains unaffected. - `toggle_inherited_hidden(&mut self)` - Toggles between `Visibility::Inherited` and `Visibility::Hidden`. If the value is `Visibility::Visible`, it remains unaffected. - `toggle_visible_hidden(&mut self)` - Toggles between `Visibility::Visible` and `Visibility::Hidden`. If the value is `Visibility::Inherited`, it remains unaffected. --------- Co-authored-by: Chris Russell <8494645+chescock@users.noreply.github.com>
This commit is contained in:
parent
cccc1137b4
commit
0070bdccd8
1 changed files with 33 additions and 0 deletions
|
@ -47,6 +47,39 @@ pub enum Visibility {
|
|||
Visible,
|
||||
}
|
||||
|
||||
impl Visibility {
|
||||
/// Toggles between `Visibility::Inherited` and `Visibility::Visible`.
|
||||
/// If the value is `Visibility::Hidden`, it remains unaffected.
|
||||
#[inline]
|
||||
pub fn toggle_inherited_visible(&mut self) {
|
||||
*self = match *self {
|
||||
Visibility::Inherited => Visibility::Visible,
|
||||
Visibility::Visible => Visibility::Inherited,
|
||||
_ => *self,
|
||||
};
|
||||
}
|
||||
/// Toggles between `Visibility::Inherited` and `Visibility::Hidden`.
|
||||
/// If the value is `Visibility::Visible`, it remains unaffected.
|
||||
#[inline]
|
||||
pub fn toggle_inherited_hidden(&mut self) {
|
||||
*self = match *self {
|
||||
Visibility::Inherited => Visibility::Hidden,
|
||||
Visibility::Hidden => Visibility::Inherited,
|
||||
_ => *self,
|
||||
};
|
||||
}
|
||||
/// Toggles between `Visibility::Visible` and `Visibility::Hidden`.
|
||||
/// If the value is `Visibility::Inherited`, it remains unaffected.
|
||||
#[inline]
|
||||
pub fn toggle_visible_hidden(&mut self) {
|
||||
*self = match *self {
|
||||
Visibility::Visible => Visibility::Hidden,
|
||||
Visibility::Hidden => Visibility::Visible,
|
||||
_ => *self,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Allows `&Visibility == Visibility`
|
||||
impl PartialEq<Visibility> for &Visibility {
|
||||
#[inline]
|
||||
|
|
Loading…
Reference in a new issue