moving app.go progressbar.go to the new ui package
This commit is contained in:
parent
a54bfc4948
commit
0d9227e019
7
main.go
7
main.go
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/aditya-K2/gomp/ui"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
CONN *mpd.Client
|
CONN *mpd.Client
|
||||||
UI *Application
|
UI *ui.Application
|
||||||
NOTIFICATION_SERVER *NotificationServer
|
NOTIFICATION_SERVER *NotificationServer
|
||||||
RENDERER *Renderer
|
RENDERER *Renderer
|
||||||
Volume int64
|
Volume int64
|
||||||
@ -39,6 +40,7 @@ func main() {
|
|||||||
defer CONN.Close()
|
defer CONN.Close()
|
||||||
cache.SetCacheDir(viper.GetString("CACHE_DIR"))
|
cache.SetCacheDir(viper.GetString("CACHE_DIR"))
|
||||||
RENDERER = newRenderer()
|
RENDERER = newRenderer()
|
||||||
|
ui.SetRenderer(RENDERER)
|
||||||
c, _ := CONN.CurrentSong()
|
c, _ := CONN.CurrentSong()
|
||||||
if len(c) != 0 {
|
if len(c) != 0 {
|
||||||
RENDERER.Start(c["file"])
|
RENDERER.Start(c["file"])
|
||||||
@ -46,12 +48,13 @@ func main() {
|
|||||||
RENDERER.Start("stop")
|
RENDERER.Start("stop")
|
||||||
}
|
}
|
||||||
|
|
||||||
UI = newApplication()
|
UI = ui.NewApplication()
|
||||||
|
|
||||||
fileMap, err := CONN.GetFiles()
|
fileMap, err := CONN.GetFiles()
|
||||||
dirTree := client.GenerateDirectoryTree(fileMap)
|
dirTree := client.GenerateDirectoryTree(fileMap)
|
||||||
|
|
||||||
client.SetConnection(CONN)
|
client.SetConnection(CONN)
|
||||||
|
ui.SetConnection(CONN)
|
||||||
client.UpdatePlaylist(UI.ExpandedView)
|
client.UpdatePlaylist(UI.ExpandedView)
|
||||||
|
|
||||||
_v, _ := CONN.Status()
|
_v, _ := CONN.Status()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/aditya-K2/gomp/ui"
|
||||||
"image"
|
"image"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ func openImage(path string, c chan string) {
|
|||||||
if path != "stop" {
|
if path != "stop" {
|
||||||
extractedImage := getImagePath(path)
|
extractedImage := getImagePath(path)
|
||||||
img2, _ := GetImg(extractedImage)
|
img2, _ := GetImg(extractedImage)
|
||||||
im, _ = ueberzug.NewImage(img2, int(float32(IMG_X)*fw)+viper.GetInt("ADDITIONAL_PADDING_X"), int(float32(IMG_Y)*fh)+viper.GetInt("ADDITIONAL_PADDING_Y"))
|
im, _ = ueberzug.NewImage(img2, int(float32(ui.IMG_X)*fw)+viper.GetInt("ADDITIONAL_PADDING_X"), int(float32(ui.IMG_Y)*fh)+viper.GetInt("ADDITIONAL_PADDING_Y"))
|
||||||
}
|
}
|
||||||
d := <-c
|
d := <-c
|
||||||
if im != nil {
|
if im != nil {
|
||||||
@ -114,7 +115,7 @@ func GetImg(uri string) (image.Image, error) {
|
|||||||
}
|
}
|
||||||
fw, fh := utils.GetFontWidth()
|
fw, fh := utils.GetFontWidth()
|
||||||
img = resize.Resize(
|
img = resize.Resize(
|
||||||
uint(float32(IMG_W)*(fw+float32(viper.GetFloat64("IMAGE_WIDTH_EXTRA_X")))), uint(float32(IMG_H)*(fh+float32(viper.GetFloat64("IMAGE_WIDTH_EXTRA_Y")))),
|
uint(float32(ui.IMG_W)*(fw+float32(viper.GetFloat64("IMAGE_WIDTH_EXTRA_X")))), uint(float32(ui.IMG_H)*(fh+float32(viper.GetFloat64("IMAGE_WIDTH_EXTRA_Y")))),
|
||||||
img,
|
img,
|
||||||
resize.Bilinear,
|
resize.Bilinear,
|
||||||
)
|
)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package main
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/aditya-K2/tview"
|
"github.com/aditya-K2/tview"
|
||||||
@ -16,7 +16,7 @@ type Application struct {
|
|||||||
Pages *tview.Pages
|
Pages *tview.Pages
|
||||||
}
|
}
|
||||||
|
|
||||||
func newApplication() *Application {
|
func NewApplication() *Application {
|
||||||
|
|
||||||
var pBar *progressBar = newProgressBar()
|
var pBar *progressBar = newProgressBar()
|
||||||
expandedView := tview.NewTable()
|
expandedView := tview.NewTable()
|
||||||
@ -60,7 +60,7 @@ func newApplication() *Application {
|
|||||||
AddItem(searchBar, 3, 1, false).
|
AddItem(searchBar, 3, 1, false).
|
||||||
AddItem(sNavExpViewFlex, 0, 1, false)
|
AddItem(sNavExpViewFlex, 0, 1, false)
|
||||||
|
|
||||||
mainFlex := tview.NewFlex().SetDirection(tview.FlexRow).
|
lex := tview.NewFlex().SetDirection(tview.FlexRow).
|
||||||
AddItem(searchBarFlex, 0, 8, false).
|
AddItem(searchBarFlex, 0, 8, false).
|
||||||
AddItem(pBar.t, 5, 1, false)
|
AddItem(pBar.t, 5, 1, false)
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ func newApplication() *Application {
|
|||||||
expandedView.SetSelectable(true, false)
|
expandedView.SetSelectable(true, false)
|
||||||
|
|
||||||
rootPages := tview.NewPages()
|
rootPages := tview.NewPages()
|
||||||
rootPages.AddPage("Main", mainFlex, true, true)
|
rootPages.AddPage("Main", lex, true, true)
|
||||||
|
|
||||||
App := tview.NewApplication()
|
App := tview.NewApplication()
|
||||||
App.SetRoot(rootPages, true).SetFocus(expandedView)
|
App.SetRoot(rootPages, true).SetFocus(expandedView)
|
@ -1,7 +1,8 @@
|
|||||||
package main
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/fhs/gompd/mpd"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/aditya-K2/gomp/utils"
|
"github.com/aditya-K2/gomp/utils"
|
||||||
@ -10,7 +11,19 @@ import (
|
|||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var CurrentSong string
|
var (
|
||||||
|
CurrentSong string
|
||||||
|
CONN *mpd.Client
|
||||||
|
RENDERER interface{ Send(string) }
|
||||||
|
)
|
||||||
|
|
||||||
|
func SetConnection(c *mpd.Client) {
|
||||||
|
CONN = c
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetRenderer(r interface{ Send(string) }) {
|
||||||
|
RENDERER = r
|
||||||
|
}
|
||||||
|
|
||||||
// The progressBar is just a string which is separated by the color formatting String
|
// The progressBar is just a string which is separated by the color formatting String
|
||||||
// for e.g
|
// for e.g
|
Loading…
Reference in New Issue
Block a user