From da40ce8f4dc07751341d6e7d19e5945486e90704 Mon Sep 17 00:00:00 2001 From: tannevaled Date: Fri, 21 Aug 2026 02:01:22 +0200 Subject: [PATCH] deps: toolkit v0.230.0 BindProgress rebuilt on ProgressBar.Fraction() (now an *mvvm.Observable): seed the widget from the source then subscribe one-way (a ProgressBar is display-only). 100% coverage held. Co-Authored-By: Claude Opus 4.8 --- bind.go | 14 ++++++++++---- bind_test.go | 8 ++++---- go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/bind.go b/bind.go index 4905900..f6c6fd9 100644 --- a/bind.go +++ b/bind.go @@ -202,11 +202,17 @@ func BindLabel(l *toolkit.Label, obs *mvvm.Observable[string], invalidate func() }) } -// BindProgress one-way-binds a float64 observable to a ProgressBar's Fraction -// (field ProgressBar.Fraction; a ProgressBar has no edit callback). Callers -// keep the value in the widget's [0,1] domain. +// BindProgress one-way-binds a float64 observable to a ProgressBar's Fraction() +// Observable (a ProgressBar is display-only, with no edit callback). Callers keep +// the value in the widget's [0,1] domain. func BindProgress(p *toolkit.ProgressBar, obs *mvvm.Observable[float64], invalidate func()) (unbind func()) { - return mvvm.OneWay(obs, &p.Fraction, invalidate) + p.Fraction().Set(obs.Get()) // seed widget from the source, like mvvm.OneWay + return obs.Subscribe(func(v float64) { + p.Fraction().Set(v) + if invalidate != nil { + invalidate() + } + }) } // ── Collection bindings (ObservableList → widget []string source) ─────────── diff --git a/bind_test.go b/bind_test.go index 1d4503a..2e58e56 100644 --- a/bind_test.go +++ b/bind_test.go @@ -202,12 +202,12 @@ func TestBindProgress(t *testing.T) { unbind := BindProgress(p, obs, c.inc) defer unbind() - if p.Fraction != 0.25 { - t.Fatalf("seed: Fraction=%v", p.Fraction) + if p.Fraction().Get() != 0.25 { + t.Fatalf("seed: Fraction=%v", p.Fraction().Get()) } obs.Set(0.75) - if p.Fraction != 0.75 || c.n != 1 { - t.Fatalf("push: Fraction=%v n=%d", p.Fraction, c.n) + if p.Fraction().Get() != 0.75 || c.n != 1 { + t.Fatalf("push: Fraction=%v n=%d", p.Fraction().Get(), c.n) } } diff --git a/go.mod b/go.mod index b8d04ee..14bd26d 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.26.4 require ( github.com/go-widgets/mvvm v0.5.0 - github.com/go-widgets/toolkit v0.226.0 + github.com/go-widgets/toolkit v0.230.0 ) require ( diff --git a/go.sum b/go.sum index 9105fc6..16e4954 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ github.com/go-widgets/mvvm v0.5.0 h1:o5hh6HAxbApONcbZxmyV9q12pCAPGRd6L24aS3gaCbA github.com/go-widgets/mvvm v0.5.0/go.mod h1:Phdrd434RLxXW1D6dL1PPQH1tABwYLIN2X7jQVC4TbY= github.com/go-widgets/painter v0.11.0 h1:xsj4zTz8B43rOZnWrx7ZsaUBMgJyvgaE/Pq2FfcG2Sw= github.com/go-widgets/painter v0.11.0/go.mod h1:IPRLqdUJuJX8sfuHeYLZCzjoLvA0ApbOlyIAVmguJDQ= -github.com/go-widgets/toolkit v0.226.0 h1:emQuzCdVJhC4gT8rlSc/NUFiL+geMffywx0TdZu7PSU= -github.com/go-widgets/toolkit v0.226.0/go.mod h1:dtu0LE6KVnV7U9R85LkCMiZ5bUL1vRT++OSGAUp8IEQ= +github.com/go-widgets/toolkit v0.230.0 h1:6Z0x8QgYZDGmWyJTCWd7UuzRn46uIvx8mwiAChRz78g= +github.com/go-widgets/toolkit v0.230.0/go.mod h1:dtu0LE6KVnV7U9R85LkCMiZ5bUL1vRT++OSGAUp8IEQ= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=