framework

package
v0.0.0-...-311b70d Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2018 License: BSD-3-Clause Imports: 6 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BubbleOverlay

type BubbleOverlay interface {
	Control
	Show(control Control, target math.Point)
	Hide()
}

type Button

type Button interface {
	LinearLayout
	Text() string
	SetText(string)
	Type() ButtonType
	SetType(ButtonType)
	IsChecked() bool
	SetChecked(bool)
}

type ButtonType

type ButtonType int
const (
	PushButton ButtonType = iota
	ToggleButton
)

type Canvas

type Canvas interface {
	Size() math.Size
	IsComplete() bool
	Complete()
	Push()
	Pop()
	AddClip(math.Rect)
	Clear(tools.Color)
	DrawCanvas(c Canvas, position math.Point)
	DrawTexture(t Texture, bounds math.Rect)
	DrawRunes(font Font, runes []rune, points []math.Point, color tools.Color)
	DrawLines(Polygon, tools.Pen)
	DrawPolygon(Polygon, tools.Pen, tools.Brush)
	DrawRect(math.Rect, tools.Brush)
	DrawRoundedRect(rect math.Rect, tl, tr, bl, br float32, p tools.Pen, b tools.Brush)
}

type Child

type Child struct {
	Control Control
	Offset  math.Point
}

func (*Child) Bounds

func (c *Child) Bounds() math.Rect

Bounds returns the Child bounds relative to the parent.

func (*Child) Layout

func (c *Child) Layout(rect math.Rect)

Layout sets the Child size and offset relative to the parent. Layout should only be called by the Child's parent.

func (*Child) String

func (c *Child) String() string

String returns a string describing the child type and bounds.

type Children

type Children []*Child

Children is a list of Child pointers.

func (Children) Find

func (c Children) Find(control Control) *Child

Find returns and returns the Child pointer for the given Control, or nil if the child is not in this Children list.

func (Children) IndexOf

func (c Children) IndexOf(control Control) int

IndexOf returns and returns the index of the child control, or -1 if the child is not in this Children list.

func (Children) String

func (c Children) String() string

String returns a string describing the child type and bounds.

type CodeEditor

type CodeEditor interface {
}

type CodeSuggestion

type CodeSuggestion interface {
	Name() string
	Code() string
}

type CodeSuggestionProvider

type CodeSuggestionProvider interface {
	SuggestionsAt(runeIndex int) []CodeSuggestion
}

type Container

type Container interface {
	Parent
	AddChild(child Control) *Child
	AddChildAt(index int, child Control) *Child
	RemoveChild(child Control)
	RemoveChildAt(index int)
	RemoveAll()
	Padding() math.Spacing
	SetPadding(math.Spacing)
}

type Control

type Control interface {
	// Size returns the size of the control. If the control is not attached, then
	// the returned size is undefined.
	Size() math.Size

	// SetSize sets the size of the control to the specified value.
	// SetSize should only be called by the parent of the control during layout.
	SetSize(math.Size)

	// Draw draws the control's visual apperance into the returned, new canvas.
	// Draw is typically called by the parent of the control - calling Draw will
	// not issue a re-draw of an attached control.
	Draw() Canvas

	// Parent returns the parent of the control.
	Parent() Parent

	// SetParent sets the parent of the control.
	// SetParent should only be called by the new parent of the control.
	SetParent(Parent)

	// Attached returns true if the control is directly or indirectly attached
	// to a window.
	Attached() bool

	// Attach is called when the control is directly or indirectly attached to a
	// window.
	// Attach should only be called by the parent of the control.
	Attach()

	// Detach is called when the control is directly or indirectly detached from a
	// window.
	// Detach should only be called by the parent of the control.
	Detach()

	// OnAttach subscribes f to be called whenever the control is attached.
	OnAttach(f func()) EventSubscription
	// OnDetach subscribes f to be called whenever the control is detached.
	OnDetach(f func()) EventSubscription

	// DesiredSize returns the desired size of the control based on the min and
	// max size limits. The parent control may ignore the desired size.
	DesiredSize(min, max math.Size) math.Size

	// Margin returns the desired spacing between sibling controls.
	Margin() math.Spacing

	// SetMargin set the desired spacing between sibling controls, issuing a
	// relayout if the margin has changed.
	SetMargin(math.Spacing)

	// IsVisible returns true if the control is visible.
	IsVisible() bool

	// SetVisible sets the visibility of the control.
	SetVisible(bool)

	// ContainsPoint returns true if the specified local-space point is considered
	// within the control.
	ContainsPoint(math.Point) bool

	// IsMouseOver returns true if the mouse cursor was last reported within the
	// control.
	IsMouseOver() bool

	//	// IsMouseDown returns true if button was last reported pressed on the
	//	// control.
	//	IsMouseDown(button MouseButton) bool
	//
	//	// Click is called when the mouse is pressed and released on the control.
	//	// If Click returns true, then the click event is consumed by the control,
	//	// otherwise the next control below the should be considered for the click
	//	// event.
	Click(MouseEvent) (consume bool)

	//
	//	// OnKeyPress subscribes f to be called whenever the control receives a
	//	// key-press event.
	//	OnKeyPress(f func(KeyboardEvent)) EventSubscription
	//
	//	// OnKeyStroke subscribes f to be called whenever the control receives a
	//	// key-stroke event.
	//	OnKeyStroke(f func(KeyStrokeEvent)) EventSubscription
	//
	//	// OnClick subscribes f to be called whenever the control receives a click
	//	// event.
	OnClick(f func(MouseEvent)) EventSubscription
}

Control is the interface exposed by all UI control elements.

type ControlList

type ControlList []Control

func (ControlList) Contains

func (l ControlList) Contains(c Control) bool

type Direction

type Direction int
const (
	TopToBottom Direction = iota
	LeftToRight
	BottomToTop
	RightToLeft
)

func (Direction) BottomToTop

func (d Direction) BottomToTop() bool

func (Direction) Flip

func (d Direction) Flip() Direction

func (Direction) LeftToRight

func (d Direction) LeftToRight() bool

func (Direction) Orientation

func (d Direction) Orientation() Orientation

func (Direction) RightToLeft

func (d Direction) RightToLeft() bool

func (Direction) TopToBottom

func (d Direction) TopToBottom() bool

type Driver

type Driver interface {
	// Call queues f to be run on the UI go-routine, returning before f may have
	// been called. Call returns false if the driver has been terminated, in which
	// case f may not be called.
	Call(f func()) bool

	// CallSync queues and then blocks for f to be run on the UI go-routine.
	// Call returns false if the driver has been terminated, in which case f may
	// not be called.
	CallSync(f func()) bool

	Terminate()
	SetClipboard(str string)
	GetClipboard() (string, error)

	// CreateWindowedViewport creates a new windowed Viewport with the specified
	// width and height in device independent pixels.
	CreateWindowedViewport(width, height int, name string) Viewport

	// CreateFullscreenViewport creates a new fullscreen Viewport with the
	// specified width and height in device independent pixels. If width or
	// height is 0, then the viewport adopts the current screen resolution.
	CreateFullscreenViewport(width, height int, name string) Viewport

	CreateCanvas(math.Size) Canvas
	CreateTexture(img image.Image, pixelsPerDip float32) Texture

	// Debug function used to verify that the caller is executing on the UI
	// go-routine. If the caller is not on the UI go-routine then the function
	// panics.
	AssertUIGoroutine()
}

type Event

type Event interface {
	Fire(args ...interface{})
	Listen(interface{}) EventSubscription
	ParameterTypes() []reflect.Type
}

type EventSubscription

type EventSubscription interface {
	Unlisten()
}

type Focusable

type Focusable interface {
	Control

	// IsFocusable returns true if the control is currently in a state where it
	// can acquire focus.
	IsFocusable() bool

	// HasFocus returns true when the control has focus.
	HasFocus() bool

	// GainedFocus is called when the Focusable gains focus.
	// This method is called by the FocusManager should not be called by the user.
	GainedFocus()

	// LostFocus is called when the Focusable loses focus.
	// This method is called by the FocusManager should not be called by the user.
	LostFocus()

	// OnGainedFocus subscribes f to be called whenever the control gains focus.
	OnGainedFocus(f func()) EventSubscription

	// OnLostFocus subscribes f to be called whenever the control loses focus.
	OnLostFocus(f func()) EventSubscription
}

Focusable is the optional interface implmented by controls that have the ability to acquire focus. A control with focus will receive keyboard input first.

type Font

type Font interface {
	LoadGlyphs(first, last rune)
	Size() int
	GlyphMaxSize() math.Size
	Measure(*TextBlock) math.Size
	Layout(*TextBlock) (offsets []math.Point)
}

A Font represents a TrueType font loaded by the GXUI driver.

type HorizontalAlignment

type HorizontalAlignment int
const (
	AlignLeft HorizontalAlignment = iota
	AlignCenter
	AlignRight
)

func (HorizontalAlignment) AlignCenter

func (a HorizontalAlignment) AlignCenter() bool

func (HorizontalAlignment) AlignLeft

func (a HorizontalAlignment) AlignLeft() bool

func (HorizontalAlignment) AlignRight

func (a HorizontalAlignment) AlignRight() bool

type KeyStrokeEvent

type KeyStrokeEvent struct {
	Character rune
	Modifier  KeyboardModifier
}

type KeyboardEvent

type KeyboardEvent struct {
	Key      KeyboardKey
	Modifier KeyboardModifier
}

type KeyboardKey

type KeyboardKey int
const (
	KeyUnknown KeyboardKey = iota
	KeySpace
	KeyApostrophe
	KeyComma
	KeyMinus
	KeyPeriod
	KeySlash
	Key0
	Key1
	Key2
	Key3
	Key4
	Key5
	Key6
	Key7
	Key8
	Key9
	KeySemicolon
	KeyEqual
	KeyA
	KeyB
	KeyC
	KeyD
	KeyE
	KeyF
	KeyG
	KeyH
	KeyI
	KeyJ
	KeyK
	KeyL
	KeyM
	KeyN
	KeyO
	KeyP
	KeyQ
	KeyR
	KeyS
	KeyT
	KeyU
	KeyV
	KeyW
	KeyX
	KeyY
	KeyZ
	KeyLeftBracket
	KeyBackslash
	KeyRightBracket
	KeyGraveAccent
	KeyWorld1
	KeyWorld2
	KeyEscape
	KeyEnter
	KeyTab
	KeyBackspace
	KeyInsert
	KeyDelete
	KeyRight
	KeyLeft
	KeyDown
	KeyUp
	KeyPageUp
	KeyPageDown
	KeyHome
	KeyEnd
	KeyCapsLock
	KeyScrollLock
	KeyNumLock
	KeyPrintScreen
	KeyPause
	KeyF1
	KeyF2
	KeyF3
	KeyF4
	KeyF5
	KeyF6
	KeyF7
	KeyF8
	KeyF9
	KeyF10
	KeyF11
	KeyF12
	KeyKp0
	KeyKp1
	KeyKp2
	KeyKp3
	KeyKp4
	KeyKp5
	KeyKp6
	KeyKp7
	KeyKp8
	KeyKp9
	KeyKpDecimal
	KeyKpDivide
	KeyKpMultiply
	KeyKpSubtract
	KeyKpAdd
	KeyKpEnter
	KeyKpEqual
	KeyLeftShift
	KeyLeftControl
	KeyLeftAlt
	KeyLeftSuper
	KeyRightShift
	KeyRightControl
	KeyRightAlt
	KeyRightSuper
	KeyMenu
	KeyLast
)

type KeyboardModifier

type KeyboardModifier int
const (
	ModNone    KeyboardModifier = 0
	ModShift   KeyboardModifier = 1
	ModControl KeyboardModifier = 2
	ModAlt     KeyboardModifier = 4
	ModSuper   KeyboardModifier = 8
)

func (KeyboardModifier) Alt

func (m KeyboardModifier) Alt() bool

func (KeyboardModifier) Control

func (m KeyboardModifier) Control() bool

func (KeyboardModifier) Shift

func (m KeyboardModifier) Shift() bool

func (KeyboardModifier) Super

func (m KeyboardModifier) Super() bool

type Label

type Label interface {
	Control
	Text() string
	SetText(string)
	Font() Font
	SetFont(Font)
	Color() tools.Color
	SetColor(tools.Color)
	Multiline() bool
	SetMultiline(bool)
	SetHorizontalAlignment(HorizontalAlignment)
	HorizontalAlignment() HorizontalAlignment
	SetVerticalAlignment(VerticalAlignment)
	VerticalAlignment() VerticalAlignment
}

type LinearLayout

type LinearLayout interface {
	// LinearLayout extends the Control interface.
	Control

	// LinearLayout extends the Container interface.
	Container

	// Direction returns the direction of layout for this LinearLayout.
	Direction() Direction

	// Direction sets the direction of layout for this LinearLayout.
	SetDirection(Direction)

	// SizeMode returns the desired size behaviour for this LinearLayout.
	SizeMode() SizeMode

	// SetSizeMode sets the desired size behaviour for this LinearLayout.
	SetSizeMode(SizeMode)

	// HorizontalAlignment returns the alignment of the child Controls when laying
	// out TopToBottom or BottomToTop. It has no effect when the layout direction
	// is LeftToRight or RightToLeft.
	HorizontalAlignment() HorizontalAlignment

	// SetHorizontalAlignment sets the alignment of the child Controls when laying
	// out TopToBottom or BottomToTop. It has no effect when the layout direction
	// is LeftToRight or RightToLeft.
	SetHorizontalAlignment(HorizontalAlignment)

	// VerticalAlignment returns the alignment of the child Controls when laying
	// out LeftToRight or RightToLeft. It has no effect when the layout direction
	// is TopToBottom or BottomToTop.
	VerticalAlignment() VerticalAlignment

	// SetVerticalAlignment returns the alignment of the child Controls when
	// laying out LeftToRight or RightToLeft. It has no effect when the layout
	// direction is TopToBottom or BottomToTop.
	SetVerticalAlignment(VerticalAlignment)

	// BorderPen returns the Pen used to draw the LinearLayout's border.
	BorderPen() tools.Pen

	// SetBorderPen sets the Pen used to draw the LinearLayout's border.
	SetBorderPen(tools.Pen)

	// BackgroundBrush returns the Brush used to fill the LinearLayout's
	// background.
	BackgroundBrush() tools.Brush

	// SetBackgroundBrush sets the Brush used to fill the LinearLayout's
	// background.
	SetBackgroundBrush(tools.Brush)
}

LinearLayout is a Container that lays out its child Controls into a column or row. The layout will always start by positioning the first (0'th) child, and then depending on the direction, will position each successive child either to the left, top, right or bottom of the preceding child Control. LinearLayout makes no effort to distribute remaining space evenly between the children - an child control that is laid out before others will reduce the remaining space given to the later children, even to the point that there is zero space remaining.

type MouseButton

type MouseButton int
const (
	MouseButtonLeft MouseButton = iota
	MouseButtonMiddle
	MouseButtonRight
)

type MouseEvent

type MouseEvent struct {
	Button           MouseButton
	State            MouseState
	Point            math.Point // Local to the event receiver
	WindowPoint      math.Point
	Window           Window
	ScrollX, ScrollY int
	Modifier         KeyboardModifier
}

type MouseState

type MouseState int

func (MouseState) IsDown

func (s MouseState) IsDown(b MouseButton) bool

type Orientation

type Orientation int
const (
	Vertical Orientation = iota
	Horizontal
)

func (Orientation) Flip

func (o Orientation) Flip() Orientation

func (Orientation) Horizontal

func (o Orientation) Horizontal() bool

func (Orientation) Major

func (o Orientation) Major(x, y int) int

func (Orientation) Minor

func (o Orientation) Minor(x, y int) int

func (Orientation) Vertical

func (o Orientation) Vertical() bool

type Parent

type Parent interface {
	Children() Children
	Relayout()
	Redraw()
}

type Polygon

type Polygon []PolygonVertex

type PolygonVertex

type PolygonVertex struct {
	Position      math.Point
	RoundedRadius float32
}

type SizeMode

type SizeMode int
const (
	ExpandToContent SizeMode = iota
	Fill
)

func (SizeMode) ExpandToContent

func (s SizeMode) ExpandToContent() bool

func (SizeMode) Fill

func (s SizeMode) Fill() bool

type TextBlock

type TextBlock struct {
	Runes     []rune
	AlignRect math.Rect
	H         HorizontalAlignment
	V         VerticalAlignment
}

TextBlock is a sequence of runes to be laid out.

type TextBox

type TextBox interface {
}

type Texture

type Texture interface {
	Image() image.Image
	Size() math.Size
	SizePixels() math.Size
	FlipY() bool
	SetFlipY(bool)
}

type Theme

type Theme interface {
	Driver() Driver
	DefaultFont() Font
	SetDefaultFont(Font)
	DefaultMonospaceFont() Font
	SetDefaultMonospaceFont(Font)
	//	CreateBubbleOverlay() BubbleOverlay
	CreateButton() Button
	//	CreateCodeEditor() CodeEditor
	//	CreateDropDownList() DropDownList
	//	CreateImage() Image
	CreateLabel() Label
	//	CreateLinearLayout() LinearLayout
	//	CreateList() List
	//	CreatePanelHolder() PanelHolder
	//	CreateProgressBar() ProgressBar
	//	CreateScrollBar() ScrollBar
	//	CreateScrollLayout() ScrollLayout
	//	CreateSplitterLayout() SplitterLayout
	//	CreateTableLayout() TableLayout
	//	CreateTextBox() TextBox
	//	CreateTree() Tree
	CreateWindow(width, height int, title string) Window
}

type VerticalAlignment

type VerticalAlignment int
const (
	AlignTop VerticalAlignment = iota
	AlignMiddle
	AlignBottom
)

func (VerticalAlignment) AlignBottom

func (a VerticalAlignment) AlignBottom() bool

func (VerticalAlignment) AlignMiddle

func (a VerticalAlignment) AlignMiddle() bool

func (VerticalAlignment) AlignTop

func (a VerticalAlignment) AlignTop() bool

type Viewport

type Viewport interface {
	// SizeDips returns the size of the viewport in device-independent pixels.
	// The ratio of pixels to DIPs is based on the screen density and scale
	// adjustments made with the SetScale method.
	SizeDips() math.Size

	// SetSizeDips sets the size of the viewport in device-independent pixels.
	// The ratio of pixels to DIPs is based on the screen density and scale
	// adjustments made with the SetScale method.
	SetSizeDips(math.Size)

	// SizePixels returns the size of the viewport in pixels.
	SizePixels() math.Size

	// Scale returns the display scaling for this viewport.
	// A scale of 1 is unscaled, 2 is twice the regular scaling.
	Scale() float32

	// SetScale alters the display scaling for this viewport.
	// A scale of 1 is unscaled, 2 is twice the regular scaling.
	SetScale(float32)

	// Fullscreen returns true if the viewport was created full-screen.
	Fullscreen() bool

	// Title returns the title of the window.
	// This is usually the text displayed at the top of the window.
	Title() string

	// SetTitle changes the title of the window.
	SetTitle(string)

	// Position returns position of the window.
	Position() math.Point

	// SetPosition changes position of the window.
	SetPosition(math.Point)

	// Show makes the window visible.
	Show()

	// Hide makes the window invisible.
	Hide()

	// Close destroys the window.
	// Once the window is closed, no further calls should be made to it.
	Close()

	// SetCanvas changes the displayed content of the viewport to the specified
	// Canvas. As canvases are immutable once completed, every visual update of a
	// viewport will require a call to SetCanvas.
	SetCanvas(Canvas)
	//
	//	// OnClose subscribes f to be called when the viewport closes.
	OnClose(f func()) EventSubscription
	//
	// OnResize subscribes f to be called whenever the viewport changes size.
	OnResize(f func()) EventSubscription

	// OnMouseMove subscribes f to be called whenever the mouse cursor moves over
	// the viewport.
	OnMouseMove(f func(MouseEvent)) EventSubscription

	// OnMouseEnter subscribes f to be called whenever the mouse cursor enters the
	// viewport.
	OnMouseEnter(f func(MouseEvent)) EventSubscription

	// OnMouseEnter subscribes f to be called whenever the mouse cursor leaves the
	// viewport.
	OnMouseExit(f func(MouseEvent)) EventSubscription

	// OnMouseDown subscribes f to be called whenever a mouse button is pressed
	// while the cursor is inside the viewport.
	OnMouseDown(f func(MouseEvent)) EventSubscription

	// OnMouseUp subscribes f to be called whenever a mouse button is released
	// while the cursor is inside the viewport.
	OnMouseUp(f func(MouseEvent)) EventSubscription

	// OnMouseScroll subscribes f to be called whenever the mouse scroll wheel
	// turns while the cursor is inside the viewport.
	OnMouseScroll(f func(MouseEvent)) EventSubscription

	// OnKeyDown subscribes f to be called whenever a keyboard key is pressed
	// while the viewport has focus.
	OnKeyDown(f func(KeyboardEvent)) EventSubscription

	// OnKeyUp subscribes f to be called whenever a keyboard key is released
	// while the viewport has focus.
	OnKeyUp(f func(KeyboardEvent)) EventSubscription

	// OnKeyRepeat subscribes f to be called whenever a keyboard key-repeat event
	// is raised while the viewport has focus.
	OnKeyRepeat(f func(KeyboardEvent)) EventSubscription

	// OnKeyStroke subscribes f to be called whenever a keyboard key-stroke event
	// is raised while the viewport has focus.
	OnKeyStroke(f func(KeyStrokeEvent)) EventSubscription
}

type Window

type Window interface {
	Container

	// Title returns the title of the window.
	// This is usually the text displayed at the top of the window.
	Title() string

	// SetTitle changes the title of the window.
	SetTitle(string)

	// Scale returns the display scaling for this window.
	// A scale of 1 is unscaled, 2 is twice the regular scaling.
	Scale() float32

	// SetScale alters the display scaling for this window.
	// A scale of 1 is unscaled, 2 is twice the regular scaling.
	SetScale(float32)

	// Position returns position of the window.
	Position() math.Point

	// SetPosition changes position of the window.
	SetPosition(math.Point)

	// Fullscreen returns true if the window is currently full-screen.
	Fullscreen() bool

	// SetFullscreen makes the window either full-screen or windowed.
	SetFullscreen(bool)

	// Show makes the window visible.
	Show()

	// Hide makes the window invisible.
	Hide()

	// Close destroys the window.
	// Once the window is closed, no further calls should be made to it.
	Close()

	// Focus returns the control currently with focus.
	Focus() Focusable

	// SetFocus gives the specified control Focus, returning true on success or
	// false if the control cannot be given focus.
	SetFocus(Control) bool

	// BackgroundBrush returns the brush used to draw the window background.
	BackgroundBrush() tools.Brush

	// SetBackgroundBrush sets the brush used to draw the window background.
	SetBackgroundBrush(tools.Brush)

	// BorderPen returns the pen used to draw the window border.
	BorderPen() tools.Pen

	// SetBorderPen sets the pen used to draw the window border.
	SetBorderPen(tools.Pen)

	//	Click(MouseEvent)
	//	DoubleClick(MouseEvent)
	//	KeyPress(KeyboardEvent)
	//	KeyStroke(KeyStrokeEvent)
	//
	//	// Events
	OnClose(func()) EventSubscription
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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