mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-12 12:13:08 +00:00
Add missing documentation.
This commit is contained in:
parent
7cfdd8e9fe
commit
9b998b0dd4
@ -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<Callback>) -> 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())
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<T: ToVec2>(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,
|
||||
|
Loading…
Reference in New Issue
Block a user