Skip to content

Unify tab-bar draw loop's split-group/single-group duplication (GTK + TUI) #549

Description

@JDonaghy

Summary

Follow-up from #547. While fixing the breadcrumb-bar regression, the same shape of duplication was found in the tab-bar draw loops of both backends — the fix used there (a shared render::breadcrumb_draw_targets() helper) applies cleanly here too, but was deliberately left out of #547 to keep that PR scoped to the reported regression.

Where the duplication lives

Both backends branch on if let Some(split) = screen.editor_group_split { ... } else { /* single group */ ... } and, in each arm, independently:

  • skip drawing when the group's tab bar is hidden (engine.is_tab_bar_hidden(group_id))
  • compute the tab bar's Rect from gtb.bounds / screen.tab_bar_primitive
  • push Surface::TabBar and draw
  • recover hit-test geometry from the draw call and cache it

Concretely:

  • src/gtk/mod.rsShellApp::render_content, the if let Some(ref split) = screen.editor_group_split { ... } else if !engine.is_tab_bar_hidden(...) { ... } block (currently just below the Draw tab bar(s) comment).
  • src/tui_main/render_impl.rsdraw_frame, the equivalent split/single-group tab-bar blocks.

Proposed fix

Add a render::tab_bar_draw_targets() (or similar) shared helper, analogous to render::breadcrumb_draw_targets() added in #547, that:

Each backend keeps its own draw call + hit-test-geometry recovery (that part isn't shareable — GTK caches pixel hit-tests into Rc<RefCell<...>> maps, TUI doesn't need to), but the skip-condition + rect math collapses into one function, same as breadcrumbs.

Why this wasn't done in #547

#515 (immediately prior work on this branch) just rewrote tab-bar hit-test pixel geometry in both backends. Touching the tab-bar draw loop again right after that risks colliding with or subtly undoing that work, and it wasn't what #547 reported as broken. Low risk, but better as its own reviewable change.

Acceptance criteria

  • render::tab_bar_draw_targets() (or equivalent) added to src/render.rs, covering the skip-condition + rect-math duplication described above.
  • Both src/gtk/mod.rs::render_content and src/tui_main/render_impl.rs::draw_frame use it for both split-group and single-group tab bar drawing.
  • No behavior change — existing tab-bar rendering/hit-testing tests (both backends) continue to pass unmodified.

Parent context: Platform-Neutral milestone (#7), same as #515/#547.

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