tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1061HTML 997Markdown 12TOML 83120 Definiciones

Add edge helpers to ContentSlot

5d5b69ee5ccb218591e3d98ab5587dde64f8e42b · por Nico Burns · (hace 9 meses) · padre 2ca609ecf · ver el árbol en este commit

Delta semántico · 4

src/compute/float.rs

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