|
|
@ -32,8 +32,9 @@ impl Partition {
|
|
|
|
/// have to do the layout calculation in a widget.
|
|
|
|
/// have to do the layout calculation in a widget.
|
|
|
|
#[derive(Debug)]
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Partitions {
|
|
|
|
pub struct Partitions {
|
|
|
|
pub items: Vec<Partition>,
|
|
|
|
items: Vec<Partition>,
|
|
|
|
pub selected: Option<Partition>,
|
|
|
|
pub selected: Option<Partition>,
|
|
|
|
|
|
|
|
pub range: Option<std::ops::RangeInclusive<usize>>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Partitions {
|
|
|
|
impl Partitions {
|
|
|
@ -41,9 +42,14 @@ impl Partitions {
|
|
|
|
Self {
|
|
|
|
Self {
|
|
|
|
items,
|
|
|
|
items,
|
|
|
|
selected: None,
|
|
|
|
selected: None,
|
|
|
|
|
|
|
|
range: None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn len(&self) -> usize {
|
|
|
|
|
|
|
|
self.items.len()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Update the layout information in the partitions
|
|
|
|
/// Update the layout information in the partitions
|
|
|
|
/// based on the current size
|
|
|
|
/// based on the current size
|
|
|
|
pub fn update_layout(&mut self, rect: EguiRect) {
|
|
|
|
pub fn update_layout(&mut self, rect: EguiRect) {
|
|
|
@ -54,7 +60,19 @@ impl Partitions {
|
|
|
|
rect.width() as f64,
|
|
|
|
rect.width() as f64,
|
|
|
|
rect.height() as f64,
|
|
|
|
rect.height() as f64,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
layout.layout_items(&mut self.items, bounds);
|
|
|
|
layout.layout_items(&mut self.items(), bounds);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// The items in this partition, with range applied
|
|
|
|
|
|
|
|
pub fn items(&mut self) -> &mut [Partition] {
|
|
|
|
|
|
|
|
match &self.range {
|
|
|
|
|
|
|
|
Some(n) => {
|
|
|
|
|
|
|
|
// we reverse the range
|
|
|
|
|
|
|
|
let reversed_range = (self.len() - n.end())..=(self.len() - 1);
|
|
|
|
|
|
|
|
&mut self.items[reversed_range]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
None => self.items.as_mut_slice(),
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|