Macro guion::constraint[][src]

macro_rules! constraint {
    (# $min:literal ~ $pref:literal - $max:tt @ $p:literal | $($m:tt)*) => { ... };
    (# $min:literal ~ $pref:literal - None @ $p:literal) => { ... };
    (# $min:literal ~ $pref:literal - $max:literal @ $p:literal) => { ... };
    (# $min:literal ~ $pref:literal - $max:tt $($m:tt)*) => { ... };
    ($min:literal ~ $pref:literal - $max:literal $($m:tt)*) => { ... };
    ($min:literal ~ $pref:literal - $($m:tt)*) => { ... };
    ($min:literal ~ $pref:literal $($m:tt)*) => { ... };
    (~ $pref:literal $($m:tt)*) => { ... };
    ($pref:literal $($m:tt)*) => { ... };
}

Defines constraints for one or both axis

preferred is the preferred/optimal size
min is the minimum size if e.g. bounds have to be shrinked below preferred
max is the maximum size if e.g. bounds are extended

Syntax:

constrant!( AXIS w [| AXIS y] )
AXIS [[min]~]preferred[-[max]]

[]: optional argument
preferred: the preferred size
~: if given, the minimum size can be smaller than preferred (default: 0)
min: additional to ~, limis the minimum size to the specific min
-: if given, the maximum size can be bigger than preferred (default: infinity)
max: additional to -, limis the maximum size to the specific max

Example:

5: fixed size 5
~5: preferred 5, can be smaller (shrinked)
2~5: preferred 5, can bes smaller, but not smaller than 2
5-: preferred 5, can be bigger (extended)
5-8: preferred 5, can be bigger, but not bigger than 8