Struct StyleBuilder

Source
pub struct StyleBuilder<'a, 'w> {
    pub target: &'a mut EntityWorldMut<'w>,
    /* private fields */
}
Expand description

An object that provides a fluent interface for defining styles for bevy_ui nodes. Most components such as BackgroundColor are mutated immediately, however some component types such as Style are cached in the builder and not applied until finish is called.

Fields§

§target: &'a mut EntityWorldMut<'w>

Implementations§

Source§

impl<'a, 'w> StyleBuilder<'a, 'w>

Source

pub fn new(target: &'a mut EntityWorldMut<'w>, style: Style) -> Self

Construct a new StyleBuilder instance.

Source

pub fn load_asset<A: Asset>(&mut self, path: AssetPath<'_>) -> Handle<A>

Helper method for loading assets.

Source

pub fn finish(self)

Consumes the StyleBuilder and applies the style to the target entity.

Trait Implementations§

Source§

impl<'a, 'w> StyleBuilderBackground for StyleBuilder<'a, 'w>

Source§

fn background_image<'p>( &mut self, path: impl Into<MaybeHandleOrPath<'p, Image>>, ) -> &mut Self

Set the background image of the target entity.
Source§

fn background_image_flipped<'p>( &mut self, path: impl Into<MaybeHandleOrPath<'p, Image>>, flip_x: bool, flip_y: bool, ) -> &mut Self

Set the background image of the target entity, and also explicitly configure the horizontal and vertical flip.
Source§

fn background_color(&mut self, color: impl ColorParam) -> &mut Self

Set the background color, or None for transparent.
Source§

fn background_image_color(&mut self, color: impl ColorParam) -> &mut Self

Set the background color, or None for transparent.
Source§

impl<'a, 'w> StyleBuilderBorderColor for StyleBuilder<'a, 'w>

Source§

fn border_color(&mut self, color: impl ColorParam) -> &mut Self

Source§

impl<'a, 'w> StyleBuilderBorderRadius for StyleBuilder<'a, 'w>

Source§

fn border_radius(&mut self, radius: impl BorderRadiusParam) -> &mut Self

Source§

impl<'a, 'w> StyleBuilderFont for StyleBuilder<'a, 'w>

Source§

fn color(&mut self, color: impl ColorParam) -> &mut Self

Source§

fn font<'p>( &mut self, path: impl Into<MaybeHandleOrPath<'p, Font>>, ) -> &mut Self

Source§

fn font_size(&mut self, val: impl OptFloatParam) -> &mut Self

Source§

impl<'a, 'w> StyleBuilderLayout for StyleBuilder<'a, 'w>

Source§

fn display(&mut self, disp: Display) -> &mut Self

Source§

fn flex_row(&mut self) -> &mut Self

Set the display to flex and the flex direction to row.
Source§

fn flex_column(&mut self) -> &mut Self

Set the display to flex and the flex direction to column.
Source§

fn position(&mut self, pos: PositionType) -> &mut Self

Source§

fn overflow(&mut self, ov: OverflowAxis) -> &mut Self

Source§

fn overflow_x(&mut self, ov: OverflowAxis) -> &mut Self

Source§

fn overflow_y(&mut self, ov: OverflowAxis) -> &mut Self

Source§

fn direction(&mut self, dir: Direction) -> &mut Self

Source§

fn left(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn right(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn top(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn bottom(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn width(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn height(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn min_width(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn min_height(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn max_width(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn max_height(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn aspect_ratio(&mut self, length: impl OptFloatParam) -> &mut Self

Source§

fn margin(&mut self, rect: impl UiRectParam) -> &mut Self

Source§

fn margin_left(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn margin_right(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn margin_top(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn margin_bottom(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn padding(&mut self, rect: impl UiRectParam) -> &mut Self

Source§

fn padding_left(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn padding_right(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn padding_top(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn padding_bottom(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn border(&mut self, rect: impl UiRectParam) -> &mut Self

Source§

fn border_left(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn border_right(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn border_top(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn border_bottom(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn flex_direction(&mut self, dir: FlexDirection) -> &mut Self

Source§

fn flex_wrap(&mut self, w: FlexWrap) -> &mut Self

Source§

fn flex(&mut self, grow: f32, shrink: f32, basis: impl LengthParam) -> &mut Self

Source§

fn flex_grow(&mut self, n: f32) -> &mut Self

Source§

fn flex_shrink(&mut self, n: f32) -> &mut Self

Source§

fn flex_basis(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn row_gap(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn column_gap(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn gap(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn align_items(&mut self, align: AlignItems) -> &mut Self

Source§

fn align_self(&mut self, align: AlignSelf) -> &mut Self

Source§

fn align_content(&mut self, align: AlignContent) -> &mut Self

Source§

fn justify_items(&mut self, justify: JustifyItems) -> &mut Self

Source§

fn justify_self(&mut self, justify: JustifySelf) -> &mut Self

Source§

fn justify_content(&mut self, justify: JustifyContent) -> &mut Self

Source§

fn grid_auto_flow(&mut self, flow: GridAutoFlow) -> &mut Self

Source§

fn grid_template_rows(&mut self, rows: Vec<RepeatedGridTrack>) -> &mut Self

Source§

fn grid_template_columns( &mut self, columns: Vec<RepeatedGridTrack>, ) -> &mut Self

Source§

fn grid_auto_rows(&mut self, rows: Vec<GridTrack>) -> &mut Self

Source§

fn grid_auto_columns(&mut self, columns: Vec<GridTrack>) -> &mut Self

Source§

fn grid_row(&mut self, val: GridPlacement) -> &mut Self

Source§

fn grid_row_start(&mut self, val: i16) -> &mut Self

Source§

fn grid_row_span(&mut self, val: u16) -> &mut Self

Source§

fn grid_row_end(&mut self, val: i16) -> &mut Self

Source§

fn grid_column(&mut self, val: GridPlacement) -> &mut Self

Source§

fn grid_column_start(&mut self, val: i16) -> &mut Self

Source§

fn grid_column_span(&mut self, val: u16) -> &mut Self

Source§

fn grid_column_end(&mut self, val: i16) -> &mut Self

Source§

impl<'a, 'w> StyleBuilderOutline for StyleBuilder<'a, 'w>

Source§

fn outline_color(&mut self, color: impl ColorParam) -> &mut Self

Source§

fn outline_width(&mut self, length: impl LengthParam) -> &mut Self

Source§

fn outline_offset(&mut self, length: impl LengthParam) -> &mut Self

Source§

impl<'a, 'w> StyleBuilderPointerEvents for StyleBuilder<'a, 'w>

Source§

fn pointer_events(&mut self, enabled: bool) -> &mut Self

Source§

impl<'a, 'w> StyleBuilderVisibility for StyleBuilder<'a, 'w>

Source§

fn visible(&mut self, visible: bool) -> &mut Self

Source§

impl<'a, 'w> StyleBuilderZIndex for StyleBuilder<'a, 'w>

Source§

fn z_index(&mut self, index: impl ZIndexParam) -> &mut Self

Auto Trait Implementations§

§

impl<'a, 'w> Freeze for StyleBuilder<'a, 'w>

§

impl<'a, 'w> !RefUnwindSafe for StyleBuilder<'a, 'w>

§

impl<'a, 'w> Send for StyleBuilder<'a, 'w>

§

impl<'a, 'w> Sync for StyleBuilder<'a, 'w>

§

impl<'a, 'w> Unpin for StyleBuilder<'a, 'w>

§

impl<'a, 'w> !UnwindSafe for StyleBuilder<'a, 'w>

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, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
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
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

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

Source§

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.
Source§

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.
Source§

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.
Source§

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> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

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

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

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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

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

Source§

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

Source§

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> Settings for T
where T: 'static + Send + Sync,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,