dear_imgui/widget/
mod.rs

1use crate::sys;
2
3pub mod button;
4pub mod color;
5pub mod combo;
6pub mod drag;
7pub mod image;
8pub mod input;
9pub mod list_box;
10pub mod menu;
11pub mod misc;
12pub mod plot;
13pub mod popup;
14pub mod progress;
15pub mod selectable;
16pub mod slider;
17pub mod tab;
18pub mod table;
19pub mod text;
20pub mod tooltip;
21pub mod tree;
22
23// Re-export important types
24pub use popup::PopupFlags;
25pub use table::{TableBgTarget, TableBuilder, TableColumnSetup};
26
27// Widget implementations
28pub use self::button::*;
29pub use self::color::*;
30pub use self::combo::*;
31pub use self::drag::*;
32pub use self::image::*;
33pub use self::input::*;
34pub use self::list_box::*;
35pub use self::menu::*;
36pub use self::misc::*;
37pub use self::plot::*;
38pub use self::popup::*;
39pub use self::progress::*;
40pub use self::selectable::*;
41pub use self::slider::*;
42pub use self::tab::*;
43pub use self::table::*;
44pub use self::tooltip::*;
45pub use self::tree::*;
46
47// ButtonFlags is defined in misc.rs and re-exported
48
49bitflags::bitflags! {
50    /// Flags for tree node widgets
51    #[repr(transparent)]
52    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
53    pub struct TreeNodeFlags: i32 {
54        /// No flags
55        const NONE = 0;
56        /// Draw as selected
57        const SELECTED = sys::ImGuiTreeNodeFlags_Selected as i32;
58        /// Draw frame with background (e.g. for CollapsingHeader)
59        const FRAMED = sys::ImGuiTreeNodeFlags_Framed as i32;
60        /// Hit testing to allow subsequent widgets to overlap this one
61        const ALLOW_ITEM_OVERLAP = sys::ImGuiTreeNodeFlags_AllowOverlap as i32;
62        /// Don't do a TreePush() when open (e.g. for CollapsingHeader) = no extra indent nor pushing on ID stack
63        const NO_TREE_PUSH_ON_OPEN = sys::ImGuiTreeNodeFlags_NoTreePushOnOpen as i32;
64        /// Don't automatically and temporarily open node when Logging is active (by default logging will automatically open tree nodes)
65        const NO_AUTO_OPEN_ON_LOG = sys::ImGuiTreeNodeFlags_NoAutoOpenOnLog as i32;
66        /// Default node to be open
67        const DEFAULT_OPEN = sys::ImGuiTreeNodeFlags_DefaultOpen as i32;
68        /// Need double-click to open node
69        const OPEN_ON_DOUBLE_CLICK = sys::ImGuiTreeNodeFlags_OpenOnDoubleClick as i32;
70        /// Only open when clicking on the arrow part. If ImGuiTreeNodeFlags_OpenOnDoubleClick is also set, single-click arrow or double-click all box to open.
71        const OPEN_ON_ARROW = sys::ImGuiTreeNodeFlags_OpenOnArrow as i32;
72        /// No collapsing, no arrow (use as a convenience for leaf nodes)
73        const LEAF = sys::ImGuiTreeNodeFlags_Leaf as i32;
74        /// Display a bullet instead of arrow
75        const BULLET = sys::ImGuiTreeNodeFlags_Bullet as i32;
76        /// Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding().
77        const FRAME_PADDING = sys::ImGuiTreeNodeFlags_FramePadding as i32;
78        /// Extend hit box to the right-most edge, even if not framed. This is not the default in order to allow adding other items on the same line. In the future we may refactor the hit system to be front-to-back, allowing natural overlaps and then this can become the default.
79        const SPAN_AVAIL_WIDTH = sys::ImGuiTreeNodeFlags_SpanAvailWidth as i32;
80        /// Extend hit box to the left-most and right-most edges (bypass the indented area).
81        const SPAN_FULL_WIDTH = sys::ImGuiTreeNodeFlags_SpanFullWidth as i32;
82        /// (WIP) Nav: left direction goes to parent. Only for the tree node, not the tree push.
83        const NAV_LEFT_JUMPS_BACK_HERE = sys::ImGuiTreeNodeFlags_NavLeftJumpsToParent as i32;
84        /// Combination of Leaf and NoTreePushOnOpen
85        const COLLAPSING_HEADER = Self::FRAMED.bits() | Self::NO_TREE_PUSH_ON_OPEN.bits();
86    }
87}
88
89bitflags::bitflags! {
90    /// Flags for combo box widgets
91    #[repr(transparent)]
92    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
93    pub struct ComboBoxFlags: i32 {
94        /// No flags
95        const NONE = 0;
96        /// Align the popup toward the left by default
97        const POPUP_ALIGN_LEFT = sys::ImGuiComboFlags_PopupAlignLeft as i32;
98        /// Max ~4 items visible. Tip: If you want your combo popup to be a specific size you can use SetNextWindowSizeConstraints() prior to calling BeginCombo()
99        const HEIGHT_SMALL = sys::ImGuiComboFlags_HeightSmall as i32;
100        /// Max ~8 items visible (default)
101        const HEIGHT_REGULAR = sys::ImGuiComboFlags_HeightRegular as i32;
102        /// Max ~20 items visible
103        const HEIGHT_LARGE = sys::ImGuiComboFlags_HeightLarge as i32;
104        /// As many fitting items as possible
105        const HEIGHT_LARGEST = sys::ImGuiComboFlags_HeightLargest as i32;
106        /// Display on the preview box without the square arrow button
107        const NO_ARROW_BUTTON = sys::ImGuiComboFlags_NoArrowButton as i32;
108        /// Display only a square arrow button
109        const NO_PREVIEW = sys::ImGuiComboFlags_NoPreview as i32;
110        /// Width dynamically calculated from preview contents
111        const WIDTH_FIT_PREVIEW = sys::ImGuiComboFlags_WidthFitPreview as i32;
112    }
113}
114
115bitflags::bitflags! {
116    /// Flags for table widgets
117    #[repr(transparent)]
118    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
119    pub struct TableFlags: i32 {
120        /// No flags
121        const NONE = 0;
122        /// Enable resizing columns
123        const RESIZABLE = sys::ImGuiTableFlags_Resizable as i32;
124        /// Enable reordering columns in header row (need calling TableSetupColumn() + TableHeadersRow() to display headers)
125        const REORDERABLE = sys::ImGuiTableFlags_Reorderable as i32;
126        /// Enable hiding/disabling columns in context menu
127        const HIDEABLE = sys::ImGuiTableFlags_Hideable as i32;
128        /// Enable sorting. Call TableGetSortSpecs() to obtain sort specs. Also see ImGuiTableFlags_SortMulti and ImGuiTableFlags_SortTristate.
129        const SORTABLE = sys::ImGuiTableFlags_Sortable as i32;
130        /// Disable persisting columns order, width and sort settings in the .ini file
131        const NO_SAVED_SETTINGS = sys::ImGuiTableFlags_NoSavedSettings as i32;
132        /// Right-click on columns body/contents will display table context menu. By default it is available in TableHeadersRow().
133        const CONTEXT_MENU_IN_BODY = sys::ImGuiTableFlags_ContextMenuInBody as i32;
134        /// Set each RowBg color with ImGuiCol_TableRowBg or ImGuiCol_TableRowBgAlt (equivalent of calling TableSetBgColor with ImGuiTableBgFlags_RowBg0 on each row manually)
135        const ROW_BG = sys::ImGuiTableFlags_RowBg as i32;
136        /// Draw horizontal borders between rows
137        const BORDERS_INNER_H = sys::ImGuiTableFlags_BordersInnerH as i32;
138        /// Draw horizontal borders at the top and bottom
139        const BORDERS_OUTER_H = sys::ImGuiTableFlags_BordersOuterH as i32;
140        /// Draw vertical borders between columns
141        const BORDERS_INNER_V = sys::ImGuiTableFlags_BordersInnerV as i32;
142        /// Draw vertical borders on the left and right sides
143        const BORDERS_OUTER_V = sys::ImGuiTableFlags_BordersOuterV as i32;
144        /// Draw horizontal borders
145        const BORDERS_H = Self::BORDERS_INNER_H.bits() | Self::BORDERS_OUTER_H.bits();
146        /// Draw vertical borders
147        const BORDERS_V = Self::BORDERS_INNER_V.bits() | Self::BORDERS_OUTER_V.bits();
148        /// Draw inner borders
149        const BORDERS_INNER = Self::BORDERS_INNER_V.bits() | Self::BORDERS_INNER_H.bits();
150        /// Draw outer borders
151        const BORDERS_OUTER = Self::BORDERS_OUTER_V.bits() | Self::BORDERS_OUTER_H.bits();
152        /// Draw all borders
153        const BORDERS = Self::BORDERS_INNER.bits() | Self::BORDERS_OUTER.bits();
154        /// [ALPHA] Disable vertical borders in columns Body (borders will always appears in Headers). -> May move to style
155        const NO_BORDERS_IN_BODY = sys::ImGuiTableFlags_NoBordersInBody as i32;
156        /// [ALPHA] Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers). -> May move to style
157        const NO_BORDERS_IN_BODY_UNTIL_RESIZE = sys::ImGuiTableFlags_NoBordersInBodyUntilResize as i32;
158        /// Columns default to _WidthFixed or _WidthAuto (if resizable or not resizable), matching contents width
159        const SIZING_FIXED_FIT = sys::ImGuiTableFlags_SizingFixedFit as i32;
160        /// Columns default to _WidthFixed or _WidthAuto (if resizable or not resizable), matching the maximum contents width of all columns. Implicitly enable ImGuiTableFlags_NoKeepColumnsVisible.
161        const SIZING_FIXED_SAME = sys::ImGuiTableFlags_SizingFixedSame as i32;
162        /// Columns default to _WidthStretch with default weights proportional to each columns contents widths.
163        const SIZING_STRETCH_PROP = sys::ImGuiTableFlags_SizingStretchProp as i32;
164        /// Columns default to _WidthStretch with default weights all equal, unless overridden by TableSetupColumn().
165        const SIZING_STRETCH_SAME = sys::ImGuiTableFlags_SizingStretchSame as i32;
166        /// Make outer width auto-fit to columns, overriding outer_size.x value. Only available when ScrollX/ScrollY are disabled and Stretch columns are not used.
167        const NO_HOST_EXTEND_X = sys::ImGuiTableFlags_NoHostExtendX as i32;
168        /// Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit). Only available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible.
169        const NO_HOST_EXTEND_Y = sys::ImGuiTableFlags_NoHostExtendY as i32;
170        /// Disable keeping column always minimally visible when ScrollX is on and table gets too small. Not recommended if columns are resizable.
171        const NO_KEEP_COLUMNS_VISIBLE = sys::ImGuiTableFlags_NoKeepColumnsVisible as i32;
172        /// Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth.
173        const PRECISE_WIDTHS = sys::ImGuiTableFlags_PreciseWidths as i32;
174        /// Disable clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow into other columns). Generally incompatible with TableSetupScrollFreeze().
175        const NO_CLIP = sys::ImGuiTableFlags_NoClip as i32;
176        /// Default if BordersOuterV is on. Enable outer-most padding. Generally desirable if you have headers.
177        const PAD_OUTER_X = sys::ImGuiTableFlags_PadOuterX as i32;
178        /// Default if BordersOuterV is off. Disable outer-most padding.
179        const NO_PAD_OUTER_X = sys::ImGuiTableFlags_NoPadOuterX as i32;
180        /// Disable inner padding between columns (double inner padding if BordersOuterV is on, single inner padding if BordersOuterV is off).
181        const NO_PAD_INNER_X = sys::ImGuiTableFlags_NoPadInnerX as i32;
182        /// Enable horizontal scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size. Changes default sizing policy. Because this creates a child window, ScrollY is currently generally recommended when using ScrollX.
183        const SCROLL_X = sys::ImGuiTableFlags_ScrollX as i32;
184        /// Enable vertical scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size.
185        const SCROLL_Y = sys::ImGuiTableFlags_ScrollY as i32;
186        /// Hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1).
187        const SORT_MULTI = sys::ImGuiTableFlags_SortMulti as i32;
188        /// Allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0).
189        const SORT_TRISTATE = sys::ImGuiTableFlags_SortTristate as i32;
190        /// Highlight column headers when hovered (may not be visible if table header is declaring a background color)
191        const HIGHLIGHT_HOVERED_COLUMN = sys::ImGuiTableFlags_HighlightHoveredColumn as i32;
192    }
193}
194
195bitflags::bitflags! {
196    /// Flags for table columns
197    #[repr(transparent)]
198    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
199    pub struct TableColumnFlags: i32 {
200        /// No flags
201        const NONE = 0;
202        /// Overriding width becomes fixed width
203        const WIDTH_FIXED = sys::ImGuiTableColumnFlags_WidthFixed as i32;
204        /// Overriding width becomes weight
205        const WIDTH_STRETCH = sys::ImGuiTableColumnFlags_WidthStretch as i32;
206        /// Disable manual resizing
207        const NO_RESIZE = sys::ImGuiTableColumnFlags_NoResize as i32;
208        /// Disable manual reordering this column
209        const NO_REORDER = sys::ImGuiTableColumnFlags_NoReorder as i32;
210        /// Disable ability to hide/disable this column
211        const NO_HIDE = sys::ImGuiTableColumnFlags_NoHide as i32;
212        /// Disable clipping for this column
213        const NO_CLIP = sys::ImGuiTableColumnFlags_NoClip as i32;
214        /// Disable ability to sort on this field
215        const NO_SORT = sys::ImGuiTableColumnFlags_NoSort as i32;
216        /// Disable ability to sort in the ascending direction
217        const NO_SORT_ASCENDING = sys::ImGuiTableColumnFlags_NoSortAscending as i32;
218        /// Disable ability to sort in the descending direction
219        const NO_SORT_DESCENDING = sys::ImGuiTableColumnFlags_NoSortDescending as i32;
220        /// TableHeadersRow() will not submit label for this column
221        const NO_HEADER_LABEL = sys::ImGuiTableColumnFlags_NoHeaderLabel as i32;
222        /// Disable header text width contribution to automatic column width
223        const NO_HEADER_WIDTH = sys::ImGuiTableColumnFlags_NoHeaderWidth as i32;
224        /// Make the initial sort direction Ascending when first sorting on this column
225        const PREFER_SORT_ASCENDING = sys::ImGuiTableColumnFlags_PreferSortAscending as i32;
226        /// Make the initial sort direction Descending when first sorting on this column
227        const PREFER_SORT_DESCENDING = sys::ImGuiTableColumnFlags_PreferSortDescending as i32;
228        /// Use current Indent value when entering cell
229        const INDENT_ENABLE = sys::ImGuiTableColumnFlags_IndentEnable as i32;
230        /// Disable indenting for this column
231        const INDENT_DISABLE = sys::ImGuiTableColumnFlags_IndentDisable as i32;
232        /// Display an angled header for this column (when angled headers feature is enabled)
233        const ANGLED_HEADER = sys::ImGuiTableColumnFlags_AngledHeader as i32;
234        /// Status: is enabled == not hidden
235        const IS_ENABLED = sys::ImGuiTableColumnFlags_IsEnabled as i32;
236        /// Status: is visible == is enabled AND not clipped by scrolling
237        const IS_VISIBLE = sys::ImGuiTableColumnFlags_IsVisible as i32;
238        /// Status: is currently part of the sort specs
239        const IS_SORTED = sys::ImGuiTableColumnFlags_IsSorted as i32;
240        /// Status: is hovered by mouse
241        const IS_HOVERED = sys::ImGuiTableColumnFlags_IsHovered as i32;
242    }
243}