Documentation
¶
Index ¶
- Constants
- func PanelKeyOf(s PanelState) string
- type Area
- type AreaRef
- func (r *AreaRef) AddPanel(key string, p Placement, size core.Points)
- func (r *AreaRef) ClosePanel(key string)
- func (r *AreaRef) GroupOf(key string) (uint64, bool)
- func (r *AreaRef) Layout() Layout
- func (r *AreaRef) MovePanel(key string, t Target)
- func (r *AreaRef) RemovePanel(key string)
- func (r *AreaRef) SelectPanel(key string)
- func (r *AreaRef) SelectTab(group uint64, index int)
- func (r *AreaRef) SetDockOpen(p Placement, open bool)
- func (r *AreaRef) SetDockSize(p Placement, size core.Points)
- func (r *AreaRef) SplitAt(group uint64, key string, side core.Placement)
- func (r *AreaRef) ToggleDock(p Placement)
- func (r *AreaRef) ToggleZoom(group uint64)
- func (r *AreaRef) ZoomedGroup() (uint64, bool)
- type AreaState
- type DropIndicator
- type Info
- type Layout
- type Node
- type PanelInfo
- type PanelOptions
- type PanelState
- type Placement
- type Region
- type StackInfo
- type State
- type Tab
- type TabsInfo
- type Target
Constants ¶
const (
// PanelKeyName is the panel_name of the leaves PanelKey writes.
PanelKeyName = "Panel"
)
The names a persisted layout gives its containers, and the panels it keeps by key alone.
Variables ¶
This section is empty.
Functions ¶
func PanelKeyOf ¶
func PanelKeyOf(s PanelState) string
PanelKeyOf reads a leaf's key back: its info's "id", else its panel_name.
Types ¶
type Area ¶
type Area struct {
// Layout makes the area controlled: it shows what Layout returns and
// reports edits with OnLayoutChange, which the app passes back.
// Without it the area keeps its own, from DefaultLayout.
Layout func() Layout
DefaultLayout Layout
OnLayoutChange func(Layout)
// Locked rearranges nothing: no drags, drops or closes. Selecting,
// resizing and toggling docks still work.
Locked func() bool
// Compact presents the area compactly while it holds; docked when
// nil, whatever the device or the width, which the app reads to set
// it.
Compact func() bool
// Panels says what each panel allows, by key.
Panels map[string]PanelOptions
// RenderPanel renders a panel's content, by key.
RenderPanel func(cx *core.Scope, key string) core.Node
// RenderTab renders what a tab shows, the key as text without it; the
// area makes it the tab, whose press selects and drag moves it.
RenderTab func(cx *core.Scope, tab Tab) core.Node
// RenderDropIndicator renders what shows where a drag would land,
// over what it would take; a view of DropIndicatorStyle without it.
RenderDropIndicator func(cx *core.Scope, d DropIndicator) core.Node
// RenderDock renders a dock's own chrome, before its layout.
RenderDock func(cx *core.Scope, d Info) core.Node
// RenderEmpty renders what an empty center shows.
RenderEmpty func(cx *core.Scope) core.Node
// RenderDragPreview renders what follows the pointer as a tab is
// dragged.
RenderDragPreview func(cx *core.Scope, tab Tab) core.Node
// The parts' styles: each tab group's frame, its tab bar, each tab
// (Selected for the displayed one), the content frame its panels show
// in, the drop indicator, each handle's line and thumb (between the
// groups of a split and at each dock's edge; a GroupStyle follows the
// handle's hover and press), each dock's frame, and in the compact
// presentation the side docks' drawers, the bottom dock's sheet and
// the backdrop behind them. Each part's Func, when set, merges over
// its style, again when what it reads changes, and its class goes
// under both.
Class, GroupClass, TabBarClass, TabClass, ContentClass string
DropIndicatorClass, HandleClass, HandleThumbClass string
DockClass, DrawerClass, SheetClass, BackdropClass string
Style, GroupStyle, TabBarStyle, TabStyle, ContentStyle core.Style
StyleFunc, GroupStyleFunc, TabBarStyleFunc, TabStyleFunc, ContentStyleFunc func() core.Style
DropIndicatorStyle, HandleStyle, HandleThumbStyle core.Style
DropIndicatorStyleFunc, HandleStyleFunc, HandleThumbStyleFunc func() core.Style
DockStyle, DrawerStyle, SheetStyle, BackdropStyle core.Style
DockStyleFunc, DrawerStyleFunc, SheetStyleFunc, BackdropStyleFunc func() core.Style
// HandleLabel says what dragging a handle resizes, for assistive
// technology.
HandleLabel string
// OnPanelActiveChange follows a panel becoming, or stopping being,
// its group's displayed tab; a closed dock displays none, and a panel
// that leaves hears OnPanelRemove instead.
OnPanelActiveChange func(key string, active bool)
// OnPanelRemove reports a panel that left the area for good.
OnPanelRemove func(key string)
// OnZoomChange reports the displayed panel of the group zoomed in, or
// "" as it zooms out.
OnZoomChange func(key string)
// OnDockOpenChange reports a dock showing or going, in either
// presentation, and as the area mounts the docks whose shown state
// differs from the layout's.
OnDockOpenChange func(p Placement, open bool)
// Ref, when set, is bound to the area's methods.
Ref *AreaRef
TestID string
// OnLayout and Tooltip are its view's, as a core.View's.
OnLayout func(core.Bounds)
Tooltip core.Node
}
Area is a dockable workspace, as gpui-base's and NSH's: a center and optional left, right and bottom docks, each a tree of splits and tab groups the user rearranges by dragging tabs between groups and docks, resizes with the handles between them and zooms into. Its layout is data the app passes and hears back whole on every edit, and persists in gpui-base's format (Layout's JSON). It draws nothing: the app styles every part and renders each panel and tab.
An area the app makes Compact, as one on a phone or in a narrow window or column, keeps the same layout and presents it compactly: the center shows one tab group at a time, its tab bar listing every panel of the center, a tab drag reorders within it, and the docks are drawers from their edges and a sheet at the bottom.
A panel's content keeps its state while its group lives, across tab switches, resizes, zooms, docks closing and the compact presentation in the center; a panel moved to another group, or a dock's panel as the presentation changes, is rendered anew.
type AreaRef ¶
type AreaRef struct {
// contains filtered or unexported fields
}
AreaRef is a Area's methods, bound once it mounts. Each edit is reported with OnLayoutChange, as the user's are.
func (*AreaRef) AddPanel ¶
AddPanel adds panel key to the first tab group of region p, displayed; a dock missing is made, size across (200 when 0). A panel the area holds moves there.
func (*AreaRef) ClosePanel ¶
ClosePanel takes panel key out of the area as its tab would: unless the area is locked, the panel is not closable, or it is the last panel of a group with nothing beside it.
func (*AreaRef) GroupOf ¶
GroupOf returns the ID of the tab group holding panel key, and whether one does.
func (*AreaRef) MovePanel ¶
MovePanel moves panel key to t; a panel the area does not hold is added there.
func (*AreaRef) RemovePanel ¶
RemovePanel takes panel key out of the area, whatever its options say.
func (*AreaRef) SelectPanel ¶
SelectPanel displays panel key in its group.
func (*AreaRef) SetDockOpen ¶
SetDockOpen opens or closes dock p; at compact width it presents it, dismissing the other, or dismisses it.
func (*AreaRef) SetDockSize ¶
SetDockSize sets dock p's size across its edge, at least PanelMinSize.
func (*AreaRef) ToggleDock ¶
ToggleDock opens dock p when it is closed and closes it otherwise.
func (*AreaRef) ToggleZoom ¶
ToggleZoom zooms tab group group in, so it fills the area, or out when it is zoomed; 0 zooms the zoomed group out.
func (*AreaRef) ZoomedGroup ¶
ZoomedGroup returns the zoomed tab group's ID, and whether one is.
type AreaState ¶
type AreaState struct {
Version *int `json:"version"`
Center PanelState `json:"center"`
LeftDock *State `json:"left_dock,omitempty"`
RightDock *State `json:"right_dock,omitempty"`
BottomDock *State `json:"bottom_dock,omitempty"`
}
AreaState is gpui-base's persisted dock layout, its field names and tags frozen, so a layout file is the same in both. It is machine written: Layout's MarshalJSON and UnmarshalJSON go through it with each panel kept by its key.
func NewAreaState ¶
func NewAreaState(l Layout, leaf func(key string) PanelState) AreaState
NewAreaState writes l in gpui-base's format, each panel's leaf by leaf (PanelKey when nil).
func (AreaState) Layout ¶
func (s AreaState) Layout(key func(PanelState) string) Layout
Layout reads s back, each leaf's key by key (PanelKeyOf when nil), with NSH's compatibility rules: a tab group of tab groups is flattened, a bare leaf where a container belongs is a tab group of it, and a "TabPanel" holding panel info is an empty tab group.
type DropIndicator ¶
DropIndicator is where a drag would land: into Group, or in a new group on Side of it. Index is the slot in Group's tab bar a drop on the bar goes to, -1 elsewhere.
type Info ¶
type Info struct {
Placement Placement
Open func() bool
// Size is its size across its edge, Collapsible whether dragging it
// below PanelMinSize closes it.
Size func() core.Points
Collapsible func() bool
Toggle func()
}
Info is what RenderDock gets about a dock.
type Layout ¶
Layout is a whole Area's layout: the center and the docks.
func (Layout) MarshalJSON ¶
MarshalJSON writes l in gpui-base's layout format, each panel as {"id": key}.
func (*Layout) UnmarshalJSON ¶
UnmarshalJSON reads a gpui-base layout file into l, each panel keyed by its "id", else its panel_name.
type Node ¶
type Node struct {
// ID names the container across edits. A layout the app writes may
// leave it 0; the area assigns it, and reports layouts with it.
ID uint64
Tabs bool
Panels []string
Active int
Axis base.Axis
Children []Node
Sizes []core.Points
}
Node is one container of a dock layout: a tab group (Tabs) of Panels, Active the one displayed, or a split of Children along Axis with their slot Sizes (0 for none: the child shares what the others leave).
type PanelInfo ¶
type PanelInfo struct {
Stack *StackInfo
Tabs *TabsInfo
Panel json.RawMessage
}
PanelInfo is what a PanelState holds: a split's sizes and axis (0 horizontal, 1 vertical), a tab group's active index, or a panel's own data, written as gpui-base's externally tagged enum.
func (PanelInfo) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*PanelInfo) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type PanelOptions ¶
type PanelOptions struct {
NoClose bool
NoZoom bool
// Hidden keeps the panel's tab out of its tab bar.
Hidden bool
}
PanelOptions are what a panel allows; a panel Panels does not list allows everything.
type PanelState ¶
type PanelState struct {
PanelName string `json:"panel_name"`
Children []PanelState `json:"children"`
Info PanelInfo `json:"info"`
}
PanelState is a persisted container or panel: a split ("StackPanel" with stack info), a tab group ("TabPanel" with tabs info) or a panel's leaf, whose info is the app's.
func PanelKey ¶
func PanelKey(key string) PanelState
PanelKey is a panel kept by its key alone: a leaf named PanelKeyName with info {"id": key}.
type Region ¶
Region is a dock: its tree, its size across its edge (200 when 0, never below PanelMinSize) and whether it is closed. A collapsible dock dragged below 50 points closes, keeping its size; NoCollapse keeps it open.
type State ¶
type State struct {
Panel PanelState `json:"panel"`
Placement string `json:"placement"`
Size core.Points `json:"size"`
Open bool `json:"open"`
}
State is one dock's persisted state.
type Tab ¶
type Tab struct {
Key string
Group uint64
// Index is its place among its group's shown tabs.
Index func() int
// Selected reports whether it is its group's displayed tab, Zoomed
// whether its group is zoomed in.
Selected, Zoomed func() bool
// Closable reports whether the area would close it: the panel may
// close, the area is not locked, and it is not the last panel of a
// group with nothing beside it.
Closable func() bool
// Close closes the panel, where it may.
Close func()
}
Tab is what RenderTab and RenderDragPreview get about a tab.
type TabsInfo ¶
type TabsInfo struct {
ActiveIndex int `json:"active_index"`
}
TabsInfo is a tab group's persisted info.
type Target ¶
type Target struct {
Group uint64
Side core.Placement
// Before is the tab it goes before; it goes last without one.
Before string
// NoActivate keeps the group's displayed tab.
NoActivate bool
// Size is the new group's length along a split, half of what it lands
// beside when 0.
Size core.Points
}
Target is where AreaRef.MovePanel puts a panel: into tab group Group, or with Side in a new tab group on that side of container Group.