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.SetRole(tomo.R("objects", "CalendarGrid"))
calendar.grid.SetAttr(tomo.ALayout(layouts.NewGrid ( calendar.grid.SetAttr(tomo.ALayout(layouts.NewGrid (
true, true, true, true, true, true, true)())) true, true, true, true, true, true, true)()))
calendar.box.Add(NewInnerContainer ( calendar.box.Add(NewContainer (
layouts.Row { false, true, false }, layouts.Row { false, true, false },
prevButton, calendar.monthLabel, nextButton)) prevButton, calendar.monthLabel, nextButton))
calendar.box.Add(calendar.grid) calendar.box.Add(calendar.grid)

View File

@ -16,7 +16,6 @@ type DialogKind int; const (
// Dialog is a modal dialog window. // Dialog is a modal dialog window.
type Dialog struct { type Dialog struct {
tomo.Window tomo.Window
controlRow *Container
} }
type clickable interface { 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 }, layouts.Column { true, false },
NewInnerContainer(layouts.ContractHorizontal, icon, messageText), NewContentSegment(layouts.ContractHorizontal, icon, messageText),
dialog.controlRow)) NewOptionSegment(nil, options...)))
return dialog, nil 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.rootContainer.SetTag("menu", true)
menu.Window.SetRoot(menu.rootContainer) menu.Window.SetRoot(menu.rootContainer)

View File

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