Skip to content

TUI: Use compute_tab_bar_hit_regions() / cached TabBar layout for drag slot bounds #477

Description

@JDonaghy

Tier: Small gap (needs cached layout exposed to drag overlay path)

Summary

build_tui_tab_slots() in src/tui_main/render_impl.rs:1202–1240 (~40 lines) hand-rolls per-tab x-bounds for the drag-and-drop overlay by walking gtb.tabs and computing tab.name.chars().count() + TAB_CLOSE_COLS per tab. This duplicates render::compute_tab_bar_hit_regions() (render.rs:463), which already does exactly this calculation and is the source of truth used by mouse-click routing.

What exists

  • render::compute_tab_bar_hit_regions(tabs, area, ...) (render.rs:463) — returns per-tab hit regions using quadraui::TabMeasure.
  • render::TAB_CLOSE_COLS (render.rs:437) — duplicated in render_impl.rs:1166 as a private const.
  • quadraui::TabBar::layout(...) produces per-tab layout inside the rasteriser scope when Backend::draw_tab_bar() is called.

What to do

Two options — either works:

Option A (preferred): Call compute_tab_bar_hit_regions() once per group/tab-bar during draw, cache the per-tab bounds (already a Vec<(x_start, x_end)> shape), and have render_tab_drag_overlay() consume the cache. Delete build_tui_tab_slots().

Option B: Expose TabBar.layout() results from inside Backend::enter_frame_scope() (or lift the layout call before draw) so the drag overlay can read per-tab bounds without recomputing.

Also: remove the duplicate TAB_CLOSE_COLS const in render_impl.rs:1166 and use render::TAB_CLOSE_COLS.

Files

  • src/tui_main/render_impl.rs — delete build_tui_tab_slots (~40 lines), update its two call sites at lines 1250 and 1353.
  • Minor edits to plumb the cached bounds.

Dependencies

None blocking. Sibling refactor #347 already factored the tab-bar/breadcrumb render wrappers; this is a different residual (drag overlay slot lookup, not draw invocation).

Notes

Part of the TUI convergence backlog (#474). The biggest risk is the tab_scroll_offset > 0 → +2 overlay adjustment at lines 1212–1217 / 1227 — make sure the shared hit-region path accounts for it (or that the cached bounds already include the offset).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    coordTracked by coord-tui pipelineenhancementNew feature or requeststatus:readyRefined and ready to enter the work pipelineuiUI/rendering

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions