Skip to main content

day_pieces/
lib.rs

1// Copyright © The Daybrite Project
2// SPDX-License-Identifier: MPL-2.0
3
4//! day-pieces: the built-in piece library (DESIGN.md §5.3).
5//!
6//! Every constructor is a plain function returning a piece value; builder methods configure;
7//! `build` runs once. Dynamic attributes become seeded bindings writing sparse typed patches
8//! through the thread-local tree.
9//!
10//! The vocabulary is split across sibling modules (one logical group each) and re-exported here,
11//! so the public API stays flat (`day_pieces::button`, `day_pieces::stack`, …) regardless of
12//! which module a piece is defined in.
13
14// External-piece registration surface (§8.2): the `renderer!` macro + `fill_measure`, plus the
15// re-exports the macro expands to (so a piece needs only a `day-pieces` dependency, not linkme).
16pub mod async_image;
17pub mod colorpicker;
18pub mod combobox;
19pub mod datetime;
20pub mod pager;
21pub mod pullrefresh;
22pub mod searchfield;
23pub mod stepper;
24pub use async_image::{AsyncImage, AsyncImageBuilder, async_image};
25pub mod render;
26
27// The dynamic piece registry (docs/lite.md §4 in https://github.com/daybrite/day-lite): drive
28// pieces by name with loosely-typed values, the surface interpreted languages (day-lite) build
29// UIs through.
30#[cfg(feature = "dyn-registry")]
31pub mod dynreg;
32/// `#[day_pieces::builder(FooBuilder)]`: a piece's builder trait, generated from its inherent
33/// impl (docs/api-style.md "Typed builders and erasure").
34pub use day_core::{Dimension, ElementId, IntoElementKey, id};
35pub use day_macros::builder;
36pub use day_spec::Renderer;
37pub use linkme;
38pub use render::fill_measure;
39
40// The piece vocabulary: one logical group per module, re-exported flat (see each module's docs).
41mod canvas;
42mod commands;
43pub use commands::Command;
44mod containers;
45mod decorators;
46mod dialogs;
47mod file_access;
48pub use file_access::FileAccess;
49#[cfg(feature = "conformance")]
50pub mod conformance;
51mod forms;
52mod image;
53mod inputs;
54mod leaves;
55/// Inline markdown → styled runs (docs/markdown.md). The parser moved to day-spec, beside
56/// the `TextRun`s it produces and the other format codecs; this keeps the old path working.
57pub use day_spec::markdown;
58mod inspector;
59mod menus;
60mod nav;
61mod shapes;
62mod sources;
63mod split;
64mod status;
65mod structure;
66mod tabs;
67mod tokens;
68mod toolbar;
69pub use tabs::*;
70pub use tokens::*;
71
72pub use canvas::*;
73pub use containers::*;
74pub use decorators::*;
75pub use dialogs::*;
76pub use forms::*;
77pub use image::*;
78pub use inputs::*;
79pub use inspector::*;
80pub use leaves::*;
81pub use menus::*;
82pub use nav::*;
83pub use shapes::*;
84pub use sources::*;
85pub use split::*;
86pub use status::{StatusItem, StatusItemHandle, status_item};
87pub use structure::*;
88// The ambient environment and the `Ambient` state trait (docs/state.md) live in day-core, so an
89// app's `*-core` crate (which depends on day-core but not on day-pieces) can `impl Ambient`
90// for its view-model. Re-exported here so `day_pieces::environment` and the prelude are unchanged.
91pub use day_core::{Ambient, app_environment, environment, focused_environment, with_environment};
92// Canvas export (docs/canvas.md "Exporting"): what this toolkit can render a `Drawing` to.
93pub use day_core::{CanvasExports, RenderBitmap, RenderPdf, canvas_exports};
94pub use toolbar::*;
95
96pub use colorpicker::{ColorPicker, ColorPickerBuilder, PickerIdiom, color_picker};
97pub use combobox::{ComboBox, ComboBoxBuilder, combo_box};
98pub use datetime::{
99    DatePicker, DatePickerBuilder, DayDate, DayTime, TimePicker, TimePickerBuilder, date_picker,
100    time_picker,
101};
102pub use day_localization::NumberFormat;
103pub use pager::{Pager, PagerState, pager};
104pub use pullrefresh::{PullRefresh, PullRefreshBuilder, pull_to_refresh};
105pub use searchfield::{SearchField, SearchFieldBuilder, search_field};
106pub use stepper::{
107    NumberField, NumberFieldBuilder, Stepper, StepperBuilder, StepperIdiom, number_field, stepper,
108};
109
110pub mod prelude {
111    pub use crate::colorpicker::{ColorPicker, ColorPickerBuilder, PickerIdiom, color_picker};
112    pub use crate::combobox::{ComboBox, ComboBoxBuilder, combo_box};
113    pub use crate::datetime::{
114        DatePicker, DatePickerBuilder, DayDate, DayTime, TimePicker, TimePickerBuilder,
115        date_picker, time_picker,
116    };
117    pub use crate::pager::{Pager, PagerState, pager};
118    pub use crate::pullrefresh::{PullRefresh, PullRefreshBuilder, pull_to_refresh};
119    pub use crate::searchfield::{SearchField, SearchFieldBuilder, search_field};
120    pub use crate::stepper::{
121        NumberField, NumberFieldBuilder, Stepper, StepperBuilder, StepperIdiom, number_field,
122        stepper,
123    };
124    pub use crate::{AsyncImage, AsyncImageBuilder, async_image};
125    pub use day_localization::NumberFormat;
126
127    pub use crate::{DocumentTabs, TabActions, TabSet, document_tabs};
128    pub use day_core::{ElementId, IntoElementKey, id};
129    // Model-driven rows (docs/model.md): the store-as-RowSource surface.
130    pub use crate::TextStyle;
131    pub use crate::ToolbarEntry;
132    pub use crate::routes;
133    pub use crate::{
134        A11yBuilder, Alert, Ambient, BackRequest, BackResponse, Binding, ButtonBuilder,
135        ColumnBuilder, Command, Confirm, ContentList, Corner, Cover, Decorate, Decorated, Delete,
136        Drag, Draw, FileAccess, FileUrl, Form, FormSection, Grid, GridRow, HAlign, Inspector,
137        IntoFocusBinding, IntoFraction, IntoImageSource, IntoReactive, IntoText, ItemSlot,
138        LabelBuilder, Labeled, Link, List, ListItem, ListItemBuilder, Loaded, MenuContent,
139        MenuEntry, Modifier, Move, NativeRef, Nav, NavContent, NavDrag, NavDrop, NavItem, NavStack,
140        NavStyle, OpenFile, OpenFiles, OpenFolder, Pan, PathBuilder, Pinch, ProgressBuilder,
141        Prompt, Reactive, Reorder, ReorderVerdict, Rotate, Route, RoutePath, RowBuilder, RowFit,
142        SaveFile, Search, SearchReveal, Sections, ShapeKind, ShapePiece, StatusItem, SwipeAction,
143        TextBuilder, VAlign, VectorWeight, When, ZStack, adaptive, alert, app_environment,
144        app_menu, arc, button, canvas, capsule, circle, column, confirm, cover, current_route,
145        divider, dock_menu, each, ellipse, environment, focused_environment, form, frame_clock,
146        grid, grid_row, image, inspector, item, items, keyed, label, labeled, line, link, list,
147        list_item, load, menu_item, menu_role, menu_separator, nav, nav_back, nav_items, nav_link,
148        nav_link_to, nav_stack, navigate, navigate_to, open_file, open_files, open_folder,
149        open_link, picker, picker_optional, polygon, progress, prompt, rectangle,
150        rounded_rectangle, route, route_param, route_params, row, save_file, scroll, section,
151        secure_field, segment, shape, shape_group, shape_group_fn, slider, spacer, spinner, split,
152        status_item, sub_menu, swipe_action, switch, text_area, text_field, toggle, toolbar_button,
153        toolbar_label, toolbar_menu, toolbar_segmented, toolbar_separator, toolbar_toggle, vector,
154        when, with_environment, zstack,
155    };
156    pub use crate::{Space, TextPreset};
157    // Canvas export (docs/canvas.md "Exporting"): record a drawing once, render it to a bitmap
158    // or a PDF through the toolkit's own painter, and ask what this target can do first.
159    pub use crate::{CanvasExports, Drawing, PdfDocument, canvas_exports};
160    pub use day_core::system_color;
161    pub use day_spec::{ExportError, SystemColor};
162    // The hierarchical tree (docs/tree.md): the piece, its sources, and its verdict enum.
163    pub use crate::{
164        Branches, MoveVerdict, NodeSource, TreeBuilder, TreeConn, TreePiece, branches, tree,
165    };
166    // Typed builder traits (docs/api-style.md "Typed builders and erasure"): each piece's own
167    // builders, forwarded through `Decorated` so they still chain after a generic modifier. A
168    // piece implements exactly one, so the names they share (`title`, `style`, `align`, …) never
169    // become ambiguous at a call site. (`LabelBuilder`, `ButtonBuilder`, `ColumnBuilder` and
170    // `RowBuilder` sit in the list above, in alphabetical company.)
171    pub use crate::{
172        AdaptiveBuilder, CoverBuilder, DividerBuilder, FormSectionBuilder, GridBuilder,
173        GridRowBuilder, ImageBuilder, InspectorBuilder, LinkBuilder, ListBuilder, NavBuilder,
174        NavStackBuilder, PickerBuilder, ScrollBuilder, ShapePieceBuilder, SliderBuilder,
175        SplitBuilder, TextAreaBuilder, TextFieldBuilder, ToggleBuilder, VectorBuilder, WhenBuilder,
176        ZStackBuilder,
177    };
178    #[cfg(feature = "model")]
179    pub use crate::{ModelSlot, Rows, StoreRows, StoreTree, StoreTrees};
180    pub use crate::{Picker, TextArea};
181    pub use day_core::{
182        Alignment, AnyPiece, BuildCx, Dimension, Either, Piece, PieceFn, PieceSeq, RNode,
183        ScrollTarget, announce, announce_urgent, invalidate_size, open_url, piece_fn,
184        with_animation,
185    };
186    pub use day_geometry::{Affine, Animatable, Color, Insets, Point, Rect, Size, Transform};
187    pub use day_reactive::{
188        AnyBinding, Effect, Memo, Scope, Setter, Signal, Trigger, batch, bind, untrack, watch,
189    };
190    // `Nav::presentation` takes one (docs/size-classes.md); apps that leave the
191    // presentation automatic never name it.
192    pub use day_spec::props::NavPresentation;
193    pub use day_spec::props::PickerStyle;
194    pub use day_spec::props::RowHeight;
195    pub use day_spec::props::TextAlign;
196    pub use day_spec::props::{PaneEdge, SplitAxis};
197    pub use day_spec::{AnimSpec, AnimSpec as Animation, Curve};
198    pub use day_spec::{AssetName, FontFamily, ImageName};
199    pub use day_spec::{DragPhase, Edges, GestureKind};
200    // Text entry (docs/textfield.md): what a field collects and what its action key says.
201    pub use day_spec::{
202        DrawOp, LinearGradient, Paint, RadialGradient, Shape, TextAnchor, TextVAlign, UnitPoint,
203    };
204    pub use day_spec::{InputPurpose, SubmitLabel};
205    // Canvas fonts and the platform font list (docs/fonts.md).
206    pub use day_spec::{CanvasFont, FontFace, FontFamilyInfo, TextMetrics};
207    pub use day_spec::{Font, FontSpec, FontWeight, Role};
208    // The styled-text document (docs/texteditor.md): what `.markdown()` parses into, what a
209    // label's runs are, and what `day-piece-text-editor` edits, plus the Markdown / HTML / RTF
210    // codecs over it.
211    pub use day_spec::{
212        LabelStyle, Symbol, ToolbarItem, ToolbarItemKind, ToolbarPlacement, ToolbarValue,
213    };
214    pub use day_spec::{
215        ListStyle, ParagraphAlign, ParagraphRun, ParagraphStyle, RunStyle, StyledText, TextRun,
216        Underline,
217    };
218    pub use day_spec::{MenuBarRole, MenuItem, MenuRole, Shortcut};
219    pub use std::time::Duration;
220}