Draft custom layout engine based on druid
This commit is contained in:
parent
2303111e09
commit
0240c3981b
38 changed files with 974 additions and 249 deletions
25
native/src/size.rs
Normal file
25
native/src/size.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
use std::f32;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct Size {
|
||||
/// The width.
|
||||
pub width: f32,
|
||||
/// The height.
|
||||
pub height: f32,
|
||||
}
|
||||
|
||||
impl Size {
|
||||
pub const ZERO: Size = Size::new(0., 0.);
|
||||
pub const INFINITY: Size = Size::new(f32::INFINITY, f32::INFINITY);
|
||||
|
||||
pub const fn new(width: f32, height: f32) -> Self {
|
||||
Size { width, height }
|
||||
}
|
||||
|
||||
pub fn pad(&self, padding: f32) -> Self {
|
||||
Size {
|
||||
width: self.width + padding * 2.0,
|
||||
height: self.height + padding * 2.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue