gomp/ui/focus.go
aditya-K2 33603e1450 Better Focusing Model
Previously I was using the InsidePlaylist and InsideSearchView boolean
values which was a very hacky and unscalable way. Instead I am using a
focus map which can be queried to check which view has focus. Also the
Pages Implementation is kind of on hold because it has a lot of problems
for e.g resizing doesn't seem to work as I imagined. I am keeping that
Idea on hold right now.
2021-12-22 23:49:16 +05:30

22 lines
353 B
Go

package ui
var FocusMap map[string]bool
func GenerateFocusMap() {
FocusMap = make(map[string]bool)
FocusMap["Playlist"] = true
FocusMap["FileBrowser"] = false
FocusMap["SearchView"] = false
}
func HasFocus(s string) bool {
return FocusMap[s]
}
func SetFocus(s string) {
for k := range FocusMap {
FocusMap[k] = false
}
FocusMap[s] = true
}