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>
impl<'a, 'w> StyleBuilder<'a, 'w>
Sourcepub fn new(target: &'a mut EntityWorldMut<'w>, style: Style) -> Self
pub fn new(target: &'a mut EntityWorldMut<'w>, style: Style) -> Self
Construct a new StyleBuilder instance.
Sourcepub fn load_asset<A: Asset>(&mut self, path: AssetPath<'_>) -> Handle<A>
pub fn load_asset<A: Asset>(&mut self, path: AssetPath<'_>) -> Handle<A>
Helper method for loading assets.
Sourcepub fn finish(self)
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>
impl<'a, 'w> StyleBuilderBackground for StyleBuilder<'a, 'w>
Source§fn background_image<'p>(
&mut self,
path: impl Into<MaybeHandleOrPath<'p, Image>>,
) -> &mut Self
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
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
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
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>
impl<'a, 'w> StyleBuilderBorderColor for StyleBuilder<'a, 'w>
fn border_color(&mut self, color: impl ColorParam) -> &mut Self
Source§impl<'a, 'w> StyleBuilderBorderRadius for StyleBuilder<'a, 'w>
impl<'a, 'w> StyleBuilderBorderRadius for StyleBuilder<'a, 'w>
fn border_radius(&mut self, radius: impl BorderRadiusParam) -> &mut Self
Source§impl<'a, 'w> StyleBuilderFont for StyleBuilder<'a, 'w>
impl<'a, 'w> StyleBuilderFont for StyleBuilder<'a, 'w>
fn color(&mut self, color: impl ColorParam) -> &mut Self
fn font<'p>( &mut self, path: impl Into<MaybeHandleOrPath<'p, Font>>, ) -> &mut Self
fn font_size(&mut self, val: impl OptFloatParam) -> &mut Self
Source§impl<'a, 'w> StyleBuilderLayout for StyleBuilder<'a, 'w>
impl<'a, 'w> StyleBuilderLayout for StyleBuilder<'a, 'w>
fn display(&mut self, disp: Display) -> &mut Self
Source§fn flex_column(&mut self) -> &mut Self
fn flex_column(&mut self) -> &mut Self
Set the display to flex and the flex direction to column.
fn position(&mut self, pos: PositionType) -> &mut Self
fn overflow(&mut self, ov: OverflowAxis) -> &mut Self
fn overflow_x(&mut self, ov: OverflowAxis) -> &mut Self
fn overflow_y(&mut self, ov: OverflowAxis) -> &mut Self
fn direction(&mut self, dir: Direction) -> &mut Self
fn left(&mut self, length: impl LengthParam) -> &mut Self
fn right(&mut self, length: impl LengthParam) -> &mut Self
fn top(&mut self, length: impl LengthParam) -> &mut Self
fn bottom(&mut self, length: impl LengthParam) -> &mut Self
fn width(&mut self, length: impl LengthParam) -> &mut Self
fn height(&mut self, length: impl LengthParam) -> &mut Self
fn min_width(&mut self, length: impl LengthParam) -> &mut Self
fn min_height(&mut self, length: impl LengthParam) -> &mut Self
fn max_width(&mut self, length: impl LengthParam) -> &mut Self
fn max_height(&mut self, length: impl LengthParam) -> &mut Self
fn aspect_ratio(&mut self, length: impl OptFloatParam) -> &mut Self
fn margin(&mut self, rect: impl UiRectParam) -> &mut Self
fn margin_left(&mut self, length: impl LengthParam) -> &mut Self
fn margin_right(&mut self, length: impl LengthParam) -> &mut Self
fn margin_top(&mut self, length: impl LengthParam) -> &mut Self
fn margin_bottom(&mut self, length: impl LengthParam) -> &mut Self
fn padding(&mut self, rect: impl UiRectParam) -> &mut Self
fn padding_left(&mut self, length: impl LengthParam) -> &mut Self
fn padding_right(&mut self, length: impl LengthParam) -> &mut Self
fn padding_top(&mut self, length: impl LengthParam) -> &mut Self
fn padding_bottom(&mut self, length: impl LengthParam) -> &mut Self
fn border(&mut self, rect: impl UiRectParam) -> &mut Self
fn border_left(&mut self, length: impl LengthParam) -> &mut Self
fn border_right(&mut self, length: impl LengthParam) -> &mut Self
fn border_top(&mut self, length: impl LengthParam) -> &mut Self
fn border_bottom(&mut self, length: impl LengthParam) -> &mut Self
fn flex_direction(&mut self, dir: FlexDirection) -> &mut Self
fn flex_wrap(&mut self, w: FlexWrap) -> &mut Self
fn flex(&mut self, grow: f32, shrink: f32, basis: impl LengthParam) -> &mut Self
fn flex_grow(&mut self, n: f32) -> &mut Self
fn flex_shrink(&mut self, n: f32) -> &mut Self
fn flex_basis(&mut self, length: impl LengthParam) -> &mut Self
fn row_gap(&mut self, length: impl LengthParam) -> &mut Self
fn column_gap(&mut self, length: impl LengthParam) -> &mut Self
fn gap(&mut self, length: impl LengthParam) -> &mut Self
fn align_items(&mut self, align: AlignItems) -> &mut Self
fn align_self(&mut self, align: AlignSelf) -> &mut Self
fn align_content(&mut self, align: AlignContent) -> &mut Self
fn justify_items(&mut self, justify: JustifyItems) -> &mut Self
fn justify_self(&mut self, justify: JustifySelf) -> &mut Self
fn justify_content(&mut self, justify: JustifyContent) -> &mut Self
fn grid_auto_flow(&mut self, flow: GridAutoFlow) -> &mut Self
fn grid_template_rows(&mut self, rows: Vec<RepeatedGridTrack>) -> &mut Self
fn grid_template_columns( &mut self, columns: Vec<RepeatedGridTrack>, ) -> &mut Self
fn grid_auto_rows(&mut self, rows: Vec<GridTrack>) -> &mut Self
fn grid_auto_columns(&mut self, columns: Vec<GridTrack>) -> &mut Self
fn grid_row(&mut self, val: GridPlacement) -> &mut Self
fn grid_row_start(&mut self, val: i16) -> &mut Self
fn grid_row_span(&mut self, val: u16) -> &mut Self
fn grid_row_end(&mut self, val: i16) -> &mut Self
fn grid_column(&mut self, val: GridPlacement) -> &mut Self
fn grid_column_start(&mut self, val: i16) -> &mut Self
fn grid_column_span(&mut self, val: u16) -> &mut Self
fn grid_column_end(&mut self, val: i16) -> &mut Self
Source§impl<'a, 'w> StyleBuilderOutline for StyleBuilder<'a, 'w>
impl<'a, 'w> StyleBuilderOutline for StyleBuilder<'a, 'w>
fn outline_color(&mut self, color: impl ColorParam) -> &mut Self
fn outline_width(&mut self, length: impl LengthParam) -> &mut Self
fn outline_offset(&mut self, length: impl LengthParam) -> &mut Self
Source§impl<'a, 'w> StyleBuilderPointerEvents for StyleBuilder<'a, 'w>
impl<'a, 'w> StyleBuilderPointerEvents for StyleBuilder<'a, 'w>
fn pointer_events(&mut self, enabled: bool) -> &mut Self
Source§impl<'a, 'w> StyleBuilderVisibility for StyleBuilder<'a, 'w>
impl<'a, 'w> StyleBuilderVisibility for StyleBuilder<'a, 'w>
Source§impl<'a, 'w> StyleBuilderZIndex for StyleBuilder<'a, 'w>
impl<'a, 'w> StyleBuilderZIndex for StyleBuilder<'a, 'w>
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, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
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> 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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn 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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
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)
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.