# `MingaEditor.FocusTree`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_editor/focus_tree.ex#L1)

Tree of visible regions, built from the per-frame `Layout` plus active overlays.

Mouse routing uses this tree instead of asking every handler to re-check screen coordinates. Hit-testing finds the deepest visible node at a position, and the router dispatches to that node's handler before bubbling to ancestors when a handler returns `{:passthrough, state}`.

Children are stored in rendered z-order from back to front. Hit-tests walk children in reverse order, so later siblings win when regions overlap.

# `path`

```elixir
@type path() :: [MingaEditor.FocusTree.Node.t()]
```

Mouse route ordered from deepest target to root for bubbling.

# `t`

```elixir
@type t() :: MingaEditor.FocusTree.Node.t()
```

Built focus tree, rooted at the viewport.

# `from_layout`

```elixir
@spec from_layout(MingaEditor.Layout.t()) :: t()
```

Builds a focus tree from a `Layout`. Pure; safe to call any time.

# `from_state`

```elixir
@spec from_state(map()) :: t()
```

Builds a focus tree from editor or render-pipeline state.

# `get`

```elixir
@spec get(map()) :: t()
```

Returns the cached focus tree from state, or builds one from the current state.

# `hit_path`

```elixir
@spec hit_path(t(), integer(), integer()) :: path()
```

Returns the bubble path ordered from deepest node to root.

# `hit_test`

```elixir
@spec hit_test(t(), integer(), integer()) :: MingaEditor.FocusTree.Node.t() | nil
```

Hit-tests `(row, col)` and returns the deepest node whose rect contains the point.

# `link_tree`

```elixir
@spec link_tree(t()) :: t()
```

Links parent and sibling references throughout a tree.

# `scroll_path`

```elixir
@spec scroll_path(t(), integer(), integer()) :: path()
```

Returns the path starting at the deepest scrollable node under `(row, col)`.

# `with_overlay`

```elixir
@spec with_overlay(
  t(),
  MingaEditor.FocusTree.Node.content_type(),
  MingaEditor.FocusTree.Node.rect(),
  keyword()
) :: t()
```

Adds a modal or float overlay node to the root in front of existing regions.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
