Skip to main content

FocusRect

Struct FocusRect 

Source
pub struct FocusRect {
    pub x: i32,
    pub y: i32,
    pub width: i32,
    pub height: i32,
}
Expand description

A 2D bounding rectangle in logical coordinates used for spatial focus calculation.

Fields§

§x: i32

Left coordinate in parent/window space.

§y: i32

Top coordinate in parent/window space.

§width: i32

Width in logical pixels.

§height: i32

Height in logical pixels.

Implementations§

Source§

impl FocusRect

Source

pub const fn new(x: i32, y: i32, width: i32, height: i32) -> Self

Creates a new rectangle from position and dimensions.

Source

pub const fn from_canvas_rect(rect: CanvasRect) -> Self

Converts a CanvasRect into a FocusRect.

Source

pub const fn to_canvas_rect(&self) -> CanvasRect

Converts this FocusRect into a CanvasRect.

Source

pub const fn left(&self) -> i32

Returns the left edge coordinate.

Source

pub const fn top(&self) -> i32

Returns the top edge coordinate.

Source

pub const fn right(&self) -> i32

Returns the right edge coordinate (x + width).

Source

pub const fn bottom(&self) -> i32

Returns the bottom edge coordinate (y + height).

Source

pub fn center_x(&self) -> f64

Returns the horizontal center point.

Source

pub fn center_y(&self) -> f64

Returns the vertical center point.

Source

pub fn center(&self) -> (f64, f64)

Returns the (x, y) center coordinates.

Source

pub const fn is_empty(&self) -> bool

Returns true if the rectangle has non-positive area.

Source

pub const fn contains_point(&self, px: i32, py: i32) -> bool

Returns true if the rectangle contains the given point.

Source

pub const fn intersects(&self, other: &Self) -> bool

Returns true if this rectangle intersects other.

Source

pub fn aspect_ratio(&self) -> f64

Returns the aspect ratio of the rectangle (width / height). If height is 0 or negative, returns 1.0.

Trait Implementations§

Source§

impl Clone for FocusRect

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for FocusRect

Source§

impl Debug for FocusRect

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FocusRect

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for FocusRect

Source§

impl Hash for FocusRect

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for FocusRect

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FocusRect

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.