Documentation
¶
Overview ¶
Package view defines vigo's base view types: View (the visual primitive) and Group (a container of views that owns event dispatch and composition). Concrete views embed *View and override the methods they need.
Index ¶
Constants ¶
const EventMaskDefault = event.ClassKey | event.ClassMouseDown | event.ClassMouseUp | event.ClassCommand | event.ClassBroadcast
EventMaskDefault is the default class mask: keys, primary mouse transitions, commands, and broadcasts.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Group ¶
Group is a View that owns a list of child views, dispatches events to them in three phases (pre-process, focused, post-process), and composes their drawing onto a Surface.
Groups carry an optional palette. Setting Palette on a group makes it the resolution point for any descendant View.MapColor lookup. In practice only Application sets a palette; intermediate groups leave it nil.
func (*Group) ChangeBounds ¶
ChangeBounds resizes the group and propagates the change to children based on each child's GrowMode. v0.1's behavior is the minimum needed for the demo: GrowAll children resize to fill the new bounds; GrowFixed children stay put. Per-edge growth flags are respected by adjusting the relevant edge.
func (*Group) Children ¶
Children returns the current child list. The slice is shared with the group; callers must not modify it directly.
func (*Group) Draw ¶
Draw composes all visible children onto s, in insertion order. A concrete subclass that needs a back-to-front Z order should override this.
func (*Group) HandleEvent ¶
HandleEvent dispatches e to children in three phases (pre, focused, post) and stops at the first child that consumes the event. Tab and Shift-Tab cycle focus through the selectable children when the focused child did not already consume them.
func (*Group) Insert ¶
Insert appends a child to the group. If the group has no current child yet and the new child is selectable, the new child becomes the focused one.
func (*Group) Remove ¶
Remove drops v from the group. If v was the current child, focus shifts to the next selectable child, or is cleared.
func (*Group) SetCurrent ¶
SetCurrent sets the focused child to the one at index i. Pass -1 to clear focus. Out-of-range indices clear focus.
type GrowMode ¶
type GrowMode uint8
GrowMode describes how a view's bounds change when its owner is resized. It mirrors Turbo Vision's gfXxx constants.
type Options ¶
type Options uint16
Options is a bitmask of options that affect how the framework dispatches events to a view and how the view participates in its owning group.
type State ¶
type State uint16
State is a bitmask of view state flags. The set roughly matches Borland Turbo Vision's sfXxx constants.
type View ¶
type View struct {
Owner *Group
Bounds vio.Rect
Cursor vio.Point
State State
Options Options
GrowMode GrowMode
HelpCtx uint16
EventMask event.Class
// PaletteIndex is the 1-based offset into the Application palette
// that this view uses for its primary fill color. Sub-classes may
// derive other colors by adding a small offset.
PaletteIndex byte
}
View is the embed-friendly base of every visual primitive. It holds the state shared by all views (bounds, cursor, owner, options, state, palette index) and provides default no-op implementations of the Viewer methods.
func NewView ¶
NewView returns a *View with the given bounds, the visible state set, and the default event mask.
func (*View) Base ¶
Base satisfies Viewer; concrete views embed *View, so their Base returns the embedded view by default.
func (*View) ChangeBounds ¶
ChangeBounds replaces v.Bounds. Sub-classes that need to react to a resize (re-laying out children, for example) override this.
func (*View) Draw ¶
Draw is the default drawing routine: fill the bounds with the view's primary palette color.
func (*View) HandleEvent ¶
HandleEvent is the default event handler: do nothing.