Skip to main content

Style

Struct Style 

Source
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: Display

CSS 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: Length

Width along the cross axis.

§height: Length

Height along the main axis.

§flex_direction: FlexDirection

Flex direction.

§padding: Edges

Padding on each edge.

§margin: Edges

Margin on each edge.

§gap: Gap

Spacing 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: f32

Flex-grow factor. Mirrors CSS flex-grow. 0 = don’t grow.

§align: FlexAlign

Cross-axis alignment (CSS align-items).

§justify: FlexJustify

Main-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: Position

Positioning 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: Edges

Distance from each edge when Self::position is Absolute.

§min_width: Length

Minimum width (after content). Auto = unconstrained.

§min_height: Length

Minimum height.

§max_width: Length

Maximum width. Auto = unbounded.

§max_height: Length

Maximum height.

§aspect_ratio: Option<f32>

width / height ratio constraint. None = none.

§overflow_x: Overflow

Per-axis overflow control. Visible clips nothing; Hidden clips children to the box; Scroll clips + the entity becomes scrollable.

§overflow_y: Overflow§shrink: f32

Flex-shrink factor. Mirrors CSS flex-shrink; default 1.0 (items shrink to fit their line, per CSS).

§basis: Length

Flex-basis - the main-axis size before free space distribution. Mirrors CSS flex-basis; default Length::Auto.

§flex_wrap: FlexWrap

Line-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: Edges

Border 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: BoxSizing

CSS 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 Clone for Style

Source§

fn clone(&self) -> Style

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Component for Style
where Self: Send + Sync + 'static,

Source§

const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::Table

A constant indicating the storage type used for this component.
Source§

type Mutability = Mutable

A marker type to assist Bevy with determining if this component is mutable, or immutable. Mutable components will have Component<Mutability = Mutable>, while immutable components will instead have Component<Mutability = Immutable>. Read more
Source§

fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )

Registers required components. Read more
Source§

fn clone_behavior() -> ComponentCloneBehavior

Called when registering this component, allowing to override clone function (or disable cloning altogether) for this component. Read more
Source§

fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>

Returns [ComponentRelationshipAccessor] required for working with relationships in dynamic contexts. Read more
§

fn on_add() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_add [ComponentHook] for this Component if one is defined.
§

fn on_insert() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_insert [ComponentHook] for this Component if one is defined.
§

fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_discard [ComponentHook] for this Component if one is defined.
§

fn on_remove() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_remove [ComponentHook] for this Component if one is defined.
§

fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>

Gets the on_despawn [ComponentHook] for this Component if one is defined.
§

fn map_entities<E>(_this: &mut Self, _mapper: &mut E)
where E: EntityMapper,

Maps the entities on this component using the given 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 more
Source§

impl Debug for Style

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Style

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Style

Source§

fn eq(&self, other: &Style) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl 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> 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<C> Bundle for C
where C: Component,

§

fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>

§

fn get_component_ids( components: &Components, ) -> impl Iterator<Item = Option<ComponentId>>

Return a iterator over this Bundle’s component ids. This will be None if the component has not been registered.
§

impl<C> BundleFromComponents for C
where C: Component,

§

unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
where F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a>,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<C> DynamicBundle for C
where C: Component,

§

type Effect = ()

An operation on the entity that happens after inserting this bundle.
§

unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect

Moves the components out of the bundle. Read more
§

unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )

Applies the after-effects of spawning this bundle. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromTemplate for T
where T: Clone + Default + Unpin,

§

type Template = T

The Template for this type.
§

impl<T> FromWorld for T
where T: Default,

§

fn from_world(_world: &mut World) -> T

Creates Self using default().

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.

§

impl<T> IntoResult<T> for T

§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
§

impl<T> Template for T
where T: Clone + Default + Unpin,

§

type Output = T

The type of value produced by this Template.
§

fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>

Uses this template and the given entity context to produce a Template::Output.
§

fn clone_template(&self) -> T

Clones this template. See Clone.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

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