nux

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2022 License: BSD-3-Clause Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	GESTURE_DOWN_DELAY                 = 100 * time.Millisecond
	GESTURE_DOWN2UP_DELAY              = 100 * time.Millisecond
	GESTURE_LONG_PRESS_TIMEOUT         = 500 * time.Millisecond
	GESTURE_DOUBLETAP_TIMEOUT          = 300 * time.Millisecond
	GESTURE_MIN_PAN_DISTANCE   float32 = 10 /*use dp*/
)
View Source
const (
	Mod_CapsLock uint32 = 0x10000 << iota
	Mod_Shift    uint32 = 0x10000 << iota
	Mod_Control  uint32 = 0x10000 << iota
	Mod_Alt      uint32 = 0x10000 << iota
	Mod_Super    uint32 = 0x10000 << iota
	Mod_Mask     uint32 = 0xFFFF0000
)
View Source
const (
	State_Disabled uint32 = 1 << iota
	State_Pressed
	State_Focused
	State_Hovered
	State_Checked
	State_Visited        // state of visited links
	State_Invalid        // invalid of input
	State_Default uint32 = 0
)
View Source
const (
	MaxMeasuredDimen int32 = 0x3FFFFFFF
)

Variables

View Source
var TestDraw func(Canvas)

Functions

func AddMixins

func AddMixins(widget Widget, mixin any)

func ApplyTheme

func ApplyTheme(kind ThemeKind, themes ...string)

func CheckPermissions

func CheckPermissions(permission []string) map[string]int

func CursorPositionScreenToWindow

func CursorPositionScreenToWindow(window Window, px, py float32) (x, y float32)

func CursorPositionWindowToScreen

func CursorPositionWindowToScreen(window Window, px, py float32) (x, y float32)

func DebugCheckMainThread

func DebugCheckMainThread()

func EjectChild

func EjectChild(child Widget)

func GestureArenaManager

func GestureArenaManager() *gestureArenaManager

func GestureManager

func GestureManager() *gestureRecognizerManager

func GetCursorScreenPosition

func GetCursorScreenPosition() (x, y float32)

Retrieves the position of the mouse cursor, in screen coordinates.

func GetCursorWindowPosition

func GetCursorWindowPosition(window Window) (x, y float32)

Retrieves the position of the mouse cursor, in window coordinates.

func GotoUI added in v0.1.0

func GotoUI(callback func())

func HoverGestureManager

func HoverGestureManager() *hoverGestureManager

func InvalidateRect

func InvalidateRect(x, y, width, height int32)

func IsMainThread

func IsMainThread() bool

func MountWidget

func MountWidget(child Widget, parent Parent)

func OnDoubleTap

func OnDoubleTap(widget Widget, callback GestureCallback)

func OnHover

func OnHover(widget Widget, callback GestureCallback)

func OnHoverEnter

func OnHoverEnter(widget Widget, callback GestureCallback)

func OnHoverExit

func OnHoverExit(widget Widget, callback GestureCallback)

func OnLongPress

func OnLongPress(widget Widget, callback GestureCallback)

func OnLongPressMove

func OnLongPressMove(widget Widget, callback GestureCallback)

func OnLongPressUp

func OnLongPressUp(widget Widget, callback GestureCallback)

func OnOtherTap

func OnOtherTap(widget Widget, callback GestureCallback)

func OnOtherTapCancel

func OnOtherTapCancel(widget Widget, callback GestureCallback)

func OnOtherTapDown

func OnOtherTapDown(widget Widget, callback GestureCallback)

func OnOtherTapUp

func OnOtherTapUp(widget Widget, callback GestureCallback)

func OnPanCancel

func OnPanCancel(widget Widget, callback GestureCallback)

func OnPanDown

func OnPanDown(widget Widget, callback GestureCallback)

func OnPanUp

func OnPanUp(widget Widget, callback GestureCallback)

func OnPanUpdate

func OnPanUpdate(widget Widget, callback GestureCallback)

func OnScaleEnd

func OnScaleEnd(widget Widget, callback GestureCallback)

func OnScaleStart

func OnScaleStart(widget Widget, callback GestureCallback)

func OnScaleUpdate

func OnScaleUpdate(widget Widget, callback GestureCallback)

func OnScrollX

func OnScrollX(widget Widget, callback GestureCallback)

func OnScrollY

func OnScrollY(widget Widget, callback GestureCallback)

func OnSecondaryTap

func OnSecondaryTap(widget Widget, callback GestureCallback)

func OnSecondaryTapCancel

func OnSecondaryTapCancel(widget Widget, callback GestureCallback)

func OnSecondaryTapDown

func OnSecondaryTapDown(widget Widget, callback GestureCallback)

func OnSecondaryTapUp

func OnSecondaryTapUp(widget Widget, callback GestureCallback)

func OnTap

func OnTap(widget Widget, callback GestureCallback)

func OnTapCancel

func OnTapCancel(widget Widget, callback GestureCallback)

func OnTapDown

func OnTapDown(widget Widget, callback GestureCallback)

func OnTapUp

func OnTapUp(widget Widget, callback GestureCallback)

func PickFileDialog

func PickFileDialog() *pickFileDialog

------------- PickFileDialog -----------------

func RegisterType

func RegisterType(niltype any, creator Creator)

func RemoveDoubleTapGesture

func RemoveDoubleTapGesture(widget Widget, callback GestureCallback)

widget will auto clear all gesture when destroy

func RemoveLongPressGesture

func RemoveLongPressGesture(widget Widget, callback GestureCallback)

func RemoveLongPressMoveGesture

func RemoveLongPressMoveGesture(widget Widget, callback GestureCallback)

func RemoveLongPressUpGesture

func RemoveLongPressUpGesture(widget Widget, callback GestureCallback)

func RemovePanCancelGesture

func RemovePanCancelGesture(widget Widget, callback GestureCallback)

func RemovePanDownGesture

func RemovePanDownGesture(widget Widget, callback GestureCallback)

func RemovePanUpGesture

func RemovePanUpGesture(widget Widget, callback GestureCallback)

func RemovePanUpdateGesture

func RemovePanUpdateGesture(widget Widget, callback GestureCallback)

func RequestFocus

func RequestFocus(widget Widget)

func RequestLayout

func RequestLayout(widget Widget)

func RequestPermissions

func RequestPermissions(permission []string, callback func(map[string]int))

func RequestRedraw

func RequestRedraw(widget Widget)

func RunOnUI

func RunOnUI(callback func())

func SaveFileDialog

func SaveFileDialog() *saveFileDialog

---------------- SaveFileDialog -------------------

func ScreenSize

func ScreenSize() (width, height int32)

func SetTextInputRect

func SetTextInputRect(x, y, width, height float32)

func StartTextInput

func StartTextInput()

func StateFromString

func StateFromString(state string) uint32

func StateToString

func StateToString(state uint32) string

func StopTextInput

func StopTextInput()

func Use

func Use(use ...any)

func ViewFileDialog

func ViewFileDialog() *viewFileDialog

----------- ViewFileDialog -------------------

Types

type Application

type Application interface {
	Init(manifest string)
	Run()
	Terminate()
	Manifest() Attr
	MainWindow() Window
}

func App

func App() Application

type Attr

type Attr map[string]any

func InflateStyle

func InflateStyle(style string) Attr

func InflateStyles

func InflateStyles(styles ...string) Attr

func MergeAttrs

func MergeAttrs(attrs ...Attr) (attr Attr)

merge attrs to a new single attr, the back will override front

func ParseAttr

func ParseAttr(attrtext string) Attr

ParseAttr parse attr string to Attr print error if has error and return empty Attr

func ParseAttrWitthError

func ParseAttrWitthError(attrtext string) (Attr, error)

func (Attr) Get

func (me Attr) Get(key string, defaultValue any) any

func (Attr) GetArray

func (me Attr) GetArray(key string, defaultValue []any) []any

func (Attr) GetAttr

func (me Attr) GetAttr(key string, defaultValue Attr) Attr

func (Attr) GetAttrArray

func (me Attr) GetAttrArray(key string, defaultValue []Attr) []Attr

func (Attr) GetBool

func (me Attr) GetBool(key string, defaultValue bool) bool

func (Attr) GetColor

func (me Attr) GetColor(key string, defaultValue Color) (result Color)

func (Attr) GetDimen

func (me Attr) GetDimen(key string, defaultValue string) Dimen

func (Attr) GetFloat32

func (me Attr) GetFloat32(key string, defaultValue float32) float32

func (Attr) GetFloat32Array added in v0.0.7

func (me Attr) GetFloat32Array(key string, defaultValue []float32) []float32

func (Attr) GetFloat64

func (me Attr) GetFloat64(key string, defaultValue float64) float64

func (Attr) GetInt

func (me Attr) GetInt(key string, defaultValue int) int

func (Attr) GetInt32

func (me Attr) GetInt32(key string, defaultValue int32) int32

func (Attr) GetInt64

func (me Attr) GetInt64(key string, defaultValue int64) int64

func (Attr) GetString

func (me Attr) GetString(key string, defaultValue string) string

func (Attr) GetStringArray

func (me Attr) GetStringArray(key string, defaultValue []string) []string

func (Attr) GetUint32

func (me Attr) GetUint32(key string, defaultValue uint32) (result uint32)

func (Attr) Has

func (me Attr) Has(key string) bool

func (Attr) Merge

func (me Attr) Merge(attr ...Attr)

func (Attr) Set

func (me Attr) Set(key string, value any)

func (Attr) String

func (me Attr) String() string

type Canvas

type Canvas interface {
	Save()
	Restore()

	Translate(x, y float32)
	Scale(x, y float32)
	Rotate(angle float32)
	Skew(x, y float32)                  // https://developer.android.com/reference/android/graphics/Canvas#skew(float,%20float)
	Transform(a, b, c, d, e, f float32) //
	SetMatrix(matrix Matrix)            // https://cairographics.org/manual/cairo-Transformations.html#cairo-set-matrix
	GetMatrix() Matrix                  // https://cairographics.org/manual/cairo-Transformations.html#cairo-get-matrix

	ClipRect(x, y, width, height float32)
	ClipRoundRect(x, y, width, height, cornerX, cornerY float32)
	ClipPath(path Path)

	///////////// draw
	SetAlpha(alpha float32)
	DrawRect(x, y, width, height float32, paint Paint)
	DrawRoundRect(x, y, width, height float32, rLT, rRT, rRB, rLB float32, paint Paint)
	DrawArc(x, y, radius, startAngle, endAngle float32, useCenter bool, paint Paint)
	DrawOval(x, y, width, height float32, paint Paint)
	DrawPath(path Path, paint Paint)
	// DrawColor(color Color)
	DrawImage(img Image)

	ResetClip()

	Flush()
	Destroy()
	// contains filtered or unexported methods
}

type Color

type Color uint32

rgba color

const (
	Transparent Color = 0x00000000
	White       Color = 0xFFFFFFFF
	Black       Color = 0x000000FF
	Red         Color = 0xFF0000FF
	Green       Color = 0x00FF00FF
	Blue        Color = 0x0000FFFF
	Purple      Color = 0xFF00FFFF
	Yellow      Color = 0xFFFF00FF
)

func FromARGB added in v0.1.0

func FromARGB(color uint32) Color

func ParseColor

func ParseColor(color string, defaultValue Color) (Color, error)

func (Color) ARGB

func (me Color) ARGB() uint32

func (Color) Equal

func (me Color) Equal(color Color) bool

func (Color) RGBAf

func (me Color) RGBAf() (r, g, b, a float32)

type Component

type Component interface {
	Widget
	SetContent(Widget)
	Content() Widget
}

type ComponentBase

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

func NewComponentBase

func NewComponentBase(owner Widget, attr Attr) *ComponentBase

func (*ComponentBase) Content

func (me *ComponentBase) Content() Widget

func (*ComponentBase) Info

func (me *ComponentBase) Info() *WidgetInfo

func (*ComponentBase) SetContent

func (me *ComponentBase) SetContent(content Widget)

type Creator

type Creator func(Attr) any

func FindTypeCreator

func FindTypeCreator(whichType any) Creator

type Cursor

type Cursor interface {
	Set()
}

func LoadNativeCursor

func LoadNativeCursor(c NativeCursor) Cursor

type Dimen

type Dimen int32
const (
	MaxDimen Dimen = 0x0FFFFFFF // 00001111111111111111111111111111
	MinDimen Dimen = -268435456 // 11110000000000000000000000000000

)

func ADimen

func ADimen(value float32, mode Mode) Dimen

func ParseDimen

func ParseDimen(s string) (Dimen, error)

func SDimen

func SDimen(s string) Dimen

func (Dimen) Mode

func (me Dimen) Mode() Mode

func (Dimen) String

func (me Dimen) String() string

func (Dimen) Value

func (me Dimen) Value() float32

type DoubleTapGestureRecognizer

type DoubleTapGestureRecognizer interface {
	GestureRecognizer
}

type Draw

type Draw interface {
	Draw(Canvas)
}

type Drawable

type Drawable interface {
	Stateable
	Size() (width, height int32)
	SetBounds(x, y, width, height int32)
	Draw(canvas Canvas)
	Equal(Drawable) bool
}

func InflateDrawable

func InflateDrawable(drawable any) Drawable

return: can be nil

func InflateDrawableAttr

func InflateDrawableAttr(attr Attr) Drawable

return: can be nil

type DrawableCreator

type DrawableCreator func(Attr) Drawable

type Eject

type Eject interface {
	OnEject()
}

type Event

type Event interface {
	Time() time.Time
	Type() EventType
	Action() EventAction
	Window() Window
	Data() any
}

type EventAction

type EventAction int
const (
	Action_None EventAction = iota
	Action_Down
	// Action_Move
	Action_Drag
	Action_Up
	Action_Hover
	Action_Scroll
	Action_Pressure

	// typing
	Action_Input
	Action_Preedit

	Action_WindowCreated
	Action_WindowMeasured
	Action_WindowDraw
	Action_WindowFocusGained
	Action_WindowFocusLost
	Action_WindowActived
	Action_WindowHide
)

func (EventAction) String

func (me EventAction) String() string

type EventType

type EventType int
const (
	Type_None EventType = iota
	Type_WindowEvent
	Type_TypingEvent
	Type_AppExit
	Type_KeyEvent
	Type_PointerEvent
	Type_ScrollEvent
	Type_BackToUI
)

func (EventType) String

func (me EventType) String() string

type Focus

type Focus interface {
	Focusable() bool
	HasFocus() bool
	FocusChanged(focus bool)
}

type Font

type Font interface {
	Family() string
	// SetFamily(family string)
	Size() int32
	SetSize(size int32)
	// contains filtered or unexported methods
}

func NewFont

func NewFont(attr Attr) Font

family: size: weight: string or int if font not exist rollback to default system font

type FontLayout

type FontLayout interface {
	MeasureText(font Font, paint Paint, text string, width, height int32) (textWidth, textHeight int32)
	DrawText(canvas Canvas, font Font, paint Paint, text string, width, height int32)
	CharacterIndexForPoint(font Font, text string, width, height int32, x, y float32) uint32
	// contains filtered or unexported methods
}

func NewFontLayout

func NewFontLayout() FontLayout

type FontWeight

type FontWeight int
const (
	FontWeight_Thin       FontWeight = 100
	FontWeight_ExtraLight FontWeight = 200
	FontWeight_Light      FontWeight = 300
	FontWeight_Normal     FontWeight = 400
	FontWeight_Medium     FontWeight = 500
	FontWeight_SemiBold   FontWeight = 600
	FontWeight_Bold       FontWeight = 700
	FontWeight_ExtraBold  FontWeight = 800
	FontWeight_Black      FontWeight = 900
)

func FontWeightFromName

func FontWeightFromName(name string) FontWeight

type Frame

type Frame struct {
	X       int32
	Y       int32
	Width   int32
	Height  int32
	Padding Side
	Margin  Side
}

func (*Frame) Clear

func (me *Frame) Clear()

func (*Frame) String

func (me *Frame) String() string

type GestureArenaMember

type GestureArenaMember interface {
	RejectGesture(pointer int64)
	AccpetGesture(pointer int64)
}

type GestureCallback

type GestureCallback func(detail GestureDetail)

type GestureDetail

type GestureDetail interface {
	Target() Widget
	Time() time.Time
	Kind() Kind
	X() float32
	Y() float32
	WindowX() float32
	WindowY() float32
	ScrollX() float32
	ScrollY() float32
}

type GestureRecognizer

type GestureRecognizer interface {
	GestureArenaMember
	PointerAllowed(event PointerEvent) bool
	HandleAllowedPointer(event PointerEvent)
	Clear(widget Widget) // clear callbacks of widget when ejected
}

type GestureState

type GestureState int
const (
	GestureState_Ready GestureState = iota + 1
	GestureState_Possible
	GestureState_Accepted
	GestureState_Rejected
)

type Gradient

type Gradient interface {
}

type HitTestResult

type HitTestResult interface {
	Add(widget Widget)
	Remove(widget Widget)
	Contain(widget Widget) bool
	Results() []Widget
}

func NewHitTestResult

func NewHitTestResult() HitTestResult

type HitTestable

type HitTestable interface {
	HitTest(widget Widget, hitTestResult HitTestResult, event PointerEvent)
}

type Image

type Image interface {
	PixelSize() (width, height int32)
	Draw(canvas Canvas)
}

func LoadImageFromFile

func LoadImageFromFile(filename string) (Image, error)

func LoadImageSVGFromFile

func LoadImageSVGFromFile(fileName string) Image

func LoadImageSVGFromReader

func LoadImageSVGFromReader(reader io.Reader) Image

func ReadImageSVG

func ReadImageSVG(svgstr string) Image

type KeyCode

type KeyCode uint32
const (
	Key_A            KeyCode = 0x61       // XK_a
	Key_B            KeyCode = 0x62       // XK_b
	Key_C            KeyCode = 0x63       // XK_c
	Key_D            KeyCode = 0x64       // XK_d
	Key_E            KeyCode = 0x65       // XK_e
	Key_F            KeyCode = 0x66       // XK_f
	Key_G            KeyCode = 0x67       // XK_g
	Key_H            KeyCode = 0x68       // XK_h
	Key_I            KeyCode = 0x69       // XK_i
	Key_J            KeyCode = 0x6a       // XK_j
	Key_K            KeyCode = 0x6b       // XK_k
	Key_L            KeyCode = 0x6c       // XK_l
	Key_M            KeyCode = 0x6d       // XK_m
	Key_N            KeyCode = 0x6e       // XK_n
	Key_O            KeyCode = 0x6f       // XK_o
	Key_P            KeyCode = 0x70       // XK_p
	Key_Q            KeyCode = 0x71       // XK_q
	Key_R            KeyCode = 0x72       // XK_r
	Key_S            KeyCode = 0x73       // XK_s
	Key_T            KeyCode = 0x74       // XK_t
	Key_U            KeyCode = 0x75       // XK_u
	Key_V            KeyCode = 0x76       // XK_v
	Key_W            KeyCode = 0x77       // XK_w
	Key_X            KeyCode = 0x78       // XK_x
	Key_Y            KeyCode = 0x79       // XK_y
	Key_Z            KeyCode = 0x7a       // XK_z
	Key_0            KeyCode = 0x30       // XK_0
	Key_1            KeyCode = 0x31       // XK_1
	Key_2            KeyCode = 0x32       // XK_2
	Key_3            KeyCode = 0x33       // XK_3
	Key_4            KeyCode = 0x34       // XK_4
	Key_5            KeyCode = 0x35       // XK_5
	Key_6            KeyCode = 0x36       // XK_6
	Key_7            KeyCode = 0x37       // XK_7
	Key_8            KeyCode = 0x38       // XK_8
	Key_9            KeyCode = 0x39       // XK_9
	Key_F1           KeyCode = 0xffbe     // XK_F1
	Key_F2           KeyCode = 0xffbf     // XK_F2
	Key_F3           KeyCode = 0xffc0     // XK_F3
	Key_F4           KeyCode = 0xffc1     // XK_F4
	Key_F5           KeyCode = 0xffc2     // XK_F5
	Key_F6           KeyCode = 0xffc3     // XK_F6
	Key_F7           KeyCode = 0xffc4     // XK_F7
	Key_F8           KeyCode = 0xffc5     // XK_F8
	Key_F9           KeyCode = 0xffc6     // XK_F9
	Key_F10          KeyCode = 0xffc7     // XK_F10
	Key_F11          KeyCode = 0xffc8     // XK_F11
	Key_F12          KeyCode = 0xffc9     // XK_F12
	Key_F13          KeyCode = 0xffca     // XK_F13
	Key_F14          KeyCode = 0xffcb     // XK_F14
	Key_F15          KeyCode = 0xffcc     // XK_F15
	Key_F16          KeyCode = 0xffcd     // XK_F16
	Key_F17          KeyCode = 0xffce     // XK_F17
	Key_F18          KeyCode = 0xffcf     // XK_F18
	Key_F19          KeyCode = 0xffd0     // XK_F19
	Key_F20          KeyCode = 0xffd1     // XK_F20
	Key_Return       KeyCode = 0xff0d     // XK_Return
	Key_Tab          KeyCode = 0xff09     // XK_Tab
	Key_Space        KeyCode = 0x0020     // XK_space
	Key_BackSpace    KeyCode = 0xff08     // XK_BackSpace
	Key_Escape       KeyCode = 0xff1b     // XK_Escape
	Key_CapsLock     KeyCode = 0xffe5     // XK_Caps_Lock
	Key_Alt          KeyCode = 0xffe9     // XK_Alt_L
	Key_RightAlt     KeyCode = 0xffea     // XK_Alt_R
	Key_Shift        KeyCode = 0xffe1     // XK_Shift_L
	Key_RightShift   KeyCode = 0xffe2     // XK_Shift_R
	Key_Control      KeyCode = 0xffe3     // XK_Control_L
	Key_RightControl KeyCode = 0xffe4     // XK_Control_R
	Key_Command      KeyCode = Key_Unknow // unknow
	Key_Equal        KeyCode = 0x003d     // XK_equal =+
	Key_Minus        KeyCode = 0x002d     // XK_minus -_
	Key_LeftBracket  KeyCode = 0x005b     // XK_bracketleft [{
	Key_RightBracket KeyCode = 0x005d     // XK_bracketright ]}
	Key_Quote        KeyCode = 0x0027     // XK_apostrophe '"
	Key_Semicolon    KeyCode = 0x003b     // XK_semicolon ;:
	Key_Comma        KeyCode = 0x002c     // XK_comma ,<
	Key_Period       KeyCode = 0x002e     // XK_period .>
	Key_Slash        KeyCode = 0x002f     // XK_slash /?
	Key_Backslash    KeyCode = 0x005c     // XK_backslash \|
	Key_Grave        KeyCode = 0x0060     // XK_grave `~
	Key_Menu         KeyCode = 0xff67     // XK_Menu
	Key_Function     KeyCode = Key_Unknow // Unknow
	Key_Left         KeyCode = 0xff51     // XK_Left
	Key_Right        KeyCode = 0xff53     // XK_Right
	Key_Down         KeyCode = 0xff54     // XK_Down
	Key_Up           KeyCode = 0xff52     // XK_Up
	Key_Mute         KeyCode = Key_Unknow // Unknow
	Key_VolumeUp     KeyCode = Key_Unknow // Unknow
	Key_VolumeDown   KeyCode = Key_Unknow // Unknow
	Key_Home         KeyCode = 0xff50     // XK_Home
	Key_End          KeyCode = 0xff57     // XK_End
	Key_PageUp       KeyCode = 0xff55     // XK_Page_Up
	Key_PageDown     KeyCode = 0xff56     // XK_Page_Down
	Key_Delete       KeyCode = 0xffff     // XK_Delete
	Key_Insert       KeyCode = 0xff63     // XK_Insert
	Key_Help         KeyCode = Key_Unknow // Unknow
	Key_Pad0         KeyCode = 0xffb0     // XK_KP_0
	Key_Pad1         KeyCode = 0xffb1     // XK_KP_1
	Key_Pad2         KeyCode = 0xffb2     // XK_KP_2
	Key_Pad3         KeyCode = 0xffb3     // XK_KP_3
	Key_Pad4         KeyCode = 0xffb4     // XK_KP_4
	Key_Pad5         KeyCode = 0xffb5     // XK_KP_5
	Key_Pad6         KeyCode = 0xffb6     // XK_KP_6
	Key_Pad7         KeyCode = 0xffb7     // XK_KP_7
	Key_Pad8         KeyCode = 0xffb8     // XK_KP_8
	Key_Pad9         KeyCode = 0xffb9     // XK_KP_9
	Key_PadDecimal   KeyCode = 0xffae     // XK_KP_Decimal
	Key_PadPlus      KeyCode = 0xffab     // XK_KP_Add +
	Key_PadMinus     KeyCode = 0xffad     // XK_KP_Subtract -
	Key_PadMultiply  KeyCode = 0xffaa     // XK_KP_Multiply *
	Key_PadDivide    KeyCode = 0xffaf     // XK_KP_Divide /
	Key_PadEnter     KeyCode = 0xff8d     // XK_KP_Enter
	Key_PadNumLock   KeyCode = 0xff7f     // XK_Num_Lock
	Key_PadBegin     KeyCode = 0xff9d     // XK_KP_Begin
	Key_Clear        KeyCode = 0xff0b     // XK_Clear
	Key_ScrollLock   KeyCode = 0xff14     // XK_Scroll_Lock
	Key_Pause        KeyCode = 0xff13     // XK_Pause
	Key_Snapshot     KeyCode = 0xff15     // XK_Sys_Req
	Key_PadEquals    KeyCode = Key_Unknow // Unknow
	Key_Back         KeyCode = Key_Unknow // AKEYCODE_BACK

)
const (
	Key_Unknow KeyCode = 0xffffffff
)

func (KeyCode) String

func (keyCode KeyCode) String() string

type KeyEvent

type KeyEvent interface {
	Event

	KeyCode() KeyCode
	Repeat() bool
	Modifiers() (none, capslock, shift, control, alt, super bool)
	Rune() rune // rune or 0
	// contains filtered or unexported methods
}

type KeyEventHandler

type KeyEventHandler interface {
	OnKeyEvent(event KeyEvent) bool
}

type Kind

type Kind int
const (
	Kind_None           Kind = 0 + iota //
	Kind_Mouse                          // A mouse-based pointer device.
	Kind_Touch                          // A touch-based pointer device.
	Kind_Stylus                         // Kind_Stylus A pointer device with a stylus that has been inverted.
	Kind_InvertedStylus                 // A pointer device with a stylus that has been inverted.
	Kind_Tablet                         // An tablet pointer device, same with mouse?
	Kind_Other                          // An other unknown pointer device.
)

func (Kind) String

func (me Kind) String() string

type Layout

type Layout interface {
	Layout(x, y, width, height int32)
}

type Manifest

type Manifest interface {
	Name() string
	AppID() string
	Package() string
	Version() string
	VersionCode() string
	VersionID() string
	Permissions() []string

	// Main main widget
	Main() string
}

func NewManifest

func NewManifest(attr Attr) Manifest

type Margin

type Margin struct {
	Left   Dimen
	Top    Dimen
	Right  Dimen
	Bottom Dimen
}

margin: !auto 10px 10dp 1em 1wt 5% !ratio !unlimit margin: {left: 10px, top: 10px, right: 10px, bottom: 10px} margin: 10px, 10px, 10px, 10px margin: 10px

func NewMargin

func NewMargin(attr any) *Margin

func (*Margin) Equal

func (me *Margin) Equal(value *Margin) bool

type Matrix

type Matrix struct {
	A float32
	B float32
	C float32
	D float32
	E float32
	F float32
}

type Measure

type Measure interface {
	Measure(width, height MeasureDimen)
}

type MeasureDimen

type MeasureDimen int32

Non-negative and only support Pixel, Auto, Unlimit

func MeasureSpec

func MeasureSpec(value int32, mode Mode) MeasureDimen

TODO:: rename to AMeasureDimen ?

func (MeasureDimen) Mode

func (me MeasureDimen) Mode() Mode

func (MeasureDimen) String

func (me MeasureDimen) String() string

func (MeasureDimen) Value

func (me MeasureDimen) Value() int32
type Menu interface {
	ID() string
	SetID(id string)
	Title() string
	SetTitle(title string)
	Icon() Image
	SetIcon(image Image)
	Action() func()
	SetAction(action func())
	Key() string
	SetKey(key string)
	Parent() Menu
	Content() Widget    // custom view
	SetContent() Widget // custom view
}
type MenuItem struct {
}

type Mode

type Mode byte
const (
	Pixel   Mode = iota // 1 means 1px
	Auto                // wrap content
	Unlimit             // MeasureDimen used Pixel, Auto, Unlimit
	Weight              // 1wt, no negative
	Ratio               // 16:9, no zero, no negative
	Percent             // 50% means (parent.size - parent.padding)*0.5
	Ems                 // 1em = 1 x font-size

)

func (Mode) String

func (me Mode) String() string

type Mount

type Mount interface {
	OnMount()
}

type NativeCursor

type NativeCursor int
const (
	CursorArrow NativeCursor = iota
	CursorIBeam
	CursorWait
	CursorCrosshair
	CursorResizeWE
	CursorResizeNS
	CursorResizeNWSE
	CursorResizeNESW
	CursorFinger
	CursorHand
	CursorDrag
	CursorSizeAll
	CursorCustom
)

type OnCreate

type OnCreate interface {
	OnCreate()
}

type OutsideShadow

type OutsideShadow interface {
	SetOutsideShadow(offsetX, offsetY, radius int32, color Color)
	OutsideShadow() (offsetX, offsetY, radius int32, color Color)
}

type Padding

type Padding struct {
	Left   Dimen
	Top    Dimen
	Right  Dimen
	Bottom Dimen
}
padding:  only supported definite size and Percent size

10px 10dp 1em 5% !auto !wt !ratio !unlimit padding Percent size is associate with parent size, eg: 5% = 0.05*parent.Width

func NewPadding

func NewPadding(attr any) *Padding

padding: {left: 10px, top: 10px, right: 10px, bottom: 10px} padding: 10px, 10px, 10px, 10px padding: 10px

func (*Padding) Equal

func (me *Padding) Equal(value *Padding) bool

type Paint

type Paint interface {
	Color() Color
	SetColor(color Color)
	AntiAlias() bool
	SetAntiAlias(antialias bool)
	Width() float32
	SetWidth(width float32)
	Style() PaintStyle
	SetStyle(style PaintStyle)
	// TextSize() float32 // TODO:: no use
	// SetTextSize(size float32)
	SetDash(dash []float32)
	Dash() []float32

	SetShadow(color Color, offsetX, offsetY, blur float32)
	Shadow() (color Color, offsetX, offsetY, blur float32)
	HasShadow() bool
	// contains filtered or unexported methods
}

func NewPaint

func NewPaint() Paint

type PaintStyle

type PaintStyle int
const (
	PaintStyle_Fill   PaintStyle = 1
	PaintStyle_Stroke PaintStyle = 2
	PaintStyle_Both   PaintStyle = 1 | 2
)

type Parent

type Parent interface {
	Widget
	InsertChild(index int, child ...Widget)
	AddChild(child ...Widget)
	RemoveChildAt(index int)
	RemoveChild(child Widget) (index int)
	ReplaceChild(src, dest Widget) (index int)
	Children() []Widget // the order of Children is from bottom to top
	ChildrenCount() int
	ChildAt(index int) Widget
	Find(id string) Widget
}

type Path

type Path interface {
	Rect(x, y, width, height float32)
	RoundRect(x, y, width, height, rLT, rRT, rRB, rLB float32)
	Ellipse(cx, cy, rx, ry float32)
	MoveTo(x, y float32)
	LineTo(x, y float32)
	CurveTo(x1, y1, x2, y2, x3, y3 float32)
	CurveToV(x2, y2, x3, y3 float32)
	Close()
	// contains filtered or unexported methods
}

func NewPath

func NewPath() Path

type PointerButton

type PointerButton int
const (
	ButtonNone PointerButton = iota
	ButtonPrimary
	ButtonSecondary
	ButtonMiddle
	ButtonX1
	ButtonX2
	ButtonOther
)

func (PointerButton) String

func (me PointerButton) String() string

type PointerEvent

type PointerEvent interface {
	Event

	Pointer() int64
	Kind() Kind
	X() float32
	Y() float32
	// Pressure() float32
	// Stage() int32
	IsPrimary() bool
	Distance(x, y float32) float32
	Button() PointerButton
	// contains filtered or unexported methods
}

type Rect

type Rect struct {
	X      int32
	Y      int32
	Width  int32
	Height int32
}

func (*Rect) Expand

func (me *Rect) Expand(rect *Rect)

type Response

type Response int
const (
	ResponseCancel Response = 0
	ResponseOK     Response = 1
)

type ScrollEvent

type ScrollEvent interface {
	Event

	X() float32
	Y() float32
	ScrollX() float32
	ScrollY() float32
	// contains filtered or unexported methods
}

type Side

type Side struct {
	Left   int32
	Top    int32
	Right  int32
	Bottom int32
}

type Size

type Size interface {
	Width() Dimen
	SetWidth(width Dimen)
	Height() Dimen
	SetHeight(height Dimen)
	Margin() *Margin     // can be nil
	SetMargin(*Margin)   // can be nil
	Padding() *Padding   // can be nil
	SetPadding(*Padding) // can be nil

	Frame() *Frame // not nil

	ScrollX() float32
	ScrollY() float32
	SetScroll(x, y float32)
	ScrollTo(x, y float32)

	AddSizeObserver(observer func())
	RemoveSizeObserver(observer func())
}

type StateBase

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

func NewStateBase

func NewStateBase(stateChanged func()) *StateBase

func (*StateBase) AddState

func (me *StateBase) AddState(state uint32) bool

func (*StateBase) DelState

func (me *StateBase) DelState(state uint32) bool

func (*StateBase) HasState

func (me *StateBase) HasState() bool

func (*StateBase) State

func (me *StateBase) State() uint32

type Stateable

type Stateable interface {
	AddState(state uint32) (changed bool)
	DelState(state uint32) (changed bool)
	State() uint32
	HasState() bool
}

type TapGestureRecognizer

type TapGestureRecognizer interface {
	GestureRecognizer
}

type Theme

type Theme interface {
	Kind() ThemeKind
	GetStyle(names ...string) Attr
}

func AppTheme

func AppTheme() Theme

type ThemeKind

type ThemeKind int
const (
	ThemeLight ThemeKind = iota
	ThemeDark
)

type Timer

type Timer interface {
	Cancel()
	Running() bool
}

func NewInterval

func NewInterval(duration time.Duration, callback func()) Timer

func NewTimerBackToUI

func NewTimerBackToUI(duration time.Duration, callback func()) Timer

type TypingEvent

type TypingEvent interface {
	Event
	Text() string
	Location() int32
	// contains filtered or unexported methods
}

type TypingEventHandler

type TypingEventHandler interface {
	OnTypingEvent(event TypingEvent) bool
}

type Widget

type Widget interface {
	Info() *WidgetInfo
}

func FindChild

func FindChild(widget Widget, id string) Widget

func InflateLayout

func InflateLayout(parent Widget, layout string, styles Attr) Widget

func InflateLayoutAttr

func InflateLayoutAttr(parent Widget, layout Attr, styles Attr) Widget

type WidgetBase

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

func NewWidgetBase

func NewWidgetBase(attr Attr) *WidgetBase

func (*WidgetBase) Info

func (me *WidgetBase) Info() *WidgetInfo

type WidgetCreator

type WidgetCreator func(Attr) Widget

type WidgetInfo

type WidgetInfo struct {
	Self    Widget
	ID      string
	Parent  Parent
	Mounted bool
	Mixins  []any
}

type WidgetOutsideShadow

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

func NewWidgetOutsideShadow

func NewWidgetOutsideShadow(dataChanged func(), attr Attr) *WidgetOutsideShadow

func (*WidgetOutsideShadow) OutsideShadow

func (me *WidgetOutsideShadow) OutsideShadow() (offsetX, offsetY, radius int32, color Color)

func (*WidgetOutsideShadow) SetOutsideShadow

func (me *WidgetOutsideShadow) SetOutsideShadow(offsetX, offsetY, radius int32, color Color)

type WidgetParent

type WidgetParent struct {
	*WidgetBase
	// contains filtered or unexported fields
}

func NewWidgetParent

func NewWidgetParent(owner Parent, attr Attr) *WidgetParent

func (*WidgetParent) AddChild

func (me *WidgetParent) AddChild(child ...Widget)

func (*WidgetParent) ChildAt

func (me *WidgetParent) ChildAt(index int) Widget

func (*WidgetParent) Children

func (me *WidgetParent) Children() []Widget

func (*WidgetParent) ChildrenCount

func (me *WidgetParent) ChildrenCount() int

func (*WidgetParent) Find

func (me *WidgetParent) Find(id string) Widget

func (*WidgetParent) GetWidget

func (me *WidgetParent) GetWidget(id string) Widget

func (*WidgetParent) InsertChild

func (me *WidgetParent) InsertChild(index int, child ...Widget)

func (*WidgetParent) RemoveChild

func (me *WidgetParent) RemoveChild(child Widget) int

func (*WidgetParent) RemoveChildAt

func (me *WidgetParent) RemoveChildAt(index int)

func (*WidgetParent) ReplaceChild

func (me *WidgetParent) ReplaceChild(src, dest Widget) int

type WidgetSize

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

func NewWidgetSize

func NewWidgetSize(attr Attr) *WidgetSize

func (*WidgetSize) AddSizeObserver

func (me *WidgetSize) AddSizeObserver(observer func())

func (*WidgetSize) Frame

func (me *WidgetSize) Frame() *Frame

func (*WidgetSize) Height

func (me *WidgetSize) Height() Dimen

func (*WidgetSize) Margin

func (me *WidgetSize) Margin() *Margin

func (*WidgetSize) Padding

func (me *WidgetSize) Padding() *Padding

func (*WidgetSize) RemoveSizeObserver

func (me *WidgetSize) RemoveSizeObserver(observer func())

func (*WidgetSize) ScrollTo

func (me *WidgetSize) ScrollTo(x, y float32)

func (*WidgetSize) ScrollX

func (me *WidgetSize) ScrollX() float32

func (*WidgetSize) ScrollY

func (me *WidgetSize) ScrollY() float32

func (*WidgetSize) SetHeight

func (me *WidgetSize) SetHeight(height Dimen)

func (*WidgetSize) SetMargin

func (me *WidgetSize) SetMargin(margin *Margin)

func (*WidgetSize) SetPadding

func (me *WidgetSize) SetPadding(padding *Padding)

TODO:: why not use value instead ref

func (*WidgetSize) SetScroll

func (me *WidgetSize) SetScroll(x, y float32)

func (*WidgetSize) SetWidth

func (me *WidgetSize) SetWidth(width Dimen)

func (*WidgetSize) Width

func (me *WidgetSize) Width() Dimen

type Window

type Window interface {
	Component

	Decor() Widget
	Title() string
	SetTitle(string)
	// Size()(width, height int32)
	// SetSize(width, height int32)
	ContentSize() (width, height int32)
	// Alpha() float32
	// SetAlpha(alpha float32)
	// SetDelegate(delegate WindowDelegate)
	// Delegate() WindowDelegate
	Center()
	Show()
	// contains filtered or unexported methods
}

type WindowEvent

type WindowEvent interface {
	Event
	// contains filtered or unexported methods
}

WindowEvent

Directories

Path Synopsis
internal
ios

Jump to

Keyboard shortcuts

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