跳到正文

ScrollArea

组合可滚动视口,以及可由调用方设置样式的滚动条、滑块和角落。

正在加载交互演示…

#导入

从 quickgui 导入 ScrollArea。

use quickgui::*;

#用法

let area = ScrollArea::new("log");
area.viewport().h(160.0).overflow_hidden()

#结构

  • ScrollArea::root
  • ScrollArea::viewport
  • ScrollArea::content
  • ScrollArea::scrollbar
  • ScrollArea::thumb
  • ScrollArea::corner

#API 参考

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

ScrollArea

查看源码
pub fn new(root_id: impl Into<ElementId>) -> Self
keep_mountedpub const fn keep_mounted(mut self, keep_mounted: bool) -> Self—

Keep a scrollbar mounted while its axis does not overflow. The default unmounts it, matching Base UI's `keepMounted={false}`. A kept scrollbar is hidden from assistive technology while its axis cannot scroll, so a mounted-but-useless scrollbar is never announced.

pub const fn keep_mounted(mut self, keep_mounted: bool) -> Self
查看源码
is_keep_mountedpub const fn is_keep_mounted(self) -> bool—

Configures is keep mounted for this part.

pub const fn is_keep_mounted(self) -> bool
查看源码
root_idpub const fn root_id(self) -> ElementId—

Configures root id for this part.

pub const fn root_id(self) -> ElementId
查看源码
viewport_idpub fn viewport_id(self) -> ElementId—

Configures viewport id for this part.

pub fn viewport_id(self) -> ElementId
查看源码
content_idpub fn content_id(self) -> ElementId—

Configures content id for this part.

pub fn content_id(self) -> ElementId
查看源码
scrollbar_idpub fn scrollbar_id(self, orientation: ScrollAreaOrientation) -> ElementId—

Configures scrollbar id for this part.

pub fn scrollbar_id(self, orientation: ScrollAreaOrientation) -> ElementId
查看源码
thumb_idpub fn thumb_id(self, orientation: ScrollAreaOrientation) -> ElementId—

Configures thumb id for this part.

pub fn thumb_id(self, orientation: ScrollAreaOrientation) -> ElementId
查看源码
corner_idpub fn corner_id(self) -> ElementId—

Configures corner id for this part.

pub fn corner_id(self) -> ElementId
查看源码
shows_scrollbarpub fn shows_scrollbar( self, state: &ScrollAreaState, orientation: ScrollAreaOrientation, ) -> bool—

Whether a scrollbar for `orientation` should be mounted at all.

pub fn shows_scrollbar( self, state: &ScrollAreaState, orientation: ScrollAreaOrientation, ) -> bool
查看源码
shows_cornerpub fn shows_corner(self, state: &ScrollAreaState) -> bool—

Whether the corner between two scrollbars should be mounted.

pub fn shows_corner(self, state: &ScrollAreaState) -> bool
查看源码

ScrollArea::root_with

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

Decorate an application-owned root without adding layout or appearance.

ScrollArea::root

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

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

ScrollArea::viewport_with

查看源码
pub fn viewport_with(self, viewport: Element) -> Element

Decorate the application-owned scroll container. The viewport clips its content on both axes and carries the ScrollView role. The caller places the content by translating [`Self::content_with`] with the retained offset, which keeps scrolling paint-only and keeps QuickGUI's built-in overlay scrollbar out of a component whose scrollbars the application draws itself.

ScrollArea::viewport

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

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

ScrollArea::content_with

查看源码
pub fn content_with(self, content: Element) -> Element

Decorate the application-owned scrolled content. Translate it by the negated [`ScrollAreaState::offset`]; QuickGUI adds no transform of its own so the application keeps full control of the motion.

ScrollArea::content

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

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

ScrollArea::scrollbar_with

查看源码
pub fn scrollbar_with( self, state: &ScrollAreaState, orientation: ScrollAreaOrientation, scrollbar: Element, ) -> Element

Decorate one application-owned scrollbar track. The track projects the ScrollBar role with the exact current position, the scrollable range, and its orientation. It is not focusable: a scrollbar duplicates keyboard scrolling the viewport already provides, so it stays out of the Tab sequence.

ScrollArea::scrollbar

查看源码
pub fn scrollbar(self, state: &ScrollAreaState, orientation: ScrollAreaOrientation) -> Element

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

ScrollArea::thumb_with

查看源码
pub fn thumb_with(self, orientation: ScrollAreaOrientation, thumb: Element) -> Element

Decorate one application-owned scrollbar thumb. The thumb carries the captured pointer drag. Attach a [`crate::ViewContext::pointer_listener`] registered for [`Self::thumb_id`] and forward the event to [`ScrollAreaState::apply_thumb_pointer`] with the track length the caller laid out.

ScrollArea::thumb

查看源码
pub fn thumb(self, orientation: ScrollAreaOrientation) -> Element

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

ScrollArea::positioned_thumb_with

查看源码
pub fn positioned_thumb_with( self, state: &ScrollAreaState, orientation: ScrollAreaOrientation, track_length: f32, thumb: Element, ) -> Element

Decorate and position one application-owned scrollbar thumb inside its scrollbar. This is [`Self::thumb_with`] plus the structural geometry a draggable thumb needs: the thumb is absolutely positioned along the scrollbar's axis at [`ScrollAreaState::thumb_offset`] with [`ScrollAreaState::thumb_length`], so it follows the offset without the application re-deriving either value. Cross-axis size and every visual property stay application-owned.

ScrollArea::positioned_thumb

查看源码
pub fn positioned_thumb( self, state: &ScrollAreaState, orientation: ScrollAreaOrientation, track_length: f32, ) -> Element

Create the unstyled positioned thumb part. Use [`Self::positioned_thumb_with`] to supply an existing element.

ScrollArea::corner_with

查看源码
pub fn corner_with(self, corner: Element) -> Element

Decorate the application-owned corner between a horizontal and a vertical scrollbar.

ScrollArea::corner

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

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