From 2838a02c83d7ce9338d6078ff13771a9f71799a1 Mon Sep 17 00:00:00 2001 From: aynakeya Date: Tue, 7 Oct 2025 00:30:54 +0800 Subject: [PATCH] update fixedSize --- gui/component/fixedsize.go | 22 ++++++++++++++++++++++ gui/views/player/controller.go | 14 ++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 gui/component/fixedsize.go diff --git a/gui/component/fixedsize.go b/gui/component/fixedsize.go new file mode 100644 index 0000000..13f6271 --- /dev/null +++ b/gui/component/fixedsize.go @@ -0,0 +1,22 @@ +package component + +import ( + "fyne.io/fyne/v2" + "fyne.io/fyne/v2/widget" +) + +type LabelFixedSize struct { + *widget.Label + fixedSize fyne.Size +} + +func (t *LabelFixedSize) MinSize() fyne.Size { + return t.fixedSize +} + +func NewLabelFixedSize(label *widget.Label) *LabelFixedSize { + return &LabelFixedSize{ + Label: label, + fixedSize: label.MinSize(), + } +} diff --git a/gui/views/player/controller.go b/gui/views/player/controller.go index 1dfaf9c..b3683f5 100644 --- a/gui/views/player/controller.go +++ b/gui/views/player/controller.go @@ -33,7 +33,7 @@ type PlayControllerContainer struct { ButtonLrc *widget.Button ButtonPlayer *widget.Button LrcWindowOpen bool - CurrentTime *widget.Label + CurrentTime *component.LabelFixedSize TotalTime *widget.Label } @@ -65,6 +65,12 @@ func registerPlayControllerHandler() { } } + gctx.Context.OnMainWindowClosing(func() { + if lyricWindow != nil { + lyricWindow.Close() + } + }) + PlayController.ButtonPlayer.OnTapped = func() { showPlayerWindow() } @@ -220,12 +226,12 @@ func createPlayControllerV2() fyne.CanvasObject { controls.SeparatorThickness = 0 PlayController.Progress = component.NewSliderPlus(0, 1000) - PlayController.CurrentTime = widget.NewLabel("00:00") + PlayController.CurrentTime = component.NewLabelFixedSize(widget.NewLabel("00:00")) PlayController.TotalTime = widget.NewLabel("00:00") progressItem := container.NewBorder(nil, nil, - nil, + PlayController.CurrentTime, PlayController.TotalTime, - component.NewFixedHSplitContainer(PlayController.CurrentTime, PlayController.Progress, 0.1)) + PlayController.Progress) PlayController.Title = widget.NewLabel("Title") PlayController.Title.Truncation = fyne.TextTruncateClip