window

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package window implements the framed Window view that hosts content on the desktop. v0.2 phase 1 delivers the minimum: a Frame border (title, optional close and zoom glyphs) and a Window that owns the frame plus a client rectangle. Drag, resize, zoom, modal dispatch, and the close button arrive in phase 2.

Index

Constants

FlagsAll enables every decoration. Stock IDE windows use this set.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flags

type Flags uint8

Flags controls which decorations the frame draws and which actions a Window will accept once phase 2 lands. Mirrors the flags Turbo Vision passes to Window.Init: wfMove, wfGrow, wfClose, wfZoom.

const (
	FlagMove Flags = 1 << iota
	FlagGrow
	FlagClose
	FlagZoom
)

Flag bits.

type Frame

type Frame struct {
	*view.View

	Title string

	PassiveSlot byte
	ActiveSlot  byte
	// contains filtered or unexported fields
}

Frame is the boxed border drawn around a Window. The frame paints a title centered along the top edge, plus optional close and zoom glyphs at the corners. Active windows use a different palette slot for the line glyphs so the focused window stands out.

A Frame's bounds are the same rectangle as its owning Window; the frame paints only the perimeter and leaves the interior untouched for the window's content children.

PassiveSlot and ActiveSlot let a Dialog point the frame at a different palette pair (e.g. 15/16 for the gray-on-gray dialog frame) without touching the regular window theme.

func NewFrame

func NewFrame(bounds vio.Rect, flags Flags) *Frame

NewFrame returns a frame sized to bounds, with the given decoration flags. Frames are not selectable on their own; the parent Window owns focus.

func (*Frame) Draw

func (f *Frame) Draw(s *vio.Surface)

Draw paints the box, title, and corner glyphs.

func (*Frame) Flags

func (f *Frame) Flags() Flags

Flags returns the frame's decoration flags.

func (*Frame) HandleEvent

func (f *Frame) HandleEvent(e *event.Event)

HandleEvent ignores everything; frames are decoration only in v0.2.1.

type Window

type Window struct {
	*view.Group

	Title  string
	Number int
	// contains filtered or unexported fields
}

Window is a framed Group hosted on the desktop. It owns a Frame child that paints the border and title; the rest of the children are content views laid out inside the client rectangle. v0.2 adds drag, resize, F5 zoom, Ctrl-F4 close, and a drop shadow.

func New

func New(bounds vio.Rect, title string, flags Flags) *Window

New returns a Window with the supplied bounds, title, and flags. The frame matches the bounds; the client rectangle is the bounds inset by 1 cell on every side. Insert the returned window into a Desktop (or any Group) to make it visible.

func (*Window) ChangeBounds

func (w *Window) ChangeBounds(r vio.Rect)

ChangeBounds resizes the window and keeps the frame aligned with the outer rectangle.

func (*Window) ClientRect

func (w *Window) ClientRect() vio.Rect

ClientRect returns the rectangle inside the frame that content views should occupy. It is the window bounds inset by 1 cell on each side.

func (*Window) Close

func (w *Window) Close()

Close removes the window from its owning group. Phase 3 will route this through a CmdClose command so dialogs can intercept (for example to prompt about unsaved changes); for v0.2 we close directly.

func (*Window) Draw

func (w *Window) Draw(s *vio.Surface)

Draw paints the drop shadow (when StateShadow is set), fills the client rectangle with the body color, and composes the frame and any content children on top. It also re-syncs the frame's active state from the window's focus, since Group.SetCurrent updates focus through the embedded *View and bypasses Window.SetState.

func (*Window) Flags

func (w *Window) Flags() Flags

Flags returns the window's decoration flags.

func (*Window) Frame

func (w *Window) Frame() *Frame

Frame returns the window's frame view, primarily for tests.

func (*Window) HandleEvent

func (w *Window) HandleEvent(e *event.Event)

HandleEvent runs window-level shortcuts (F5 zoom, Ctrl-F4 close) and mouse drag/resize before delegating to the embedded Group dispatch.

func (*Window) SetState

func (w *Window) SetState(bits view.State, on bool)

SetState propagates focus state into the frame so it switches between active and inactive palette slots.

func (*Window) SetTitle

func (w *Window) SetTitle(title string)

SetTitle updates the title shown in the frame.

func (*Window) Zoom

func (w *Window) Zoom()

Zoom toggles the window between its previous bounds and the bounds of its owner. Without an owner Zoom is a no-op.

func (*Window) Zoomed

func (w *Window) Zoomed() bool

Zoomed reports whether the window is currently zoomed to fill its owner.

Jump to

Keyboard shortcuts

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