Documentation ¶
Overview ¶
Package gui provide the graphic user interface.
the standard coordinate system used by the gui package, is in pixel unit, the origin point (0, 0) is top left of the viewport, positive of x is right, positive of y is down, positive of z is toward the inner of screen. just like most of other GUI system in the world.
the z axis is typically useless in GUI, but it still a 3D system, can be embeded into the 3D scene in some situation.
|/ 0 ---------- x+ - 0 ------- x+ | /| | / | | / z+ | y+ y+
Index ¶
- Constants
- Variables
- func FactoryRegister()
- type Button
- type Color
- type Elem
- func (el *Elem) Bounds() Rect
- func (el *Elem) BoundsGLCoord() (rc Rect)
- func (el *Elem) Children() []IElem
- func (p *Elem) Class() string
- func (el *Elem) Index(x IElem) int
- func (el *Elem) Init()
- func (el *Elem) Insert(i int, x IElem)
- func (el *Elem) Parent() IElem
- func (el *Elem) Remove(i int) IElem
- func (el *Elem) RemoveAll()
- func (el *Elem) Render()
- func (el *Elem) SetBounds(rect Rect)
- func (el *Elem) SetParent(p IElem)
- func (el *Elem) SetWindow(w IWindow)
- func (el *Elem) Window() IWindow
- type IButton
- type IElem
- type IPane
- type IPane3D
- type ITestPane
- type ITestPane3D
- type IWidget
- type IWindow
- type Mat4
- type Pane
- type Pane3D
- func (p *Pane3D) Class() string
- func (pn *Pane3D) Frustum(left float32, right float32, bottom float32, top float32, near float32, ...)
- func (pn *Pane3D) Init()
- func (pn *Pane3D) Is3D() bool
- func (pn *Pane3D) LookAt(eye Vec3, lookAt Vec3, up Vec3)
- func (pn *Pane3D) Ortho(xMin float32, xMax float32, yMin float32, yMax float32, zMin float32, ...)
- func (pn *Pane3D) Perspective(fovy float32, aspect float32, near float32, far float32)
- func (pn *Pane3D) Render()
- func (pn *Pane3D) SetState(data []byte) error
- func (pn *Pane3D) State() ([]byte, error)
- type Rect
- type TestPane
- type TestPane3D
- type Vec2
- type Vec3
- type Vec4
- type Widget
- type Window
- func (p *Window) Class() string
- func (w *Window) Layout() *WndLayout
- func (w *Window) ObjID() string
- func (w *Window) OnCreate()
- func (w *Window) OnDestroy()
- func (w *Window) OnExpose(x, y, width, height float32)
- func (w *Window) OnMouseEnter(x, y float32)
- func (w *Window) OnMouseLeave(x, y float32)
- func (w *Window) OnMouseMove(x, y float32)
- func (w *Window) OnMousePress(btn int, x, y float32)
- func (w *Window) OnMouseRelease(btn int, x, y float32)
- func (w *Window) OnMouseWheel(vert bool, dz float32)
- func (w *Window) OnResize(width, height float32)
- func (w *Window) OnSkin()
- func (w *Window) Render()
- func (w *Window) SetLayout(wl *WndLayout) error
- func (w *Window) SetObjID(id string)
- func (w *Window) SetState(data []byte) error
- func (w *Window) State() ([]byte, error)
- type WndLayout
Constants ¶
const ( // HintResizable is int for window has resize box HintResizable = winl.HintResizable // HintVideo is hint for window with animated (FPS video) content HintVideo = winl.HintVideo // HintPainter is hint for 2d drawing using painter algorithm HintPainter = winl.HintPainter )
Variables ¶
var ( ErrWrongType = errors.New("Wrong type") ErrBadParams = errors.New("Bad params") )
Errors
Functions ¶
func FactoryRegister ¶
func FactoryRegister()
FactoryRegister register creator in factory for package gui
Types ¶
type Button ¶
type Button struct { Widget // contains filtered or unexported fields }
Button is button widget
type Elem ¶
type Elem struct { Self interface{} // contains filtered or unexported fields }
Elem class is abstract gui element
func (*Elem) BoundsGLCoord ¶
BoundsGLCoord reports bounds rect of the element, in OpenGL (Y-UP) coordinate.
type IButton ¶
type IButton interface { IWidget // Font returns current font Font() glman.Font // SetFont set the font SetFont(f glman.Font) // SetText set the text label on the button SetText(s string) // Text label on the button Text() string }
IButton is interface of class Button
type IElem ¶
type IElem interface { // Bounds reports bounds rect of the element Bounds() Rect // BoundsGLCoord reports bounds rect of the element, in OpenGL (Y-UP) coordinate. BoundsGLCoord() Rect // Children returns child elements Children() []IElem // Class name for factory Class() string // Index of x Index(x IElem) int // Init a new object Init() // Insert x at index i, if i < 0 then append to the end Insert(i int, x IElem) // Parent returns parent element Parent() IElem // Remove child at index i Remove(i int) IElem // RemoveAll remove all children RemoveAll() // Render the element Render() // SetBounds set the bounds rect of the element SetBounds(rect Rect) // SetParent set parent element SetParent(p IElem) // SetWindow set the owner window SetWindow(w IWindow) // Window reports the owner window Window() IWindow }
IElem is interface of class Elem
type IPane ¶
type IPane interface { IWidget // Is3D reports whether pane is 3D scene Is3D() bool // SetState from string SetState(data []byte) error // State to string State() ([]byte, error) }
IPane is interface of class Pane
type IPane3D ¶
type IPane3D interface { IPane // Frustum set projection to special frustum Frustum(left float32, right float32, bottom float32, top float32, near float32, far float32) // LookAt set view matrix to look at special point LookAt(eye Vec3, lookAt Vec3, up Vec3) // Ortho set projection to orthographic Ortho(xMin float32, xMax float32, yMin float32, yMax float32, zMin float32, zMax float32) // Perspective set projection to perspective Perspective(fovy float32, aspect float32, near float32, far float32) }
IPane3D is interface of class Pane3D
type ITestPane3D ¶
type ITestPane3D interface { IPane3D }
ITestPane3D is interface of class TestPane3D
type IWindow ¶
type IWindow interface { winl.IWindow // Layout return current split layout Layout() *WndLayout // ObjID returns the object id ObjID() string // OnSkin handle the skin change event OnSkin() // Render the scene Render() // SetLayout set the split layout SetLayout(wl *WndLayout) error // SetObjID set the object id SetObjID(id string) // SetState from string SetState(data []byte) error // State to string State() ([]byte, error) }
IWindow is interface of class Window
type Pane ¶
type Pane struct {
Widget
}
Pane is compound widget typically use as split area in window.
type Pane3D ¶
Pane3D is a pane for 3D scene
func (*Pane3D) Frustum ¶
func (pn *Pane3D) Frustum(left float32, right float32, bottom float32, top float32, near float32, far float32)
Frustum set projection to special frustum
func (*Pane3D) Ortho ¶
func (pn *Pane3D) Ortho(xMin float32, xMax float32, yMin float32, yMax float32, zMin float32, zMax float32)
Ortho set projection to orthographic
func (*Pane3D) Perspective ¶
Perspective set projection to perspective
type TestPane ¶
type TestPane struct { Pane // contains filtered or unexported fields }
TestPane is a pane for testing
type TestPane3D ¶
type TestPane3D struct {
Pane3D
}
TestPane3D is a pane for 3D scene
func NewTestPane3D ¶
func NewTestPane3D() *TestPane3D
NewTestPane3D create and init new TestPane3D object.
func (*TestPane3D) SetState ¶
func (pn *TestPane3D) SetState(data []byte) error
SetState from string
type Window ¶
type Window struct { // Window is underlying winl.Window winl.Window // super // contains filtered or unexported fields }
Window class wrap operating systems's window object.
func (*Window) OnMouseEnter ¶
OnMouseEnter event handler
func (*Window) OnMouseLeave ¶
OnMouseLeave event handler
func (*Window) OnMousePress ¶
OnMousePress event handler
func (*Window) OnMouseRelease ¶
OnMouseRelease event handler
func (*Window) OnMouseWheel ¶
OnMouseWheel event handler
type WndLayout ¶
type WndLayout struct { Vert bool `json:"vert,omitempty"` // split direction Sp float32 `json:"split,omitempty"` // split position Pane IPane `json:"-"` // associated pane Class string `json:"class,omitempty"` // pane' class Param string `json:"param,omitempty"` // params for create pane L *WndLayout `json:"left,omitempty"` // left or top child R *WndLayout `json:"right,omitempty"` // right or bottom child // contains filtered or unexported fields }
WndLayout is tree structure split window into multipile panes
func (*WndLayout) CalcLayout ¶
CalcLayout recursive calc wl.rc, and set to wl.Pane if any