Allow dialogues to be hidden or shown
To do this, MENU and SUBMENU are split into two types (at last), and a Widget type is introduced. This should allow lots of code to be removed at some point.
This commit is contained in:
73
internal/ui/widget.go
Normal file
73
internal/ui/widget.go
Normal file
@@ -0,0 +1,73 @@
|
||||
package ui
|
||||
|
||||
type Widget struct {
|
||||
Locator string
|
||||
Children []*Widget
|
||||
|
||||
ownClickables []clickable
|
||||
ownFreezables []freezable
|
||||
ownHoverables []hoverable
|
||||
ownMouseables []mouseable
|
||||
ownPaintables []paintable
|
||||
ownValueables []valueable
|
||||
}
|
||||
|
||||
func (w *Widget) clickables() []clickable {
|
||||
out := w.ownClickables
|
||||
|
||||
for _, widget := range w.Children {
|
||||
out = append(out, widget.clickables()...)
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func (w *Widget) freezables() []freezable {
|
||||
out := w.ownFreezables
|
||||
|
||||
for _, widget := range w.Children {
|
||||
out = append(out, widget.freezables()...)
|
||||
}
|
||||
|
||||
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 {
|
||||
out := w.ownValueables
|
||||
|
||||
for _, widget := range w.Children {
|
||||
out = append(out, widget.valueables()...)
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
Reference in New Issue
Block a user