Skip to main content

Module tooltip

Module tooltip 

Source
Expand description

Hover-delay tooltip widget driven by markup <tooltip text="Save" delay="500">...trigger...</tooltip>.

  • The single child is the trigger; the tooltip remains invisible until the trigger has carried Hovered for delay milliseconds (default 500, --lumen-tooltip-delay token).
  • The trigger entity carries TooltipSource; the first tick of Hovered records HoverStartedAt.
  • Once dwell exceeds the configured delay, a TooltipPopup entity is spawned below-right of the CURSOR (Qt QToolTip placement), flipping above/left near viewport edges - see cursor_tooltip_origin.
  • The popup despawns one tick after Hovered clears.

§Canonical #[derive(Widget)] port

Tooltip is the reference port to the new lumen_widget_macros::Widget derive. TooltipSource carries #[derive(Widget)] with tag = "tooltip", which emits a lumen_widget::Widget impl (parser-tag accessor + spawn glue) so a runtime registry can wire <tooltip text="..."> markup to this component without the previous hand-coded if tag == "tooltip" { ... } branch in lumenc::parse::html.

The four per-tick systems remain hand-written (the #[widget(prop)] /#[widget(state)] attributes only cover marker-component authoring; system bodies stay author-supplied for v1). The plugin struct is also hand-written (via #[widget(plugin = "TooltipPlugin")]) because the four systems need to be installed in a specific tick stage - the canned no-op plugin emitted by the derive can’t do that yet.

Structs§

HoverStartedAt
Per-entity timestamp of when Hovered was first inserted. Recorded on Added<Hovered> and used to compute dwell time before the tooltip popup is allowed to appear.
TooltipPlugin
Plugin: registers the four tooltip systems and a default class rule via the LSP completion tables. No render path of its own - the popup is just an <overlay>-shaped entity with a Visuals fill + TextContent, so all standard styling (CSS .tooltip selector, hover-bg, opacity) works.
TooltipPopup
Marker on the spawned popup entity. Tracks which trigger the popup belongs to so the cleanup pass knows what to despawn when the trigger un-hovers.
TooltipSource
Authored on the trigger via <tooltip text="..." delay="...">. The markup parser attaches this component on the SINGLE child the <tooltip> wraps - <tooltip> itself is a no-op container in the layout tree.

Functions§

cursor_tooltip_origin
Cursor-relative tooltip origin (Qt QToolTip placement): the popup sits below-right of the cursor hotspot, offset px away on each axis. When the preferred spot would overflow the viewport, each axis flips independently to the cursor’s other side (above / left), saturating at 0 so the popup never leaves the window.