densa_widgets/lib.rs
1//! Standard widgets for `densa_ui`: [`Label`], [`Button`], [`TextInput`] (with undo and the
2//! clipboard), [`ScrollView`], [`Splitter`], [`Panel`], [`DockArea`] (panels in tab groups
3//! the user rearranges, the arrangement saved and restored as a [`DockLayout`]),
4//! [`DataGrid`] (rows of a model, scrolled, selected, copied and sorted), [`Chart`] (time
5//! series, candles and volume, panned and zoomed), and [`Menu`] and [`MenuBar`] (commands in
6//! menus that pop up, with submenus, check marks and keyboard navigation).
7//!
8//! Each is a [`Widget`](densa_ui::Widget): add it to a [`Ui`](densa_ui::Ui) with a
9//! [`Style`](densa_ui::Style), and read what the user did from the actions it reports.
10//! They take their colors and text size from the [`Theme`](densa_ui::Theme), and paint and
11//! handle input without allocating (editing text re-lays it out, which does).
12//!
13//! ```
14//! use densa_core::Size;
15//! use densa_paragraph::TextSystem;
16//! use densa_ui::{Align, Style, Ui};
17//! use densa_widgets::{Button, Label, Panel, TextInput};
18//!
19//! let mut ui = Ui::new(TextSystem::new()?);
20//! ui.resize(Size::new(640.0, 480.0));
21//! let bar = ui.add(
22//! ui.root(),
23//! Panel::new(),
24//! Style::row().gap(6.0).padding(8.0).align_items(Align::Center),
25//! )?;
26//! ui.add(bar, Label::new("Symbol"), Style::row())?;
27//! let filter = ui.add(bar, TextInput::new("").with_placeholder("Filter"), Style::row())?;
28//! let run = ui.add(bar, Button::new("Run").primary(), Style::row())?;
29//! ui.layout();
30//! assert!(ui.rect(run).unwrap().left() > ui.rect(filter).unwrap().right());
31//! # Ok::<(), Box<dyn std::error::Error>>(())
32//! ```
33
34mod button;
35mod chart;
36mod dock;
37mod grid;
38mod label;
39mod menu;
40mod paint;
41mod panel;
42mod scroll;
43mod splitter;
44mod text;
45mod text_input;
46
47pub use button::Button;
48pub use chart::Chart;
49pub use dock::{
50 DockArea, DockAt, DockAxis, DockLayout, DockLayoutError, DockLayoutErrorKind, DockPanel,
51 DockSide, MAX_LAYOUT_DEPTH,
52};
53pub use grid::DataGrid;
54pub use label::Label;
55pub use menu::{Menu, MenuBar, MenuItem};
56pub use panel::Panel;
57pub use scroll::ScrollView;
58pub use splitter::Splitter;
59pub use text_input::TextInput;