Documentation ¶
Overview ¶
Package base is base package of GoVision.
This package contain TComponent/Component that is root of all GoVision components. Contains also TView/View that is base component of all display component. Application is the main struct to use GoVision.
Index ¶
- Constants
- func ApplicationHandler() uuid.UUID
- func BroadcastHandler() uuid.UUID
- func InHorizontal(x int, r Rect) bool
- func InVertical(y int, r Rect) bool
- func MaxInt(a int, b int) int
- func MinInt(a int, b int) int
- func PrintStringOnScreen(screen tcell.Screen, bc tcell.Color, fc tcell.Color, x int, y int, msg string)
- type Application
- type ApplicationConfig
- type ApplicationStyle
- type Bus
- type ByZorder
- type Canvas
- type Component
- func (c *Component) AddChild(child TComponent)
- func (c *Component) Children() []TComponent
- func (c *Component) GetEnabled() bool
- func (c *Component) GetMessageBus() Bus
- func (c *Component) GetOnEnabled() OnEnabled
- func (c *Component) GetOnReceiveMessage() OnReceiveMessage
- func (c *Component) GetParent() TComponent
- func (c *Component) GetZorder() int
- func (c *Component) HandleMessage(msg Message) bool
- func (c *Component) Handler() uuid.UUID
- func (c *Component) Name() string
- func (c *Component) RemoveChild(child TComponent)
- func (c *Component) SetEnabled(status bool)
- func (c *Component) SetOnEnabled(f OnEnabled)
- func (c *Component) SetOnReceiveMessage(f OnReceiveMessage)
- func (c *Component) SetParent(p TComponent)
- func (c *Component) SetZorder(i int)
- type Message
- func BuildActivateMessage(handler uuid.UUID) Message
- func BuildChangeBoundsMessage(handler uuid.UUID, bounds Rect) Message
- func BuildClickMouseMessage(handler uuid.UUID, ev *tcell.EventMouse, side uint) Message
- func BuildDesactivateMessage(handler uuid.UUID) Message
- func BuildDrawMessage(handler uuid.UUID) Message
- func BuildEmptyMessage() Message
- func BuildKeyMessage(event *tcell.EventKey) Message
- func BuildMouseEnterMessage(handler uuid.UUID, x, y int) Message
- func BuildMouseLeaveMessage(handler uuid.UUID) Message
- func BuildScreenResizeMessage(screen tcell.Screen) Message
- func BuildZorderMessage(handler uuid.UUID) Message
- type OnActivate
- type OnChangeBounds
- type OnDraw
- type OnEnabled
- type OnReceiveMessage
- type Rect
- type TCanvas
- type TComponent
- type TView
- type View
- func (v *View) AddChild(c TComponent)
- func (v *View) Canvas() TCanvas
- func (v *View) Children() []TComponent
- func (v *View) ClientCanvas() TCanvas
- func (v *View) Draw()
- func (v *View) GetBackgroundColor() tcell.Color
- func (v *View) GetBounds() Rect
- func (v *View) GetClientBounds() Rect
- func (v *View) GetEnabled() bool
- func (v *View) GetFocused() bool
- func (v *View) GetForegroundColor() tcell.Color
- func (v *View) GetMessageBus() Bus
- func (v *View) GetOnActivate() OnActivate
- func (v *View) GetOnChangeBounds() OnChangeBounds
- func (v *View) GetOnDraw() OnDraw
- func (v *View) GetOnEnabled() OnEnabled
- func (v *View) GetOnReceiveMessage() OnReceiveMessage
- func (v *View) GetParent() TComponent
- func (v *View) GetVisible() bool
- func (v *View) GetZorder() int
- func (v *View) HandleMessage(msg Message) bool
- func (v *View) Handler() uuid.UUID
- func (v *View) Name() string
- func (v *View) RemoveChild(c TComponent)
- func (v *View) SetBackgroundColor(c tcell.Color)
- func (v *View) SetBounds(r Rect)
- func (v *View) SetEnabled(e bool)
- func (v *View) SetFocused(f bool)
- func (v *View) SetForegroundColor(c tcell.Color)
- func (v *View) SetOnActivate(f OnActivate)
- func (v *View) SetOnChangeBounds(f OnChangeBounds)
- func (v *View) SetOnDraw(f OnDraw)
- func (v *View) SetOnEnabled(f OnEnabled)
- func (v *View) SetOnReceiveMessage(f OnReceiveMessage)
- func (v *View) SetParent(p TComponent)
- func (v *View) SetVisible(s bool)
- func (v *View) SetZorder(o int)
Constants ¶
const WaActive uint = 1
WaActive Activated.
const WaInactive uint = 0
WaInactive Deactivated.
const WmActivate uint = 16
WmActivate Sent to both the window being activated and the window being deactivated. Value can be WaActive or WaInactive.
const WmChangeBounds uint = 7
WmChangeBounds send to component to change size, or move.
const WmCreate uint = 9
WmCreate sent when you have create windows and want add in list.
const WmDestroy uint = 10
WmDestroy sent when you want remove windows from list and let GC remove it.
const WmDraw uint = 4
WmDraw draw component. Becarefull! If you send to one component, only this component and his child draw.
const WmEnable uint = 1
WmEnable send to enable or disable a component.
const WmKey uint = 2
WmKey when a key is pressed.
const WmLButtonDown uint = 12
WmLButtonDown send when left button pressed on window beneath cursor.
const WmLButtonUp uint = 13
WmLButtonUp send when left button released on window beneath cursor.
const WmMouse uint = 11
WmMouse send when mouse occure. Generally manage by Application struct. If nothing can be done with, send to Window struct.
const WmMouseEnter uint = 17
WmMouseEnter sent when mouse enter to TView.
const WmMouseLeave uint = 18
WmMouseLeave sent when mouse leave to TView.
const WmNull uint = 0
WmNull is empty message, ignore it (internal use only). This is never use by GoVision.
const WmQuit uint = 6
WmQuit force application to shutdown.
const WmRButtonDown uint = 14
WmRButtonDown send when right button pressed on window beneath cursor.
const WmRButtonUp uint = 15
WmRButtonUp send when right button released on window beneath cursor.
const WmScreenResize uint = 3
WmScreenResize when a screen size change.
const WmTimer uint = 8
WmTimer send to Timer parent component if OnTimer is nil.
const WmUser uint = ^uint(0) / 2
WmUser allow user to have own message.
const WmZorderChange uint = 5
WmZorderChange send to parent when you change Zorder of children.
Variables ¶
This section is empty.
Functions ¶
func ApplicationHandler ¶
ApplicationHandler is use to send message to application only.
func BroadcastHandler ¶
BroadcastHandler return value for broadcast all component.
Types ¶
type Application ¶
type Application struct { // Quit application on Ctrl+C. ExitOnCtrlC bool // Show text mouse cursor. ShowMouseCursor bool // contains filtered or unexported fields }
Application is base struct for create text UI.
func NewApplication ¶
func NewApplication(config ApplicationConfig) Application
NewApplication create a text application.
func (*Application) AddWindow ¶
func (a *Application) AddWindow(w TView)
AddWindow add window to list. If first window, she become the main window.
func (*Application) Canvas ¶
func (a *Application) Canvas() TCanvas
Canvas return application confguration.
func (*Application) Init ¶
func (a *Application) Init() error
Init initialize screen (color, style...).
func (*Application) MainWindow ¶
func (a *Application) MainWindow() TView
MainWindow return main windows.
func (*Application) SetEncodingFallback ¶
func (a *Application) SetEncodingFallback(fb tcell.EncodingFallback)
SetEncodingFallback changes the behavior of GetEncoding when a suitable encoding is not found. The default is EncodingFallbackFail, which causes GetEncoding to simply return nil.
func (*Application) WindowsList ¶
func (a *Application) WindowsList() []TView
WindowsList return the current windows list. Becarefull, each call create a new array to return.
type ApplicationConfig ¶
type ApplicationConfig struct { // Default style screen application. ScreenStyle ApplicationStyle // Screen of application. Screen tcell.Screen // Message bus. Message Bus }
ApplicationConfig is configuration of application.
func CreateDefaultApplicationConfig ¶
func CreateDefaultApplicationConfig() ApplicationConfig
CreateDefaultApplicationConfig create application config for almost case.
type ApplicationStyle ¶
type ApplicationStyle struct { // Default screen style. Style tcell.Style // Default screen text color. ForegroundColor tcell.Color // Default screen background color. BackgroundColor tcell.Color }
ApplicationStyle is style of screen for application.
type ByZorder ¶
type ByZorder []TComponent
ByZorder implements sort.Interface based on the zorder field.
type Canvas ¶
type Canvas struct {
// contains filtered or unexported fields
}
Canvas is virtal screen to draw components.
func (*Canvas) CreateCanvasFrom ¶
CreateCanvasFrom create a sub-canvas for `r` parameter.
func (*Canvas) PrintCharWithBrush ¶
PrintCharWithBrush print a charactere with brush.
func (*Canvas) UpdateBounds ¶
UpdateBounds call when component move or resize.
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component is the base object of all widget.
func NewComponent ¶
NewComponent create new component.
func (*Component) AddChild ¶
func (c *Component) AddChild(child TComponent)
AddChild add a child component.
func (*Component) Children ¶
func (c *Component) Children() []TComponent
Children return children list.
func (*Component) GetEnabled ¶
GetEnabled return if component is enable.
func (*Component) GetMessageBus ¶
GetMessageBus return application bus.
func (*Component) GetOnEnabled ¶
GetOnEnabled return function to be execute when receive enable message.
func (*Component) GetOnReceiveMessage ¶
func (c *Component) GetOnReceiveMessage() OnReceiveMessage
GetOnReceiveMessage return function to be execute when receive message.
func (*Component) GetParent ¶
func (c *Component) GetParent() TComponent
GetParent return parent of component. Nil -> no parent, maybe root component.
func (*Component) HandleMessage ¶
HandleMessage is use to manage message and give message to children.
func (*Component) RemoveChild ¶
func (c *Component) RemoveChild(child TComponent)
RemoveChild remove the child.
func (*Component) SetEnabled ¶
SetEnabled active or disable component.
func (*Component) SetOnEnabled ¶
SetOnEnabled set function when set enable.
func (*Component) SetOnReceiveMessage ¶
func (c *Component) SetOnReceiveMessage(f OnReceiveMessage)
SetOnReceiveMessage set function when receive message.
func (*Component) SetParent ¶
func (c *Component) SetParent(p TComponent)
SetParent set parent of component. Nil -> no parent, maybe root component.
type Message ¶
Message is data structure for any message.
func BuildActivateMessage ¶
BuildActivateMessage send message to windows gains focus.
func BuildChangeBoundsMessage ¶
BuildChangeBoundsMessage return a message to change bounds of component.
func BuildClickMouseMessage ¶
BuildClickMouseMessage send message to windows gains focus.
func BuildDesactivateMessage ¶
BuildDesactivateMessage send message to windows gains focus.
func BuildDrawMessage ¶
BuildDrawMessage return a message to force a component to redraw.
func BuildKeyMessage ¶
BuildKeyMessage build a message for keyboard event.
func BuildMouseEnterMessage ¶
BuildMouseEnterMessage send message to windows when mouse enter.
func BuildMouseLeaveMessage ¶
BuildMouseLeaveMessage send message to windows when mouse enter.
func BuildScreenResizeMessage ¶
BuildScreenResizeMessage build a resize message broadcast.
func BuildZorderMessage ¶
BuildZorderMessage return a message to change Zorder.
type OnChangeBounds ¶
type OnChangeBounds func(Rect)
OnChangeBounds is call when change bounds message receive.
type OnReceiveMessage ¶
type OnReceiveMessage func(TComponent, Message) bool
OnReceiveMessage is call when component receive message and you want overide behavior. Return true to stop message propagation.
type TCanvas ¶
type TCanvas interface { // Set brush property. SetBrush(b tcell.Style) // Create a canvas. CreateCanvasFrom(r Rect) TCanvas // Print char with current brush property. PrintChar(x int, y int, char rune) // Print char with brush. PrintCharWithBrush(x int, y int, char rune, brush tcell.Style) // Update position. UpdateBounds(r Rect) // Fill zone of canvas. Fill(bounds Rect) }
TCanvas is virtal screen to draw components.
type TComponent ¶
type TComponent interface { // Call when receive a message. // Return true if stop loop because message are manage by client. HandleMessage(Message) bool // Name of component. Name() string // Handler of component (UUID). Handler() uuid.UUID // Enable component. SetEnabled(bool) GetEnabled() bool // Parent component. SetParent(TComponent) GetParent() TComponent // Children component. AddChild(TComponent) RemoveChild(TComponent) Children() []TComponent // Odrer of draw. SetZorder(int) GetZorder() int // Return application configuration. GetMessageBus() Bus // Set function when receive message. SetOnReceiveMessage(OnReceiveMessage) // GetOnReceiveMessage return function to be execute when receive message. GetOnReceiveMessage() OnReceiveMessage // Set function when set enable. SetOnEnabled(OnEnabled) // GetOnEnabled return function to be execute when receive enable message. GetOnEnabled() OnEnabled }
TComponent is the base object of all widget.
type TView ¶
type TView interface { TComponent // External component size. SetBounds(Rect) GetBounds() Rect // Focus component. SetFocused(bool) GetFocused() bool // Visible component. SetVisible(bool) GetVisible() bool // Client size. GetClientBounds() Rect // Color of component. GetBackgroundColor() tcell.Color SetBackgroundColor(tcell.Color) GetForegroundColor() tcell.Color SetForegroundColor(tcell.Color) // Draw component Draw() // Canvas of view. Canvas() TCanvas // Client canvas of view. ClientCanvas() TCanvas SetOnDraw(OnDraw) GetOnDraw() OnDraw // Change bounds SetOnChangeBounds(OnChangeBounds) GetOnChangeBounds() OnChangeBounds // Activate SetOnActivate(OnActivate) GetOnActivate() OnActivate }
TView is the base object of all visual widget.
type View ¶
type View struct {
// contains filtered or unexported fields
}
View is the base object of all visual widget.
func (*View) Children ¶
func (v *View) Children() []TComponent
Children return list of children of component.
func (*View) ClientCanvas ¶
ClientCanvas return client canvas of view.
func (*View) GetBackgroundColor ¶
GetBackgroundColor return background color.
func (*View) GetClientBounds ¶
GetClientBounds return client size.
func (*View) GetEnabled ¶
GetEnabled return is component is enable.
func (*View) GetFocused ¶
GetFocused return true if component has focus.
func (*View) GetForegroundColor ¶
GetForegroundColor return text color.
func (*View) GetMessageBus ¶
GetMessageBus return application config.
func (*View) GetOnActivate ¶
func (v *View) GetOnActivate() OnActivate
GetOnActivate return OnActivate event.
func (*View) GetOnChangeBounds ¶
func (v *View) GetOnChangeBounds() OnChangeBounds
GetOnChangeBounds return OnChangeBounds event.
func (*View) GetOnEnabled ¶
GetOnEnabled return function to be execute when receive enable message.
func (*View) GetOnReceiveMessage ¶
func (v *View) GetOnReceiveMessage() OnReceiveMessage
GetOnReceiveMessage return function to be execute when receive message.
func (*View) HandleMessage ¶
HandleMessage is use to manage message.
func (*View) RemoveChild ¶
func (v *View) RemoveChild(c TComponent)
RemoveChild remove a child to component.
func (*View) SetBackgroundColor ¶
SetBackgroundColor change background color.
func (*View) SetForegroundColor ¶
SetForegroundColor change text color.
func (*View) SetOnActivate ¶
func (v *View) SetOnActivate(f OnActivate)
SetOnActivate set OnActivate event.
func (*View) SetOnChangeBounds ¶
func (v *View) SetOnChangeBounds(f OnChangeBounds)
SetOnChangeBounds set OnChangeBounds event.
func (*View) SetOnEnabled ¶
SetOnEnabled set function when set enable.
func (*View) SetOnReceiveMessage ¶
func (v *View) SetOnReceiveMessage(f OnReceiveMessage)
SetOnReceiveMessage set function when receive message.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
_demo
|
|
Package components is standard component library of GoVision.
|
Package components is standard component library of GoVision. |