layout

package
v0.0.0-...-ad46cc6 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocate

type Allocate func(w gtk.Widgetter, width int, height int, baseline int)

Allocate is called to allocate the size of the widget.

type CustomLayout

type CustomLayout struct {
	// contains filtered or unexported fields
}

CustomLayout is a custom layout manager.

Example
layout := layout.New(layout.Funcs{
	RequestMode: func(w2 gtk.Widgetter) gtk.SizeRequestMode {
		return gtk.SizeRequestConstantSize
	},
	Measure: func(w2 gtk.Widgetter, orientation gtk.Orientation, forSize int) (
		minimum int,
		natural int,
		minimumBaseline int,
		naturalBaseline int,
	) {
		w := gtk.BaseWidget(w2)
		minimum, natural, minimumBaseline, naturalBaseline = w.Measure(orientation, forSize)
		if minimum < 100 {
			minimum = 100
		}
		return minimum, natural, minimumBaseline, naturalBaseline
	},
	Allocate: func(w2 gtk.Widgetter, width int, height int, baseline int) {
		w := gtk.BaseWidget(w2)
		w.Allocate(width, height, baseline, nil)
	},
})

label := gtk.NewLabel("Hello, world!")
layout.SetForWidget(label)

w := gtk.NewWindow()
w.SetChild(label)
w.Show()
Output:

func New

func New(funcs Funcs) *CustomLayout

New creates a new custom layout manager.

func (*CustomLayout) SetForWidget

func (l *CustomLayout) SetForWidget(w gtk.Widgetter)

SetForWidget sets the layout manager for the given widget. It handles the initialization of the layout manager for the widget.

type Funcs

type Funcs struct {
	RequestMode RequestModeFunc
	Measure     MeasureFunc
	Allocate    Allocate
}

Funcs is a box of functions for the layout manager.

type MeasureFunc

type MeasureFunc func(w gtk.Widgetter, orientation gtk.Orientation, forSize int) (
	minimum int,
	natural int,
	minimumBaseline int,
	naturalBaseline int)

Measure is called to measure the size of the widget.

type RequestModeFunc

type RequestModeFunc func(w gtk.Widgetter) gtk.SizeRequestMode

RequestModeFunc queries the widget for its preferred size request mode.

Jump to

Keyboard shortcuts

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