Skip to content

Commit

Permalink
New container.New() and container.NewWithoutLayout() functions (#1637)
Browse files Browse the repository at this point in the history
This adds container.New() and container.NewWithoutLayout() over fyne.NewContainer() and derivatives.
  • Loading branch information
Jacalz committed Dec 15, 2020
1 parent a37bc75 commit 4a5a5ac
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
10 changes: 7 additions & 3 deletions container.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ type Container struct {

// NewContainer returns a new Container instance holding the specified CanvasObjects.
//
// Deprecated: Use NewContainerWithoutLayout to create a container that uses manual layout.
// Deprecated: Use container.NewWithoutLayout() to create a container that uses manual layout.
func NewContainer(objects ...CanvasObject) *Container {
return NewContainerWithoutLayout(objects...)
}

// NewContainerWithoutLayout returns a new Container instance holding the specified CanvasObjects
// that are manually arranged.
// NewContainerWithoutLayout returns a new Container instance holding the specified
// CanvasObjects that are manually arranged.
//
// Deprecated: Use container.NewWithoutLayout() instead
func NewContainerWithoutLayout(objects ...CanvasObject) *Container {
ret := &Container{
Objects: objects,
Expand All @@ -34,6 +36,8 @@ func NewContainerWithoutLayout(objects ...CanvasObject) *Container {

// NewContainerWithLayout returns a new Container instance holding the specified
// CanvasObjects which will be laid out according to the specified Layout.
//
// Deprecated: Use container.New() instead
func NewContainerWithLayout(layout Layout, objects ...CanvasObject) *Container {
ret := &Container{
Objects: objects,
Expand Down
20 changes: 20 additions & 0 deletions container/container.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Package container provides container widgets that are used to lay out and organise applications
package container

import (
"fyne.io/fyne"
)

// New returns a new Container instance holding the specified CanvasObjects which will be laid out according to the specified Layout.
//
// Since 2.0.0
func New(layout fyne.Layout, objects ...fyne.CanvasObject) *fyne.Container {
return fyne.NewContainerWithLayout(layout, objects...)
}

// NewWithoutLayout returns a new Container instance holding the specified CanvasObjects that are manually arranged.
//
// Since 2.0.0
func NewWithoutLayout(objects ...fyne.CanvasObject) *fyne.Container {
return fyne.NewContainerWithoutLayout(objects...)
}
1 change: 0 additions & 1 deletion container/layouts.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package container provides container widgets that are used to lay out and organise applications
package container // import "fyne.io/fyne/container"

import (
Expand Down

0 comments on commit 4a5a5ac

Please sign in to comment.