use bitflags::bitflags; use std::borrow::Cow; use crate::sys; use crate::Ui; // TODO: support size constraints /// Combo box height mode. #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum ComboBoxHeight { /// Max ~4 items visible. Small, /// Max ~8 items visible. Regular, /// Max ~20 items visible. Large, /// As many fitting items as possible visible. Largest, } /// Combo box preview mode. #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum ComboBoxPreviewMode { /// Show only a box with the preview value Label, /// Show only an arrow button ArrowButton, /// Show a box with the preview value and an arrow button Full, } bitflags!( /// Flags for combo boxes #[repr(transparent)] pub struct ComboBoxFlags: u32 { /// Align the popup toward the left by default const POPUP_ALIGN_LEFT = sys::ImGuiComboFlags_PopupAlignLeft; /// Max ~4 items visible. const HEIGHT_SMALL = sys::ImGuiComboFlags_HeightSmall; /// Max ~8 items visible (default) const HEIGHT_REGULAR = sys::ImGuiComboFlags_HeightRegular; /// Max ~20 items visible const HEIGHT_LARGE = sys::ImGuiComboFlags_HeightLarge; /// As many fitting items as possible const HEIGHT_LARGEST = sys::ImGuiComboFlags_HeightLargest; /// Display on the preview box without the square arrow button const NO_ARROW_BUTTON = sys::ImGuiComboFlags_NoArrowButton; /// Display only a square arrow button const NO_PREVIEW = sys::ImGuiComboFlags_NoPreview; } ); /// Builder for a combo box widget #[derive(Copy, Clone, Debug)] #[must_use] pub struct ComboBox { label: Label, preview_value: Option, flags: ComboBoxFlags, } impl> ComboBox