Introduce helper methods for alignment for all widgets

This commit is contained in:
Héctor Ramón Jiménez 2024-07-12 15:11:30 +02:00
parent be06060117
commit f9dd5cbb09
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
45 changed files with 380 additions and 282 deletions

View file

@ -6,7 +6,7 @@
/// (e.g. `impl Into<Pixels>`) and, since `Pixels` implements `From` both for
/// `f32` and `u16`, you should be able to provide both integers and float
/// literals as needed.
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Default)]
pub struct Pixels(pub f32);
impl From<f32> for Pixels {
@ -27,6 +27,30 @@ impl From<Pixels> for f32 {
}
}
impl std::ops::Add for Pixels {
type Output = Pixels;
fn add(self, rhs: Self) -> Self {
Pixels(self.0 + rhs.0)
}
}
impl std::ops::Add<f32> for Pixels {
type Output = Pixels;
fn add(self, rhs: f32) -> Self {
Pixels(self.0 + rhs)
}
}
impl std::ops::Mul for Pixels {
type Output = Pixels;
fn mul(self, rhs: Self) -> Self {
Pixels(self.0 * rhs.0)
}
}
impl std::ops::Mul<f32> for Pixels {
type Output = Pixels;