pub struct DockBuilder;Expand description
DockBuilder API for programmatic dock layout creation
Implementations§
Source§impl DockBuilder
impl DockBuilder
Sourcepub fn node<'ui>(_ui: &'ui Ui, node_id: Id) -> Option<DockNode<'ui>>
pub fn node<'ui>(_ui: &'ui Ui, node_id: Id) -> Option<DockNode<'ui>>
Returns a reference to a dock node by ID, scoped to the current frame.
Sourcepub fn central_node<'ui>(
_ui: &'ui Ui,
dockspace_id: Id,
) -> Option<DockNode<'ui>>
pub fn central_node<'ui>( _ui: &'ui Ui, dockspace_id: Id, ) -> Option<DockNode<'ui>>
Returns the central node for a given dockspace ID, scoped to the current frame.
Sourcepub fn node_exists(ui: &Ui, node_id: Id) -> bool
pub fn node_exists(ui: &Ui, node_id: Id) -> bool
Returns true if a dock node with the given ID exists this frame.
Sourcepub fn add_node(node_id: Id, flags: DockNodeFlags) -> Id
pub fn add_node(node_id: Id, flags: DockNodeFlags) -> Id
Sourcepub fn remove_node(node_id: Id)
pub fn remove_node(node_id: Id)
Sourcepub fn remove_node_docked_windows(node_id: Id, clear_settings_refs: bool)
pub fn remove_node_docked_windows(node_id: Id, clear_settings_refs: bool)
Sourcepub fn remove_node_child_nodes(node_id: Id)
pub fn remove_node_child_nodes(node_id: Id)
Sourcepub fn set_node_pos(node_id: Id, pos: [f32; 2])
pub fn set_node_pos(node_id: Id, pos: [f32; 2])
Sourcepub fn set_node_size(node_id: Id, size: [f32; 2])
pub fn set_node_size(node_id: Id, size: [f32; 2])
Sourcepub fn split_node(
node_id: Id,
split_dir: SplitDirection,
size_ratio_for_node_at_dir: f32,
) -> (Id, Id)
pub fn split_node( node_id: Id, split_dir: SplitDirection, size_ratio_for_node_at_dir: f32, ) -> (Id, Id)
Splits a dock node into two child nodes.
This function splits the specified dock node in the given direction, creating two child nodes. The original node becomes a parent node containing the two new child nodes.
§Parameters
node_id- The ID of the dock node to splitsplit_dir- The direction to split (Left, Right, Up, or Down)size_ratio_for_node_at_dir- The size ratio for the new node in the split direction (0.0 to 1.0)
§Returns
A tuple (id_at_dir, id_at_opposite_dir) containing:
id_at_dir: The ID of the new node in the split directionid_at_opposite_dir: The ID of the new node in the opposite direction
§Example
let dockspace_id = ui.get_id("MyDockspace");
DockBuilder::add_node(dockspace_id, DockNodeFlags::NONE);
// Split the dockspace: 20% left panel, 80% remaining
let (left_panel, main_area) = DockBuilder::split_node(
dockspace_id,
SplitDirection::Left,
0.20
);
// Further split the main area: 70% top, 30% bottom
let (top_area, bottom_area) = DockBuilder::split_node(
main_area,
SplitDirection::Down,
0.30
);
// Dock windows to the created nodes
DockBuilder::dock_window("Left Panel", left_panel);
DockBuilder::dock_window("Main View", top_area);
DockBuilder::dock_window("Console", bottom_area);
DockBuilder::finish(dockspace_id);§Notes
- Make sure to call
DockBuilder::set_node_size()before splitting if you want reliable split sizes - The original
node_idbecomes a parent node after splitting - Call
DockBuilder::finish()after all layout operations are complete
Sourcepub fn dock_window(window_name: &str, node_id: Id)
pub fn dock_window(window_name: &str, node_id: Id)
Sourcepub fn copy_dock_space(src_dockspace_id: Id, dst_dockspace_id: Id)
pub fn copy_dock_space(src_dockspace_id: Id, dst_dockspace_id: Id)
Copies a dockspace layout from src_dockspace_id to dst_dockspace_id.
This variant does not provide window remap pairs and will copy windows by name. For advanced remapping, prefer using the raw sys bindings.
Sourcepub fn copy_node(src_node_id: Id, dst_node_id: Id)
pub fn copy_node(src_node_id: Id, dst_node_id: Id)
Copies a single dock node from src_node_id to dst_node_id.
This variant does not return node remap pairs. For detailed remap output,
use the raw sys bindings and provide an ImVector_ImGuiID buffer.
Sourcepub fn copy_window_settings(src_name: &str, dst_name: &str)
pub fn copy_window_settings(src_name: &str, dst_name: &str)
Copies persistent window docking settings from src_name to dst_name.
Sourcepub fn copy_dock_space_with_window_remap(
src_dockspace_id: Id,
dst_dockspace_id: Id,
window_remaps: &[(&str, &str)],
)
pub fn copy_dock_space_with_window_remap( src_dockspace_id: Id, dst_dockspace_id: Id, window_remaps: &[(&str, &str)], )
Copies a dockspace layout with explicit window name remapping.
Provide pairs of (src_window_name, dst_window_name). The vector will be flattened
into [src, dst, src, dst, ...] as expected by ImGui.
Sourcepub fn copy_node_with_remap_out(
src_node_id: Id,
dst_node_id: Id,
) -> Vec<(Id, Id)>
pub fn copy_node_with_remap_out( src_node_id: Id, dst_node_id: Id, ) -> Vec<(Id, Id)>
Copies a node and returns the node ID remap pairs as a vector
of (old_id, new_id) tuples.
Sourcepub fn finish(node_id: Id)
pub fn finish(node_id: Id)
Finishes the dock builder operations
This function should be called after all dock builder operations are complete to finalize the layout.
§Parameters
node_id- The root node ID of the dock layout
§Example
// ... create layout ...
let dockspace_id = 1; // placeholder dockspace id for example
DockBuilder::finish(dockspace_id);