widget

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Repaint

func Repaint(obj core.CanvasObject)

Repaint instructs the containing canvas to redraw, even if nothing changed. This method is a duplicate of what is in `canvas/canvas.go` to avoid a dependency loop or public API.

Types

type Base

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

Base provides a helper that handles basic widget behaviours.

func (*Base) ExtendBaseWidget

func (w *Base) ExtendBaseWidget(wid core.Widget)

ExtendBaseWidget is used by an extending widget to make use of BaseWidget functionality.

func (*Base) Hide

func (w *Base) Hide()

Hide this widget so it is no longer visible

func (*Base) MinSize

func (w *Base) MinSize() geo.Size

MinSize for the widget - it should never be resized below this value.

func (*Base) Move

func (w *Base) Move(pos geo.Position)

Move the widget to a new position, relative to its parent. Note this should not be used if the widget is being managed by a Layout within a Container.

func (*Base) Position

func (w *Base) Position() geo.Position

Position gets the current position of this widget, relative to its parent.

func (*Base) Refresh

func (w *Base) Refresh()

Refresh causes this widget to be redrawn in it's current state

func (*Base) Resize

func (w *Base) Resize(size geo.Size)

Resize sets a new size for a widget. Note this should not be used if the widget is being managed by a Layout within a Container.

func (*Base) Show

func (w *Base) Show()

Show this widget so it becomes visible

func (*Base) Size

func (w *Base) Size() geo.Size

Size gets the current size of this widget.

func (*Base) Visible

func (w *Base) Visible() bool

Visible returns whether or not this widget should be visible. Note that this may not mean it is currently visible if a parent has been hidden.

type BaseRenderer

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

BaseRenderer is a renderer base that provides part of the widget.Renderer interface.

func NewBaseRenderer

func NewBaseRenderer(objects []core.CanvasObject) BaseRenderer

NewBaseRenderer creates a new BaseRenderer.

func (*BaseRenderer) Destroy

func (r *BaseRenderer) Destroy()

Destroy does nothing in the base implementation.

func (*BaseRenderer) Objects

func (r *BaseRenderer) Objects() []core.CanvasObject

Objects returns the objects that should be rendered.

func (*BaseRenderer) SetObjects

func (r *BaseRenderer) SetObjects(objects []core.CanvasObject)

SetObjects updates the objects of the renderer.

type DragGhost

type DragGhost struct {
	Base
	// contains filtered or unexported fields
}

DragGhost is an input-pass-through overlay that paints a drag image following the pointer during an in-canvas drag (#819). It spans the canvas but draws only its content at the tracked position, and reports PassesInputThrough so the driver's hit-testing falls straight through to the UI beneath — the drag dispatch and any drop-target routing must resolve the objects under the pointer, never the ghost.

func NewDragGhost

func NewDragGhost(content core.CanvasObject, pos geo.Position) *DragGhost

NewDragGhost creates a ghost overlay painting content at pos (its top-left).

func (*DragGhost) CreateRenderer

func (g *DragGhost) CreateRenderer() core.WidgetRenderer

CreateRenderer returns a renderer that lays out the content at the tracked position; the overlay root spans the canvas but paints nothing itself.

func (*DragGhost) PassesInputThrough

func (g *DragGhost) PassesInputThrough() bool

PassesInputThrough marks the ghost as input-transparent for the driver's hit-testing (internal/driver.InputPassThrough).

func (*DragGhost) SetPosition

func (g *DragGhost) SetPosition(pos geo.Position)

SetPosition moves the ghost content to follow the pointer.

type ElevationLevel

type ElevationLevel int

ElevationLevel is the level of elevation of the shadow casting object.

const (
	BaseLevel             ElevationLevel = 0
	CardLevel             ElevationLevel = 1
	ButtonLevel           ElevationLevel = 2
	MenuLevel             ElevationLevel = 4
	PopUpLevel            ElevationLevel = 8
	SubmergedContentLevel ElevationLevel = 8
	DialogLevel           ElevationLevel = 24
)

ElevationLevel constants inspired by: https://storage.googleapis.com/spec-host/mio-staging%2Fmio-design%2F1584058305895%2Fassets%2F0B6xUSjjSulxceF9udnA4Sk5tdU0%2Fbaselineelevation-chart.png

type OverlayContainer

type OverlayContainer struct {
	Base
	Content core.CanvasObject

	// FocusTransparent, when set before Show, excludes this overlay from the
	// canvas focus routing: the focus manager of the layer beneath (usually
	// the window content) stays active, so the previously focused widget
	// keeps receiving key and shortcut events as if the overlay were not
	// there. Used by non-modal companion surfaces such as the completion
	// popup's KeepHostFocus mode, where the host widget drives the overlay.
	FocusTransparent bool

	// TapThrough, when set before Show, makes an outside tap dismiss the
	// overlay without consuming the press: the desktop driver dismisses the
	// overlay at press time and lets the same click re-resolve against the
	// layer beneath, so e.g. the click that closes a completion popup also
	// places the caret in the editor under it. A tap inside Content is
	// unaffected. Without it the outside tap is swallowed by Tapped.
	TapThrough bool
	// contains filtered or unexported fields
}

OverlayContainer is a transparent widget containing one core.CanvasObject and meant to be used as overlay.

func NewOverlayContainer

func NewOverlayContainer(c core.CanvasObject, canvas core.Canvas, onDismiss func()) *OverlayContainer

NewOverlayContainer creates an OverlayContainer.

func (*OverlayContainer) CreateRenderer

func (o *OverlayContainer) CreateRenderer() core.WidgetRenderer

CreateRenderer returns a new renderer for the overlay container.

func (*OverlayContainer) Dismiss

func (o *OverlayContainer) Dismiss()

Dismiss performs the overlay container’s dismiss action, if any. Drivers call it directly for TapThrough overlays, where the dismissing press never reaches Tapped because it is re-delivered to the layer beneath.

func (*OverlayContainer) Hide

func (o *OverlayContainer) Hide()

Hide hides the overlay container.

func (*OverlayContainer) HoverIn

func (o *OverlayContainer) HoverIn(*event.HoverEvent)

HoverIn catches hover-in events not handled by the container’s content. It does nothing.

func (*OverlayContainer) HoverMoved

func (o *OverlayContainer) HoverMoved(*event.HoverEvent)

HoverMoved catches hover-moved events not handled by the container’s content. It does nothing.

func (*OverlayContainer) HoverOut

func (o *OverlayContainer) HoverOut()

HoverOut catches hover-out events not handled by the container’s content. It does nothing.

func (*OverlayContainer) Show

func (o *OverlayContainer) Show()

Show makes the overlay container visible.

func (*OverlayContainer) TapThroughDismiss

func (o *OverlayContainer) TapThroughDismiss(pos geo.Position) bool

TapThroughDismiss implements the drivers' press-time pass-through seam (#472): when the overlay opted in via TapThrough and the press lands outside Content, the overlay is dismissed and true is returned, telling the driver to resolve the same press against the layer beneath. Drivers assert for this method structurally on the top overlay before dispatching a press.

func (*OverlayContainer) Tapped

func (o *OverlayContainer) Tapped(*event.PointEvent)

Tapped catches tap events not handled by the container’s content. It performs the overlay container’s dismiss action.

type Scroll

type Scroll struct {
	Base

	Direction ScrollDirection
	Content   core.CanvasObject
	Offset    geo.Position
	// OnScrolled can be set to be notified when the Scroll has changed position.
	// You should not update the Scroll.Offset from this method.
	//
	// Since: 2.0
	OnScrolled func(geo.Position) `json:"-"`

	// ReserveBarSpace, when true, reduces the content width (or height)
	// to prevent the scrollbar from overlapping content. This ensures that
	// text wraps correctly and visual elements are not clipped by the scrollbar.
	ReserveBarSpace bool

	// HideShadows, when true, suppresses the edge fade-shadows that are
	// otherwise shown when the content overflows. Text inputs (widget.Entry)
	// set this: a text field clips its overflowing text at the edge rather
	// than fading it, and the fade-shadow gradient otherwise dims content
	// (and, when the viewport overlaps it, the surrounding border) at the
	// scrolled edge — see #353 / #357.
	HideShadows bool
	// contains filtered or unexported fields
}

Scroll defines a container that is smaller than the Content. The Offset is used to determine the position of the child widgets within the container.

func NewHScroll

func NewHScroll(content core.CanvasObject) *Scroll

NewHScroll create a scrollable parent wrapping the specified content. Note that this may cause the MinSize.Width to be smaller than that of the passed object.

func NewScroll

func NewScroll(content core.CanvasObject) *Scroll

NewScroll creates a scrollable parent wrapping the specified content. Note that this may cause the MinSize to be smaller than that of the passed object.

func NewVScroll

func NewVScroll(content core.CanvasObject) *Scroll

NewVScroll create a scrollable parent wrapping the specified content. Note that this may cause the MinSize.Height to be smaller than that of the passed object.

func (*Scroll) AddScrollListener

func (s *Scroll) AddScrollListener(fn func(geo.Position)) (remove func())

AddScrollListener registers fn to be called whenever the scroll offset changes, returning a function that removes the registration. Unlike the single-slot Scroll.OnScrolled field, any number of listeners can attach and detach independently and in any order, so overlays such as ScrollIndicator can observe a Scroll without clobbering each other's callbacks.

Listeners run on the main goroutine, after OnScrolled. As with OnScrolled, do not change Scroll.Offset from a listener.

func (*Scroll) CreateRenderer

func (s *Scroll) CreateRenderer() core.WidgetRenderer

CreateRenderer is a private method to Bellui which links this widget to its renderer

func (*Scroll) MinSize

func (s *Scroll) MinSize() geo.Size

MinSize returns the smallest size this widget can shrink to

func (*Scroll) Refresh

func (s *Scroll) Refresh()

Refresh causes this widget to be redrawn in it's current state

func (*Scroll) Resize

func (s *Scroll) Resize(sz geo.Size)

Resize is called when this scroller should change size. We refresh to ensure the scroll bars are updated.

func (*Scroll) ScrollToBottom

func (s *Scroll) ScrollToBottom()

ScrollToBottom will scroll content to container bottom - to show latest info which end user just added

func (*Scroll) ScrollToOffset

func (s *Scroll) ScrollToOffset(p geo.Position)

ScrollToOffset will update the location of the content of this scroll container.

Since: 2.6

func (*Scroll) ScrollToTop

func (s *Scroll) ScrollToTop()

ScrollToTop will scroll content to container top

func (*Scroll) Scrolled

func (s *Scroll) Scrolled(ev *event.ScrollEvent)

Scrolled is called when an input device triggers a scroll event

func (*Scroll) SetMinSize

func (s *Scroll) SetMinSize(size geo.Size)

SetMinSize specifies a minimum size for this scroll container. If the specified size is larger than the content size then scrolling will not be enabled This can be helpful to appear larger than default if the layout is collapsing this widget.

func (*Scroll) TryScrolled

func (s *Scroll) TryScrolled(ev *event.ScrollEvent) bool

TryScrolled handles a scroll event and returns true if the event was consumed (i.e., the content actually scrolled). Returns false if the scroll container is at its boundary in the scroll direction or if the content fits entirely, allowing the event to propagate to a parent scrollable.

type ScrollDirection

type ScrollDirection = bellui.ScrollDirection

ScrollDirection represents the directions in which a Scroll can scroll its child content.

const (
	// ScrollBoth supports horizontal and vertical scrolling.
	ScrollBoth ScrollDirection = iota
	// ScrollHorizontalOnly specifies the scrolling should only happen left to right.
	ScrollHorizontalOnly
	// ScrollVerticalOnly specifies the scrolling should only happen top to bottom.
	ScrollVerticalOnly
	// ScrollNone turns off scrolling for this container.
	//
	// Since: 2.0
	ScrollNone
)

Constants for valid values of ScrollDirection.

type Shadow

type Shadow struct {
	Base
	// contains filtered or unexported fields
}

Shadow is a widget that renders a shadow.

func NewShadow

func NewShadow(typ ShadowType, level ElevationLevel) *Shadow

NewShadow create a new Shadow.

func (*Shadow) CreateRenderer

func (s *Shadow) CreateRenderer() core.WidgetRenderer

CreateRenderer returns a new renderer for the shadow.

type ShadowType

type ShadowType int

ShadowType specifies the type of the shadow.

const (
	ShadowAround ShadowType = iota
	ShadowLeft
	ShadowRight
	ShadowBottom
	ShadowTop
)

ShadowType constants

type ShadowingRenderer

type ShadowingRenderer struct {
	BaseRenderer
	// contains filtered or unexported fields
}

ShadowingRenderer is a renderer that adds a shadow around the rendered content. When using the ShadowingRenderer the embedding renderer should call LayoutShadow(contentSize, contentPos) to lay out the shadow.

func NewShadowingRenderer

func NewShadowingRenderer(objects []core.CanvasObject, level ElevationLevel) *ShadowingRenderer

NewShadowingRenderer creates a ShadowingRenderer.

func (*ShadowingRenderer) LayoutShadow

func (r *ShadowingRenderer) LayoutShadow(size geo.Size, pos geo.Position)

LayoutShadow adjusts the size and position of the shadow if necessary.

func (*ShadowingRenderer) RefreshShadow

func (r *ShadowingRenderer) RefreshShadow()

RefreshShadow asks the shadow graphical element to update to current theme

func (*ShadowingRenderer) SetObjects

func (r *ShadowingRenderer) SetObjects(objects []core.CanvasObject)

SetObjects updates the renderer's objects including the shadow if necessary.

type SimpleRenderer

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

SimpleRenderer is a basic renderer that satisfies widget.Renderer interface by wrapping a single core.CanvasObject.

Since: 2.1

func NewSimpleRenderer

func NewSimpleRenderer(object core.CanvasObject) *SimpleRenderer

NewSimpleRenderer creates a new SimpleRenderer to render a widget using a single CanvasObject.

Since: 2.1

func (*SimpleRenderer) Destroy

func (r *SimpleRenderer) Destroy()

Destroy does nothing in this implementation.

Since: 2.1

func (*SimpleRenderer) Layout

func (r *SimpleRenderer) Layout(s geo.Size)

Layout updates the contained object to be the requested size.

Since: 2.1

func (*SimpleRenderer) MinSize

func (r *SimpleRenderer) MinSize() geo.Size

MinSize returns the smallest size that this render can use, returned from the underlying object.

Since: 2.1

func (*SimpleRenderer) Objects

func (r *SimpleRenderer) Objects() []core.CanvasObject

Objects returns the objects that should be rendered.

Since: 2.1

func (*SimpleRenderer) Refresh

func (r *SimpleRenderer) Refresh()

Refresh requests the underlying object to redraw.

Since: 2.1

Jump to

Keyboard shortcuts

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