docked

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package docked arranges widgets in dockable panels.

Group, LockedGroup, and Split build a tree of tabbed panels. NewRoot shows that tree and lets the user drag panels to redock them. Root can save and restore the arrangement as JSON. PaneView is a separate vertical stack of collapsible panes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction int
const (
	Horizontal Direction = iota
	Vertical
)

type Node

type Node struct {
	ID string
	// contains filtered or unexported fields
}

func Group

func Group(id string, panels ...*Panel) *Node

Group creates a named leaf node containing panels. ID must be stable across application runs when the node participates in layout serialization.

func LockedGroup

func LockedGroup(id string, panels ...*Panel) *Node

LockedGroup creates a named leaf node like Group, but one whose panels can never be dragged out, removed, or covered by another node's panels tabbed in via a drag. Use it for content that must always stay visible, such as a fixed viewport docked among otherwise rearrangeable panels. Other nodes can still be docked to its Left, Right, Top, or Bottom.

func Split

func Split(direction Direction, ratio float64, first, second *Node) *Node

type Pane

type Pane struct {
	Title       string
	Content     guigui.Widget
	Expanded    bool
	MinBodySize int
	MaxBodySize int
}

Pane is a data-only descriptor for a single collapsible panel within a PaneView. It is not a widget — the PaneView owns the rendering and input.

func NewPane

func NewPane(title string, content guigui.Widget) *Pane

type PaneView

type PaneView struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

PaneView is a vertical stack of collapsible panes with headers, similar to dockview's PaneView. Each pane has a header that is always visible; clicking it toggles the body content.

func (*PaneView) AddPane

func (pv *PaneView) AddPane(pane *Pane)

func (*PaneView) Build

func (pv *PaneView) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*PaneView) Layout

func (pv *PaneView) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*PaneView) Len

func (pv *PaneView) Len() int

func (*PaneView) Measure

func (pv *PaneView) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point

func (*PaneView) RemovePane

func (pv *PaneView) RemovePane(index int) *Pane

func (*PaneView) WriteStateKey

func (pv *PaneView) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

type Panel

type Panel struct {
	Title   string
	Content guigui.Widget
}

Panel is a unit of dockable content. Title labels the panel's tab, and Content is the widget shown while the panel is the active tab of its group.

type Position

type Position int
const (
	Left Position = iota
	Right
	Top
	Bottom
	Center
)

type Root

type Root struct {
	guigui.DefaultWidget
	// contains filtered or unexported fields
}

Root is a docking layout. Register every leaf with NewRoot, including leaves that start hidden, then add the root to the widget tree.

func NewRoot

func NewRoot(initial *Node, nodes ...*Node) (*Root, error)

func (*Root) Add

func (r *Root) Add(node, target *Node, position Position) bool

func (*Root) ApplyJSON

func (r *Root) ApplyJSON(data []byte) error

ApplyJSON validates and applies a layout snapshot atomically. Every node ID in the JSON must be registered with this Root; absent registered nodes remain absent from the restored layout.

func (*Root) Build

func (r *Root) Build(context *guigui.Context, adder *guigui.ChildAdder) error

func (*Root) Contains

func (r *Root) Contains(node *Node) bool

func (*Root) ContentAt

func (r *Root) ContentAt(p image.Point) guigui.Widget

func (*Root) CursorShape

func (r *Root) CursorShape(context *guigui.Context, widgetBounds *guigui.WidgetBounds) (ebiten.CursorShapeType, bool)

func (*Root) Draw

func (r *Root) Draw(context *guigui.Context, widgetBounds *guigui.WidgetBounds, dst *ebiten.Image)

func (*Root) HandlePointingInput

func (r *Root) HandlePointingInput(context *guigui.Context, widgetBounds *guigui.WidgetBounds) guigui.HandleInputResult

func (*Root) Layout

func (r *Root) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)

func (*Root) MarshalJSON

func (r *Root) MarshalJSON() ([]byte, error)

func (*Root) Remove

func (r *Root) Remove(node *Node) bool

func (*Root) ReplaceTree

func (r *Root) ReplaceTree(node *Node)

ReplaceTree swaps the docking tree. Used to enter play mode (emulator only) or restore a debug layout without recreating registered nodes. Edge bars are cleared; call Root.SetEdgeBar afterwards if needed.

func (*Root) SelectedContent

func (r *Root) SelectedContent(node *Node) guigui.Widget

func (*Root) SetEdgeBar

func (r *Root) SetEdgeBar(position Position, nodes ...*Node)

SetEdgeBar docks nodes as a sticky tab strip on the Left or Right edge. Nodes already in the tree are moved onto the bar. Other Position values are ignored. Nil nodes are skipped.

func (*Root) SetOnPanelClosed

func (r *Root) SetOnPanelClosed(f func(*Node))

func (*Root) WriteStateKey

func (r *Root) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)

Jump to

Keyboard shortcuts

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