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: i32Left coordinate in parent/window space.
y: i32Top coordinate in parent/window space.
width: i32Width in logical pixels.
height: i32Height in logical pixels.
Implementations§
Source§impl FocusRect
impl FocusRect
Sourcepub const fn new(x: i32, y: i32, width: i32, height: i32) -> Self
pub const fn new(x: i32, y: i32, width: i32, height: i32) -> Self
Creates a new rectangle from position and dimensions.
Sourcepub const fn from_canvas_rect(rect: CanvasRect) -> Self
pub const fn from_canvas_rect(rect: CanvasRect) -> Self
Converts a CanvasRect into a FocusRect.
Sourcepub const fn to_canvas_rect(&self) -> CanvasRect
pub const fn to_canvas_rect(&self) -> CanvasRect
Converts this FocusRect into a CanvasRect.
Sourcepub const fn contains_point(&self, px: i32, py: i32) -> bool
pub const fn contains_point(&self, px: i32, py: i32) -> bool
Returns true if the rectangle contains the given point.
Sourcepub const fn intersects(&self, other: &Self) -> bool
pub const fn intersects(&self, other: &Self) -> bool
Returns true if this rectangle intersects other.
Sourcepub fn aspect_ratio(&self) -> f64
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§
impl Copy for FocusRect
impl Eq for FocusRect
impl StructuralPartialEq for FocusRect
Auto Trait Implementations§
impl Forget for FocusRect
impl Freeze for FocusRect
impl Move for FocusRect
impl RefUnwindSafe for FocusRect
impl Send for FocusRect
impl Sync for FocusRect
impl Unpin for FocusRect
impl UnsafeUnpin for FocusRect
impl UnwindSafe for FocusRect
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
Mutably borrows from an owned value. Read more