Skip to content

Commit

Permalink
fix: propagated margins
Browse files Browse the repository at this point in the history
  • Loading branch information
ten3roberts committed Dec 3, 2023
1 parent 87ceddd commit 2b6a2d7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
50 changes: 25 additions & 25 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,18 +555,18 @@ struct LayoutTest {

impl Widget for LayoutTest {
fn mount(self, scope: &mut Scope<'_>) {
// let row_2 = List::new((
// Rectangle { color: BRONZE }
// .with_margin(MARGIN)
// .with_size(Unit::px(vec2(100.0, 20.0))),
// Rectangle { color: EMERALD }
// .with_margin(MARGIN)
// .with_size(Unit::px(vec2(20.0, 20.0))),
// ))
// .with_direction(Direction::Vertical)
// .contain_margins(self.contain_margins)
// .with_background_color(EERIE_BLACK_300)
// .with_margin(MARGIN);
let row_2 = List::new((
Rectangle { color: BRONZE }
.with_margin(MARGIN)
.with_size(Unit::px(vec2(100.0, 20.0))),
Rectangle { color: EMERALD }
.with_margin(MARGIN)
.with_size(Unit::px(vec2(20.0, 20.0))),
))
.with_direction(Direction::Vertical)
.contain_margins(self.contain_margins)
.with_background_color(EERIE_BLACK_300)
.with_margin(MARGIN);

let row_1 = List::new((
Button {
Expand All @@ -576,19 +576,19 @@ impl Widget for LayoutTest {
}
.with_margin(MARGIN)
.with_size(Unit::px(vec2(800.0, 50.0))),
// row_2,
// // StackTest {},
// Button {
// normal_color: CHILI_RED,
// pressed_color: BRONZE,
// on_click: Box::new(|_, _| {}),
// }
// .with_margin(MARGIN)
// .with_size(Unit::px(vec2(200.0, 50.0))),
// // Text::new("Inline text, wrapping to fit").with_margin(MARGIN),
// Rectangle { color: EMERALD }
// .with_margin(Edges::new(20.0, 20.0, 20.0, 20.0))
// .with_size(Unit::px(vec2(10.0, 80.0))),
row_2,
StackTest {},
Button {
normal_color: CHILI_RED,
pressed_color: BRONZE,
on_click: Box::new(|_, _| {}),
}
.with_margin(MARGIN)
.with_size(Unit::px(vec2(200.0, 50.0))),
Text::new("Inline text, wrapping to fit").with_margin(MARGIN),
Rectangle { color: EMERALD }
.with_margin(Edges::new(20.0, 20.0, 20.0, 20.0))
.with_size(Unit::px(vec2(10.0, 80.0))),
))
.contain_margins(self.contain_margins)
.with_cross_align(CrossAlign::Center)
Expand Down
5 changes: 1 addition & 4 deletions src/layout/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use glam::{vec2, Vec2};
use itertools::Itertools;

use crate::{
components::{self, children, margin, Edges, Rect},
components::{self, children, Edges, Rect},
layout::query_size,
};

Expand Down Expand Up @@ -193,7 +193,6 @@ impl Flow {
let row = self.query_size(world, entity, content_area);

tracing::info!(?row.margin, "row margins to be contained");
if self.contain_margins {}

// If everything was squished as much as possible
let minimum_inner_size = row.min.size().dot(axis);
Expand Down Expand Up @@ -250,9 +249,7 @@ impl Flow {
// tracing::info!(%axis_sizing, block_min_size, remaining, "sizing: {}", ratio);

let child_margin = if self.contain_margins {
/// TODO recursively save the margin for transitive uncontained margins
sizing.margin
// entity.get_copy(margin()).unwrap_or_default()
} else {
Edges::ZERO
};
Expand Down

0 comments on commit 2b6a2d7

Please sign in to comment.