all: clean up code, upgrade to modern Go

Signed-off-by: ddkwork
This commit is contained in:
Admin
2025-05-05 23:27:04 +08:00
committed by Elias Naur
parent 86668e8b45
commit f73287be87
58 changed files with 413 additions and 241 deletions
-4
View File
@@ -308,10 +308,6 @@ func (l *List) layout(ops *op.Ops, macro op.MacroOp) Dimensions {
cross = (maxCross - sz.Y) / 2
}
childSize := sz.X
min := pos
if min < 0 {
min = 0
}
pt := l.Axis.Convert(image.Pt(pos, cross))
trans := op.Offset(pt).Push(ops)
child.call.Add(ops)
+12 -6
View File
@@ -88,7 +88,8 @@ func TestListPosition(t *testing.T) {
{label: "1 visible 0 hidden", num: 1, count: 1, last: 10},
{label: "2 visible 0 hidden", num: 2, count: 2},
{label: "2 visible 1 hidden", num: 3, count: 2},
{label: "3 visible 0 hidden small scroll", num: 3, count: 3, offset: 5, last: -5,
{
label: "3 visible 0 hidden small scroll", num: 3, count: 3, offset: 5, last: -5,
scroll: _s(
pointer.Event{
Source: pointer.Mouse,
@@ -107,8 +108,10 @@ func TestListPosition(t *testing.T) {
Kind: pointer.Release,
Position: f32.Pt(5, 0),
},
)},
{label: "3 visible 0 hidden small scroll 2", num: 3, count: 3, offset: 3, last: -7,
),
},
{
label: "3 visible 0 hidden small scroll 2", num: 3, count: 3, offset: 3, last: -7,
scroll: _s(
pointer.Event{
Source: pointer.Mouse,
@@ -127,8 +130,10 @@ func TestListPosition(t *testing.T) {
Kind: pointer.Release,
Position: f32.Pt(5, 0),
},
)},
{label: "2 visible 1 hidden large scroll", num: 3, count: 2, first: 1,
),
},
{
label: "2 visible 1 hidden large scroll", num: 3, count: 2, first: 1,
scroll: _s(
pointer.Event{
Source: pointer.Mouse,
@@ -147,7 +152,8 @@ func TestListPosition(t *testing.T) {
Kind: pointer.Release,
Position: f32.Pt(15, 0),
},
)},
),
},
} {
t.Run(tc.label, func(t *testing.T) {
gtx.Ops.Reset()
+2 -4
View File
@@ -17,9 +17,8 @@ func BenchmarkStack(b *testing.B) {
},
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
for b.Loop() {
gtx.Ops.Reset()
Stack{}.Layout(gtx,
@@ -41,9 +40,8 @@ func BenchmarkBackground(b *testing.B) {
},
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
for b.Loop() {
gtx.Ops.Reset()
Background{}.Layout(gtx,