# anhosh/egui_dock architecture

> Architecture diagram of the GitHub repository anhosh/egui_dock, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anhosh/egui_dock
- Repository: https://github.com/anhosh/egui_dock

## Overview

egui_dock is a Rust docking library for egui. An application provides a DockState and implements TabViewer; DockArea displays the layout, renders tab content, and manages interactions such as closing, resizing, moving, and undocking tabs into window surfaces. Internally, DockState organizes surfaces and binary trees of leaf and split nodes. Styling, translations, and persisted egui interaction state support the user-facing area. The README documents the main workflow and capabilities; some internal connections are shown only where the supplied excerpts or source index support them.

Main entry points: [`src/widgets/dock_area/show/mod.rs`](https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/show/mod.rs) (Dock Show Logic), [`src/dock_state/tree/mod.rs`](https://github.com/anhosh/egui_dock/blob/main/src/dock_state/tree/mod.rs) (Dock Tree), [`src/widgets/dock_area/mod.rs`](https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/mod.rs) (DockArea), [`src/dock_state/mod.rs`](https://github.com/anhosh/egui_dock/blob/main/src/dock_state/mod.rs) (DockState)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_dock_area["DockArea<br/>[mod.rs]"]
  node_tab_viewer["TabViewer<br/>[tab_viewer.rs]"]
  node_utils["Utilities<br/>[utils.rs]"]
end

subgraph group_layout["Dock Layout"]
  node_dock_state["DockState<br/>[mod.rs]"]
  node_surfaces["Surfaces<br/>[surface.rs]"]
  node_window_state["Window State<br/>[window_state.rs]"]
  node_tree["Dock Tree<br/>[mod.rs]"]
  node_nodes["Tree Nodes<br/>[mod.rs]"]
  node_leaf_node["Leaf Node<br/>[leaf.rs]"]
  node_split_node["Split Node<br/>[split.rs]"]
  node_node_index["Node Index<br/>[node_index.rs]"]
  node_tab_index["Tab Index<br/>[tab_index.rs]"]
  node_tab_iter["Tab Iteration<br/>[tab_iter.rs]"]
  node_surface_index["Surface Index<br/>[surface_index.rs]"]
  node_errors["Layout Errors<br/>[error.rs]"]
end

subgraph group_interaction["Dock Interactions"]
  node_show["Dock Show Logic<br/>[mod.rs]"]
  node_dnd["Drag and Drop<br/>[drag_and_drop.rs]"]
  node_interaction_state["Interaction State<br/>[state.rs]"]
  node_tab_removal["Tab Removal<br/>[tab_removal.rs]"]
  node_allowed_splits["Allowed Splits<br/>[allowed_splits.rs]"]
end

subgraph group_presentation["Presentation"]
  node_render_main["Main Surface View<br/>[main_surface.rs]"]
  node_render_window["Window Surface View<br/>[window_surface.rs]"]
  node_render_leaf["Leaf View<br/>[leaf.rs]"]
  node_style["Dock Styling<br/>[style.rs]"]
  node_translations["Translations<br/>[translations.rs]"]
end

node_app(("Application"))
node_egui["egui UI"]

node_app -->|"configures"| node_dock_area
node_app -->|"implements"| node_tab_viewer
node_dock_area -->|"displays"| node_dock_state
node_dock_area -->|"delegates rendering"| node_show
node_dock_area -->|"configures"| node_allowed_splits
node_show -->|"loads and stores"| node_interaction_state
node_show -->|"uses drag state"| node_dnd
node_show -->|"processes removals"| node_tab_removal
node_show -->|"renders"| node_render_main
node_show -->|"renders"| node_render_window
node_show -->|"renders"| node_render_leaf
node_dnd -->|"reads overlay style"| node_style
node_dock_state -->|"manages"| node_surfaces
node_surfaces -->|"contains trees"| node_tree
node_surfaces -->|"stores window state"| node_window_state
node_tree -->|"stores nodes"| node_nodes
node_nodes -->|"uses"| node_leaf_node
node_nodes -->|"uses"| node_split_node
node_tree -->|"indexes nodes"| node_node_index
node_tree -->|"indexes tabs"| node_tab_index
node_tree -->|"iterates tabs"| node_tab_iter
node_dock_state -->|"indexes surfaces"| node_surface_index
node_dock_state -->|"provides"| node_translations
node_render_leaf -.->|"renders tab content"| node_tab_viewer
node_show -->|"draws interface"| node_egui

click node_dock_area "https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/mod.rs"
click node_tab_viewer "https://github.com/anhosh/egui_dock/blob/main/src/widgets/tab_viewer.rs"
click node_dock_state "https://github.com/anhosh/egui_dock/blob/main/src/dock_state/mod.rs"
click node_surfaces "https://github.com/anhosh/egui_dock/blob/main/src/dock_state/surface.rs"
click node_window_state "https://github.com/anhosh/egui_dock/blob/main/src/dock_state/window_state.rs"
click node_tree "https://github.com/anhosh/egui_dock/blob/main/src/dock_state/tree/mod.rs"
click node_nodes "https://github.com/anhosh/egui_dock/blob/main/src/dock_state/tree/node/mod.rs"
click node_leaf_node "https://github.com/anhosh/egui_dock/blob/main/src/dock_state/tree/node/leaf.rs"
click node_split_node "https://github.com/anhosh/egui_dock/blob/main/src/dock_state/tree/node/split.rs"
click node_node_index "https://github.com/anhosh/egui_dock/blob/main/src/dock_state/tree/node_index.rs"
click node_tab_index "https://github.com/anhosh/egui_dock/blob/main/src/dock_state/tree/tab_index.rs"
click node_tab_iter "https://github.com/anhosh/egui_dock/blob/main/src/dock_state/tree/tab_iter.rs"
click node_surface_index "https://github.com/anhosh/egui_dock/blob/main/src/dock_state/surface_index.rs"
click node_errors "https://github.com/anhosh/egui_dock/blob/main/src/dock_state/error.rs"
click node_render_main "https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/show/main_surface.rs"
click node_render_window "https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/show/window_surface.rs"
click node_render_leaf "https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/show/leaf.rs"
click node_style "https://github.com/anhosh/egui_dock/blob/main/src/style.rs"
click node_translations "https://github.com/anhosh/egui_dock/blob/main/src/dock_state/translations.rs"
click node_show "https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/show/mod.rs"
click node_dnd "https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/drag_and_drop.rs"
click node_interaction_state "https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/state.rs"
click node_tab_removal "https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/tab_removal.rs"
click node_allowed_splits "https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/allowed_splits.rs"
click node_utils "https://github.com/anhosh/egui_dock/blob/main/src/utils.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dock_area,node_tab_viewer,node_utils,node_egui toneBlue
class node_dock_state,node_surfaces,node_window_state,node_tree,node_nodes,node_leaf_node,node_split_node,node_node_index,node_tab_index,node_tab_iter,node_surface_index,node_errors toneAmber
class node_show,node_dnd,node_interaction_state,node_tab_removal,node_allowed_splits toneMint
class node_render_main,node_render_window,node_render_leaf,node_style,node_translations toneRose
class node_app toneIndigo
```

## Components

### Public API

- [DockArea](https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/mod.rs): `src/widgets/dock_area/mod.rs`
- [TabViewer](https://github.com/anhosh/egui_dock/blob/main/src/widgets/tab_viewer.rs): `src/widgets/tab_viewer.rs`
- [Utilities](https://github.com/anhosh/egui_dock/blob/main/src/utils.rs): `src/utils.rs`

### Dock Layout

- [DockState](https://github.com/anhosh/egui_dock/blob/main/src/dock_state/mod.rs): `src/dock_state/mod.rs`
- [Surfaces](https://github.com/anhosh/egui_dock/blob/main/src/dock_state/surface.rs): `src/dock_state/surface.rs`
- [Window State](https://github.com/anhosh/egui_dock/blob/main/src/dock_state/window_state.rs): `src/dock_state/window_state.rs`
- [Dock Tree](https://github.com/anhosh/egui_dock/blob/main/src/dock_state/tree/mod.rs): `src/dock_state/tree/mod.rs`
- [Tree Nodes](https://github.com/anhosh/egui_dock/blob/main/src/dock_state/tree/node/mod.rs): `src/dock_state/tree/node/mod.rs`
- [Leaf Node](https://github.com/anhosh/egui_dock/blob/main/src/dock_state/tree/node/leaf.rs): `src/dock_state/tree/node/leaf.rs`
- [Split Node](https://github.com/anhosh/egui_dock/blob/main/src/dock_state/tree/node/split.rs): `src/dock_state/tree/node/split.rs`
- [Node Index](https://github.com/anhosh/egui_dock/blob/main/src/dock_state/tree/node_index.rs): `src/dock_state/tree/node_index.rs`
- [Tab Index](https://github.com/anhosh/egui_dock/blob/main/src/dock_state/tree/tab_index.rs): `src/dock_state/tree/tab_index.rs`
- [Tab Iteration](https://github.com/anhosh/egui_dock/blob/main/src/dock_state/tree/tab_iter.rs): `src/dock_state/tree/tab_iter.rs`
- [Surface Index](https://github.com/anhosh/egui_dock/blob/main/src/dock_state/surface_index.rs): `src/dock_state/surface_index.rs`
- [Layout Errors](https://github.com/anhosh/egui_dock/blob/main/src/dock_state/error.rs): `src/dock_state/error.rs`

### Dock Interactions

- [Dock Show Logic](https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/show/mod.rs): `src/widgets/dock_area/show/mod.rs`
- [Drag and Drop](https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/drag_and_drop.rs): `src/widgets/dock_area/drag_and_drop.rs`
- [Interaction State](https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/state.rs): `src/widgets/dock_area/state.rs`
- [Tab Removal](https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/tab_removal.rs): `src/widgets/dock_area/tab_removal.rs`
- [Allowed Splits](https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/allowed_splits.rs): `src/widgets/dock_area/allowed_splits.rs`

### Presentation

- [Main Surface View](https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/show/main_surface.rs): `src/widgets/dock_area/show/main_surface.rs`
- [Window Surface View](https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/show/window_surface.rs): `src/widgets/dock_area/show/window_surface.rs`
- [Leaf View](https://github.com/anhosh/egui_dock/blob/main/src/widgets/dock_area/show/leaf.rs): `src/widgets/dock_area/show/leaf.rs`
- [Dock Styling](https://github.com/anhosh/egui_dock/blob/main/src/style.rs): `src/style.rs`
- [Translations](https://github.com/anhosh/egui_dock/blob/main/src/dock_state/translations.rs): `src/dock_state/translations.rs`

### Other components

- **Application**
- **egui UI**

## Connections

- Application → DockArea: configures
- Application → TabViewer: implements
- DockArea → DockState: displays (evidence: `src/widgets/dock_area/mod.rs`)
- DockArea → Dock Show Logic: delegates rendering (evidence: `src/widgets/dock_area/mod.rs`)
- DockArea → Allowed Splits: configures (evidence: `src/widgets/dock_area/mod.rs`)
- Dock Show Logic → Interaction State: loads and stores (evidence: `src/widgets/dock_area/show/mod.rs`)
- Dock Show Logic → Drag and Drop: uses drag state (evidence: `src/widgets/dock_area/show/mod.rs`)
- Dock Show Logic → Tab Removal: processes removals (evidence: `src/widgets/dock_area/show/mod.rs`)
- Dock Show Logic → Main Surface View: renders (evidence: `src/widgets/dock_area/show/mod.rs`)
- Dock Show Logic → Window Surface View: renders (evidence: `src/widgets/dock_area/show/mod.rs`)
- Dock Show Logic → Leaf View: renders (evidence: `src/widgets/dock_area/show/mod.rs`)
- Drag and Drop → Dock Styling: reads overlay style (evidence: `src/widgets/dock_area/drag_and_drop.rs`)
- DockState → Surfaces: manages (evidence: `src/dock_state/mod.rs`)
- Surfaces → Dock Tree: contains trees (evidence: `src/dock_state/surface.rs`)
- Surfaces → Window State: stores window state (evidence: `src/dock_state/surface.rs`)
- Dock Tree → Tree Nodes: stores nodes (evidence: `src/dock_state/tree/mod.rs`)
- Tree Nodes → Leaf Node: uses (evidence: `src/dock_state/tree/node/mod.rs`)
- Tree Nodes → Split Node: uses (evidence: `src/dock_state/tree/node/mod.rs`)
- Dock Tree → Node Index: indexes nodes (evidence: `src/dock_state/tree/mod.rs`)
- Dock Tree → Tab Index: indexes tabs (evidence: `src/dock_state/tree/mod.rs`)
- Dock Tree → Tab Iteration: iterates tabs (evidence: `src/dock_state/tree/mod.rs`)
- DockState → Surface Index: indexes surfaces (evidence: `src/dock_state/mod.rs`)
- DockState → Translations: provides (evidence: `src/dock_state/mod.rs`)
- Leaf View → TabViewer: renders tab content
- Dock Show Logic → egui UI: draws interface
