Skip to content
coding-jackalope edited this page Feb 23, 2019 · 20 revisions

Windows

Creating windows are required to render any controls. Below is an example of creating a simple window with a title bar.

Slab.BeginWindow('MyWindow', {Title = "My First Window"})
Slab.EndWindow()

[TODO]: Add image for above.

Windows take in a unique Id to identify this window from other windows. Windows with a title bar are movable by default while windows without title bars are not.

[TODO]: Add Gif showing window moving.

Windows by default are set to automatically grow as controls are added to the window.

Slab.BeginWindow('MyWindow', {Title = "My First Window"})
Slab.Text("Hello World")
Slab.Text("Foo Bar")
Slab.Text("This is a very long string")
Slab.EndWindow()

[TODO]: Add image of above.

If resizing the window is desired, then the flag 'AutoSizeWindow' must be set to false.

Slab.BeginWindow('MyWindow', {Title = "My First Window", AutoSizeWindow = false})
Slab.Text("Hello World")
Slab.Text("Foo Bar")
Slab.Text("This is a very long string")
Slab.EndWindow()

[TODO]: Add gif of above.

If the contents of a window cannot fit within the bounds of the window, then scroll bars will be rendered to allow the user to scroll within the window.

[TODO]: Add gif of above.

Window behavior can be controlled through a table of options that is passed in as the second parameter. Below is the list of options available and what they do.

Option Type Description
X Number The X position to start rendering the window at.
Y Number The Y position to start rendering the window at.
W Number The starting width of the window.
H Number The starting height of the window.
ContentW Number The starting width of the content contained within this window.
ContentH Number The starting height of the content contained within this window.
BgColor Table The background color value for this window. Will use the default style WindowBackgroundColor if this is empty.
Title String The title to display for this window. If emtpy, no title bar will be rendered and the window will not be movable.
AllowMove Boolean Controls whether the window is movable within the title bar area. The default value is true.
AllowResize Boolean Controls whether the window is resizable. The default value is true. AutoSizeWindow must be false for this to work.
AllowFocus Boolean Controls whether the window can be focused. The default value is true.
Border Number The value which controls how much empty space should be left between all sides of the window from the content. The default value is 4.0
NoOutline Boolean Controls whether an outline should not be rendered. The default value is false.
IsMenuBar Boolean Controls whether if this window is a menu bar or not. This flag should be ignored and is used by the menu bar system. The default value is false.
AutoSizeWindow Boolean Automatically updates the window size to match the content size. The default value is true.
AutoSizeWindowW Boolean Automatically update the window width to match the content size. This value is taken from AutoSizeWindow by default.
AutoSizeWindowH Boolean Automatically update the window height to match the content size. This value is taken from AutoSizeWindow by default.
AutoSizeContent Boolean The content size of the window is automatically updated with each new widget. The default value is true.
Layer String The layer to which to draw this window. This is used internally and should be ignored by the user.
ResetPosition Boolean Determines if the window should reset any delta changes to its position.
ResetSize Boolean Determines if the window should reset any delta changes to its size.
ResetContent Boolean Determines if the window should reset any delta changes to its content size.
ResetLayout Boolean Will reset the position, size, and content. Short hand for the above 3 flags.
Clone this wiki locally