跳到正文

PreviewCard

在触发器旁显示更丰富的悬停或聚焦预览,不改变当前页面。

正在加载交互演示…

#导入

从 quickgui 导入 PreviewCard。

use quickgui::*;

#用法

let card = PreviewCard::new("file", &state);
card.trigger_with(text("README.md"))

#结构

  • PreviewCard::root
  • PreviewCard::trigger
  • PreviewCard::portal
  • PreviewCard::backdrop
  • PreviewCard::positioner
  • PreviewCard::popup
  • PreviewCard::arrow

#API 参考

展开条目查看说明和完整签名。短横线表示声明中未记录默认值。

PreviewCard

查看源码
pub fn new( trigger_id: impl Into<ElementId>, popup_id: impl Into<ElementId>, open: bool, ) -> Self

Declare a preview card over caller-owned trigger and popup identities.

from_statepub fn from_state( trigger_id: impl Into<ElementId>, popup_id: impl Into<ElementId>, state: &PreviewCardState, ) -> Self—

Declare a preview card from its retained state.

pub fn from_state( trigger_id: impl Into<ElementId>, popup_id: impl Into<ElementId>, state: &PreviewCardState, ) -> Self
查看源码
placementpub const fn placement(mut self, placement: AnchorPlacement) -> Self—

Configures placement for this part.

pub const fn placement(mut self, placement: AnchorPlacement) -> Self
查看源码
anchor_gappub fn anchor_gap(mut self, gap: f32) -> Self—

Set the structural distance between the trigger and the popup.

pub fn anchor_gap(mut self, gap: f32) -> Self
查看源码
viewport_marginpub fn viewport_margin(mut self, margin: f32) -> Self—

Set the structural collision margin inside the current window viewport.

pub fn viewport_margin(mut self, margin: f32) -> Self
查看源码
popoverpub const fn popover(self) -> Popover—

The composed popover, for callers that need its remaining parts directly.

pub const fn popover(self) -> Popover
查看源码
is_openpub const fn is_open(self) -> bool—

Configures is open for this part.

pub const fn is_open(self) -> bool
查看源码
trigger_idpub const fn trigger_id(self) -> ElementId—

Configures trigger id for this part.

pub const fn trigger_id(self) -> ElementId
查看源码
popup_idpub const fn popup_id(self) -> ElementId—

Configures popup id for this part.

pub const fn popup_id(self) -> ElementId
查看源码
positioner_idpub fn positioner_id(self) -> ElementId—

Configures positioner id for this part.

pub fn positioner_id(self) -> ElementId
查看源码
backdrop_idpub fn backdrop_id(self) -> ElementId—

Configures backdrop id for this part.

pub fn backdrop_id(self) -> ElementId
查看源码
arrow_idpub fn arrow_id(self) -> ElementId—

Configures arrow id for this part.

pub fn arrow_id(self) -> ElementId
查看源码
trigger_focuspub fn trigger_focus(self) -> FocusHandle—

Configures trigger focus for this part.

pub fn trigger_focus(self) -> FocusHandle
查看源码
on_trigger_hoverpub fn on_trigger_hover<V: 'static, Change>( self, cx: &mut ViewContext<'_, V>, access: fn(&mut V) -> &mut PreviewCardState, on_open_change: Change, ) -> HoverListener<V> where Change: Fn(&mut V, bool, &mut EventContext) + 'static,—

Build the trigger's hover behavior. Attach the returned handle with [`crate::Element::on_hover`]. `on_open_change` runs only when the open value actually changes, which for the delayed open is on the frame the deadline is applied rather than on the pointer event that armed it.

pub fn on_trigger_hover<V: 'static, Change>( self, cx: &mut ViewContext<'_, V>, access: fn(&mut V) -> &mut PreviewCardState, on_open_change: Change, ) -> HoverListener<V> where Change: Fn(&mut V, bool, &mut EventContext) + 'static,
查看源码
on_trigger_hover_withpub fn on_trigger_hover_with<V: 'static, Change>( self, cx: &mut ViewContext<'_, V>, access: StateAccessor<V, PreviewCardState>, on_open_change: Change, ) -> HoverListener<V> where Change: Fn(&mut V, bool, &mut EventContext) + 'static,—

Build the trigger's hover behavior against a per-instance state accessor.

pub fn on_trigger_hover_with<V: 'static, Change>( self, cx: &mut ViewContext<'_, V>, access: StateAccessor<V, PreviewCardState>, on_open_change: Change, ) -> HoverListener<V> where Change: Fn(&mut V, bool, &mut EventContext) + 'static,
查看源码
on_popup_hoverpub fn on_popup_hover<V: 'static, Change>( self, cx: &mut ViewContext<'_, V>, access: fn(&mut V) -> &mut PreviewCardState, on_open_change: Change, ) -> HoverListener<V> where Change: Fn(&mut V, bool, &mut EventContext) + 'static,—

Build the popup's hover behavior, which keeps an open card open.

pub fn on_popup_hover<V: 'static, Change>( self, cx: &mut ViewContext<'_, V>, access: fn(&mut V) -> &mut PreviewCardState, on_open_change: Change, ) -> HoverListener<V> where Change: Fn(&mut V, bool, &mut EventContext) + 'static,
查看源码
on_popup_hover_withpub fn on_popup_hover_with<V: 'static, Change>( self, cx: &mut ViewContext<'_, V>, access: StateAccessor<V, PreviewCardState>, on_open_change: Change, ) -> HoverListener<V> where Change: Fn(&mut V, bool, &mut EventContext) + 'static,—

Build the popup's hover behavior against a per-instance state accessor.

pub fn on_popup_hover_with<V: 'static, Change>( self, cx: &mut ViewContext<'_, V>, access: StateAccessor<V, PreviewCardState>, on_open_change: Change, ) -> HoverListener<V> where Change: Fn(&mut V, bool, &mut EventContext) + 'static,
查看源码
on_dismisspub fn on_dismiss<V: 'static, Change>( self, cx: &mut ViewContext<'_, V>, access: fn(&mut V) -> &mut PreviewCardState, on_open_change: Change, ) -> DismissListener<V> where Change: Fn(&mut V, bool, &mut EventContext) + 'static,—

Build the popup's dismissal behavior for Escape and outside presses. Attach the returned handle with [`crate::Element::on_dismiss`].

pub fn on_dismiss<V: 'static, Change>( self, cx: &mut ViewContext<'_, V>, access: fn(&mut V) -> &mut PreviewCardState, on_open_change: Change, ) -> DismissListener<V> where Change: Fn(&mut V, bool, &mut EventContext) + 'static,
查看源码
on_dismiss_withpub fn on_dismiss_with<V: 'static, Change>( self, cx: &mut ViewContext<'_, V>, access: StateAccessor<V, PreviewCardState>, on_open_change: Change, ) -> DismissListener<V> where Change: Fn(&mut V, bool, &mut EventContext) + 'static,—

Build the popup's dismissal behavior against a per-instance state accessor.

pub fn on_dismiss_with<V: 'static, Change>( self, cx: &mut ViewContext<'_, V>, access: StateAccessor<V, PreviewCardState>, on_open_change: Change, ) -> DismissListener<V> where Change: Fn(&mut V, bool, &mut EventContext) + 'static,
查看源码
schedulepub fn schedule<V: 'static>(cx: &mut ViewContext<'_, V>, state: &PreviewCardState)—

Ask for the one repaint an armed open or close deadline needs. Call this while rendering. A settled preview card requests nothing, so the window sleeps.

pub fn schedule<V: 'static>(cx: &mut ViewContext<'_, V>, state: &PreviewCardState)
查看源码

PreviewCard::root_with

查看源码
pub fn root_with(self, root: Element) -> Element

Decorate the optional application-owned structural wrapper. A preview card needs no wrapper of its own; this part exists so a composition that wants one keeps the trigger out of the window's native drag region without inventing appearance.

PreviewCard::root

查看源码
pub fn root(self) -> Element

Create the unstyled root part. Use [`Self::root_with`] to supply an existing element.

PreviewCard::trigger_with

查看源码
pub fn trigger_with(self, trigger: Element) -> Element

Decorate the application-owned link-like trigger without adding appearance. Unlike a popover trigger, this projects the Link role: a preview card previews a destination rather than opening a menu, so the trigger stays an ordinary link for the keyboard and for assistive technology.

PreviewCard::trigger

查看源码
pub fn trigger(self) -> Element

Create the unstyled trigger part. Use [`Self::trigger_with`] to supply an existing element.

PreviewCard::portal_with

查看源码
pub fn portal_with(self, portal: Element) -> Element

Decorate the caller-owned portal boundary. QuickGUI's retained overlay node is itself the portal, so this is the same boundary as [`Self::positioner_with`]; mount exactly one of them.

PreviewCard::portal

查看源码
pub fn portal(self) -> Element

Create the unstyled portal part. Use [`Self::portal_with`] to supply an existing element.

PreviewCard::positioner_with

查看源码
pub fn positioner_with(self, positioner: Element) -> Element

Decorate the caller-owned positioner without adding appearance.

PreviewCard::positioner

查看源码
pub fn positioner(self) -> Element

Create the unstyled positioner part. Use [`Self::positioner_with`] to supply an existing element.

PreviewCard::popup_with

查看源码
pub fn popup_with(self, popup: Element) -> Element

Decorate the application-owned popup without adding layout or appearance. The popup emits [`crate::Event::Dismiss`] under [`Self::popup_id`] for Escape and for an outside pointer press, and restores focus to the trigger.

PreviewCard::popup

查看源码
pub fn popup(self) -> Element

Create the unstyled popup part. Use [`Self::popup_with`] to supply an existing element.

PreviewCard::arrow_with

查看源码
pub fn arrow_with(self, arrow: Element) -> Element

Decorate the application-owned arrow. The arrow is decorative: it carries a stable identity so the application can position and animate it, and is hidden from assistive technology.

PreviewCard::arrow

查看源码
pub fn arrow(self) -> Element

Create the unstyled arrow part. Use [`Self::arrow_with`] to supply an existing element.

PreviewCard::backdrop_with

查看源码
pub fn backdrop_with(self, backdrop: Element) -> Element

Decorate an optional caller-painted viewport backdrop.

PreviewCard::backdrop

查看源码
pub fn backdrop(self) -> Element

Create the unstyled backdrop part. Use [`Self::backdrop_with`] to supply an existing element.