Skip to main content

Crate densa_widgets

Crate densa_widgets 

Source
Expand description

Standard widgets for densa_ui: Label, Button, TextInput, ScrollView, Splitter, Panel, DockArea (panels in tab groups the user rearranges), DataGrid (rows of a model, scrolled, selected and sorted) and Chart (time series, candles and volume, panned and zoomed).

Each is a Widget: add it to a Ui with a Style, and read what the user did from the actions it reports. They take their colors and text size from the Theme, and paint and handle input without allocating (editing text re-lays it out, which does).

use densa_core::Size;
use densa_paragraph::TextSystem;
use densa_ui::{Align, Style, Ui};
use densa_widgets::{Button, Label, Panel, TextInput};

let mut ui = Ui::new(TextSystem::new()?);
ui.resize(Size::new(640.0, 480.0));
let bar = ui.add(
    ui.root(),
    Panel::new(),
    Style::row().gap(6.0).padding(8.0).align_items(Align::Center),
)?;
ui.add(bar, Label::new("Symbol"), Style::row())?;
let filter = ui.add(bar, TextInput::new("").with_placeholder("Filter"), Style::row())?;
let run = ui.add(bar, Button::new("Run").primary(), Style::row())?;
ui.layout();
assert!(ui.rect(run).unwrap().left() > ui.rect(filter).unwrap().right());

Structs§

Button
A push button: reports ActionKind::Clicked when released over itself, or when Enter or Space is pressed while it has focus.
Chart
A chart of a ChartModel: its panes stacked top to bottom on one horizontal axis, labelled under the lowest, each scaled to what it shows.
DataGrid
A grid of rows from a GridModel: the user scrolls it (wheel, touchpad, scroll bar, keys), selects a row (click, arrow keys, Page Up and Down, Home, End), sorts it by clicking a column’s title (again to reverse), and resizes columns by dragging the edges between titles. Leading columns can stay in place while the rest scroll sideways (with_frozen_columns).
DockArea
Panels in tab groups, side by side or stacked, that the user rearranges: click a tab to show its panel, drag it along its bar to reorder, onto another group to join that group, or near a group’s edge to split the group, and drag the gaps between groups to resize them. Tabs that do not fit their bar shrink, and the shown tab always stays in view.
DockPanel
What a dock shows for a panel: its tab’s title and, for saving and restoring workspaces, a key that stays the same across runs (widget ids do not, and titles need not be unique).
Label
Text, on one line or wrapped to its width, vertically centered in its rectangle.
Panel
A container that paints a background (the theme’s surface color by default) and, optionally, a border. Lay out its children with its style.
ScrollView
Scrolls its children with the wheel, a touchpad or by dragging its scroll bars.
Splitter
Two panes side by side (or one above the other) with a draggable divider between them.
TextInput
A single line of editable text. Reports ActionKind::Changed after every edit and ActionKind::Submitted on Enter.

Enums§

DockAt
Where DockArea::add_panel puts a panel.
DockSide
A side of a dock group.