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: WindowId
The window id
monitor_scale: f64
The scaling of the monitor, if any
monitor_bounds: Rect
The logical bounds of the monitor
window_content_bounds: Rect
The bounds of the view content within the monitor’s bounds
window_bounds: Rect
The 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,
§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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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