gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 254C 19JavaScript 81371 Definitions

Add edge helpers to ContentSlot

5d5b69ee5ccb218591e3d98ab5587dde64f8e42b · by Nico Burns · (9 months ago) · parent 2ca609ecf · browse the tree at this commit

Semantic delta · 4

src/compute/float.rs

1 files · +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 {