Drag[en]gine Script Module DragonScript
1.23
|
Arrange widgets along X or Y axis with weighted size. More...
Classes | |
class | LayoutSettings |
Immutable widget layout settings. More... | |
Public Member Functions | |
void | addWidget (Widget widget, Object settings) |
Add widget to layout using settings. More... | |
void | doLayout (Container container) |
Layout widgets in container. More... | |
LayoutAxis | getAxis () |
Axis to arrange widgets along. More... | |
int | getGap () |
Gap between child widgets. More... | |
Point | getMinimumSize (Container container) |
Minimal size required for layout in container. More... | |
Point | getMinimumSizeForHeight (Container container, int height) |
Minimum size of layout using reference widget height and variable width. More... | |
Point | getMinimumSizeForWidth (Container container, int width) |
Minimum size of layout using reference width and variable height. More... | |
LayoutSettings | getWidgetSettings (Widget widget) |
Layout settings for widget. More... | |
WeightLayout | new (LayoutAxis axis) |
Create layout with 0 gap. More... | |
WeightLayout | new (LayoutAxis axis, int gap) |
Create layout. More... | |
void | removeWidget (Widget widget) |
Remove widget from layout. More... | |
void | setAxis (LayoutAxis axis) |
Set axis to arrange along. More... | |
void | setGap (int gap) |
Set gap between child widgets. More... | |
void | setWidgetSettings (Widget widget, LayoutSettings settings) |
Set layout settings for widget. More... | |
Protected Member Functions | |
Point | getMinimumSizeFor (Container container, int width, int height) |
Minimum size of layout using reference and variable size. More... | |
int | getWeightSum () |
Weight sum. More... | |
Arrange widgets along X or Y axis with weighted size.
Distribute size across widgets based on fixed size and weight factors. The minimum, preferred and maximum size requirements of widgets are disregarded to allow widget sizes to align with fixed external factors. This can be used to enforce relative distribution across different containers no matter what size requirements widgets have.
Use instances of immutable LayoutSettings as layout options when adding widgets. The layout settings can be replaced after adding the widgets. This can be used for example for column based lists to apply changed column sizes to all widgets in affected layouts.
LayoutSettings uses a fixed size and a weight factor. The fixed size replaces the minimum size indicated by the widget measured in pixels. The weight factors are sumemd up across all widgets to obtain the weight sum. The size of each widget is the weight factor divided by the weight sum. The fixed sizes are subtracted from the available space before doing weight calculation.
Instances of this layout can not be shared across multiple widgets.
void Dragengine.Gui.Layouts.WeightLayout.addWidget | ( | Widget | widget, |
Object | settings | ||
) |
Add widget to layout using settings.
widget | Widget to add to layout. |
settings | Instance of LayoutSettings. If null a weight of 1 is used. |
Implements Dragengine.Gui.Layout.
void Dragengine.Gui.Layouts.WeightLayout.doLayout | ( | Container | container | ) |
Layout widgets in container.
Implements Dragengine.Gui.Layout.
LayoutAxis Dragengine.Gui.Layouts.WeightLayout.getAxis | ( | ) |
Axis to arrange widgets along.
int Dragengine.Gui.Layouts.WeightLayout.getGap | ( | ) |
Gap between child widgets.
Minimal size required for layout in container.
Implements Dragengine.Gui.Layout.
|
protected |
Minimum size of layout using reference and variable size.
If LayoutAxis.x or LayoutAxis.inverseX is used height is the reference size. If LayoutAxis.y or LayoutAxis.inverseY is used widthis the reference size.
Point Dragengine.Gui.Layouts.WeightLayout.getMinimumSizeForHeight | ( | Container | container, |
int | height | ||
) |
Minimum size of layout using reference widget height and variable width.
Implements Dragengine.Gui.Layout.
Minimum size of layout using reference width and variable height.
Implements Dragengine.Gui.Layout.
|
protected |
Weight sum.
Recalculates weight sum if required.
LayoutSettings Dragengine.Gui.Layouts.WeightLayout.getWidgetSettings | ( | Widget | widget | ) |
Layout settings for widget.
WeightLayout Dragengine.Gui.Layouts.WeightLayout.new | ( | LayoutAxis | axis | ) |
Create layout with 0 gap.
WeightLayout Dragengine.Gui.Layouts.WeightLayout.new | ( | LayoutAxis | axis, |
int | gap | ||
) |
Create layout.
gap | Size of gap between child widgets. Can be negative to overlap widgets. |
void Dragengine.Gui.Layouts.WeightLayout.removeWidget | ( | Widget | widget | ) |
Remove widget from layout.
Implements Dragengine.Gui.Layout.
void Dragengine.Gui.Layouts.WeightLayout.setAxis | ( | LayoutAxis | axis | ) |
Set axis to arrange along.
void Dragengine.Gui.Layouts.WeightLayout.setGap | ( | int | gap | ) |
Set gap between child widgets.
Can be negative to overlap widgets.
void Dragengine.Gui.Layouts.WeightLayout.setWidgetSettings | ( | Widget | widget, |
LayoutSettings | settings | ||
) |
Set layout settings for widget.
Layouts the parent of widget after changing the settings.
widget | Widget to set settings for. |
settings | Instance of LayoutSettings. |