- Notifications
You must be signed in to change notification settings - Fork28
Flex is a flexible box layout system written in C, designed to be easy to consume from other languages
License
xamarin/flex
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
flex is a flexible box layout system following theCSS flexbox module specifications. The goal is to offer a fully compliant implementation with a small and maintainable code base under a permissive license.
flex exposes a plain C API with the same parameters that you would use in CSS to customize the layout of a flexible view hierarchy. The API is designed to be easily interoperable with foreign runtimes (ex. C#) and meant to be used by widget toolkits as the foundation of a view layout API.
flex supports both single and multiple (wrap) lines layouts.
If you program in C# you can go straight to thebindings/csharp directory.
If you program in a C-compatible environment you can simply copy theflex.c
andflex.h
files to your project. The code was written to be cross-platform and does not require dependencies.
On a Mac you can also generate static and dynamic libraries for iOS, Android and macOS usingmake
:
$ make macos$ make ios$ make android$ make # builds everything
Make sure to have theANDROID_NDK
environment variable set to the path where the Android NDK is located in your system. You can also tweak build variables by editing theMakefile
file.
On a Windows machine you can generate dynamic libraires (DLL) for x86, x64, ARM and ARM64 by opening the Visual Studio project file or runningmsbuild
from the command line.
Under thedemo
directory you will find an Xcode project that will build a Mac demo app. The app exposes the entire set of flexbox parameters that are implemented and lets you create views (including nested ones), similar to how you would build a more realistic user interface in practice.
Attribute | Status |
---|---|
width, height | 🆗 |
self_sizing | 🆗 |
padding | 🆗 |
margin | 🆗 |
justify_content flex_start | 🆗 |
justify_content flex_end | 🆗 |
justify_content center | 🆗 |
justify_content space_around | 🆗 |
justify_content space_between | 🆗 |
justify_content space_evenly | 🆗 |
align_content flex_start | 🆗 |
align_content flex_end | 🆗 |
align_content center | 🆗 |
align_content space_around | 🆗 |
align_content space_between | 🆗 |
align_content space_evenly | 🆗 |
align_content stretch | 🆗 |
align_items flex_start | 🆗 |
align_items flex_end | 🆗 |
align_items center | 🆗 |
align_items stretch | 🆗 |
align_self flex_start | 🆗 |
align_self flex_end | 🆗 |
align_self center | 🆗 |
align_self stretch | 🆗 |
position relative | 🆗 |
position absolute | 🆗 |
direction column | 🆗 |
direction column_reverse | 🆗 |
direction row | 🆗 |
direction row_reverse | 🆗 |
wrap no_wrap | 🆗 |
wrap wrap | 🆗 |
wrap wrap_reverse | 🆗 |
grow | 🆗 |
shrink | 🆗 |
order | 🆗 |
basis | 🆗 |
There is a test suite in thetests
directory. See thetests/README.md file for more details on how to build, run and contribute to the test suite.
flex is distributed under the terms of the MIT license. See theLICENSE.txt
file for more information.
About
Flex is a flexible box layout system written in C, designed to be easy to consume from other languages