Drag[en]gine Script Module DragonScript 1.32.1
Loading...
Searching...
No Matches
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.Layouts.BoxLayout 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.
 
void doLayout (Container container)
 Layout widgets in container.
 
LayoutSettings getWidgetSettings (Widget widget)
 Layout settings for widget.
 
WeightLayout new (LayoutAxis axis)
 Create layout with 0 gap.
 
WeightLayout new (LayoutAxis axis, int gap)
 Create layout.
 
void removeWidget (Widget widget)
 Remove widget from layout.
 
void setWidgetSettings (Widget widget, LayoutSettings settings)
 Set layout settings for widget.
 
- Public Member Functions inherited from Dragengine.Gui.Layouts.BoxLayout
LayoutAxis getAxis ()
 Axis to arrange widgets along.
 
int getGap ()
 Gap between child widgets.
 
Point getMinimumSize (Container container)
 Minimal size required for layout in container.
 
Point getMinimumSizeForHeight (Container container, int height)
 Minimum size of layout using reference widget height and variable width.
 
Point getMinimumSizeForWidth (Container container, int width)
 Minimum size of layout using reference width and variable height.
 
void setAxis (LayoutAxis axis)
 Set axis to arrange along.
 
void setGap (int gap)
 Set gap between child widgets.
 

Public Attributes

int pWeightSum
 Weight sum or -1 if not calculated yet.
 
Dictionary pWidgetSettings
 Widget layout settings as Dictionary with Widget keys and LayoutSettings values.
 

Protected Member Functions

Point getMinimumSizeFor (Container container, int width, int height)
 Minimum size of layout using reference and variable size.
 
int getWeightSum ()
 Weight sum.
 

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.

Reimplemented from Dragengine.Gui.Layouts.BoxLayout.

◆ doLayout()

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

Layout widgets in container.

Reimplemented from Dragengine.Gui.Layouts.BoxLayout.

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

Reimplemented from Dragengine.Gui.Layouts.BoxLayout.

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

Reimplemented from Dragengine.Gui.Layouts.BoxLayout.

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

Reimplemented from Dragengine.Gui.Layouts.BoxLayout.

◆ removeWidget()

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

Remove widget from layout.

Reimplemented from Dragengine.Gui.Layouts.BoxLayout.

◆ 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.
settingsWidget settings. If null a weight of 1 is used.

Member Data Documentation

◆ pWeightSum

int Dragengine.Gui.Layouts.WeightLayout.pWeightSum

Weight sum or -1 if not calculated yet.

◆ pWidgetSettings

Dictionary Dragengine.Gui.Layouts.WeightLayout.pWidgetSettings

Widget layout settings as Dictionary with Widget keys and LayoutSettings values.


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