pub struct Style {Show 22 fields
pub display: Display,
pub position_type: PositionType,
pub direction: Direction,
pub flex_direction: FlexDirection,
pub flex_wrap: FlexWrap,
pub align_items: AlignItems,
pub align_self: AlignSelf,
pub align_content: AlignContent,
pub justify_content: JustifyContent,
pub position: UiRect,
pub margin: UiRect,
pub padding: UiRect,
pub border: UiRect,
pub flex_grow: f32,
pub flex_shrink: f32,
pub flex_basis: Val,
pub size: Size,
pub min_size: Size,
pub max_size: Size,
pub aspect_ratio: Option<f32>,
pub overflow: Overflow,
pub gap: Size,
}
Expand description
Describes the style of a UI node
It uses the Flexbox system.
Fields§
§display: Display
Whether to arrange this node and its children with flexbox layout
If this is set to Display::None
, this node will be collapsed.
position_type: PositionType
Whether to arrange this node relative to other nodes, or positioned absolutely
direction: Direction
Which direction the content of this node should go
flex_direction: FlexDirection
Whether to use column or row layout
flex_wrap: FlexWrap
How to wrap nodes
align_items: AlignItems
How items are aligned according to the cross axis
align_self: AlignSelf
How this item is aligned according to the cross axis.
Overrides AlignItems
.
align_content: AlignContent
How to align each line, only applies if flex_wrap is set to
FlexWrap::Wrap
and there are multiple lines of items
justify_content: JustifyContent
How items align according to the main axis
position: UiRect
The position of the node as described by its Rect
margin: UiRect
The amount of space around a node outside its border.
If a percentage value is used, the percentage is calculated based on the width of the parent node.
Example
let style = Style {
margin: UiRect {
left: Val::Percent(10.),
right: Val::Percent(10.),
top: Val::Percent(15.),
bottom: Val::Percent(15.)
},
..Default::default()
};
A node with this style and a parent with dimensions of 100px by 300px, will have calculated margins of 10px on both left and right edges, and 15px on both top and bottom egdes.
padding: UiRect
The amount of space between the edges of a node and its contents.
If a percentage value is used, the percentage is calculated based on the width of the parent node.
Example
let style = Style {
padding: UiRect {
left: Val::Percent(1.),
right: Val::Percent(2.),
top: Val::Percent(3.),
bottom: Val::Percent(4.)
},
..Default::default()
};
A node with this style and a parent with dimensions of 300px by 100px, will have calculated padding of 3px on the left, 6px on the right, 9px on the top and 12px on the bottom.
border: UiRect
The amount of space between the margins of a node and its padding.
If a percentage value is used, the percentage is calculated based on the width of the parent node.
The size of the node will be expanded if there are constraints that prevent the layout algorithm from placing the border within the existing node boundary.
Rendering for borders is not yet implemented.
flex_grow: f32
Defines how much a flexbox item should grow if there’s space available
flex_shrink: f32
How to shrink if there’s not enough space available
flex_basis: Val
The initial length of the main axis, before other properties are applied.
If both are set, flex_basis
overrides size
on the main axis but it obeys the bounds defined by min_size
and max_size
.
size: Size
The ideal size of the flexbox
size.width
is used when it is within the bounds defined by min_size.width
and max_size.width
.
size.height
is used when it is within the bounds defined by min_size.height
and max_size.height
.
min_size: Size
The minimum size of the flexbox
min_size.width
is used if it is greater than either size.width
or max_size.width
, or both.
min_size.height
is used if it is greater than either size.height
or max_size.height
, or both.
max_size: Size
The maximum size of the flexbox
max_size.width
is used if it is within the bounds defined by min_size.width
and size.width
.
max_size.height
is used if it is within the bounds defined by min_size.height
and `size.height.
aspect_ratio: Option<f32>
The aspect ratio of the flexbox
overflow: Overflow
How to handle overflow
gap: Size
The size of the gutters between the rows and columns of the flexbox layout
Values of Size::UNDEFINED
and Size::AUTO
are treated as zero.
Implementations§
§impl Style
impl Style
pub const DEFAULT: Style = Self{ display: Display::DEFAULT, position_type: PositionType::DEFAULT, direction: Direction::DEFAULT, flex_direction: FlexDirection::DEFAULT, flex_wrap: FlexWrap::DEFAULT, align_items: AlignItems::DEFAULT, align_self: AlignSelf::DEFAULT, align_content: AlignContent::DEFAULT, justify_content: JustifyContent::DEFAULT, position: UiRect::DEFAULT, margin: UiRect::DEFAULT, padding: UiRect::DEFAULT, border: UiRect::DEFAULT, flex_grow: 0.0, flex_shrink: 1.0, flex_basis: Val::Auto, size: Size::AUTO, min_size: Size::AUTO, max_size: Size::AUTO, aspect_ratio: None, overflow: Overflow::DEFAULT, gap: Size::UNDEFINED,}
Trait Implementations§
§impl GetTypeRegistration for Stylewhere
Display: Reflect,
PositionType: Reflect,
Direction: Reflect,
FlexDirection: Reflect,
FlexWrap: Reflect,
AlignItems: Reflect,
AlignSelf: Reflect,
AlignContent: Reflect,
JustifyContent: Reflect,
UiRect: Reflect,
f32: Reflect,
Val: Reflect,
Size: Reflect,
Option<f32>: Reflect,
Overflow: Reflect,
impl GetTypeRegistration for Stylewhere Display: Reflect, PositionType: Reflect, Direction: Reflect, FlexDirection: Reflect, FlexWrap: Reflect, AlignItems: Reflect, AlignSelf: Reflect, AlignContent: Reflect, JustifyContent: Reflect, UiRect: Reflect, f32: Reflect, Val: Reflect, Size: Reflect, Option<f32>: Reflect, Overflow: Reflect,
§impl Reflect for Stylewhere
Display: Reflect,
PositionType: Reflect,
Direction: Reflect,
FlexDirection: Reflect,
FlexWrap: Reflect,
AlignItems: Reflect,
AlignSelf: Reflect,
AlignContent: Reflect,
JustifyContent: Reflect,
UiRect: Reflect,
f32: Reflect,
Val: Reflect,
Size: Reflect,
Option<f32>: Reflect,
Overflow: Reflect,
impl Reflect for Stylewhere Display: Reflect, PositionType: Reflect, Direction: Reflect, FlexDirection: Reflect, FlexWrap: Reflect, AlignItems: Reflect, AlignSelf: Reflect, AlignContent: Reflect, JustifyContent: Reflect, UiRect: Reflect, f32: Reflect, Val: Reflect, Size: Reflect, Option<f32>: Reflect, Overflow: Reflect,
§fn get_type_info(&self) -> &'static TypeInfo
fn get_type_info(&self) -> &'static TypeInfo
§fn into_any(self: Box<Style, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<Style, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Any>
.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut dyn Any
.§fn into_reflect(self: Box<Style, Global>) -> Box<dyn Reflect + 'static, Global>
fn into_reflect(self: Box<Style, Global>) -> Box<dyn Reflect + 'static, Global>
§fn as_reflect(&self) -> &(dyn Reflect + 'static)
fn as_reflect(&self) -> &(dyn Reflect + 'static)
§fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
§fn clone_value(&self) -> Box<dyn Reflect + 'static, Global>
fn clone_value(&self) -> Box<dyn Reflect + 'static, Global>
Reflect
trait object. Read more§fn set(
&mut self,
value: Box<dyn Reflect + 'static, Global>
) -> Result<(), Box<dyn Reflect + 'static, Global>>
fn set( &mut self, value: Box<dyn Reflect + 'static, Global> ) -> Result<(), Box<dyn Reflect + 'static, Global>>
§fn apply(&mut self, value: &(dyn Reflect + 'static))
fn apply(&mut self, value: &(dyn Reflect + 'static))
§fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
§fn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
§fn reflect_owned(self: Box<Style, Global>) -> ReflectOwned
fn reflect_owned(self: Box<Style, Global>) -> ReflectOwned
§fn reflect_partial_eq(&self, value: &(dyn Reflect + 'static)) -> Option<bool>
fn reflect_partial_eq(&self, value: &(dyn Reflect + 'static)) -> Option<bool>
§fn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
§fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
§fn serializable(&self) -> Option<Serializable<'_>>
fn serializable(&self) -> Option<Serializable<'_>>
§impl Struct for Stylewhere
Display: Reflect,
PositionType: Reflect,
Direction: Reflect,
FlexDirection: Reflect,
FlexWrap: Reflect,
AlignItems: Reflect,
AlignSelf: Reflect,
AlignContent: Reflect,
JustifyContent: Reflect,
UiRect: Reflect,
f32: Reflect,
Val: Reflect,
Size: Reflect,
Option<f32>: Reflect,
Overflow: Reflect,
impl Struct for Stylewhere Display: Reflect, PositionType: Reflect, Direction: Reflect, FlexDirection: Reflect, FlexWrap: Reflect, AlignItems: Reflect, AlignSelf: Reflect, AlignContent: Reflect, JustifyContent: Reflect, UiRect: Reflect, f32: Reflect, Val: Reflect, Size: Reflect, Option<f32>: Reflect, Overflow: Reflect,
§fn field(&self, name: &str) -> Option<&(dyn Reflect + 'static)>
fn field(&self, name: &str) -> Option<&(dyn Reflect + 'static)>
name
as a &dyn Reflect
.§fn field_mut(&mut self, name: &str) -> Option<&mut (dyn Reflect + 'static)>
fn field_mut(&mut self, name: &str) -> Option<&mut (dyn Reflect + 'static)>
name
as a
&mut dyn Reflect
.§fn field_at(&self, index: usize) -> Option<&(dyn Reflect + 'static)>
fn field_at(&self, index: usize) -> Option<&(dyn Reflect + 'static)>
index
as a
&dyn Reflect
.§fn field_at_mut(&mut self, index: usize) -> Option<&mut (dyn Reflect + 'static)>
fn field_at_mut(&mut self, index: usize) -> Option<&mut (dyn Reflect + 'static)>
index
as a &mut dyn Reflect
.§fn iter_fields(&self) -> FieldIter<'_> ⓘ
fn iter_fields(&self) -> FieldIter<'_> ⓘ
§fn clone_dynamic(&self) -> DynamicStruct
fn clone_dynamic(&self) -> DynamicStruct
DynamicStruct
.§impl Typed for Stylewhere
Display: Reflect,
PositionType: Reflect,
Direction: Reflect,
FlexDirection: Reflect,
FlexWrap: Reflect,
AlignItems: Reflect,
AlignSelf: Reflect,
AlignContent: Reflect,
JustifyContent: Reflect,
UiRect: Reflect,
f32: Reflect,
Val: Reflect,
Size: Reflect,
Option<f32>: Reflect,
Overflow: Reflect,
impl Typed for Stylewhere Display: Reflect, PositionType: Reflect, Direction: Reflect, FlexDirection: Reflect, FlexWrap: Reflect, AlignItems: Reflect, AlignSelf: Reflect, AlignContent: Reflect, JustifyContent: Reflect, UiRect: Reflect, f32: Reflect, Val: Reflect, Size: Reflect, Option<f32>: Reflect, Overflow: Reflect,
impl StructuralPartialEq for Style
Auto Trait Implementations§
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnwindSafe for Style
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere C: Component,
fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId) )
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> Cwhere F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a, Aligned>,
fn get_components( self, func: &mut impl FnMut(StorageType, OwningPtr<'_, Aligned>) )
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§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
Self
using data from the given World§impl<T> GetPath for Twhere
T: Reflect,
impl<T> GetPath for Twhere T: Reflect,
§fn reflect_path<'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
fn reflect_path<'r, 'p>( &'r self, path: &'p str ) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
path
. Read more§fn reflect_path_mut<'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
fn reflect_path_mut<'r, 'p>( &'r mut self, path: &'p str ) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
path
. Read more