fix seek bar changing size with num. digits in track time
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@ func SecondsToTimeString(s float64) string {
|
|||||||
min := sec / 60
|
min := sec / 60
|
||||||
sec -= min * 60
|
sec -= min * 60
|
||||||
|
|
||||||
return fmt.Sprintf("%3d:%02d", min, sec)
|
return fmt.Sprintf("%d:%02d", min, sec)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RichTextSegsFromHTMLString(s string) []widget.RichTextSegment {
|
func RichTextSegsFromHTMLString(s string) []widget.RichTextSegment {
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ type PlayerControls struct {
|
|||||||
widget.BaseWidget
|
widget.BaseWidget
|
||||||
|
|
||||||
slider *TrackPosSlider
|
slider *TrackPosSlider
|
||||||
curTimeLabel *widget.Label
|
curTimeLabel *labelMinSize
|
||||||
totalTimeLabel *widget.Label
|
totalTimeLabel *labelMinSize
|
||||||
prev *widget.Button
|
prev *widget.Button
|
||||||
playpause *widget.Button
|
playpause *widget.Button
|
||||||
next *widget.Button
|
next *widget.Button
|
||||||
@@ -69,14 +69,31 @@ type PlayerControls struct {
|
|||||||
|
|
||||||
var _ fyne.Widget = (*PlayerControls)(nil)
|
var _ fyne.Widget = (*PlayerControls)(nil)
|
||||||
|
|
||||||
|
type labelMinSize struct {
|
||||||
|
widget.Label
|
||||||
|
MinWidth float32
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *labelMinSize) MinSize() fyne.Size {
|
||||||
|
return fyne.NewSize(l.MinWidth, l.Label.MinSize().Height)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewLabelMinSize(text string, minWidth float32) *labelMinSize {
|
||||||
|
l := &labelMinSize{MinWidth: minWidth, Label: widget.Label{Text: text}}
|
||||||
|
l.ExtendBaseWidget(l)
|
||||||
|
return l
|
||||||
|
}
|
||||||
|
|
||||||
// NewPlayerControls sets up the seek bar, and transport buttons.
|
// NewPlayerControls sets up the seek bar, and transport buttons.
|
||||||
func NewPlayerControls() *PlayerControls {
|
func NewPlayerControls() *PlayerControls {
|
||||||
pc := &PlayerControls{}
|
pc := &PlayerControls{}
|
||||||
pc.ExtendBaseWidget(pc)
|
pc.ExtendBaseWidget(pc)
|
||||||
|
|
||||||
pc.slider = NewTrackPosSlider()
|
pc.slider = NewTrackPosSlider()
|
||||||
pc.curTimeLabel = widget.NewLabel(util.SecondsToTimeString(0))
|
pc.curTimeLabel = NewLabelMinSize(util.SecondsToTimeString(0), 55)
|
||||||
pc.totalTimeLabel = widget.NewLabel(util.SecondsToTimeString(0))
|
pc.curTimeLabel.Alignment = fyne.TextAlignTrailing
|
||||||
|
pc.totalTimeLabel = NewLabelMinSize(util.SecondsToTimeString(0), 55)
|
||||||
|
pc.totalTimeLabel.Alignment = fyne.TextAlignTrailing
|
||||||
|
|
||||||
pc.slider.OnChanged = func(f float64) {
|
pc.slider.OnChanged = func(f float64) {
|
||||||
time := f * pc.totalTime
|
time := f * pc.totalTime
|
||||||
|
|||||||
Reference in New Issue
Block a user