Skip to main content

OverlayComponent

Trait OverlayComponent 

Source
pub trait OverlayComponent {
    type Action;

    // Required methods
    fn show(&mut self, ctx: &Context) -> Self::Action;
    fn is_visible(&self) -> bool;
    fn set_visible(&mut self, visible: bool);
}
Expand description

Common interface for egui overlay UI components that follow the show(&mut self, ctx: &egui::Context) -> Self::Action pattern.

§Design notes

Twelve or more UI dialogs in par-term share the same shape:

  • they maintain a visible: bool field (or equivalent),
  • they expose a show method that renders the dialog and returns an action,
  • they can be hidden without producing an action.

This trait formalises that contract so callers can be written generically and components become easier to test in isolation.

§Components that are excluded

The following components have additional required parameters on show and cannot implement this trait without a wrapper:

  • HelpUI::show — returns () (no action type)
  • TmuxSessionPickerUI::show — requires tmux_path: &str
  • InspectorPanel::show — requires available_agents: &[AgentConfig]

These are documented as out-of-scope in docs/TRAITS.md (future work).

Required Associated Types§

Source

type Action

The action type produced by this component’s show call.

Required Methods§

Source

fn show(&mut self, ctx: &Context) -> Self::Action

Render the overlay and return any action produced by user interaction.

When the component is not visible this must return the “no action” variant immediately, without touching ctx.

Source

fn is_visible(&self) -> bool

Returns true if the overlay is currently visible.

Source

fn set_visible(&mut self, visible: bool)

Show or hide the overlay.

Setting to false hides the dialog immediately. Setting to true is equivalent to calling a parameter-free open method; components that require additional state to open (e.g. show_for_tab) should use their own specific API instead of relying on this method.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§