Skip to content

Commit

Permalink
Auto min size (#33)
Browse files Browse the repository at this point in the history
* Add auto min-size

* Add auto min-size

* Fix for computing auto size from children

* Fix min/max order

* Fix auto min content size

* Fmt

* Clippy

* Remove playground

* cleanup
  • Loading branch information
geom3trik authored Nov 28, 2024
1 parent 001a24f commit f300a5d
Show file tree
Hide file tree
Showing 12 changed files with 628 additions and 1,905 deletions.
9 changes: 9 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
{
"version": "0.2.0",
"configurations": [

{
"type": "lldb",
"request": "launch",
"name": "Basic",
"program": "${workspaceFolder}/target/debug/examples/basic",
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Menu",
"program": "${workspaceFolder}/target/debug/examples/menu",
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ description = "A UI layout engine"
repository = "https://github.com/vizia/morphorm"
keywords = ["ui", "gui", "layout", "flex"]

[workspace]
members = ["playground"]

[dependencies]
smallvec = "1.11.0"

Expand Down
55 changes: 55 additions & 0 deletions examples/menu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
mod common;
use common::*;

fn main() {
let mut world = World::default();

let root = world.add(None);
world.set_width(root, Units::Pixels(600.0));
world.set_height(root, Units::Pixels(600.0));
world.set_child_space(root, Units::Stretch(1.0));

let node = world.add(Some(root));
world.set_width(node, Units::Auto);
world.set_height(node, Units::Auto);

let child = world.add(Some(node));
world.set_width(child, Units::Stretch(1.0));
world.set_min_width(child, Units::Auto);
world.set_height(child, Units::Pixels(50.0));
world.set_content_size(child, |_, _, height| {
let h = height.unwrap();
(50.0, h)
});

let child = world.add(Some(node));
world.set_width(child, Units::Stretch(1.0));
world.set_min_width(child, Units::Auto);
world.set_height(child, Units::Pixels(50.0));
world.set_content_size(child, |_, _, height| {
let h = height.unwrap();
(60.0, h)
});

let child = world.add(Some(node));
world.set_width(child, Units::Stretch(1.0));
world.set_min_width(child, Units::Auto);
world.set_height(child, Units::Pixels(50.0));
world.set_content_size(child, |_, _, height| {
let h = height.unwrap();
(130.0, h)
});

let child = world.add(Some(node));
world.set_width(child, Units::Stretch(1.0));
world.set_min_width(child, Units::Auto);
world.set_height(child, Units::Pixels(50.0));
world.set_content_size(child, |_, _, height| {
let h = height.unwrap();
(80.0, h)
});

root.layout(&mut world.cache, &world.tree, &world.store, &mut ());

render(world, root);
}
11 changes: 0 additions & 11 deletions playground/Cargo.toml

This file was deleted.

196 changes: 0 additions & 196 deletions playground/src/canvas.rs

This file was deleted.

Loading

0 comments on commit f300a5d

Please sign in to comment.