Scrollbar initial values
This commit is contained in:
parent
4e17ef1e09
commit
df1d1dddc6
3 changed files with 27 additions and 14 deletions
|
|
@ -4,7 +4,7 @@ use crate::i18n::t;
|
|||
use ratatui::widgets::ScrollbarState;
|
||||
use rayon::prelude::*;
|
||||
|
||||
const BORDER_LINES_VIEW: usize = 3;
|
||||
pub const BORDER_LINES_VIEW: usize = 3;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum MonitorStatus {
|
||||
|
|
@ -37,6 +37,7 @@ pub struct DashboardViewState {
|
|||
pub error_message: Option<String>,
|
||||
pub auto_refresh_interval: u32,
|
||||
pub scroll_state: ScrollbarState,
|
||||
content_length: usize,
|
||||
}
|
||||
|
||||
impl DashboardViewState {
|
||||
|
|
@ -49,6 +50,7 @@ impl DashboardViewState {
|
|||
error_message: None,
|
||||
auto_refresh_interval: 300,
|
||||
scroll_state: ScrollbarState::new(0),
|
||||
content_length: 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75,6 +77,7 @@ impl DashboardViewState {
|
|||
error_message: None,
|
||||
auto_refresh_interval: data.auto_refresh_interval.max(30),
|
||||
scroll_state: ScrollbarState::new(content_length.saturating_sub(1)),
|
||||
content_length,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +86,7 @@ impl DashboardViewState {
|
|||
}
|
||||
|
||||
pub fn show_vertical_scrollbar(&self, height: u16) -> bool {
|
||||
height < self.get_all_monitors().len() as u16
|
||||
height < self.content_length as u16
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue