ui

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2019 License: BSD-3-Clause Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdSender

type CmdSender interface {
	SendCommand(cmd string)
	SendRawCommand(r rune)
	SendControlSkippingWait(enable bool)
}

CmdSender is interface for sending information to the model.

type CommandLine

type CommandLine struct {
	node.LeafEmbed
	// contains filtered or unexported fields
}

CommandLine is a leaf widget which can edit its text content and submit it.

func NewCommandLine

func NewCommandLine(sender CmdSender) *CommandLine

construct new CommandLine widget with custom theme.

func (*CommandLine) Append

func (cl *CommandLine) Append(s string)

append text at end of command line. and position is moved to end.

func (CommandLine) Close

func (cl CommandLine) Close()

finalization. after this editing text does not work. It is exported for unexpected panic. It is called automatically onLifeCycelEvent.

func (*CommandLine) Confirm

func (cl *CommandLine) Confirm() string

confirm current text as command and return it. all of the command line's text is cleared after confirming.

func (*CommandLine) Delete

func (cl *CommandLine) Delete(n_rune int) int

delete n runes backwards. It returns deleted number of runes.

func (*CommandLine) InsertString

func (cl *CommandLine) InsertString(s string)

insert text at current positon

func (*CommandLine) Measure

func (cl *CommandLine) Measure(t *theme.Theme, widthHint, heightHint int)

implements node.Node interface.

func (*CommandLine) MoveCurosr

func (cl *CommandLine) MoveCurosr(n_rune int)

func (*CommandLine) OnInputEvent

func (cl *CommandLine) OnInputEvent(ev interface{}, origin image.Point) node.EventHandled

implements node.Node interface.

func (*CommandLine) OnLifecycleEvent

func (cl *CommandLine) OnLifecycleEvent(e lifecycle.Event)

func (*CommandLine) PaintBase

func (cl *CommandLine) PaintBase(ctx *node.PaintBaseContext, origin image.Point) error

implements node.Node interface.

type Edge

type Edge uint8

Edge is four edges in square shape, upper, bottom, left, and right.

const (
	EdgeNone Edge = iota
	EdgeTop
	EdgeBottom
	EdgeLeft
	EdgeRight
)

func (Edge) Horizontal

func (e Edge) Horizontal() bool

whether Edge axis is Horizontal?

func (Edge) Vertical

func (e Edge) Vertical() bool

whether Edge axis is Vertical?

type EragoPresenter

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

EragoPresenter is mediator between erago.Game model and GUI widgets. It sends PresenterTask and ModelError for eventQ, user should handle these.

func NewEragoPresenter

func NewEragoPresenter(eventQ screen.EventDeque) *EragoPresenter

func (*EragoPresenter) AddRequestObserver

func (p *EragoPresenter) AddRequestObserver(obs uiadapter.RequestObserver)

add uiadapter.RequestObserver to notify inputRequest is changed. it is valid before RunGameThread() and not used concurrently.

func (*EragoPresenter) CommandWaiting

func (p *EragoPresenter) CommandWaiting() bool

return command event is waitng?

func (*EragoPresenter) InputWaiting

func (p *EragoPresenter) InputWaiting() bool

return any input event is waitng?

func (*EragoPresenter) Mark

func (p *EragoPresenter) Mark(n node.Node, mark node.Marks)

Mark any node.Marks, NeedsPaint etc, to node n. It is queued in main event queue and execute on UI thread, not execute immdiately.

func (*EragoPresenter) OnRequestChanged

func (p *EragoPresenter) OnRequestChanged(typ uiadapter.InputRequestType)

implements uiadapter.RequestObserver

func (*EragoPresenter) Quit

func (p *EragoPresenter) Quit()

send quit signal to the internal model execution. it must be called after RunGameThread().

func (*EragoPresenter) RunGameThread

func (p *EragoPresenter) RunGameThread(ui uiadapter.UI, Conf erago.Config) bool

run game main thread on other gorutine. return true if staring at first time, false if multiple calling this.

func (*EragoPresenter) SendCommand

func (p *EragoPresenter) SendCommand(cmd string)

implements CmdSender interface.

func (*EragoPresenter) SendControlSkippingWait

func (p *EragoPresenter) SendControlSkippingWait(enable bool)

implements CmdSender interface.

func (*EragoPresenter) SendRawCommand

func (p *EragoPresenter) SendRawCommand(r rune)

implements CmdSender interface.

type FixedSplit

type FixedSplit struct {
	node.ContainerEmbed

	Edge       Edge
	BorderSize unit.Value
}

FixedSplit splits itself to 2 widgets. its splitting line is same axis as Edge and BorderSize away from Edge. The size of Node close to Edge is fixed by BorderSize and another Node's one is chaged by FixedSplit's size. These sizes along with Edge are always expanded or shrinked to fit FixedSplit's size.

func NewFixedSplit

func NewFixedSplit(edge Edge, borderSize unit.Value, fixedNode, another node.Node) *FixedSplit

func (*FixedSplit) Insert

func (fsp *FixedSplit) Insert(c, nextSibling node.Node)

can not insert new child after build.

func (*FixedSplit) Layout

func (fsp *FixedSplit) Layout(t *theme.Theme)

implements node.Node interface

func (*FixedSplit) Measure

func (fsp *FixedSplit) Measure(t *theme.Theme, widthHint, heightHint int)

implements node.Node interface

func (*FixedSplit) OnInputEvent

func (fsp *FixedSplit) OnInputEvent(ev interface{}, origin image.Point) node.EventHandled

type Frame

type Frame struct {
	*widget.Padder

	// color to draw frame.
	ThemeColor theme.Color
}

frame is a shell widget which paints frame on its margin space.

func NewFrame

func NewFrame(margin unit.Value, color theme.Color, inner node.Node) *Frame

func (*Frame) PaintBase

func (w *Frame) PaintBase(ctx *node.PaintBaseContext, origin image.Point) error

implements node.Node interface. Paint flikers the screen so deprecated.

type ImageView

type ImageView struct {
	node.LeafEmbed
	// contains filtered or unexported fields
}

ImageView is a leaf widget that paints image.Image. the painted image is fitted to its widget size so that entire view of image is shown.

func NewImageView

func NewImageView(filename string) *ImageView

func (*ImageView) Layout

func (v *ImageView) Layout(t *theme.Theme)

func (*ImageView) Measure

func (v *ImageView) Measure(t *theme.Theme, widthHint, heightHint int)

func (*ImageView) PaintBase

func (v *ImageView) PaintBase(ctx *node.PaintBaseContext, origin image.Point) error

func (*ImageView) SrcName

func (v *ImageView) SrcName() string

type ModelError

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

ModelError reperesents error in the Game model. The Game also returns error(nil) if quiting it correctly. To distinguish quiting signal and an error, check ModelError.HasCause(). It means error that having a cause, quiting signal otherwise.

func (ModelError) Error

func (me ModelError) Error() string

implements error interface.

func (ModelError) HasCause

func (me ModelError) HasCause() bool

whether model's error has cause? model error if cause exist, quiting signal otherwise.

type MultipleView

type MultipleView struct {
	// ShellEmbed has MultipleView's root as a child.
	// a child may be changed dynamically from other goroutine.
	node.ShellEmbed
	// contains filtered or unexported fields
}

MultipleView is abstruct of multiple views which has current view state. It implements uiadapter.UI interface, the functions accessing current view are called through currentView.Printer.

func NewMultipleView

func NewMultipleView(sender *EragoPresenter) *MultipleView

func (*MultipleView) ClearLine

func (mv *MultipleView) ClearLine(nline int) error

func (*MultipleView) ClearLineAll

func (mv *MultipleView) ClearLineAll() error

func (*MultipleView) Close

func (mv *MultipleView) Close()

finalize MultipleView. Multiple calling It is OK but do nothing. It is called automatically when lifecycle stage go to StageDead. but for unexpected panic, it is exported.

func (*MultipleView) CurrentRuneWidth

func (mv *MultipleView) CurrentRuneWidth() (int, error)

func (*MultipleView) GetAlignment

func (mv *MultipleView) GetAlignment() (attr.Alignment, error)

func (*MultipleView) GetColor

func (mv *MultipleView) GetColor() (color uint32, err error)

func (*MultipleView) GetCurrentViewName

func (mv *MultipleView) GetCurrentViewName() string

implement uiadapter.UI.

func (*MultipleView) GetViewNames

func (mv *MultipleView) GetViewNames() []string

implement uiadapter.UI.

func (*MultipleView) Layout

func (mv *MultipleView) Layout(t *theme.Theme)

func (*MultipleView) LineCount

func (mv *MultipleView) LineCount() (int, error)

func (*MultipleView) Measure

func (mv *MultipleView) Measure(t *theme.Theme, widthHint, heightHint int)

func (*MultipleView) NewPage

func (mv *MultipleView) NewPage() error

func (*MultipleView) OnInputEvent

func (mv *MultipleView) OnInputEvent(ev interface{}, origin image.Point) node.EventHandled

func (*MultipleView) OnLifeCycleEvent

func (mv *MultipleView) OnLifeCycleEvent(e lifecycle.Event)

func (*MultipleView) Paint

func (mv *MultipleView) Paint(ctx *node.PaintContext, origin image.Point) error

implements node.Node interface.

func (*MultipleView) PaintBase

func (mv *MultipleView) PaintBase(ctx *node.PaintBaseContext, origin image.Point) error

implements node.Node interface.

func (*MultipleView) Print

func (mv *MultipleView) Print(s string) error

func (*MultipleView) PrintButton

func (mv *MultipleView) PrintButton(caption string, command string) error

func (*MultipleView) PrintLabel

func (mv *MultipleView) PrintLabel(s string) error

func (*MultipleView) PrintLine

func (mv *MultipleView) PrintLine(sym string) error

func (*MultipleView) ResetColor

func (mv *MultipleView) ResetColor() error

func (*MultipleView) SetAlignment

func (mv *MultipleView) SetAlignment(a attr.Alignment) error

func (*MultipleView) SetColor

func (mv *MultipleView) SetColor(color uint32) error

func (*MultipleView) SetCurrentView

func (mv *MultipleView) SetCurrentView(vname string) error

implement uiadapter.UI.

func (*MultipleView) SetHorizontalLayout

func (mv *MultipleView) SetHorizontalLayout(vname1, vname2 string, rate float64) error

implement uiadapter.UI.

func (*MultipleView) SetLayout

func (mv *MultipleView) SetLayout(l *attr.LayoutData) error

implement uiadapter.UI.

func (*MultipleView) SetSingleLayout

func (mv *MultipleView) SetSingleLayout(vname string) error

implement uiadapter.UI.

func (*MultipleView) SetVerticalLayout

func (mv *MultipleView) SetVerticalLayout(vname1, vname2 string, rate float64) error

implement uiadapter.UI.

func (*MultipleView) String

func (mv *MultipleView) String() string

implements fmt.Stringer interface.

func (*MultipleView) Sync

func (mv *MultipleView) Sync() error

func (*MultipleView) WindowLineCount

func (mv *MultipleView) WindowLineCount() (int, error)

func (*MultipleView) WindowRuneWidth

func (mv *MultipleView) WindowRuneWidth() (int, error)

type PresenterTask

type PresenterTask func()

Presenter pushes asynchronized task for screen.EventDeque. it should handled on UI thread.

func (PresenterTask) Run

func (task PresenterTask) Run()

execute task.

type Printer

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

Printer is interface for text.Frame. It implements erago.uiadapter.UI.Printer

func NewPrinter

func NewPrinter(f *text.Frame) *Printer

func (Printer) ClearLine

func (p Printer) ClearLine(nline int)

implemnts erago/uiadapter/UI.

func (Printer) ClearLineAll

func (p Printer) ClearLineAll()

implemnts erago/uiadapter/UI.

func (Printer) CurrentRuneWidth

func (p Printer) CurrentRuneWidth() int

implemnts erago/uiadapter/UI.

func (Printer) GetAlignment

func (p Printer) GetAlignment() attr.Alignment

implemnts erago/uiadapter/UI.

func (Printer) GetColor

func (p Printer) GetColor() uint32

implemnts erago/uiadapter/UI.

func (Printer) LineCount

func (p Printer) LineCount() int

implemnts erago/uiadapter/UI.

func (Printer) NewPage

func (p Printer) NewPage()

implemnts erago/uiadapter/UI.

func (Printer) Print

func (p Printer) Print(s string)

implemnts erago/uiadapter/UI.

func (Printer) PrintButton

func (p Printer) PrintButton(caption, cmd string)

implemnts erago/uiadapter/UI.

func (Printer) PrintLabel

func (p Printer) PrintLabel(s string)

implemnts erago/uiadapter/UI.

func (Printer) PrintLine

func (p Printer) PrintLine(sym string)

implemnts erago/uiadapter/UI.

func (Printer) ResetColor

func (p Printer) ResetColor()

implemnts erago/uiadapter/UI.

func (Printer) SetAlignment

func (p Printer) SetAlignment(a attr.Alignment)

implemnts erago/uiadapter/UI.

func (Printer) SetColor

func (p Printer) SetColor(c uint32)

implemnts erago/uiadapter/UI.

func (Printer) WindowLineCount

func (p Printer) WindowLineCount() int

implemnts erago/uiadapter/UI.

func (Printer) WindowRuneWidth

func (p Printer) WindowRuneWidth() int

implemnts erago/uiadapter/UI.

type TabView

type TabView struct {
	*widget.Flow
	// contains filtered or unexported fields
}

TabView is a container widget which paints only current view and has tabs for selecting view to paint. It implements uiadapter.UI interface, the functions accessing current view are called through currentView.Printer.

func NewTabView

func NewTabView(sender *EragoPresenter) *TabView

func (*TabView) ClearLine

func (v *TabView) ClearLine(nline int)

func (*TabView) ClearLineAll

func (v *TabView) ClearLineAll()

func (*TabView) CurrentRuneWidth

func (v *TabView) CurrentRuneWidth() (int, error)

func (*TabView) GetAlignment

func (v *TabView) GetAlignment() (attr.Alignment, error)

func (*TabView) GetColor

func (v *TabView) GetColor() (color uint32, err error)

func (*TabView) GetCurrentViewName

func (v *TabView) GetCurrentViewName() string

func (*TabView) GetViewNames

func (v *TabView) GetViewNames() []string

func (*TabView) Layout

func (v *TabView) Layout(t *theme.Theme)

func (*TabView) LineCount

func (v *TabView) LineCount() (int, error)

func (*TabView) Measure

func (v *TabView) Measure(t *theme.Theme, widthHint, heightHint int)

func (*TabView) NewPage

func (v *TabView) NewPage()

func (*TabView) OnInputEvent

func (v *TabView) OnInputEvent(ev interface{}, origin image.Point) node.EventHandled

func (*TabView) Paint

func (v *TabView) Paint(ctx *node.PaintContext, origin image.Point) error

func (*TabView) PaintBase

func (v *TabView) PaintBase(ctx *node.PaintBaseContext, origin image.Point) error

func (*TabView) Print

func (v *TabView) Print(s string)

func (*TabView) PrintButton

func (v *TabView) PrintButton(caption string, command string)

func (*TabView) PrintLabel

func (v *TabView) PrintLabel(s string)

func (*TabView) PrintLine

func (v *TabView) PrintLine(sym string)

func (*TabView) ResetColor

func (v *TabView) ResetColor() error

func (*TabView) SetAlignment

func (v *TabView) SetAlignment(a attr.Alignment) error

func (*TabView) SetColor

func (v *TabView) SetColor(color uint32) error

func (*TabView) SetCurrentView

func (v *TabView) SetCurrentView(vname string) error

func (*TabView) SetHorizontalLayout

func (v *TabView) SetHorizontalLayout(vname1 string, vname2 string, rate float64) error

func (*TabView) SetLayout

func (v *TabView) SetLayout(layout *attr.LayoutData) error

func (*TabView) SetSingleLayout

func (v *TabView) SetSingleLayout(name string) error

func (*TabView) SetVerticalLayout

func (v *TabView) SetVerticalLayout(vname1 string, vname2 string, rate float64) error

func (*TabView) WindowLineCount

func (v *TabView) WindowLineCount() (int, error)

func (*TabView) WindowRuneWidth

func (v *TabView) WindowRuneWidth() (int, error)

type TextView

type TextView struct {
	node.LeafEmbed
	// implements erago/uiadapter.Printer interface.
	*Printer
	// contains filtered or unexported fields
}

View is interface of text.Frame and its Printer. Any text.Frame is treated through View. View is identified by uniq name.

func NewTextView

func NewTextView(name string, sender *EragoPresenter) *TextView

func (*TextView) ClearLine

func (v *TextView) ClearLine(nline int) error

func (*TextView) ClearLineAll

func (v *TextView) ClearLineAll() error

func (*TextView) Close

func (v *TextView) Close()

close to explicitly finalize this.

func (*TextView) CurrentRuneWidth

func (v *TextView) CurrentRuneWidth() (int, error)

func (*TextView) FindCommand

func (v *TextView) FindCommand(at, origin image.Point) (string, bool)

find clicakble Command at the postion. Return command and command found.

func (*TextView) Focus

func (v *TextView) Focus()

Focused means this view is current view on viewManager, not lifecycle.Focused.

func (*TextView) GetAlignment

func (v *TextView) GetAlignment() (attr.Alignment, error)

func (*TextView) GetColor

func (v *TextView) GetColor() (uint32, error)

func (*TextView) HighlightCommand

func (v *TextView) HighlightCommand(at, origin image.Point) bool

highlight Command at the postion. Return highlighted command is found.

func (*TextView) Layout

func (v *TextView) Layout(t *theme.Theme)

implements node.Node interface

func (*TextView) LineCount

func (v *TextView) LineCount() (int, error)

func (*TextView) Measure

func (v *TextView) Measure(t *theme.Theme, widthHint, heightHint int)

implements node.Node interface

func (*TextView) NewPage

func (v *TextView) NewPage() error

func (*TextView) OnInputEvent

func (v *TextView) OnInputEvent(ev interface{}, origin image.Point) node.EventHandled

implements node.Node interface if it has no focus then do nothing and return NotHandled.

func (*TextView) PaintBase

func (v *TextView) PaintBase(ctx *node.PaintBaseContext, origin image.Point) error

implements node.Node interface if it has no MarkPaintBase then do nothing.

func (*TextView) Print

func (v *TextView) Print(s string) error

func (*TextView) PrintButton

func (v *TextView) PrintButton(caption string, command string) error

func (*TextView) PrintLabel

func (v *TextView) PrintLabel(s string) error

func (*TextView) PrintLine

func (v *TextView) PrintLine(sym string) error

func (*TextView) ResetColor

func (v *TextView) ResetColor() error

func (*TextView) SetAlignment

func (v *TextView) SetAlignment(a attr.Alignment) error

func (*TextView) SetColor

func (v *TextView) SetColor(c uint32) error

func (*TextView) String

func (v *TextView) String() string

implements fmt.Stringer

func (*TextView) Sync

func (v *TextView) Sync() error

func (*TextView) Unfocus

func (v *TextView) Unfocus()

func (*TextView) WindowLineCount

func (v *TextView) WindowLineCount() (int, error)

func (*TextView) WindowRuneWidth

func (v *TextView) WindowRuneWidth() (int, error)

Jump to

Keyboard shortcuts

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