mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-25 05:30:22 +00:00
refactor: move some state code around (#839)
This commit is contained in:
parent
c0a5fd15b2
commit
b879c36588
7 changed files with 54 additions and 37 deletions
|
@ -872,11 +872,11 @@ pub struct BottomWidget {
|
|||
#[builder(default = None)]
|
||||
pub parent_reflector: Option<(WidgetDirection, u64)>,
|
||||
|
||||
/// Top left corner when drawn, for mouse click detection. (x, y)
|
||||
/// Top left corner when drawn, for mouse click detection. (x, y)
|
||||
#[builder(default = None)]
|
||||
pub top_left_corner: Option<(u16, u16)>,
|
||||
|
||||
/// Bottom right corner when drawn, for mouse click detection. (x, y)
|
||||
/// Bottom right corner when drawn, for mouse click detection. (x, y)
|
||||
#[builder(default = None)]
|
||||
pub bottom_right_corner: Option<(u16, u16)>,
|
||||
}
|
||||
|
|
|
@ -7,7 +7,10 @@ use crate::{
|
|||
constants,
|
||||
};
|
||||
|
||||
use super::widgets::{CpuWidgetState, DiskTableWidget, ProcWidget, TempWidgetState};
|
||||
use super::widgets::{
|
||||
BatteryWidgetState, CpuWidgetState, DiskTableWidget, MemWidgetState, NetWidgetState,
|
||||
ProcWidget, TempWidgetState,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ScrollDirection {
|
||||
|
@ -140,20 +143,6 @@ impl ProcState {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct NetWidgetState {
|
||||
pub current_display_time: u64,
|
||||
pub autohide_timer: Option<Instant>,
|
||||
}
|
||||
|
||||
impl NetWidgetState {
|
||||
pub fn init(current_display_time: u64, autohide_timer: Option<Instant>) -> Self {
|
||||
NetWidgetState {
|
||||
current_display_time,
|
||||
autohide_timer,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct NetState {
|
||||
pub force_update: Option<u64>,
|
||||
pub widget_states: HashMap<u64, NetWidgetState>,
|
||||
|
@ -198,19 +187,6 @@ impl CpuState {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct MemWidgetState {
|
||||
pub current_display_time: u64,
|
||||
pub autohide_timer: Option<Instant>,
|
||||
}
|
||||
|
||||
impl MemWidgetState {
|
||||
pub fn init(current_display_time: u64, autohide_timer: Option<Instant>) -> Self {
|
||||
MemWidgetState {
|
||||
current_display_time,
|
||||
autohide_timer,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct MemState {
|
||||
pub force_update: Option<u64>,
|
||||
pub widget_states: HashMap<u64, MemWidgetState>,
|
||||
|
@ -281,12 +257,6 @@ pub struct BasicTableWidgetState {
|
|||
pub right_brc: Option<(u16, u16)>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct BatteryWidgetState {
|
||||
pub currently_selected_battery_index: usize,
|
||||
pub tab_click_locs: Option<Vec<((u16, u16), (u16, u16))>>,
|
||||
}
|
||||
|
||||
pub struct BatteryState {
|
||||
pub widget_states: HashMap<u64, BatteryWidgetState>,
|
||||
}
|
||||
|
|
|
@ -11,3 +11,12 @@ pub use disk_table::*;
|
|||
|
||||
pub mod cpu_graph;
|
||||
pub use cpu_graph::*;
|
||||
|
||||
pub mod net_graph;
|
||||
pub use net_graph::*;
|
||||
|
||||
pub mod mem_graph;
|
||||
pub use mem_graph::*;
|
||||
|
||||
pub mod battery_widget;
|
||||
pub use battery_widget::*;
|
||||
|
|
5
src/app/widgets/battery_widget.rs
Normal file
5
src/app/widgets/battery_widget.rs
Normal file
|
@ -0,0 +1,5 @@
|
|||
#[derive(Default)]
|
||||
pub struct BatteryWidgetState {
|
||||
pub currently_selected_battery_index: usize,
|
||||
pub tab_click_locs: Option<Vec<((u16, u16), (u16, u16))>>,
|
||||
}
|
15
src/app/widgets/mem_graph.rs
Normal file
15
src/app/widgets/mem_graph.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
use std::time::Instant;
|
||||
|
||||
pub struct MemWidgetState {
|
||||
pub current_display_time: u64,
|
||||
pub autohide_timer: Option<Instant>,
|
||||
}
|
||||
|
||||
impl MemWidgetState {
|
||||
pub fn init(current_display_time: u64, autohide_timer: Option<Instant>) -> Self {
|
||||
MemWidgetState {
|
||||
current_display_time,
|
||||
autohide_timer,
|
||||
}
|
||||
}
|
||||
}
|
15
src/app/widgets/net_graph.rs
Normal file
15
src/app/widgets/net_graph.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
use std::time::Instant;
|
||||
|
||||
pub struct NetWidgetState {
|
||||
pub current_display_time: u64,
|
||||
pub autohide_timer: Option<Instant>,
|
||||
}
|
||||
|
||||
impl NetWidgetState {
|
||||
pub fn init(current_display_time: u64, autohide_timer: Option<Instant>) -> Self {
|
||||
NetWidgetState {
|
||||
current_display_time,
|
||||
autohide_timer,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,7 +11,10 @@ use std::{
|
|||
use crate::{
|
||||
app::{
|
||||
layout_manager::*,
|
||||
widgets::{CpuWidgetState, DiskTableWidget, ProcWidget, ProcWidgetMode, TempWidgetState},
|
||||
widgets::{
|
||||
BatteryWidgetState, CpuWidgetState, DiskTableWidget, MemWidgetState, NetWidgetState,
|
||||
ProcWidget, ProcWidgetMode, TempWidgetState,
|
||||
},
|
||||
*,
|
||||
},
|
||||
canvas::{canvas_colours::CanvasColours, ColourScheme},
|
||||
|
|
Loading…
Reference in a new issue