Skip to content

A VBox/HBox layout library for Rust

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
Unknown
LICENSE-MIT
Notifications You must be signed in to change notification settings

richardanaya/shoji

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shoji

docs.rs docs

A VBox/HBox layout library implemented in Rust. shoji allows your layout tree and it's calculations to be separate from your render tree. It's built for speed and style.

[dependencies]
shoji = "0.1"

Example

In shoji you build a tree of layout nodes each with a style that determines:

  • direction child content flows
  • margin/padding
  • alignment
  • etc.
use shoji::*;

fn main() -> Result<(), &'static str> {
    let mut shoji = Shoji::new();

    // Put together layout
    let top = shoji.new_node(LayoutStyle::default(),vec![]);

    let bottom_left = shoji.new_node(LayoutStyle::default(),vec![]);
    let bottom_right = shoji.new_node(LayoutStyle::default(),vec![]);

    let bottom = shoji.new_node(
        LayoutStyle { direction: Direction:LeftRight },
        vec![bottom_left, bottom_right],
    );

    let root = shoji.new_node(
        LayoutStyle { direction: Direction:TopDown },
        vec![top, bottom],
    );

    // Compute all layouts
    shoji.compute_layout(root, LayoutSize::new(100.0, 100.0))?;

    // Get the calculated layout
    dbg!(shoji.get_layout(top));
}

when you compute_layout to a constrained size, all layout nodes will have layout calculations with absolute values:

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in shoji by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

A VBox/HBox layout library for Rust

Resources

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
Unknown
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published