Pipeline and structure
This commit is contained in:
+1
-45
@@ -1,17 +1,4 @@
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Size {
|
||||
Fixed(u16),
|
||||
Flex(u16),
|
||||
Percent(u16),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Rect {
|
||||
pub x: u16,
|
||||
pub y: u16,
|
||||
pub width: u16,
|
||||
pub height: u16,
|
||||
}
|
||||
use crate::unit::{Rect, Size};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum LayoutItem {
|
||||
@@ -91,37 +78,6 @@ impl LayoutItem {
|
||||
}
|
||||
}
|
||||
|
||||
impl Size {
|
||||
pub fn get_fixed(&self, alloc: u16) -> u16 {
|
||||
match self {
|
||||
Self::Fixed(v) => *v,
|
||||
Self::Percent(v) => alloc * (*v) / 100,
|
||||
Self::Flex(_) => 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_flex(&self) -> u16 {
|
||||
match self {
|
||||
Self::Flex(f) => *f,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get(&self, alloc: u16, remaining: u16, total_weight: u16) -> u16 {
|
||||
match self {
|
||||
Self::Fixed(v) => *v,
|
||||
Self::Percent(v) => alloc * (*v) / 100,
|
||||
Self::Flex(v) => {
|
||||
if total_weight == 0 {
|
||||
0
|
||||
} else {
|
||||
remaining * v / total_weight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Rect {
|
||||
pub fn allocate(&self, layout: &LayoutItem) -> Allocation {
|
||||
let mut widget_alloc = Vec::new();
|
||||
|
||||
Reference in New Issue
Block a user