container

package
v2.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2024 License: BSD-3-Clause Imports: 12 Imported by: 1,688

Documentation

Overview

Package container provides containers that are used to lay out and organise applications.

Index

Constants

View Source
const (
	// ScrollBoth supports horizontal and vertical scrolling.
	ScrollBoth ScrollDirection = widget.ScrollBoth
	// ScrollHorizontalOnly specifies the scrolling should only happen left to right.
	ScrollHorizontalOnly = widget.ScrollHorizontalOnly
	// ScrollVerticalOnly specifies the scrolling should only happen top to bottom.
	ScrollVerticalOnly = widget.ScrollVerticalOnly
	// ScrollNone turns off scrolling for this container.
	//
	// Since: 2.1
	ScrollNone = widget.ScrollNone
)

Constants for valid values of ScrollDirection.

Variables

This section is empty.

Functions

func New

func New(layout fyne.Layout, objects ...fyne.CanvasObject) *fyne.Container

New returns a new Container instance holding the specified CanvasObjects which will be laid out according to the specified Layout.

Since: 2.0

func NewAdaptiveGrid

func NewAdaptiveGrid(rowcols int, objects ...fyne.CanvasObject) *fyne.Container

NewAdaptiveGrid creates a new container with the specified objects and using the grid layout. When in a horizontal arrangement the rowcols parameter will specify the column count, when in vertical it will specify the rows. On mobile this will dynamically refresh when device is rotated.

Since: 1.4

func NewBorder

func NewBorder(top, bottom, left, right fyne.CanvasObject, objects ...fyne.CanvasObject) *fyne.Container

NewBorder creates a new container with the specified objects and using the border layout. The top, bottom, left and right parameters specify the items that should be placed around edges, the remaining elements will be in the center. Nil can be used to an edge if it should not be filled.

Since: 1.4

func NewCenter

func NewCenter(objects ...fyne.CanvasObject) *fyne.Container

NewCenter creates a new container with the specified objects centered in the available space.

Since: 1.4

func NewGridWithColumns

func NewGridWithColumns(cols int, objects ...fyne.CanvasObject) *fyne.Container

NewGridWithColumns creates a new container with the specified objects and using the grid layout with a specified number of columns. The number of rows will depend on how many children are in the container.

Since: 1.4

func NewGridWithRows

func NewGridWithRows(rows int, objects ...fyne.CanvasObject) *fyne.Container

NewGridWithRows creates a new container with the specified objects and using the grid layout with a specified number of rows. The number of columns will depend on how many children are in the container.

Since: 1.4

func NewGridWrap

func NewGridWrap(size fyne.Size, objects ...fyne.CanvasObject) *fyne.Container

NewGridWrap creates a new container with the specified objects and using the gridwrap layout. Every element will be resized to the size parameter and the content will arrange along a row and flow to a new row if the elements don't fit.

Since: 1.4

func NewHBox

func NewHBox(objects ...fyne.CanvasObject) *fyne.Container

NewHBox creates a new container with the specified objects and using the HBox layout. The objects will be placed in the container from left to right and always displayed at their horizontal MinSize. Use a different layout if the objects are intended to be larger then their horizontal MinSize.

Since: 1.4

func NewMax deprecated

func NewMax(objects ...fyne.CanvasObject) *fyne.Container

NewMax creates a new container with the specified objects filling the available space.

Since: 1.4

Deprecated: Use container.NewStack() instead.

func NewPadded

func NewPadded(objects ...fyne.CanvasObject) *fyne.Container

NewPadded creates a new container with the specified objects inset by standard padding size.

Since: 1.4

func NewStack added in v2.4.0

func NewStack(objects ...fyne.CanvasObject) *fyne.Container

NewStack returns a new container that stacks objects on top of each other. Objects at the end of the container will be stacked on top of objects before. Having only a single object has no impact as CanvasObjects will fill the available space even without a Stack.

Since: 2.4

func NewVBox

func NewVBox(objects ...fyne.CanvasObject) *fyne.Container

NewVBox creates a new container with the specified objects and using the VBox layout. The objects will be stacked in the container from top to bottom and always displayed at their vertical MinSize. Use a different layout if the objects are intended to be larger then their vertical MinSize.

Since: 1.4

func NewWithoutLayout

func NewWithoutLayout(objects ...fyne.CanvasObject) *fyne.Container

NewWithoutLayout returns a new Container instance holding the specified CanvasObjects that are manually arranged.

Since: 2.0

Types

type AppTabs

type AppTabs struct {
	widget.BaseWidget

	Items []*TabItem

	// Deprecated: Use `OnSelected func(*TabItem)` instead.
	OnChanged    func(*TabItem) `json:"-"`
	OnSelected   func(*TabItem) `json:"-"`
	OnUnselected func(*TabItem) `json:"-"`
	// contains filtered or unexported fields
}

AppTabs container is used to split your application into various different areas identified by tabs. The tabs contain text and/or an icon and allow the user to switch between the content specified in each TabItem. Each item is represented by a button at the edge of the container.

Since: 1.4

func NewAppTabs

func NewAppTabs(items ...*TabItem) *AppTabs

NewAppTabs creates a new tab container that allows the user to choose between different areas of an app.

Since: 1.4

func (*AppTabs) Append

func (t *AppTabs) Append(item *TabItem)

Append adds a new TabItem to the end of the tab bar.

func (*AppTabs) CreateRenderer

func (t *AppTabs) CreateRenderer() fyne.WidgetRenderer

CreateRenderer is a private method to Fyne which links this widget to its renderer

Implements: fyne.Widget

func (*AppTabs) CurrentTab deprecated

func (t *AppTabs) CurrentTab() *TabItem

CurrentTab returns the currently selected TabItem.

Deprecated: Use `AppTabs.Selected() *TabItem` instead.

func (*AppTabs) CurrentTabIndex deprecated

func (t *AppTabs) CurrentTabIndex() int

CurrentTabIndex returns the index of the currently selected TabItem.

Deprecated: Use `AppTabs.SelectedIndex() int` instead.

func (*AppTabs) DisableIndex added in v2.3.0

func (t *AppTabs) DisableIndex(i int)

DisableIndex disables the TabItem at the specified index.

Since: 2.3

func (*AppTabs) DisableItem added in v2.3.0

func (t *AppTabs) DisableItem(item *TabItem)

DisableItem disables the specified TabItem.

Since: 2.3

func (*AppTabs) EnableIndex added in v2.3.0

func (t *AppTabs) EnableIndex(i int)

EnableIndex enables the TabItem at the specified index.

Since: 2.3

func (*AppTabs) EnableItem added in v2.3.0

func (t *AppTabs) EnableItem(item *TabItem)

EnableItem enables the specified TabItem.

Since: 2.3

func (*AppTabs) ExtendBaseWidget deprecated added in v2.0.1

func (t *AppTabs) ExtendBaseWidget(wid fyne.Widget)

ExtendBaseWidget is used by an extending widget to make use of BaseWidget functionality.

Deprecated: Support for extending containers is being removed

func (*AppTabs) Hide added in v2.1.0

func (t *AppTabs) Hide()

Hide hides the widget.

Implements: fyne.CanvasObject

func (*AppTabs) MinSize

func (t *AppTabs) MinSize() fyne.Size

MinSize returns the size that this widget should not shrink below

Implements: fyne.CanvasObject

func (*AppTabs) Remove

func (t *AppTabs) Remove(item *TabItem)

Remove tab by value.

func (*AppTabs) RemoveIndex

func (t *AppTabs) RemoveIndex(index int)

RemoveIndex removes tab by index.

func (*AppTabs) Select added in v2.1.0

func (t *AppTabs) Select(item *TabItem)

Select sets the specified TabItem to be selected and its content visible.

func (*AppTabs) SelectIndex added in v2.1.0

func (t *AppTabs) SelectIndex(index int)

SelectIndex sets the TabItem at the specific index to be selected and its content visible.

func (*AppTabs) SelectTab deprecated

func (t *AppTabs) SelectTab(item *TabItem)

SelectTab sets the specified TabItem to be selected and its content visible.

Deprecated: Use `AppTabs.Select(*TabItem)` instead.

func (*AppTabs) SelectTabIndex deprecated

func (t *AppTabs) SelectTabIndex(index int)

SelectTabIndex sets the TabItem at the specific index to be selected and its content visible.

Deprecated: Use `AppTabs.SelectIndex(int)` instead.

func (*AppTabs) Selected added in v2.1.0

func (t *AppTabs) Selected() *TabItem

Selected returns the currently selected TabItem.

func (*AppTabs) SelectedIndex added in v2.1.0

func (t *AppTabs) SelectedIndex() int

SelectedIndex returns the index of the currently selected TabItem.

func (*AppTabs) SetItems

func (t *AppTabs) SetItems(items []*TabItem)

SetItems sets the containers items and refreshes.

func (*AppTabs) SetTabLocation

func (t *AppTabs) SetTabLocation(l TabLocation)

SetTabLocation sets the location of the tab bar

func (*AppTabs) Show

func (t *AppTabs) Show()

Show this widget, if it was previously hidden

Implements: fyne.CanvasObject

type DocTabs added in v2.1.0

type DocTabs struct {
	widget.BaseWidget

	Items []*TabItem

	CreateTab      func() *TabItem `json:"-"`
	CloseIntercept func(*TabItem)  `json:"-"`
	OnClosed       func(*TabItem)  `json:"-"`
	OnSelected     func(*TabItem)  `json:"-"`
	OnUnselected   func(*TabItem)  `json:"-"`
	// contains filtered or unexported fields
}

DocTabs container is used to display various pieces of content identified by tabs. The tabs contain text and/or an icon and allow the user to switch between the content specified in each TabItem. Each item is represented by a button at the edge of the container.

Since: 2.1

func NewDocTabs added in v2.1.0

func NewDocTabs(items ...*TabItem) *DocTabs

NewDocTabs creates a new tab container that allows the user to choose between various pieces of content.

Since: 2.1

func (*DocTabs) Append added in v2.1.0

func (t *DocTabs) Append(item *TabItem)

Append adds a new TabItem to the end of the tab bar.

func (*DocTabs) CreateRenderer added in v2.1.0

func (t *DocTabs) CreateRenderer() fyne.WidgetRenderer

CreateRenderer is a private method to Fyne which links this widget to its renderer

Implements: fyne.Widget

func (*DocTabs) DisableIndex added in v2.3.0

func (t *DocTabs) DisableIndex(i int)

DisableIndex disables the TabItem at the specified index.

Since: 2.3

func (*DocTabs) DisableItem added in v2.3.0

func (t *DocTabs) DisableItem(item *TabItem)

DisableItem disables the specified TabItem.

Since: 2.3

func (*DocTabs) EnableIndex added in v2.3.0

func (t *DocTabs) EnableIndex(i int)

EnableIndex enables the TabItem at the specified index.

Since: 2.3

func (*DocTabs) EnableItem added in v2.3.0

func (t *DocTabs) EnableItem(item *TabItem)

EnableItem enables the specified TabItem.

Since: 2.3

func (*DocTabs) Hide added in v2.1.0

func (t *DocTabs) Hide()

Hide hides the widget.

Implements: fyne.CanvasObject

func (*DocTabs) MinSize added in v2.1.0

func (t *DocTabs) MinSize() fyne.Size

MinSize returns the size that this widget should not shrink below

Implements: fyne.CanvasObject

func (*DocTabs) Remove added in v2.1.0

func (t *DocTabs) Remove(item *TabItem)

Remove tab by value.

func (*DocTabs) RemoveIndex added in v2.1.0

func (t *DocTabs) RemoveIndex(index int)

RemoveIndex removes tab by index.

func (*DocTabs) Select added in v2.1.0

func (t *DocTabs) Select(item *TabItem)

Select sets the specified TabItem to be selected and its content visible.

func (*DocTabs) SelectIndex added in v2.1.0

func (t *DocTabs) SelectIndex(index int)

SelectIndex sets the TabItem at the specific index to be selected and its content visible.

func (*DocTabs) Selected added in v2.1.0

func (t *DocTabs) Selected() *TabItem

Selected returns the currently selected TabItem.

func (*DocTabs) SelectedIndex added in v2.1.0

func (t *DocTabs) SelectedIndex() int

SelectedIndex returns the index of the currently selected TabItem.

func (*DocTabs) SetItems added in v2.1.0

func (t *DocTabs) SetItems(items []*TabItem)

SetItems sets the containers items and refreshes.

func (*DocTabs) SetTabLocation added in v2.1.0

func (t *DocTabs) SetTabLocation(l TabLocation)

SetTabLocation sets the location of the tab bar

func (*DocTabs) Show added in v2.1.0

func (t *DocTabs) Show()

Show this widget, if it was previously hidden

Implements: fyne.CanvasObject

type InnerWindow added in v2.5.0

type InnerWindow struct {
	widget.BaseWidget

	CloseIntercept                                      func()                `json:"-"`
	OnDragged, OnResized                                func(*fyne.DragEvent) `json:"-"`
	OnMinimized, OnMaximized, OnTappedBar, OnTappedIcon func()                `json:"-"`
	Icon                                                fyne.Resource
	// contains filtered or unexported fields
}

InnerWindow defines a container that wraps content in a window border - that can then be placed inside a regular container/canvas.

Since: 2.5

func NewInnerWindow added in v2.5.0

func NewInnerWindow(title string, content fyne.CanvasObject) *InnerWindow

NewInnerWindow creates a new window border around the given `content`, displaying the `title` along the top. This will behave like a normal contain and will probably want to be added to a `MultipleWindows` parent.

Since: 2.5

func (*InnerWindow) Close added in v2.5.0

func (w *InnerWindow) Close()

func (*InnerWindow) CreateRenderer added in v2.5.0

func (w *InnerWindow) CreateRenderer() fyne.WidgetRenderer

func (*InnerWindow) SetContent added in v2.5.0

func (w *InnerWindow) SetContent(obj fyne.CanvasObject)

func (*InnerWindow) SetPadded added in v2.5.0

func (w *InnerWindow) SetPadded(pad bool)

func (*InnerWindow) SetTitle added in v2.5.0

func (w *InnerWindow) SetTitle(title string)

type MultipleWindows added in v2.5.0

type MultipleWindows struct {
	widget.BaseWidget

	Windows []*InnerWindow
	// contains filtered or unexported fields
}

MultipleWindows is a container that handles multiple `InnerWindow` containers. Each inner window can be dragged, resized and the stacking will change when the title bar is tapped.

Since: 2.5

func NewMultipleWindows added in v2.5.0

func NewMultipleWindows(wins ...*InnerWindow) *MultipleWindows

NewMultipleWindows creates a new `MultipleWindows` container to manage many inner windows. The initial window list is passed optionally to this constructor function. You can add new more windows to this container by calling `Add` or updating the `Windows` field and calling `Refresh`.

Since: 2.5

func (*MultipleWindows) Add added in v2.5.0

func (m *MultipleWindows) Add(w *InnerWindow)

func (*MultipleWindows) CreateRenderer added in v2.5.0

func (m *MultipleWindows) CreateRenderer() fyne.WidgetRenderer

func (*MultipleWindows) Refresh added in v2.5.0

func (m *MultipleWindows) Refresh()

type Scroll

type Scroll = widget.Scroll

Scroll defines a container that is smaller than the Content. The Offset is used to determine the position of the child widgets within the container.

Since: 1.4

func NewHScroll

func NewHScroll(content fyne.CanvasObject) *Scroll

NewHScroll create a scrollable parent wrapping the specified content. Note that this may cause the MinSize.Width to be smaller than that of the passed object.

Since: 1.4

func NewScroll

func NewScroll(content fyne.CanvasObject) *Scroll

NewScroll creates a scrollable parent wrapping the specified content. Note that this may cause the MinSize to be smaller than that of the passed object.

Since: 1.4

func NewVScroll

func NewVScroll(content fyne.CanvasObject) *Scroll

NewVScroll a scrollable parent wrapping the specified content. Note that this may cause the MinSize.Height to be smaller than that of the passed object.

Since: 1.4

type ScrollDirection

type ScrollDirection = widget.ScrollDirection

ScrollDirection represents the directions in which a Scroll container can scroll its child content.

Since: 1.4

type Split

type Split struct {
	widget.BaseWidget
	Offset     float64
	Horizontal bool
	Leading    fyne.CanvasObject
	Trailing   fyne.CanvasObject
}

Split defines a container whose size is split between two children.

Since: 1.4

func NewHSplit

func NewHSplit(leading, trailing fyne.CanvasObject) *Split

NewHSplit creates a horizontally arranged container with the specified leading and trailing elements. A vertical split bar that can be dragged will be added between the elements.

Since: 1.4

func NewVSplit

func NewVSplit(top, bottom fyne.CanvasObject) *Split

NewVSplit creates a vertically arranged container with the specified top and bottom elements. A horizontal split bar that can be dragged will be added between the elements.

Since: 1.4

func (*Split) CreateRenderer

func (s *Split) CreateRenderer() fyne.WidgetRenderer

CreateRenderer is a private method to Fyne which links this widget to its renderer

func (*Split) ExtendBaseWidget deprecated added in v2.0.1

func (s *Split) ExtendBaseWidget(wid fyne.Widget)

ExtendBaseWidget is used by an extending widget to make use of BaseWidget functionality.

Deprecated: Support for extending containers is being removed

func (*Split) SetOffset

func (s *Split) SetOffset(offset float64)

SetOffset sets the offset (0.0 to 1.0) of the Split divider. 0.0 - Leading is min size, Trailing uses all remaining space. 0.5 - Leading & Trailing equally share the available space. 1.0 - Trailing is min size, Leading uses all remaining space.

type TabItem

type TabItem struct {
	Text    string
	Icon    fyne.Resource
	Content fyne.CanvasObject
	// contains filtered or unexported fields
}

TabItem represents a single view in a tab view. The Text and Icon are used for the tab button and the Content is shown when the corresponding tab is active.

Since: 1.4

func NewTabItem

func NewTabItem(text string, content fyne.CanvasObject) *TabItem

NewTabItem creates a new item for a tabbed widget - each item specifies the content and a label for its tab.

Since: 1.4

func NewTabItemWithIcon

func NewTabItemWithIcon(text string, icon fyne.Resource, content fyne.CanvasObject) *TabItem

NewTabItemWithIcon creates a new item for a tabbed widget - each item specifies the content and a label with an icon for its tab.

Since: 1.4

func (*TabItem) Disabled added in v2.3.0

func (ti *TabItem) Disabled() bool

Disabled returns whether or not the TabItem is disabled.

Since: 2.3

type TabLocation

type TabLocation int

TabLocation is the location where the tabs of a tab container should be rendered

Since: 1.4

const (
	TabLocationTop TabLocation = iota
	TabLocationLeading
	TabLocationBottom
	TabLocationTrailing
)

TabLocation values

type ThemeOverride added in v2.5.0

type ThemeOverride struct {
	widget.BaseWidget

	Content fyne.CanvasObject
	Theme   fyne.Theme
	// contains filtered or unexported fields
}

ThemeOverride is a container where the child widgets are themed by the specified theme. Containers will be traversed and all child widgets will reflect the theme in this container. This should be used sparingly to avoid a jarring user experience.

Since: 2.5

func NewThemeOverride added in v2.5.0

func NewThemeOverride(obj fyne.CanvasObject, th fyne.Theme) *ThemeOverride

NewThemeOverride provides a container where the child widgets are themed by the specified theme. Containers will be traversed and all child widgets will reflect the theme in this container. This should be used sparingly to avoid a jarring user experience.

If the content `obj` of this theme override is a container and items are later added to the container or any sub-containers ensure that you call `Refresh()` on this `ThemeOverride` to ensure the new items match the theme.

Since: 2.5

func (*ThemeOverride) CreateRenderer added in v2.5.0

func (t *ThemeOverride) CreateRenderer() fyne.WidgetRenderer

func (*ThemeOverride) Refresh added in v2.5.0

func (t *ThemeOverride) Refresh()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL