GithubHelp home page GithubHelp logo

tony / layout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from randrew/layout

0.0 1.0 0.0 51 KB

Library for calculating 2D UI layouts using stacking boxes. Compiles as C99 or C++. Two files.

License: Other

C 93.08% Lua 6.92%

layout's Introduction

Layout

A simple/fast stacking box layout library. It's useful for calculating layouts for things like 2D user interfaces. It compiles as C99 or C++. It's tested with gcc (mingw64), VS2015, and clang/LLVM. There are only two important files, layout.h and layout.c.

Layout has no external dependencies, but does use stdlib.h and string.h for realloc and memset. If your own project does not or cannot use these, you can easily exchange them for something else. Only a few lines will need to be edited.

Layout comes with a small set of tests as a build target, along with a primitive benchmark and example usage of the library as a Lua .dll module. However, if you want to use Layout in your own project, you can probably copy layout.h and layout.c into your project's source tree and use your own build system. You don't have to separately build Layout as a shared library and link against it.

Building the tests, benchmarks and Lua module are handled by GENie, but no executable binaries for GENie are included in this source repository. Download links for binary builds of GENie are listed below. You will need to download (or build yourself) a GENie executable and place it in your path or at the root of this repository tree. If you want to build on a platform other than Windows, you'll likely need to modify genie.lua for compatibility. Feel free to open issues or pull requests.

Layout is based on the nice library oui by duangle. Unlike oui, Layout does not handle anything related to user input, focus, or UI state.

Building

If you just want to use Layout in your own project, you can simply copy layout.h and layout.c directly into your project. Take a look at genie.lua for some recommended compiler and linker options.

If you want to build Layout's tests, benchmarks, or example Lua module, you will first need to get (or make) a GENie binary and place it in your path or at the root of this repository.

Download GENie

Linux:
https://github.com/bkaradzic/bx/raw/master/tools/bin/linux/genie

OSX:
https://github.com/bkaradzic/bx/raw/master/tools/bin/darwin/genie

Windows:
https://github.com/bkaradzic/bx/raw/master/tools/bin/windows/genie.exe

Visual Studio 2015

genie.exe vs2015
start build/vs2015/layout.sln

GCC/MinGW/Clang

./genie gmake

and then run your make in the directory build/gmake. You will need to specify a target and config. Here is an example for building the tests target in Windows with the 64-bit release configuration using mingw64 in a bash-like shell (for example, git bash):

./genie.exe gmake && mingw32-make.exe -C build/gmake tests config=release64

Options

You can choose to build Layout to use either integer (int16) or floating point (float) coordinates. Integer is the default, because UI and other 2D layouts do not often use units smaller than a single point when aligning and positioning elements. You can choose to use floating point instead of integer by defining LAY_FLOAT. If you are building the tests, benchmarks, or Lua module for Layout, you can configure this when you invoke GENie:

./genie gmake --coords=float

or if you want to specify integer (the default):

./genie gmake --coords=integer

If you are building Layout to use floating point coordinates, and if you want to enforce SSE alignment for the vector coordinate types, you'll probably want to add or tweak alignment specifiers for some types (or typedef them to m128) in layout.h. The code is simple and should be easy to modify for your purposes. If you do this, and if you also change the code to use your own custom allocator, you might also need to guarantee that the starting addresses of the buffers given to Layout by your allocator are 16-byte aligned. If you do all of that, and if you build Layout as a shared library or a static library without linker optimizations enabled in MSVC, you might want to also consider using __vectorcall, which may help reduce overhead when calling functions which receive or return SSE values.

layout's People

Contributors

cancel avatar

Watchers

Tony Narlock avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.