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
sourceimpl Widget
impl Widget
pub fn centered(self) -> Widget
pub fn centered_horiz(self) -> Widget
pub fn centered_vert(self) -> Widget
pub fn centered_cross(self) -> Widget
pub fn evenly_spaced(self) -> Widget
pub fn fill_width(self) -> Widget
pub fn fill_height(self) -> Widget
sourcepub fn flex_wrap(self, ctx: &EventCtx<'_>, width: Percent) -> Widget
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.
sourcepub fn flex_wrap_no_inner_spacing(
self,
ctx: &EventCtx<'_>,
width: Percent
) -> Widget
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.
sourcepub fn force_width(self, width: f64) -> Widget
pub fn force_width(self, width: f64) -> Widget
Only for rows/columns. Used to force table columns to line up.
pub fn force_width_window_pct(
self,
ctx: &EventCtx<'_>,
width: Percent
) -> Widget
pub fn force_width_parent_pct(self, width: f64) -> Widget
sourcepub fn get_width_for_forcing(&self) -> f64
pub fn get_width_for_forcing(&self) -> f64
Needed for force_width.
pub fn bg(self, color: Color) -> Widget
sourcepub fn outline(self, style: OutlineStyle) -> Widget
pub fn outline(self, style: OutlineStyle) -> Widget
Callers have to adjust padding too, probably
pub fn corner_rounding<R: Into<CornerRounding>>(self, value: R) -> Widget
sourcepub fn container(self) -> Widget
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
pub fn section(self, ctx: &EventCtx<'_>) -> Widget
pub fn tab_body(self, ctx: &EventCtx<'_>) -> Widget
pub fn padding<I: Into<EdgeInsets>>(self, insets: I) -> Widget
pub fn padding_top(self, pixels: usize) -> Widget
pub fn padding_left(self, pixels: usize) -> Widget
pub fn padding_bottom(self, pixels: usize) -> Widget
pub fn padding_right(self, pixels: usize) -> Widget
pub fn margin<I: Into<EdgeInsets>>(self, insets: I) -> Widget
pub fn margin_above(self, pixels: usize) -> Widget
pub fn margin_below(self, pixels: usize) -> Widget
pub fn margin_left(self, pixels: usize) -> Widget
pub fn margin_right(self, pixels: usize) -> Widget
pub fn margin_horiz(self, pixels: usize) -> Widget
pub fn margin_vert(self, pixels: usize) -> Widget
pub fn align_left(self) -> Widget
pub fn align_right(self) -> Widget
pub fn align_bottom(self) -> Widget
sourcepub fn align_vert_center(self) -> Widget
pub fn align_vert_center(self) -> Widget
This doesn’t count against the entire container
fn abs(self, x: f64, y: f64) -> Widget
pub fn named<I: Into<String>>(self, id: I) -> Widget
sourceimpl Widget
impl Widget
pub(crate) fn new(widget: Box<dyn WidgetImpl>) -> Widget
pub fn dropdown<T: 'static + PartialEq + Clone + Debug, I: AsRef<str>>(
ctx: &EventCtx<'_>,
label: I,
default_value: T,
choices: Vec<Choice<T>>
) -> Widget
sourcepub fn custom_row(widgets: Vec<Widget>) -> Widget
pub fn custom_row(widgets: Vec<Widget>) -> Widget
Creates a row with the specified widgets. No margins or other layouting is applied.
sourcepub fn row(widgets: Vec<Widget>) -> Widget
pub fn row(widgets: Vec<Widget>) -> Widget
Creates a row with the specified widgets. Every member gets a default horizontal margin.
sourcepub fn evenly_spaced_row(spacing: usize, widgets: Vec<Widget>) -> Widget
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
sourcepub fn custom_col(widgets: Vec<Widget>) -> Widget
pub fn custom_col(widgets: Vec<Widget>) -> Widget
Creates a column with the specified widgets. No margins or other layouting is applied.
sourcepub fn evenly_spaced_col(spacing: usize, widgets: Vec<Widget>) -> Widget
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
sourcepub fn col(widgets: Vec<Widget>) -> Widget
pub fn col(widgets: Vec<Widget>) -> Widget
Creates a column with the specified widgets. Every member gets a default vertical margin.
pub fn nothing() -> Widget
pub fn into_geom(
self,
ctx: &EventCtx<'_>,
exact_pct_width: Option<f64>
) -> (GeomBatch, Polygon)
pub fn horiz_separator(ctx: &EventCtx<'_>, pct_container_width: f64) -> Widget
pub fn vert_separator(ctx: &EventCtx<'_>, height_px: f64) -> Widget
pub fn placeholder(ctx: &EventCtx<'_>, label: &str) -> Widget
sourceimpl Widget
impl Widget
pub(crate) fn draw(&self, g: &mut GfxCtx<'_>)
fn get_flexbox(
&self,
parent: Node,
stretch: &mut Stretch,
nodes: &mut Vec<Node>
)
fn apply_flexbox(
&mut self,
stretch: &Stretch,
nodes: &mut Vec<Node>,
dx: f64,
dy: f64,
scroll_offset: (f64, f64),
ctx: &EventCtx<'_>,
recompute_layout: bool,
defer_draw: bool
)
fn get_all_click_actions(&self, actions: &mut HashSet<String>)
fn currently_hovering(&self) -> Option<&String>
fn restore(&mut self, ctx: &mut EventCtx<'_>, prev: &Panel)
fn consume_geometry(self, batch: &mut GeomBatch)
pub fn is_btn(&self, name: &str) -> bool
fn find(&self, name: &str) -> Option<&Widget>
fn find_mut(&mut self, name: &str) -> Option<&mut Widget>
fn take(&mut self, name: &str) -> Option<Widget>
pub(crate) fn take_just_draw(self) -> JustDraw
Auto Trait Implementations
impl !RefUnwindSafe for Widget
impl !Send for Widget
impl !Sync for Widget
impl Unpin for Widget
impl !UnwindSafe for Widget
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn as_any(&self) -> &(dyn Any + 'static)
pub 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. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub 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. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self