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