mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 00:48:38 +00:00
uic: support colspan/rowspan in grid layouts
This commit is contained in:
parent
1a4d34185f
commit
b64d48a974
@ -5,8 +5,10 @@ import (
|
||||
)
|
||||
|
||||
type UiLayoutItem struct {
|
||||
Row *int `xml:"row,attr"`
|
||||
Column *int `xml:"column,attr"`
|
||||
Row *int `xml:"row,attr"`
|
||||
Column *int `xml:"column,attr"`
|
||||
RowSpan *int `xml:"rowspan,attr"`
|
||||
ColSpan *int `xml:"colspan,attr"`
|
||||
|
||||
// A layout item either has a widget, or a spacer
|
||||
Widget *UiWidget `xml:"widget"`
|
||||
|
@ -298,12 +298,29 @@ func generateWidget(w UiWidget, parentName string, parentClass string) (string,
|
||||
`)
|
||||
|
||||
case `QGridLayout`:
|
||||
// For QGridLayout it's AddWidget2
|
||||
// FIXME in Miqt this function has optionals, needs to be called with the correct arity
|
||||
// TODO support rowSpan, columnSpan
|
||||
ret.WriteString(`
|
||||
if child.ColSpan != nil || child.RowSpan != nil {
|
||||
// If either are present, use full four-value AddWidget3
|
||||
rowSpan := 1
|
||||
if child.RowSpan != nil {
|
||||
rowSpan = *child.RowSpan
|
||||
}
|
||||
colSpan := 1
|
||||
if child.ColSpan != nil {
|
||||
colSpan = *child.ColSpan
|
||||
}
|
||||
|
||||
ret.WriteString(`
|
||||
ui.` + w.Layout.Name + `.AddWidget3(` + qwidgetName(`ui.`+child.Widget.Name, child.Widget.Class) + `, ` + fmt.Sprintf("%d, %d, %d, %d", *child.Row, *child.Column, rowSpan, colSpan) + `)
|
||||
`)
|
||||
|
||||
} else {
|
||||
// Row and Column are always present in the .ui file
|
||||
// For row/column it's AddWidget2
|
||||
|
||||
ret.WriteString(`
|
||||
ui.` + w.Layout.Name + `.AddWidget2(` + qwidgetName(`ui.`+child.Widget.Name, child.Widget.Class) + `, ` + fmt.Sprintf("%d, %d", *child.Row, *child.Column) + `)
|
||||
`)
|
||||
}
|
||||
|
||||
case "QVBoxLayout", "QHBoxLayout":
|
||||
// For box layout it's AddWidget
|
||||
|
Loading…
Reference in New Issue
Block a user