From 7a4673ab3d841d3443b9b984fc0c24c1904fc4b5 Mon Sep 17 00:00:00 2001 From: Martyn R Date: Thu, 23 Dec 2021 16:26:34 +0000 Subject: [PATCH] Added resizing to correct widget --- pkg/numeter/numeter.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/numeter/numeter.go b/pkg/numeter/numeter.go index 1560830..af0ca5f 100644 --- a/pkg/numeter/numeter.go +++ b/pkg/numeter/numeter.go @@ -22,6 +22,9 @@ type vuRenderer struct { } func (v *vuRenderer) MinSize() fyne.Size { + if (v.meter.overriddenMinSize.Height >= 0) && (v.meter.overriddenMinSize.Height >= 0) { + return v.meter.overriddenMinSize + } var tsize fyne.Size if text := v.meter.TextFormatter; text != nil { tsize = fyne.MeasureText(text(), theme.TextSize(), fyne.TextStyle{false, false, false, 4}) @@ -162,7 +165,8 @@ type vuMeter struct { Peakhold time.Duration VUMeterDirection VUMeterDirectionEnum - binder basicBinder + binder basicBinder + overriddenMinSize fyne.Size } func NewVUMeterRenderer(m *vuMeter) *vuRenderer { @@ -222,6 +226,11 @@ func (m *vuMeter) Unbind() { m.binder.Unbind() } +func (m *vuMeter) SetMinSize(s fyne.Size) { + m.overriddenMinSize = s + m.Refresh() +} + // NewVUMeter creates a new meter widget with the specified value func NewVUMeter(value float64) *vuMeter { meter := &vuMeter{Value: value} @@ -230,6 +239,7 @@ func NewVUMeter(value float64) *vuMeter { meter.Min = 0 meter.Max = 100 meter.ExtendBaseWidget(meter) + meter.overriddenMinSize = fyne.NewSize(-1, -1) meter.VUMeterDirection = VUMeterHorizontal meter.Peakhold = 0 return meter