Add mouse support to queue
This commit is contained in:
parent
803053317a
commit
9b2116f579
6 changed files with 44 additions and 17 deletions
|
@ -1,3 +1,6 @@
|
|||
0.1.6:
|
||||
- Add mouse support to queue
|
||||
|
||||
0.1.5:
|
||||
- Add initial volume configuration option and flag
|
||||
- Add queue feature
|
||||
|
|
17
audio.go
17
audio.go
|
@ -187,16 +187,23 @@ func pause() {
|
|||
|
||||
func nextTrack() {
|
||||
if queueCursor < len(queueFiles)-1 {
|
||||
queueCursor++
|
||||
queueNext()
|
||||
|
||||
entry := selectedQueueEntry()
|
||||
audioFile, err := openFile(path.Join(mainBufferDirectory, entry.File.Name()), entry.Metadata)
|
||||
audioFile, err := openFile(entry.Path, entry.Metadata)
|
||||
if err != nil {
|
||||
statusText = err.Error()
|
||||
go func() {
|
||||
time.Sleep(5 * time.Second)
|
||||
statusText = ""
|
||||
go app.QueueUpdateDraw(updateMain)
|
||||
}()
|
||||
go app.QueueUpdateDraw(updateMain)
|
||||
return
|
||||
}
|
||||
|
||||
play(audioFile)
|
||||
go app.QueueUpdateDraw(updateMain)
|
||||
go app.QueueUpdateDraw(updateQueue)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,7 +235,7 @@ func supportedFormat(filePath string) bool {
|
|||
return true
|
||||
case ".mp3":
|
||||
return true
|
||||
case ".ogg", ".weba", ".webm":
|
||||
case ".ogg", ".weba":
|
||||
return true
|
||||
case ".flac":
|
||||
return true
|
||||
|
@ -243,7 +250,7 @@ func fileFormat(fileName string) string {
|
|||
return "WAV"
|
||||
case ".mp3":
|
||||
return "MP3"
|
||||
case ".ogg", ".weba", ".webm":
|
||||
case ".ogg", ".weba":
|
||||
return "OGG"
|
||||
case ".flac":
|
||||
return "FLAC"
|
||||
|
|
9
gui.go
9
gui.go
|
@ -299,11 +299,8 @@ func updateQueue() {
|
|||
|
||||
writeListItemPrefix(&queueBuffer, queueFocused, queueCursor, i)
|
||||
|
||||
if entry.File.IsDir() {
|
||||
line = entry.File.Name() + "/"
|
||||
} else {
|
||||
line = entry.String()
|
||||
}
|
||||
line = entry.String()
|
||||
|
||||
queueBuffer.WriteString(line)
|
||||
|
||||
if !queueFocused {
|
||||
|
@ -429,7 +426,7 @@ func updateStatus() {
|
|||
|
||||
statusBuffer.Reset()
|
||||
|
||||
trackInfo := fmt.Sprintf("ditty %s", version)
|
||||
trackInfo := fmt.Sprintf("ditty v%s", version)
|
||||
|
||||
topStatusMaxLength := screenWidth - 2
|
||||
padding := (topStatusMaxLength - runewidth.StringWidth(trackInfo)) + 1
|
||||
|
|
|
@ -84,11 +84,11 @@ func listSelect() {
|
|||
|
||||
entry := selectedMainEntry()
|
||||
if entry.File.IsDir() {
|
||||
browseFolder(path.Join(mainBufferDirectory, path.Base(entry.File.Name())))
|
||||
browseFolder(entry.Path)
|
||||
return
|
||||
}
|
||||
|
||||
audioFile, err := openFile(path.Join(mainBufferDirectory, entry.File.Name()), entry.Metadata)
|
||||
audioFile, err := openFile(entry.Path, entry.Metadata)
|
||||
if err != nil {
|
||||
statusText = err.Error()
|
||||
go func() {
|
||||
|
|
26
gui_mouse.go
26
gui_mouse.go
|
@ -13,14 +13,34 @@ import (
|
|||
func handleMouse(event *cview.EventMouse) *cview.EventMouse {
|
||||
if event.Action()&cview.MouseDown != 0 && event.Buttons()&tcell.Button1 != 0 {
|
||||
mouseX, mouseY := event.Position()
|
||||
if mouseY > 0 && mouseY < mainBufHeight+1 {
|
||||
if mouseY >= 0 && mouseY < mainBufHeight {
|
||||
if queueFocused {
|
||||
queueFocused = false
|
||||
go app.QueueUpdateDraw(updateLists)
|
||||
}
|
||||
|
||||
// TODO Delay playing while cursor is moved
|
||||
if mouseY-1 < len(mainBufferFiles)+1 {
|
||||
if mouseY > 0 && mouseY < mainBufHeight-1 && mouseY-1 < len(mainBufferFiles)+1 {
|
||||
mainBufferCursor = mainBufferOrigin + (mouseY - 1)
|
||||
go app.QueueUpdateDraw(updateMain)
|
||||
go app.QueueUpdateDraw(updateLists)
|
||||
go listSelect()
|
||||
}
|
||||
return nil
|
||||
} else if mouseY >= mainBufHeight && mouseY < screenHeight-2 {
|
||||
if !queueFocused {
|
||||
queueFocused = true
|
||||
go app.QueueUpdateDraw(updateLists)
|
||||
}
|
||||
|
||||
if mouseY > mainBufHeight && mouseY < screenHeight-3 {
|
||||
mouseHit := (mouseY - mainBufHeight) - 1
|
||||
if mouseHit < len(queueFiles) {
|
||||
queueCursor = queueOrigin + mouseHit
|
||||
go app.QueueUpdateDraw(updateLists)
|
||||
go queueSelect()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
} else if mouseY == screenHeight-1 {
|
||||
if mouseX >= seekStart && mouseX <= seekEnd {
|
||||
if strings.ToLower(path.Ext(playingFileName)) == ".flac" {
|
||||
|
|
|
@ -107,7 +107,7 @@ func scanFolderRecursively(path string) []*libraryEntry {
|
|||
continue
|
||||
}
|
||||
|
||||
entries = append(entries, scanFolder(entry.Path)...)
|
||||
entries = append(entries, scanFolderRecursively(entry.Path)...)
|
||||
}
|
||||
for _, entry := range scanFiles {
|
||||
if entry.File.IsDir() {
|
||||
|
|
Loading…
Reference in a new issue