/// Stack nodes along a specified dimension
Stack nodes along a specified dimension
Stack nodes along a specified dimension
pub fn stack(&mut self, axis: Axis, items: &[NodeId]) {
        for item_ids in items.windows(2) {
            let item_a = self.nodes.get(&item_ids[0]).unwrap();
            let item_b = self.nodes.get(&item_ids[1]).unwrap();
            match axis {
                Axis::X => self
                    .solver
                    .add_constraint(item_a.x + item_a.width | LE(REQUIRED) | item_b.x),
                Axis::Y => self
                    .solver
                    .add_constraint(item_a.y + item_a.height | LE(REQUIRED) | item_b.y),
                Axis::Z => self
                    .solver
                    .add_constraint(item_a.z + item_a.depth | LE(REQUIRED) | item_b.z),
            }.unwrap();
        }
    }
pub fn stack ( & mut self , axis : Axis , items : & [ NodeId ] ) { for item_ids in items . windows ( 2 ) { let item_a = self . nodes . get ( & item_ids [ 0 ] ) . unwrap ( ) ; let item_b = self . nodes . get ( & item_ids [ 1 ] ) . unwrap ( ) ; match axis { Axis :: X => self . solver . add_constraint ( item_a . x + item_a . width | LE ( REQUIRED ) | item_b . x ) , Axis :: Y => self . solver . add_constraint ( item_a . y + item_a . height | LE ( REQUIRED ) | item_b . y ) , Axis :: Z => self . solver . add_constraint ( item_a . z + item_a . depth | LE ( REQUIRED ) | item_b . z ) , } . unwrap ( ) ; } }
Stack nodes along a specified dimension
Stack nodes along a specified dimension
&mut self
axis
Axis
items
&[NodeId]