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:
30
internal/ui/dialogues.go
Normal file
30
internal/ui/dialogues.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func (d *Driver) Dialogues() []string {
|
||||
out := make([]string, len(d.dialogues))
|
||||
|
||||
for i, dialogue := range d.dialogues {
|
||||
out[i] = dialogue.Locator
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func (d *Driver) ShowDialogue(locator string) error {
|
||||
for _, dialogue := range d.dialogues {
|
||||
if dialogue.Locator == locator {
|
||||
d.activeDialogue = dialogue
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("Couldn't find dialogue %v", locator)
|
||||
}
|
||||
|
||||
func (d *Driver) HideDialogue() {
|
||||
d.activeDialogue = nil
|
||||
}
|
Reference in New Issue
Block a user