pub struct BoxStyle {Show 15 fields
pub width: Option<Length>,
pub height: Option<Length>,
pub min_width: Option<Length>,
pub max_width: Option<Length>,
pub min_height: Option<Length>,
pub max_height: Option<Length>,
pub padding: Option<[Length; 4]>,
pub margin: Option<[Length; 4]>,
pub aspect_ratio: Option<OrderedLayoutUnit>,
pub overflow: Overflow,
pub alignment: BoxAlignment,
pub position: Option<BoxPosition>,
pub grid: Option<BoxGridPlacement>,
pub flex_grow: Option<OrderedLayoutUnit>,
pub flex_shrink: Option<OrderedLayoutUnit>,
}Expand description
Typed sizing and overflow shared by common box-like widgets.
BoxStyle lets widgets expose CSS-like layout capabilities without
embedding CSS or shell-specific behavior in application code.
§Example
use fission_ir::op::{BoxAlignment, BoxStyle, Length, Overflow};
let style = BoxStyle::default()
.width(Length::clamp(
Length::points(280.0),
Length::percent(50.0),
Length::points(720.0),
))
.padding_symmetric(Length::points(24.0), Length::points(16.0))
.align(BoxAlignment::Center)
.overflow(Overflow::Clip);Fields§
§width: Option<Length>Preferred width.
height: Option<Length>Preferred height.
min_width: Option<Length>Minimum width constraint.
max_width: Option<Length>Maximum width constraint.
min_height: Option<Length>Minimum height constraint.
max_height: Option<Length>Maximum height constraint.
padding: Option<[Length; 4]>Inner spacing in [left, right, top, bottom] order.
margin: Option<[Length; 4]>Outer spacing in [left, right, top, bottom] order.
aspect_ratio: Option<OrderedLayoutUnit>Width-to-height ratio.
overflow: OverflowWhether content can paint outside this box.
alignment: BoxAlignmentChild alignment inside the content rectangle.
position: Option<BoxPosition>Optional absolute positioning offsets.
grid: Option<BoxGridPlacement>Optional parent-grid placement.
flex_grow: Option<OrderedLayoutUnit>Flex grow participation for box-like widgets.
flex_shrink: Option<OrderedLayoutUnit>Flex shrink participation for box-like widgets.
Implementations§
Source§impl BoxStyle
impl BoxStyle
Sourcepub fn min_height(self, value: Length) -> BoxStyle
pub fn min_height(self, value: Length) -> BoxStyle
Sets the minimum height.
Sourcepub fn max_height(self, value: Length) -> BoxStyle
pub fn max_height(self, value: Length) -> BoxStyle
Sets the maximum height.
Sourcepub fn padding(self, edges: [Length; 4]) -> BoxStyle
pub fn padding(self, edges: [Length; 4]) -> BoxStyle
Sets [left, right, top, bottom] inner spacing.
Sourcepub fn padding_all(self, value: Length) -> BoxStyle
pub fn padding_all(self, value: Length) -> BoxStyle
Sets equal inner spacing on every edge.
Sourcepub fn padding_symmetric(self, horizontal: Length, vertical: Length) -> BoxStyle
pub fn padding_symmetric(self, horizontal: Length, vertical: Length) -> BoxStyle
Sets horizontal and vertical inner spacing.
Sourcepub fn margin(self, edges: [Length; 4]) -> BoxStyle
pub fn margin(self, edges: [Length; 4]) -> BoxStyle
Sets [left, right, top, bottom] outer spacing.
Sourcepub fn margin_all(self, value: Length) -> BoxStyle
pub fn margin_all(self, value: Length) -> BoxStyle
Sets equal outer spacing on every edge.
Sourcepub fn margin_symmetric(self, horizontal: Length, vertical: Length) -> BoxStyle
pub fn margin_symmetric(self, horizontal: Length, vertical: Length) -> BoxStyle
Sets horizontal and vertical outer spacing.
Sourcepub fn align(self, alignment: BoxAlignment) -> BoxStyle
pub fn align(self, alignment: BoxAlignment) -> BoxStyle
Aligns the child within the box’s content rectangle.
Sourcepub fn aspect_ratio(self, ratio: f32) -> BoxStyle
pub fn aspect_ratio(self, ratio: f32) -> BoxStyle
Sets a non-negative width-to-height ratio.
Sourcepub fn positioned(self, position: BoxPosition) -> BoxStyle
pub fn positioned(self, position: BoxPosition) -> BoxStyle
Absolutely positions the box within its positioned parent.
Sourcepub fn grid(self, placement: BoxGridPlacement) -> BoxStyle
pub fn grid(self, placement: BoxGridPlacement) -> BoxStyle
Places the box in a parent grid.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for BoxStyle
impl<'de> Deserialize<'de> for BoxStyle
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<BoxStyle, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<BoxStyle, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for BoxStyle
impl Serialize for BoxStyle
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for BoxStyle
Auto Trait Implementations§
impl Freeze for BoxStyle
impl RefUnwindSafe for BoxStyle
impl Send for BoxStyle
impl Sync for BoxStyle
impl Unpin for BoxStyle
impl UnsafeUnpin for BoxStyle
impl UnwindSafe for BoxStyle
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.