diff --git a/src/event.rs b/src/event.rs index 467372f..35bd49a 100644 --- a/src/event.rs +++ b/src/event.rs @@ -19,10 +19,13 @@ pub enum EventResult { } impl EventResult { + /// Convenient method to create EventResult::Consumed + /// from the given callback and empty ViewPath. pub fn callback(cb: Rc) -> Self { EventResult::Consumed(Some(cb), ViewPath::new()) } + /// Convenient method to create EventResult::Consumed with no callback. pub fn consume() -> Self { EventResult::Consumed(None, ViewPath::new()) } diff --git a/src/vec.rs b/src/vec.rs index cf3c906..de16d1c 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -31,15 +31,17 @@ impl Vec2 { Vec2::new(min(a.x, b.x), min(a.y, b.y)) } + /// Returns a vector with the X component of self, and y=0. pub fn keep_x(&self) -> Self { Vec2::new(self.x, 0) } + /// Returns a vector with the Y component of self, and x=0. pub fn keep_y(&self) -> Self { Vec2::new(0, self.y) } - /// Alias for Vec::new(0,0) + /// Alias for Vec::new(0,0). pub fn zero() -> Self { Vec2::new(0,0) } @@ -47,6 +49,7 @@ impl Vec2 { /// A generic trait for converting a value into a 2D vector. pub trait ToVec2 { + /// Converts self into a Vec2. fn to_vec2(self) -> Vec2; } diff --git a/src/view/mod.rs b/src/view/mod.rs index 354f556..af3f6f4 100644 --- a/src/view/mod.rs +++ b/src/view/mod.rs @@ -38,6 +38,7 @@ pub enum DimensionRequest { } impl DimensionRequest { + /// Returns a new request, reduced from the original by the given offset. pub fn reduced(self, offset: u32) -> Self { match self { DimensionRequest::Fixed(w) => DimensionRequest::Fixed(w - offset), @@ -57,6 +58,7 @@ pub struct SizeRequest { } impl SizeRequest { + /// Returns a new SizeRequest, reduced from the original by the given offset. pub fn reduced(self, offset: T) -> Self { let ov = offset.to_vec2(); SizeRequest { @@ -65,6 +67,7 @@ impl SizeRequest { } } + /// Creates a new dummy request, with no restriction. pub fn dummy() -> Self { SizeRequest { w: DimensionRequest::Unknown,