tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 9TOML 3CSS 1345 Sutichaykuna

Add edge helpers to ContentSlot

5d5b69ee5ccb218591e3d98ab5587dde64f8e42b · ruwaq Nico Burns · (9 killa ñawpaq) · tayta 2ca609ecf · kay commitpi sach'ata qhaway

Semántico sayk'uy · 4

src/compute/float.rs

1 qillqakuna · +23 −0

diff --git a/src/compute/float.rs b/src/compute/float.rs
index 0a27ebe9d..85a2b8cfa 100644
--- a/src/compute/float.rs
+++ b/src/compute/float.rs
@@ -46,6 +46,29 @@ pub struct ContentSlot {
     pub height: f32,
 }
 
+impl ContentSlot {
+    /// The distance of the left edge of the slot from the left side of it's container
+    #[inline(always)]
+    pub fn left_edge(&self) -> f32 {
+        self.x
+    }
+    /// The distance of the right edge of the slot from the left side of it's container
+    #[inline(always)]
+    pub fn right_edge(&self) -> f32 {
+        self.x + self.width
+    }
+    /// The distance of the top edge of the slot from the top side of it's container
+    #[inline(always)]
+    pub fn top_edge(&self) -> f32 {
+        self.y + self.height
+    }
+    /// The distance of the bottom edge of the slot from the top side of it's container
+    #[inline(always)]
+    pub fn bottom_edge(&self) -> f32 {
+        self.y + self.height
+    }
+}
+
 /// A floated box
 #[derive(Debug, Clone, Default)]
 pub struct PlacedFloatedBox {