-
Notifications
You must be signed in to change notification settings - Fork 8
The Helpful Macros
This simplifies the way to create a constraint for a layout!
A simple constraint looks like this:
constraint!(%20) // A Constraint that takes up 20 percent% A percentage of the screen
# An exact length
> A minimum value
< A maximum value
num ; num A ratio
This is a macro that will simplify the creation of your chunks!
Example:
layout![
frame.size()
(#3),
(%100) => { #3, %50, %50 },
(#3)
]Ok, ok, this could be confusing.
First, we must always provide a Rect that will be the size that we are splitting up.
Then, within the () we can define a constraint! You don't need to call the constraint! macro, but you will type it the same as it would look within that macro.
Next, we can either define the horizontal parts of the layout, using a =>, followed by your constraints within {}s
Now that you mostly understand, I'll provide a few more examples before describing the end.
layout![
frame.size()
(#3),
(%100) => { #3, %50, %50 },
(#3)
]layout![
frame.size()
(<50),
(%100) => { #3, %50, %50 },
(>3) => { #3, <5, >50 }
]layout![
frame.size()
(22 ; 50) => { %15, #3, %25, %50 },
]Warning, no promises any of these layouts will look good.