~prokop/lebka

2a9f4c1ba417cdfe7f3f15323a210b955ba05884 — Prokop Randacek 1 year, 4 months ago a5fcc3a
fix container size
3 files changed, 25 insertions(+), 17 deletions(-)

M index.lua
M src/layout.rs
M src/lib.rs
M index.lua => index.lua +1 -0
@@ 75,6 75,7 @@ return Box {
		Title('rdck.dev'), -- header
		Box { -- nav bar
			direction = "right",
			overflow = "wrap",
			NavItem('Home'), NavItem('Contact'), NavItem('Posts'), NavItem('Fun stuff'), NavItem('Maps'),
		},
		Box {

M src/layout.rs => src/layout.rs +23 -17
@@ 201,22 201,25 @@ impl Box {

                // collect child sizes
                // TODO: could be very parallel
                let children: Vec<_> = children.iter().map(|c| {
                    let index = cmds.len();
                    cmds.push(Command::PopOffset); // will be overwritten
                    let child_size = c.layout_intern(max_self_size, cmds);
                    cmds.push(Command::PopOffset);

                    let pad_top = Vec2::new_y(c.padding_top.eval(max_self_size.y, 0.0));
                    let pad_bottom = Vec2::new_y(c.padding_bottom.eval(max_self_size.y, 0.0));
                    let pad_left = Vec2::new_x(c.padding_left.eval(max_self_size.x, 0.0));
                    let pad_right = Vec2::new_x(c.padding_right.eval(max_self_size.x, 0.0));
                    // TODO: cap the values?

                    (child_size, index, pad_top, pad_bottom, pad_left, pad_right)
                }).collect();

                for (child_size, index, pad_top, pad_bottom, pad_left, pad_right) in children.into_iter() {
                let children: Vec<_> = children
                    .iter()
                    .map(|c| {
                        let index = cmds.len();
                        cmds.push(Command::PopOffset); // will be overwritten
                        let child_size = c.layout_intern(max_self_size, cmds);
                        cmds.push(Command::PopOffset);

                        let pad_top = Vec2::new_y(c.padding_top.eval(max_self_size.y, 0.0));
                        let pad_bottom = Vec2::new_y(c.padding_bottom.eval(max_self_size.y, 0.0));
                        let pad_left = Vec2::new_x(c.padding_left.eval(max_self_size.x, 0.0));
                        let pad_right = Vec2::new_x(c.padding_right.eval(max_self_size.x, 0.0));
                        // TODO: cap the values?

                        (child_size, index, pad_top, pad_bottom, pad_left, pad_right)
                    })
                    .collect();

                for (child_size, index, pad_top, pad_bottom, pad_left, pad_right) in children {
                    children_on_line += 1;

                    let pre_child_pad = match layout.direction {


@@ 368,7 371,10 @@ impl Box {

                cmds.push(Command::PopOffset);

                content_size
                Vec2::new(
                    f32::min(max_size.x, self.width.eval(max_size.x, content_size.x)),
                    f32::min(max_size.y, self.height.eval(max_size.y, content_size.y)),
                )
            }
            BoxType::Leaf(leaf_type) => {
                let (leaf_size, leaf_content) = match leaf_type {

M src/lib.rs => src/lib.rs +1 -0
@@ 11,6 11,7 @@
#![allow(clippy::cast_precision_loss)]
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::missing_panics_doc)]
#![allow(clippy::many_single_char_names)]

use render::Lebka;
use sandbox::Sandbox;