pub struct Style {Show 31 fields
pub display: Display,
pub width: Length,
pub height: Length,
pub flex_direction: FlexDirection,
pub padding: Edges,
pub margin: Edges,
pub gap: Gap,
pub grow: f32,
pub align: FlexAlign,
pub justify: FlexJustify,
pub align_self: Option<FlexAlign>,
pub justify_items: Option<FlexAlign>,
pub justify_self: Option<FlexAlign>,
pub grid_template: Option<GridTemplate>,
pub grid_row: (i16, i16),
pub grid_column: (i16, i16),
pub position: Position,
pub inset: Edges,
pub min_width: Length,
pub min_height: Length,
pub max_width: Length,
pub max_height: Length,
pub aspect_ratio: Option<f32>,
pub overflow_x: Overflow,
pub overflow_y: Overflow,
pub shrink: f32,
pub basis: Length,
pub flex_wrap: FlexWrap,
pub align_content: Option<AlignContent>,
pub border: Edges,
pub box_sizing: BoxSizing,
}Expand description
Framework-internal style record. Smaller and renderer-agnostic compared with taffy::Style; the layout impl crate translates it into its backend type.
New fields require a corresponding dirty_mask bit allocation in lumen/src/style_mask.rs.
W5.9 made this Clone (no longer Copy) because GridTemplate
owns track-list vectors. Hot paths that previously took Style by
value should switch to &Style - the layout backend already does.
Fields§
§display: DisplayCSS display mode. Selects the layout algorithm used for the
element’s children (W5.9). Display::Flex is the default
flexbox container; Display::Grid enables CSS Grid layout;
Display::None hides the element + its subtree.
width: LengthWidth along the cross axis.
height: LengthHeight along the main axis.
flex_direction: FlexDirectionFlex direction.
padding: EdgesPadding on each edge.
margin: EdgesMargin on each edge.
gap: GapSpacing inserted between adjacent rows / columns of a flex or
grid container. CSS gap / row-gap / column-gap. W5.9
split the previous single-scalar gap: f32 into a per-axis
Gap { row, column }; existing call sites use the
Gap::from(f32) shorthand to keep the same number on both
axes.
grow: f32Flex-grow factor. Mirrors CSS flex-grow. 0 = don’t grow.
align: FlexAlignCross-axis alignment (CSS align-items).
justify: FlexJustifyMain-axis distribution (CSS justify-content).
align_self: Option<FlexAlign>Per-item override of the container’s Self::align. None
inherits. Mirrors CSS align-self. W5.9: includes
FlexAlign::Baseline for mixed-size inline runs.
justify_items: Option<FlexAlign>Grid-only: alignment of items along the inline axis. Mirrors
CSS justify-items. None = Stretch. Ignored under
Display::Flex.
justify_self: Option<FlexAlign>Grid-only: per-item override of the parent’s justify_items.
Mirrors CSS justify-self.
grid_template: Option<GridTemplate>Grid template (rows / columns). None under
Display::Flex; required under Display::Grid. The
taffy backend lowers this into grid_template_rows /
grid_template_columns.
grid_row: (i16, i16)Grid-item: row line range (start, end) - CSS grid-row.
Each is a 1-based positive integer line number; 0 =
auto-placement.
grid_column: (i16, i16)Grid-item: column line range. See Self::grid_row.
position: PositionPositioning mode. Relative (default) participates in flex flow;
Absolute lifts the entity out of the flow and offsets it by
Self::inset against the nearest positioned ancestor.
inset: EdgesDistance from each edge when Self::position is Absolute.
min_width: LengthMinimum width (after content). Auto = unconstrained.
min_height: LengthMinimum height.
max_width: LengthMaximum width. Auto = unbounded.
max_height: LengthMaximum height.
aspect_ratio: Option<f32>width / height ratio constraint. None = none.
overflow_x: OverflowPer-axis overflow control. Visible clips nothing; Hidden clips
children to the box; Scroll clips + the entity becomes
scrollable.
overflow_y: OverflowSee Self::overflow_x.
shrink: f32Flex-shrink factor. Mirrors CSS flex-shrink; default 1.0
(items shrink to fit their line, per CSS).
basis: LengthFlex-basis - the main-axis size before free space distribution.
Mirrors CSS flex-basis; default Length::Auto.
flex_wrap: FlexWrapLine-wrapping mode for flex containers. Mirrors CSS flex-wrap;
default FlexWrap::NoWrap.
align_content: Option<AlignContent>Cross-axis distribution of lines in a multi-line flex container
(or of tracks in grid). Mirrors CSS align-content. None =
backend default (stretch-like). Only observable when
Self::flex_wrap allows multiple lines.
border: EdgesBorder widths per edge in logical pixels. Mirrors CSS
border-width with the resolved border-style folded in: a side
whose style is none carries width 0 here (per CSS, the
computed border-width of a none side is zero). Consumes space
per the CSS box model; paint lives in Visuals::border.
box_sizing: BoxSizingCSS box-sizing. Default BoxSizing::BorderBox (Lumen’s UA
default - explicit sizes include padding + border, matching what
virtually every real-world stylesheet opts into).
Trait Implementations§
Source§impl Component for Style
impl Component for Style
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor] required for working with relationships in dynamic contexts. Read more§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreimpl StructuralPartialEq for Style
Auto Trait Implementations§
impl Freeze for Style
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnsafeUnpin for Style
impl UnwindSafe for Style
Blanket Implementations§
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
§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
§unsafe fn get_components(
ptr: MovingPtr<'_, C>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
) -> <C as DynamicBundle>::Effect
unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
§unsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
§impl<T> FromTemplate for T
impl<T> FromTemplate for T
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
§impl<T> Template for T
impl<T> Template for T
§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.