refactor: remove TypedBuilder for widget (#1159)
* refactor: remove TypedBuilder for widget * group together cpu * clean up proc too
This commit is contained in:
parent
0a98ad1b93
commit
463b0fbef8
|
@ -538,78 +538,72 @@ impl BottomLayout {
|
||||||
vec![
|
vec![
|
||||||
BottomCol::builder()
|
BottomCol::builder()
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.children(vec![BottomColRow::new(vec![BottomWidget::builder()
|
.children(vec![BottomColRow::new(vec![BottomWidget::new(
|
||||||
.canvas_handle_width(true)
|
BottomWidgetType::Disk,
|
||||||
.widget_type(BottomWidgetType::Disk)
|
4,
|
||||||
.widget_id(4)
|
)
|
||||||
.up_neighbour(Some(100))
|
.canvas_handle_width(true)
|
||||||
.left_neighbour(Some(8))
|
.up_neighbour(Some(100))
|
||||||
.right_neighbour(Some(DEFAULT_WIDGET_ID + 2))
|
.left_neighbour(Some(8))
|
||||||
.build()])
|
.right_neighbour(Some(DEFAULT_WIDGET_ID + 2))])
|
||||||
.canvas_handle_height(true)])
|
.canvas_handle_height(true)])
|
||||||
.build(),
|
.build(),
|
||||||
BottomCol::builder()
|
BottomCol::builder()
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.children(vec![
|
.children(vec![
|
||||||
BottomColRow::new(vec![
|
BottomColRow::new(vec![
|
||||||
BottomWidget::builder()
|
BottomWidget::new(BottomWidgetType::ProcSort, DEFAULT_WIDGET_ID + 2)
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.widget_type(BottomWidgetType::ProcSort)
|
|
||||||
.widget_id(DEFAULT_WIDGET_ID + 2)
|
|
||||||
.up_neighbour(Some(100))
|
.up_neighbour(Some(100))
|
||||||
.down_neighbour(Some(DEFAULT_WIDGET_ID + 1))
|
.down_neighbour(Some(DEFAULT_WIDGET_ID + 1))
|
||||||
.left_neighbour(Some(4))
|
.left_neighbour(Some(4))
|
||||||
.right_neighbour(Some(DEFAULT_WIDGET_ID))
|
.right_neighbour(Some(DEFAULT_WIDGET_ID))
|
||||||
.width_ratio(1)
|
.width_ratio(1)
|
||||||
.parent_reflector(Some((WidgetDirection::Right, 2)))
|
.parent_reflector(Some((WidgetDirection::Right, 2))),
|
||||||
.build(),
|
BottomWidget::new(BottomWidgetType::Proc, DEFAULT_WIDGET_ID)
|
||||||
BottomWidget::builder()
|
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.widget_type(BottomWidgetType::Proc)
|
|
||||||
.widget_id(DEFAULT_WIDGET_ID)
|
|
||||||
.up_neighbour(Some(100))
|
.up_neighbour(Some(100))
|
||||||
.down_neighbour(Some(DEFAULT_WIDGET_ID + 1))
|
.down_neighbour(Some(DEFAULT_WIDGET_ID + 1))
|
||||||
.left_neighbour(Some(DEFAULT_WIDGET_ID + 2))
|
.left_neighbour(Some(DEFAULT_WIDGET_ID + 2))
|
||||||
.right_neighbour(Some(7))
|
.right_neighbour(Some(7))
|
||||||
.width_ratio(2)
|
.width_ratio(2),
|
||||||
.build(),
|
|
||||||
])
|
])
|
||||||
.canvas_handle_height(true)
|
.canvas_handle_height(true)
|
||||||
.total_widget_ratio(3),
|
.total_widget_ratio(3),
|
||||||
BottomColRow::new(vec![BottomWidget::builder()
|
BottomColRow::new(vec![BottomWidget::new(
|
||||||
.canvas_handle_width(true)
|
BottomWidgetType::ProcSearch,
|
||||||
.widget_type(BottomWidgetType::ProcSearch)
|
DEFAULT_WIDGET_ID + 1,
|
||||||
.widget_id(DEFAULT_WIDGET_ID + 1)
|
)
|
||||||
.up_neighbour(Some(DEFAULT_WIDGET_ID))
|
.canvas_handle_width(true)
|
||||||
.left_neighbour(Some(4))
|
.up_neighbour(Some(DEFAULT_WIDGET_ID))
|
||||||
.right_neighbour(Some(7))
|
.left_neighbour(Some(4))
|
||||||
.parent_reflector(Some((WidgetDirection::Up, 1)))
|
.right_neighbour(Some(7))
|
||||||
.build()])
|
.parent_reflector(Some((WidgetDirection::Up, 1)))])
|
||||||
.canvas_handle_height(true),
|
.canvas_handle_height(true),
|
||||||
])
|
])
|
||||||
.build(),
|
.build(),
|
||||||
BottomCol::builder()
|
BottomCol::builder()
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.children(vec![BottomColRow::new(vec![BottomWidget::builder()
|
.children(vec![BottomColRow::new(vec![BottomWidget::new(
|
||||||
.canvas_handle_width(true)
|
BottomWidgetType::Temp,
|
||||||
.widget_type(BottomWidgetType::Temp)
|
7,
|
||||||
.widget_id(7)
|
)
|
||||||
.up_neighbour(Some(100))
|
.canvas_handle_width(true)
|
||||||
.left_neighbour(Some(DEFAULT_WIDGET_ID))
|
.up_neighbour(Some(100))
|
||||||
.right_neighbour(Some(8))
|
.left_neighbour(Some(DEFAULT_WIDGET_ID))
|
||||||
.build()])
|
.right_neighbour(Some(8))])
|
||||||
.canvas_handle_height(true)])
|
.canvas_handle_height(true)])
|
||||||
.build(),
|
.build(),
|
||||||
BottomCol::builder()
|
BottomCol::builder()
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.children(vec![BottomColRow::new(vec![BottomWidget::builder()
|
.children(vec![BottomColRow::new(vec![BottomWidget::new(
|
||||||
.canvas_handle_width(true)
|
BottomWidgetType::Battery,
|
||||||
.widget_type(BottomWidgetType::Battery)
|
8,
|
||||||
.widget_id(8)
|
)
|
||||||
.up_neighbour(Some(100))
|
.canvas_handle_width(true)
|
||||||
.left_neighbour(Some(7))
|
.up_neighbour(Some(100))
|
||||||
.right_neighbour(Some(4))
|
.left_neighbour(Some(7))
|
||||||
.build()])
|
.right_neighbour(Some(4))])
|
||||||
.canvas_handle_height(true)])
|
.canvas_handle_height(true)])
|
||||||
.build(),
|
.build(),
|
||||||
]
|
]
|
||||||
|
@ -617,63 +611,57 @@ impl BottomLayout {
|
||||||
vec![
|
vec![
|
||||||
BottomCol::builder()
|
BottomCol::builder()
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.children(vec![BottomColRow::new(vec![BottomWidget::builder()
|
.children(vec![BottomColRow::new(vec![BottomWidget::new(
|
||||||
.canvas_handle_width(true)
|
BottomWidgetType::Disk,
|
||||||
.widget_type(BottomWidgetType::Disk)
|
4,
|
||||||
.widget_id(4)
|
)
|
||||||
.up_neighbour(Some(100))
|
.canvas_handle_width(true)
|
||||||
.left_neighbour(Some(7))
|
.up_neighbour(Some(100))
|
||||||
.right_neighbour(Some(DEFAULT_WIDGET_ID + 2))
|
.left_neighbour(Some(7))
|
||||||
.build()])
|
.right_neighbour(Some(DEFAULT_WIDGET_ID + 2))])
|
||||||
.canvas_handle_height(true)])
|
.canvas_handle_height(true)])
|
||||||
.build(),
|
.build(),
|
||||||
BottomCol::builder()
|
BottomCol::builder()
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.children(vec![
|
.children(vec![
|
||||||
BottomColRow::new(vec![
|
BottomColRow::new(vec![
|
||||||
BottomWidget::builder()
|
BottomWidget::new(BottomWidgetType::ProcSort, DEFAULT_WIDGET_ID + 2)
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.widget_type(BottomWidgetType::ProcSort)
|
|
||||||
.widget_id(DEFAULT_WIDGET_ID + 2)
|
|
||||||
.up_neighbour(Some(100))
|
.up_neighbour(Some(100))
|
||||||
.down_neighbour(Some(DEFAULT_WIDGET_ID + 1))
|
.down_neighbour(Some(DEFAULT_WIDGET_ID + 1))
|
||||||
.left_neighbour(Some(4))
|
.left_neighbour(Some(4))
|
||||||
.right_neighbour(Some(DEFAULT_WIDGET_ID))
|
.right_neighbour(Some(DEFAULT_WIDGET_ID))
|
||||||
.parent_reflector(Some((WidgetDirection::Right, 2)))
|
.parent_reflector(Some((WidgetDirection::Right, 2))),
|
||||||
.build(),
|
BottomWidget::new(BottomWidgetType::Proc, DEFAULT_WIDGET_ID)
|
||||||
BottomWidget::builder()
|
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.widget_type(BottomWidgetType::Proc)
|
|
||||||
.widget_id(DEFAULT_WIDGET_ID)
|
|
||||||
.up_neighbour(Some(100))
|
.up_neighbour(Some(100))
|
||||||
.down_neighbour(Some(DEFAULT_WIDGET_ID + 1))
|
.down_neighbour(Some(DEFAULT_WIDGET_ID + 1))
|
||||||
.left_neighbour(Some(DEFAULT_WIDGET_ID + 2))
|
.left_neighbour(Some(DEFAULT_WIDGET_ID + 2))
|
||||||
.right_neighbour(Some(7))
|
.right_neighbour(Some(7)),
|
||||||
.build(),
|
|
||||||
])
|
])
|
||||||
.canvas_handle_height(true),
|
.canvas_handle_height(true),
|
||||||
BottomColRow::new(vec![BottomWidget::builder()
|
BottomColRow::new(vec![BottomWidget::new(
|
||||||
.canvas_handle_width(true)
|
BottomWidgetType::ProcSearch,
|
||||||
.widget_type(BottomWidgetType::ProcSearch)
|
DEFAULT_WIDGET_ID + 1,
|
||||||
.widget_id(DEFAULT_WIDGET_ID + 1)
|
)
|
||||||
.up_neighbour(Some(DEFAULT_WIDGET_ID))
|
.canvas_handle_width(true)
|
||||||
.left_neighbour(Some(4))
|
.up_neighbour(Some(DEFAULT_WIDGET_ID))
|
||||||
.right_neighbour(Some(7))
|
.left_neighbour(Some(4))
|
||||||
.parent_reflector(Some((WidgetDirection::Up, 1)))
|
.right_neighbour(Some(7))
|
||||||
.build()])
|
.parent_reflector(Some((WidgetDirection::Up, 1)))])
|
||||||
.canvas_handle_height(true),
|
.canvas_handle_height(true),
|
||||||
])
|
])
|
||||||
.build(),
|
.build(),
|
||||||
BottomCol::builder()
|
BottomCol::builder()
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.children(vec![BottomColRow::new(vec![BottomWidget::builder()
|
.children(vec![BottomColRow::new(vec![BottomWidget::new(
|
||||||
.canvas_handle_width(true)
|
BottomWidgetType::Temp,
|
||||||
.widget_type(BottomWidgetType::Temp)
|
7,
|
||||||
.widget_id(7)
|
)
|
||||||
.up_neighbour(Some(100))
|
.canvas_handle_width(true)
|
||||||
.left_neighbour(Some(DEFAULT_WIDGET_ID))
|
.up_neighbour(Some(100))
|
||||||
.right_neighbour(Some(4))
|
.left_neighbour(Some(DEFAULT_WIDGET_ID))
|
||||||
.build()])
|
.right_neighbour(Some(4))])
|
||||||
.canvas_handle_height(true)])
|
.canvas_handle_height(true)])
|
||||||
.build(),
|
.build(),
|
||||||
]
|
]
|
||||||
|
@ -686,12 +674,12 @@ impl BottomLayout {
|
||||||
.canvas_handle_height(true)
|
.canvas_handle_height(true)
|
||||||
.children(vec![BottomCol::builder()
|
.children(vec![BottomCol::builder()
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.children(vec![BottomColRow::new(vec![BottomWidget::builder()
|
.children(vec![BottomColRow::new(vec![BottomWidget::new(
|
||||||
.canvas_handle_width(true)
|
BottomWidgetType::BasicCpu,
|
||||||
.widget_type(BottomWidgetType::BasicCpu)
|
1,
|
||||||
.widget_id(1)
|
)
|
||||||
.down_neighbour(Some(2))
|
.canvas_handle_width(true)
|
||||||
.build()])
|
.down_neighbour(Some(2))])
|
||||||
.canvas_handle_height(true)])
|
.canvas_handle_height(true)])
|
||||||
.build()])
|
.build()])
|
||||||
.build(),
|
.build(),
|
||||||
|
@ -700,22 +688,16 @@ impl BottomLayout {
|
||||||
.children(vec![BottomCol::builder()
|
.children(vec![BottomCol::builder()
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.children(vec![BottomColRow::new(vec![
|
.children(vec![BottomColRow::new(vec![
|
||||||
BottomWidget::builder()
|
BottomWidget::new(BottomWidgetType::BasicMem, 2)
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.widget_type(BottomWidgetType::BasicMem)
|
|
||||||
.widget_id(2)
|
|
||||||
.up_neighbour(Some(1))
|
.up_neighbour(Some(1))
|
||||||
.down_neighbour(Some(100))
|
.down_neighbour(Some(100))
|
||||||
.right_neighbour(Some(3))
|
.right_neighbour(Some(3)),
|
||||||
.build(),
|
BottomWidget::new(BottomWidgetType::BasicNet, 3)
|
||||||
BottomWidget::builder()
|
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.widget_type(BottomWidgetType::BasicNet)
|
|
||||||
.widget_id(3)
|
|
||||||
.up_neighbour(Some(1))
|
.up_neighbour(Some(1))
|
||||||
.down_neighbour(Some(100))
|
.down_neighbour(Some(100))
|
||||||
.left_neighbour(Some(2))
|
.left_neighbour(Some(2)),
|
||||||
.build(),
|
|
||||||
])
|
])
|
||||||
.canvas_handle_height(true)])
|
.canvas_handle_height(true)])
|
||||||
.build()])
|
.build()])
|
||||||
|
@ -724,12 +706,12 @@ impl BottomLayout {
|
||||||
.canvas_handle_height(true)
|
.canvas_handle_height(true)
|
||||||
.children(vec![BottomCol::builder()
|
.children(vec![BottomCol::builder()
|
||||||
.canvas_handle_width(true)
|
.canvas_handle_width(true)
|
||||||
.children(vec![BottomColRow::new(vec![BottomWidget::builder()
|
.children(vec![BottomColRow::new(vec![BottomWidget::new(
|
||||||
.canvas_handle_width(true)
|
BottomWidgetType::BasicTables,
|
||||||
.widget_type(BottomWidgetType::BasicTables)
|
100,
|
||||||
.widget_id(100)
|
)
|
||||||
.up_neighbour(Some(2))
|
.canvas_handle_width(true)
|
||||||
.build()])
|
.up_neighbour(Some(2))])
|
||||||
.canvas_handle_height(true)])
|
.canvas_handle_height(true)])
|
||||||
.build()])
|
.build()])
|
||||||
.build(),
|
.build(),
|
||||||
|
@ -831,57 +813,105 @@ pub enum WidgetDirection {
|
||||||
|
|
||||||
impl WidgetDirection {
|
impl WidgetDirection {
|
||||||
pub fn is_opposite(&self, other_direction: &WidgetDirection) -> bool {
|
pub fn is_opposite(&self, other_direction: &WidgetDirection) -> bool {
|
||||||
match &self {
|
let to_compare = match &self {
|
||||||
WidgetDirection::Left => *other_direction == WidgetDirection::Right,
|
WidgetDirection::Left => WidgetDirection::Right,
|
||||||
WidgetDirection::Right => *other_direction == WidgetDirection::Left,
|
WidgetDirection::Right => WidgetDirection::Left,
|
||||||
WidgetDirection::Up => *other_direction == WidgetDirection::Down,
|
WidgetDirection::Up => WidgetDirection::Down,
|
||||||
WidgetDirection::Down => *other_direction == WidgetDirection::Up,
|
WidgetDirection::Down => WidgetDirection::Up,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
*other_direction == to_compare
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a single widget.
|
/// Represents a single widget.
|
||||||
#[derive(Debug, Default, Clone, TypedBuilder)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct BottomWidget {
|
pub struct BottomWidget {
|
||||||
pub widget_type: BottomWidgetType,
|
pub widget_type: BottomWidgetType,
|
||||||
pub widget_id: u64,
|
pub widget_id: u64,
|
||||||
|
|
||||||
#[builder(default = 1)]
|
|
||||||
pub width_ratio: u32,
|
pub width_ratio: u32,
|
||||||
|
|
||||||
#[builder(default = None)]
|
|
||||||
pub left_neighbour: Option<u64>,
|
pub left_neighbour: Option<u64>,
|
||||||
|
|
||||||
#[builder(default = None)]
|
|
||||||
pub right_neighbour: Option<u64>,
|
pub right_neighbour: Option<u64>,
|
||||||
|
|
||||||
#[builder(default = None)]
|
|
||||||
pub up_neighbour: Option<u64>,
|
pub up_neighbour: Option<u64>,
|
||||||
|
|
||||||
#[builder(default = None)]
|
|
||||||
pub down_neighbour: Option<u64>,
|
pub down_neighbour: Option<u64>,
|
||||||
|
|
||||||
/// If set to true, the canvas will override any ratios.
|
/// If set to true, the canvas will override any ratios.
|
||||||
#[builder(default = false)]
|
|
||||||
pub canvas_handle_width: bool,
|
pub canvas_handle_width: bool,
|
||||||
|
|
||||||
/// Whether we want this widget to take up all available room (and ignore any ratios).
|
/// Whether we want this widget to take up all available room (and ignore any ratios).
|
||||||
#[builder(default = false)]
|
|
||||||
pub flex_grow: bool,
|
pub flex_grow: bool,
|
||||||
|
|
||||||
/// The value is the direction to bounce, as well as the parent offset.
|
/// The value is the direction to bounce, as well as the parent offset.
|
||||||
#[builder(default = None)]
|
|
||||||
pub parent_reflector: Option<(WidgetDirection, u64)>,
|
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)>,
|
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)>,
|
pub bottom_right_corner: Option<(u16, u16)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl BottomWidget {
|
||||||
|
pub(crate) fn new(widget_type: BottomWidgetType, widget_id: u64) -> Self {
|
||||||
|
Self {
|
||||||
|
widget_type,
|
||||||
|
widget_id,
|
||||||
|
width_ratio: 1,
|
||||||
|
left_neighbour: None,
|
||||||
|
right_neighbour: None,
|
||||||
|
up_neighbour: None,
|
||||||
|
down_neighbour: None,
|
||||||
|
canvas_handle_width: false,
|
||||||
|
flex_grow: false,
|
||||||
|
parent_reflector: None,
|
||||||
|
top_left_corner: None,
|
||||||
|
bottom_right_corner: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn width_ratio(mut self, width_ratio: u32) -> Self {
|
||||||
|
self.width_ratio = width_ratio;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn left_neighbour(mut self, left_neighbour: Option<u64>) -> Self {
|
||||||
|
self.left_neighbour = left_neighbour;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn right_neighbour(mut self, right_neighbour: Option<u64>) -> Self {
|
||||||
|
self.right_neighbour = right_neighbour;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn up_neighbour(mut self, up_neighbour: Option<u64>) -> Self {
|
||||||
|
self.up_neighbour = up_neighbour;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn down_neighbour(mut self, down_neighbour: Option<u64>) -> Self {
|
||||||
|
self.down_neighbour = down_neighbour;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn canvas_handle_width(mut self, canvas_handle_width: bool) -> Self {
|
||||||
|
self.canvas_handle_width = canvas_handle_width;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn flex_grow(mut self, flex_grow: bool) -> Self {
|
||||||
|
self.flex_grow = flex_grow;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn parent_reflector(
|
||||||
|
mut self, parent_reflector: Option<(WidgetDirection, u64)>,
|
||||||
|
) -> Self {
|
||||||
|
self.parent_reflector = parent_reflector;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Hash, Default)]
|
#[derive(Debug, Clone, Eq, PartialEq, Hash, Default)]
|
||||||
pub enum BottomWidgetType {
|
pub enum BottomWidgetType {
|
||||||
#[default]
|
#[default]
|
||||||
|
|
|
@ -12,6 +12,51 @@ pub struct Row {
|
||||||
pub child: Option<Vec<RowChildren>>,
|
pub child: Option<Vec<RowChildren>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn new_cpu(left_legend: bool, iter_id: &mut u64) -> BottomColRow {
|
||||||
|
let cpu_id = *iter_id;
|
||||||
|
*iter_id += 1;
|
||||||
|
let legend_id = *iter_id;
|
||||||
|
|
||||||
|
if left_legend {
|
||||||
|
BottomColRow::new(vec![
|
||||||
|
BottomWidget::new(BottomWidgetType::CpuLegend, legend_id)
|
||||||
|
.width_ratio(3)
|
||||||
|
.canvas_handle_width(true)
|
||||||
|
.parent_reflector(Some((WidgetDirection::Right, 1))),
|
||||||
|
BottomWidget::new(BottomWidgetType::Cpu, cpu_id)
|
||||||
|
.width_ratio(17)
|
||||||
|
.flex_grow(true),
|
||||||
|
])
|
||||||
|
} else {
|
||||||
|
BottomColRow::new(vec![
|
||||||
|
BottomWidget::new(BottomWidgetType::Cpu, cpu_id)
|
||||||
|
.width_ratio(17)
|
||||||
|
.flex_grow(true),
|
||||||
|
BottomWidget::new(BottomWidgetType::CpuLegend, legend_id)
|
||||||
|
.width_ratio(3)
|
||||||
|
.canvas_handle_width(true)
|
||||||
|
.parent_reflector(Some((WidgetDirection::Left, 1))),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
.total_widget_ratio(20)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_proc_sort(sort_id: u64) -> BottomWidget {
|
||||||
|
BottomWidget::new(BottomWidgetType::ProcSort, sort_id)
|
||||||
|
.canvas_handle_width(true)
|
||||||
|
.parent_reflector(Some((WidgetDirection::Right, 2)))
|
||||||
|
.width_ratio(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_proc(proc_id: u64) -> BottomWidget {
|
||||||
|
BottomWidget::new(BottomWidgetType::Proc, proc_id).width_ratio(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_proc_search(search_id: u64) -> BottomWidget {
|
||||||
|
BottomWidget::new(BottomWidgetType::ProcSearch, search_id)
|
||||||
|
.parent_reflector(Some((WidgetDirection::Up, 1)))
|
||||||
|
}
|
||||||
|
|
||||||
impl Row {
|
impl Row {
|
||||||
pub fn convert_row_to_bottom_row(
|
pub fn convert_row_to_bottom_row(
|
||||||
&self, iter_id: &mut u64, total_height_ratio: &mut u32, default_widget_id: &mut u64,
|
&self, iter_id: &mut u64, total_height_ratio: &mut u32, default_widget_id: &mut u64,
|
||||||
|
@ -53,48 +98,10 @@ impl Row {
|
||||||
}
|
}
|
||||||
|
|
||||||
children.push(match widget_type {
|
children.push(match widget_type {
|
||||||
BottomWidgetType::Cpu => {
|
BottomWidgetType::Cpu => BottomCol::builder()
|
||||||
let cpu_id = *iter_id;
|
.col_width_ratio(width_ratio)
|
||||||
*iter_id += 1;
|
.children(vec![new_cpu(left_legend, iter_id)])
|
||||||
BottomCol::builder()
|
.build(),
|
||||||
.col_width_ratio(width_ratio)
|
|
||||||
.children(if left_legend {
|
|
||||||
vec![BottomColRow::new(vec![
|
|
||||||
BottomWidget::builder()
|
|
||||||
.width_ratio(3)
|
|
||||||
.widget_type(BottomWidgetType::CpuLegend)
|
|
||||||
.widget_id(*iter_id)
|
|
||||||
.canvas_handle_width(true)
|
|
||||||
.parent_reflector(Some((WidgetDirection::Right, 1)))
|
|
||||||
.build(),
|
|
||||||
BottomWidget::builder()
|
|
||||||
.width_ratio(17)
|
|
||||||
.widget_type(BottomWidgetType::Cpu)
|
|
||||||
.widget_id(cpu_id)
|
|
||||||
.flex_grow(true)
|
|
||||||
.build(),
|
|
||||||
])
|
|
||||||
.total_widget_ratio(20)]
|
|
||||||
} else {
|
|
||||||
vec![BottomColRow::new(vec![
|
|
||||||
BottomWidget::builder()
|
|
||||||
.width_ratio(17)
|
|
||||||
.widget_type(BottomWidgetType::Cpu)
|
|
||||||
.widget_id(cpu_id)
|
|
||||||
.flex_grow(true)
|
|
||||||
.build(),
|
|
||||||
BottomWidget::builder()
|
|
||||||
.width_ratio(3)
|
|
||||||
.widget_type(BottomWidgetType::CpuLegend)
|
|
||||||
.widget_id(*iter_id)
|
|
||||||
.canvas_handle_width(true)
|
|
||||||
.parent_reflector(Some((WidgetDirection::Left, 1)))
|
|
||||||
.build(),
|
|
||||||
])
|
|
||||||
.total_widget_ratio(20)]
|
|
||||||
})
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
BottomWidgetType::Proc => {
|
BottomWidgetType::Proc => {
|
||||||
let proc_id = *iter_id;
|
let proc_id = *iter_id;
|
||||||
let proc_search_id = *iter_id + 1;
|
let proc_search_id = *iter_id + 1;
|
||||||
|
@ -104,36 +111,22 @@ impl Row {
|
||||||
.col_width_ratio(width_ratio)
|
.col_width_ratio(width_ratio)
|
||||||
.children(vec![
|
.children(vec![
|
||||||
BottomColRow::new(vec![
|
BottomColRow::new(vec![
|
||||||
BottomWidget::builder()
|
new_proc_sort(*iter_id),
|
||||||
.widget_type(BottomWidgetType::ProcSort)
|
new_proc(proc_id),
|
||||||
.widget_id(*iter_id)
|
|
||||||
.canvas_handle_width(true)
|
|
||||||
.parent_reflector(Some((WidgetDirection::Right, 2)))
|
|
||||||
.width_ratio(1)
|
|
||||||
.build(),
|
|
||||||
BottomWidget::builder()
|
|
||||||
.widget_type(BottomWidgetType::Proc)
|
|
||||||
.widget_id(proc_id)
|
|
||||||
.width_ratio(2)
|
|
||||||
.build(),
|
|
||||||
])
|
])
|
||||||
.total_widget_ratio(3)
|
.total_widget_ratio(3)
|
||||||
.flex_grow(true),
|
.flex_grow(true),
|
||||||
BottomColRow::new(vec![BottomWidget::builder()
|
BottomColRow::new(vec![new_proc_search(proc_search_id)])
|
||||||
.widget_type(BottomWidgetType::ProcSearch)
|
.canvas_handle_height(true),
|
||||||
.widget_id(proc_search_id)
|
|
||||||
.parent_reflector(Some((WidgetDirection::Up, 1)))
|
|
||||||
.build()])
|
|
||||||
.canvas_handle_height(true),
|
|
||||||
])
|
])
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
_ => BottomCol::builder()
|
_ => BottomCol::builder()
|
||||||
.col_width_ratio(width_ratio)
|
.col_width_ratio(width_ratio)
|
||||||
.children(vec![BottomColRow::new(vec![BottomWidget::builder()
|
.children(vec![BottomColRow::new(vec![BottomWidget::new(
|
||||||
.widget_type(widget_type)
|
widget_type,
|
||||||
.widget_id(*iter_id)
|
*iter_id,
|
||||||
.build()])])
|
)])])
|
||||||
.build(),
|
.build(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -171,55 +164,10 @@ impl Row {
|
||||||
|
|
||||||
match widget_type {
|
match widget_type {
|
||||||
BottomWidgetType::Cpu => {
|
BottomWidgetType::Cpu => {
|
||||||
let cpu_id = *iter_id;
|
col_row_children.push(
|
||||||
*iter_id += 1;
|
new_cpu(left_legend, iter_id)
|
||||||
if left_legend {
|
.col_row_height_ratio(col_row_height_ratio),
|
||||||
col_row_children.push(
|
);
|
||||||
BottomColRow::new(vec![
|
|
||||||
BottomWidget::builder()
|
|
||||||
.width_ratio(3)
|
|
||||||
.widget_type(BottomWidgetType::CpuLegend)
|
|
||||||
.widget_id(*iter_id)
|
|
||||||
.canvas_handle_width(true)
|
|
||||||
.parent_reflector(Some((
|
|
||||||
WidgetDirection::Right,
|
|
||||||
1,
|
|
||||||
)))
|
|
||||||
.build(),
|
|
||||||
BottomWidget::builder()
|
|
||||||
.width_ratio(17)
|
|
||||||
.widget_type(BottomWidgetType::Cpu)
|
|
||||||
.widget_id(cpu_id)
|
|
||||||
.flex_grow(true)
|
|
||||||
.build(),
|
|
||||||
])
|
|
||||||
.col_row_height_ratio(col_row_height_ratio)
|
|
||||||
.total_widget_ratio(20),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
col_row_children.push(
|
|
||||||
BottomColRow::new(vec![
|
|
||||||
BottomWidget::builder()
|
|
||||||
.width_ratio(17)
|
|
||||||
.widget_type(BottomWidgetType::Cpu)
|
|
||||||
.widget_id(cpu_id)
|
|
||||||
.flex_grow(true)
|
|
||||||
.build(),
|
|
||||||
BottomWidget::builder()
|
|
||||||
.width_ratio(3)
|
|
||||||
.widget_type(BottomWidgetType::CpuLegend)
|
|
||||||
.widget_id(*iter_id)
|
|
||||||
.canvas_handle_width(true)
|
|
||||||
.parent_reflector(Some((
|
|
||||||
WidgetDirection::Left,
|
|
||||||
1,
|
|
||||||
)))
|
|
||||||
.build(),
|
|
||||||
])
|
|
||||||
.col_row_height_ratio(col_row_height_ratio)
|
|
||||||
.total_widget_ratio(20),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
BottomWidgetType::Proc => {
|
BottomWidgetType::Proc => {
|
||||||
contains_proc = true;
|
contains_proc = true;
|
||||||
|
@ -228,37 +176,23 @@ impl Row {
|
||||||
*iter_id += 2;
|
*iter_id += 2;
|
||||||
col_row_children.push(
|
col_row_children.push(
|
||||||
BottomColRow::new(vec![
|
BottomColRow::new(vec![
|
||||||
BottomWidget::builder()
|
new_proc_sort(*iter_id),
|
||||||
.widget_type(BottomWidgetType::ProcSort)
|
new_proc(proc_id),
|
||||||
.widget_id(*iter_id)
|
|
||||||
.canvas_handle_width(true)
|
|
||||||
.parent_reflector(Some((WidgetDirection::Right, 2)))
|
|
||||||
.width_ratio(1)
|
|
||||||
.build(),
|
|
||||||
BottomWidget::builder()
|
|
||||||
.widget_type(BottomWidgetType::Proc)
|
|
||||||
.widget_id(proc_id)
|
|
||||||
.width_ratio(2)
|
|
||||||
.build(),
|
|
||||||
])
|
])
|
||||||
.col_row_height_ratio(col_row_height_ratio)
|
.col_row_height_ratio(col_row_height_ratio)
|
||||||
.total_widget_ratio(3),
|
.total_widget_ratio(3),
|
||||||
);
|
);
|
||||||
col_row_children.push(
|
col_row_children.push(
|
||||||
BottomColRow::new(vec![BottomWidget::builder()
|
BottomColRow::new(vec![new_proc_search(proc_search_id)])
|
||||||
.widget_type(BottomWidgetType::ProcSearch)
|
.canvas_handle_height(true)
|
||||||
.widget_id(proc_search_id)
|
.col_row_height_ratio(col_row_height_ratio),
|
||||||
.parent_reflector(Some((WidgetDirection::Up, 1)))
|
|
||||||
.build()])
|
|
||||||
.canvas_handle_height(true)
|
|
||||||
.col_row_height_ratio(col_row_height_ratio),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
_ => col_row_children.push(
|
_ => col_row_children.push(
|
||||||
BottomColRow::new(vec![BottomWidget::builder()
|
BottomColRow::new(vec![BottomWidget::new(
|
||||||
.widget_type(widget_type)
|
widget_type,
|
||||||
.widget_id(*iter_id)
|
*iter_id,
|
||||||
.build()])
|
)])
|
||||||
.col_row_height_ratio(col_row_height_ratio),
|
.col_row_height_ratio(col_row_height_ratio),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue