pub struct Margin {
pub margin: EdgeInsets,
}Expand description
Outer spacing around a child (margin).
Mirrors Padding behavior: deflates child constraints, inflates final size,
and positions the child at (margin.left, margin.top).
Insets are logical pixels and are not normalized; callers should use finite
non-negative values because negative/non-finite values can produce unusual
offsets even though inner minima and maxima are floored at zero.
§Examples
use ailloli_ui_core::EdgeInsets;
use ailloli_ui_widgets::layout::Margin;
let margin = Margin::new(EdgeInsets::all(8.0));
assert_eq!(margin.margin.left, 8.0);Fields§
§margin: EdgeInsetsOuter logical-pixel insets in left/top/right/bottom order.
Implementations§
Source§impl Margin
impl Margin
Sourcepub fn new(margin: EdgeInsets) -> Self
pub fn new(margin: EdgeInsets) -> Self
Creates an outer-inset widget with the exact supplied edges.
§Examples
use ailloli_ui_core::EdgeInsets;
use ailloli_ui_widgets::layout::Margin;
let margin = Margin::new(EdgeInsets::new(1.0, 2.0, 3.0, 4.0));
assert_eq!((margin.margin.left, margin.margin.top), (1.0, 2.0));Trait Implementations§
Source§impl<A: 'static> Widget<A> for Margin
Deflates constraints, offsets at most one child, and reinflates final size.
impl<A: 'static> Widget<A> for Margin
Deflates constraints, offsets at most one child, and reinflates final size.
Source§fn debug_name(&self) -> &'static str
fn debug_name(&self) -> &'static str
Returns a stable, non-sensitive static name for diagnostics. Read more
Source§fn layout(
&self,
engine: &mut LayoutEngine<'_, A>,
ctx: &mut LayoutCtx<'_>,
children: &mut [LayoutChild],
constraints: Constraints,
) -> LayoutResult
fn layout( &self, engine: &mut LayoutEngine<'_, A>, ctx: &mut LayoutCtx<'_>, children: &mut [LayoutChild], constraints: Constraints, ) -> LayoutResult
Measures and positions this widget’s direct retained children. Read more
Source§fn paint(&self, _ctx: &mut PaintCtx<'_>, _bounds: Rect, _layout: &LayoutResult)
fn paint(&self, _ctx: &mut PaintCtx<'_>, _bounds: Rect, _layout: &LayoutResult)
Emits base draw commands for absolute logical-pixel
bounds. Read more§fn layout_dependency_revision(&self) -> u64
fn layout_dependency_revision(&self) -> u64
Revision of widget-owned inputs that can change its layout result. Read more
§fn layout_committed(
&self,
_ctx: &mut LayoutContext<'_>,
_bounds: Rect,
_layout: &LayoutResult,
)
fn layout_committed( &self, _ctx: &mut LayoutContext<'_>, _bounds: Rect, _layout: &LayoutResult, )
Observes newly committed absolute bounds after layout. Read more
§fn paint_overlay(
&self,
_ctx: &mut PaintContext<'_>,
_bounds: Rect,
_layout: &LayoutResult,
)
fn paint_overlay( &self, _ctx: &mut PaintContext<'_>, _bounds: Rect, _layout: &LayoutResult, )
Emits top-level paint commands after this widget’s descendants. Read more
§fn event(
&self,
_ctx: &mut EventContext<A>,
_event: &Event,
_bounds: Rect,
_layout: &LayoutResult,
)
fn event( &self, _ctx: &mut EventContext<A>, _event: &Event, _bounds: Rect, _layout: &LayoutResult, )
Handles one routed event for absolute bounds and cached layout. Read more
§fn focus_policy(&self) -> FocusPolicy
fn focus_policy(&self) -> FocusPolicy
Returns whether the widget may receive keyboard focus. Read more
§fn activation_policy(&self) -> ActivationPolicy
fn activation_policy(&self) -> ActivationPolicy
Policy used for provider-neutral focus-only pointer gestures. Read more
§fn input_role(&self) -> InputRole
fn input_role(&self) -> InputRole
Returns provider-neutral text-input semantics. Read more
§fn hover_cursor_role(&self) -> HoverCursorRole
fn hover_cursor_role(&self) -> HoverCursorRole
Returns the widget-wide hover cursor role. Read more
§fn hover_cursor_role_at(
&self,
_bounds: Rect,
_layout: &LayoutResult,
_pos: Point,
) -> HoverCursorRole
fn hover_cursor_role_at( &self, _bounds: Rect, _layout: &LayoutResult, _pos: Point, ) -> HoverCursorRole
Returns the hover cursor role at an absolute logical-pixel position. Read more
§fn ime_cursor_rect(&self, _bounds: Rect, _layout: &LayoutResult) -> Option<Rect>
fn ime_cursor_rect(&self, _bounds: Rect, _layout: &LayoutResult) -> Option<Rect>
Returns the absolute logical-pixel IME candidate/caret rectangle. Read more
Auto Trait Implementations§
impl Freeze for Margin
impl RefUnwindSafe for Margin
impl Send for Margin
impl Sync for Margin
impl Unpin for Margin
impl UnwindSafe for Margin
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