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.
This commit is contained in:
21
ui/focus.go
Normal file
21
ui/focus.go
Normal file
@@ -0,0 +1,21 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user