pub struct StatsView<V: 'static + ViewBridge> {
pub state: Rc<RefCell<V::StateType>>,
pub reverse_sort: bool,
pub event_controllers: Rc<RefCell<HashMap<Event, Controllers>>>,
/* private fields */
}Expand description
StatsView is a view wrapper that wraps tabs, titles, and list of stats.
Terminology:
title: A title here means a column name in the stats table. We call it title to align with
below_derive’s function get_title_line.
tab or topic: A tab or topic is the content of “Tabs” defined in the module level description.
For example, “general”, “cpu”, “pressure”, etc.
The tab_titles_map defines a hashmap between a tab name and a vector of its corresponding
string titles. This will help StatsView to switch stats headline(columns name) when a user switching
tabs. This hashmap will be automatically generated by tab_view_map.
tab_view_map defines a map relationship between a tab name and its concrete V
data structure. The V here represents “view” which, in implementation, is a enum of
“tab” data structure. And each “tab” defines stats data and will derive the BelowDecor
to generate all display functions. Please check the implementation of V for more details.
detailed_view here is our cursive object. I wrapped it with OnEventView in order to
let the concrete “view“s to define their customized handler. You can think the detailed_view
will be something like this
OnEventView –> Panel –> LinearLayout::Vertical –> Child 0: A TabView that represent the topic tab –> child 1: ScrollView –> LinearLayout::Vertical –> child 0: A TabView that represent the title header tab –> child 1: A SelectView that represents the detail stats –> child 2: Command palette
state defines the state of a view. Filters, sorting orders will be defined here.
Fields§
§state: Rc<RefCell<V::StateType>>§reverse_sort: bool§event_controllers: Rc<RefCell<HashMap<Event, Controllers>>>Implementations§
Source§impl<V: 'static + ViewBridge> StatsView<V>
impl<V: 'static + ViewBridge> StatsView<V>
pub fn new( name: &'static str, tabs: Vec<String>, tab_view_map: HashMap<String, V>, select_view: SelectView<<V::StateType as StateCommon>::KeyType>, state: V::StateType, event_controllers: Rc<RefCell<HashMap<Event, Controllers>>>, cmd_controllers: Rc<RefCell<HashMap<&'static str, Controllers>>>, ) -> Self
pub fn update_title(&mut self)
pub fn on_event<F, E>(self, trigger: E, cb: F) -> Self
pub fn get_tab_view(&mut self) -> ViewRef<TabView>
pub fn get_title_view(&mut self) -> ViewRef<TabView>
pub fn get_list_scroll_view( &mut self, ) -> &mut ScrollView<NamedView<SelectView<<V::StateType as StateCommon>::KeyType>>>
pub fn get_detail_view( &mut self, ) -> ViewRef<SelectView<<V::StateType as StateCommon>::KeyType>>
pub fn get_cmd_palette(&mut self) -> ViewRef<CommandPalette>
pub fn get_screen_width(&mut self) -> usize
pub fn set_horizontal_offset(&mut self, x: usize)
pub fn refresh(&mut self, c: &mut Cursive)
pub fn feed_data(self, c: &mut Cursive) -> Self
pub fn refresh_myself(c: &mut Cursive)
pub fn set_alert(&mut self, msg: &str)
Trait Implementations§
Source§impl<V: 'static + ViewBridge> ViewWrapper for StatsView<V>
impl<V: 'static + ViewBridge> ViewWrapper for StatsView<V>
Source§type V = OnEventView<Panel<LinearLayout>>
type V = OnEventView<Panel<LinearLayout>>
Source§fn with_view<F, R>(&self, f: F) -> Option<R>
fn with_view<F, R>(&self, f: F) -> Option<R>
Source§fn with_view_mut<F, R>(&mut self, f: F) -> Option<R>
fn with_view_mut<F, R>(&mut self, f: F) -> Option<R>
Source§fn into_inner(self) -> Result<Self::V, Self>
fn into_inner(self) -> Result<Self::V, Self>
Source§fn wrap_on_event(&mut self, ch: Event) -> EventResult
fn wrap_on_event(&mut self, ch: Event) -> EventResult
on_event method.Source§fn wrap_layout(&mut self, size: XY<usize>)
fn wrap_layout(&mut self, size: XY<usize>)
layout method.Source§fn wrap_take_focus(
&mut self,
source: Direction,
) -> Result<EventResult, CannotFocus>
fn wrap_take_focus( &mut self, source: Direction, ) -> Result<EventResult, CannotFocus>
take_focus method.Source§fn wrap_call_on_any(
&mut self,
selector: &Selector<'_>,
callback: &mut dyn FnMut(&mut (dyn View + 'static)),
)
fn wrap_call_on_any( &mut self, selector: &Selector<'_>, callback: &mut dyn FnMut(&mut (dyn View + 'static)), )
find method.Source§fn wrap_focus_view(
&mut self,
selector: &Selector<'_>,
) -> Result<EventResult, ViewNotFound>
fn wrap_focus_view( &mut self, selector: &Selector<'_>, ) -> Result<EventResult, ViewNotFound>
focus_view method.Source§fn wrap_needs_relayout(&self) -> bool
fn wrap_needs_relayout(&self) -> bool
needs_relayout method.Auto Trait Implementations§
impl<V> !RefUnwindSafe for StatsView<V>
impl<V> !Send for StatsView<V>
impl<V> !Sync for StatsView<V>
impl<V> !UnwindSafe for StatsView<V>
impl<V> Freeze for StatsView<V>
impl<V> Unpin for StatsView<V>where
V: Unpin,
impl<V> UnsafeUnpin for StatsView<V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> Erased for T
Source§impl<T> Finder for Twhere
T: View,
impl<T> Finder for Twhere
T: View,
Source§fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
fn call_on_all<V, F>(&mut self, sel: &Selector<'_>, callback: F)
sel. Read moreSource§fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
fn call_on<V, F, R>(&mut self, sel: &Selector<'_>, callback: F) -> Option<R>
sel. Read moreSource§fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
fn call_on_name<V, F, R>(&mut self, name: &str, callback: F) -> Option<R>
call_on with a view::Selector::Name.Source§impl<T> IntoBoxedView for Twhere
T: View,
impl<T> IntoBoxedView for Twhere
T: View,
Source§fn into_boxed_view(self) -> Box<dyn View>
fn into_boxed_view(self) -> Box<dyn View>
Box<View>.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Resizable for Twhere
T: View,
impl<T> Resizable for Twhere
T: View,
Source§fn resized(
self,
width: SizeConstraint,
height: SizeConstraint,
) -> ResizedView<Self>
fn resized( self, width: SizeConstraint, height: SizeConstraint, ) -> ResizedView<Self>
self in a ResizedView with the given size constraints.Source§fn fixed_size<S>(self, size: S) -> ResizedView<Self>
fn fixed_size<S>(self, size: S) -> ResizedView<Self>
self into a fixed-size ResizedView.Source§fn fixed_width(self, width: usize) -> ResizedView<Self>
fn fixed_width(self, width: usize) -> ResizedView<Self>
self into a fixed-width ResizedView.Source§fn fixed_height(self, height: usize) -> ResizedView<Self>
fn fixed_height(self, height: usize) -> ResizedView<Self>
self into a fixed-width ResizedView.Source§fn full_screen(self) -> ResizedView<Self>
fn full_screen(self) -> ResizedView<Self>
self into a full-screen ResizedView.Source§fn full_width(self) -> ResizedView<Self>
fn full_width(self) -> ResizedView<Self>
self into a full-width ResizedView.Source§fn full_height(self) -> ResizedView<Self>
fn full_height(self) -> ResizedView<Self>
self into a full-height ResizedView.Source§fn max_size<S>(self, size: S) -> ResizedView<Self>
fn max_size<S>(self, size: S) -> ResizedView<Self>
self into a limited-size ResizedView.Source§fn max_width(self, max_width: usize) -> ResizedView<Self>
fn max_width(self, max_width: usize) -> ResizedView<Self>
self into a limited-width ResizedView.Source§fn max_height(self, max_height: usize) -> ResizedView<Self>
fn max_height(self, max_height: usize) -> ResizedView<Self>
self into a limited-height ResizedView.Source§fn min_size<S>(self, size: S) -> ResizedView<Self>
fn min_size<S>(self, size: S) -> ResizedView<Self>
self into a ResizedView at least sized size.Source§fn min_width(self, min_width: usize) -> ResizedView<Self>
fn min_width(self, min_width: usize) -> ResizedView<Self>
self in a ResizedView at least min_width wide.Source§fn min_height(self, min_height: usize) -> ResizedView<Self>
fn min_height(self, min_height: usize) -> ResizedView<Self>
self in a ResizedView at least min_height tall.Source§impl<T> Scrollable for Twhere
T: View,
impl<T> Scrollable for Twhere
T: View,
Source§fn scrollable(self) -> ScrollView<Self>
fn scrollable(self) -> ScrollView<Self>
self in a ScrollView.