cursive/src/views/mod.rs

120 lines
2.9 KiB
Rust
Raw Normal View History

2016-07-29 06:05:08 +00:00
//! Various views to use when creating the layout.
2016-07-28 23:36:01 +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
}
}
}
2016-07-28 23:36:01 +00:00
mod box_view;
mod button;
2017-01-24 06:01:25 +00:00
mod canvas;
2016-07-28 23:36:01 +00:00
mod checkbox;
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;
2016-07-28 23:36:01 +00:00
mod id_view;
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;
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;
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;
2016-07-28 23:36:01 +00:00
mod sized_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;
2018-05-18 00:37:39 +00:00
mod view_box;
2016-07-28 23:36:01 +00:00
pub use self::box_view::BoxView;
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;
pub use self::circular_focus::CircularFocus;
2019-02-22 20:38:16 +00:00
pub use self::debug_view::DebugView;
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;
pub use self::id_view::{IdView, ViewRef};
pub use self::layer::Layer;
2016-07-28 23:36:01 +00:00
pub use self::linear_layout::LinearLayout;
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;
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};
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;
pub use self::sized_view::SizedView;
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;
2018-03-14 22:11:27 +00:00
pub use self::view_box::ViewBox;