From ff8ef70691d41b213813b756b7277c2833a17a4c Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Mon, 3 Jun 2024 17:15:17 -0700 Subject: [PATCH 1/4] WIP: fix list last row sometimes missing --- cmd/fyne_demo/main.go | 4 ++-- cmd/fyne_demo/tutorials/widget.go | 5 ++++- widget/list.go | 6 +++--- widget/list_test.go | 8 ++++---- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cmd/fyne_demo/main.go b/cmd/fyne_demo/main.go index f5c93b3567..b661983d76 100644 --- a/cmd/fyne_demo/main.go +++ b/cmd/fyne_demo/main.go @@ -253,10 +253,10 @@ func makeNav(setTutorial func(tutorial tutorials.Tutorial), loadPrevious bool) f themes := container.NewGridWithColumns(2, widget.NewButton("Dark", func() { - a.Settings().SetTheme(&forcedVariant{Theme: theme.DefaultTheme(), variant: theme.VariantDark}) + //a.Settings().SetTheme(&forcedVariant{Theme: theme.DefaultTheme(), variant: theme.VariantDark}) }), widget.NewButton("Light", func() { - a.Settings().SetTheme(&forcedVariant{Theme: theme.DefaultTheme(), variant: theme.VariantLight}) + //a.Settings().SetTheme(&forcedVariant{Theme: theme.DefaultTheme(), variant: theme.VariantLight}) }), ) diff --git a/cmd/fyne_demo/tutorials/widget.go b/cmd/fyne_demo/tutorials/widget.go index f0c6a005bd..729efea8dc 100644 --- a/cmd/fyne_demo/tutorials/widget.go +++ b/cmd/fyne_demo/tutorials/widget.go @@ -516,9 +516,12 @@ func stopProgress() { // widgetScreen shows a panel containing widget demos func widgetScreen(_ fyne.Window) fyne.CanvasObject { + thIcon := theme.NewThemedResource(theme.HomeIcon()) + thIcon.ColorName = theme.ColorNamePrimary + btn := widget.NewButtonWithIcon("Icons", thIcon, func() {}) content := container.NewVBox( widget.NewLabel("Labels"), - widget.NewButtonWithIcon("Icons", theme.HomeIcon(), func() {}), + btn, widget.NewSlider(0, 1)) return container.NewCenter(content) } diff --git a/widget/list.go b/widget/list.go index e103d3c07d..5be6143dcc 100644 --- a/widget/list.go +++ b/widget/list.go @@ -411,11 +411,11 @@ func (l *listLayout) calculateVisibleRowHeights(itemHeight float32, length int) offY = 0 } - if maxRow > length { - maxRow = length + if maxRow > length-1 { + maxRow = length - 1 } - for i := 0; i < maxRow-minRow; i++ { + for i := 0; i <= maxRow-minRow; i++ { l.visibleRowHeights = append(l.visibleRowHeights, itemHeight) } return diff --git a/widget/list_test.go b/widget/list_test.go index 2dcb4b72a5..06a4662adb 100644 --- a/widget/list_test.go +++ b/widget/list_test.go @@ -490,7 +490,7 @@ func TestList_ScrollThenShrink(t *testing.T) { visibles := list.scroller.Content.(*fyne.Container).Layout.(*listLayout).children visibleCount := len(visibles) - assert.Equal(t, visibleCount, 8) + assert.Equal(t, visibleCount, 9) list.scroller.ScrollToBottom() visibles = list.scroller.Content.(*fyne.Container).Layout.(*listLayout).children @@ -637,11 +637,11 @@ func TestList_LimitUpdateItem(t *testing.T) { ) w.SetContent(list) w.ShowAndRun() - assert.Equal(t, "0.0.", printOut) + assert.Equal(t, "0.1.0.1.", printOut) list.scrollTo(1) - assert.Equal(t, "0.0.1.", printOut) + assert.Equal(t, "0.1.0.1.2.", printOut) list.scrollTo(2) - assert.Equal(t, "0.0.1.2.", printOut) + assert.Equal(t, "0.1.0.1.2.3.", printOut) } func TestList_RefreshUpdatesAllItems(t *testing.T) { From 9ecdf0a4f02a6e12d591d3b5416cd8fed156eb82 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Mon, 3 Jun 2024 17:19:10 -0700 Subject: [PATCH 2/4] undo accidentally commited fyne_demo changes --- cmd/fyne_demo/main.go | 4 ++-- cmd/fyne_demo/tutorials/widget.go | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd/fyne_demo/main.go b/cmd/fyne_demo/main.go index b661983d76..f5c93b3567 100644 --- a/cmd/fyne_demo/main.go +++ b/cmd/fyne_demo/main.go @@ -253,10 +253,10 @@ func makeNav(setTutorial func(tutorial tutorials.Tutorial), loadPrevious bool) f themes := container.NewGridWithColumns(2, widget.NewButton("Dark", func() { - //a.Settings().SetTheme(&forcedVariant{Theme: theme.DefaultTheme(), variant: theme.VariantDark}) + a.Settings().SetTheme(&forcedVariant{Theme: theme.DefaultTheme(), variant: theme.VariantDark}) }), widget.NewButton("Light", func() { - //a.Settings().SetTheme(&forcedVariant{Theme: theme.DefaultTheme(), variant: theme.VariantLight}) + a.Settings().SetTheme(&forcedVariant{Theme: theme.DefaultTheme(), variant: theme.VariantLight}) }), ) diff --git a/cmd/fyne_demo/tutorials/widget.go b/cmd/fyne_demo/tutorials/widget.go index 729efea8dc..f0c6a005bd 100644 --- a/cmd/fyne_demo/tutorials/widget.go +++ b/cmd/fyne_demo/tutorials/widget.go @@ -516,12 +516,9 @@ func stopProgress() { // widgetScreen shows a panel containing widget demos func widgetScreen(_ fyne.Window) fyne.CanvasObject { - thIcon := theme.NewThemedResource(theme.HomeIcon()) - thIcon.ColorName = theme.ColorNamePrimary - btn := widget.NewButtonWithIcon("Icons", thIcon, func() {}) content := container.NewVBox( widget.NewLabel("Labels"), - btn, + widget.NewButtonWithIcon("Icons", theme.HomeIcon(), func() {}), widget.NewSlider(0, 1)) return container.NewCenter(content) } From b6498b024121fde6194c2bd35732498ec456e1df Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Sat, 22 Jun 2024 07:47:29 -0700 Subject: [PATCH 3/4] update test XML fixtures --- widget/testdata/list/initial.xml | 15 +++++++++++++++ widget/testdata/list/item_removed.xml | 4 ++-- widget/testdata/list/new_data.xml | 15 +++++++++++++++ widget/testdata/list/offset_changed.xml | 15 +++++++++++++++ widget/testdata/list/resized.xml | 15 +++++++++++++++ 5 files changed, 62 insertions(+), 2 deletions(-) diff --git a/widget/testdata/list/initial.xml b/widget/testdata/list/initial.xml index 80bc47b1df..0c870318fc 100644 --- a/widget/testdata/list/initial.xml +++ b/widget/testdata/list/initial.xml @@ -135,6 +135,18 @@ + + + + + + + + Test Item 11 + + + + @@ -168,6 +180,9 @@ + + + diff --git a/widget/testdata/list/item_removed.xml b/widget/testdata/list/item_removed.xml index 68d265a365..f559b64eeb 100644 --- a/widget/testdata/list/item_removed.xml +++ b/widget/testdata/list/item_removed.xml @@ -20,8 +20,8 @@ - - + + Test Item 1 diff --git a/widget/testdata/list/new_data.xml b/widget/testdata/list/new_data.xml index 501596c756..c8807f5e83 100644 --- a/widget/testdata/list/new_data.xml +++ b/widget/testdata/list/new_data.xml @@ -135,6 +135,18 @@ + + + + + + + + l + + + + @@ -168,6 +180,9 @@ + + + diff --git a/widget/testdata/list/offset_changed.xml b/widget/testdata/list/offset_changed.xml index 0aca058620..66149b5ad8 100644 --- a/widget/testdata/list/offset_changed.xml +++ b/widget/testdata/list/offset_changed.xml @@ -135,6 +135,18 @@ + + + + + + + + Test Item 18 + + + + @@ -168,6 +180,9 @@ + + + diff --git a/widget/testdata/list/resized.xml b/widget/testdata/list/resized.xml index 82da1a1b1b..66aed2525e 100644 --- a/widget/testdata/list/resized.xml +++ b/widget/testdata/list/resized.xml @@ -195,6 +195,18 @@ + + + + + + + + Test Item 16 + + + + @@ -243,6 +255,9 @@ + + + From bfbee04477cbf40975126bf624e8ae5e740633c1 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Sat, 22 Jun 2024 07:57:05 -0700 Subject: [PATCH 4/4] more XML fixture updates --- widget/testdata/list/initial.xml | 2 +- widget/testdata/list/new_data.xml | 2 +- widget/testdata/list/offset_changed.xml | 2 +- widget/testdata/list/resized.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/widget/testdata/list/initial.xml b/widget/testdata/list/initial.xml index 0c870318fc..2aca3be5cb 100644 --- a/widget/testdata/list/initial.xml +++ b/widget/testdata/list/initial.xml @@ -181,7 +181,7 @@ - + diff --git a/widget/testdata/list/new_data.xml b/widget/testdata/list/new_data.xml index c8807f5e83..f5e34cb184 100644 --- a/widget/testdata/list/new_data.xml +++ b/widget/testdata/list/new_data.xml @@ -181,7 +181,7 @@ - + diff --git a/widget/testdata/list/offset_changed.xml b/widget/testdata/list/offset_changed.xml index 66149b5ad8..54447799e9 100644 --- a/widget/testdata/list/offset_changed.xml +++ b/widget/testdata/list/offset_changed.xml @@ -181,7 +181,7 @@ - + diff --git a/widget/testdata/list/resized.xml b/widget/testdata/list/resized.xml index 66aed2525e..930486f876 100644 --- a/widget/testdata/list/resized.xml +++ b/widget/testdata/list/resized.xml @@ -256,7 +256,7 @@ - +