Update object code to use new containers

This commit is contained in:
Sasha Koshka 2024-09-12 14:54:26 -04:00
parent f1f71208f2
commit 51ce2a84f2
4 changed files with 15 additions and 20 deletions

View File

@ -60,7 +60,7 @@ func NewCalendar (tm time.Time) *Calendar {
calendar.grid.SetRole(tomo.R("objects", "CalendarGrid"))
calendar.grid.SetAttr(tomo.ALayout(layouts.NewGrid (
true, true, true, true, true, true, true)()))
calendar.box.Add(NewInnerContainer (
calendar.box.Add(NewContainer (
layouts.Row { false, true, false },
prevButton, calendar.monthLabel, nextButton))
calendar.box.Add(calendar.grid)

View File

@ -16,7 +16,6 @@ type DialogKind int; const (
// Dialog is a modal dialog window.
type Dialog struct {
tomo.Window
controlRow *Container
}
type clickable interface {
@ -65,13 +64,11 @@ func NewDialog (kind DialogKind, parent tomo.Window, title, message string, opti
})
}
}
dialog.controlRow = NewInnerContainer(layouts.ContractHorizontal, options...)
dialog.controlRow.SetAlign(tomo.AlignEnd, tomo.AlignEnd)
dialog.SetRoot(NewOuterContainer (
dialog.SetRoot(NewRoot (
layouts.Column { true, false },
NewInnerContainer(layouts.ContractHorizontal, icon, messageText),
dialog.controlRow))
NewContentSegment(layouts.ContractHorizontal, icon, messageText),
NewOptionSegment(nil, options...)))
return dialog, nil
}

View File

@ -62,7 +62,7 @@ func newMenu (parent tomo.Window, bounds image.Rectangle, items ...tomo.Object)
})
}
}
menu.rootContainer.SetRole(tomo.R("objects", "Container"))
menu.rootContainer.SetRole(tomo.R("objects", "Root"))
menu.rootContainer.SetTag("menu", true)
menu.Window.SetRoot(menu.rootContainer)

View File

@ -139,18 +139,16 @@ func (this *Swatch) Choose () {
})
okButton.OnClick(commit)
controlRow := NewInnerContainer (
layouts.ContractHorizontal,
cancelButton,
okButton)
controlRow.SetAlign(tomo.AlignEnd, tomo.AlignMiddle)
window.SetRoot(NewOuterContainer (
window.SetRoot(NewRoot (
layouts.Column { true, false },
colorPicker,
NewInnerContainer(layouts.Row { false, true },
NewLabel("Hex"),
hexInput),
controlRow))
NewContentSegment (
layouts.Column { true, false },
colorPicker,
NewContainer (
layouts.Row { false, true },
NewLabel("Hex"),
hexInput)),
NewOptionSegment(nil, cancelButton, okButton)))
window.OnClose(func () {
if committed {
this.on.confirm.Broadcast()