Skip to main content

ravenrs_widgets/
lib.rs

1//! Declarative views and the UI runtime.
2//!
3//! # Writing components
4//!
5//! There are three ways to make your own component, from simplest to most powerful:
6//!
7//! 1. **A function** returning `impl View`, composing existing views. Good for
8//!    stateless pieces of UI.
9//! 2. **A [`Component`]**: a struct holding its state ([`State`](ravenrs_reactive::State)
10//!    fields, bindings, callbacks) with a `body()` that composes views. This is the
11//!    SwiftUI-style building block and covers most needs.
12//! 3. **A [`View`]** implemented directly: full control over layout boxes,
13//!    painting (including arbitrary [`Scene`](ravenrs_core::Scene) drawing through
14//!    [`Paint::Custom`]), hit-testing, focus and click handling via [`BuildCx`].
15//!    The built-in widgets are written this way, with no private API.
16//!
17//! [`Canvas`] is the shortcut for custom drawing inside a normal layout.
18//!
19//! # Features
20//!
21//! * `decode` (default): PNG and JPEG decoding for [`Image::from_bytes`].
22//! * `charts` (default): `Chart`, `BarChart`, `AreaChart` and `Barcode`. They draw
23//!   the same charts and codes as reports, through `ravenrs-graphics`.
24//!
25//! # Runtime
26//!
27//! [`Ui`] owns the root view and turns it into a [`Scene`](ravenrs_core::Scene):
28//! *build* (views to elements, tracked by a reactive observer), *layout* (Taffy),
29//! *paint*. It only rebuilds when state the last build read has changed or the
30//! interaction state (hover, press, focus) changed, and it never touches the GPU.
31//!
32//! # Motion
33//!
34//! A view declares how a node moves with [`BuildCx::motion`] and the runtime
35//! plays it. While only animations run, frames repeat the paint phase alone, so
36//! views are not rebuilt. When nothing moves, no frames are requested.
37
38mod button;
39mod calendar;
40mod canvas;
41mod card;
42#[cfg(feature = "charts")]
43mod chart;
44mod chat;
45mod choice;
46mod clipboard;
47#[cfg(feature = "code")]
48mod code_editor;
49mod color_picker;
50mod commands;
51mod context;
52mod conversation;
53mod data;
54mod date;
55mod diagnostics;
56mod display;
57mod dock;
58mod editors;
59mod event_calendar;
60mod expression_editor;
61mod extras;
62mod files;
63mod fill;
64mod filter_builder;
65mod floating;
66mod form_layout;
67mod full_screen;
68pub mod grid;
69mod icon;
70mod icon_set;
71mod image;
72mod imaging;
73mod inputs;
74mod labels;
75mod links;
76mod lists;
77#[cfg(feature = "live")]
78mod live;
79#[cfg(feature = "live")]
80mod live_list;
81mod lookup;
82#[cfg(feature = "lottie")]
83mod lottie;
84mod model_picker;
85mod modifiers;
86mod motion;
87mod nav;
88mod overlay;
89mod page_motion;
90#[cfg(feature = "code")]
91mod playground;
92mod quad_field;
93mod quick_edit;
94mod recurrence;
95mod release_notes;
96mod remote;
97mod ribbon;
98mod rich_text;
99#[cfg(feature = "charts")]
100mod sankey;
101mod scheduler;
102mod scroll_scene;
103mod shortcuts;
104mod sound;
105mod stack;
106mod status;
107mod tag_box;
108mod text;
109mod text_field;
110mod theme;
111mod tiles;
112mod timeline;
113mod tree;
114pub(crate) mod ui;
115mod util;
116mod view;
117mod wizard;
118
119pub use button::{Button, ButtonGroup, ButtonSize, ButtonStyle, IconButton};
120pub use calendar::{Calendar, DatePicker, DateRange, DateRangePicker};
121pub use canvas::Canvas;
122pub use card::{Card, GlassCard};
123#[cfg(feature = "charts")]
124pub use chart::{
125    AreaChart, BarChart, Barcode, Chart, ChartBarFrom, ChartCard, ChartCurve, ChartGrid, ChartIndicator,
126    ChartKind, ChartLabelAt, ChartLegend, ChartPolarGrid, ChartReference, ChartStack, ChartTooltip,
127    Symbology,
128};
129pub use chat::{Chat, ChatAuthor, ChatMedia, ChatMessage, FloatingCorner, FloatingPanel};
130pub use choice::{
131    AnchorPoint, AspectRatio, ColorPair, ColorSwatch, FavoriteToggle, Label, NinePointAnchor, Pagination,
132    SwatchGrid, ToggleButton, ToggleGroup,
133};
134pub use clipboard::{Clipboard, ClipboardProvider, MemoryClipboard};
135#[cfg(feature = "code")]
136pub use code_editor::{CodeDiagnostic, CodeEditor, CodeLanguage, highlight_rust};
137pub use color_picker::ColorPicker;
138pub use commands::{ConfirmDialog, FloatingToolbar, Hotkey, SplitButton, Toolbar, ToolbarAction};
139pub use context::{
140    ActivityObserver, BuildCx, Drag, DragHandler, DragPhase, DrawFn, KeyHandler, LiveFn, NodeId, Paint,
141    PaintCx, Placement, QuadPaint, RichFn, Semantics, UiActivity, WidgetId,
142};
143pub use conversation::{Attachment, AttachmentStrip, AudioPlayerButton, SelectionBar};
144pub use data::{Column, List, ListItem, Table};
145pub use date::{Date, days_in_month, is_leap_year};
146pub use diagnostics::{Diagnostics, DiagnosticsHost};
147pub use display::{
148    Alert, AlertAction, Avatar, Badge, Divider, Kbd, ProgressBar, Section, Skeleton, Stat, Tone,
149};
150pub use dock::{
151    DockArea, DockChild, DockDrop, DockEdge, DockLayout, DockLayoutError, DockNode, DockPanel, DockSide,
152    DockTabBar,
153};
154pub use editors::{DateTime, DateTimePicker, MaskedField, NumberField, TextArea, Time, TimePicker};
155pub use event_calendar::{CalendarEvent, EventCalendar, RecurrenceEditor};
156pub use expression_editor::ExpressionEditor;
157pub use extras::{
158    AccessibleControl, Carousel, FormField, InputOtp, Menubar, Rule, Spinner, SplitHandle, SplitPane,
159    SplitPanes, Splitter, validate,
160};
161#[cfg(feature = "decode")]
162pub use files::ImageField;
163pub use files::{
164    DropZone, FilePicker, FilePickerProvider, FileRequest, FileUpload, NoFilePicker, PickedFile,
165};
166pub use fill::Fill;
167pub use filter_builder::{FilterBuilder, FilterField, FilterFieldKind};
168pub use floating::{
169    Combobox, Command, CommandPalette, ContextMenu, HoverCard, Sheet, Side, SplashScreen, Toast, ToastExtras,
170    ToastPosition, Toaster, Toasts,
171};
172pub use form_layout::{FormGroup, FormLayout};
173pub use full_screen::{FullScreen, FullScreenProvider};
174pub use grid::{
175    CellAlign, CellEdit, ColumnLayout, DataGrid, FilterLayout, GridCellStyle, GridColumn, GridData,
176    GridExportFormat, GridLayout, GridPage, GridRequest, GridResponder, GridRowAction, GridScenario,
177    GridTable, GridTableColumn, GridTableKind, NumberFormat, RemoteRows, SelectionMode, SortDirection,
178    SortLayout, Summary, Value,
179};
180pub use icon::Icon;
181pub use icon_set::IconName;
182#[cfg(feature = "decode")]
183pub use image::decode_image;
184pub use image::{ContentMode, DecodeError, Image};
185pub use imaging::{
186    BoxHandle, BoxTransform, ColorWheel, CompareMode, CompareSide, CompareView, CompositionGuide,
187    ContentSpace, CropArea, CropOverlay, CurveEditor, Eyedropper, EyedropperArea, EyedropperState, Histogram,
188    HistogramChannel, HistogramScale, HueSaturation, ImageLightbox, LightboxItem, Marquee, Minimap,
189    Protractor, RubberBand, RuleOfThirdsGrid, Ruler, TransformHandles, ZoomControl, ZoomPanPaint,
190    ZoomPanView, ZoomView,
191};
192pub use inputs::{Checkbox, RadioGroup, SegmentedControl, Slider, Stepper, ThemeSwitcher, Toggle};
193pub use labels::{Labels, Localized};
194pub use links::{Link, LinkOpener, Links};
195pub use lists::{
196    DayMark, DocumentTab, DocumentTabs, FileBrowser, FileEntry, FileSort, FileSortColumn, Filmstrip,
197    FilmstripCell, PagedDocumentView, SortableList, VirtualList, YearView,
198};
199#[cfg(feature = "live")]
200#[doc(hidden)]
201pub use live::view as __live_view;
202#[cfg(feature = "live")]
203pub use live::{LiveRunner, live_registry};
204pub use lookup::{LookupField, LookupItem, LookupRequest, LookupResponder};
205#[cfg(feature = "lottie")]
206pub use lottie::Lottie;
207pub use model_picker::{ModelChoice, ModelPicker, ModelPickerLabels, ModelStatus};
208pub use modifiers::{Faded, Styled, ViewExt};
209pub use motion::{Collapse, Motion};
210pub use nav::{
211    Accordion, Breadcrumb, Disclosure, Sidebar, SidebarBrand, SidebarCollapse, SidebarGroup, SidebarInset,
212    SidebarItem, SidebarParts, SidebarSection, SidebarSkeleton, SidebarState, SidebarTrigger, SidebarVariant,
213    Tabs, TabsVariant,
214};
215pub use overlay::{Dialog, DropdownMenu, HelpTip, MenuItem, Popover, Select, Tooltip};
216pub use page_motion::{Anchor, CountUp, Ticker, TimeLink};
217#[cfg(feature = "code")]
218pub use playground::{Playground, RunOutput, Runner};
219pub use quad_field::QuadField;
220pub use quick_edit::{InlineRename, ValueSlider};
221#[cfg(feature = "lottie")]
222pub use ravenrs_lottie::{Animation as LottieAnimation, LottieError};
223pub use recurrence::{Frequency, RecurrenceEnd, RecurrenceRule};
224pub use release_notes::{CodeBlock, ReleaseNote, ReleaseNotes};
225pub use remote::UiWaker;
226pub use ribbon::{Ribbon, RibbonGroup, RibbonItem, RibbonPage, RibbonSize};
227pub use rich_text::RichText;
228#[cfg(feature = "charts")]
229pub use sankey::{SankeyAlign, SankeyChart};
230pub use scheduler::{
231    Resource, Scheduler, SchedulerChange, SchedulerEvent, SchedulerRange, TimeAxis, TimePoint, TimeScale,
232};
233pub use scroll_scene::{ScrollLink, ScrollLinked, ScrollRange, ScrollScene, Sticky};
234pub use shortcuts::{ShortcutHintBar, ShortcutSheet};
235pub use sound::{Silence, Sound, SoundClip, SoundProvider};
236pub use stack::{
237    Footer, Grid, HStack, PageHeader, PropertyRow, ScrollEdgeArrow, ScrollView, Spacer, StatusBar, TitleBar,
238    ToolRail, ToolRailItem, VStack, ZStack,
239};
240pub use status::{
241    DaySeparator, Dot, EmptyState, HeroBanner, IconTile, MultiProgress, OverlayBadge, Rating, ShimmerText,
242};
243pub use tag_box::TagBox;
244pub use text::Text;
245pub use text_field::TextField;
246pub use theme::{ThemeEditor, ThemePicker};
247pub use tiles::{CardView, Tile, TileLayout, TileSpot};
248pub use timeline::{Timeline, TimelineEdit, TimelineItem, TimelineMarker, TimelineTrack};
249pub use tree::{TreeNode, TreeView};
250pub use ui::{Ui, UiStats};
251pub use view::{AnyView, Component, FnView, Keyed, Responsive, View, ViewSeq, responsive, view_fn};
252pub use wizard::{IndicatorStep, StepBadge, StepIndicator, StepState, Wizard, WizardStep};