Skip to main content

dear_imgui_rs/dock_space/
flags.rs

1use crate::sys;
2
3bitflags::bitflags! {
4    /// Flags accepted when submitting a dockspace.
5    #[repr(transparent)]
6    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7    pub struct DockNodeFlags: i32 {
8        /// No flags
9        const NONE = sys::ImGuiDockNodeFlags_None as i32;
10        /// Don't display the dockspace node but keep it alive. Windows docked into this dockspace node won't be undocked.
11        const KEEP_ALIVE_ONLY = sys::ImGuiDockNodeFlags_KeepAliveOnly as i32;
12        /// Disable docking over the Central Node, which will be always kept empty.
13        const NO_DOCKING_OVER_CENTRAL_NODE = sys::ImGuiDockNodeFlags_NoDockingOverCentralNode as i32;
14        /// Enable passthru dockspace: 1) DockSpace() will render a ImGuiCol_WindowBg background covering everything excepted the Central Node when empty. 2) When Central Node is empty: let inputs pass-through + won't display a DockingEmptyBg background.
15        const PASSTHRU_CENTRAL_NODE = sys::ImGuiDockNodeFlags_PassthruCentralNode as i32;
16        /// Disable other windows/nodes from splitting this node.
17        const NO_DOCKING_SPLIT = sys::ImGuiDockNodeFlags_NoDockingSplit as i32;
18        /// Disable resizing node using the splitter/separators. Useful with programmatically setup dockspaces.
19        const NO_RESIZE = sys::ImGuiDockNodeFlags_NoResize as i32;
20        /// Tab bar will automatically hide when there is a single window in the dock node.
21        const AUTO_HIDE_TAB_BAR = sys::ImGuiDockNodeFlags_AutoHideTabBar as i32;
22        /// Disable undocking this node.
23        const NO_UNDOCKING = sys::ImGuiDockNodeFlags_NoUndocking as i32;
24    }
25}
26
27pub(crate) fn validate_dock_node_flags(caller: &str, flags: DockNodeFlags) {
28    let unsupported = flags.bits() & !DockNodeFlags::all().bits();
29    assert!(
30        unsupported == 0,
31        "{caller} received unsupported ImGuiDockNodeFlags bits: 0x{unsupported:X}"
32    );
33}
34
35bitflags::bitflags! {
36    /// Dock-node policies contributed by every window using a [`crate::WindowClass`].
37    ///
38    /// Dear ImGui combines these flags across all windows in the same dock node. Dockspace
39    /// submission controls such as [`DockNodeFlags::KEEP_ALIVE_ONLY`] and
40    /// [`DockNodeFlags::PASSTHRU_CENTRAL_NODE`] are intentionally not part of this type.
41    /// Several policies mirror version-pinned experimental Dear ImGui node behavior, but remain
42    /// memory-safe because they do not accept caller-owned pointers or topology identities.
43    ///
44    /// These policies are a separate semantic domain from dockspace submission flags:
45    ///
46    /// ```compile_fail
47    /// # use dear_imgui_rs::{DockNodeFlags, WindowClass};
48    /// let class = WindowClass::default()
49    ///     .dock_node_flags_override_set(DockNodeFlags::NO_RESIZE);
50    /// # let _ = class;
51    /// ```
52    #[repr(transparent)]
53    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
54    pub struct WindowClassDockNodeFlags: i32 {
55        /// No dock-node policy.
56        const NONE = sys::ImGuiDockNodeFlags_None as i32;
57        /// Prevent docking over a central node.
58        const NO_DOCKING_OVER_CENTRAL_NODE =
59            sys::ImGuiDockNodeFlags_NoDockingOverCentralNode as i32;
60        /// Prevent other windows or nodes from splitting this node.
61        const NO_DOCKING_SPLIT = sys::ImGuiDockNodeFlags_NoDockingSplit as i32;
62        /// Prevent splitter resizing.
63        const NO_RESIZE = sys::ImGuiDockNodeFlags_NoResize as i32;
64        /// Hide the tab bar automatically when the node contains one window.
65        const AUTO_HIDE_TAB_BAR = sys::ImGuiDockNodeFlags_AutoHideTabBar as i32;
66        /// Prevent windows from being undocked from this node.
67        const NO_UNDOCKING = sys::ImGuiDockNodeFlags_NoUndocking as i32;
68        /// Never create a tab bar for this node.
69        const NO_TAB_BAR = sys::ImGuiDockNodeFlags_NoTabBar as i32;
70        /// Keep the existing tab bar hidden.
71        const HIDDEN_TAB_BAR = sys::ImGuiDockNodeFlags_HiddenTabBar as i32;
72        /// Hide the tab-bar window menu button.
73        const NO_WINDOW_MENU_BUTTON = sys::ImGuiDockNodeFlags_NoWindowMenuButton as i32;
74        /// Hide the tab-bar close button.
75        const NO_CLOSE_BUTTON = sys::ImGuiDockNodeFlags_NoCloseButton as i32;
76        /// Prevent horizontal splitter resizing.
77        const NO_RESIZE_X = sys::ImGuiDockNodeFlags_NoResizeX as i32;
78        /// Prevent vertical splitter resizing.
79        const NO_RESIZE_Y = sys::ImGuiDockNodeFlags_NoResizeY as i32;
80        /// Include docked windows in their host window's focus route.
81        const DOCKED_WINDOWS_IN_FOCUS_ROUTE =
82            sys::ImGuiDockNodeFlags_DockedWindowsInFocusRoute as i32;
83        /// Prevent this node from splitting another node while docking.
84        const NO_DOCKING_SPLIT_OTHER = sys::ImGuiDockNodeFlags_NoDockingSplitOther as i32;
85        /// Prevent other payloads from docking over this node.
86        const NO_DOCKING_OVER_ME = sys::ImGuiDockNodeFlags_NoDockingOverMe as i32;
87        /// Prevent this payload from docking over another non-empty node.
88        const NO_DOCKING_OVER_OTHER = sys::ImGuiDockNodeFlags_NoDockingOverOther as i32;
89        /// Prevent this payload from docking over an empty node.
90        const NO_DOCKING_OVER_EMPTY = sys::ImGuiDockNodeFlags_NoDockingOverEmpty as i32;
91        /// Prevent all docking operations involving this node.
92        const NO_DOCKING = sys::ImGuiDockNodeFlags_NoDocking as i32;
93    }
94}