layout

package
v0.0.0-...-d5a0809 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: BSD-3-Clause Imports: 7 Imported by: 2

Documentation

Overview

Package layout contains community extensions for Fyne layouts

Index

Constants

View Source
const (
	// SMALL is the smallest breakpoint (mobile vertical).
	SMALL responsiveBreakpoint = 576

	// MEDIUM is the medium breakpoint (mobile horizontal, tablet vertical).
	MEDIUM responsiveBreakpoint = 768

	// LARGE is the largest breakpoint (tablet horizontal, small desktop).
	LARGE responsiveBreakpoint = 992

	// XLARGE is the largest breakpoint (large desktop).
	XLARGE responsiveBreakpoint = 1200

	// SM is an alias for SMALL
	SM responsiveBreakpoint = SMALL

	// MD is an alias for MEDIUM
	MD responsiveBreakpoint = MEDIUM

	// LG is an alias for LARGE
	LG responsiveBreakpoint = LARGE

	// XL is an alias for XLARGE
	XL responsiveBreakpoint = XLARGE
)

Variables

This section is empty.

Functions

func NewResponsiveLayout

func NewResponsiveLayout(o ...fyne.CanvasObject) *fyne.Container

NewResponsiveLayout return a responsive layout that will adapt objects with the responsive rules. To configure the rule, each object could be encapsulated by a "Responsive" object.

Example:

container := NewResponsiveLayout(
    Responsive(label, 1, .5, .25),  // 100% for small, 50% for medium, 25% for large
    Responsive(button, 1, .5, .25), // ...
    label2,                         // this will be placed and resized with default behaviors
                                    // => 1, 1, 1
)

func Responsive

func Responsive(object fyne.CanvasObject, breakpointRatio ...float32) fyne.CanvasObject

Responsive register the object with a responsive configuration. The optional ratios must be 0 < ratio <= 1 and passed in this order:

Responsive(object, smallRatio, mediumRatio, largeRatio, xlargeRatio)

They are set to previous value if a value is not passed, or 1.0 if there is no previous value. The returned object is not modified.

Types

type HPortion

type HPortion struct {
	Portions []float64
}

HPortion allows the canvas objects to be divided into portions of the width. The length of the Portions slice needs to be equal to the amount of canvas objects.

func NewHPortion

func NewHPortion(Portions []float64) *HPortion

NewHPortion creates a layout that partitions objects horizontally taking up as large of a portion of the space as defined by the given slice. The length of the Portions slice needs to be equal to the amount of objects.

func (*HPortion) Layout

func (p *HPortion) Layout(objects []fyne.CanvasObject, size fyne.Size)

Layout sets the size and position of the canvas objects.

func (*HPortion) MinSize

func (p *HPortion) MinSize(objects []fyne.CanvasObject) fyne.Size

MinSize calculates the minimum required size to fit all objects. It is equal to the largest width MinSize divided by the corresponding portion.

type ResponsiveLayout

type ResponsiveLayout struct{}

ResponsiveLayout is the layout that will adapt objects with the responsive rules. See NewResponsiveLayout for details.

func (*ResponsiveLayout) Layout

func (resp *ResponsiveLayout) Layout(objects []fyne.CanvasObject, containerSize fyne.Size)

Layout will place the size and place the objects following the configured reponsive rules.

Implements: fyne.Layout

func (*ResponsiveLayout) MinSize

func (resp *ResponsiveLayout) MinSize(objects []fyne.CanvasObject) fyne.Size

MinSize return the minimum size ot the layout.

Implements: fyne.Layout

type VPortion

type VPortion struct {
	Portions []float64
}

VPortion allows the canvas objects to be divided into portions of the height. The length of the Portions slice needs to be equal to the amount of canvas objects.

func NewVPortion

func NewVPortion(portion []float64) *VPortion

NewVPortion creates a layout that partitions objects verticaly taking up as large of a portion of the space as defined by the given slice. The length of the Portions slice needs to be equal to the amount of objects.

func (*VPortion) Layout

func (p *VPortion) Layout(objects []fyne.CanvasObject, size fyne.Size)

Layout sets the size and position of the canvas objects.

func (*VPortion) MinSize

func (p *VPortion) MinSize(objects []fyne.CanvasObject) fyne.Size

MinSize calculates the minimum required size to fit all objects. It is equal to the largest height MinSize divided by the corresponding portion.

Jump to

Keyboard shortcuts

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