Documentation ¶
Overview ¶
Package view implements the client.
Index ¶
- func C(p Pointer) complex128
- func Setup(doc dom.Document, gc GraphController)
- type Channel
- type ChannelController
- type Graph
- type GraphController
- type Group
- type Node
- type NodeController
- type Pin
- type PinController
- type Point
- type Pointer
- type Route
- type TextBox
- func (b *TextBox) CurrentText() string
- func (b *TextBox) MakeElements(doc dom.Document, parent dom.Element) *TextBox
- func (b *TextBox) RecomputeWidth() *TextBox
- func (b *TextBox) SetHeight(height float64) *TextBox
- func (b *TextBox) SetText(text string) *TextBox
- func (b *TextBox) SetWidth(w float64) *TextBox
- func (b *TextBox) Width() float64
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Setup ¶
func Setup(doc dom.Document, gc GraphController)
Setup connects to elements in the DOM.
Types ¶
type Channel ¶
type Channel struct { Group // Container for all the channel elements. // Cache of raw Pin objects which are connected. Pins map[*Pin]*Route // contains filtered or unexported fields }
Channel is the view's model of a channel.
func (*Channel) MakeElements ¶
MakeElements recreates elements for this channel and adds them to the parent.
type ChannelController ¶
type ChannelController interface { Name() string Pins(func(PinController)) // input called for all currently attached pins Attach(PinController) Detach(PinController) GainFocus() Commit(ctx context.Context) error Delete(ctx context.Context) error }
ChannelController is implemented by the controller of a channel.
type Graph ¶
type Graph struct { Group // container for all graph elements Nodes map[string]*Node Channels map[string]*Channel // contains filtered or unexported fields }
Graph is the view-model of a graph.
type GraphController ¶
type GraphController interface { GainFocus() // Sub-controllers Nodes(func(NodeController)) // input called for all nodes NumNodes() int Channels(func(ChannelController)) // input called for all channels NumChannels() int CreateChannel(pcs ...PinController) (ChannelController, error) CreateNode(ctx context.Context, partType string) (NodeController, error) // Send properties to server Commit(ctx context.Context) error // Action links Save(ctx context.Context) error Revert(ctx context.Context) error Generate(ctx context.Context) error Build(ctx context.Context) error Install(ctx context.Context) error Run(ctx context.Context) error PreviewGo() PreviewRawGo() PreviewJSON() // Misc HelpLicenses() HelpAbout() }
GraphController is implemented by the controller of a whole graph.
type Group ¶
Group includes handy methods for using SVG groups.
func (Group) BringToFront ¶
func (g Group) BringToFront()
BringToFront re-adds the group to the parent.
type Node ¶
type Node struct { Group TextBox *TextBox Inputs []*Pin Outputs []*Pin AllPins []*Pin // contains filtered or unexported fields }
Node is the view's model of a node.
func (*Node) MakeElements ¶
MakeElements makes the elements that are part of this node.
type NodeController ¶
type NodeController interface { Name() string Position() (x, y float64) Pins(func(pc PinController, channel string)) // input called for all pins on this node GainFocus() ShowMetadataSubpanel() ShowPartSubpanel(name string) Commit(ctx context.Context) error Delete(ctx context.Context) error SetPosition(ctx context.Context, x, y float64) error }
NodeController is implemented by the controller of a node.
type Pin ¶
type Pin struct { Group // Container for all the pin elements. Shape dom.Element // The pin itself. // contains filtered or unexported fields }
Pin represents a node pin visually, and has enough information to know if it is validly connected.
func (*Pin) MakeElements ¶
MakeElements recreates elements associated with this pin.
type PinController ¶
PinController is implemented by the controller for a pin.
type Pointer ¶
type Pointer interface {
Pt() Point
}
Pointer is anything that has a position on the canvas.
type Route ¶
type Route struct { Group // contains filtered or unexported fields }
Route is the visual connection between two points
type TextBox ¶
type TextBox struct { // Children Rectangle and Text, and Text has child TextNode. Group Rect dom.Element Text dom.Element TextNode dom.Element MinWidth float64 Margin float64 // contains filtered or unexported fields }
TextBox is an SVG group containing a filled rectangle and text.
func (*TextBox) CurrentText ¶
CurrentText returns the last string passed to SetText.
func (*TextBox) MakeElements ¶
MakeElements creates the DOM elements, organises them, and sets default attributes. The return is the main group.
func (*TextBox) RecomputeWidth ¶
RecomputeWidth resizes the textbox to fit all text (plus a margin).