mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-16 07:58:33 +00:00
Use an enum instead of two booleans
This commit is contained in:
parent
9a82e127dc
commit
63ceb71d44
@ -30,6 +30,13 @@ pub enum EditableColorFormat {
|
||||
Float,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum EditableColorPreview {
|
||||
Opaque,
|
||||
HalfAlpha,
|
||||
Alpha,
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub struct ColorEdit<'ui, 'p> {
|
||||
label: &'p ImStr,
|
||||
@ -93,13 +100,15 @@ impl<'ui, 'p> ColorEdit<'ui, 'p> {
|
||||
self
|
||||
}
|
||||
#[inline]
|
||||
pub fn alpha_preview(mut self, value: bool) -> Self {
|
||||
self.flags.set(ImGuiColorEditFlags::AlphaPreview, value);
|
||||
self
|
||||
}
|
||||
#[inline]
|
||||
pub fn alpha_preview_half(mut self, value: bool) -> Self {
|
||||
self.flags.set(ImGuiColorEditFlags::AlphaPreviewHalf, value);
|
||||
pub fn preview(mut self, preview: EditableColorPreview) -> Self {
|
||||
self.flags.set(
|
||||
ImGuiColorEditFlags::AlphaPreviewHalf,
|
||||
preview == EditableColorPreview::HalfAlpha,
|
||||
);
|
||||
self.flags.set(
|
||||
ImGuiColorEditFlags::AlphaPreview,
|
||||
preview == EditableColorPreview::Alpha,
|
||||
);
|
||||
self
|
||||
}
|
||||
#[inline]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user