pub struct DockSizing { /* private fields */ }Expand description
Pure arithmetic for resizing one dock. The caller supplies the area
bounds and the opposite dock’s size; base does not reach across entities
to find them — the original Dock::resize read sibling dock sizes
straight off the (application-owned) DockArea entity, which base has no
way to do.
Implementations§
Source§impl DockSizing
impl DockSizing
pub fn new(placement: DockPlacement) -> Self
Sourcepub fn with_area_bounds(self, area: Bounds<Pixels>) -> Self
pub fn with_area_bounds(self, area: Bounds<Pixels>) -> Self
Set the full area bounds (origin and size). Needed whenever the dock’s placement depends on the area’s origin, e.g. a bottom dock measuring from the area’s bottom edge.
Sourcepub fn with_area_width(self, width: Pixels) -> Self
pub fn with_area_width(self, width: Pixels) -> Self
Set only the area’s width, leaving its origin and height untouched.
Convenient for left/right dock clamping, which only reads
area.size.width.
Sourcepub fn with_area_height(self, height: Pixels) -> Self
pub fn with_area_height(self, height: Pixels) -> Self
Set only the area’s height, leaving its origin and width untouched.
Convenient for bottom dock clamping, which only reads
area.size.height.
Sourcepub fn with_opposite_dock_size(self, size: Pixels) -> Self
pub fn with_opposite_dock_size(self, size: Pixels) -> Self
Set the size of the dock on the opposite side (right, for a left dock; left, for a right dock). Bottom docks have no opposite side.
Sourcepub fn size_from_pointer(&self, pointer: Point<Pixels>) -> Pixels
pub fn size_from_pointer(&self, pointer: Point<Pixels>) -> Pixels
The dock size the pointer implies, before clamping.
DockPlacement::Center names the canvas, which has no edge to measure
from and no dock size, so it answers zero. Both this and Self::clamp
are public and take a pub enum, so a caller can name that variant; a
base-layer arithmetic helper must not panic a desktop application over
it. DockPlacement::axis resolves the same variant the same way,
silently rather than by panicking.
Sourcepub fn clamp(&self, size: Pixels) -> Pixels
pub fn clamp(&self, size: Pixels) -> Pixels
Clamp a size into the range this dock may occupy: never below
PANEL_MIN_SIZE, and never so large it would squeeze the opposite
dock (if any) below PANEL_MIN_SIZE either. The .max(PANEL_MIN_SIZE)
on the computed maximum matters when the area itself is narrower than
both minimums combined — it keeps the clamp range non-empty.
DockPlacement::Center constrains nothing, so it hands the size back
unchanged. See Self::size_from_pointer for why that variant is
answered rather than rejected.
Trait Implementations§
Source§impl Clone for DockSizing
impl Clone for DockSizing
Source§fn clone(&self) -> DockSizing
fn clone(&self) -> DockSizing
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for DockSizing
Auto Trait Implementations§
impl Freeze for DockSizing
impl RefUnwindSafe for DockSizing
impl Send for DockSizing
impl Sync for DockSizing
impl Unpin for DockSizing
impl UnsafeUnpin for DockSizing
impl UnwindSafe for DockSizing
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