Skip to main content

damascene_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 damascene_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
40// Every public item in this crate is documented (issue #73); keep it
41// that way — the docs are the discovery surface for LLM authors.
42#![warn(missing_docs)]
43
44pub mod affine;
45pub mod anim;
46pub mod bundle;
47pub mod clipboard;
48pub mod color;
49pub mod cursor;
50pub mod event;
51pub mod focus;
52pub mod hit_test;
53pub mod icons;
54pub mod image;
55pub mod key;
56pub mod layout;
57pub mod math;
58pub mod metrics;
59#[doc(hidden)]
60pub mod paint;
61// Back-compat re-exports of paint submodules at the crate root. These
62// modules (draw_ops / ir / shader / surface) are referenced from ~85
63// sites across this crate and downstream renderers / examples; the
64// paint-pipeline regrouping shouldn't break those imports.
65pub use paint::draw_ops;
66pub use paint::ir;
67pub use paint::shader;
68pub use paint::surface;
69pub mod plot;
70#[cfg(feature = "prebaked-default-fonts")]
71pub mod prebaked;
72pub mod prelude;
73pub mod profile;
74#[doc(hidden)]
75pub mod runtime;
76pub mod scene;
77pub mod scroll;
78pub mod selection;
79pub mod state;
80pub mod text;
81pub mod theme;
82// Back-compat re-exports of theme submodules at the crate root, since
83// `tokens::`, `palette::`, and `style::` are referenced from ~130 call
84// sites across this crate and downstream renderers / examples.
85pub use theme::palette;
86pub use theme::style;
87pub use theme::tokens;
88pub mod toast;
89pub mod tooltip;
90pub mod tree;
91pub mod vector;
92pub mod viewport;
93pub mod widgets;
94
95// Prelude — for `use damascene_core::*;`.
96pub use anim::{AnimProp, AnimValue, Animation, SpringConfig, Timing, TweenConfig};
97pub use bundle::artifact::{
98    Bundle, render_bundle, render_bundle_themed, render_bundle_with, render_bundle_with_theme,
99    write_bundle,
100};
101pub use bundle::inspect::dump_tree;
102pub use bundle::lint::{Finding, FindingKind, LintReport, lint};
103pub use bundle::manifest::{draw_ops_text, shader_manifest};
104pub use bundle::svg::svg_from_ops;
105pub use clipboard::{delete_selection_event, paste_text_event};
106pub use cursor::Cursor;
107pub use draw_ops::{draw_ops, draw_ops_with_theme};
108pub use event::{
109    App, AppShader, BuildCx, ChordTrigger, EventCx, FrameTrigger, HostDiagnostics, KeyChord,
110    KeyModifiers, KeyPress, LogicalKey, NamedKey, PhysicalKey, Pointer, PointerButton, PointerId,
111    PointerKind, SurfaceColorInfo, SurfaceFormatInfo, UiEvent, UiEventKind, UiTarget,
112};
113pub use focus::focus_order;
114pub use hit_test::{hit_test, hit_test_target};
115pub use icons::svg::{IconSource, IntoIconSource, SvgIcon, SvgIconPaintMode};
116pub use icons::{IconStroke, all_icon_names, icon, icon_path, icon_strokes, icon_vector_asset};
117pub use ir::{DrawOp, TextAnchor};
118pub use layout::{LayoutCtx, LayoutFn, VirtualAnchorPolicy, VirtualItems, VirtualMode, layout};
119pub use math::{
120    MathAtom, MathDisplay, MathExpr, MathLayout, MathParseError, layout_math, parse_mathml,
121    parse_mathml_with_display, parse_tex,
122};
123pub use metrics::{ComponentSize, MetricsRole, ThemeMetrics};
124// `plot::Axis` is intentionally not flattened here — the layout `Axis`
125// (Row/Column/Overlay) owns the short name at the crate root. Reach the
126// plot axis as `plot::Axis`.
127pub use plot::{
128    AxisView, Decimation, LegendPosition, LineMark, Mark, PlotControls, PlotRequest, PlotSpec,
129    PlotStyle, PlotView, Sample, Scale, ScatterMark, SeriesBounds, SeriesHandle, Tick,
130};
131pub use scene::{
132    GeometryHandle, GeometryId, LineData, LineSegment, LinesHandle, MeshData, MeshHandle,
133    MeshVertex, PointData, PointsHandle, ScenePoint,
134};
135pub use shader::{ShaderBinding, ShaderHandle, StockShader, UniformBlock, UniformValue};
136pub use state::{AnimationMode, UiState, WidgetState};
137pub use style::StyleProfile;
138pub use surface::{
139    AppTexture, AppTextureBackend, AppTextureId, SurfaceAlpha, SurfaceFormat, SurfaceSource,
140    next_app_texture_id,
141};
142// Atlas/glyph types are backend-implementer surface (consumed by
143// `damascene-wgpu` / `damascene-vulkano` paint paths). App authors don't
144// touch them, so hide from docs.rs while keeping them resolvable
145// at the crate root for backend imports.
146pub use palette::Palette;
147pub use selection::{Selection, SelectionPoint, SelectionRange, selected_text};
148#[doc(hidden)]
149pub use text::atlas::{
150    AtlasPage, AtlasRect, GlyphAtlas, GlyphKey, GlyphSlot, RunStyle, ShapedGlyph, ShapedRun,
151};
152pub use text::metrics::{
153    MeasuredText, TextGeometry, TextHit, TextLayout, TextLine, caret_xy, caret_xy_with_family,
154    hit_text, hit_text_with_family, layout_text, layout_text_with_family,
155    layout_text_with_line_height_and_family, line_height, line_width, line_width_with_family,
156    measure_text, selection_rects, selection_rects_with_family, wrap_lines, wrap_lines_with_family,
157};
158pub use theme::Theme;
159pub use tree::{
160    Align, Axis, Color, Corners, El, FontFamily, FontWeight, IconName, InteractionState, Justify,
161    Kind, Rect, Sides, Size, Source, SurfaceRole, TextAlign, TextOverflow, TextRole, TextWrap,
162    chart3d, column, divider, fit_contain, fit_contain_intrinsic, fit_cover, grid, hard_break,
163    math, math_block, math_inline, plot, row, scroll, spacer, stack, surface, text_runs, vector,
164    viewport, virtual_grid, virtual_list, virtual_list_dyn,
165};
166pub use vector::{IconMaterial, VectorRenderMode};
167pub use viewport::{
168    FitPolicy, PanBounds, PanTrigger, ViewportConfig, ViewportRequest, ViewportView,
169};
170// Vector path / mesh tessellation types are internal-tooling surface.
171// `damascene_core::vector::*` keeps them reachable for tools that need
172// raw mesh access; hide from docs.rs and the crate-root prelude so
173// app authors aren't tempted to depend on them.
174#[doc(hidden)]
175pub use vector::{
176    PathBuilder, VectorAsset, VectorColor, VectorFill, VectorFillRule, VectorGradient,
177    VectorGradientStop, VectorLineCap, VectorLineJoin, VectorLinearGradient, VectorMesh,
178    VectorMeshOptions, VectorMeshRun, VectorMeshVertex, VectorParseError, VectorPath,
179    VectorRadialGradient, VectorSegment, VectorSpreadMethod, VectorStroke,
180    append_vector_asset_mesh, parse_svg_asset, tessellate_vector_asset,
181};
182
183pub use widgets::accordion::{
184    AccordionAction, accordion, accordion_content, accordion_item, accordion_item_key,
185    accordion_separator, accordion_trigger, accordion_trigger_with_icon,
186};
187pub use widgets::alert::{alert, alert_description, alert_title};
188pub use widgets::avatar::{DEFAULT_AVATAR_SIZE, avatar_fallback, avatar_image, avatar_initials};
189pub use widgets::badge::badge;
190pub use widgets::blockquote::blockquote;
191pub use widgets::breadcrumb::{
192    breadcrumb, breadcrumb_item, breadcrumb_link, breadcrumb_list, breadcrumb_page,
193    breadcrumb_separator,
194};
195pub use widgets::button::{button, button_with_icon, icon_button};
196pub use widgets::calendar::{CalendarAction, CalendarDay, calendar_day_key, calendar_month};
197pub use widgets::card::{
198    card, card_content, card_description, card_footer, card_header, card_title, titled_card,
199};
200pub use widgets::checkbox::checkbox;
201pub use widgets::code_block::{code_block, code_block_chrome};
202pub use widgets::command::{
203    command_group, command_icon, command_item, command_label, command_row, command_shortcut,
204};
205pub use widgets::dialog::{
206    dialog, dialog_content, dialog_description, dialog_footer, dialog_header, dialog_title,
207};
208pub use widgets::dropdown_menu::{
209    dropdown_menu, dropdown_menu_content, dropdown_menu_content_with_density, dropdown_menu_group,
210    dropdown_menu_icon, dropdown_menu_item, dropdown_menu_item_label,
211    dropdown_menu_item_with_density, dropdown_menu_item_with_icon,
212    dropdown_menu_item_with_icon_and_shortcut, dropdown_menu_item_with_shortcut,
213    dropdown_menu_label, dropdown_menu_separator, dropdown_menu_shortcut,
214    dropdown_menu_with_density,
215};
216pub use widgets::editor_tabs::{
217    ActiveTabStyle, CloseVisibility, EditorTabsAction, EditorTabsConfig, editor_tab,
218    editor_tab_add_key, editor_tab_close_key, editor_tab_select_key, editor_tabs, editor_tabs_with,
219};
220pub use widgets::form::{
221    field_row, form, form_control, form_description, form_item, form_label, form_message,
222    form_section,
223};
224pub use widgets::input_otp::input_otp;
225pub use widgets::item::{
226    item, item_actions, item_content, item_description, item_footer, item_group, item_header,
227    item_media, item_media_icon, item_separator, item_title,
228};
229pub use widgets::list::{bullet_list, numbered_list, numbered_list_from, task_list};
230pub use widgets::menubar::{
231    MenubarAction, menubar, menubar_content, menubar_group, menubar_icon, menubar_item,
232    menubar_item_label, menubar_item_with_icon, menubar_item_with_icon_and_shortcut,
233    menubar_item_with_shortcut, menubar_label, menubar_menu, menubar_separator, menubar_shortcut,
234    menubar_trigger, menubar_trigger_key,
235};
236pub use widgets::number_scrubber::{ScrubDrag, ScrubberOpts, number_scrubber};
237pub use widgets::numeric_input::{NumericInputOpts, numeric_input};
238pub use widgets::overlay::{modal, modal_panel, overlay, overlays, scrim};
239pub use widgets::page::page;
240pub use widgets::pagination::{
241    pagination, pagination_content, pagination_ellipsis, pagination_item, pagination_link,
242    pagination_next, pagination_previous,
243};
244pub use widgets::popover::{
245    Anchor, MenuDensity, Side, TOUCH_MENU_ITEM_HEIGHT, anchor_rect, apply_menu_density,
246    context_menu, context_menu_with_density, dropdown, menu_item, menu_item_with_density, popover,
247    popover_panel,
248};
249pub use widgets::progress::progress;
250pub use widgets::radio::{RadioAction, radio_group, radio_item, radio_option_key};
251pub use widgets::select::{
252    SelectAction, select_menu, select_menu_with_density, select_option_key, select_trigger,
253};
254pub use widgets::separator::{separator, vertical_separator};
255pub use widgets::sheet::{
256    SheetSide, sheet, sheet_content, sheet_description, sheet_footer, sheet_header, sheet_title,
257};
258pub use widgets::sidebar::{
259    sidebar, sidebar_group, sidebar_group_label, sidebar_header, sidebar_menu, sidebar_menu_button,
260    sidebar_menu_button_with_icon, sidebar_menu_item, sidebar_menu_label,
261};
262pub use widgets::skeleton::{skeleton, skeleton_circle};
263pub use widgets::slider::{SliderAction, slider};
264pub use widgets::switch::switch;
265pub use widgets::table::{
266    table, table_body, table_cell, table_head, table_head_el, table_header, table_row,
267};
268pub use widgets::tabs::{
269    TabsAction, tab_option_key, tab_trigger, tab_trigger_content, tabs_list,
270    tabs_list_from_triggers,
271};
272pub use widgets::text::{h1, h2, h3, mono, paragraph, text};
273pub use widgets::text_area::text_area;
274pub use widgets::text_input::{
275    ClipboardKind, MaskMode, TextInputOpts, TextSelection, text_input, text_input_with,
276};
277pub use widgets::toggle::{
278    ToggleAction, toggle, toggle_group, toggle_group_multi, toggle_item, toggle_option_key,
279};
280pub use widgets::toolbar::{toolbar, toolbar_description, toolbar_group, toolbar_title};