Introduce new layouts.Grid construct
This commit is contained in:
parent
ae1e62c1f2
commit
e8a3a376ea
@ -47,8 +47,7 @@ func NewCalendar (tm time.Time) *Calendar {
|
|||||||
calendar.grid = tomo.NewContainerBox()
|
calendar.grid = tomo.NewContainerBox()
|
||||||
calendar.grid.SetRole(tomo.R("objects", "CalendarGrid", ""))
|
calendar.grid.SetRole(tomo.R("objects", "CalendarGrid", ""))
|
||||||
calendar.grid.SetLayout(layouts.NewGrid (
|
calendar.grid.SetLayout(layouts.NewGrid (
|
||||||
[]bool { true, true, true, true, true, true, true },
|
true, true, true, true, true, true, true)())
|
||||||
[]bool { }))
|
|
||||||
calendar.Add(NewInnerContainer (
|
calendar.Add(NewInnerContainer (
|
||||||
layouts.Row { false, true, false },
|
layouts.Row { false, true, false },
|
||||||
prevButton, calendar.monthLabel, nextButton))
|
prevButton, calendar.monthLabel, nextButton))
|
||||||
|
@ -66,7 +66,7 @@ func NewDialog (kind DialogKind, parent tomo.Window, title, message string, opti
|
|||||||
dialog.controlRow.SetAlign(tomo.AlignEnd, tomo.AlignEnd)
|
dialog.controlRow.SetAlign(tomo.AlignEnd, tomo.AlignEnd)
|
||||||
|
|
||||||
dialog.SetRoot(NewOuterContainer (
|
dialog.SetRoot(NewOuterContainer (
|
||||||
layouts.NewGrid([]bool { true }, []bool { true, false }),
|
layouts.Column { true, false },
|
||||||
NewInnerContainer(layouts.ContractHorizontal, icon, messageText),
|
NewInnerContainer(layouts.ContractHorizontal, icon, messageText),
|
||||||
dialog.controlRow))
|
dialog.controlRow))
|
||||||
return dialog, nil
|
return dialog, nil
|
||||||
|
@ -24,7 +24,7 @@ func NewLabelCheckbox (value bool, text string) *LabelCheckbox {
|
|||||||
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
||||||
box.Add(box.checkbox)
|
box.Add(box.checkbox)
|
||||||
box.Add(box.label)
|
box.Add(box.label)
|
||||||
box.SetLayout(layouts.NewGrid([]bool { false, true }, []bool { false }))
|
box.SetLayout(layouts.Row { false, true })
|
||||||
|
|
||||||
box.OnMouseUp(box.handleMouseUp)
|
box.OnMouseUp(box.handleMouseUp)
|
||||||
box.label.OnMouseUp(box.handleMouseUp)
|
box.label.OnMouseUp(box.handleMouseUp)
|
||||||
|
@ -25,7 +25,7 @@ func NewLabelSwatch (value color.Color, text string) *LabelSwatch {
|
|||||||
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
||||||
box.Add(box.swatch)
|
box.Add(box.swatch)
|
||||||
box.Add(box.label)
|
box.Add(box.label)
|
||||||
box.SetLayout(layouts.NewGrid([]bool { false, true }, []bool { false }))
|
box.SetLayout(layouts.Row { false, true })
|
||||||
|
|
||||||
box.OnMouseUp(box.handleMouseUp)
|
box.OnMouseUp(box.handleMouseUp)
|
||||||
box.label.OnMouseUp(box.handleMouseUp)
|
box.label.OnMouseUp(box.handleMouseUp)
|
||||||
|
@ -18,12 +18,18 @@ type Grid struct {
|
|||||||
// will contract. Boxes are laid out left to right, then top to bottom. Boxes
|
// will contract. Boxes are laid out left to right, then top to bottom. Boxes
|
||||||
// that go beyond the lengh of rows will be laid out according to columns, but
|
// that go beyond the lengh of rows will be laid out according to columns, but
|
||||||
// they will not expand vertically.
|
// they will not expand vertically.
|
||||||
func NewGrid (columns, rows []bool) *Grid {
|
//
|
||||||
this := &Grid {
|
// If you aren't sure how to use this constructor, here is an example:
|
||||||
xExpand: columns,
|
//
|
||||||
yExpand: rows,
|
// X0 X1 X2 Y0 Y1 Y2
|
||||||
|
// NewGrid(true, false, true)(false, true, true)
|
||||||
|
func NewGrid (columns ...bool) func (rows ...bool) *Grid {
|
||||||
|
return func (rows ...bool) *Grid {
|
||||||
|
return &Grid {
|
||||||
|
xExpand: columns,
|
||||||
|
yExpand: rows,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Grid) MinimumSize (hints tomo.LayoutHints, boxes []tomo.Box) image.Point {
|
func (this *Grid) MinimumSize (hints tomo.LayoutHints, boxes []tomo.Box) image.Point {
|
||||||
|
@ -27,7 +27,7 @@ func NewMenuItem (text string) *MenuItem {
|
|||||||
}
|
}
|
||||||
box.SetRole(tomo.R("objects", "MenuItem", ""))
|
box.SetRole(tomo.R("objects", "MenuItem", ""))
|
||||||
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
box.label.SetAlign(tomo.AlignStart, tomo.AlignMiddle)
|
||||||
box.SetLayout(layouts.NewGrid([]bool { false, true }, []bool { true }))
|
box.SetLayout(layouts.Row { false, true })
|
||||||
|
|
||||||
box.Add(box.icon)
|
box.Add(box.icon)
|
||||||
box.Add(box.label)
|
box.Add(box.label)
|
||||||
|
@ -32,7 +32,7 @@ func NewNumberInput (value float64) *NumberInput {
|
|||||||
box.Add(box.input)
|
box.Add(box.input)
|
||||||
box.Add(box.decrement)
|
box.Add(box.decrement)
|
||||||
box.Add(box.increment)
|
box.Add(box.increment)
|
||||||
box.SetLayout(layouts.NewGrid([]bool { true, false, false }, []bool { true }))
|
box.SetLayout(layouts.Row { true, false, false })
|
||||||
box.increment.SetIcon(tomo.IconValueIncrement)
|
box.increment.SetIcon(tomo.IconValueIncrement)
|
||||||
box.decrement.SetIcon(tomo.IconValueDecrement)
|
box.decrement.SetIcon(tomo.IconValueDecrement)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user