endlessm/emeus

Name: emeus

Owner: endlessm

Description: Constraint-based layout manager for GTK+

Forked from: ebassi/emeus

Created: 2016-11-22 20:41:56.0

Updated: 2016-11-22 20:42:21.0

Pushed: 2018-05-15 05:21:12.0

Homepage: https://ebassi.github.io/emeus

Size: 439

Language: C

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Emeus - Constraint-based layout manager for GTK+
What is Emeus?

Emeus is a constraint-based layout manager widget for GTK+, written using the Cassowary constraint solving algorithm.

What's the difference between Emeus and GTK+'s layout managers?

GTK+ has two different sorts of layout managers:

The first model works really well in ensuring that UIs are responsive to size changes, by avoiding pixel-perfect positioning on the screen, as well as ensuring that changing the font size or margins and paddings do not break the user interface; its main down side is that it requires accurate, and often verbose packing of widgets inside boxes, inside other boxes.

The second model allows a more efficient way to construct a user interface, at the major costs of either “freezing” it, or requiring constant recalculations of the relative position and size of each UI element.

Emeus provides a third layout management policy, based on constraints; each UI element binds one of more of its attributes ? like its width, or its position ? to other UI elements, in a way that is more natural to describe from a UI building perspective, and hopefully more efficient that stacking piles of boxes one inside another.

Constraints

EmeusLayoutConstraint is a GtkContainer that can support multiple children; each child, in turn, is associated to one or more EmeusConstraint instances. Each constraint is the expression of a simple linear equation:

item1.attr1 = item2.attr2 × multiplier + constant

Where:

Using both notations, then, we can construct user interfaces like:

+-------------------------------------------+
|   [ button 1 ] [ button 2 ] [ button 3]   |
+-------------------------------------------+

By expressing the constraints between the UI elements. For instance, we can center button2 within its parent and give it a minimum width of 250 logical pixels:

button2.width >= 250
button2.centerX = parent.centerX
button2.centerY = parent.centerY

Then, we can tie button1 and button3 to button2, and ensure that the width and height of all three buttons are the same:

button1.end = button2.start - 8
button1.width = button2.width
button1.height = button2.height

button3.start = button2.end + 8
button3.width = button2.width
button3.height = button2.height

The EmeusConstraintLayout widget will attempt to resolve all the constraints, and lay out its children according to them.

Building
Documentation

The API reference for Emeus is available online.

Licensing

Emeus is released under the terms of the GNU Lesser General Public License, either version 2.1 or, at your option, any later version.

The Cassowary simplex solving algorithm implementation is largely inspired by the equivalent implementations written in various other language, including:

Additionally, the automatic layout solving is inspired by autolayout.js, a JavaScript automatic constraint-based layout, which, in turn, is based on the Apple autolayout layout manager.

You can check on the Overconstrained website for additional Cassowary implementations in various languages.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.