2016-07-29 06:05:08 +00:00
|
|
|
//! Various views to use when creating the layout.
|
2016-07-28 23:36:01 +00:00
|
|
|
|
2017-01-24 02:54:33 +00:00
|
|
|
/// A macro to help with creating toggleable views.
|
2019-10-08 22:33:33 +00:00
|
|
|
///
|
|
|
|
/// # Examples
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// struct MyView {
|
|
|
|
/// enabled: bool,
|
|
|
|
/// }
|
|
|
|
///
|
|
|
|
/// impl MyView {
|
|
|
|
/// cursive::impl_enabled!(self.enabled);
|
|
|
|
/// }
|
|
|
|
///
|
|
|
|
/// let view = MyView { enabled: true };
|
|
|
|
/// assert!(view.is_enabled());
|
|
|
|
/// ```
|
|
|
|
#[macro_export]
|
2016-10-02 21:55:19 +00:00
|
|
|
macro_rules! impl_enabled {
|
|
|
|
(self.$x:ident) => {
|
|
|
|
|
|
|
|
/// Disables this view.
|
|
|
|
///
|
|
|
|
/// A disabled view cannot be selected.
|
|
|
|
pub fn disable(&mut self) {
|
|
|
|
self.$x = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Disables this view.
|
|
|
|
///
|
|
|
|
/// Chainable variant.
|
|
|
|
pub fn disabled(self) -> Self {
|
2019-10-08 22:33:33 +00:00
|
|
|
use $crate::traits::With as _;
|
2016-10-02 21:55:19 +00:00
|
|
|
self.with(Self::disable)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Re-enables this view.
|
|
|
|
pub fn enable(&mut self) {
|
|
|
|
self.$x = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Enable or disable this view.
|
|
|
|
pub fn set_enabled(&mut self, enabled: bool) {
|
|
|
|
self.$x = enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns `true` if this view is enabled.
|
|
|
|
pub fn is_enabled(&self) -> bool {
|
|
|
|
self.$x
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-06 19:51:50 +00:00
|
|
|
mod boxed_view;
|
2016-07-28 23:36:01 +00:00
|
|
|
mod button;
|
2017-01-24 06:01:25 +00:00
|
|
|
mod canvas;
|
2016-07-28 23:36:01 +00:00
|
|
|
mod checkbox;
|
2019-01-24 19:47:22 +00:00
|
|
|
mod circular_focus;
|
2019-02-22 20:38:16 +00:00
|
|
|
mod debug_view;
|
2016-07-28 23:36:01 +00:00
|
|
|
mod dialog;
|
2016-07-30 06:36:40 +00:00
|
|
|
mod dummy;
|
2016-07-28 23:36:01 +00:00
|
|
|
mod edit_view;
|
2018-11-09 22:19:37 +00:00
|
|
|
mod enableable_view;
|
2018-06-14 04:35:37 +00:00
|
|
|
mod hideable_view;
|
2020-01-06 19:51:50 +00:00
|
|
|
mod last_size_view;
|
2017-01-24 02:54:33 +00:00
|
|
|
mod layer;
|
2016-07-28 23:36:01 +00:00
|
|
|
mod linear_layout;
|
|
|
|
mod list_view;
|
|
|
|
mod menu_popup;
|
2018-05-18 00:37:39 +00:00
|
|
|
mod menubar;
|
2020-01-06 20:10:24 +00:00
|
|
|
mod named_view;
|
2018-05-18 00:37:39 +00:00
|
|
|
mod on_event_view;
|
2018-11-19 04:05:31 +00:00
|
|
|
mod padded_view;
|
2016-07-28 23:36:01 +00:00
|
|
|
mod panel;
|
|
|
|
mod progress_bar;
|
2016-10-02 21:55:19 +00:00
|
|
|
mod radio;
|
2020-01-06 19:51:50 +00:00
|
|
|
mod resized_view;
|
2018-04-05 00:48:51 +00:00
|
|
|
mod scroll_view;
|
2016-07-28 23:36:01 +00:00
|
|
|
mod select_view;
|
2016-08-02 07:32:16 +00:00
|
|
|
mod shadow_view;
|
2018-05-18 00:37:39 +00:00
|
|
|
mod slider_view;
|
2016-07-28 23:36:01 +00:00
|
|
|
mod stack_view;
|
2016-08-02 07:32:16 +00:00
|
|
|
mod text_area;
|
2016-07-28 23:36:01 +00:00
|
|
|
mod text_view;
|
|
|
|
mod tracked_view;
|
|
|
|
|
2020-01-06 19:51:50 +00:00
|
|
|
pub use self::boxed_view::BoxedView;
|
2016-07-28 23:36:01 +00:00
|
|
|
pub use self::button::Button;
|
2017-01-24 06:01:25 +00:00
|
|
|
pub use self::canvas::Canvas;
|
2016-07-28 23:36:01 +00:00
|
|
|
pub use self::checkbox::Checkbox;
|
2019-01-24 19:47:22 +00:00
|
|
|
pub use self::circular_focus::CircularFocus;
|
2019-02-22 20:38:16 +00:00
|
|
|
pub use self::debug_view::DebugView;
|
2018-02-18 19:44:04 +00:00
|
|
|
pub use self::dialog::{Dialog, DialogFocus};
|
2016-07-30 06:36:40 +00:00
|
|
|
pub use self::dummy::DummyView;
|
2016-07-28 23:36:01 +00:00
|
|
|
pub use self::edit_view::EditView;
|
2018-11-09 22:19:37 +00:00
|
|
|
pub use self::enableable_view::EnableableView;
|
2018-06-14 04:35:37 +00:00
|
|
|
pub use self::hideable_view::HideableView;
|
2020-01-06 19:51:50 +00:00
|
|
|
pub use self::last_size_view::LastSizeView;
|
2017-01-24 02:54:33 +00:00
|
|
|
pub use self::layer::Layer;
|
2016-07-28 23:36:01 +00:00
|
|
|
pub use self::linear_layout::LinearLayout;
|
2017-05-21 16:50:16 +00:00
|
|
|
pub use self::list_view::{ListChild, ListView};
|
2016-07-28 23:36:01 +00:00
|
|
|
pub use self::menu_popup::MenuPopup;
|
2016-10-02 22:22:29 +00:00
|
|
|
pub use self::menubar::Menubar;
|
2020-01-06 20:10:24 +00:00
|
|
|
pub use self::named_view::{NamedView, ViewRef};
|
2017-10-12 23:38:55 +00:00
|
|
|
pub use self::on_event_view::OnEventView;
|
2018-11-19 04:05:31 +00:00
|
|
|
pub use self::padded_view::PaddedView;
|
2016-07-28 23:36:01 +00:00
|
|
|
pub use self::panel::Panel;
|
2018-04-10 18:45:02 +00:00
|
|
|
pub use self::progress_bar::ProgressBar;
|
2017-10-12 23:38:55 +00:00
|
|
|
pub use self::radio::{RadioButton, RadioGroup};
|
2020-01-06 19:51:50 +00:00
|
|
|
pub use self::resized_view::ResizedView;
|
2018-04-05 00:48:51 +00:00
|
|
|
pub use self::scroll_view::ScrollView;
|
2016-07-28 23:36:01 +00:00
|
|
|
pub use self::select_view::SelectView;
|
|
|
|
pub use self::shadow_view::ShadowView;
|
2016-10-02 22:22:29 +00:00
|
|
|
pub use self::slider_view::SliderView;
|
2017-12-30 22:03:42 +00:00
|
|
|
pub use self::stack_view::{LayerPosition, StackView};
|
2016-08-02 07:32:16 +00:00
|
|
|
pub use self::text_area::TextArea;
|
2017-12-30 22:03:42 +00:00
|
|
|
pub use self::text_view::{TextContent, TextContentRef, TextView};
|
2016-07-28 23:36:01 +00:00
|
|
|
pub use self::tracked_view::TrackedView;
|
2020-01-06 19:51:50 +00:00
|
|
|
|
|
|
|
/// Same as [`LastSizeView`](self::LastSizeView).
|
2020-01-06 23:39:30 +00:00
|
|
|
#[deprecated(note = "`SizedView` is being renamed to `LastSizeView`")]
|
2020-01-06 19:51:50 +00:00
|
|
|
pub type SizedView<T> = LastSizeView<T>;
|
|
|
|
|
|
|
|
/// Same as [`ResizedView`](self::ResizedView).
|
2020-01-06 23:39:30 +00:00
|
|
|
#[deprecated(note = "`BoxView` is being renamed to `ResizedView`")]
|
2020-01-06 19:51:50 +00:00
|
|
|
pub type BoxView<T> = ResizedView<T>;
|
|
|
|
|
|
|
|
/// Same as [`BoxedView`](self::BoxedView).
|
2020-01-06 23:39:30 +00:00
|
|
|
#[deprecated(note = "`ViewBox` is being renamed to `BoxedView`")]
|
2020-01-06 19:51:50 +00:00
|
|
|
pub type ViewBox = BoxedView;
|
2020-01-06 20:10:24 +00:00
|
|
|
|
|
|
|
/// Same as [`NamedView`](self::NamedView).
|
2020-01-06 23:39:30 +00:00
|
|
|
#[deprecated(note = "`IdView` is being renamed to `NamedView`")]
|
2020-01-06 20:10:24 +00:00
|
|
|
pub type IdView<T> = NamedView<T>;
|