cu

package module
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 13 Imported by: 0

README

CU

A Gioui GUI widget library based on JetBrains Int UI kit.

Warning: The API is still subject to changes

See the examples folder for some examples.

example.png

Todo

  • Implement radio buttons
  • Checkbox cannot be disabled yet
  • Implement Dark mode

Credits

The design of CU is based on the Jetbrains Int UI kit which is licensed under CC BY 4.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Align

func Align(a layout.Alignment) func(w *Flex, t Theme)

func Centered

func Centered(l layout.Widget) layout.Widget

func Gap

func Gap(s Unit) func(w *Flex, t Theme)

func HSpacer

func HSpacer(m unit.Dp) layout.Widget

func Spacing

func Spacing(s layout.Spacing) func(w *Flex, t Theme)

func VSpacer

func VSpacer(m unit.Dp) layout.Widget

Types

type C

type C = layout.Context

type CuFlexOption

type CuFlexOption func(w *Flex, t Theme)

type D

type D = layout.Dimensions

type Flex

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

func (Flex) Flexed

func (f Flex) Flexed(weight float32, w layout.Widget) Flex

func (Flex) FlexedIf added in v0.0.14

func (f Flex) FlexedIf(condition bool, weight float32, w layout.Widget) Flex

func (Flex) Layout

func (f Flex) Layout(gtx layout.Context) layout.Dimensions

func (Flex) Rigid

func (f Flex) Rigid(w layout.Widget) Flex

func (Flex) RigidIf added in v0.0.4

func (f Flex) RigidIf(condition bool, w layout.Widget) Flex

type Fonts

type Fonts struct {
	SansSerif font.Font
	Monospace font.Font
}

type Palette

type Palette struct {
	Text          color.NRGBA
	TextSecondary color.NRGBA

	// The primary highlight color
	Primary       color.NRGBA
	ControlBorder color.NRGBA
}

type TextOptions

type TextOptions struct {
	Size     unit.Sp
	Bold     bool
	Centered bool
	Color    *color.NRGBA
	Truncate bool
}

type Theme

type Theme struct {
	Color          Palette
	TextSize       unit.Sp
	TextSizeMedium unit.Sp
	TextSizeH1     unit.Sp
	TextSizeH2     unit.Sp
	Shaper         *text.Shaper
	Font           Fonts

	LineHeightH1 unit.Sp
	LineHeightH2 unit.Sp
}

func NewDefaultTheme

func NewDefaultTheme() *Theme

func NewTheme

func NewTheme(fonts []font.FontFace) *Theme

func (Theme) Background

func (t Theme) Background(gtx layout.Context)

func (Theme) FlexColumn

func (t Theme) FlexColumn(options ...CuFlexOption) Flex

func (Theme) FlexRow

func (t Theme) FlexRow(options ...CuFlexOption) Flex

func (Theme) H1

func (t Theme) H1(label string) layout.Widget

func (Theme) H2 added in v0.0.4

func (t Theme) H2(label string) layout.Widget

func (Theme) Hr

func (t Theme) Hr() layout.Widget

func (Theme) M

func (t Theme) M(u Unit, w layout.Widget) layout.Widget

M adds margin at each side of the given widget

func (Theme) Mb

func (t Theme) Mb(u Unit, w layout.Widget) layout.Widget

Mb adds margin at the bottom

func (Theme) Mh

func (t Theme) Mh(u Unit, w layout.Widget) layout.Widget

Mh adds horizontal margin, at the left and right side

func (Theme) Mv

func (t Theme) Mv(u Unit, w layout.Widget) layout.Widget

Mv adds vertical margin, at the top and bottom side

func (Theme) Paragraph

func (t Theme) Paragraph(label string) layout.Widget

func (Theme) Text

func (t Theme) Text(label string, opts ...TextOptions) layout.Widget

type Unit

type Unit interface {
	Dp(t Theme) unit.Dp
}
var (
	XS Unit = Scaled(0.25)
	S  Unit = Scaled(0.5)
	M  Unit = Scaled(1)
	L  Unit = Scaled(1.33)
)

func Scaled

func Scaled(n float32) Unit

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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