mirror of
https://github.com/issadarkthing/gomu.git
synced 2025-04-25 13:48:49 +08:00
Fixed:position of photo window
This commit is contained in:
parent
f8c1d36c3e
commit
ca5051fa13
@ -3,10 +3,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"C"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
@ -17,10 +17,13 @@ import (
|
||||
"github.com/tramhao/id3v2"
|
||||
"github.com/ztrue/tracerr"
|
||||
ugo "gitlab.com/diamondburned/ueberzug-go"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
|
||||
"github.com/issadarkthing/gomu/lyric"
|
||||
)
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// PlayingBar shows song name, progress and lyric
|
||||
type PlayingBar struct {
|
||||
@ -335,14 +338,12 @@ func (p *PlayingBar) loadLyrics(currentSongPath string) error {
|
||||
|
||||
go gomu.app.QueueUpdateDraw(func() {
|
||||
x, y, _, _ := p.GetInnerRect()
|
||||
width, height, err := terminal.GetSize(int(os.Stdin.Fd()))
|
||||
width, height, windowWidth, windowHeight := getConsoleSize()
|
||||
if err != nil {
|
||||
errorPopup(err)
|
||||
}
|
||||
|
||||
windowWidth := 1920
|
||||
windowHeight := 1200
|
||||
p.albumPhoto, err = ugo.NewImage(dstImage128, x*windowWidth/width, y*windowHeight/height)
|
||||
p.albumPhoto, err = ugo.NewImage(dstImage128, (x+3)*windowWidth/width, (y+2)*windowHeight/height)
|
||||
if err != nil {
|
||||
errorPopup(err)
|
||||
}
|
||||
@ -368,3 +369,15 @@ func (p *PlayingBar) getFull() int {
|
||||
func (p *PlayingBar) setFull(full int) {
|
||||
atomic.StoreInt64(&p.full, int64(full))
|
||||
}
|
||||
|
||||
func getConsoleSize() (int, int, int, int) {
|
||||
var sz struct {
|
||||
rows uint16
|
||||
cols uint16
|
||||
xpixels uint16
|
||||
ypixels uint16
|
||||
}
|
||||
_, _, _ = syscall.Syscall(syscall.SYS_IOCTL,
|
||||
uintptr(syscall.Stdout), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&sz)))
|
||||
return int(sz.cols), int(sz.rows), int(sz.xpixels), int(sz.ypixels)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user