DockBuilder

Struct DockBuilder 

Source
pub struct DockBuilder;
Expand description

DockBuilder API for programmatic dock layout creation

Implementations§

Source§

impl DockBuilder

Source

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.

Source

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.

Source

pub fn node_exists(ui: &Ui, node_id: Id) -> bool

Returns true if a dock node with the given ID exists this frame.

Source

pub fn add_node(node_id: Id, flags: DockNodeFlags) -> Id

Adds a new dock node

§Parameters
  • node_id - The ID for the new dock node (use 0 to auto-generate)
  • flags - Dock node flags
§Returns

The ID of the created dock node

§Example
let node_id = DockBuilder::add_node(0, DockNodeFlags::NO_RESIZE);
Source

pub fn remove_node(node_id: Id)

Removes a dock node

§Parameters
  • node_id - The ID of the dock node to remove
§Example
DockBuilder::remove_node(123);
Source

pub fn remove_node_docked_windows(node_id: Id, clear_settings_refs: bool)

Removes all docked windows from a node

§Parameters
  • node_id - The ID of the dock node
  • clear_settings_refs - Whether to clear settings references
§Example
DockBuilder::remove_node_docked_windows(123, true);
Source

pub fn remove_node_child_nodes(node_id: Id)

Removes all child nodes from a dock node

§Parameters
  • node_id - The ID of the dock node
§Example
DockBuilder::remove_node_child_nodes(123);
Source

pub fn set_node_pos(node_id: Id, pos: [f32; 2])

Sets the position of a dock node

§Parameters
  • node_id - The ID of the dock node
  • pos - The position in pixels
§Example
DockBuilder::set_node_pos(123, [100.0, 50.0]);
Source

pub fn set_node_size(node_id: Id, size: [f32; 2])

Sets the size of a dock node

§Parameters
  • node_id - The ID of the dock node
  • size - The size in pixels
§Example
DockBuilder::set_node_size(123, [800.0, 600.0]);
Source

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 split
  • split_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 direction
  • id_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_id becomes a parent node after splitting
  • Call DockBuilder::finish() after all layout operations are complete
Source

pub fn dock_window(window_name: &str, node_id: Id)

Docks a window to a specific dock node

§Parameters
  • window_name - The name of the window to dock
  • node_id - The ID of the dock node to dock the window to
§Example
DockBuilder::dock_window("My Tool", 123);
Source

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.

Source

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.

Source

pub fn copy_window_settings(src_name: &str, dst_name: &str)

Copies persistent window docking settings from src_name to dst_name.

Source

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.

Source

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.

Source

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);

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more