[][src]Struct druid::widget::padding::Padding

pub struct Padding<T: Data + 'static + Default> {
    id: WidgetId,
    left: f64,
    right: f64,
    top: f64,
    bottom: f64,
    child: WidgetPod<T, WidgetBox<T>>,
}

A widget that just adds padding around its child.

Fields

id: WidgetIdleft: f64right: f64top: f64bottom: f64child: WidgetPod<T, WidgetBox<T>>

Methods

impl<T: Data + 'static + Default> Padding<T>[src]

pub fn new<W: Widget<T> + Clone>(
    insets: impl Into<Insets>,
    child: W
) -> Padding<T>
[src]

Create a new widget with the specified padding. This can either be an instance of kurbo::Insets, a f64 for uniform padding, a 2-tuple for axis-uniform padding or 4-tuple with (left, top, right, bottom) values.

Examples

Uniform padding:

use druid::widget::{Label, Padding};
use druid::kurbo::Insets;

let _: Padding<()> = Padding::new(10.0, Label::new("uniform!"));
let _: Padding<()> = Padding::new(Insets::uniform(10.0), Label::new("uniform!"));

Uniform padding across each axis:

use druid::widget::{Label, Padding};
use druid::kurbo::Insets;

let child: Label<()> = Label::new("I need my space!");
let _: Padding<()> = Padding::new((10.0, 20.0), Label::new("more y than x!"));
// equivalent:
let _: Padding<()> = Padding::new(Insets::uniform_xy(10.0, 20.0), Label::new("ditto :)"));

Trait Implementations

impl<T: Clone + Data + 'static + Default> Clone for Padding<T>[src]

impl<T: Data + 'static + Default> Widget<T> for Padding<T>[src]

Auto Trait Implementations

impl<T> Send for Padding<T> where
    T: Send

impl<T> Sync for Padding<T> where
    T: Sync

impl<T> Unpin for Padding<T> where
    T: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T[src]

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.