Added resizing to correct widget

This commit is contained in:
Martyn 2021-12-23 16:26:34 +00:00
parent 90669b36f1
commit 7a4673ab3d
1 changed files with 11 additions and 1 deletions

View File

@ -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