MCPcopy Create free account
hub / github.com/lxn/walk / CreateLayoutItem

Method CreateLayoutItem

gridlayout.go:260–313  ·  view source on GitHub ↗
(ctx *LayoutContext)

Source from the content-addressed store, hash-verified

258}
259
260func (l *GridLayout) CreateLayoutItem(ctx *LayoutContext) ContainerLayoutItem {
261 wb2Item := make(map[*WidgetBase]LayoutItem)
262
263 var children []LayoutItem
264
265 cells := make([][]gridLayoutItemCell, len(l.cells))
266 for row, srcCols := range l.cells {
267 dstCols := make([]gridLayoutItemCell, len(srcCols))
268 cells[row] = dstCols
269
270 for col, srcCell := range srcCols {
271 dstCell := &dstCols[col]
272
273 dstCell.row = row
274 dstCell.column = col
275 if srcCell.widgetBase != nil {
276 item, ok := wb2Item[srcCell.widgetBase]
277 if !ok {
278 item = createLayoutItemForWidgetWithContext(srcCell.widgetBase.window.(Widget), ctx)
279 children = append(children, item)
280 wb2Item[srcCell.widgetBase] = item
281
282 }
283 dstCell.item = item
284 }
285 }
286 }
287
288 item2Info := make(map[LayoutItem]*gridLayoutItemInfo, len(l.widgetBase2Info))
289 for wb, info := range l.widgetBase2Info {
290 item := wb2Item[wb]
291 var cell *gridLayoutItemCell
292 if info.cell != nil {
293 cell = &cells[info.cell.row][info.cell.column]
294 }
295 item2Info[item] = &gridLayoutItemInfo{
296 cell: cell,
297 spanHorz: info.spanHorz,
298 spanVert: info.spanVert,
299 minSize: info.minSize,
300 }
301 }
302
303 return &gridLayoutItem{
304 ContainerLayoutItemBase: ContainerLayoutItemBase{
305 children: children,
306 },
307 size2MinSize: make(map[Size]Size),
308 rowStretchFactors: append([]int(nil), l.rowStretchFactors...),
309 columnStretchFactors: append([]int(nil), l.columnStretchFactors...),
310 item2Info: item2Info,
311 cells: cells,
312 }
313}
314
315type gridLayoutItem struct {
316 ContainerLayoutItemBase

Callers

nothing calls this directly

Tested by

no test coverage detected