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: boolfield (or equivalent), - they expose a
showmethod 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— requirestmux_path: &strInspectorPanel::show— requiresavailable_agents: &[AgentConfig]
These are documented as out-of-scope in docs/TRAITS.md (future work).
Required Associated Types§
Required Methods§
Sourcefn show(&mut self, ctx: &Context) -> Self::Action
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.
Sourcefn is_visible(&self) -> bool
fn is_visible(&self) -> bool
Returns true if the overlay is currently visible.
Sourcefn set_visible(&mut self, visible: bool)
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".