Struct widgetry::Widget

source ·
pub struct Widget {
    pub(crate) widget: Box<dyn WidgetImpl>,
    layout: LayoutStyle,
    pub(crate) rect: ScreenRectangle,
    bg: Option<Drawable>,
    bg_batch: Option<GeomBatch>,
    id: Option<String>,
}

Fields§

§widget: Box<dyn WidgetImpl>§layout: LayoutStyle§rect: ScreenRectangle§bg: Option<Drawable>§bg_batch: Option<GeomBatch>§id: Option<String>

Implementations§

source§

impl Widget

source

pub fn centered(self) -> Widget

source

pub fn centered_horiz(self) -> Widget

source

pub fn centered_vert(self) -> Widget

source

pub fn centered_cross(self) -> Widget

source

pub fn evenly_spaced(self) -> Widget

source

pub fn fill_width(self) -> Widget

source

pub fn fill_height(self) -> Widget

source

pub fn flex_wrap(self, ctx: &EventCtx<'_>, width: Percent) -> Widget

This one is really weird. percent_width should be LESS than the max_size_percent given to the overall Panel, otherwise weird things happen. Only makes sense for rows/columns.

source

pub fn flex_wrap_no_inner_spacing( self, ctx: &EventCtx<'_>, width: Percent ) -> Widget

Like flex_wrap, but doesn’t horizontally space out widgets on the same row.

source

pub fn force_width(self, width: f64) -> Widget

Only for rows/columns. Used to force table columns to line up.

source

pub fn force_width_window_pct( self, ctx: &EventCtx<'_>, width: Percent ) -> Widget

source

pub fn force_width_parent_pct(self, width: f64) -> Widget

source

pub fn get_width_for_forcing(&self) -> f64

Needed for force_width.

source

pub fn bg(self, color: Color) -> Widget

source

pub fn outline(self, style: OutlineStyle) -> Widget

Callers have to adjust padding too, probably

source

pub fn corner_rounding<R: Into<CornerRounding>>(self, value: R) -> Widget

source

pub fn container(self) -> Widget

Things like padding don’t work on many widgets, so just make a convenient way to wrap in a row/column first

source

pub fn section(self, ctx: &EventCtx<'_>) -> Widget

source

pub fn tab_body(self, ctx: &EventCtx<'_>) -> Widget

source

pub fn padding<I: Into<EdgeInsets>>(self, insets: I) -> Widget

source

pub fn padding_top(self, pixels: usize) -> Widget

source

pub fn padding_left(self, pixels: usize) -> Widget

source

pub fn padding_bottom(self, pixels: usize) -> Widget

source

pub fn padding_right(self, pixels: usize) -> Widget

source

pub fn margin<I: Into<EdgeInsets>>(self, insets: I) -> Widget

source

pub fn margin_above(self, pixels: usize) -> Widget

source

pub fn margin_below(self, pixels: usize) -> Widget

source

pub fn margin_left(self, pixels: usize) -> Widget

source

pub fn margin_right(self, pixels: usize) -> Widget

source

pub fn margin_horiz(self, pixels: usize) -> Widget

source

pub fn margin_vert(self, pixels: usize) -> Widget

source

pub fn align_left(self) -> Widget

source

pub fn align_right(self) -> Widget

source

pub fn align_bottom(self) -> Widget

source

pub fn align_vert_center(self) -> Widget

This doesn’t count against the entire container

source

fn abs(self, x: f64, y: f64) -> Widget

source

pub fn named<I: Into<String>>(self, id: I) -> Widget

source

pub fn hide(self, x: bool) -> Widget

If the argument is true, don’t actually create this widget. May be more readable than an if/else block.

source§

impl Widget

source

pub(crate) fn new(widget: Box<dyn WidgetImpl>) -> Widget

source

pub fn dropdown<T: 'static + PartialEq + Clone + Debug, I: AsRef<str>>( ctx: &EventCtx<'_>, label: I, default_value: T, choices: Vec<Choice<T>> ) -> Widget

source

pub fn custom_row(widgets: Vec<Widget>) -> Widget

Creates a row with the specified widgets. No margins or other layouting is applied.

source

pub fn row(widgets: Vec<Widget>) -> Widget

Creates a row with the specified widgets. Every member gets a default horizontal margin.

source

pub fn evenly_spaced_row(spacing: usize, widgets: Vec<Widget>) -> Widget

Creates a row with the specified widgets, with a spacing sized margin between members

source

pub fn custom_col(widgets: Vec<Widget>) -> Widget

Creates a column with the specified widgets. No margins or other layouting is applied.

source

pub fn evenly_spaced_col(spacing: usize, widgets: Vec<Widget>) -> Widget

Creates a column with the specified widgets, with a spacing sized margin between members

source

pub fn col(widgets: Vec<Widget>) -> Widget

Creates a column with the specified widgets. Every member gets a default vertical margin.

source

pub fn nothing() -> Widget

source

pub fn into_geom( self, ctx: &EventCtx<'_>, exact_pct_width: Option<f64> ) -> (GeomBatch, Polygon)

source

pub fn horiz_separator(ctx: &EventCtx<'_>, pct_container_width: f64) -> Widget

source

pub fn vert_separator(ctx: &EventCtx<'_>, height_px: f64) -> Widget

source

pub fn vertical_separator(ctx: &EventCtx<'_>) -> Widget

source

pub fn placeholder(ctx: &EventCtx<'_>, label: &str) -> Widget

source§

impl Widget

source

pub(crate) fn draw(&self, g: &mut GfxCtx<'_>)

source

fn get_flexbox(&self, parent: Node, taffy: &mut Taffy, nodes: &mut Vec<Node>)

source

fn apply_flexbox( &mut self, taffy: &Taffy, nodes: &mut Vec<Node>, dx: f64, dy: f64, scroll_offset: (f64, f64), ctx: &EventCtx<'_>, recompute_layout: bool, defer_draw: bool )

source

fn get_all_click_actions(&self, actions: &mut HashSet<String>)

source

fn currently_hovering(&self) -> Option<&String>

source

fn restore(&mut self, ctx: &mut EventCtx<'_>, prev: &Panel)

source

fn consume_geometry(self, batch: &mut GeomBatch)

source

fn find(&self, name: &str) -> Option<&Widget>

source

fn find_mut(&mut self, name: &str) -> Option<&mut Widget>

source

fn take(&mut self, name: &str) -> Option<Widget>

source

pub(crate) fn take_just_draw(self) -> JustDraw

Auto Trait Implementations§

§

impl Freeze for Widget

§

impl !RefUnwindSafe for Widget

§

impl !Send for Widget

§

impl !Sync for Widget

§

impl Unpin for Widget

§

impl !UnwindSafe for Widget

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

§

fn is_within(&self, b: &G2) -> bool