duitx

package
v0.0.0-...-203cdba Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InlineBlock = iota // default
	Block              // always start a new line
	Inline             // flow inline but ignore margin, width and height
	Flex
)
View Source
const (
	Row = iota + 1
	Column
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Box

type Box struct {
	Kids       []*duit.Kid // Kids and UIs in this box.
	Reverse    bool        // Lay out children from bottom to top. First kid will be at the bottom.
	Margin     duit.Space  // In lowDPI pixels, will be adjusted for highDPI screens.
	Padding    duit.Space  // Padding inside box, so children don't touch the sides; in lowDPI pixels, also adjusted for highDPI screens.
	Valign     duit.Valign // How to align children on a line.
	Width      int         // 0 means dynamic (as much as needed), -1 means full width, >0 means that exact amount of lowDPI pixels.
	Height     int         // 0 means dynamic (as much as needed), -1 means full height, >0 means that exact amount of lowDPI pixels.
	MaxWidth   int         // if >0, the max number of lowDPI pixels that will be used.
	ContentBox bool        // Use ContentBox (BorderBox by default)
	Disp       Display
	Dir        Dir
	Background *draw.Image `json:"-"` // Background for this box, instead of default duit background.
	// contains filtered or unexported fields
}

Box keeps elements on a line as long as they fit, then moves on to the next line.

func NewBox

func NewBox(uis ...duit.UI) *Box

NewBox returns a box containing all uis in its Kids field.

func NewReverseBox

func NewReverseBox(uis ...duit.UI) *Box

NewReverseBox returns a box containing all uis in original order in its Kids field, with the Reverse field set.

func (*Box) Display

func (ui *Box) Display() Display

func (*Box) Draw

func (ui *Box) Draw(dui *duit.DUI, self *duit.Kid, img *draw.Image, orig image.Point, m draw.Mouse, force bool)

func (*Box) FirstFocus

func (ui *Box) FirstFocus(dui *duit.DUI, self *duit.Kid) *image.Point

func (*Box) FlexDir

func (ui *Box) FlexDir() Dir

func (*Box) Focus

func (ui *Box) Focus(dui *duit.DUI, self *duit.Kid, o duit.UI) *image.Point

func (*Box) Key

func (ui *Box) Key(dui *duit.DUI, self *duit.Kid, k rune, m draw.Mouse, orig image.Point) (r duit.Result)

func (*Box) Layout

func (ui *Box) Layout(dui *duit.DUI, self *duit.Kid, sizeAvail image.Point, force bool)

func (*Box) Mark

func (ui *Box) Mark(self *duit.Kid, o duit.UI, forLayout bool) (marked bool)

func (*Box) Mouse

func (ui *Box) Mouse(dui *duit.DUI, self *duit.Kid, m draw.Mouse, origM draw.Mouse, orig image.Point) (r duit.Result)

func (*Box) Print

func (ui *Box) Print(self *duit.Kid, indent int)

type Boxable

type Boxable interface {
	Display() Display
	FlexDir() Dir
}

type Dir

type Dir int

type Display

type Display int

type Grid

type Grid struct {
	Kids       []*duit.Kid // Holds UIs in the grid, per row.
	Columns    int         // Number of columns.
	Rows       int         // Number of rows.
	RowSpans   []int
	ColSpans   []int
	Valign     []duit.Valign // Vertical alignment per column.
	Halign     []duit.Halign // Horizontal alignment per column.
	Padding    []duit.Space  // Padding in lowDPI pixels per column.
	Width      int           // -1 means full width, 0 means automatic width, >0 means exactly that many lowDPI pixels.
	Background *draw.Image   `json:"-"` // Background color.
	// contains filtered or unexported fields
}

Grid lays out other duit.UIs in a table-like grid.

func (*Grid) Draw

func (ui *Grid) Draw(dui *duit.DUI, self *duit.Kid, img *draw.Image, orig image.Point, m draw.Mouse, force bool)

func (*Grid) FirstFocus

func (ui *Grid) FirstFocus(dui *duit.DUI, self *duit.Kid) *image.Point

func (*Grid) Focus

func (ui *Grid) Focus(dui *duit.DUI, self *duit.Kid, o duit.UI) *image.Point

func (*Grid) Key

func (ui *Grid) Key(dui *duit.DUI, self *duit.Kid, k rune, m draw.Mouse, orig image.Point) (r duit.Result)

func (*Grid) Layout

func (ui *Grid) Layout(dui *duit.DUI, self *duit.Kid, sizeAvail image.Point, force bool)

func (*Grid) Mark

func (ui *Grid) Mark(self *duit.Kid, o duit.UI, forLayout bool) (marked bool)

func (*Grid) Mouse

func (ui *Grid) Mouse(dui *duit.DUI, self *duit.Kid, m draw.Mouse, origM draw.Mouse, orig image.Point) (r duit.Result)

func (*Grid) Print

func (ui *Grid) Print(self *duit.Kid, indent int)

type Label

type Label struct {
	Text     string                // Text to draw, wrapped at glyph boundary.
	Font     *draw.Font            `json:"-"` // For drawing text.
	Click    func() (e duit.Event) `json:"-"` // Called on button1 click.
	Selected bool
	// contains filtered or unexported fields
}

Label draws multiline text in a single font.:

Keys:

cmd-c, copy text
\n, like button1 click, calls the Click function

func (*Label) Draw

func (ui *Label) Draw(dui *duit.DUI, self *duit.Kid, img *draw.Image, orig image.Point, m draw.Mouse, force bool)

func (*Label) FirstFocus

func (ui *Label) FirstFocus(dui *duit.DUI, self *duit.Kid) *image.Point

func (*Label) Focus

func (ui *Label) Focus(dui *duit.DUI, self *duit.Kid, o duit.UI) *image.Point

func (*Label) Key

func (ui *Label) Key(dui *duit.DUI, self *duit.Kid, k rune, m draw.Mouse, orig image.Point) (r duit.Result)

func (*Label) Layout

func (ui *Label) Layout(dui *duit.DUI, self *duit.Kid, sizeAvail image.Point, force bool)

func (*Label) Mark

func (ui *Label) Mark(self *duit.Kid, o duit.UI, forLayout bool) (marked bool)

func (*Label) Mouse

func (ui *Label) Mouse(dui *duit.DUI, self *duit.Kid, m draw.Mouse, origM draw.Mouse, orig image.Point) (r duit.Result)

func (*Label) Print

func (ui *Label) Print(self *duit.Kid, indent int)

func (*Label) Rect

func (ui *Label) Rect() draw.Rectangle

type Scroll

type Scroll struct {
	Kid    duit.Kid
	Height int // < 0 means full height, 0 means as much as necessary, >0 means exactly that many lowdpi pixels

	Offset int // current scroll offset in pixels
	// contains filtered or unexported fields
}

Scroll shows a part of its single child, typically a box, and lets you scroll the content.

func NewScroll

func NewScroll(dui *duit.DUI, ui duit.UI) *Scroll

NewScroll returns a full-height scroll bar containing ui.

func (*Scroll) Draw

func (ui *Scroll) Draw(dui *duit.DUI, self *duit.Kid, img *draw.Image, orig image.Point, m draw.Mouse, force bool)

func (*Scroll) FirstFocus

func (ui *Scroll) FirstFocus(dui *duit.DUI, self *duit.Kid) *image.Point

func (*Scroll) Focus

func (ui *Scroll) Focus(dui *duit.DUI, self *duit.Kid, o duit.UI) *image.Point

func (*Scroll) Free

func (ui *Scroll) Free()

func (*Scroll) Key

func (ui *Scroll) Key(dui *duit.DUI, self *duit.Kid, k rune, m draw.Mouse, orig image.Point) (r duit.Result)

func (*Scroll) Layout

func (ui *Scroll) Layout(dui *duit.DUI, self *duit.Kid, sizeAvail image.Point, force bool)

func (*Scroll) Mark

func (ui *Scroll) Mark(self *duit.Kid, o duit.UI, forLayout bool) (marked bool)

func (*Scroll) Mouse

func (ui *Scroll) Mouse(dui *duit.DUI, self *duit.Kid, m draw.Mouse, origM draw.Mouse, orig image.Point) (r duit.Result)

func (*Scroll) Print

func (ui *Scroll) Print(self *duit.Kid, indent int)

Jump to

Keyboard shortcuts

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