Drag[en]gine Script Module DragonScript  1.21
Dragengine.Gui.Layouts.WeightLayout Class Reference

Arrange widgets along X or Y axis with weighted size. More...

Inheritance diagram for Dragengine.Gui.Layouts.WeightLayout:
Dragengine.Gui.Layout

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...
 

Detailed Description

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.

Member Function Documentation

◆ addWidget()

void Dragengine.Gui.Layouts.WeightLayout.addWidget ( Widget  widget,
Object  settings 
)

Add widget to layout using settings.

Parameters
widgetWidget to add to layout.
settingsInstance of LayoutSettings. If null a weight of 1 is used.

Implements Dragengine.Gui.Layout.

◆ doLayout()

void Dragengine.Gui.Layouts.WeightLayout.doLayout ( Container  container)

Layout widgets in container.

Implements Dragengine.Gui.Layout.

◆ getAxis()

LayoutAxis Dragengine.Gui.Layouts.WeightLayout.getAxis ( )

Axis to arrange widgets along.

◆ getGap()

int Dragengine.Gui.Layouts.WeightLayout.getGap ( )

Gap between child widgets.

◆ getMinimumSize()

Point Dragengine.Gui.Layouts.WeightLayout.getMinimumSize ( Container  container)

Minimal size required for layout in container.

Implements Dragengine.Gui.Layout.

◆ getMinimumSizeFor()

Point Dragengine.Gui.Layouts.WeightLayout.getMinimumSizeFor ( Container  container,
int  width,
int  height 
)
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.

◆ getMinimumSizeForHeight()

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.

◆ getMinimumSizeForWidth()

Point Dragengine.Gui.Layouts.WeightLayout.getMinimumSizeForWidth ( Container  container,
int  width 
)

Minimum size of layout using reference width and variable height.

Implements Dragengine.Gui.Layout.

◆ getWeightSum()

int Dragengine.Gui.Layouts.WeightLayout.getWeightSum ( )
protected

Weight sum.

Recalculates weight sum if required.

◆ getWidgetSettings()

LayoutSettings Dragengine.Gui.Layouts.WeightLayout.getWidgetSettings ( Widget  widget)

Layout settings for widget.

◆ new() [1/2]

WeightLayout Dragengine.Gui.Layouts.WeightLayout.new ( LayoutAxis  axis)

Create layout with 0 gap.

◆ new() [2/2]

WeightLayout Dragengine.Gui.Layouts.WeightLayout.new ( LayoutAxis  axis,
int  gap 
)

Create layout.

Parameters
gapSize of gap between child widgets. Can be negative to overlap widgets.

◆ removeWidget()

void Dragengine.Gui.Layouts.WeightLayout.removeWidget ( Widget  widget)

Remove widget from layout.

Implements Dragengine.Gui.Layout.

◆ setAxis()

void Dragengine.Gui.Layouts.WeightLayout.setAxis ( LayoutAxis  axis)

Set axis to arrange along.

◆ setGap()

void Dragengine.Gui.Layouts.WeightLayout.setGap ( int  gap)

Set gap between child widgets.

Can be negative to overlap widgets.

◆ setWidgetSettings()

void Dragengine.Gui.Layouts.WeightLayout.setWidgetSettings ( Widget  widget,
LayoutSettings  settings 
)

Set layout settings for widget.

Layouts the parent of widget after changing the settings.

Parameters
widgetWidget to set settings for.
settingsInstance of LayoutSettings.

The documentation for this class was generated from the following file: