Documentation ¶
Index ¶
- Constants
- Variables
- func ColorRGBAToInt32RGB(c color.RGBA) int32
- func ColorRGBAToUInt32RGB(c color.RGBA) uint32
- func Int32RGBToColorRGBA(c int32) color.RGBA
- func UInt32RGBToColorRGBA(c uint32) color.RGBA
- type APIError
- type Callback
- type CallbackDefault
- type Editor
- func (e *Editor) ClearLine(nline int) error
- func (e *Editor) ClearLineAll() error
- func (e *Editor) Close() error
- func (e *Editor) CurrentRuneWidth() (int, error)
- func (e *Editor) GetAlignment() (align attribute.Alignment, err error)
- func (e *Editor) GetColor() (color uint32, err error)
- func (e *Editor) LineCount() (int, error)
- func (e *Editor) MeasureImageSize(file string, widthInRW, heightInLC int) (retW, retH int, err error)
- func (e *Editor) NewPage() error
- func (e *Editor) Print(s string) error
- func (e *Editor) PrintButton(caption string, command string) error
- func (e *Editor) PrintImage(file string, widthInRW, heightInLC int) error
- func (e *Editor) PrintLabel(s string) error
- func (e *Editor) PrintLine(sym string) error
- func (e *Editor) PrintSpace(widthInRW int) error
- func (e *Editor) ResetColor() error
- func (e *Editor) SetAlignment(align attribute.Alignment) error
- func (e *Editor) SetCallback(cb Callback) error
- func (e *Editor) SetColor(color uint32) error
- func (e *Editor) SetTextUnitPx(textUnitPx fixed.Point26_6) error
- func (e *Editor) SetViewSize(viewLineCount, viewLineRuneWidth int) error
- func (e *Editor) Sync() error
- func (e *Editor) WindowLineCount() (int, error)
- func (e *Editor) WindowRuneWidth() (int, error)
- type EditorOptions
- type ImageBytesLoader
- type ImageFetchResult
- type Message
- type MessageID
- type MessageLooper
- type MessageType
Constants ¶
const ( MessageTypeTask MessageType = 0 MessageAsyncTask = MessageTypeTask + iota // same as MessageTypeTask MessageSyncTask )
Variables ¶
var DefaultCachedImageSize = text.DefaultCachedImageSize
DefaultCachedImageSize is used as a number of cached images.
var ErrMessageLooperClosed = errors.New("MessageLooper is closed")
ErrMEssageLooperClosed indicates API call is failed due to MessageLooper is already closed.
var ResetColor = text.ResetColor
ResetColor is imported from text.ResetColor so that user need not to import text package explicitly.
Functions ¶
func ColorRGBAToInt32RGB ¶
Color RGBA converts from color.RGBA to int32 type RGB color #0xRRGGBB. NOTE: A is not considered
func ColorRGBAToUInt32RGB ¶
Color RGBA converts from color.RGBA to uint32 type RGB color #0xRRGGBB. NOTE: A is not considered
func Int32RGBToColorRGBA ¶
Int32ColorToColorRGBA converts from int32 type RGB color #0xRRGGBB to color.RGBA NOTE: A is not considered
func UInt32RGBToColorRGBA ¶
UInt32ColorToColorRGBA converts from uint32 type RGB color #0xRRGGBB to color.RGBA NOTE: A is not considered
Types ¶
type APIError ¶ added in v0.9.0
APIError is an error wrapper with API Name.
type Callback ¶
type Callback interface { // OnPublish is called when Paragraph is fixed by hard return (\n). OnPublish(*pubdata.Paragraph) error // OnPublishTemporary is called when Paragraph is NOT fixed yet by hard return(\n), // but required to show on UI. OnPublishTemporary(*pubdata.Paragraph) error // OnRemove is called when game thread requests to remove (N-1)-paragraphs which have been fixed // by calling OnPublish and also temporal Paragraph by calling OnPublishTemporary, thus to remove N-paragraphs. OnRemove(nParagraph int) error // OnRemoveAll is called when game thread requests to remove all paragraphs which have been fixed // by calling OnPublish and also temporal Paragraph by calling OnPublishTemporary. OnRemoveAll() error }
Callback defines callback interface. If callee somehow no longer handles the callback, return error to notify its status to the caller.
type CallbackDefault ¶
type CallbackDefault struct { OnPublishFunc func(*pubdata.Paragraph) error OnPublishTemporaryFunc func(*pubdata.Paragraph) error OnRemoveFunc func(nParagraph int) error OnRemoveAllFunc func() error }
CallbackDefault implements Callback interface. User can only set override interface functions to its fields. Otherwise the functions not set fields are called to do nothing.
func (*CallbackDefault) OnPublish ¶
func (cb *CallbackDefault) OnPublish(p *pubdata.Paragraph) error
OnPublish is called when Paragraph is fixed by hard return (\n).
func (*CallbackDefault) OnPublishTemporary ¶
func (cb *CallbackDefault) OnPublishTemporary(p *pubdata.Paragraph) error
OnPublishTemporary is called when Paragraph is NOT fixed yet by hard return(\n), but required to show on UI.
func (*CallbackDefault) OnRemove ¶
func (cb *CallbackDefault) OnRemove(nParagraph int) error
OnRemove is called when game thread requests to remove (N-1)-paragraphs which have been fixed by calling OnPublish and also temporal Paragraph by calling OnPublishTemporary, thus to remove N-paragraphs.
func (*CallbackDefault) OnRemoveAll ¶
func (cb *CallbackDefault) OnRemoveAll() error
OnRemoveAll is called when game thread requests to remove all paragraphs which have been fixed by calling OnPublish and also temporal Paragraph by calling OnPublishTemporary.
type Editor ¶
type Editor struct {
// contains filtered or unexported fields
}
Editor edits just one Paragraph It only appends new content into Frame's last.
It is constructed by Frame.Editor(), not NewEditor() or Editor{}
Multiple Editors do not share their states.
func (*Editor) ClearLineAll ¶
Clear all lines containing historys.
func (*Editor) Close ¶
Close closes editor APIs. After calling this, any editor's API return error which is errors.Is(ErrMessageLooperClosed). This API waits until all of pending tasks are done.
func (*Editor) CurrentRuneWidth ¶
current rune width in the editting line.
func (*Editor) GetAlignment ¶
func (*Editor) MeasureImageSize ¶
func (e *Editor) MeasureImageSize(file string, widthInRW, heightInLC int) (retW, retH int, err error)
Measure Image size in text scale, width in rune-width and height in line-count. This is useful when PrintImage will call with either widthInRW or heightInLC is zero, the drawn image size shall be auto determined but client want to know determined size before calling PrintImage.
func (*Editor) PrintButton ¶
Print Clickable button text. it shows caption on screen and emits command when it is selected. It is no separatable in wrapping text.
func (*Editor) PrintImage ¶
Print image from file path. Image is exceptional case, which may draw image region exceed over 1 line.
func (*Editor) PrintLabel ¶
Print label text to screen. It should not be separated in wrapping text.
func (*Editor) PrintSpace ¶ added in v0.9.0
Print Space in output area. widthInRW is blank space width in runewidth, should be > 0.
func (*Editor) ResetColor ¶
func (*Editor) SetAlignment ¶
Set and Get Alignment
func (*Editor) SetCallback ¶
SetCallback set callback interface. This is goroutine safe, But some events do not call callback until reflation latency.
func (*Editor) SetTextUnitPx ¶
SetTextUnitPx sets text unit size in px. The text unit size means pixel region of drawn half character on UI. This setting affects calculation of image size in Editor.
func (*Editor) SetViewSize ¶
func (*Editor) Sync ¶
Sync flushes any pending output result, PrintXXX or ClearLine, at UI implementor. It can also use rate limitting for PrintXXX functions.
func (*Editor) WindowLineCount ¶
line count to fill the window height.
func (*Editor) WindowRuneWidth ¶
rune width to fill the window width.
type EditorOptions ¶
type EditorOptions struct { // ImageFetchType indicates how does image pixels fetched by Editor. ImageFetchType pubdata.ImageFetchType }
type ImageBytesLoader ¶
type ImageBytesLoader struct {
// contains filtered or unexported fields
}
ImageBytesLoader loads image byte contents with different image fetch methods. It caches returned image bytes.
func NewImageBytesLoader ¶
func NewImageBytesLoader( cacheSize int, fontSingleWidthPx, fontHeightPx fixed.Int26_6, fetchType pubdata.ImageFetchType, ) *ImageBytesLoader
func (*ImageBytesLoader) LoadBytes ¶
func (loader *ImageBytesLoader) LoadBytes(src string, widthInRW, heightInLC int) ImageFetchResult
type ImageFetchResult ¶
type ImageFetchResult struct { Bytes []byte TsSize text.TextScaleSize PxSize image.Point FetchType pubdata.ImageFetchType }
ImageFetchResult is a result of ImageBytesLoader::LoadBytes() It contains image bytes, text-scale image size, px-scale image size and fetched type of bytes.
type Message ¶
type Message struct { ID MessageID Type MessageType Task func() }
Message is task primitive executed in a event loop. Only Task should be set, others are optional.
type MessageID ¶
type MessageID uint64
MessageID indicates a unique ID for the Message. This is used by SyncTask to identify which task is waited for its done.
const (
DefaultMessageID MessageID = 0
)
type MessageLooper ¶
type MessageLooper struct {
// contains filtered or unexported fields
}
MessageLooper executes Message tasks in its event loop.
func NewMessageLooper ¶
func NewMessageLooper(ctx context.Context) *MessageLooper
NewMessageLooper create new MessageLooper instance and start event loop internally. So new instance can be used immediately for Send() message.
func (*MessageLooper) Close ¶
func (looper *MessageLooper) Close()
Close quits internal event loop. It is goroutine safe.