Expand description
§rgpui
rgpui 是 rgpui 项目的核心 crate,是一个混合即时/保留模式、GPU 加速的 Rust UI 框架。
关于项目背景、重命名原因和整体架构,请参见项目根目录 README。
§主要特性
- 混合即时/保留模式:结合即时模式的高性能与保留模式的状态管理优势
- 基于 Entity 的状态管理:通过智能指针安全地在应用各部分之间共享和通信状态
- 声明式视图(View):实现
Rendertrait 即可构建声明式 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.
- Anchored
State - The state that the anchored element element uses to track its children.
- Animation
- An animation that can be applied to an element.
- Animation
Element - 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>. - AnyImage
Cache - 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。
- AnyWeak
Entity - A type erased, weak reference to a entity.
- AnyWeak
View - 一个弱的、动态类型的视图句柄,不会阻止视图被释放。
- AnyWindow
Handle - 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函数中构建。 除了在初始配置和启动阶段外,你通常不会直接与这个类型交互。 - Arena
Clear Needed - Returned when the element arena has been used and so must be cleared before the next draw.
- Async
App - App 的异步友好版本,具有静态生命周期,因此可以在异步代码的
await点之间持有。 调用 App::spawn 时会提供此实例,你也可以通过 App::to_async 创建。 - Async
Window Context - 对应用上下文的克隆 owned 句柄, 与当前任务关联的窗口组合在一起。
- Atlas
Texture Id - Atlas
Tile - Background
- 背景颜色,可以是纯色或线性渐变。
- Background
Executor - 指向当前正在运行的执行器的指针, 用于生成后台任务。
- Binding
Index - 键映射内绑定的索引。
- Boundary
- A boundary between two lines of text.
- Bounds
- 表示 2D 空间中的矩形区域,包含原点和尺寸。
- Bounds
Refinement - [
#ident] 的可细化版本,详见该文档。 - BoxShadow
- box-shadow 属性的可能值
- Canvas
- A canvas element, meant for accessing the low level paint API without defining a whole custom element
- Capslock
- 某个时间点的 capslock 键状态
- Clipboard
Item - 应复制到剪贴板的项目
- Clipboard
String - A clipboard item that should be copied to the clipboard
- Content
Mask - 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
- 应用上下文,针对给定实体具有专门行为。
- Context
Entry - KeyContext 中的条目
- Corners
- Represents the corners of a box in a 2D space, such as border radius.
- Corners
Refinement - [
#ident] 的可细化版本,详见该文档。 - Debug
Below - 使用此结构与你自己元素中的 ‘debug_below’ 样式进行交互。 如果父元素设置了此样式,则此结构将被设置为 GPUI 中的全局值。
- Decoration
Run - 设置文本段的文本装饰
- 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.
- Deferred
Scroll ToItem - Device
Pixels - Represents physical pixels on the display.
- Dialog
Options - 原生对话框的选项
- Dismiss
Event - 由
ManagedView的实现者发出,表示视图应该被解散, 例如当视图作为模态框呈现时。 - Dispatch
Event Result - Display
Id - 硬件显示器的不透明标识符
- Div
- A
Divelement, the all-in-one element for building complex UIs in GPUI - DivFrame
State - A frame state for a
Divelement, which contains layout IDs for its children. - DivInspector
State - Interactivity state displayed an manipulated in the inspector.
- Drag
Move Event - An event for when a drag is moving over this element, with the given state type.
- Drawable
- A wrapper around an implementer of
Elementthat allows it to be drawn in a window. - Dummy
Keyboard Mapper - 平台键盘映射器的虚拟实现
- Edges
- Represents the edges of a box in a 2D space, such as padding or margin.
- Edges
Refinement - [
#ident] 的可细化版本,详见该文档。 - Element
Clicked State - Whether or not the element or a group that contains it is clicked by the mouse.
- Element
Hover State - Whether or not the element or a group that contains it is hovered.
- Element
Input Handler crate::PlatformInputHandler的标准实现。在元素的 paint 阶段 使用实例调用Window::handle_input。- Empty
- 空的元素,不渲染任何内容。
- Empty
View - 一个不渲染任何内容的视图
- Entity
- A strong, well-typed reference to a struct which is managed by GPUI
- Entity
Id - A unique identifier for a entity across the application.
- External
Paths - 来自平台的路径集合,如从文件拖放中获取。
- Fallback
Prompt Renderer - 默认的 GPUI 回退提示渲染,当平台不支持时使用
- Fill
Options - Parameters for the fill tessellator.
- Focus
Handle - 用于跟踪和操控窗口中聚焦元素的句柄。
- FocusId
- A globally unique identifier for a focusable element.
- Focus
OutEvent - This is provided when subscribing for
Context::on_focus_outevents. - Focused
Window Info - 当前系统聚焦窗口的信息
- Font
- 用于标识特定字体的配置详情。
- Font
Fallbacks - 指定字体可配置的备用字体。 备用字体的字体族名称存储在此结构中。
- Font
Family Id - 特定字体族的不透明标识符。
- Font
Features - 可为给定字体配置的 OpenType 功能。
- FontId
- 特定字体的不透明标识符。
- Font
Metrics - 用于存储字体指标的结构体。 用于定义字体的测量值。
- FontRun
- 具有单一字体的文本段
- Font
Weight - 文本的字重,范围从 100.0 到 900.0, 其中 400.0 为正常字重。
- Foreground
Executor - 指向当前正在运行的执行器的指针, 用于在主线程上生成任务。
- Global
Element Id - 元素的全局唯一标识符,用于跨帧跟踪状态。
- Global
HotKey Event - 全局快捷键事件
- GlyphId
- 特定字形的标识符,由
WindowTextSystem::layout_line返回。 - Glyph
Raster Data - 预计算的字形光栅数据,用于高效绘制而无需每个字形缓存查找。
- GpuSpecs
- 关于 GPUI 运行所在的 GPU 的信息。
- Gpui
Borrow - A mutable reference to an entity owned by GPUI
- Grid
Location - A location in a grid layout.
- Grid
Template grid-template-*值的简化表示- Grid
Template Refinement - [
#ident] 的可细化版本,详见该文档。 - Group
Style - The styling information for a given group.
- Highlight
Style - 高亮样式,类似于
TextStyle,但适用于单一字体、 统一大小和间距的文本。 - Hitbox
- 一个矩形的命中区域,可能会阻止先插入的 hitbox。 详见 Window::insert_hitbox。
- Hitbox
Id - An identifier for a Hitbox which also includes HitboxBehavior.
- Hsla
- 一个 HSLA 颜色
- Image
- An image, with a format and certain bytes
- Image
Cache Element - An image cache element.
- Image
Format Iter - An iterator over the variants of ImageFormat
- ImageId
- 图像缓存的唯一标识符
- Image
Style - The style of an image element.
- Img
- An image element.
- ImgLayout
State - The image layout state between frames
- Inspector
- 管理检查器状态 —— 当前选中的元素以及检查器是否处于拾取模式。
- Inspector
Element Id - 可被检查的元素的唯一标识符。
- Inspector
Element Path - 具有元素构造源位置的
GlobalElementId。 - Interactive
Element State - The per-frame state of an interactive element. Used for tracking stateful interactions like clicks and scroll offsets.
- Interactive
Text - A text element that can be interacted with.
- Interactivity
- The interactivity struct. Powers all of the general-purpose
interactivity in the
Divelement. - Invalid
Keystroke Error Keystroke::parse的错误类型。使用此类型而不是anyhow::Error,以便 Zed 可以使用 markdown 来显示它。- Item
Size - The size of the item and its contents.
- KeyBinding
- 键绑定及其关联的元数据,来自键映射
- KeyBinding
Meta Index - 用于检索与键绑定关联元数据的唯一标识符。 用作用户定义的元数据存储的索引或键, 例如绑定的来源。
- KeyContext
- 用于解析是否应在元素树的当前位置分发动作的数据结构。 包含一组标识符和/或键值对,表示键映射的当前上下文。
- KeyDown
Event - 平台的按键按下事件等效物。
- KeyUp
Event - 平台的按键释放事件等效物。
- Keybinding
Keystroke - 表示可用于键绑定并向用户显示的按键。
- Keyboard
Click Event - 由键盘按钮按下并释放生成的点击事件。
- Keymap
- 用户应用程序的键绑定集合。
- Keymap
Version - 当前活动的键映射版本的不透明标识符。 每当添加或删除绑定时,键映射的版本都会更改。
- Keystroke
- 由平台生成的按键及关联元数据
- Keystroke
Event - A keystroke event, and potentially the associated action
- Layout
Id - A unique identifier for a layout node, generated when requesting a layout from Taffy
- Line
Layout - 已排版和样式化的文本行
- Line
Wrapper - The GPUI line wrapper, used to wrap lines of text to a given width.
- Line
Wrapper Handle - A handle into the text system, which can be used to compute the wrapped layout of text
- Linear
Color Stop - 线性渐变中的颜色停止点。
- List
- A list element
- List
Offset - 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.
- List
Prepaint State - Frame state used by the List element after layout.
- List
Scroll Event - A scroll event that has been converted to be in terms of the list’s items.
- List
State - The list state that views must hold on behalf of the list element.
- Menu
- 应用程序菜单,可以是主菜单或子菜单
- Modifiers
- 某个时间点的修饰键状态
- Modifiers
Changed Event - 平台的修饰符更改事件等效物。
- Monochrome
Sprite - Mouse
Click Event - 点击事件,当鼠标按钮按下并释放时生成。
- Mouse
Down Event - 来自平台的鼠标按下事件
- Mouse
Exit Event - 来自平台的鼠标离开事件,当鼠标离开窗口时生成。
- Mouse
Move Event - 来自平台的鼠标移动事件。
- Mouse
Pressure Event - 来自平台的鼠标压力事件。当用力按压力敏感触控板时生成。 目前仅在 macOS 触控板上实现。
- Mouse
UpEvent - 来自平台的鼠标释放事件
- NoAction
- Action with special handling which unbinds the keybinding this is associated with, if it is the highest precedence match.
- Noop
Text System - OsInfo
- 操作系统信息
- OsMenu
- 操作系统菜单,由操作系统识别 这允许操作系统为这些菜单提供专门的菜单项
- Owned
Menu - 应用程序菜单,可以是主菜单或子菜单
- Owned
OsMenu - 操作系统菜单,由操作系统识别 这允许操作系统为这些菜单提供专门的行为
- Paint
Quad - A rectangle to be rendered in the window at the given position and size.
Passed as an argument
Window::paint_quad. - Paint
Surface - Path
- 由一系列顶点和控制点组成的线。
- Path
Builder Path构建器。- PathId
- Path
Prompt Options - 文件对话框提示的可配置选项
- Path
Vertex - Percentage
- A type representing a percentage value.
- Pinch
Event - 来自平台的捏合手势事件,当用户执行 捏合缩放手势时生成(通常在触控板上)。
- Pixels
- Represents a length in pixels, the base unit of measurement in the UI framework.
- Platform
Input Handler - Point
- Describes a location in a 2D cartesian space.
- Point
Refinement - [
#ident] 的可细化版本,详见该文档。 - Polychrome
Sprite - Prompt
Handle - 可用于与提示交互的句柄
- Prompt
Response - 选择提示选项时触发的事件。 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. - Render
Glyph Params - Parameters for rendering a glyph, used as cache keys for raster bounds.
- Render
Image - 已缓存并处理的图像,采用 BGRA 格式
- Render
Image Params - Render
SvgParams - Renderable
Prompt Handle - 可在窗口中渲染的提示句柄
- Request
Frame Options - Reservation
- 由 Context::reserve_entity 返回,用于稍后传递给 Context::insert_entity。 允许你在实体创建之前获取其 EntityId。
- Retain
AllImage Cache - An implementation of ImageCache, that uses an LRU caching strategy to unload images when the cache is full
- Retain
AllImage Cache Provider - A provider struct for creating a retain-all image cache inline
- Rgba
- 一个 RGBA 颜色
- Scaled
Pixels - Represents scaled pixels that take into account the device’s scale factor.
- Scene
- Scope
- Scope 管理一组一起入队并等待的任务。参见
BackgroundExecutor::scoped。 - Screen
Capture Frame - 从屏幕捕获的视频帧
- Scroll
Anchor - 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.
- Scroll
Handle - 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.
- Scroll
Wheel Event - 来自平台的鼠标滚轮事件。
- Shadow
- Shaped
Glyph - 单个字形,准备绘制
- Shaped
Line - 已塑形和装饰的文本行
- Shaped
Run - 已塑形的文本段
- Shared
String - 共享字符串是 GPUI 任务中可以廉价克隆的不可变字符串。
本质上是
Arc<str>和&'static str的抽象, 当前由SmolStr支持。 - Shared
Uri - 包含 URI 的
SharedString。 - Size
- 表示一个两维的尺寸,包含给定单位的宽度和高度。
- Size
Refinement - [
#ident] 的可细化版本,详见该文档。 - Source
Metadata - 屏幕捕获源的元数据
- Stateful
- A wrapper around an element that can store state, produced after assigning an ElementId.
- Strikethrough
Style - 可以应用于删除线的属性。
- Strikethrough
Style Refinement - [
#ident] 的可细化版本,详见该文档。 - Stroke
Options - Parameters for the tessellator.
- Style
- 可以通过
Styledtrait 应用于元素的 CSS 样式 - Style
Refinement - [
#ident] 的可细化版本,详见该文档。 - Styled
Text - Renders text with runs of different styles.
- Subpixel
Sprite - 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.
- System
Window TabController - 窗口标签页的控制器。
- Text
Layout - The Layout for TextElement. This can be used to map indices to pixels and vice versa.
- TextRun
- 用于
crate::TextLayout的样式化文本段。 - Text
Style - 可用于在 GPUI 中设置文本样式的属性
- Text
Style Refinement - [
#ident] 的可细化版本,详见该文档。 - Text
System - GPUI 文本渲染子系统。
- TileId
- Tiling
- 描述窗口哪些边缘当前被平铺
- Titlebar
Options - 窗口标题栏可配置的选项
- Toast
- Toast 通知结构体
- Toast
Stack - Toast 通知堆栈实体
- Tooltip
Id - An identifier for a tooltip.
- Transformation
- A transformation to apply to an SVG element.
- Transformation
Matrix - 表示可应用于元素的二维变换的数据类型。
- Tray
- 系统托盘图标
- Tray
Icon Data - 渲染后的图标数据,供平台使用
- UTF16
Selection - 文本缓冲区中表示选区的结构,使用 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
- Underline
Style - 可以应用于下划线的属性。
- Underline
Style Refinement - [
#ident] 的可细化版本,详见该文档。 - Uniform
List - A list element for efficiently laying out and displaying a list of uniform-height elements.
- Uniform
List Frame State - Frame state used by the UniformList.
- Uniform
List Scroll Handle - 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.
- Uniform
List Scroll State - Util
Deferred - 丢弃时运行闭包的守卫,除非被中止
- Weak
Entity - A weak reference to a entity of the given type.
- Weak
Focus Handle - A weak reference to a focus handle.
- Window
- Holds the state for a specific window.
- Window
Button Layout - 描述标题栏每侧出现哪些控制按钮
- Window
Controls - 平台支持的窗口控制按钮
- Window
Handle - A handle to a window with a specific root view type. Note that this does not keep the window alive on its own.
- Window
Id - A unique identifier for a window.
- Window
Options - 创建新窗口时可配置的选项
- Window
Params - 创建新窗口时传递给平台的参数
- Window
Text System - GPUI 文本布局子系统。
- Wrap
Boundary - 行被换行时的换行边界
- Wrapped
Line - 由文本布局系统塑形、装饰和换行的文本行
- Wrapped
Line Layout - 已换行以适应给定宽度的文本行
Enums§
- Absolute
Length - Represents an absolute length in pixels or rems.
- Action
Build Error - Error type for
Keystroke::parse. This is used instead ofanyhow::Errorso that Zed can use markdown to display it. - Align
Content - 设置内容之间和周围的空间分布 对于 Flexbox,它控制交叉轴中的对齐 对于 Grid,它控制块轴中的对齐
- Align
Items - 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.
- Anchored
FitMode - Which algorithm to use when fitting the anchored element to be inside the window.
- Anchored
Position Mode - Which algorithm to use when positioning the anchored element.
- ArcCow
- 基于 Arc 的写时复制智能指针
- Asset
Logger - 一个资源加载器,在加载期间记录
Result的Err变体 - Atlas
Key - Atlas
Texture Kind - Attention
Type - 请求用户注意力的类型
- Available
Space - The space available for an element to be laid out in
- Axis
- 二维笛卡尔空间中的轴。
- Biometric
Kind - 可用的生物识别认证类型
- Biometric
Status - 生物识别认证的可用性状态
- Blend
Mode - 渲染四边形时应用的混合模式。
- Border
Style - 边框的样式。
- Click
Event - 点击事件,当鼠标按钮或键盘按钮按下并释放时生成。
- Clipboard
Entry - 剪贴板条目类型,可以是文本、图片或外部文件路径
- Color
Space - 用于颜色插值的颜色空间。
- Cursor
Hide Mode - 控制 GPUI 何时响应键盘输入自动隐藏鼠标光标。
- Cursor
Style - 鼠标指针样式
- Decorations
- 描述窗口当前的装饰配置
- Definite
Length - A non-auto length that can be defined in pixels, rems, or percent of parent.
- Dialog
Kind - 原生对话框类型
- Dispatch
Phase - 表示事件分发时的两个不同阶段。
- Display
- 设置此节点子项使用的布局
- Element
Id - An identifier for an
Element. - File
Drop Event - 来自平台的文件拖放事件,当文件被拖放并放到窗口上时生成。
- Fill
- 可以应用于形状的填充类型。
- Fill
Rule - The fill rule defines how to determine what is inside and what is outside of the shape.
- Flex
Direction - flexbox 布局主轴的方向。
- Flex
Wrap - 控制 flex 项目是否强制放在一行或可以换行到多行。
- Follow
Mode - Controls whether the list automatically follows new content at the end.
- Font
Style - 允许选择斜体或倾斜字体。
- Grid
Placement - The placement of an item within a grid layout’s column or row.
- Hitbox
Behavior - hitbox 影响鼠标行为的方式。
- Image
Asset Loader - An image loader for the GPUI asset system
- Image
Cache Error - An error that can occur when interacting with the image cache.
- Image
Cache Item - An image cache item
- Image
Format - One of the editor’s supported image formats (e.g. PNG, JPEG) - used when dealing with images in the clipboard
- Image
Source - A source of image content.
- KeyBinding
Context Predicate - 用于解析是否应分发动作的数据结构。 表示一种小型语言,用于描述哪些上下文对应哪些动作。
- Keyboard
Button - 表示点击事件按下的键盘按钮的枚举。
- Length
- A length that can be defined in pixels, rems, percent of parent, or auto.
- Line
Fragment - A fragment of a line that can be wrapped.
- List
Alignment - Whether the list is scrolling from top to bottom or bottom to top.
- List
Horizontal Sizing Behavior - The horizontal sizing behavior to apply during layout.
- List
Measuring Behavior - The measuring behavior to apply during layout.
- List
Sizing Behavior - The sizing behavior to apply during layout.
- Media
KeyEvent - 媒体键事件,来自硬件媒体键或系统媒体控件
- Menu
Item - 菜单中可以的不同类型的菜单项
- Mouse
Button - 表示按下的鼠标按钮的枚举。
- Navigation
Direction - 导航方向,如后退或前进。
- Network
Status - 当前网络连接状态
- Object
Fit - 图像如何适应元素边界的方式。
- OsAction
- 操作系统操作,由操作系统识别 这允许操作系统为这些操作提供专门的行为
- Overflow
- 子元素溢出容器时如何影响布局
- Owned
Menu Item - 菜单中可以的不同类型的菜单项
- Path
Style - PathBuilder 的样式
- Permission
Status - 权限状态枚举
- Permission
Type - 权限类型枚举
- Platform
Input - 对应所有类型平台输入事件的枚举。
- Position
- 此项目的定位策略。
- Power
Save Blocker Kind - 电源阻止器类型,用于阻止系统进入省电模式
- Pressure
Stage - 压力点击事件的阶段。
- Primitive
- Primitive
Batch - Progress
BarState - 任务栏/程序坞进度条状态
- Prompt
Button - 提示框按钮
- Prompt
Level - 提示框的样式级别
- Quit
Mode - 定义应用程序何时应该自动退出。
- Resize
Edge - 窗口可调整大小的边缘位置
- Resource
- 表示资源位置的枚举
- Scroll
Delta - 滚轮事件的滚动增量。
- Scroll
Strategy - Where to place the element scrolled to.
- Surface
Source - A source of a surface’s content.
- SvgSize
- The size in which to render the SVG.
- System
Menu Type - 系统菜单类型
- System
Power Event - 系统电源状态变更事件
- Template
Column MinSize - 网格布局中列或行的最小尺寸
- Text
Align - 如何对齐元素内的文本
- Text
Overflow - 如何截断超出元素宽度的文本
- Text
Rendering Mode - 绘制字形时使用的文本渲染模式
- Thermal
State - 系统热状态,表示 CPU/GPU 的热限制情况
- Toast
Position - Toast 位置枚举
- Touch
Phase - 触摸运动事件的阶段。 基于同名 winit 枚举。
- Tray
Icon Event - 系统托盘图标事件类型
- Tray
Menu Item - 系统托盘菜单项类型
- Truncate
From - Determines whether to truncate text from the start or end.
- Visibility
- 类似于 CSS
visibility属性的可见性值 - White
Space - 如何处理文本中的空白字符
- Window
Appearance - 窗口外观,由操作系统定义
- Window
Background Appearance - 窗口背景的外观,当没有内容或内容透明时使用
- Window
Bounds - 表示窗口的打开状态
- Window
Button - 标题栏中的窗口控制按钮类型
- Window
Control Area - 对应于平台窗口的窗口控制区域类型。
- Window
Decorations - 窗口装饰类型,决定使用服务端还是客户端装饰
- Window
Kind - 要创建的窗口类型
- Window
Position - 语义化窗口位置,用于相对于屏幕定位窗口
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。
- Animation
Ext - An extension trait for adding the animation wrapper to both Elements and Components
- AppContext
- GPUI 中的上下文 trait,允许不同的上下文类型 在某些操作中可以互换使用。
- AsKeystroke
- 这是一个辅助 trait,用于简化某些函数的实现
- Asset
- 用于异步加载资源的 trait。
- Asset
Source - 应用程序使用的资源来源。
- Borrow
AppContext - 一个辅助 trait,用于在可以互换使用的上下文上 自动实现某些方法。
- Element
- 实现此 trait 的类型将参与窗口内容的布局和绘制。 元素形成一棵树,并根据 Taffy 实现的基于 Web 的布局规则进行布局。 你可以通过实现此 trait 来创建自定义元素,详见模块级文档。
- Entity
Input Handler - 实现此 trait 以允许视图在处理编辑器、输入框等时处理文本输入。
- Event
Emitter - 用于绑定 GPUI 实体类型与其可发出的事件类型的 trait。
- Focusable
- Focusable 允许用户通过
window.focus_view(cx, view)来聚焦你的视图。 - Gesture
Event - 来自平台的手势事件。
- 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.
- Image
Cache - 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.
- Image
Cache Provider - An object that can create an ImageCache during the render phase. See the ImageCache trait for more information.
- Input
Event - 来自平台输入源的事件。
- Input
Handler - Zed 处理平台 IME 系统文本输入的接口 当前为 NSTextInputClient API 的 1:1 映射:
- Interactive
Element - A trait for elements that want to use the standard GPUI event handlers that don’t require any state.
- Into
Element - 由任何可以转换为元素的类型实现。
- IsZero
- A trait for checking if a value is zero.
- KeyEvent
- 来自平台的按键事件。
- Managed
View - ManagedView 是由另一个视图管理生命周期的视图 (如 Modal、Popover、Menu 等)。
- Mouse
Event - 来自平台的鼠标事件。
- Parent
Element - 此 trait 用于为任何实现
IntoElement的类型提供 uniform 接口, 使其可以接受任意数量的任意类型的子元素。 - Platform
- 平台抽象层 trait,定义了与操作系统交互所需的所有接口 各平台(Windows、macOS、Linux、Web)需实现此 trait 以提供平台特定功能
- Platform
Atlas - 平台图集 trait,用于管理纹理图集的插入和移除
- Platform
Display - 平台显示器句柄 trait,表示物理显示器或笔记本屏幕
- Platform
Keyboard Layout - 平台特定键盘布局的 trait
- Platform
Keyboard Mapper - 平台特定键盘映射的 trait
- Platform
Text System - 平台文本系统 trait,负责字体加载、字形渲染和文本布局
- Platform
Window - 平台窗口 trait,定义了窗口操作的核心接口 各平台窗口实现需实现此 trait
- Prompt
- 可在窗口中渲染的提示
- Read
Global - A trait for reading a global value from the context.
- Render
- 可以被绘制到屏幕的对象。这是区分“视图“与其他实体的 trait。
视图是实现
Render的Entity,会被绘制到屏幕上。 - Render
Once - You can derive
IntoElementon any type that implements this trait. It is used to construct reusablecomponentsout 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. - Result
Ext - Result 类型的扩展特征,提供日志工具
- Screen
Capture Source - 可捕获的屏幕视频内容源
- Screen
Capture Stream - 从屏幕捕获的视频流
- Stateful
Interactive Element - A trait for elements that want to use the standard GPUI interactivity features that require state.
- Styled
- 可设置样式的元素的 trait。 使用此功能可选择使用实用程序 CSS 类似样式 API。
- Styled
Image - Style an image element.
- TaskExt
Task<Result<T, E>>的扩展 trait,添加了带有&App上下文的detach_and_log_err。- TryFuture
Ext - Future 类型的扩展特征,提供日志工具
- TryFuture
ExtBacktrace - Future 类型的扩展特征,提供回溯日志
- Uniform
List Decoration - A decoration for a
UniformList. This can be used for various things, such as rendering indent guides, or other visual effects. - Update
Global - A trait for updating a global value in the context.
- Visual
Context - 用于 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
Lengthrepresenting 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
Deferredelement, which delays the layout and paint of its child. - div
- Construct a new
Divelement - 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
Fontfor 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_fallbacksbut accepts and returnsSharedStringreferences. - 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
Radianfrom 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
Pixelsvalue 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
Radianfrom a raw value - red
Hsla中的红色- relative
- Constructs a
DefiniteLengthrepresenting a relative fraction of a parent size. - rems
- Constructs a
Remsvalue 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§
- Align
Self - 用于控制如何对齐指定的节点。
覆盖父节点的
AlignItems属性。 对于 Flexbox,它控制交叉轴中的对齐 对于 Grid,它控制块轴中的对齐 - Draw
Order - Image
Loading Task - An image loading task associated with an image cache.
- ImgResource
Loader - A type alias to the resource loader that the
img()element uses. - Inspector
Renderer - 设置在
App上用于渲染检查器 UI 的函数。 - Justify
Content - 设置内容之间和周围的空间分布 对于 Flexbox,它控制主轴中的对齐 对于 Grid,它控制内联轴中的对齐
- Justify
Items - 用于控制如何对齐子节点。 不适用于 Flexbox,如果在 flex 容器上指定将被忽略 对于 Grid,它控制内联轴中的对齐
- Justify
Self - 用于控制如何对齐指定的节点。
覆盖父节点的
JustifyItems属性。 不适用于 Flexbox,如果在 flex 子项上指定将被忽略 对于 Grid,它控制内联轴中的对齐 - Path
Vertex_ Scaled Pixels - Result
Result<T, Error>- Runnable
Variant - 带元数据的可运行任务类型别名
- Timer
Resolution Guard - 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的结构体生成应用上下文实现。- Into
Element IntoElement派生宏 - 用于将实现了RenderOnce特质的类型转换为 UI 组件。- Visual
Context VisualContext派生宏 - 用于为持有&mut Window并实现了AppContext的类型生成可视化上下文实现。