cushy/src/widgets.rs
Jonathan Johnson 4bc3f5a884
Refactored VirtualList
These set of changes attempt to resolve a few complexities from the
original implementation: sizing and how to dynamically update the
content in the list.

On the sizing front, manually specifying the width and height of the
rows felt like it was more complex than measuring the first widget and
using that for all other widgets. This allows a user who wants to force
an explicit size to use the Resize widget, while also supporting
SizeToFit flows. Additionally, this paves the way for us to add
horizontal scrolling to this list, but this commit was already complex
enough I held off on that change for now.

One workflow I wanted to see supported was going from 0 rows to 50 rows.
When the item count comes from a trait, it was pretty complicated to
determine how to tell the list to ask for a new row count. By having the
user provide a Value<usize>, they can provide a `Dynamic<usize>` that
can be updated with a new row count whenever the application determines
there is new data. We still need to figure out a way to force a refresh
of the data even if the row count doesn't change.

Ultimately changing this allowed removing the trait and seemingly
simplified the basic usage in addition to adding more flexibility.
2024-11-07 14:27:08 -08:00

74 lines
1.7 KiB
Rust

//! Built-in [`Widget`](crate::widget::Widget) implementations.
mod align;
pub mod button;
mod canvas;
pub mod checkbox;
mod collapse;
pub mod color;
mod component_probe;
pub mod container;
mod custom;
mod data;
pub mod delimiter;
pub mod disclose;
mod expand;
pub mod grid;
pub mod image;
pub mod input;
pub mod label;
pub mod layers;
pub mod list;
pub mod menu;
mod mode_switch;
pub mod progress;
pub mod radio;
mod resize;
pub mod scroll;
pub mod select;
pub mod shortcuts;
pub mod slider;
mod space;
pub mod stack;
mod style;
mod switcher;
mod themed;
mod tilemap;
pub mod validated;
mod virtual_list;
pub mod wrap;
pub use self::align::Align;
pub use self::button::Button;
pub use self::canvas::Canvas;
pub use self::checkbox::Checkbox;
pub use self::collapse::Collapse;
pub use self::component_probe::ComponentProbe;
pub use self::container::Container;
pub use self::custom::Custom;
pub use self::data::Data;
pub use self::delimiter::Delimiter;
pub use self::disclose::Disclose;
pub use self::expand::Expand;
pub use self::grid::Grid;
pub use self::image::Image;
pub use self::input::Input;
pub use self::label::Label;
pub use self::layers::Layers;
pub use self::menu::Menu;
pub use self::mode_switch::ThemedMode;
pub use self::progress::ProgressBar;
pub use self::radio::Radio;
pub use self::resize::Resize;
pub use self::scroll::Scroll;
pub use self::select::Select;
pub use self::slider::Slider;
pub use self::space::Space;
pub use self::stack::Stack;
pub use self::style::Style;
pub use self::switcher::Switcher;
pub use self::themed::Themed;
pub use self::tilemap::TileMap;
pub use self::validated::Validated;
pub use self::virtual_list::VirtualList;
pub use self::wrap::Wrap;