wResizable is the superclass of wWindow to handle layout DSL. It is based on yglukhov's constraint solving library - kiwi.
wNim's layout DSL looking like this:
panel.layout: button1: top = panel.top left = panel.left button2: centerX = panel.centerX centerY = panel.centerY height = panel.height / 2 width = panel.width / 2
Following identifiers can be used in the layout DSL as attributes:
Identifiers | Description |
---|---|
left | Left margin. |
right | Right margin. |
top | Top margin. |
bottom | Bottom margin. |
width | Width of object. |
height | Height of object. |
up | Alias for top. |
down | Alias for bottom. |
centerX | Center of X-axis. |
centerY | Center of Y-axis. |
defaultWidth | Default width of object. |
defaultHeight | Default height of object. |
bestWidth | Best width of object. |
bestHeight | Best height of object. |
innerLeft | Left margin of sibling's client area. |
innerTop | Top margin of sibling's client area. |
innerRight | Right margin of sibling's client area. |
innerBottom | Bottom margin of sibling's client area. |
innerUp | Alias for innerTop. |
innerDown | Alias for innerBottom. |
innerWidth | Width of sibling's client area. |
innerHeight | Height of sibling's client area. |
wNim also support Visual Format Language. For example:
panel.autolayout """ V:|-{col1:[child1(child2)]-[child2]}-| V:|-{col2:[child3(child4,child5)]-[child4]-[child5]}-| H:|-[col1(col2)]-[col2]-| """
See autolayout module for details.
Subclass: | wWindow |
---|
Seealso: | wResizer autolayout |
---|
Procs
proc getLayoutSize(self: wResizable): wSize {...}{.raises: [], tags: [].}
- Returns the current layout size.
proc getLayoutRect(self: wResizable): wRect {...}{.raises: [], tags: [].}
- Returns the current layout rect.
proc setLayoutSize(self: wResizable; size: wSize) {...}{.raises: [], tags: [].}
- Sets the layout size.
proc setLayoutRect(self: wResizable; rect: wRect) {...}{.raises: [], tags: [].}
- Sets the layout rect.
proc init(self: wResizable) {...}{.raises: [], tags: [].}
- Initializer.
proc Resizable(): wResizable {...}{.inline, discardable, raises: [], tags: [].}
- Constructor.
Macros
macro autolayout(parent: wResizable; input: static[string]): untyped
- Parses the layout VFL (Visual Format Language), and then use layout function to deal with the result.
macro autorelayout(parent: wResizable; input: static[string]): untyped
- Parses the layout VFL (Visual Format Language), and then use relayout function to deal with the result.
macro autoplan(parent: wResizable; input: static[string]): untyped
- Parses the layout VFL (Visual Format Language), and then use plan function to deal with the result.
macro autoreplan(parent: wResizable; input: static[string]): untyped
- Parses the layout VFL (Visual Format Language), and then use replan function to deal with the result.
macro layoutDebug(parent: wResizable; x: untyped): untyped
- Parses the layout DSL and returns the constraints in string literal for debugging.
macro layoutDump(parent: wResizable; x: untyped): untyped
- Parses the layout DSL and displays the constraints at compile time for debugging.
macro autolayoutDebug(parent: wResizable; input: static[string]): untyped
- Parses the VFL (Visual Format Language) and returns the result in string literal for debugging.
macro autolayoutDump(parent: wResizable; input: static[string]): untyped
- Parses the VFL (Visual Format Language) and displays the result at compile time for debugging.
Templates
template layout(parent: wResizable; x: untyped)
- Parses the layout DSL and rearrange the objects. This function only evaluate the DSL and creates the constraints once.
template relayout(parent: wResizable; x: untyped)
- Parses the layout DSL and rearrange the objects. This function evaluate the DSL and creates the constraints every time. If the value in the constraints is not constant (For example, if there is object.bestWidth in DSL and the label of the object will change every time), use this function instead of layout.
template plan(parent: wResizable; x: untyped): untyped
- Similar to layout, but return the wResizer object. Calls wResizer.resolve() and then wResizer.rearrange() to change the layout in reality later. This function provides a chance to modify the resolved values.
template replan(parent: wResizable; x: untyped): untyped
- Similar to relayout, but return the wResizer object. Calls wResizer.resolve() and then wResizer.rearrange() to change the layout in reality later. This function provides a chance to modify the resolved values.