|
1 | 1 | use taffy::style_helpers; |
2 | 2 |
|
3 | 3 | use crate::{ |
4 | | - AlignContent, AlignItems, AlignSelf, Display, FlexDirection, FlexWrap, GridAutoFlow, |
| 4 | + AlignContent, AlignItems, AlignSelf, BoxSizing, Display, FlexDirection, FlexWrap, GridAutoFlow, |
5 | 5 | GridPlacement, GridTrack, GridTrackRepetition, JustifyContent, JustifyItems, JustifySelf, |
6 | 6 | MaxTrackSizingFunction, MinTrackSizingFunction, OverflowAxis, PositionType, RepeatedGridTrack, |
7 | 7 | Style, UiRect, Val, |
@@ -70,7 +70,7 @@ pub fn from_style( |
70 | 70 | ) -> taffy::style::Style { |
71 | 71 | taffy::style::Style { |
72 | 72 | display: style.display.into(), |
73 | | - box_sizing: taffy::BoxSizing::BorderBox, |
| 73 | + box_sizing: style.box_sizing.into(), |
74 | 74 | item_is_table: false, |
75 | 75 | text_align: taffy::TextAlign::Auto, |
76 | 76 | overflow: taffy::Point { |
@@ -255,6 +255,15 @@ impl From<Display> for taffy::style::Display { |
255 | 255 | } |
256 | 256 | } |
257 | 257 |
|
| 258 | +impl From<BoxSizing> for taffy::style::BoxSizing { |
| 259 | + fn from(value: BoxSizing) -> Self { |
| 260 | + match value { |
| 261 | + BoxSizing::BorderBox => taffy::style::BoxSizing::BorderBox, |
| 262 | + BoxSizing::ContentBox => taffy::style::BoxSizing::ContentBox, |
| 263 | + } |
| 264 | + } |
| 265 | +} |
| 266 | + |
258 | 267 | impl From<OverflowAxis> for taffy::style::Overflow { |
259 | 268 | fn from(value: OverflowAxis) -> Self { |
260 | 269 | match value { |
@@ -453,6 +462,7 @@ mod tests { |
453 | 462 |
|
454 | 463 | let bevy_style = Style { |
455 | 464 | display: Display::Flex, |
| 465 | + box_sizing: BoxSizing::ContentBox, |
456 | 466 | position_type: PositionType::Absolute, |
457 | 467 | left: Val::ZERO, |
458 | 468 | right: Val::Percent(50.), |
@@ -520,6 +530,7 @@ mod tests { |
520 | 530 | let viewport_values = LayoutContext::new(1.0, bevy_math::Vec2::new(800., 600.)); |
521 | 531 | let taffy_style = from_style(&viewport_values, &bevy_style, false); |
522 | 532 | assert_eq!(taffy_style.display, taffy::style::Display::Flex); |
| 533 | + assert_eq!(taffy_style.box_sizing, taffy::style::BoxSizing::ContentBox); |
523 | 534 | assert_eq!(taffy_style.position, taffy::style::Position::Absolute); |
524 | 535 | assert_eq!( |
525 | 536 | taffy_style.inset.left, |
|
0 commit comments