pub struct Point {
pub x: i32,
pub y: i32,
}Expand description
A screen coordinate pair (x, y).
Use Point wherever you need a column/row position: view origins, cursor
positions, mouse hit coordinates, or scroll offsets. Both fields are i32
because view origins go negative when a view is scrolled offscreen, and
translation deltas are frequently negative. Conversion to an unsigned buffer
index happens only at the screen boundary.
Point supports all four arithmetic operators (+, -, +=, -=) so
you can translate positions and compute offsets without converting to tuples:
let origin = Point::new(5, 3);
let offset = Point::new(-2, 1);
assert_eq!(origin + offset, Point::new(3, 4));Default returns Point::new(0, 0).
§Turbo Vision heritage
Ports TPoint from objects.h. Field names are lowercase (x, y)
following Rust conventions; the original used uppercase X/Y.
Fields§
§x: i32Screen column (horizontal position).
Zero is the leftmost column. Negative values occur when a view’s origin
is scrolled to the left of the visible area. Write this field directly
when constructing geometry; use Point::new to set both axes at once.
y: i32Screen row (vertical position).
Zero is the topmost row. Negative values occur when a view’s origin is
scrolled above the visible area. Write this field directly when
constructing geometry; use Point::new to set both axes at once.
Implementations§
Source§impl Point
impl Point
Sourcepub const fn new(x: i32, y: i32) -> Self
pub const fn new(x: i32, y: i32) -> Self
Construct a point from a column x and row y.
This is a const fn, so it can be used in const and static
contexts. For the zero point, Default::default() (or
Point::default()) is equivalent and more expressive.
const ORIGIN: Point = Point::new(0, 0);
assert_eq!(ORIGIN, Point::default());Trait Implementations§
Source§impl AddAssign for Point
impl AddAssign for Point
Source§fn add_assign(&mut self, rhs: Point)
fn add_assign(&mut self, rhs: Point)
Shifts this point in place by adding rhs.
Use this to accumulate translation steps without allocating a new
Point: cursor += delta.
impl Copy for Point
impl Eq for Point
impl StructuralPartialEq for Point
Auto Trait Implementations§
impl Freeze for Point
impl RefUnwindSafe for Point
impl Send for Point
impl Sync for Point
impl Unpin for Point
impl UnsafeUnpin for Point
impl UnwindSafe for Point
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.