Expand description
Tuple Fields§
§0: i32
§1: i32
Implementations§
source§impl Offset
impl Offset
sourcepub fn min(self, other: Self) -> Self
pub fn min(self, other: Self) -> Self
Return the minimum, componentwise
Examples found in repository?
src/event/components.rs (line 154)
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
pub fn set_offset(&mut self, offset: Offset) -> TkAction {
let offset = offset.min(self.max_offset).max(Offset::ZERO);
if offset == self.offset {
TkAction::empty()
} else {
self.offset = offset;
TkAction::REGION_MOVED
}
}
/// Scroll to make the given `rect` visible
///
/// Inputs and outputs:
///
/// - `rect`: the rect to focus in child's coordinate space
/// - `window_rect`: the rect of the scroll window
/// - returned `Rect`: the focus rect, adjusted for scroll offset; this
/// may be set via [`EventMgr::set_scroll`]
/// - returned `TkAction`: action to pass to the event manager
pub fn focus_rect(&mut self, rect: Rect, window_rect: Rect) -> (Rect, TkAction) {
let v = rect.pos - window_rect.pos;
let off = Offset::conv(rect.size) - Offset::conv(window_rect.size);
let offset = self.offset.max(v + off).min(v);
let action = self.set_offset(offset);
(rect - self.offset, action)
}
sourcepub fn max(self, other: Self) -> Self
pub fn max(self, other: Self) -> Self
Return the maximum, componentwise
Examples found in repository?
src/event/components.rs (line 154)
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
pub fn set_offset(&mut self, offset: Offset) -> TkAction {
let offset = offset.min(self.max_offset).max(Offset::ZERO);
if offset == self.offset {
TkAction::empty()
} else {
self.offset = offset;
TkAction::REGION_MOVED
}
}
/// Scroll to make the given `rect` visible
///
/// Inputs and outputs:
///
/// - `rect`: the rect to focus in child's coordinate space
/// - `window_rect`: the rect of the scroll window
/// - returned `Rect`: the focus rect, adjusted for scroll offset; this
/// may be set via [`EventMgr::set_scroll`]
/// - returned `TkAction`: action to pass to the event manager
pub fn focus_rect(&mut self, rect: Rect, window_rect: Rect) -> (Rect, TkAction) {
let v = rect.pos - window_rect.pos;
let off = Offset::conv(rect.size) - Offset::conv(window_rect.size);
let offset = self.offset.max(v + off).min(v);
let action = self.set_offset(offset);
(rect - self.offset, action)
}
sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Restrict a value to the specified interval, componentwise
sourcepub fn distance_l1(self) -> i32
pub fn distance_l1(self) -> i32
Return the L1 (rectilinear / taxicab) distance
sourcepub fn distance_l_inf(self) -> i32
pub fn distance_l_inf(self) -> i32
Return the L-inf (max) distance
sourcepub fn extract<D: Directional>(self, dir: D) -> i32
pub fn extract<D: Directional>(self, dir: D) -> i32
Extract one component, based on a direction
This merely extracts the horizontal or vertical component. It never negates it, even if the axis is reversed.
sourcepub fn set_component<D: Directional>(&mut self, dir: D, value: i32)
pub fn set_component<D: Directional>(&mut self, dir: D, value: i32)
Set one component of self, based on a direction
This does not negate components when the direction is reversed.
Examples found in repository?
src/layout/visitor.rs (line 545)
536 537 538 539 540 541 542 543 544 545 546 547 548
pub fn size_rules(
&mut self,
mgr: SizeMgr,
axis: AxisInfo,
child_rules: SizeRules,
style: FrameStyle,
) -> SizeRules {
let frame_rules = mgr.frame(style, axis);
let (rules, offset, size) = frame_rules.surround(child_rules);
self.offset.set_component(axis, offset);
self.size.set_component(axis, size);
rules
}
source§impl Offset
impl Offset
sourcepub const fn splat(n: i32) -> Self
pub const fn splat(n: i32) -> Self
Construct, using the same value on all axes
Examples found in repository?
src/geom.rs (line 587)
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602
pub fn shrink(&self, n: i32) -> Rect {
let pos = self.pos + Offset::splat(n);
let size = self.size - Size::splat(n + n);
Rect { pos, size }
}
/// Expand self in all directions by the given `n`
///
/// In debug mode this asserts that `n` is non-negative.
#[inline]
#[must_use = "method does not modify self but returns a new value"]
pub fn expand(&self, n: i32) -> Rect {
debug_assert!(n >= 0);
let pos = self.pos - Offset::splat(n);
let size = self.size + Size::splat(n + n);
Rect { pos, size }
}
Trait Implementations§
source§impl AddAssign<Offset> for Coord
impl AddAssign<Offset> for Coord
source§fn add_assign(&mut self, rhs: Offset)
fn add_assign(&mut self, rhs: Offset)
Performs the
+=
operation. Read moresource§impl AddAssign<Offset> for Event
impl AddAssign<Offset> for Event
source§fn add_assign(&mut self, offset: Offset)
fn add_assign(&mut self, offset: Offset)
Performs the
+=
operation. Read moresource§impl AddAssign<Offset> for Offset
impl AddAssign<Offset> for Offset
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresource§impl AddAssign<Offset> for Rect
impl AddAssign<Offset> for Rect
source§fn add_assign(&mut self, offset: Offset)
fn add_assign(&mut self, offset: Offset)
Performs the
+=
operation. Read moresource§impl ConvApprox<DVec2> for Offset
impl ConvApprox<DVec2> for Offset
source§fn try_conv_approx(arg: DVec2) -> Result<Self>
fn try_conv_approx(arg: DVec2) -> Result<Self>
source§fn conv_approx(x: T) -> Self
fn conv_approx(x: T) -> Self
source§impl ConvApprox<Vec2> for Offset
impl ConvApprox<Vec2> for Offset
source§fn try_conv_approx(arg: Vec2) -> Result<Self>
fn try_conv_approx(arg: Vec2) -> Result<Self>
source§fn conv_approx(x: T) -> Self
fn conv_approx(x: T) -> Self
source§impl ConvFloat<DVec2> for Offset
impl ConvFloat<DVec2> for Offset
source§fn try_conv_trunc(x: DVec2) -> Result<Self>
fn try_conv_trunc(x: DVec2) -> Result<Self>
Try converting to integer with truncation Read more
source§fn conv_trunc(x: T) -> Self
fn conv_trunc(x: T) -> Self
Convert to integer with truncatation Read more
source§fn conv_nearest(x: T) -> Self
fn conv_nearest(x: T) -> Self
Convert to the nearest integer Read more
source§fn conv_floor(x: T) -> Self
fn conv_floor(x: T) -> Self
Convert the floor to an integer Read more
source§impl ConvFloat<Vec2> for Offset
impl ConvFloat<Vec2> for Offset
source§fn try_conv_trunc(x: Vec2) -> Result<Self>
fn try_conv_trunc(x: Vec2) -> Result<Self>
Try converting to integer with truncation Read more
source§fn conv_trunc(x: T) -> Self
fn conv_trunc(x: T) -> Self
Convert to integer with truncatation Read more
source§fn conv_nearest(x: T) -> Self
fn conv_nearest(x: T) -> Self
Convert to the nearest integer Read more
source§fn conv_floor(x: T) -> Self
fn conv_floor(x: T) -> Self
Convert the floor to an integer Read more
source§impl<'de> Deserialize<'de> for Offset
impl<'de> Deserialize<'de> for Offset
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq<Offset> for Offset
impl PartialEq<Offset> for Offset
source§impl SubAssign<Offset> for Coord
impl SubAssign<Offset> for Coord
source§fn sub_assign(&mut self, rhs: Offset)
fn sub_assign(&mut self, rhs: Offset)
Performs the
-=
operation. Read moresource§impl SubAssign<Offset> for Offset
impl SubAssign<Offset> for Offset
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read moresource§impl SubAssign<Offset> for Rect
impl SubAssign<Offset> for Rect
source§fn sub_assign(&mut self, offset: Offset)
fn sub_assign(&mut self, offset: Offset)
Performs the
-=
operation. Read moreimpl Copy for Offset
impl Eq for Offset
impl StructuralEq for Offset
impl StructuralPartialEq for Offset
Auto Trait Implementations§
impl RefUnwindSafe for Offset
impl Send for Offset
impl Sync for Offset
impl Unpin for Offset
impl UnwindSafe for Offset
Blanket Implementations§
source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Cast to integer, truncating Read more
source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Cast to the nearest integer Read more
source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Cast the floor to an integer Read more
source§impl<S, T> ConvApprox<S> for Twhere
T: Conv<S>,
impl<S, T> ConvApprox<S> for Twhere
T: Conv<S>,
source§fn try_conv_approx(x: S) -> Result<T, Error>
fn try_conv_approx(x: S) -> Result<T, Error>
source§fn conv_approx(x: S) -> T
fn conv_approx(x: S) -> T
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.