diff --git a/container/doctabs.go b/container/doctabs.go
index 25dcbca16b..cd8df75663 100644
--- a/container/doctabs.go
+++ b/container/doctabs.go
@@ -1,6 +1,8 @@
package container
import (
+ "image/color"
+
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/layout"
@@ -62,7 +64,7 @@ func (t *DocTabs) CreateRenderer() fyne.WidgetRenderer {
buttonCache: make(map[*TabItem]*tabButton),
},
docTabs: t,
- scroller: NewScroll(nil),
+ scroller: NewScroll(&fyne.Container{}),
}
r.action = r.buildAllTabsButton()
r.create = r.buildCreateTabsButton()
@@ -289,8 +291,8 @@ func (r *docTabsRenderer) buildCreateTabsButton() *widget.Button {
return create
}
-func (r *docTabsRenderer) buildTabButtons(count int) *fyne.Container {
- buttons := &fyne.Container{}
+func (r *docTabsRenderer) buildTabButtons(count int, buttons *fyne.Container) {
+ buttons.Objects = nil
var iconPos buttonIconPosition
if fyne.CurrentDevice().IsMobile() {
@@ -335,7 +337,6 @@ func (r *docTabsRenderer) buildTabButtons(count int) *fyne.Container {
button.Refresh()
buttons.Objects = append(buttons.Objects, button)
}
- return buttons
}
func (r *docTabsRenderer) scrollToSelected() {
@@ -363,7 +364,7 @@ func (r *docTabsRenderer) scrollToSelected() {
func (r *docTabsRenderer) updateIndicator(animate bool) {
if r.docTabs.current < 0 {
- r.indicator.Hide()
+ r.indicator.FillColor = color.Transparent
r.indicator.Refresh()
return
}
@@ -414,7 +415,7 @@ func (r *docTabsRenderer) updateIndicator(animate bool) {
indicatorPos.Y = 0
}
if indicatorSize.Width < 0 || indicatorSize.Height < 0 {
- r.indicator.Hide()
+ r.indicator.FillColor = color.Transparent
r.indicator.Refresh()
return
}
@@ -441,8 +442,7 @@ func (r *docTabsRenderer) updateCreateTab() {
func (r *docTabsRenderer) updateTabs() {
tabCount := len(r.docTabs.Items)
-
- r.scroller.Content = r.buildTabButtons(tabCount)
+ r.buildTabButtons(tabCount, r.scroller.Content.(*fyne.Container))
// Set layout of tab bar containing tab buttons and overflow action
if r.docTabs.location == TabLocationLeading || r.docTabs.location == TabLocationTrailing {
diff --git a/container/tabs.go b/container/tabs.go
index 5d0fca34ea..f2fc7b83a8 100644
--- a/container/tabs.go
+++ b/container/tabs.go
@@ -107,6 +107,12 @@ func buildPopUpMenu(t baseTabs, button *widget.Button, items []*fyne.MenuItem) *
popUpPos.X = buttonPos.X + buttonSize.Width - popUpMin.Width
popUpPos.Y = buttonPos.Y - popUpMin.Height
}
+ if popUpPos.X < 0 {
+ popUpPos.X = 0
+ }
+ if popUpPos.Y < 0 {
+ popUpPos.Y = 0
+ }
popUpMenu.ShowAtPosition(popUpPos)
return popUpMenu
}
@@ -202,9 +208,10 @@ func setItems(t baseTabs, items []*TabItem) {
type baseTabsRenderer struct {
positionAnimation, sizeAnimation *fyne.Animation
- lastIndicatorMutex sync.RWMutex
- lastIndicatorPos fyne.Position
- lastIndicatorSize fyne.Size
+ lastIndicatorMutex sync.RWMutex
+ lastIndicatorPos fyne.Position
+ lastIndicatorSize fyne.Size
+ lastIndicatorHidden bool
action *widget.Button
bar *fyne.Container
@@ -301,7 +308,8 @@ func (r *baseTabsRenderer) minSize(t baseTabs) fyne.Size {
func (r *baseTabsRenderer) moveIndicator(pos fyne.Position, siz fyne.Size, animate bool) {
r.lastIndicatorMutex.RLock()
- isSameState := r.lastIndicatorPos.Subtract(pos).IsZero() && r.lastIndicatorSize.Subtract(siz).IsZero()
+ isSameState := r.lastIndicatorPos.Subtract(pos).IsZero() && r.lastIndicatorSize.Subtract(siz).IsZero() &&
+ r.lastIndicatorHidden == r.indicator.Hidden
r.lastIndicatorMutex.RUnlock()
if isSameState {
return
@@ -316,7 +324,7 @@ func (r *baseTabsRenderer) moveIndicator(pos fyne.Position, siz fyne.Size, anima
r.sizeAnimation = nil
}
- r.indicator.Show()
+ r.indicator.FillColor = theme.PrimaryColor()
if r.indicator.Position().IsZero() {
r.indicator.Move(pos)
r.indicator.Resize(siz)
@@ -327,6 +335,7 @@ func (r *baseTabsRenderer) moveIndicator(pos fyne.Position, siz fyne.Size, anima
r.lastIndicatorMutex.Lock()
r.lastIndicatorPos = pos
r.lastIndicatorSize = siz
+ r.lastIndicatorHidden = r.indicator.Hidden
r.lastIndicatorMutex.Unlock()
if animate {
diff --git a/container/testdata/doctabs/desktop/dynamic_appended.xml b/container/testdata/doctabs/desktop/dynamic_appended.xml
index 40021bce33..227549c461 100644
--- a/container/testdata/doctabs/desktop/dynamic_appended.xml
+++ b/container/testdata/doctabs/desktop/dynamic_appended.xml
@@ -7,8 +7,8 @@
Test1
-
- Test2
+
+ Test2
diff --git a/container/testdata/doctabs/desktop/dynamic_appended_and_removed.xml b/container/testdata/doctabs/desktop/dynamic_appended_and_removed.xml
index 7fffa1ad7a..918901ff91 100644
--- a/container/testdata/doctabs/desktop/dynamic_appended_and_removed.xml
+++ b/container/testdata/doctabs/desktop/dynamic_appended_and_removed.xml
@@ -4,8 +4,8 @@
-
- Test2
+
+ Test2
@@ -18,7 +18,7 @@
-
+
Text 2
diff --git a/container/testdata/doctabs/desktop/tab_location_leading.xml b/container/testdata/doctabs/desktop/tab_location_leading.xml
index c014a403de..69a9bb7b0e 100644
--- a/container/testdata/doctabs/desktop/tab_location_leading.xml
+++ b/container/testdata/doctabs/desktop/tab_location_leading.xml
@@ -32,6 +32,7 @@
+
Text 1
diff --git a/container/testdata/doctabs/desktop/tab_location_trailing.xml b/container/testdata/doctabs/desktop/tab_location_trailing.xml
index 9524b6d1ab..a4e4d27096 100644
--- a/container/testdata/doctabs/desktop/tab_location_trailing.xml
+++ b/container/testdata/doctabs/desktop/tab_location_trailing.xml
@@ -32,6 +32,7 @@
+
Text 1
diff --git a/container/testdata/doctabs/mobile/dynamic_appended.xml b/container/testdata/doctabs/mobile/dynamic_appended.xml
index a3e5cdf522..261bd4343c 100644
--- a/container/testdata/doctabs/mobile/dynamic_appended.xml
+++ b/container/testdata/doctabs/mobile/dynamic_appended.xml
@@ -4,16 +4,16 @@
-
- Test1
-
+
+ Test1
+
-
- Test2
-
-
+
+ Test2
+
+
@@ -27,7 +27,7 @@
-
+
Text 1
diff --git a/container/testdata/doctabs/mobile/dynamic_appended_and_removed.xml b/container/testdata/doctabs/mobile/dynamic_appended_and_removed.xml
index 02746daca4..0d2258573b 100644
--- a/container/testdata/doctabs/mobile/dynamic_appended_and_removed.xml
+++ b/container/testdata/doctabs/mobile/dynamic_appended_and_removed.xml
@@ -4,10 +4,10 @@
-
- Test2
-
-
+
+ Test2
+
+
@@ -21,7 +21,7 @@
-
+
Text 2