2016-07-29 06:05:08 +00:00
|
|
|
//! Base elements required to build views.
|
2016-07-14 03:52:24 +00:00
|
|
|
//!
|
|
|
|
//! Views are the main building blocks of your UI.
|
|
|
|
//!
|
|
|
|
//! A view can delegate part or all of its responsabilities to child views,
|
|
|
|
//! forming a view tree. The root of this tree is a `StackView` handled
|
|
|
|
//! directly by the `Cursive` element.
|
|
|
|
//!
|
|
|
|
//! # Layout
|
|
|
|
//!
|
|
|
|
//! The layout phase is when the size and location of each view is computed.
|
|
|
|
//!
|
|
|
|
//! Each view is given an area of the screen by the `View::layout()` method.
|
|
|
|
//! With this, the view is free to plan its content, including calling
|
|
|
|
//! `View::layout()` on its own children.
|
|
|
|
//!
|
|
|
|
//! In order to determine how much space should be given each child, parents
|
2017-01-24 06:52:29 +00:00
|
|
|
//! can use `View::required_size()` on them.
|
2016-07-14 03:52:24 +00:00
|
|
|
//!
|
|
|
|
//!
|
|
|
|
//! ### Contracts
|
|
|
|
//!
|
|
|
|
//! When building new Views, you should respect these contracts:
|
|
|
|
//!
|
|
|
|
//! * By default, `View::layout()` should be called before any call to
|
|
|
|
//! `View::draw()` with the same available size. The only exceptions is
|
|
|
|
//! when both following conditions are met:
|
2016-07-15 03:27:15 +00:00
|
|
|
//! * The available size has not changed since the last call to
|
|
|
|
//! `View::layout()`
|
2016-07-14 03:52:24 +00:00
|
|
|
//! * `View::needs_relayout()` returns `false`
|
|
|
|
//!
|
|
|
|
//! In this case, it is safe to omit the call to `View::layout()`.
|
|
|
|
//!
|
2017-01-24 06:52:29 +00:00
|
|
|
//! * The value returned by `required_size` should be an actually viable size,
|
2016-07-14 03:52:24 +00:00
|
|
|
//! no matter what the request is. This means calling `View::layout()` with
|
2017-01-24 06:52:29 +00:00
|
|
|
//! a size returned by `required_size` is **never** an error.
|
2015-05-15 19:16:58 +00:00
|
|
|
|
2016-07-02 03:23:58 +00:00
|
|
|
#[macro_use]
|
|
|
|
mod view_wrapper;
|
2015-06-08 03:58:10 +00:00
|
|
|
|
2016-07-02 02:19:43 +00:00
|
|
|
// Essentials components
|
2018-03-14 22:11:27 +00:00
|
|
|
mod any;
|
|
|
|
mod finder;
|
2018-03-16 23:09:47 +00:00
|
|
|
mod margins;
|
2018-06-11 06:29:10 +00:00
|
|
|
mod position;
|
2016-08-04 04:55:41 +00:00
|
|
|
mod size_cache;
|
|
|
|
mod size_constraint;
|
2018-06-11 06:29:10 +00:00
|
|
|
mod view_path;
|
2019-03-04 18:31:36 +00:00
|
|
|
mod view_trait;
|
2016-07-02 02:19:43 +00:00
|
|
|
|
|
|
|
// Helper bases
|
2016-08-04 04:55:41 +00:00
|
|
|
mod boxable;
|
2018-06-11 06:29:10 +00:00
|
|
|
mod identifiable;
|
2019-03-05 00:51:22 +00:00
|
|
|
pub mod scroll;
|
|
|
|
mod scroll_base;
|
2018-06-27 00:40:15 +00:00
|
|
|
mod scrollable;
|
2015-05-16 00:56:38 +00:00
|
|
|
|
2018-03-14 20:58:57 +00:00
|
|
|
mod into_boxed_view;
|
|
|
|
|
2018-03-14 22:11:27 +00:00
|
|
|
pub use self::any::AnyView;
|
2016-10-02 22:22:29 +00:00
|
|
|
pub use self::boxable::Boxable;
|
2018-03-14 22:11:27 +00:00
|
|
|
pub use self::finder::{Finder, Selector};
|
2016-10-02 22:22:29 +00:00
|
|
|
pub use self::identifiable::Identifiable;
|
2018-03-14 22:11:27 +00:00
|
|
|
pub use self::into_boxed_view::IntoBoxedView;
|
2018-03-16 23:09:47 +00:00
|
|
|
pub use self::margins::Margins;
|
2016-07-10 02:05:51 +00:00
|
|
|
pub use self::position::{Offset, Position};
|
2019-03-05 00:51:22 +00:00
|
|
|
pub use self::scroll_base::{ScrollBase, ScrollStrategy};
|
2018-06-27 00:40:15 +00:00
|
|
|
pub use self::scrollable::Scrollable;
|
2016-08-04 04:55:41 +00:00
|
|
|
pub use self::size_cache::SizeCache;
|
|
|
|
pub use self::size_constraint::SizeConstraint;
|
2015-06-08 03:58:10 +00:00
|
|
|
pub use self::view_path::ViewPath;
|
2019-03-04 18:31:36 +00:00
|
|
|
pub use self::view_trait::View;
|
2015-06-08 03:58:10 +00:00
|
|
|
pub use self::view_wrapper::ViewWrapper;
|