pub struct ScreenLayout {
pub window_id: WindowId,
pub monitor_scale: f64,
pub monitor_bounds: Rect,
pub window_content_bounds: Rect,
pub window_bounds: Rect,
pub view_origin_in_window: Option<Point>,
}Expand description
A ScreenLayout is a snapshot of the layout of a view within a window
Relates a realized View to the bounds of the window that contains it,
and the window to the bounds of the monitor that contains it. All fields
are in logical coordinates (if the OS scales physical coordinates for high
DPI displays, the scaling is already applied).
Instances are a snapshot in time of the location of the view and window at the time of creation, and are not updated if view or window or monitor in use is.
Fields§
§window_id: WindowIdThe window id
monitor_scale: f64The scaling of the monitor, if any
monitor_bounds: RectThe logical bounds of the monitor
window_content_bounds: RectThe bounds of the view content within the monitor’s bounds
window_bounds: RectThe bounds of the window within the monitor’s bounds
view_origin_in_window: Option<Point>The origin of the view within the window, if this ScreenLayout was
created from a View rather than a WindowId - needed for computing
relative offsets from, e.g., the location of a mouse click within
a View.
Implementations§
Source§impl ScreenLayout
impl ScreenLayout
Sourcepub fn to_physical_scale(&self) -> Self
pub fn to_physical_scale(&self) -> Self
Unscales this Screen to physical device coordinates, less any DPI scaling done by hardware.
Sourcepub fn window_frame_insets(&self) -> (f64, f64, f64, f64)
pub fn window_frame_insets(&self) -> (f64, f64, f64, f64)
Get the insets required to transform the outer rectangle into
the inner one in the form (left, top, right, bottom)
Sourcepub fn view_location_from_screen(&self, screen_point: Point) -> Point
pub fn view_location_from_screen(&self, screen_point: Point) -> Point
Convert a screen position to a position within the view that created this one.
Sourcepub fn contains_frame_decoration_insets(&self) -> bool
pub fn contains_frame_decoration_insets(&self) -> bool
Determine if this ScreenBounds has a different bounding rectangle for
the content and frame bounds. Some X11 window managers (Openbox, for one)
appear to support getting frame position separately from content position,
but in fact report the same bounds for both.
Sourcepub fn screen_location_from_view(
&self,
relative_position: Option<Point>,
target_size: Option<Size>,
) -> Point
pub fn screen_location_from_view( &self, relative_position: Option<Point>, target_size: Option<Size>, ) -> Point
Compute a position, in screen coordinates, relative to the view this layout was created from. If a target size is passed, the implementation will attempt to adjust the resulting point so that a rectangle of the required size fits entirely on-screen.
Trait Implementations§
Source§impl Clone for ScreenLayout
impl Clone for ScreenLayout
Source§fn clone(&self) -> ScreenLayout
fn clone(&self) -> ScreenLayout
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ScreenLayout
impl Debug for ScreenLayout
Source§impl PartialEq for ScreenLayout
impl PartialEq for ScreenLayout
impl Copy for ScreenLayout
impl StructuralPartialEq for ScreenLayout
Auto Trait Implementations§
impl Freeze for ScreenLayout
impl RefUnwindSafe for ScreenLayout
impl Send for ScreenLayout
impl Sync for ScreenLayout
impl Unpin for ScreenLayout
impl UnwindSafe for ScreenLayout
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more