eram

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

TODO: 1. Fix mouse to put top box not the bottom box

Index

Constants

View Source
const (
	Line4None = iota
	Line4Destination
	Line4Type
)
View Source
const (
	NexradToolbarOff     = -1
	NexradToolbarExtreme = 3
	NexradToolbarHeavy   = 23
	NexradToolbarAll     = 123
)

Settings for the NX LVL toolbar button / the NexradLevel preference. Non-OFF values match the digits the button displays (e.g., 23 = Heavy and Extreme). OFF is intentionally non-zero so the JSON zero value (from preference sets that predate this field) is reserved as "uninitialized" and gets migrated to the default.

Variables

View Source
var (
	ErrCommandFormat       = NewERAMError("FORMAT")
	ErrERAMAmbiguousACID   = NewERAMError("AMB ACID")
	ErrERAMIllegalACID     = NewERAMError("ILL CID")
	ErrERAMIllegalPosition = NewERAMError("ILLEGAL POSITION")
	ErrERAMIllegalValue    = NewERAMError("ILLEGAL VALUE")
	ErrERAMIllegalAirport  = NewERAMError("ILLEGAL AIRPORT")
	ErrIllegalUserAction   = NewERAMError("ILLEGAL USER ACTION")
	ErrERAMMapUnavailable  = NewERAMError("MAP UNAVAILABLE")
	ErrERAMMessageTooLong  = NewERAMError("MESSAGE TOO LONG")
	ErrERAMSectorNotActive = NewERAMError("SECTOR NOT ACTIVE")
)

Functions

func InitCommands added in v0.14.1

func InitCommands()

Types

type Badge added in v0.14.6

type Badge struct {
	Width  float32
	Height float32
	Fill   renderer.RGB
	Border renderer.RGB
}

Badge is an optional indicator on the left of a row: filled box with border.

type CAPair added in v0.15.0

type CAPair struct {
	ADSBCallsigns [2]av.ADSBCallsign
	Start         sim.Time
}

CAPair is an active conflict alert between two targets. Callsigns are stored alphabetically ordered so a pair has a single identity.

type CRRColor added in v0.13.3

type CRRColor int

CRRColor represents one of the selectable CRR colors. The palette approximates the figures provided by the user.

const (
	CRRGreen CRRColor = iota
	CRRYellow
	CRRMagenta
	CRRCyan
	CRRWhite
	CRRAmber
)

func (CRRColor) BaseRGB added in v0.13.3

func (c CRRColor) BaseRGB() renderer.RGB

BaseRGB returns the unscaled RGB for the CRR color.

func (CRRColor) BrightRGB added in v0.13.3

func (c CRRColor) BrightRGB(b radar.Brightness) renderer.RGB

BrightRGB applies an ERAM brightness to the base color.

type CRRGroup added in v0.13.3

type CRRGroup struct {
	Label    string
	Location math.Point2LL
	Color    CRRColor
	// Aircraft present in the group; value unused.
	Aircraft map[av.ADSBCallsign]struct{}
}

CRRGroup holds one CRR group definition and its aircraft membership.

type CRRLocation added in v0.14.0

type CRRLocation struct {
	Location math.Point2LL
	Token    string // Original token without // prefix (for deriving labels)
}

CRRLocation represents a parsed CRR location from //FIX, //FRD, etc.

type CommandInput added in v0.14.0

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

CommandInput holds the current state during command matching.

type CommandMode

type CommandMode int
const (
	CommandModeNone CommandMode = iota
	CommandModeDrawRoute
)

type CommandStatus

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

type CommonPreferences

type CommonPreferences struct {
	CharSize struct {
		Line4   int // Find out what this is
		RDB     int
		LDB     int
		FDB     int
		Toolbar int
		Outage  int // Again, what is this?
		Portal  int // Same here...
	}
	Brightness struct {
		Background radar.Brightness
		Cursor     radar.Brightness
		Text       radar.Brightness
		PRTGT      radar.Brightness
		UNPTGT     radar.Brightness
		PRHST      radar.Brightness
		UNPHST     radar.Brightness
		LDB        radar.Brightness
		SLDB       radar.Brightness
		WX         radar.Brightness
		NEXRAD     radar.Brightness
		Backlight  radar.Brightness
		Button     radar.Brightness
		Border     radar.Brightness
		Toolbar    radar.Brightness
		TBBRDR     radar.Brightness
		ABBRDR     radar.Brightness
		FDB        radar.Brightness
		Portal     radar.Brightness
		Satcomm    radar.Brightness
		ONFREQ     radar.Brightness
		Line4      radar.Brightness
		Dwell      radar.Brightness
		Fence      radar.Brightness
		DBFEL      radar.Brightness
		Outage     radar.Brightness
	}

	Line4Type    int
	FDBLdrLength int // Datablock leader line length: 0=no line (W/E only), 1=normal (default), 2=2x, 3=3x

	// NexradLevel encodes which NEXRAD precipitation levels are displayed,
	// using the digits the NX LVL toolbar button shows: 0=OFF, 3=Extreme,
	// 23=Heavy+Extreme, 123=Moderate+Heavy+Extreme.
	NexradLevel int

	TornOffButtons        map[string][2]float32 // button name -> screen position
	MasterToolbarPosition [2]float32            // top-left position of the master toolbar button
}

type DatablockFieldID added in v0.14.0

type DatablockFieldID string

DatablockFieldID identifies a datablock field for outline lookup.

const (
	DBFieldMain         DatablockFieldID = "main"
	DBFieldCallsign     DatablockFieldID = "callsign"
	DBFieldVCI          DatablockFieldID = "vci"
	DBFieldAltitude     DatablockFieldID = "altitude"
	DBFieldCID          DatablockFieldID = "cid"
	DBFieldHandoffSpeed DatablockFieldID = "handoff_speed"
	DBFieldSpeed        DatablockFieldID = "speed"
	DBFieldLine4        DatablockFieldID = "line4"
	DBFieldLine4Heading DatablockFieldID = "line4_heading"
	DBFieldLine4Speed   DatablockFieldID = "line4_speed"
	DBFieldPointOut     DatablockFieldID = "pointout"
)

type DatablockFieldSpec added in v0.14.0

type DatablockFieldSpec struct {
	Line int
	Col  int
	Cols int
}

DatablockFieldSpec describes a field location in line/column space (0-based).

type DatablockLayout added in v0.14.0

type DatablockLayout struct {
	Anchor      [2]float32
	CharWidth   float32
	LineHeight  float32
	LineSpacing float32
}

DatablockLayout captures the layout metrics for a rendered datablock.

func (DatablockLayout) FieldExtent added in v0.14.0

func (l DatablockLayout) FieldExtent(spec DatablockFieldSpec) math.Extent2D

FieldExtent returns the outline for the specified field.

func (DatablockLayout) LineExtent added in v0.14.0

func (l DatablockLayout) LineExtent(line, cols int) math.Extent2D

LineExtent returns the outline for a full line of the specified width.

type DatablockOutlines added in v0.14.0

type DatablockOutlines struct {
	Layout DatablockLayout
	Fields map[DatablockFieldID]math.Extent2D
	Lines  map[int]math.Extent2D
}

DatablockOutlines provides field and line outlines for a datablock.

type DatablockType

type DatablockType int

DatablockType enumerates the supported ERAM datablock formats. Only the general types are provided here; the specific contents are defined elsewhere.

const (
	// LimitedDatablock represents the two-line limited data block used for
	// untracked or unpaired targets.
	LimitedDatablock DatablockType = iota
	// FullDatablock represents the five line full data block.
	FullDatablock
	// EnhancedLimitedDatablock represents the optional enhanced limited data
	// block.  It behaves like LimitedDatablock with additional information.
	EnhancedLimitedDatablock
)

type ERAMError

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

func GetERAMError

func GetERAMError(e error, lg *log.Logger) *ERAMError

func NewERAMError

func NewERAMError(msg string, args ...any) *ERAMError

type ERAMMenuCell added in v0.14.6

type ERAMMenuCell struct {
	Label   string
	BgColor renderer.RGB
	Color   renderer.RGB
	Weight  float32                                // relative width; 0 = 1
	OnClick func(clickType ERAMMenuClickType) bool // return true = close menu
}

ERAMMenuCell is one pick area of a multi-cell row.

type ERAMMenuClickType added in v0.14.1

type ERAMMenuClickType int

ERAMMenuClickType distinguishes primary from tertiary clicks.

const (
	MenuClickPrimary ERAMMenuClickType = iota
	MenuClickTertiary
)

type ERAMMenuConfig added in v0.14.1

type ERAMMenuConfig struct {
	Title              string
	TitleLeftJustified bool // false = centered (default)
	ShowMButton        bool
	OnMClick           func(ERAMMenuClickType)
	Width              float32
	Font               *renderer.Font // row font; nil = ep.ERAMToolbarFont()
	TitleFont          *renderer.Font // title bar font; nil = same as Font
	ItemHeight         float32        // 0 = default 18px
	Rows               []ERAMMenuItem

	// Escape hatch for custom drawn content (e.g. CRR color swatches).
	// Returns the new cursor position after drawing.
	CustomContent func(cursor [2]float32, width float32,
		trid *renderer.ColoredTrianglesDrawBuilder,
		ld *renderer.ColoredLinesDrawBuilder,
		td *renderer.TextDrawBuilder,
		mouse *platform.MouseState) [2]float32
}

ERAMMenuConfig holds the full configuration for a menu drawn by DrawERAMMenu.

type ERAMMenuGrid added in v0.14.6

type ERAMMenuGrid struct {
	Rows        [][]ERAMMenuGridCell
	VisibleRows int  // rows shown per page
	Offset      *int // caller-owned first visible row index
}

ERAMMenuGrid is a scrollable grid of value pick areas. A reserved arrow column on the right scrolls by pages the way the ERAM altitude/heading/ speed menus do; the mouse wheel scrolls by rows.

type ERAMMenuGridCell added in v0.14.6

type ERAMMenuGridCell struct {
	Label   string
	BgColor renderer.RGB // zero value = section background
	Color   renderer.RGB
	Weight  float32 // relative width; 0 = 1
	// HoverSpansRow extends the hover outline across the row's full content
	// width (e.g. the altitude menu's interim T pick area, whose action
	// includes the altitude to its left).
	HoverSpansRow bool
	OnClick       func(clickType ERAMMenuClickType) bool // return true = close menu
}

ERAMMenuGridCell is one pick area in a value grid row.

type ERAMMenuInput added in v0.14.6

type ERAMMenuInput struct {
	Buf *string
}

ERAMMenuInput is a text input row; the caller owns the buffer and updates it from keyboard input.

type ERAMMenuItem added in v0.14.1

type ERAMMenuItem struct {
	Label    string
	BgColor  renderer.RGB
	Color    renderer.RGB
	Centered bool
	OnClick  func(clickType ERAMMenuClickType) bool // return true = close menu

	// If non-empty, drawn after Label inside an outlined box (Color is used for both the text and the box).
	BoxedSuffix string

	// If SubRows is non-nil, this row renders as a scrollable list instead of a single text row.
	SubRows     []ERAMScrollItem
	VisibleRows int                                          // Number of visible sub-rows; 0 = show all
	ScrollState *ERAMScrollState                             // Required if SubRows is non-nil
	OnSelect    func(index int, clickType ERAMMenuClickType) // Called when a sub-row is clicked

	// If Cells is non-nil, this row renders as side-by-side pick areas
	// (e.g. the heading menu's LT | PH | RT row).
	Cells []ERAMMenuCell

	// If Grid is non-nil, this row renders as a scrollable multi-column
	// value grid (e.g. the altitude/heading/speed pick lists).
	Grid *ERAMMenuGrid

	// If Input is non-nil, this row renders as a text input area. Keyboard
	// handling is the popup's responsibility (see keyboardPopup).
	Input *ERAMMenuInput
}

ERAMMenuItem describes a single row in the menu, or a scrollable list section if SubRows is set.

type ERAMMenuResult added in v0.14.1

type ERAMMenuResult struct {
	Extent     math.Extent2D
	Dismissed  bool
	RowExtents []math.Extent2D
}

ERAMMenuResult is returned by DrawERAMMenu.

type ERAMPane

type ERAMPane struct {
	ERAMPreferenceSets map[string]*PrefrenceSet `json:"PreferenceSets,omitempty"`

	TrackState map[av.ADSBCallsign]*TrackState `json:"TrackState,omitempty"`

	DisableERAMtoRadio bool `json:"-"`
	FlipNumericKeypad  bool

	InboundPointOuts  map[sim.ACID][]sim.ControlPosition
	OutboundPointOuts map[sim.ACID][]outboundPointOut

	QuickLookSectors map[string]struct{}

	// via QB ...
	AddedBeaconCodes []av.Squawk

	Input inputText `json:"-"`

	// Short-term conflict alert state; recomputed every caUpdateInterval.
	CAPairs []CAPair `json:"-"`

	VelocityTime int // 0, 1, 4, or 8 minutes

	IFPHelpers struct {
		ArrivalsColor    *[3]float32
		ApproachesColor  *[3]float32
		DeparturesColor  *[3]float32
		OverflightsColor *[3]float32
		AirspaceColor    *[3]float32
	}

	// CRR state (session)
	CRRGroups map[string]*CRRGroup `json:"CRRGroups,omitempty"`

	// ALTIM SET state (session)
	AltimSetAirports []string `json:"AltimSetAirports,omitempty"`

	// WX window state (session)
	WXReportStations []string `json:"WXReportStations,omitempty"`
	// contains filtered or unexported fields
}

func NewERAMPane

func NewERAMPane() *ERAMPane

func (*ERAMPane) Activate

func (ep *ERAMPane) Activate(r renderer.Renderer, pl platform.Platform, log *log.Logger)

func (*ERAMPane) CanTakeKeyboardFocus

func (ep *ERAMPane) CanTakeKeyboardFocus() bool

func (*ERAMPane) ClearTemporaryCursor added in v0.14.0

func (ep *ERAMPane) ClearTemporaryCursor()

ClearTemporaryCursor removes any temporary cursor override and rollback cursor.

func (*ERAMPane) DisplayName

func (ep *ERAMPane) DisplayName() string

func (*ERAMPane) Draw

func (ep *ERAMPane) Draw(ctx *panes.Context, cb *renderer.CommandBuffer)

func (*ERAMPane) DrawERAMMenu added in v0.14.1

func (ep *ERAMPane) DrawERAMMenu(ctx *panes.Context, transforms radar.ScopeTransformations,
	cb *renderer.CommandBuffer, origin [2]float32, cfg ERAMMenuConfig) ERAMMenuResult

DrawERAMMenu renders a floating popup menu and handles clicks.

func (*ERAMPane) DrawInfo

func (ep *ERAMPane) DrawInfo(c *client.ControlClient, p platform.Platform, lg *log.Logger)

func (*ERAMPane) DrawUI

func (ep *ERAMPane) DrawUI(p platform.Platform, config *platform.Config)

func (*ERAMPane) DrawView added in v0.14.6

func (ep *ERAMPane) DrawView(ctx *panes.Context, transforms radar.ScopeTransformations, cb *renderer.CommandBuffer, v View)

DrawView renders a View, processing chrome and clicks in this order: scroll bar → title-bar buttons → title-bar drag → body-tertiary menu → body-primary drag → finalize in-progress drag. Each handler consumes its click so Body sees only fall-through events.

func (*ERAMPane) ERAMFont

func (ep *ERAMPane) ERAMFont(size int) *renderer.Font

func (*ERAMPane) ERAMGeomapFont added in v0.14.4

func (ep *ERAMPane) ERAMGeomapFont(size int) *renderer.Font

ERAMGeomapFont returns the EramGeomap bitmap font that holds the navigational symbol glyphs (VOR / TACAN / airport / etc.) at one of three pixel sizes, selected by the MapSymbol.Size byte typically stored in video maps (1, 2, 3).

func (*ERAMPane) ERAMInputFont

func (ep *ERAMPane) ERAMInputFont() *renderer.Font

func (*ERAMPane) ERAMToolbarFont

func (ep *ERAMPane) ERAMToolbarFont() *renderer.Font

func (*ERAMPane) FullDatablockOutlines added in v0.14.0

func (ep *ERAMPane) FullDatablockOutlines(ctx *panes.Context, trk sim.Track,
	transforms radar.ScopeTransformations) (DatablockOutlines, bool)

FullDatablockOutlines returns outlines for the ERAM full datablock fields. Field extents are derived from the datablock's actual contents so they track what is drawn rather than each field's maximum width.

func (*ERAMPane) LoadedSim

func (ep *ERAMPane) LoadedSim(client *client.ControlClient, pl platform.Platform, lg *log.Logger)

func (*ERAMPane) OpenPopupAt added in v0.14.6

func (ep *ERAMPane) OpenPopupAt(ctx *panes.Context, originGuess [2]float32, width, height float32, titleFont *renderer.Font, hostExtent math.Extent2D) viewPopupPlacement

OpenPopupAt clamps originGuess so a menu with the given dimensions stays on screen — preferring to flip to the left of hostExtent when the popup would extend past the right edge of the pane — and warps the cursor to the center of the title-bar close (X) button. The returned placement carries the clamped origin plus the anchor side and pinned X that DrawView uses to keep the host view's pinned edge flush with the pop-up as the view resizes.

func (*ERAMPane) ResetSim

func (ep *ERAMPane) ResetSim(client *client.ControlClient, pl platform.Platform, lg *log.Logger)

func (*ERAMPane) ScaledRGBFromColorPickerRGB

func (ep *ERAMPane) ScaledRGBFromColorPickerRGB(input [3]float32) renderer.RGB

func (*ERAMPane) SetTemporaryCursor added in v0.14.0

func (ep *ERAMPane) SetTemporaryCursor(cursorType string, seconds float64, rollbackCursor string)

SetTemporaryCursor displays a cursor type for the given number of seconds.

func (*ERAMPane) Upgrade added in v0.14.4

func (ep *ERAMPane) Upgrade(from, to int)

type ERAMScrollItem added in v0.14.1

type ERAMScrollItem struct {
	Label string
	Color renderer.RGB
}

ERAMScrollItem describes one item in a scrollable list.

type ERAMScrollState added in v0.14.1

type ERAMScrollState struct {
	Offset      int // first visible item index
	SelectedIdx int // -1 = none
}

ERAMScrollState is caller-owned persistent state for a scrollable list.

type InterimAltitude added in v0.14.0

type InterimAltitude struct {
	Altitude int                // Altitude in feet
	Type     sim.InterimAltType // InterimNormal when no prefix is given
}

InterimAltitude holds an interim altitude value with optional type (P for procedure, L for local)

type Preferences

type Preferences struct {
	CommonPreferences

	Name string

	// ARTCC facility identifier for which this preference set applies (e.g., ZNY)
	ARTCC string

	Center math.Point2LL
	Range  float32

	CurrentCenter math.Point2LL

	VideoMapGroup string // ZNYMAP, AREAA, AREAB, etc

	AltitudeFilters []float32 // find out the different targets

	VideoMapVisible map[string]any

	DisplayToolbar bool

	Line4Size   int
	FDBSize     int
	PoralSize   int
	ToolbarSize int
	RDBSize     int // CRR datablocks
	LDBSize     int
	OutageSize  int
	CursorSize  int

	VideoMapBrightness map[string]radar.Brightness
	HistoryLength      int

	UseRightClick bool

	// CRR view preferences and configuration
	CRR struct {
		Visible       bool
		ListMode      bool // true: list, false: panel
		Opaque        bool
		ShowBorder    bool
		Lines         int
		Font          int
		Bright        radar.Brightness
		SelectedColor CRRColor
		ColorBright   map[CRRColor]radar.Brightness
		Position      [2]float32
		DisplayFixes  bool // ATC TOOLS overlay of CRR fixes
	}

	// ALTIM SET view preferences
	AltimSet struct {
		Visible        bool
		Position       [2]float32
		Opaque         bool
		ShowBorder     bool
		ShowIndicators bool
		Lines          int
		Col            int              // 1-4 columns
		Font           int              // 1-3
		Bright         radar.Brightness // 0-100
	}

	// WX view preferences
	WX struct {
		Visible        bool
		Position       [2]float32
		Opaque         bool
		ShowBorder     bool
		ShowIndicators bool
		Lines          int
		Font           int              // 1-3
		Bright         radar.Brightness // 0-100
	}

	// MCA (Message Composition Area) preferences
	MCA struct {
		Position [2]float32       // top-left of the feedback box
		PALines  int              // max number of preview/feedback area lines
		Width    int              // chars per line
		Font     int              // 1-3
		Bright   radar.Brightness // 0-100
	}

	// RA (Response Area) preferences
	RA struct {
		Position [2]float32
		Width    int              // chars per line
		Font     int              // 1-3
		Bright   radar.Brightness // 0-100
	}

	// TimeView (clock) preferences
	TimeView struct {
		Position   [2]float32
		Opaque     bool
		ShowBorder bool
		Font       int              // 1-3
		Bright     radar.Brightness // 0-100
	}

	BeaconCodeView struct {
		Visible    bool
		Position   [2]float32
		Opaque     bool
		ShowBorder bool
		Lines      int
		Col        int
		Font       int
		Bright     radar.Brightness
		SortManual bool
	}

	// Check list views (POS CHECK / EMERG CHECK). Only one is visible at a
	// time; Visible is an enum (checkListHidden/checkListPos/checkListEmerg)
	// rather than two booleans so the mutual exclusion is structural.
	CheckList struct {
		Visible    int
		Position   [2]float32
		Opaque     bool
		ShowBorder bool
		Lines      int
		Font       int
		Highlight  radar.Brightness
		Text       radar.Brightness
	}
	// contains filtered or unexported fields
}

func (*Preferences) Upgrade added in v0.14.4

func (p *Preferences) Upgrade(from, to int)

type PrefrenceSet

type PrefrenceSet struct {
	Current  Preferences
	Selected *int
	// Saved preference slots (10). Some slots may be nil. Each stored
	// Preferences includes ARTCC and VideoMapGroup so we can filter rows.
	Saved [numSavedPreferenceSets]*Preferences
}

func (*PrefrenceSet) Upgrade added in v0.14.4

func (p *PrefrenceSet) Upgrade(from, to int)

type Row added in v0.14.6

type Row struct {
	Badge *Badge
	Label string
	Body  string

	Centered bool

	// ID is the user-visible name used in the "DELETE <ID>" confirmation
	// popup, resolved per index via ViewSelectable.Label. Independent of
	// Label so rows whose visible text lives entirely in Body still get a
	// useful delete-popup string.
	ID string

	Color renderer.RGB

	// Toggled, when true, renders a RowList.HighlightColor fill behind the
	// row. Used by check list views for click-to-toggle highlighting.
	Toggled bool

	SpacerHeight float32

	// AfterDraw is called after the row content is drawn, with the row's
	// full extent and the baseline position where the body text starts.
	// Used by callers to add per-row decorations (e.g. AltimSet's altimeter
	// underline).
	AfterDraw func(extent math.Extent2D, bodyOrigin [2]float32, b *ViewBuilders)
}

Row is one row in a RowList. The layout has three logical regions:

[ Badge ][ Label ]  [ Body... wraps to multiple lines if needed ]
                    [ ...continuation aligned with Label start ]

If Centered is true, Label is centered across the row width and Badge/Body are ignored (used for group-header rows). If Body is empty, the row has just Badge + Label. If SpacerHeight > 0, the row renders nothing and just takes up that much vertical space (used for inter-group gaps in CRR list mode).

type RowList added in v0.14.6

type RowList struct {
	Font       *renderer.Font
	LineHeight float32

	TopPad    float32 // above each row's content
	BottomGap float32 // below each row's content

	// List-level padding applied once at the top/bottom of the whole list
	// (in addition to per-row TopPad/BottomGap).
	ListTopPad    float32
	ListBottomPad float32

	// Width is the wrap width for body text and is also the assumed render
	// width — Draw uses the body extent for placement but expects its width
	// to match this value.
	Width float32

	Rows []Row

	// MaxLines caps the total wrapped body lines rendered. The last visible
	// row is truncated mid-content if needed; subsequent rows are dropped.
	// 0 = unlimited.
	MaxLines int

	// SelectedRow is the index *within this column's Rows* of the
	// currently selected row, or -1 for none. applyRowSource computes
	// this per-column from the global ViewSelectionState.Selected (a
	// flat-Rows index).
	SelectedRow int

	// HighlightColor is the fill drawn behind rows with Row.Toggled=true
	// (multi-row toggle highlight, e.g. check list views). Independent of
	// SelectedRow/selection.
	HighlightColor renderer.RGB
	// contains filtered or unexported fields
}

RowList is package-internal. applyRowSource constructs one per column, calls Measure to learn the body height, then Draw / TextExtents during the View's Body callback.

func (*RowList) Draw added in v0.14.6

func (l *RowList) Draw(body math.Extent2D, b *ViewBuilders) []math.Extent2D

Draw renders the visible rows into body and returns per-rendered-row extents (P0 = bottom-left, P1 = top-right) for click hit-testing. Measure must have been called first.

func (*RowList) Measure added in v0.14.6

func (l *RowList) Measure() float32

Measure pre-wraps each row's body to fit Width and returns the height of the visible portion (after MaxLines truncation). Must be called before Draw / TextExtents.

func (*RowList) RowExtents added in v0.14.6

func (l *RowList) RowExtents(body math.Extent2D) []math.Extent2D

RowExtents returns one Extent2D per visible row: the full row rectangle (full body width × row height). Used by full-width row affordances (e.g. check list toggle) where the hit-test and hover outline should match the full-width highlight bar drawn behind toggled rows.

func (*RowList) TextExtents added in v0.14.6

func (l *RowList) TextExtents(body math.Extent2D) []math.Extent2D

TextExtents returns one Extent2D per visible row: a tight box around the rendered text (expanded by 1 px) for normal rows, or the full row extent for spacers and centered headers. Used for selection / hover hit-testing.

type RowSpacing added in v0.14.6

type RowSpacing int

RowSpacing selects the vertical padding rule for a ViewRowSource.

const (
	// RowSpacingCompact is the default for one-line rows (ALTIM SET, CODE,
	// CRR): lineH/4 above and below the list, lineH/4 below each row.
	RowSpacingCompact RowSpacing = iota
	// RowSpacingAiry is for rows whose Body may wrap to multiple lines
	// (WX): lineH/2 above and below each row's content.
	RowSpacingAiry
)

type TrackState

type TrackState struct {
	Track             av.RadarTrack
	PreviousTrack     av.RadarTrack
	PreviousAltitude  float32 // for seeing if the track is climbing or descending. This may need to be moved someplace else later
	PreviousTrackTime time.Time
	TrackTime         time.Time
	CID               int

	HistoryTracks     [6]historyTrack // I think it's six?
	HistoryTrackIndex int

	DatablockType DatablockType

	LeaderLineDirection *math.CardinalOrdinalDirection
	LeaderLineLength    int // 0=no line (W/E only), 1=normal (default), 2=2x, 3=3x

	ELDB bool
	EFDB bool

	DisplayJRing        bool
	DisplayReducedJRing bool

	DisplayVCI bool

	OSectorEndTime sim.Time

	ReachedAltitude bool

	HoverVCI bool // if the user is hovering over the VCI field

	HSFHide bool

	// p/o receiver keeps a FDB until cleared by QP <FLID>.
	PointOutFDBLocked bool
}

func (*TrackState) Climbing

func (ts *TrackState) Climbing() bool

func (*TrackState) Descending

func (ts *TrackState) Descending() bool

func (*TrackState) HaveHeading

func (ts *TrackState) HaveHeading() bool

func (*TrackState) HeadingVector

func (ts *TrackState) HeadingVector(nmPerLongitude, magneticVariation float32) math.Point2LL

func (*TrackState) IsLevel

func (ts *TrackState) IsLevel() bool

func (*TrackState) TrackDeltaAltitude

func (ts *TrackState) TrackDeltaAltitude() int

func (*TrackState) TrackHeading

func (ts *TrackState) TrackHeading(nmPerLongitude float32) math.TrueHeading

type View added in v0.14.6

type View struct {
	Position *[2]float32

	// ID identifies this view for the pane-wide drag state (ep.viewRepo).
	// Must be unique across all views and stable across frames.
	ID string

	// Width is the body *content* width. DrawView adds 2 space characters
	// (per BodyFont) of reserve on the right when Scroll is non-nil so the
	// scroll bar can be drawn without overlapping content.
	Width      float32
	BodyHeight float32

	Title string

	// BodyFont is the font used for measuring body-related layout that
	// DrawView itself performs — currently just the scroll-bar reserve.
	// Falls back to the title font when nil.
	BodyFont *renderer.Font

	Opaque     bool
	ShowBorder bool
	Brightness radar.Brightness

	// OpaqueOnlyBg controls how the body background reacts to Opaque. When
	// false (default), the body background is always drawn black — used by
	// every multi-row view. When true, the body background follows Opaque:
	// grey (scaled by Brightness) when Opaque, not drawn at all when not
	// Opaque. Clock uses this so the scope shows through in T mode.
	OpaqueOnlyBg bool

	OnMenu func(host math.Extent2D) popup

	// OnMinimize enables the title-bar "-" button: when non-nil, clicking
	// "-" invokes the callback. Callers typically set a "Visible" pref to
	// false (or to a hidden-sentinel value for enum-style visibility).
	OnMinimize func()

	OnBodyTertiaryMenu func(host math.Extent2D) popup

	DrawBody func(extent math.Extent2D, b *ViewBuilders)

	// RowSource, when set, supplies a column-major list-of-rows body.
	// DrawView builds per-column layouts, computes Width / BodyHeight, and
	// wires scroll / selectable. Callers must NOT also set Width,
	// BodyHeight, or DrawBody when RowSource is set.
	RowSource *ViewRowSource
	// contains filtered or unexported fields
}

View is the declarative spec. See package overview above.

type ViewBuilders added in v0.14.6

ViewBuilders is passed to a View's DrawBody callback. The draw builders are pooled by DrawView and flushed after DrawBody returns; DrawBody should not Generate* on them.

type ViewRepoState added in v0.14.6

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

ViewRepoState is the pane-wide drag-to-reposition state. Only one view can be repositioned at a time, so a single instance lives on ERAMPane and activeID identifies which view (by View.ID) currently owns the drag.

func (*ViewRepoState) Cancel added in v0.14.6

func (s *ViewRepoState) Cancel()

Cancel ends an in-progress drag.

type ViewRowSource added in v0.14.6

type ViewRowSource struct {
	// Rows is the flat slice in display order. Distributed column-major
	// (first VisibleRows fill column 0, next VisibleRows fill column 1, …).
	// Row.Color is filled with the View's default text color where the row
	// leaves it zero.
	Rows []Row

	// FontIndex selects ERAMFont(FontIndex); clamped to [1,3].
	FontIndex int

	// ContentChars is the per-column body content width in characters of
	// the selected (fixed-width) font.
	ContentChars int

	MaxCols     int
	VisibleRows int

	// ReserveBadgeColumn reserves the leftmost badge column matching the
	// title-bar M button; this doesn't need to be set if ShowBadges is true,
	// only if we want to reserve badge space but not fill it.
	ReserveBadgeColumn bool

	// ShowBadges draws the standard yellow fill in the badge column, scaled
	// by Brightness. Implies ReserveBadgeColumn.
	ShowBadges bool

	RowSpacing RowSpacing

	// ScrollState, when non-nil, enables the scroll bar. MaxOffset is
	// computed as max(0, len(Rows) - VisibleRows*MaxCols).
	ScrollState *ViewScrollState

	// CenterColumnsInTitleBar widens the view to at least the title bar's
	// minimum width and horizontally centers the column block. Used by CODE.
	CenterColumnsInTitleBar bool

	// EmptyKeepsColumnWidth keeps width = column width (rather than
	// collapsing to 0) when Rows is empty. Used by ALTIM SET so the title
	// bar still renders at a reasonable size.
	EmptyKeepsColumnWidth bool

	// SelectableState / OnRowDelete wire click-to-delete by row index.
	// The selection highlight tracks SelectableState.Selected (an index
	// into Rows). OnRowDelete is called with the row's index; callers
	// typically use slices.Delete to remove it from a parallel slice.
	SelectableState *ViewSelectionState
	OnRowDelete     func(idx int)

	// OnRowToggle, when non-nil, makes rows clickable and invokes the
	// callback with the row's index into Rows. The caller flips its own
	// per-row state (typically a []bool) and re-sets Row.Toggled on the
	// next frame. Mutually exclusive with SelectableState.
	OnRowToggle func(idx int)

	// HighlightColor is the fill drawn behind rows with Row.Toggled=true.
	HighlightColor renderer.RGB

	// OnRowExtents, if non-nil, is called after each column's Draw with the
	// visible-row extents flattened in display order (col 0 rows, then col 1
	// rows, …) and the row index of the first visible row. Used by CRR
	// list mode to populate its own click-tracking maps.
	OnRowExtents func(firstVisible int, extents []math.Extent2D)
}

ViewRowSource declaratively describes a column-major list-of-rows body for a View. The View handles column layout, scroll, padding, badge geometry, side pads, and the default text color; callers describe only the row data, the per-column content width, and a handful of high-level flags.

type ViewScrollConfig added in v0.14.6

type ViewScrollConfig struct {
	State     *ViewScrollState
	MaxOffset int
}

ViewScrollConfig describes the optional scroll bar on the right edge of the body. State is caller-owned so the view's body can read Offset when rendering. MaxOffset is the largest valid State.Offset; the scroll bar is shown when MaxOffset > 0 and clicks clamp Offset to [0, MaxOffset].

type ViewScrollState added in v0.14.6

type ViewScrollState struct {
	Offset int
}

ViewScrollState is caller-owned scroll position.

type ViewSelectable added in v0.14.6

type ViewSelectable struct {
	State    *ViewSelectionState
	Items    func(body math.Extent2D) []ViewSelectableItem
	Label    func(idx int) string
	OnDelete func(idx int)
	OnToggle func(idx int)
}

ViewSelectable enables hover outlines and click-to-* on body rows. Either OnDelete (delete-confirmation popup, single selection) or OnToggle (multi-row toggle, no popup) is set, never both. Items is invoked once per frame with the body extent so the caller can derive row extents from their RowList without duplicating geometry math. Label resolves an index to the user-visible string shown in the "DELETE <X>" popup; required when OnDelete is set.

type ViewSelectableItem added in v0.14.6

type ViewSelectableItem struct {
	Extent math.Extent2D
	Idx    int
}

ViewSelectableItem is one selectable row inside the View body. Extent is the pane-coord hit-test rectangle; Idx is the row's index into the flat ViewRowSource.Rows slice (passed to OnDelete/OnToggle, and resolved through ViewSelectable.Label for the "DELETE <X>" popup display).

type ViewSelectionState added in v0.14.6

type ViewSelectionState struct {
	Selected int
}

ViewSelectionState is caller-owned selection tracking for the click-to-delete affordance. Selected is the index of the currently chosen row (into the flat ViewRowSource.Rows slice), or -1 for none. DrawView clears Selected automatically whenever the delete-confirmation popup is no longer the active popup, so dismissal via Escape, click-outside, or popup replacement all do the right thing. Callers must initialize new instances with Selected: -1 (zero value 0 would highlight row 0).

Jump to

Keyboard shortcuts

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