File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1
1
package fyne
2
2
3
+ import "fyne.io/fyne/v2/internal/types"
4
+
3
5
// Declare conformity to [CanvasObject]
4
6
var _ CanvasObject = (* Container )(nil )
5
7
6
8
// Container is a [CanvasObject] that contains a collection of child objects.
7
9
// The layout of the children is set by the specified Layout.
8
10
type Container struct {
11
+ types.ContainerRoot
12
+
9
13
size Size // The current size of the Container
10
14
position Position // The current position of the Container
11
15
Hidden bool // Is this Container hidden
Original file line number Diff line number Diff line change
1
+ package types
2
+
3
+ type container interface {
4
+ fyneTypeContainer ()
5
+ }
6
+
7
+ type ContainerRoot struct {
8
+ }
9
+
10
+ func (c * ContainerRoot ) fyneTypeContainer () {}
11
+
12
+ func IsContainer (o any ) bool { // any to avoid loop if using fyne.CanvasObject
13
+ _ , ok := o .(container )
14
+ return ok
15
+ }
Original file line number Diff line number Diff line change
1
+ package types_test
2
+
3
+ import (
4
+ "testing"
5
+
6
+ "github.com/stretchr/testify/assert"
7
+
8
+ "fyne.io/fyne/v2"
9
+ container2 "fyne.io/fyne/v2/container"
10
+ "fyne.io/fyne/v2/internal/types"
11
+ )
12
+
13
+ func TestIsContainer (t * testing.T ) {
14
+ assert .True (t , types .IsContainer (& fyne.Container {}))
15
+ assert .True (t , types .IsContainer (container2 .NewWithoutLayout ()))
16
+ assert .True (t , types .IsContainer (& extendedContainer {}))
17
+ }
18
+
19
+ type extendedContainer struct {
20
+ fyne.Container
21
+ }
You can’t perform that action at this time.
0 commit comments