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