splitpane

package
v1.0.31-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package splitpane provides SplitPane: two panes side by side (or one above the other) with a divider between them the user drags to share the space - a sidebar and an editor, an editor and a terminal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Axis

type Axis uint8

Axis selects how the panes are placed.

const (
	// Horizontal places them side by side, the first at the start (the
	// left, or the right in a right-to-left locale). The default.
	Horizontal Axis = iota
	// Vertical places the first above the second.
	Vertical
)

type SplitPane

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

SplitPane is two panes with a divider between them. Create it once with New and lay it out every frame; it fills the space it's given.

By default the first pane takes Ratio of the space, and keeps that share as the space changes; FirstSize instead keeps the first pane's size in dp (a sidebar), the second taking the rest. Dragging the divider resizes; a double-click on it puts back the size it started with. The divider takes keyboard focus with Tab, and the arrow keys move it.

func New

func New(first, second func() elements.Element) *SplitPane

New returns a split pane showing first and second, each built every frame, the first taking half the space.

func (*SplitPane) Axis

func (s *SplitPane) Axis(a Axis) *SplitPane

Axis sets how the panes are placed: Horizontal (side by side, the default) or Vertical. It returns s for chaining.

func (*SplitPane) Content

func (s *SplitPane) Content(first, second func() elements.Element) *SplitPane

Content replaces the panes' contents. It returns s for chaining.

func (*SplitPane) DividerColor

func (s *SplitPane) DividerColor(c properties.Color) *SplitPane

DividerColor sets the divider line's color; theme.border by default. It returns s for chaining.

func (*SplitPane) Dragging

func (s *SplitPane) Dragging() bool

Dragging reports whether the divider is being dragged.

func (*SplitPane) FirstSize

func (s *SplitPane) FirstSize(dp float32) *SplitPane

FirstSize keeps the first pane dp wide (or tall), as a sidebar keeps its width when the window is resized; dragging changes it. It returns s for chaining.

func (*SplitPane) Layout

func (s *SplitPane) Layout(gtx layout.Context) layout.Dimensions

Layout lays out the panes and the divider.

func (*SplitPane) MinSizes

func (s *SplitPane) MinSizes(first, second float32) *SplitPane

MinSizes sets how small, in dp, each pane may be dragged; 48dp by default. It returns s for chaining.

func (*SplitPane) OnResize

func (s *SplitPane) OnResize(fn func(ratio, firstDp float32)) *SplitPane

OnResize sets a handler for the user moving the divider, with the first pane's share of the space and its size in dp: to remember them. It returns s for chaining.

func (*SplitPane) Ratio

func (s *SplitPane) Ratio(r float32) *SplitPane

Ratio sets the first pane's share of the space, 0 to 1, and the share a double-click on the divider puts back. It returns s for chaining.

func (*SplitPane) Share

func (s *SplitPane) Share() float32

Share returns the first pane's share of the space in the last frame.

Jump to

Keyboard shortcuts

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