Documentation ¶
Index ¶
- Constants
- Variables
- func Activate(root *DisplayNode, r renderer.Renderer, p platform.Platform, ...)
- func DrawPanes(root *DisplayNode, p platform.Platform, r renderer.Renderer, ...) renderer.RendererStats
- func LoadedSim(root *DisplayNode, client *sim.ControlClient, state sim.State, ...)
- func RegisterUnmarshalPane(name string, fn func([]byte) (Pane, error))
- func ResetSim(root *DisplayNode, client *sim.ControlClient, state sim.State, ...)
- type Context
- type DisplayNode
- func (d *DisplayNode) FindPaneForMouse(displayExtent math.Extent2D, p [2]float32, plat platform.Platform) Pane
- func (d *DisplayNode) MarshalJSON() ([]byte, error)
- func (d *DisplayNode) NodeForPane(pane Pane) *DisplayNode
- func (d *DisplayNode) ParentNodeForPane(pane Pane) (*DisplayNode, int)
- func (d *DisplayNode) SplitX(x float32, newChild *DisplayNode) *DisplayNode
- func (d *DisplayNode) SplitY(y float32, newChild *DisplayNode) *DisplayNode
- func (d *DisplayNode) String() string
- func (d *DisplayNode) UnmarshalJSON(s []byte) error
- func (d *DisplayNode) VisitPanes(visit func(Pane))
- func (d *DisplayNode) VisitPanesWithBounds(displayExtent math.Extent2D, parentDisplayExtent math.Extent2D, ...)
- type EmptyPane
- func (ep *EmptyPane) Activate(renderer.Renderer, platform.Platform, *sim.EventStream, *log.Logger)
- func (ep *EmptyPane) CanTakeKeyboardFocus() bool
- func (ep *EmptyPane) Draw(ctx *Context, cb *renderer.CommandBuffer)
- func (ep *EmptyPane) Hide() bool
- func (ep *EmptyPane) LoadedSim(client *sim.ControlClient, ss sim.State, pl platform.Platform, lg *log.Logger)
- func (ep *EmptyPane) ResetSim(client *sim.ControlClient, ss sim.State, pl platform.Platform, lg *log.Logger)
- type FlightStripPane
- func (fsp *FlightStripPane) Activate(r renderer.Renderer, p platform.Platform, eventStream *sim.EventStream, ...)
- func (fsp *FlightStripPane) CanTakeKeyboardFocus() bool
- func (fsp *FlightStripPane) DisplayName() string
- func (fsp *FlightStripPane) Draw(ctx *Context, cb *renderer.CommandBuffer)
- func (fsp *FlightStripPane) DrawUI(p platform.Platform, config *platform.Config)
- func (fsp *FlightStripPane) Hide() bool
- func (fsp *FlightStripPane) LoadedSim(client *sim.ControlClient, ss sim.State, pl platform.Platform, lg *log.Logger)
- func (fsp *FlightStripPane) ResetSim(client *sim.ControlClient, ss sim.State, pl platform.Platform, lg *log.Logger)
- type KeyboardFocus
- type Message
- type MessagesPane
- func (mp *MessagesPane) Activate(r renderer.Renderer, p platform.Platform, eventStream *sim.EventStream, ...)
- func (mp *MessagesPane) CanTakeKeyboardFocus() bool
- func (mp *MessagesPane) DisplayName() string
- func (mp *MessagesPane) Draw(ctx *Context, cb *renderer.CommandBuffer)
- func (mp *MessagesPane) DrawUI(p platform.Platform, config *platform.Config)
- func (mp *MessagesPane) Hide() bool
- func (mp *MessagesPane) LoadedSim(client *sim.ControlClient, ss sim.State, pl platform.Platform, lg *log.Logger)
- func (mp *MessagesPane) ResetSim(client *sim.ControlClient, ss sim.State, pl platform.Platform, lg *log.Logger)
- type Pane
- type PaneUpgrader
- type ScrollBar
- type SplitLine
- func (s *SplitLine) Activate(renderer.Renderer, platform.Platform, *sim.EventStream, *log.Logger)
- func (s *SplitLine) CanTakeKeyboardFocus() bool
- func (s *SplitLine) Deactivate()
- func (s *SplitLine) Draw(ctx *Context, cb *renderer.CommandBuffer)
- func (s *SplitLine) Hide() bool
- func (s *SplitLine) LoadedSim(*sim.ControlClient, sim.State, platform.Platform, *log.Logger)
- func (s *SplitLine) ResetSim(*sim.ControlClient, sim.State, platform.Platform, *log.Logger)
- type SplitType
- type TypedDisplayNodePane
- type UIDrawer
- type WMKeyboardFocus
Constants ¶
const ( SplitAxisNone = iota SplitAxisX SplitAxisY )
Variables ¶
var UICautionColor renderer.RGB = renderer.RGBFromHex(0xB7B513)
var UIControlColor renderer.RGB = renderer.RGB{R: 0.2754237, G: 0.2754237, B: 0.2754237}
var UIErrorColor renderer.RGB = renderer.RGBFromHex(0xE94242)
var UITextColor renderer.RGB = renderer.RGB{R: 0.85, G: 0.85, B: 0.85}
var UITextHighlightColor renderer.RGB = renderer.RGBFromHex(0xB2B338)
Functions ¶
func Activate ¶
func Activate(root *DisplayNode, r renderer.Renderer, p platform.Platform, eventStream *sim.EventStream, lg *log.Logger)
func DrawPanes ¶
func DrawPanes(root *DisplayNode, p platform.Platform, r renderer.Renderer, controlClient *sim.ControlClient, menuBarHeight float32, audioEnabled *bool, lg *log.Logger) renderer.RendererStats
DrawPanes is called each time through the main rendering loop; it handles all of the details of drawing the Panes in the display hierarchy, making sure they don't inadvertently draw over other panes, and providing mouse and keyboard events only to the Pane that should respectively be receiving them.
Types ¶
type Context ¶
type Context struct { PaneExtent math.Extent2D ParentPaneExtent math.Extent2D Platform platform.Platform // If we want something to be n pixels big, scale factor to apply to n. // (This is necessary for Windows high-DPI displays, which just expose // their native resolution to us, vs. Mac which pretends retina // displays are 72dpi as far as graphics commands.) DrawPixelScale float32 PixelsPerInch float32 // DPIScale is similar to DrawPixelScale but always includes the // "retina" factor; this is mostly useful for drawing "chunky" 1 // pixel-wide lines and the like. DPIScale float32 Renderer renderer.Renderer Mouse *platform.MouseState Keyboard *platform.KeyboardState HaveFocus bool Now time.Time Lg *log.Logger MenuBarHeight float32 AudioEnabled *bool KeyboardFocus KeyboardFocus ControlClient *sim.ControlClient }
func (*Context) InitializeMouse ¶
func (*Context) SetWindowCoordinateMatrices ¶
func (ctx *Context) SetWindowCoordinateMatrices(cb *renderer.CommandBuffer)
type DisplayNode ¶
type DisplayNode struct { // non-nil only for leaf nodes: iff splitAxis == SplitAxisNone Pane Pane SplitLine SplitLine // non-nil only for interior notes: iff splitAxis != SplitAxisNone Children [2]*DisplayNode }
DisplayNode represents a node in the Pane display hierarchy, which is a kd-tree.
func NewDisplayPanes ¶
func NewDisplayPanes(stars, messages, fsp Pane) *DisplayNode
func (*DisplayNode) FindPaneForMouse ¶
func (d *DisplayNode) FindPaneForMouse(displayExtent math.Extent2D, p [2]float32, plat platform.Platform) Pane
FindPaneForMouse returns the Pane that the provided mouse position p is inside.
func (*DisplayNode) MarshalJSON ¶
func (d *DisplayNode) MarshalJSON() ([]byte, error)
MarshalJSON is called when a DisplayNode is to be marshaled into JSON. Here we instead marshal out a TypedDisplayNodePane that also stores the Pane's type.
func (*DisplayNode) NodeForPane ¶
func (d *DisplayNode) NodeForPane(pane Pane) *DisplayNode
NodeForPane searches a display node hierarchy for a given Pane, returning the associated DisplayNode.
func (*DisplayNode) ParentNodeForPane ¶
func (d *DisplayNode) ParentNodeForPane(pane Pane) (*DisplayNode, int)
ParentNodeForPane returns both the DisplayNode one level up the hierarchy from the specified Pane and the index into the children nodes for that node that leads to the specified Pane.
func (*DisplayNode) SplitX ¶
func (d *DisplayNode) SplitX(x float32, newChild *DisplayNode) *DisplayNode
SplitX returns a new DisplayNode that is the result of splitting the provided node horizontally direction at the specified offset (which should be between 0 and 1), storing the node as the new node's first child, and storing newChild as the's second child.
func (*DisplayNode) SplitY ¶
func (d *DisplayNode) SplitY(y float32, newChild *DisplayNode) *DisplayNode
SplitY returns a new DisplayNode from splitting the provided node vertically, analogous to the SplitX method.
func (*DisplayNode) String ¶
func (d *DisplayNode) String() string
func (*DisplayNode) UnmarshalJSON ¶
func (d *DisplayNode) UnmarshalJSON(s []byte) error
UnmarshalJSON unmarshals text into a DisplayNode; its main task is to use the type sting that comes along in the TypedDisplayNodePane to determine which Pane type to unmarshal the Pane's member variables into.
func (*DisplayNode) VisitPanes ¶
func (d *DisplayNode) VisitPanes(visit func(Pane))
VisitPanes visits all of the Panes in a DisplayNode hierarchy, calling the provided callback function for each one.
func (*DisplayNode) VisitPanesWithBounds ¶
func (d *DisplayNode) VisitPanesWithBounds(displayExtent math.Extent2D, parentDisplayExtent math.Extent2D, p platform.Platform, visit func(math.Extent2D, math.Extent2D, Pane))
VisitPanesWithBounds visits all of the panes in a DisplayNode hierarchy, giving each one both its own bounding box in window coordinates as well the bounding box of its parent node in the DisplayNodeTree.
type EmptyPane ¶
type EmptyPane struct {
// contains filtered or unexported fields
}
func NewEmptyPane ¶
func NewEmptyPane() *EmptyPane
func (*EmptyPane) CanTakeKeyboardFocus ¶
type FlightStripPane ¶
type FlightStripPane struct { FontSize int HideFlightStrips bool AutoAddDepartures bool AutoAddArrivals bool AutoAddOverflights bool AutoAddTracked bool AutoAddAcceptedHandoffs bool AutoRemoveDropped bool AutoRemoveHandoffs bool AddPushed bool CollectDeparturesArrivals bool // computer id number: 000-999 CIDs map[string]int AllocatedCIDs map[int]interface{} // estimated departure/arrival or coordination time, depending AircraftTimes map[string]time.Time // contains filtered or unexported fields }
func NewFlightStripPane ¶
func NewFlightStripPane() *FlightStripPane
func (*FlightStripPane) Activate ¶
func (fsp *FlightStripPane) Activate(r renderer.Renderer, p platform.Platform, eventStream *sim.EventStream, lg *log.Logger)
func (*FlightStripPane) CanTakeKeyboardFocus ¶
func (fsp *FlightStripPane) CanTakeKeyboardFocus() bool
func (*FlightStripPane) DisplayName ¶
func (fsp *FlightStripPane) DisplayName() string
func (*FlightStripPane) Draw ¶
func (fsp *FlightStripPane) Draw(ctx *Context, cb *renderer.CommandBuffer)
func (*FlightStripPane) DrawUI ¶
func (fsp *FlightStripPane) DrawUI(p platform.Platform, config *platform.Config)
func (*FlightStripPane) Hide ¶
func (fsp *FlightStripPane) Hide() bool
type KeyboardFocus ¶
type MessagesPane ¶
type MessagesPane struct { FontIdentifier renderer.FontIdentifier // contains filtered or unexported fields }
func NewMessagesPane ¶
func NewMessagesPane() *MessagesPane
func (*MessagesPane) Activate ¶
func (mp *MessagesPane) Activate(r renderer.Renderer, p platform.Platform, eventStream *sim.EventStream, lg *log.Logger)
func (*MessagesPane) CanTakeKeyboardFocus ¶
func (mp *MessagesPane) CanTakeKeyboardFocus() bool
func (*MessagesPane) DisplayName ¶
func (mp *MessagesPane) DisplayName() string
func (*MessagesPane) Draw ¶
func (mp *MessagesPane) Draw(ctx *Context, cb *renderer.CommandBuffer)
func (*MessagesPane) DrawUI ¶
func (mp *MessagesPane) DrawUI(p platform.Platform, config *platform.Config)
func (*MessagesPane) Hide ¶
func (mp *MessagesPane) Hide() bool
type Pane ¶
type Pane interface { // Activate is called once at startup time; it should do general, // Sim-independent initialization. Activate(r renderer.Renderer, p platform.Platform, eventStream *sim.EventStream, lg *log.Logger) // LoadedSim is called when vice is restarted and a Sim is loaded from disk. LoadedSim(client *sim.ControlClient, ss sim.State, pl platform.Platform, lg *log.Logger) // ResetSim is called when a brand new Sim is launched ResetSim(client *sim.ControlClient, ss sim.State, pl platform.Platform, lg *log.Logger) CanTakeKeyboardFocus() bool Hide() bool Draw(ctx *Context, cb *renderer.CommandBuffer) }
Panes (should) mostly operate in window coordinates: (0,0) is lower left, just in their own pane, oblivious to the full window size. Higher level code will handle positioning the panes in the main window.
type PaneUpgrader ¶
type PaneUpgrader interface {
Upgrade(prev, current int)
}
type ScrollBar ¶
type ScrollBar struct {
// contains filtered or unexported fields
}
ScrollBar provides functionality for a basic scrollbar for use in Pane implementations. (Since those are not handled by imgui, we can't use imgui's scrollbar there.)
func NewVerticalScrollBar ¶
NewVerticalScrollBar returns a new ScrollBar instance with the given width. invert indicates whether the scrolled items are drawn from the bottom of the Pane or the top; invert should be true if they are being drawn from the bottom.
func (*ScrollBar) Draw ¶
func (sb *ScrollBar) Draw(ctx *Context, cb *renderer.CommandBuffer)
Draw emits the drawing commands for the scrollbar into the provided CommandBuffer.
func (*ScrollBar) Offset ¶
Offset returns the offset into the items at which drawing should start (i.e., the items before the offset are offscreen.) Note that the scroll offset is reported in units of the number of items passed to Update; thus, if scrolling text, the number of items might be measured in lines of text, or it might be measured in scanlines. The choice determines whether scrolling happens at the granularity of entire lines at a time or is continuous.
func (*ScrollBar) PixelExtent ¶
type SplitLine ¶
type SplitLine struct { // Offset in [0,1] with respect to the parent Pane's bounds. Pos float32 Axis SplitType }
SplitLine represents a line separating two Panes in the display hierarchy. It implements the Pane interface, which simplifies some of the details of drawing and interacting with the display hierarchy.
func (*SplitLine) CanTakeKeyboardFocus ¶
func (*SplitLine) Deactivate ¶
func (s *SplitLine) Deactivate()
type TypedDisplayNodePane ¶
type TypedDisplayNodePane struct { DisplayNode Type string }
TypedDisplayNodePane helps with marshaling to and unmarshaling from JSON, which is how the configuration and settings are saved between sessions. Most of this works out pretty much for free thanks to go's JSON support and ability to automatically inspect and serialize structs. The one messy bit is that when we save the DisplayNode hierarchy, although the public member variables of Panes are automatically serialized, the types of the Panes are not. Therefore, we instead marshal/unmarshal TypedDisplayNodePane instances, which carry along a string representation of the associated Pane type stored at a DisplayNode.
type WMKeyboardFocus ¶
type WMKeyboardFocus struct {
// contains filtered or unexported fields
}
func (*WMKeyboardFocus) Current ¶
func (f *WMKeyboardFocus) Current() Pane
func (*WMKeyboardFocus) Release ¶
func (f *WMKeyboardFocus) Release()
func (*WMKeyboardFocus) Take ¶
func (f *WMKeyboardFocus) Take(p Pane)
func (*WMKeyboardFocus) TakeTemporary ¶
func (f *WMKeyboardFocus) TakeTemporary(p Pane)