重写controller部分,修改search界面,添加歌词滚动效果,部分资源添加到bundle,修复拖动进度条时产生的噪音

This commit is contained in:
Aynakeya
2022-12-24 03:51:21 -08:00
parent c47d338a9e
commit 9ec4057412
52 changed files with 777 additions and 376 deletions

View File

@@ -1,14 +1,9 @@
package gui
import (
"AynaLivePlayer/model"
"bytes"
"errors"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/storage"
"fyne.io/fyne/v2/widget"
)
@@ -23,21 +18,6 @@ func newLabelWithWrapping(text string, wrapping fyne.TextWrap) *widget.Label {
return w
}
func createAsyncOnTapped(btn *widget.Button, f func()) func() {
return func() {
btn.Disable()
go func() {
f()
btn.Enable()
}()
}
}
func createAsyncButton(btn *widget.Button, tapped func()) *widget.Button {
btn.OnTapped = createAsyncOnTapped(btn, tapped)
return btn
}
type ContextMenuButton struct {
widget.Button
menu *fyne.Menu
@@ -55,57 +35,6 @@ func newContextMenuButton(label string, menu *fyne.Menu) *ContextMenuButton {
return b
}
type FixedSplitContainer struct {
*container.Split
}
func (f *FixedSplitContainer) Dragged(event *fyne.DragEvent) {
// do nothing
}
func (f *FixedSplitContainer) DragEnd() {
// do nothing
}
func newFixedSplitContainer(horizontal bool, leading, trailing fyne.CanvasObject) *FixedSplitContainer {
s := &container.Split{
Offset: 0.5, // Sensible default, can be overridden with SetOffset
Horizontal: horizontal,
Leading: leading,
Trailing: trailing,
}
fs := &FixedSplitContainer{
s,
}
fs.Split.BaseWidget.ExtendBaseWidget(s)
return fs
}
func newImageFromPlayerPicture(picture model.Picture) (*canvas.Image, error) {
if picture.Data != nil {
img := canvas.NewImageFromReader(bytes.NewReader(picture.Data), "cover")
// return an error when img is nil
if img == nil {
return nil, errors.New("fail to read image")
}
return img, nil
} else {
uri, err := storage.ParseURI(picture.Url)
if err != nil {
return nil, err
}
if uri == nil {
return nil, errors.New("fail to fail url")
}
img := canvas.NewImageFromURI(uri)
if img == nil {
// bug fix, return a new error to indicate fail to read an image
return nil, errors.New("fail to read image")
}
return img, nil
}
}
func showDialogIfError(err error) {
if err != nil {
dialog.ShowError(err, MainWindow)