More work for MainGame.mnu

This commit is contained in:
2020-04-19 18:21:08 +01:00
parent f8828c95bd
commit 9be93b6091
12 changed files with 248 additions and 76 deletions

View File

@@ -3,6 +3,7 @@ package ui
type Widget struct {
Locator string
Children []*Widget
Active bool
ownClickables []clickable
ownFreezables []freezable
@@ -12,62 +13,130 @@ type Widget struct {
ownValueables []valueable
}
func (w *Widget) clickables() []clickable {
func (w *Widget) allClickables() []clickable {
out := w.ownClickables
for _, widget := range w.Children {
out = append(out, widget.clickables()...)
out = append(out, widget.allClickables()...)
}
return out
}
func (w *Widget) freezables() []freezable {
func (w *Widget) allFreezables() []freezable {
out := w.ownFreezables
for _, widget := range w.Children {
out = append(out, widget.freezables()...)
out = append(out, widget.allFreezables()...)
}
return out
}
func (w *Widget) hoverables() []hoverable {
out := w.ownHoverables
for _, widget := range w.Children {
out = append(out, widget.hoverables()...)
}
return out
}
func (w *Widget) mouseables() []mouseable {
out := w.ownMouseables
for _, widget := range w.Children {
out = append(out, widget.mouseables()...)
}
return out
}
func (w *Widget) paintables() []paintable {
out := w.ownPaintables
for _, widget := range w.Children {
out = append(out, widget.paintables()...)
}
return out
}
func (w *Widget) valueables() []valueable {
func (w *Widget) allValueables() []valueable {
out := w.ownValueables
for _, widget := range w.Children {
out = append(out, widget.valueables()...)
out = append(out, widget.allValueables()...)
}
return out
}
func (w *Widget) activeClickables() []clickable {
if !w.Active {
return nil
}
out := w.ownClickables
for _, widget := range w.Children {
out = append(out, widget.activeClickables()...)
}
return out
}
func (w *Widget) activeFreezables() []freezable {
if !w.Active {
return nil
}
out := w.ownFreezables
for _, widget := range w.Children {
out = append(out, widget.activeFreezables()...)
}
return out
}
func (w *Widget) activeHoverables() []hoverable {
if !w.Active {
return nil
}
out := w.ownHoverables
for _, widget := range w.Children {
out = append(out, widget.activeHoverables()...)
}
return out
}
func (w *Widget) activeMouseables() []mouseable {
if !w.Active {
return nil
}
out := w.ownMouseables
for _, widget := range w.Children {
out = append(out, widget.activeMouseables()...)
}
return out
}
func (w *Widget) activePaintables() []paintable {
if !w.Active {
return nil
}
out := w.ownPaintables
for _, widget := range w.Children {
out = append(out, widget.activePaintables()...)
}
return out
}
func (w *Widget) activeValueables() []valueable {
if !w.Active {
return nil
}
out := w.ownValueables
for _, widget := range w.Children {
out = append(out, widget.activeValueables()...)
}
return out
}
func (w *Widget) findWidget(locator string) *Widget {
if w.Locator == locator {
return w
}
for _, child := range w.Children {
if found := child.findWidget(locator); found != nil {
return found
}
}
return nil
}