#ffi #layout #yoga #flex

sys yoga-sys

Raw rust bindings for yoga (facebook flex layout cross-platform engine)

5 releases

0.2.3 Nov 23, 2017
0.2.2 Oct 19, 2017
0.2.1 Oct 19, 2017
0.2.0 Sep 25, 2017
0.1.0 May 23, 2017

#10 in Rendering engine

Download history 1/week @ 2018-09-18 1/week @ 2018-09-25 16/week @ 2018-10-02 4/week @ 2018-10-09 61/week @ 2018-10-16 6/week @ 2018-10-23 31/week @ 2018-11-06 10/week @ 2018-11-13 10/week @ 2018-11-20 10/week @ 2018-11-27 14/week @ 2018-12-04

26 downloads per month

BSD-3-Clause

200KB
4K SLoC

C++ 3K SLoC // 0.1% comments Rust 1K SLoC // 0.0% comments Shell 10 SLoC

yoga-sys Build StatusBuild Status

Raw rust bindings for yoga.

Disclaimer: Those bindings are not provided by any of the facebook maintainers and thus may contains additional bugs.

Getting started:

Add to your Cargo.toml:

[dependencies]
yoga-sys = "0.2.3"

In your main.rs or lib.rs file add:

extern crate yoga_sys;

Example

Here is the example that you can find here translated to rust using this crate:

extern crate yoga_sys;

use yoga_sys::*;

fn main() {
    unsafe {
        let root = YGNodeNew();
        YGNodeStyleSetWidth(root, 500.);
        YGNodeStyleSetHeight(root, 120.);
        YGNodeStyleSetFlexDirection(root, YGFlexDirection::YGFlexDirectionRow);
        YGNodeStyleSetPadding(root, YGEdge::YGEdgeAll, 20.);

        let image = YGNodeNew();
        YGNodeStyleSetWidth(image, 80.);
        YGNodeStyleSetMargin(image, YGEdge::YGEdgeEnd, 20.);

        let text = YGNodeNew();
        YGNodeStyleSetHeight(text, 25.);
        YGNodeStyleSetAlignSelf(text, YGAlign::YGAlignCenter);
        YGNodeStyleSetFlexGrow(text, 1.);

        YGNodeInsertChild(root, image, 0);
        YGNodeInsertChild(root, text, 1);

        YGNodeFreeRecursive(root);
    }
}

Dependencies

~599KB
~12K SLoC

  • build build.rs
  • build cc 1.0
  • build skeptic 0.13