Documentation ¶
Index ¶
- Variables
- type CmdSender
- type CommandLine
- func (cl *CommandLine) Append(s string)
- func (cl CommandLine) Close()
- func (cl *CommandLine) Confirm() string
- func (cl *CommandLine) Delete(n_rune int) int
- func (cl *CommandLine) InsertString(s string)
- func (cl *CommandLine) Measure(t *theme.Theme, widthHint, heightHint int)
- func (cl *CommandLine) MoveCurosr(n_rune int)
- func (cl *CommandLine) OnInputEvent(ev interface{}, origin image.Point) node.EventHandled
- func (cl *CommandLine) OnLifecycleEvent(e lifecycle.Event)
- func (cl *CommandLine) PaintBase(ctx *node.PaintBaseContext, origin image.Point) error
- type Edge
- type EragoPresenter
- func (p *EragoPresenter) AddRequestObserver(obs uiadapter.RequestObserver)
- func (p *EragoPresenter) CommandWaiting() bool
- func (p *EragoPresenter) InputWaiting() bool
- func (p *EragoPresenter) Mark(n node.Node, mark node.Marks)
- func (p *EragoPresenter) OnRequestChanged(typ uiadapter.InputRequestType)
- func (p *EragoPresenter) Quit()
- func (p *EragoPresenter) RestartGameThread(ui uiadapter.UI, conf erago.Config) error
- func (p *EragoPresenter) RunGameThread(ui uiadapter.UI, Conf erago.Config) error
- func (p *EragoPresenter) SendCommand(cmd string)
- func (p *EragoPresenter) SendControlSkippingWait(enable bool)
- func (p *EragoPresenter) SendRawCommand(r rune)
- type FixedSplit
- type Frame
- type ImageView
- type ModelError
- type MultipleView
- func (mv *MultipleView) ClearLine(nline int) error
- func (mv *MultipleView) ClearLineAll() error
- func (mv *MultipleView) Close()
- func (mv *MultipleView) CurrentRuneWidth() (int, error)
- func (mv *MultipleView) GetAlignment() (attr.Alignment, error)
- func (mv *MultipleView) GetColor() (color uint32, err error)
- func (mv *MultipleView) GetCurrentViewName() string
- func (mv *MultipleView) GetViewNames() []string
- func (mv *MultipleView) Layout(t *theme.Theme)
- func (mv *MultipleView) LineCount() (int, error)
- func (mv *MultipleView) Measure(t *theme.Theme, widthHint, heightHint int)
- func (mv *MultipleView) MeasureImageSize(file string, widthInRW, heightInLC int) (int, int, error)
- func (mv *MultipleView) NewPage() error
- func (mv *MultipleView) OnInputEvent(ev interface{}, origin image.Point) node.EventHandled
- func (mv *MultipleView) OnLifeCycleEvent(e lifecycle.Event)
- func (mv *MultipleView) Paint(ctx *node.PaintContext, origin image.Point) error
- func (mv *MultipleView) PaintBase(ctx *node.PaintBaseContext, origin image.Point) error
- func (mv *MultipleView) Print(s string) error
- func (mv *MultipleView) PrintButton(caption string, command string) error
- func (mv *MultipleView) PrintImage(file string, widthInRW, heightInLC int) error
- func (mv *MultipleView) PrintLabel(s string) error
- func (mv *MultipleView) PrintLine(sym string) error
- func (mv *MultipleView) ResetColor() error
- func (mv *MultipleView) SetAlignment(a attr.Alignment) error
- func (mv *MultipleView) SetColor(color uint32) error
- func (mv *MultipleView) SetCurrentView(vname string) error
- func (mv *MultipleView) SetHorizontalLayout(vname1, vname2 string, rate float64) error
- func (mv *MultipleView) SetLayout(l *attr.LayoutData) error
- func (mv *MultipleView) SetSingleLayout(vname string) error
- func (mv *MultipleView) SetVerticalLayout(vname1, vname2 string, rate float64) error
- func (mv *MultipleView) String() string
- func (mv *MultipleView) Sync() error
- func (mv *MultipleView) WindowLineCount() (int, error)
- func (mv *MultipleView) WindowRuneWidth() (int, error)
- type PresenterTask
- type Printer
- func (p Printer) ClearLine(nline int)
- func (p Printer) ClearLineAll()
- func (p Printer) CurrentRuneWidth() int
- func (p Printer) GetAlignment() attr.Alignment
- func (p Printer) GetColor() uint32
- func (p Printer) LineCount() int
- func (p Printer) NewPage()
- func (p Printer) Print(s string)
- func (p Printer) PrintButton(caption, cmd string)
- func (p Printer) PrintImage(file string, widthInRW, heightInLC int)
- func (p Printer) PrintLabel(s string)
- func (p Printer) PrintLine(sym string)
- func (p Printer) ResetColor()
- func (p Printer) SetAlignment(a attr.Alignment)
- func (p Printer) SetColor(c uint32)
- func (p Printer) WindowLineCount() int
- func (p Printer) WindowRuneWidth() int
- type TabView
- func (v *TabView) ClearLine(nline int)
- func (v *TabView) ClearLineAll()
- func (v *TabView) CurrentRuneWidth() (int, error)
- func (v *TabView) GetAlignment() (attr.Alignment, error)
- func (v *TabView) GetColor() (color uint32, err error)
- func (v *TabView) GetCurrentViewName() string
- func (v *TabView) GetViewNames() []string
- func (v *TabView) Layout(t *theme.Theme)
- func (v *TabView) LineCount() (int, error)
- func (v *TabView) Measure(t *theme.Theme, widthHint, heightHint int)
- func (v *TabView) NewPage()
- func (v *TabView) OnInputEvent(ev interface{}, origin image.Point) node.EventHandled
- func (v *TabView) Paint(ctx *node.PaintContext, origin image.Point) error
- func (v *TabView) PaintBase(ctx *node.PaintBaseContext, origin image.Point) error
- func (v *TabView) Print(s string)
- func (v *TabView) PrintButton(caption string, command string)
- func (v *TabView) PrintLabel(s string)
- func (v *TabView) PrintLine(sym string)
- func (v *TabView) ResetColor() error
- func (v *TabView) SetAlignment(a attr.Alignment) error
- func (v *TabView) SetColor(color uint32) error
- func (v *TabView) SetCurrentView(vname string) error
- func (v *TabView) SetHorizontalLayout(vname1 string, vname2 string, rate float64) error
- func (v *TabView) SetLayout(layout *attr.LayoutData) error
- func (v *TabView) SetSingleLayout(name string) error
- func (v *TabView) SetVerticalLayout(vname1 string, vname2 string, rate float64) error
- func (v *TabView) WindowLineCount() (int, error)
- func (v *TabView) WindowRuneWidth() (int, error)
- type TextView
- func (v *TextView) ClearLine(nline int) error
- func (v *TextView) ClearLineAll() error
- func (v *TextView) Close()
- func (v *TextView) CurrentRuneWidth() (int, error)
- func (v *TextView) FindCommand(at, origin image.Point) (string, bool)
- func (v *TextView) Focus()
- func (v *TextView) GetAlignment() (attr.Alignment, error)
- func (v *TextView) GetColor() (uint32, error)
- func (v *TextView) HighlightCommand(at, origin image.Point) bool
- func (v *TextView) Layout(t *theme.Theme)
- func (v *TextView) LineCount() (int, error)
- func (v *TextView) Measure(t *theme.Theme, widthHint, heightHint int)
- func (v *TextView) MeasureImageSize(file string, widthInRW, heightInLC int) (width, height int, err error)
- func (v *TextView) NewPage() error
- func (v *TextView) OnInputEvent(ev interface{}, origin image.Point) node.EventHandled
- func (v *TextView) PaintBase(ctx *node.PaintBaseContext, origin image.Point) error
- func (v *TextView) Print(s string) error
- func (v *TextView) PrintButton(caption string, command string) error
- func (v *TextView) PrintImage(file string, widthInRW, heightInLC int) error
- func (v *TextView) PrintLabel(s string) error
- func (v *TextView) PrintLine(sym string) error
- func (v *TextView) ResetColor() error
- func (v *TextView) SetAlignment(a attr.Alignment) error
- func (v *TextView) SetColor(c uint32) error
- func (v *TextView) String() string
- func (v *TextView) Sync() error
- func (v *TextView) Unfocus()
- func (v *TextView) WindowLineCount() (int, error)
- func (v *TextView) WindowRuneWidth() (int, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorGameQuitByRestartRequest indicates the game thread ends by restart request. // It is notified via ModelErorr and can be obtained from ModelError.Cause(). ErrorGameQuitByRestartRequest = fmt.Errorf("Quit model thread by restart request") // ErrorGameAlreadyRunning indicates the game thread already running but // invalid operations such as starting the game are arrived. ErrorGameAlreadyRunning = fmt.Errorf("game already running") )
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 ¶
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 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) RestartGameThread ¶ added in v0.5.0
RestartGameThread restarts game thread with another game instance. Exsiting game thread is stopped and diposed. It returns nil when restart succeeded and also notifies ModelError.Cause() == ErrorGameQuitByRestartRequest through the event queue. Otherwise returns error.
func (*EragoPresenter) RunGameThread ¶
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 (*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 ImageView ¶
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 ¶
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) Cause ¶ added in v0.5.0
func (me ModelError) Cause() error
Cause returns error which caused this ModelError, or may return nil when game thread quiting correctly.
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) MeasureImageSize ¶ added in v0.6.0
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) PrintImage ¶ added in v0.6.0
func (mv *MultipleView) PrintImage(file string, widthInRW, heightInLC int) 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.
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 (Printer) CurrentRuneWidth ¶
implemnts erago/uiadapter/UI.
func (Printer) GetAlignment ¶
implemnts erago/uiadapter/UI.
func (Printer) PrintButton ¶
implemnts erago/uiadapter/UI.
func (Printer) PrintImage ¶ added in v0.6.0
implements erago/uiadapter/UI.
func (Printer) SetAlignment ¶
implemnts erago/uiadapter/UI.
func (Printer) WindowLineCount ¶
implemnts erago/uiadapter/UI.
func (Printer) WindowRuneWidth ¶
implemnts erago/uiadapter/UI.
type TabView ¶
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) ClearLineAll ¶
func (v *TabView) ClearLineAll()
func (*TabView) CurrentRuneWidth ¶
func (*TabView) GetCurrentViewName ¶
func (*TabView) GetViewNames ¶
func (*TabView) OnInputEvent ¶
func (v *TabView) OnInputEvent(ev interface{}, origin image.Point) node.EventHandled
func (*TabView) PrintButton ¶
func (*TabView) PrintLabel ¶
func (*TabView) ResetColor ¶
func (*TabView) SetCurrentView ¶
func (*TabView) SetHorizontalLayout ¶
func (*TabView) SetSingleLayout ¶
func (*TabView) SetVerticalLayout ¶
func (*TabView) WindowLineCount ¶
func (*TabView) WindowRuneWidth ¶
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) ClearLineAll ¶
func (*TextView) CurrentRuneWidth ¶
func (*TextView) FindCommand ¶
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) HighlightCommand ¶
highlight Command at the postion. Return highlighted command is found.
func (*TextView) MeasureImageSize ¶ added in v0.6.0
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 ¶
implements node.Node interface if it has no MarkPaintBase then do nothing.