MCPcopy Index your code
hub / github.com/g3n/engine / BuildLayout

Method BuildLayout

gui/builder_layout.go:115–151  ·  view source on GitHub ↗

BuildLayout builds and returns a GridLayout with the specified attributes

(b *Builder, am map[string]interface{})

Source from the content-addressed store, hash-verified

113
114// BuildLayout builds and returns a GridLayout with the specified attributes
115func (bl *BuilderLayoutGrid) BuildLayout(b *Builder, am map[string]interface{}) (ILayout, error) {
116
117 // Get number of columns
118 v := am[AttribCols]
119 if v == nil {
120 return nil, b.err(am, AttribCols, "Number of columns must be supplied")
121 }
122 cols := v.(int)
123 if cols <= 0 {
124 return nil, b.err(am, AttribCols, "Invalid number of columns")
125 }
126
127 // Creates layout
128 l := NewGridLayout(cols)
129
130 // Sets optional horizontal alignment
131 if ah := am[AttribAlignh]; ah != nil {
132 l.SetAlignH(ah.(Align))
133 }
134
135 // Sets optional vertical alignment
136 if av := am[AttribAlignv]; av != nil {
137 l.SetAlignV(av.(Align))
138 }
139
140 // Sets optional horizontal expand flag
141 if eh := am[AttribExpandh]; eh != nil {
142 l.SetExpandH(eh.(bool))
143 }
144
145 // Sets optional vertical expand flag
146 if ev := am[AttribExpandv]; ev != nil {
147 l.SetExpandV(ev.(bool))
148 }
149
150 return l, nil
151}
152
153// BuildParams builds and returns a pointer to GridLayoutParams with the specified attributes
154func (bl *BuilderLayoutGrid) BuildParams(b *Builder, am map[string]interface{}) (interface{}, error) {

Callers

nothing calls this directly

Calls 6

SetAlignHMethod · 0.95
SetAlignVMethod · 0.95
SetExpandHMethod · 0.95
SetExpandVMethod · 0.95
NewGridLayoutFunction · 0.85
errMethod · 0.80

Tested by

no test coverage detected