uik

package module
v0.0.0-...-c5bdd4e Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

README

go.uik GoDoc Go Report Card codebeat badge

A concurrent UI kit written in pure go.

This project is in its infancy. Feel free to experiment, but don't expect too much yet.

There was a google group dedicated to this project.


###A concurrent UI kit

Every component visible on the screen is backed by a Block. Every collection of components is backed by a Foundation. All Blocks are built upon a Foundation, but a Foundation itself is made up of a Block, which must itself be laid upon a Foundation. The only exception to this rule is the WindowFoundation.

All communication between Foundations, Blocks and the widgets and layouts composed of them is done via non-blocking channel communication.

While this is a break from the typical polymorphism approach, the result is that a component that stalls while processing input cannot get in the way of other components.

History

This project was closed, but I reopen it. Original repo was here.

Documentation

Index

Constants

View Source
const FrameDelay = 16 * time.Millisecond

FrameDelay is how long the window will wait, after receiving an invalidation, to redraw the window. This gives related updates a chance to get ready. If they take too long, they'll just have to wait for the next frame.

View Source
const ReportIDs = false

Variables

View Source
var DefaultFontData = draw2d.FontData{
	Name:   "Fira Sans Light",
	Family: draw2d.FontFamilySans,
	Style:  draw2d.FontStyleNormal,
}
View Source
var StartTime = time.Now()
View Source
var WindowGenerator func(parent wde.Window, width, height int) (window wde.Window, err error)

Functions

func ClearPaint

func ClearPaint(gc draw2d.GraphicContext)

func GetFontHeight

func GetFontHeight(fd draw2d.FontData, size float64) (height float64)

func RectangleForRect

func RectangleForRect(b geom.Rect) (r image.Rectangle)

func RegisterPaint

func RegisterPaint(path string, dg PaintGen)

func RenderString

func RenderString(text string, fd draw2d.FontData, size float64, color color.Color) (buffer image.Image)

func Report

func Report(args ...interface{})

func SubscriptionQueue

func SubscriptionQueue(cap int) (in chan<- interface{}, out <-chan interface{}, sub chan<- Subscription)

func TimeSinceStart

func TimeSinceStart() (dur time.Duration)

func ZeroRGBA

func ZeroRGBA(rgba *image.RGBA)

Types

type Block

type Block struct {
	ID BlockID

	Parent *Foundation

	UserEventsIn DropChan
	UserEvents   <-chan interface{}

	ResizeEvents ResizeChan

	Subscribe chan<- Subscription

	Drawer

	Paint func(gc draw2d.GraphicContext)

	Invalidations InvalidationChan
	SizeHints     SizeHintChan

	HasKeyFocus bool

	// size of block
	Size geom.Coord
	// contains filtered or unexported fields
}

The Block type is a basic unit that can receive events and draw itself.

This struct essentially defines an interface, except a synchronous interface based on channels rather than an asynchronous interface based on method calls.

func (*Block) Bounds

func (b *Block) Bounds() geom.Rect

func (*Block) DoPaint

func (b *Block) DoPaint(gc draw2d.GraphicContext)

func (*Block) DoResizeEvent

func (b *Block) DoResizeEvent(e ResizeEvent)

func (*Block) Draw

func (b *Block) Draw(buffer draw.Image, invalidRects RectSet)

func (*Block) HandleEvent

func (b *Block) HandleEvent(e interface{})

func (*Block) Initialize

func (b *Block) Initialize()

func (*Block) Invalidate

func (b *Block) Invalidate(areas ...geom.Rect)

func (*Block) SetSizeHint

func (b *Block) SetSizeHint(sh SizeHint)

type BlockID

type BlockID int

type BlockInvalidation

type BlockInvalidation struct {
	Invalidation
	Block *Block
}

type BlockSizeHint

type BlockSizeHint struct {
	SizeHint
	Block *Block
}

type CloseEvent

type CloseEvent struct {
	Event
	wde.CloseEvent
}

type Drawer

type Drawer interface {
	Draw(buffer draw.Image, invalidRects RectSet)
}

type DropChan

type DropChan chan<- interface{}

func (DropChan) SendOrDrop

func (ch DropChan) SendOrDrop(e interface{})

type Event

type Event struct {
	When time.Duration
}

type Filter

type Filter func(e interface{}) (accept, done bool)

type Foundation

type Foundation struct {
	Block

	DrawOp draw.Op

	Children      map[*Block]bool
	ChildrenHints map[*Block]SizeHint

	BlockSizeHints chan BlockSizeHint

	BlockInvalidations chan BlockInvalidation

	DragOriginBlocks map[wde.Button][]*Block

	// this block currently has keyboard priority
	KeyFocus *Block
	// contains filtered or unexported fields
}

The foundation type is for channeling events to children, and passing along draw calls.

func (*Foundation) AddBlock

func (f *Foundation) AddBlock(b *Block)

func (*Foundation) BlocksForCoord

func (f *Foundation) BlocksForCoord(p geom.Coord) (bs []*Block)

func (*Foundation) DoBlockInvalidation

func (f *Foundation) DoBlockInvalidation(e BlockInvalidation)

func (*Foundation) DoCloseEvent

func (f *Foundation) DoCloseEvent(e CloseEvent)

func (*Foundation) DoKeyEvent

func (f *Foundation) DoKeyEvent(e interface{})

func (*Foundation) DoKeyFocusEvent

func (f *Foundation) DoKeyFocusEvent(e KeyFocusEvent)

func (*Foundation) DoMouseDownEvent

func (f *Foundation) DoMouseDownEvent(e MouseDownEvent)

func (*Foundation) DoMouseDraggedEvent

func (f *Foundation) DoMouseDraggedEvent(e MouseDraggedEvent)

func (*Foundation) DoMouseMovedEvent

func (f *Foundation) DoMouseMovedEvent(e MouseMovedEvent)

func (*Foundation) DoMouseUpEvent

func (f *Foundation) DoMouseUpEvent(e MouseUpEvent)

func (*Foundation) Draw

func (f *Foundation) Draw(buffer draw.Image, invalidRects RectSet)

func (*Foundation) HandleEvent

func (f *Foundation) HandleEvent(e interface{})

func (*Foundation) HandleEvents

func (f *Foundation) HandleEvents()

dispense events to children, as appropriate

func (*Foundation) Initialize

func (f *Foundation) Initialize()

func (*Foundation) InvokeOnBlocksUnder

func (f *Foundation) InvokeOnBlocksUnder(p geom.Coord, foo func(*Block))

func (*Foundation) KeyFocusRequest

func (f *Foundation) KeyFocusRequest(e KeyFocusRequest)

func (*Foundation) PlaceBlock

func (f *Foundation) PlaceBlock(b *Block, bounds geom.Rect)

func (*Foundation) RemoveBlock

func (f *Foundation) RemoveBlock(b *Block)

type Invalidation

type Invalidation struct {
	Bounds []geom.Rect
}

type InvalidationChan

type InvalidationChan chan Invalidation

func (InvalidationChan) Stack

func (ch InvalidationChan) Stack(e Invalidation)

type KeyDownEvent

type KeyDownEvent struct {
	Event
	wde.KeyDownEvent
}

type KeyFocusChan

type KeyFocusChan chan *Block

func (KeyFocusChan) Stack

func (ch KeyFocusChan) Stack(b *Block)

type KeyFocusEvent

type KeyFocusEvent struct {
	Focus bool
}

type KeyFocusRequest

type KeyFocusRequest struct {
	Block *Block
}

type KeyTypedEvent

type KeyTypedEvent struct {
	Event
	wde.KeyTypedEvent
}

type KeyUpEvent

type KeyUpEvent struct {
	Event
	wde.KeyUpEvent
}

type MouseDownEvent

type MouseDownEvent struct {
	Event
	wde.MouseDownEvent
	MouseLocator
}

type MouseDraggedEvent

type MouseDraggedEvent struct {
	Event
	wde.MouseDraggedEvent
	MouseLocator
	From geom.Coord
}

type MouseEnteredEvent

type MouseEnteredEvent struct {
	Event
	wde.MouseEnteredEvent
	MouseLocator
	From geom.Coord
}

type MouseEvent

type MouseEvent interface {
	Where() geom.Coord
}

type MouseExitedEvent

type MouseExitedEvent struct {
	Event
	wde.MouseExitedEvent
	MouseLocator
	From geom.Coord
}

type MouseLocator

type MouseLocator struct {
	Loc geom.Coord
}

func (*MouseLocator) Translate

func (e *MouseLocator) Translate(offset geom.Coord)

func (*MouseLocator) Where

func (e *MouseLocator) Where() geom.Coord

type MouseMovedEvent

type MouseMovedEvent struct {
	Event
	wde.MouseMovedEvent
	MouseLocator
	From geom.Coord
}

type MouseUpEvent

type MouseUpEvent struct {
	Event
	wde.MouseUpEvent
	MouseLocator
}

type PaintFunc

type PaintFunc func(draw2d.GraphicContext)

func LookupPaint

func LookupPaint(path string, x interface{}) (pf PaintFunc)

type PaintGen

type PaintGen func(interface{}) PaintFunc

type RectSet

type RectSet []geom.Rect

func (RectSet) Intersection

func (rs RectSet) Intersection(r geom.Rect) (nrs RectSet)

func (RectSet) Intersects

func (rs RectSet) Intersects(r geom.Rect) bool

func (RectSet) IntersectsStrict

func (rs RectSet) IntersectsStrict(r geom.Rect) bool

func (RectSet) Translate

func (rs RectSet) Translate(offset geom.Coord) (nrs RectSet)

type ResizeChan

type ResizeChan chan ResizeEvent

func (ResizeChan) Stack

func (ch ResizeChan) Stack(e ResizeEvent)

type ResizeEvent

type ResizeEvent struct {
	Size geom.Coord
}

type SizeHint

type SizeHint struct {
	MinSize, PreferredSize, MaxSize geom.Coord
}

type SizeHintChan

type SizeHintChan chan SizeHint

func (SizeHintChan) Stack

func (ch SizeHintChan) Stack(sh SizeHint)

type Subscription

type Subscription struct {
	Filter Filter
	Ch     chan<- interface{}
}

type WindowFoundation

type WindowFoundation struct {
	Foundation
	W wde.Window
	// contains filtered or unexported fields
}

A foundation that wraps a wde.Window

func NewWindow

func NewWindow(parent wde.Window, width, height int) (wf *WindowFoundation, err error)

func (*WindowFoundation) HandleEvents

func (wf *WindowFoundation) HandleEvents()

func (*WindowFoundation) Initialize

func (wf *WindowFoundation) Initialize()

func (*WindowFoundation) SetPane

func (wf *WindowFoundation) SetPane(b *Block)

func (*WindowFoundation) Show

func (wf *WindowFoundation) Show()

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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