atomize-element-interface #2

Merged
sashakoshka merged 20 commits from atomize-element-interface into main 2023-01-16 10:24:23 -07:00
3 changed files with 27 additions and 20 deletions
Showing only changes of commit 95b6607e4e - Show all commits

View File

@ -4,6 +4,11 @@ import "image"
import "git.tebibyte.media/sashakoshka/tomo" import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/theme" import "git.tebibyte.media/sashakoshka/tomo/theme"
// Dialog arranges elements in the form of a dialog box. The first element is
// positioned above as the main focus of the dialog, and is set to expand
// regardless of whether it is expanding or not. The remaining elements are
// arranged at the bottom in a row called the control row, which is aligned to
// the right, the last element being the rightmost one.
type Dialog struct { type Dialog struct {
// If Gap is true, a gap will be placed between each element. // If Gap is true, a gap will be placed between each element.
Gap bool Gap bool
@ -39,10 +44,7 @@ func (layout Dialog) Arrange (entries []tomo.LayoutEntry, width, height int) {
mainBounds := entries[0].Bounds() mainBounds := entries[0].Bounds()
if mainBounds.Dy() != mainHeight || if mainBounds.Dy() != mainHeight ||
mainBounds.Dx() != width { mainBounds.Dx() != width {
entries[0].Handle (tomo.EventResize { entries[0].Resize(width, mainHeight)
Width: width,
Height: mainHeight,
})
} }
} }
@ -94,10 +96,7 @@ func (layout Dialog) Arrange (entries []tomo.LayoutEntry, width, height int) {
entryBounds := entry.Bounds() entryBounds := entry.Bounds()
if entryBounds.Dy() != controlRowHeight || if entryBounds.Dy() != controlRowHeight ||
entryBounds.Dx() != entryWidth { entryBounds.Dx() != entryWidth {
entry.Handle (tomo.EventResize { entry.Resize(entryWidth, controlRowHeight)
Width: entryWidth,
Height: controlRowHeight,
})
} }
} }
} }