Skip to main content

aetna_core/
lib.rs

1#![doc = include_str!("../README.md")]
2//!
3//! # Rendering smoke test
4//!
5//! Any `App` builds and renders headlessly through the bundle pipeline:
6//!
7//! ```
8//! use aetna_core::prelude::*;
9//!
10//! struct Demo;
11//!
12//! impl App for Demo {
13//!     fn build(&self, _cx: &BuildCx) -> El {
14//!         card([
15//!             card_header([card_title("Hello")]),
16//!             card_content([text("rendered headlessly")]),
17//!         ])
18//!         .width(Size::Fixed(320.0))
19//!     }
20//! }
21//!
22//! let app = Demo;
23//! let theme = app.theme();
24//! let mut ui = app.build(&BuildCx::new(&theme));
25//! let bundle = render_bundle(&mut ui, Rect::new(0.0, 0.0, 720.0, 400.0));
26//! assert!(!bundle.svg.is_empty());
27//! ```
28//!
29//! # Rendering pipeline
30//!
31//! Builders produce an [`El`] tree. Layout writes rects into [`UiState`].
32//! The draw-op pass resolves visual facts into backend-neutral [`DrawOp`]
33//! values. Backend runners turn those draw ops into GPU resources and
34//! route pointer/keyboard input back into [`UiEvent`] values.
35//!
36//! The stock surface shader is `rounded_rect`; text, icons, custom
37//! shaders, and backdrop-sampling materials all flow through the same
38//! tree and event model.
39
40pub mod affine;
41pub mod anim;
42pub mod bundle;
43pub mod cursor;
44pub mod draw_ops;
45pub mod event;
46pub mod focus;
47pub mod hit_test;
48pub mod icon_msdf;
49pub mod icon_msdf_atlas;
50pub mod icons;
51pub mod image;
52pub mod ir;
53pub mod layout;
54pub mod metrics;
55#[doc(hidden)]
56pub mod paint;
57pub mod palette;
58pub mod prelude;
59pub mod profile;
60#[doc(hidden)]
61pub mod runtime;
62pub mod scroll;
63pub mod selection;
64pub mod shader;
65pub mod state;
66pub mod style;
67pub mod surface;
68pub mod svg_icon;
69pub mod text;
70pub mod theme;
71pub mod toast;
72pub mod tokens;
73pub mod tooltip;
74pub mod tree;
75pub mod vector;
76pub mod widgets;
77
78// Prelude — for `use aetna_core::*;`.
79pub use anim::{AnimProp, AnimValue, Animation, SpringConfig, Timing, TweenConfig};
80pub use bundle::artifact::{
81    Bundle, render_bundle, render_bundle_themed, render_bundle_with, render_bundle_with_theme,
82    write_bundle,
83};
84pub use bundle::inspect::dump_tree;
85pub use bundle::lint::{Finding, FindingKind, LintReport, lint};
86pub use bundle::manifest::{draw_ops_text, shader_manifest};
87pub use bundle::svg::svg_from_ops;
88pub use cursor::Cursor;
89pub use draw_ops::{draw_ops, draw_ops_with_theme};
90pub use event::{
91    App, AppShader, BuildCx, FrameTrigger, HostDiagnostics, KeyChord, KeyModifiers, KeyPress,
92    PointerButton, UiEvent, UiEventKind, UiKey, UiTarget,
93};
94pub use focus::focus_order;
95pub use hit_test::{hit_test, hit_test_target};
96pub use icons::{IconStroke, all_icon_names, icon, icon_path, icon_strokes, icon_vector_asset};
97pub use ir::{DrawOp, TextAnchor};
98pub use layout::{LayoutCtx, LayoutFn, VirtualItems, VirtualMode, layout};
99pub use metrics::{ComponentSize, MetricsRole, ThemeMetrics};
100pub use shader::{ShaderBinding, ShaderHandle, StockShader, UniformBlock, UniformValue};
101pub use state::{AnimationMode, UiState, WidgetState};
102pub use style::StyleProfile;
103pub use surface::{
104    AppTexture, AppTextureBackend, AppTextureId, SurfaceAlpha, SurfaceFormat, SurfaceSource,
105    next_app_texture_id,
106};
107pub use svg_icon::{IconSource, IntoIconSource, SvgIcon, SvgIconPaintMode};
108// Atlas/glyph types are backend-implementer surface (consumed by
109// `aetna-wgpu` / `aetna-vulkano` paint paths). App authors don't
110// touch them, so hide from docs.rs while keeping them resolvable
111// at the crate root for backend imports.
112pub use palette::Palette;
113pub use selection::{Selection, SelectionPoint, SelectionRange, selected_text};
114#[doc(hidden)]
115pub use text::atlas::{
116    AtlasPage, AtlasRect, GlyphAtlas, GlyphKey, GlyphSlot, RunStyle, ShapedGlyph, ShapedRun,
117};
118pub use text::metrics::{
119    MeasuredText, TextGeometry, TextHit, TextLayout, TextLine, caret_xy, caret_xy_with_family,
120    hit_text, hit_text_with_family, layout_text, layout_text_with_family,
121    layout_text_with_line_height_and_family, line_height, line_width, line_width_with_family,
122    measure_text, selection_rects, selection_rects_with_family, wrap_lines, wrap_lines_with_family,
123};
124pub use theme::Theme;
125pub use tree::{
126    Align, Axis, Color, Corners, El, FontFamily, FontWeight, IconName, InteractionState, Justify,
127    Kind, Rect, Sides, Size, Source, SurfaceRole, TextAlign, TextOverflow, TextRole, TextWrap,
128    column, divider, hard_break, row, scroll, spacer, stack, surface, text_runs, vector,
129    virtual_list, virtual_list_dyn,
130};
131pub use vector::{IconMaterial, VectorRenderMode};
132// Vector path / mesh tessellation types are internal-tooling surface.
133// `aetna_core::vector::*` keeps them reachable for tools that need
134// raw mesh access; hide from docs.rs and the crate-root prelude so
135// app authors aren't tempted to depend on them.
136#[doc(hidden)]
137pub use vector::{
138    PathBuilder, VectorAsset, VectorColor, VectorFill, VectorFillRule, VectorGradient,
139    VectorGradientStop, VectorLineCap, VectorLineJoin, VectorLinearGradient, VectorMesh,
140    VectorMeshOptions, VectorMeshRun, VectorMeshVertex, VectorParseError, VectorPath,
141    VectorRadialGradient, VectorSegment, VectorSpreadMethod, VectorStroke,
142    append_vector_asset_mesh, parse_svg_asset, tessellate_vector_asset,
143};
144
145pub use widgets::accordion::{
146    AccordionAction, accordion, accordion_content, accordion_item, accordion_item_key,
147    accordion_separator, accordion_trigger, accordion_trigger_with_icon,
148};
149pub use widgets::alert::{alert, alert_description, alert_title};
150pub use widgets::avatar::{DEFAULT_AVATAR_SIZE, avatar_fallback, avatar_image, avatar_initials};
151pub use widgets::badge::badge;
152pub use widgets::blockquote::blockquote;
153pub use widgets::breadcrumb::{
154    breadcrumb, breadcrumb_item, breadcrumb_link, breadcrumb_list, breadcrumb_page,
155    breadcrumb_separator,
156};
157pub use widgets::button::{button, button_with_icon, icon_button};
158pub use widgets::card::{
159    card, card_content, card_description, card_footer, card_header, card_title, titled_card,
160};
161pub use widgets::checkbox::checkbox;
162pub use widgets::code_block::{code_block, code_block_chrome};
163pub use widgets::command::{
164    command_group, command_icon, command_item, command_label, command_row, command_shortcut,
165};
166pub use widgets::dialog::{
167    dialog, dialog_content, dialog_description, dialog_footer, dialog_header, dialog_title,
168};
169pub use widgets::dropdown_menu::{
170    dropdown_menu, dropdown_menu_content, dropdown_menu_group, dropdown_menu_icon,
171    dropdown_menu_item, dropdown_menu_item_label, dropdown_menu_item_with_icon,
172    dropdown_menu_item_with_icon_and_shortcut, dropdown_menu_item_with_shortcut,
173    dropdown_menu_label, dropdown_menu_separator, dropdown_menu_shortcut,
174};
175pub use widgets::editor_tabs::{
176    ActiveTabStyle, CloseVisibility, EditorTabsAction, EditorTabsConfig, editor_tab,
177    editor_tab_add_key, editor_tab_close_key, editor_tab_select_key, editor_tabs, editor_tabs_with,
178};
179pub use widgets::form::{
180    field_row, form, form_control, form_description, form_item, form_label, form_message,
181    form_section,
182};
183pub use widgets::input_otp::input_otp;
184pub use widgets::item::{
185    item, item_actions, item_content, item_description, item_footer, item_group, item_header,
186    item_media, item_media_icon, item_separator, item_title,
187};
188pub use widgets::list::{bullet_list, numbered_list, numbered_list_from, task_list};
189pub use widgets::numeric_input::{NumericInputOpts, numeric_input};
190pub use widgets::overlay::{modal, modal_panel, overlay, overlays, scrim};
191pub use widgets::pagination::{
192    pagination, pagination_content, pagination_ellipsis, pagination_item, pagination_link,
193    pagination_next, pagination_previous,
194};
195pub use widgets::popover::{
196    Anchor, Side, anchor_rect, context_menu, dropdown, menu_item, popover, popover_panel,
197};
198pub use widgets::progress::progress;
199pub use widgets::radio::{RadioAction, radio_group, radio_item, radio_option_key};
200pub use widgets::select::{SelectAction, select_menu, select_option_key, select_trigger};
201pub use widgets::separator::{separator, vertical_separator};
202pub use widgets::sheet::{
203    SheetSide, sheet, sheet_content, sheet_description, sheet_footer, sheet_header, sheet_title,
204};
205pub use widgets::sidebar::{
206    sidebar, sidebar_group, sidebar_group_label, sidebar_header, sidebar_menu, sidebar_menu_button,
207    sidebar_menu_button_with_icon, sidebar_menu_item, sidebar_menu_label,
208};
209pub use widgets::skeleton::{skeleton, skeleton_circle};
210pub use widgets::slider::{SliderAction, slider};
211pub use widgets::switch::switch;
212pub use widgets::table::{
213    table, table_body, table_cell, table_head, table_head_el, table_header, table_row,
214};
215pub use widgets::tabs::{
216    TabsAction, tab_option_key, tab_trigger, tab_trigger_content, tabs_list,
217    tabs_list_from_triggers,
218};
219pub use widgets::text::{h1, h2, h3, mono, paragraph, text};
220pub use widgets::text_area::text_area;
221pub use widgets::text_input::{
222    ClipboardKind, MaskMode, TextInputOpts, TextSelection, text_input, text_input_with,
223};
224pub use widgets::toggle::{
225    ToggleAction, toggle, toggle_group, toggle_group_multi, toggle_item, toggle_option_key,
226};
227pub use widgets::toolbar::{toolbar, toolbar_description, toolbar_group, toolbar_title};