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