Thanks to visit codestin.com
Credit goes to docs.rs

Skip to main content

Crate rgpui

Crate rgpui 

Source
Expand description

§rgpui

rgpui 是 rgpui 项目的核心 crate,是一个混合即时/保留模式、GPU 加速的 Rust UI 框架。

关于项目背景、重命名原因和整体架构,请参见项目根目录 README

§主要特性

  • 混合即时/保留模式:结合即时模式的高性能与保留模式的状态管理优势
  • 基于 Entity 的状态管理:通过智能指针安全地在应用各部分之间共享和通信状态
  • 声明式视图(View):实现 Render trait 即可构建声明式 UI,每帧自动刷新
  • 命令式元素(Element):底层构建块,提供对渲染和布局的完全控制
  • GPU 加速渲染:利用 Metal/Vulkan 进行高性能图形渲染
  • Taffy 布局引擎:支持 Flexbox 和 Grid 布局
  • 丰富的文本系统:支持字体渲染、文本布局和高亮
  • 输入处理与快捷键:完整的键盘/鼠标事件处理和可配置的键位映射
  • 动画系统:内置动画支持
  • 跨平台:支持 macOS、Linux 和 Windows
  • Tailwind 风格 API:通过 div 元素提供熟悉的样式链式调用
  • 系统托盘:完整托盘图标、右键菜单及窗口隐藏/恢复功能
  • 增强透明窗口:支持半透明、毛玻璃等视觉效果

§快速开始

§添加依赖

Cargo.toml 中添加:

[dependencies]
rgpui = "0.1"
rgpui_platform = "0.1"

§最小示例

use rgpui::*;
use rgpui_platform::application;

struct HelloWorld;

impl Render for HelloWorld {
    fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
        div()
            .flex()
            .items_center()
            .justify_center()
            .size_full()
            .child("Hello, RGPUI!")
    }
}

fn main() {
    application().run(|cx: &mut App| {
        let bounds = Bounds::centered(None, size(px(500.), px(500.0)), cx);
        cx.open_window(
            WindowOptions {
                window_bounds: Some(WindowBounds::Windowed(bounds)),
                titlebar: Some(TitlebarOptions {
                    title: Some("Hello你好".into()),
                    ..Default::default()
                }),
                ..Default::default()
            },
            |_window, cx| cx.new(|_cx| HelloWorld),
        )
            .unwrap();
    });
}

§许可证

Apache-2.0

Re-exports§

pub use util::FutureExt;
pub use util::Timeout;
pub use crate::scheduler::FallibleTask;
pub use crate::scheduler::ForegroundExecutor as SchedulerForegroundExecutor;
pub use crate::scheduler::Priority;
pub use crate::scheduler::Task;
pub use crate::scheduler::RunnableMeta;
pub use crate::collections::*;
pub use crate::refineable::*;
pub use profiler::*;
pub use single_instance::*;

Modules§

_ownership_and_data_flow
In GPUI, every model or view in the application is actually owned by a single top-level object called the App. When a new entity or view is created (referred to collectively as entities), the application is given ownership of their state to enable their participation in a variety of app services and interaction with other entities.
collections
Re-export of collections for backwards compatibility.
colors
The default colors used by GPUI.
http_client
HTTP client library.
inspector_reflection
提供 #[derive_inspector_reflection] 使用的定义。
layer_shell
perf
Performance benchmarking utilities. Some constants and datatypes used in the GPUI perf profiler.
prelude
The GPUI prelude is a collection of traits and types that are widely used throughout the library. It is recommended to import this prelude into your application to avoid having to import each trait individually.
profiler
Profiling utilities for task timing and thread performance tracking.
queue
refineable
Refinement types for partial initialization.
scheduler
Task scheduler for async execution.
single_instance
跨平台单实例锁实现
styled_reflection
实现函数反射
sum_tree
A sum tree data structure, a concurrency-friendly B-tree.
util
window_positioner
窗口位置计算器

Macros§

actions
定义并注册可用作操作的单元结构体。对于更复杂的数据类型,请派生 Action
border_style_methods
生成边框(border)样式相关的方法。
box_shadow_style_methods
生成盒子阴影(box shadow)样式相关的方法。
cursor_style_methods
生成光标(cursor)样式相关的方法。
debug_panic
在调试模式下 panic,在发布模式下记录错误及回溯
margin_style_methods
生成外边距(margin)样式相关的方法。
maybe
展开为立即调用的函数表达式。适用于在不返回 Option 或 Result 的函数中使用 ? 运算符
overflow_style_methods
生成溢出(overflow)样式相关的方法。
padding_style_methods
生成内边距(padding)样式相关的方法。
position_style_methods
生成定位(position)样式相关的方法。
register_action
用于向 GPUI 运行时注册动作的过程宏。
visibility_style_methods
生成可见性样式相关的方法。

Structs§

Anchored
An anchored element that can be used to display UI that will avoid overflowing the window bounds.
AnchoredState
The state that the anchored element element uses to track its children.
Animation
An animation that can be applied to an element.
AnimationElement
A GPUI element that applies an animation to another element
AnyDrag
Contains state associated with an active drag operation, started by dragging an element within the window or by dragging into the app from the underlying platform.
AnyElement
A dynamically typed element that can be used to store any element type.
AnyEntity
A dynamically typed reference to a entity, which can be downcast into a Entity<T>.
AnyImageCache
A dynamically typed image cache, which can be used to store any image cache
AnyTooltip
Contains state associated with a tooltip. You’ll only need this struct if you’re implementing tooltip behavior on a custom element. Otherwise, use Div::tooltip.
AnyView
一个动态类型的视图句柄,可以向下转换为特定类型的 Entity
AnyWeakEntity
A type erased, weak reference to a entity.
AnyWeakView
一个弱的、动态类型的视图句柄,不会阻止视图被释放。
AnyWindowHandle
A handle to a window with any root view type, which can be downcast to a window with a specific root view type.
App
包含完整应用程序的状态,并作为引用传递给各种回调。 其他 Context 会解引用到此类型。 你需要一个 App 的引用来访问 Entity 的状态。
Application
对 GPUI 应用程序的引用,通常在应用的 main 函数中构建。 除了在初始配置和启动阶段外,你通常不会直接与这个类型交互。
ArenaClearNeeded
Returned when the element arena has been used and so must be cleared before the next draw.
AsyncApp
App 的异步友好版本,具有静态生命周期,因此可以在异步代码的 await 点之间持有。 调用 App::spawn 时会提供此实例,你也可以通过 App::to_async 创建。
AsyncWindowContext
对应用上下文的克隆 owned 句柄, 与当前任务关联的窗口组合在一起。
AtlasTextureId
AtlasTile
Background
背景颜色,可以是纯色或线性渐变。
BackgroundExecutor
指向当前正在运行的执行器的指针, 用于生成后台任务。
BindingIndex
键映射内绑定的索引。
Boundary
A boundary between two lines of text.
Bounds
表示 2D 空间中的矩形区域,包含原点和尺寸。
BoundsRefinement
[#ident] 的可细化版本,详见该文档。
BoxShadow
box-shadow 属性的可能值
Canvas
A canvas element, meant for accessing the low level paint API without defining a whole custom element
Capslock
某个时间点的 capslock 键状态
ClipboardItem
应复制到剪贴板的项目
ClipboardString
A clipboard item that should be copied to the clipboard
ContentMask
Indicates which region of the window is visible. Content falling outside of this mask will not be rendered. Currently, only rectangular content masks are supported, but we give the mask its own type to leave room to support more complex shapes in the future.
Context
应用上下文,针对给定实体具有专门行为。
ContextEntry
KeyContext 中的条目
Corners
Represents the corners of a box in a 2D space, such as border radius.
CornersRefinement
[#ident] 的可细化版本,详见该文档。
DebugBelow
使用此结构与你自己元素中的 ‘debug_below’ 样式进行交互。 如果父元素设置了此样式,则此结构将被设置为 GPUI 中的全局值。
DecorationRun
设置文本段的文本装饰
Deferred
An element which delays the painting of its child until after all of its ancestors, while keeping its layout as part of the current element tree.
DeferredScrollToItem
DevicePixels
Represents physical pixels on the display.
DialogOptions
原生对话框的选项
DismissEvent
ManagedView 的实现者发出,表示视图应该被解散, 例如当视图作为模态框呈现时。
DispatchEventResult
DisplayId
硬件显示器的不透明标识符
Div
A Div element, the all-in-one element for building complex UIs in GPUI
DivFrameState
A frame state for a Div element, which contains layout IDs for its children.
DivInspectorState
Interactivity state displayed an manipulated in the inspector.
DragMoveEvent
An event for when a drag is moving over this element, with the given state type.
Drawable
A wrapper around an implementer of Element that allows it to be drawn in a window.
DummyKeyboardMapper
平台键盘映射器的虚拟实现
Edges
Represents the edges of a box in a 2D space, such as padding or margin.
EdgesRefinement
[#ident] 的可细化版本,详见该文档。
ElementClickedState
Whether or not the element or a group that contains it is clicked by the mouse.
ElementHoverState
Whether or not the element or a group that contains it is hovered.
ElementInputHandler
crate::PlatformInputHandler 的标准实现。在元素的 paint 阶段 使用实例调用 Window::handle_input
Empty
空的元素,不渲染任何内容。
EmptyView
一个不渲染任何内容的视图
Entity
A strong, well-typed reference to a struct which is managed by GPUI
EntityId
A unique identifier for a entity across the application.
ExternalPaths
来自平台的路径集合,如从文件拖放中获取。
FallbackPromptRenderer
默认的 GPUI 回退提示渲染,当平台不支持时使用
FillOptions
Parameters for the fill tessellator.
FocusHandle
用于跟踪和操控窗口中聚焦元素的句柄。
FocusId
A globally unique identifier for a focusable element.
FocusOutEvent
This is provided when subscribing for Context::on_focus_out events.
FocusedWindowInfo
当前系统聚焦窗口的信息
Font
用于标识特定字体的配置详情。
FontFallbacks
指定字体可配置的备用字体。 备用字体的字体族名称存储在此结构中。
FontFamilyId
特定字体族的不透明标识符。
FontFeatures
可为给定字体配置的 OpenType 功能。
FontId
特定字体的不透明标识符。
FontMetrics
用于存储字体指标的结构体。 用于定义字体的测量值。
FontRun
具有单一字体的文本段
FontWeight
文本的字重,范围从 100.0 到 900.0, 其中 400.0 为正常字重。
ForegroundExecutor
指向当前正在运行的执行器的指针, 用于在主线程上生成任务。
GlobalElementId
元素的全局唯一标识符,用于跨帧跟踪状态。
GlobalHotKeyEvent
全局快捷键事件
GlyphId
特定字形的标识符,由 WindowTextSystem::layout_line 返回。
GlyphRasterData
预计算的字形光栅数据,用于高效绘制而无需每个字形缓存查找。
GpuSpecs
关于 GPUI 运行所在的 GPU 的信息。
GpuiBorrow
A mutable reference to an entity owned by GPUI
GridLocation
A location in a grid layout.
GridTemplate
grid-template-* 值的简化表示
GridTemplateRefinement
[#ident] 的可细化版本,详见该文档。
GroupStyle
The styling information for a given group.
HighlightStyle
高亮样式,类似于 TextStyle,但适用于单一字体、 统一大小和间距的文本。
Hitbox
一个矩形的命中区域,可能会阻止先插入的 hitbox。 详见 Window::insert_hitbox
HitboxId
An identifier for a Hitbox which also includes HitboxBehavior.
Hsla
一个 HSLA 颜色
Image
An image, with a format and certain bytes
ImageCacheElement
An image cache element.
ImageFormatIter
An iterator over the variants of ImageFormat
ImageId
图像缓存的唯一标识符
ImageStyle
The style of an image element.
Img
An image element.
ImgLayoutState
The image layout state between frames
Inspector
管理检查器状态 —— 当前选中的元素以及检查器是否处于拾取模式。
InspectorElementId
可被检查的元素的唯一标识符。
InspectorElementPath
具有元素构造源位置的 GlobalElementId
InteractiveElementState
The per-frame state of an interactive element. Used for tracking stateful interactions like clicks and scroll offsets.
InteractiveText
A text element that can be interacted with.
Interactivity
The interactivity struct. Powers all of the general-purpose interactivity in the Div element.
InvalidKeystrokeError
Keystroke::parse 的错误类型。使用此类型而不是 anyhow::Error,以便 Zed 可以使用 markdown 来显示它。
ItemSize
The size of the item and its contents.
KeyBinding
键绑定及其关联的元数据,来自键映射
KeyBindingMetaIndex
用于检索与键绑定关联元数据的唯一标识符。 用作用户定义的元数据存储的索引或键, 例如绑定的来源。
KeyContext
用于解析是否应在元素树的当前位置分发动作的数据结构。 包含一组标识符和/或键值对,表示键映射的当前上下文。
KeyDownEvent
平台的按键按下事件等效物。
KeyUpEvent
平台的按键释放事件等效物。
KeybindingKeystroke
表示可用于键绑定并向用户显示的按键。
KeyboardClickEvent
由键盘按钮按下并释放生成的点击事件。
Keymap
用户应用程序的键绑定集合。
KeymapVersion
当前活动的键映射版本的不透明标识符。 每当添加或删除绑定时,键映射的版本都会更改。
Keystroke
由平台生成的按键及关联元数据
KeystrokeEvent
A keystroke event, and potentially the associated action
LayoutId
A unique identifier for a layout node, generated when requesting a layout from Taffy
LineLayout
已排版和样式化的文本行
LineWrapper
The GPUI line wrapper, used to wrap lines of text to a given width.
LineWrapperHandle
A handle into the text system, which can be used to compute the wrapped layout of text
LinearColorStop
线性渐变中的颜色停止点。
List
A list element
ListOffset
An offset into the list’s items, in terms of the item index and the number of pixels off the top left of the item.
ListPrepaintState
Frame state used by the List element after layout.
ListScrollEvent
A scroll event that has been converted to be in terms of the list’s items.
ListState
The list state that views must hold on behalf of the list element.
Menu
应用程序菜单,可以是主菜单或子菜单
Modifiers
某个时间点的修饰键状态
ModifiersChangedEvent
平台的修饰符更改事件等效物。
MonochromeSprite
MouseClickEvent
点击事件,当鼠标按钮按下并释放时生成。
MouseDownEvent
来自平台的鼠标按下事件
MouseExitEvent
来自平台的鼠标离开事件,当鼠标离开窗口时生成。
MouseMoveEvent
来自平台的鼠标移动事件。
MousePressureEvent
来自平台的鼠标压力事件。当用力按压力敏感触控板时生成。 目前仅在 macOS 触控板上实现。
MouseUpEvent
来自平台的鼠标释放事件
NoAction
Action with special handling which unbinds the keybinding this is associated with, if it is the highest precedence match.
NoopTextSystem
OsInfo
操作系统信息
OsMenu
操作系统菜单,由操作系统识别 这允许操作系统为这些菜单提供专门的菜单项
OwnedMenu
应用程序菜单,可以是主菜单或子菜单
OwnedOsMenu
操作系统菜单,由操作系统识别 这允许操作系统为这些菜单提供专门的行为
PaintQuad
A rectangle to be rendered in the window at the given position and size. Passed as an argument Window::paint_quad.
PaintSurface
Path
由一系列顶点和控制点组成的线。
PathBuilder
Path 构建器。
PathId
PathPromptOptions
文件对话框提示的可配置选项
PathVertex
Percentage
A type representing a percentage value.
PinchEvent
来自平台的捏合手势事件,当用户执行 捏合缩放手势时生成(通常在触控板上)。
Pixels
Represents a length in pixels, the base unit of measurement in the UI framework.
PlatformInputHandler
Point
Describes a location in a 2D cartesian space.
PointRefinement
[#ident] 的可细化版本,详见该文档。
PolychromeSprite
PromptHandle
可用于与提示交互的句柄
PromptResponse
选择提示选项时触发的事件。 usize 是所选选项的索引,来自传递给提示的动作
Quad
Radians
Represents an angle in Radians
Rems
Represents a length in rems, a unit based on the font-size of the window, which can be assigned with Window::set_rem_size.
RenderGlyphParams
Parameters for rendering a glyph, used as cache keys for raster bounds.
RenderImage
已缓存并处理的图像,采用 BGRA 格式
RenderImageParams
RenderSvgParams
RenderablePromptHandle
可在窗口中渲染的提示句柄
RequestFrameOptions
Reservation
Context::reserve_entity 返回,用于稍后传递给 Context::insert_entity。 允许你在实体创建之前获取其 EntityId
RetainAllImageCache
An implementation of ImageCache, that uses an LRU caching strategy to unload images when the cache is full
RetainAllImageCacheProvider
A provider struct for creating a retain-all image cache inline
Rgba
一个 RGBA 颜色
ScaledPixels
Represents scaled pixels that take into account the device’s scale factor.
Scene
Scope
Scope 管理一组一起入队并等待的任务。参见 BackgroundExecutor::scoped
ScreenCaptureFrame
从屏幕捕获的视频帧
ScrollAnchor
Represents an element that can be scrolled to in its parent element. Contrary to ScrollHandle::scroll_to_active_item, an anchored element does not have to be an immediate child of the parent.
ScrollHandle
A handle to the scrollable aspects of an element. Used for accessing scroll state, like the current scroll offset, and for mutating the scroll state, like scrolling to a specific child.
ScrollWheelEvent
来自平台的鼠标滚轮事件。
Shadow
ShapedGlyph
单个字形,准备绘制
ShapedLine
已塑形和装饰的文本行
ShapedRun
已塑形的文本段
SharedString
共享字符串是 GPUI 任务中可以廉价克隆的不可变字符串。 本质上是 Arc<str>&'static str 的抽象, 当前由 SmolStr 支持。
SharedUri
包含 URI 的 SharedString
Size
表示一个两维的尺寸,包含给定单位的宽度和高度。
SizeRefinement
[#ident] 的可细化版本,详见该文档。
SourceMetadata
屏幕捕获源的元数据
Stateful
A wrapper around an element that can store state, produced after assigning an ElementId.
StrikethroughStyle
可以应用于删除线的属性。
StrikethroughStyleRefinement
[#ident] 的可细化版本,详见该文档。
StrokeOptions
Parameters for the tessellator.
Style
可以通过 Styled trait 应用于元素的 CSS 样式
StyleRefinement
[#ident] 的可细化版本,详见该文档。
StyledText
Renders text with runs of different styles.
SubpixelSprite
Subscription
A handle to a subscription created by GPUI. When dropped, the subscription is cancelled and the callback will no longer be invoked.
Surface
A surface element.
Svg
An SVG element.
SvgRenderer
A struct holding everything necessary to render SVGs.
SystemWindowTabController
窗口标签页的控制器。
TextLayout
The Layout for TextElement. This can be used to map indices to pixels and vice versa.
TextRun
用于 crate::TextLayout 的样式化文本段。
TextStyle
可用于在 GPUI 中设置文本样式的属性
TextStyleRefinement
[#ident] 的可细化版本,详见该文档。
TextSystem
GPUI 文本渲染子系统。
TileId
Tiling
描述窗口哪些边缘当前被平铺
TitlebarOptions
窗口标题栏可配置的选项
Toast
Toast 通知结构体
ToastStack
Toast 通知堆栈实体
TooltipId
An identifier for a tooltip.
Transformation
A transformation to apply to an SVG element.
TransformationMatrix
表示可应用于元素的二维变换的数据类型。
Tray
系统托盘图标
TrayIconData
渲染后的图标数据,供平台使用
UTF16Selection
文本缓冲区中表示选区的结构,使用 UTF16 字符 与普通的 Range 不同,因为选区的头部可能在尾部之前
Unbind
Action with special handling which unbinds later bindings for the same keystrokes when they dispatch the named action, regardless of that action’s context.
Underline
UnderlineStyle
可以应用于下划线的属性。
UnderlineStyleRefinement
[#ident] 的可细化版本,详见该文档。
UniformList
A list element for efficiently laying out and displaying a list of uniform-height elements.
UniformListFrameState
Frame state used by the UniformList.
UniformListScrollHandle
A handle for controlling the scroll position of a uniform list. This should be stored in your view and passed to the uniform_list on each frame.
UniformListScrollState
UtilDeferred
丢弃时运行闭包的守卫,除非被中止
WeakEntity
A weak reference to a entity of the given type.
WeakFocusHandle
A weak reference to a focus handle.
Window
Holds the state for a specific window.
WindowButtonLayout
描述标题栏每侧出现哪些控制按钮
WindowControls
平台支持的窗口控制按钮
WindowHandle
A handle to a window with a specific root view type. Note that this does not keep the window alive on its own.
WindowId
A unique identifier for a window.
WindowOptions
创建新窗口时可配置的选项
WindowParams
创建新窗口时传递给平台的参数
WindowTextSystem
GPUI 文本布局子系统。
WrapBoundary
行被换行时的换行边界
WrappedLine
由文本布局系统塑形、装饰和换行的文本行
WrappedLineLayout
已换行以适应给定宽度的文本行

Enums§

AbsoluteLength
Represents an absolute length in pixels or rems.
ActionBuildError
Error type for Keystroke::parse. This is used instead of anyhow::Error so that Zed can use markdown to display it.
AlignContent
设置内容之间和周围的空间分布 对于 Flexbox,它控制交叉轴中的对齐 对于 Grid,它控制块轴中的对齐
AlignItems
Used to control how child nodes are aligned. For Flexbox it controls alignment in the cross axis For Grid it controls alignment in the block axis
Anchor
Identifies a reference point on a 2D box, used to anchor positioned elements.
AnchoredFitMode
Which algorithm to use when fitting the anchored element to be inside the window.
AnchoredPositionMode
Which algorithm to use when positioning the anchored element.
ArcCow
基于 Arc 的写时复制智能指针
AssetLogger
一个资源加载器,在加载期间记录 ResultErr 变体
AtlasKey
AtlasTextureKind
AttentionType
请求用户注意力的类型
AvailableSpace
The space available for an element to be laid out in
Axis
二维笛卡尔空间中的轴。
BiometricKind
可用的生物识别认证类型
BiometricStatus
生物识别认证的可用性状态
BlendMode
渲染四边形时应用的混合模式。
BorderStyle
边框的样式。
ClickEvent
点击事件,当鼠标按钮或键盘按钮按下并释放时生成。
ClipboardEntry
剪贴板条目类型,可以是文本、图片或外部文件路径
ColorSpace
用于颜色插值的颜色空间。
CursorHideMode
控制 GPUI 何时响应键盘输入自动隐藏鼠标光标。
CursorStyle
鼠标指针样式
Decorations
描述窗口当前的装饰配置
DefiniteLength
A non-auto length that can be defined in pixels, rems, or percent of parent.
DialogKind
原生对话框类型
DispatchPhase
表示事件分发时的两个不同阶段。
Display
设置此节点子项使用的布局
ElementId
An identifier for an Element.
FileDropEvent
来自平台的文件拖放事件,当文件被拖放并放到窗口上时生成。
Fill
可以应用于形状的填充类型。
FillRule
The fill rule defines how to determine what is inside and what is outside of the shape.
FlexDirection
flexbox 布局主轴的方向。
FlexWrap
控制 flex 项目是否强制放在一行或可以换行到多行。
FollowMode
Controls whether the list automatically follows new content at the end.
FontStyle
允许选择斜体或倾斜字体。
GridPlacement
The placement of an item within a grid layout’s column or row.
HitboxBehavior
hitbox 影响鼠标行为的方式。
ImageAssetLoader
An image loader for the GPUI asset system
ImageCacheError
An error that can occur when interacting with the image cache.
ImageCacheItem
An image cache item
ImageFormat
One of the editor’s supported image formats (e.g. PNG, JPEG) - used when dealing with images in the clipboard
ImageSource
A source of image content.
KeyBindingContextPredicate
用于解析是否应分发动作的数据结构。 表示一种小型语言,用于描述哪些上下文对应哪些动作。
KeyboardButton
表示点击事件按下的键盘按钮的枚举。
Length
A length that can be defined in pixels, rems, percent of parent, or auto.
LineFragment
A fragment of a line that can be wrapped.
ListAlignment
Whether the list is scrolling from top to bottom or bottom to top.
ListHorizontalSizingBehavior
The horizontal sizing behavior to apply during layout.
ListMeasuringBehavior
The measuring behavior to apply during layout.
ListSizingBehavior
The sizing behavior to apply during layout.
MediaKeyEvent
媒体键事件,来自硬件媒体键或系统媒体控件
MenuItem
菜单中可以的不同类型的菜单项
MouseButton
表示按下的鼠标按钮的枚举。
NavigationDirection
导航方向,如后退或前进。
NetworkStatus
当前网络连接状态
ObjectFit
图像如何适应元素边界的方式。
OsAction
操作系统操作,由操作系统识别 这允许操作系统为这些操作提供专门的行为
Overflow
子元素溢出容器时如何影响布局
OwnedMenuItem
菜单中可以的不同类型的菜单项
PathStyle
PathBuilder 的样式
PermissionStatus
权限状态枚举
PermissionType
权限类型枚举
PlatformInput
对应所有类型平台输入事件的枚举。
Position
此项目的定位策略。
PowerSaveBlockerKind
电源阻止器类型,用于阻止系统进入省电模式
PressureStage
压力点击事件的阶段。
Primitive
PrimitiveBatch
ProgressBarState
任务栏/程序坞进度条状态
PromptButton
提示框按钮
PromptLevel
提示框的样式级别
QuitMode
定义应用程序何时应该自动退出。
ResizeEdge
窗口可调整大小的边缘位置
Resource
表示资源位置的枚举
ScrollDelta
滚轮事件的滚动增量。
ScrollStrategy
Where to place the element scrolled to.
SurfaceSource
A source of a surface’s content.
SvgSize
The size in which to render the SVG.
SystemMenuType
系统菜单类型
SystemPowerEvent
系统电源状态变更事件
TemplateColumnMinSize
网格布局中列或行的最小尺寸
TextAlign
如何对齐元素内的文本
TextOverflow
如何截断超出元素宽度的文本
TextRenderingMode
绘制字形时使用的文本渲染模式
ThermalState
系统热状态,表示 CPU/GPU 的热限制情况
ToastPosition
Toast 位置枚举
TouchPhase
触摸运动事件的阶段。 基于同名 winit 枚举。
TrayIconEvent
系统托盘图标事件类型
TrayMenuItem
系统托盘菜单项类型
TruncateFrom
Determines whether to truncate text from the start or end.
Visibility
类似于 CSS visibility 属性的可见性值
WhiteSpace
如何处理文本中的空白字符
WindowAppearance
窗口外观,由操作系统定义
WindowBackgroundAppearance
窗口背景的外观,当没有内容或内容透明时使用
WindowBounds
表示窗口的打开状态
WindowButton
标题栏中的窗口控制按钮类型
WindowControlArea
对应于平台窗口的窗口控制区域类型。
WindowDecorations
窗口装饰类型,决定使用服务端还是客户端装饰
WindowKind
要创建的窗口类型
WindowPosition
语义化窗口位置,用于相对于屏幕定位窗口

Constants§

DEFAULT_ADDITIONAL_WINDOW_SIZE
A 6:5 aspect ratio minimum window size to be used for functional, additional-to-main-Zed windows, like the settings and rules library windows.
DEFAULT_WINDOW_SIZE
Default window size used when no explicit size is provided.
KEYSTROKE_PARSE_EXPECTED_MESSAGE
按键解析器期望的格式说明,以 “Expected …” 开头
LOADING_DELAY
The delay before showing the loading state.
MAX_BUTTONS_PER_SIDE
标题栏每侧最多可放置的按钮数量
SHUTDOWN_TIMEOUT
应用程序退出前,Context::on_app_quit 返回的 future 可以运行的持续时间。
SMOOTH_SVG_SCALE_FACTOR
When rendering SVGs, we render them at twice the size to get a higher-quality result.
SUBPIXEL_VARIANTS_X
Number of subpixel glyph variants along the X axis.
SUBPIXEL_VARIANTS_Y
Number of subpixel glyph variants along the Y axis.

Traits§

Action
Actions are used to implement keyboard-driven UI. When you declare an action, you can bind keys to the action in the keymap and listeners for that action in the element tree.
Along
用于沿特定轴访问给定单位的 trait。
AnimationExt
An extension trait for adding the animation wrapper to both Elements and Components
AppContext
GPUI 中的上下文 trait,允许不同的上下文类型 在某些操作中可以互换使用。
AsKeystroke
这是一个辅助 trait,用于简化某些函数的实现
Asset
用于异步加载资源的 trait。
AssetSource
应用程序使用的资源来源。
BorrowAppContext
一个辅助 trait,用于在可以互换使用的上下文上 自动实现某些方法。
Element
实现此 trait 的类型将参与窗口内容的布局和绘制。 元素形成一棵树,并根据 Taffy 实现的基于 Web 的布局规则进行布局。 你可以通过实现此 trait 来创建自定义元素,详见模块级文档。
EntityInputHandler
实现此 trait 以允许视图在处理编辑器、输入框等时处理文本输入。
EventEmitter
用于绑定 GPUI 实体类型与其可发出的事件类型的 trait。
Focusable
Focusable 允许用户通过 window.focus_view(cx, view) 来聚焦你的视图。
GestureEvent
来自平台的手势事件。
Global
A marker trait for types that can be stored in GPUI’s global state.
Half
Provides a trait for types that can calculate half of their value.
ImageCache
An object that can handle the caching and unloading of images. Implementations of this trait should ensure that images are removed from all windows when they are no longer needed.
ImageCacheProvider
An object that can create an ImageCache during the render phase. See the ImageCache trait for more information.
InputEvent
来自平台输入源的事件。
InputHandler
Zed 处理平台 IME 系统文本输入的接口 当前为 NSTextInputClient API 的 1:1 映射:
InteractiveElement
A trait for elements that want to use the standard GPUI event handlers that don’t require any state.
IntoElement
由任何可以转换为元素的类型实现。
IsZero
A trait for checking if a value is zero.
KeyEvent
来自平台的按键事件。
ManagedView
ManagedView 是由另一个视图管理生命周期的视图 (如 Modal、Popover、Menu 等)。
MouseEvent
来自平台的鼠标事件。
ParentElement
此 trait 用于为任何实现 IntoElement 的类型提供 uniform 接口, 使其可以接受任意数量的任意类型的子元素。
Platform
平台抽象层 trait,定义了与操作系统交互所需的所有接口 各平台(Windows、macOS、Linux、Web)需实现此 trait 以提供平台特定功能
PlatformAtlas
平台图集 trait,用于管理纹理图集的插入和移除
PlatformDisplay
平台显示器句柄 trait,表示物理显示器或笔记本屏幕
PlatformKeyboardLayout
平台特定键盘布局的 trait
PlatformKeyboardMapper
平台特定键盘映射的 trait
PlatformTextSystem
平台文本系统 trait,负责字体加载、字形渲染和文本布局
PlatformWindow
平台窗口 trait,定义了窗口操作的核心接口 各平台窗口实现需实现此 trait
Prompt
可在窗口中渲染的提示
ReadGlobal
A trait for reading a global value from the context.
Render
可以被绘制到屏幕的对象。这是区分“视图“与其他实体的 trait。 视图是实现 RenderEntity,会被绘制到屏幕上。
RenderOnce
You can derive IntoElement on any type that implements this trait. It is used to construct reusable components out of plain data. Think of components as a recipe for a certain pattern of elements. RenderOnce allows you to invoke this pattern, without breaking the fluent builder pattern of the element APIs.
ResultExt
Result 类型的扩展特征,提供日志工具
ScreenCaptureSource
可捕获的屏幕视频内容源
ScreenCaptureStream
从屏幕捕获的视频流
StatefulInteractiveElement
A trait for elements that want to use the standard GPUI interactivity features that require state.
Styled
可设置样式的元素的 trait。 使用此功能可选择使用实用程序 CSS 类似样式 API。
StyledImage
Style an image element.
TaskExt
Task<Result<T, E>> 的扩展 trait,添加了带有 &App 上下文的 detach_and_log_err
TryFutureExt
Future 类型的扩展特征,提供日志工具
TryFutureExtBacktrace
Future 类型的扩展特征,提供回溯日志
UniformListDecoration
A decoration for a UniformList. This can be used for various things, such as rendering indent guides, or other visual effects.
UpdateGlobal
A trait for updating a global value in the context.
VisualContext
用于 GPUI 中不同可视化上下境的 trait, 这些上下文需要窗口才能运行。

Functions§

anchored
anchored gives you an element that will avoid overflowing the window bounds. Its children should have no margin to avoid measurement issues.
auto
Returns a Length representing an automatic length.
black
Hsla 中的纯黑色
block_on
Block the thread until the future is ready.
blue
Hsla 中的蓝色
bounce
Apply the given easing function, first in the forward direction and then in the reverse direction
bounds
Create a bounds with the given origin and size
canvas
Construct a canvas element with the given paint callback. Useful for adding short term custom drawing to a view.
checkerboard
创建棋盘图案背景
combine_highlights
组合并合并两个迭代器中的高亮和范围。
conic_gradient
创建锥形(扫描)渐变背景。
defer
运行给定函数,当返回值被丢弃时(除非被中止)
deferred
Builds a Deferred element, which delays the layout and paint of its child.
div
Construct a new Div element
ease_in_out
The quadratic ease-in-out function, which starts and ends slowly but speeds up in the middle
ease_out_quint
The Quint ease-out function, which starts quickly and decelerates to a stop
fallback_prompt_renderer
使用此函数与 App::set_prompt_builder 结合,可强制 GPUI 始终使用回退提示渲染器
fill
Creates a filled quad with the given bounds and background color.
font
Get a Font for a given name.
font_name_with_fallbacks
Maps well-known virtual font names to their concrete equivalents.
font_name_with_fallbacks_shared
Like font_name_with_fallbacks but accepts and returns SharedString references.
generate_list_of_all_registered_actions
Generate a list of all the registered actions. Useful for transforming the list of available actions into a format suited for static analysis such as in validating keymaps, or generating documentation.
get_gamma_correction_ratios
计算子像素文本渲染的伽马校正比率
green
Hsla 中的绿色
guess_compositor
猜测当前 Linux 桌面环境使用的显示服务器类型 不会实际尝试连接显示服务器
hash
使用快速、非密码学安全的哈希函数从数据中获取标识符
hsla
使用普通值构造 Hsla 对象
image_cache
An image cache element, all its child img elements will use the cache specified by this element. Note that this could as simple as passing an Entity<T: ImageCache>
img
Create a new image element.
is_no_action
Returns whether or not this action represents a removed key binding.
is_unbind
Returns whether or not this action represents an unbind marker.
linear
The linear easing function, or delta itself
linear_color_stop
创建新的线性颜色停止点。
linear_gradient
创建 LinearGradient 背景颜色。
list
Construct a new list element
log_err
measure
如果设置了 ZED_MEASUREMENTS 环境变量,则测量闭包的执行时间
multi_stop_linear_gradient
创建最多 4 个颜色停止点的线性渐变。
opaque_grey
Hsla 中的不透明灰色,值将被限制在 [0, 1] 范围内
outline
Creates a rectangle outline with the given bounds, border color, and a 1px border width
pattern_slash
创建哈希图案背景
percentage
Generate a Radian from a percentage of a full circle.
phi
Returns the Golden Ratio, i.e. ~(1.0 + sqrt(5.0)) / 2.0.
point
Constructs a new Point<T> with the given x and y coordinates.
post_inc
递增一个值并返回先前的值
pulsating_between
A custom easing function for pulsating alpha that slows down as it approaches 0.1
px
Constructs a Pixels value representing a length in pixels.
quad
Creates a quad with the given parameters.
quadratic
The quadratic easing function, delta * delta
radial_gradient
创建径向渐变背景。
radians
Create a Radian from a raw value
red
Hsla 中的红色
relative
Constructs a DefiniteLength representing a relative fraction of a parent size.
rems
Constructs a Rems value representing a length in rems.
retain_all
Constructs a retain-all image cache that uses the element state associated with the given ID.
rgb
将 RGB 十六进制颜色代码转换为颜色类型
rgba
将 RGBA 十六进制颜色代码转换为 Rgba
size
Constructs a new Size<T> with the provided width and height.
solid_background
创建纯色背景颜色。
some_or_debug_panic
返回选项值,如果在调试模式下为 None 则 panic
svg
Create a new SVG element.
swap_rgba_pa_to_bgra
从预乘 alpha 的 RGBA 转换为 BGRA
transparent_black
Hsla 中的透明黑色
transparent_white
Hsla 中的透明白色
uniform_list
uniform_list provides lazy rendering for a set of items that are of uniform height. When rendered into a container with overflow-y: hidden and a fixed (or max) height, uniform_list will only render the visible subset of items.
white
Hsla 中的纯白色
yellow
Hsla 中的黄色

Type Aliases§

AlignSelf
用于控制如何对齐指定的节点。 覆盖父节点的 AlignItems 属性。 对于 Flexbox,它控制交叉轴中的对齐 对于 Grid,它控制块轴中的对齐
DrawOrder
ImageLoadingTask
An image loading task associated with an image cache.
ImgResourceLoader
A type alias to the resource loader that the img() element uses.
InspectorRenderer
设置在 App 上用于渲染检查器 UI 的函数。
JustifyContent
设置内容之间和周围的空间分布 对于 Flexbox,它控制主轴中的对齐 对于 Grid,它控制内联轴中的对齐
JustifyItems
用于控制如何对齐子节点。 不适用于 Flexbox,如果在 flex 容器上指定将被忽略 对于 Grid,它控制内联轴中的对齐
JustifySelf
用于控制如何对齐指定的节点。 覆盖父节点的 JustifyItems 属性。 不适用于 Flexbox,如果在 flex 子项上指定将被忽略 对于 Grid,它控制内联轴中的对齐
PathVertex_ScaledPixels
Result
Result<T, Error>
RunnableVariant
带元数据的可运行任务类型别名
TimerResolutionGuard
Transform
Alias for euclid::default::Transform2D<f32>

Attribute Macros§

ctor
property_test
#[rgpui::property_test] 属性测试宏 - 支持基于属性的测试(property-based testing)。
test
#[rgpui::test] 测试属性宏 - 用于注解需要 GPUI 支持的测试函数。

Derive Macros§

Action
Action 派生宏 - 用于为结构体自动实现 rgpui::Action 特质。
AppContext
AppContext 派生宏 - 用于为持有 &mut App 的结构体生成应用上下文实现。
IntoElement
IntoElement 派生宏 - 用于将实现了 RenderOnce 特质的类型转换为 UI 组件。
VisualContext
VisualContext 派生宏 - 用于为持有 &mut Window 并实现了 AppContext 的类型生成可视化上下文实现。