Documentation
¶
Index ¶
- func AttachPress(t *PressTarget, shape func() (PressShape, bool)) *canvas.Ripple
- func CancelPress(t *PressTarget)
- func Repaint(obj core.CanvasObject)
- func ShadowGeometry(level ElevationLevel) (blurRadius, offsetY float32)
- func TapPress(t *PressTarget, ev *event.PointEvent)
- type Base
- func (w *Base) ExtendBaseWidget(wid core.Widget)
- func (w *Base) Hide()
- func (w *Base) MinSize() geo.Size
- func (w *Base) Move(pos geo.Position)
- func (w *Base) Position() geo.Position
- func (w *Base) Refresh()
- func (w *Base) Resize(size geo.Size)
- func (w *Base) Show()
- func (w *Base) Size() geo.Size
- func (w *Base) Visible() bool
- type BaseRenderer
- type DragGhost
- type ElevationLevel
- type OverlayContainer
- func (o *OverlayContainer) CreateRenderer() core.WidgetRenderer
- func (o *OverlayContainer) Dismiss()
- func (o *OverlayContainer) Hide()
- func (o *OverlayContainer) HoverIn(*event.HoverEvent)
- func (o *OverlayContainer) HoverMoved(*event.HoverEvent)
- func (o *OverlayContainer) HoverOut()
- func (o *OverlayContainer) Show()
- func (o *OverlayContainer) TapThroughDismiss(pos geo.Position) bool
- func (o *OverlayContainer) Tapped(*event.PointEvent)
- type PressFeedback
- func (f *PressFeedback) Cancel()
- func (f *PressFeedback) Press(at geo.Position, size geo.Size, cornerRadius float32, content color.Color)
- func (f *PressFeedback) Pressed() bool
- func (f *PressFeedback) Release()
- func (f *PressFeedback) Resize(size geo.Size)
- func (f *PressFeedback) Tap(at geo.Position, size geo.Size, cornerRadius float32, content color.Color)
- type PressShape
- type PressTarget
- type Scroll
- func (s *Scroll) AddScrollListener(fn func(geo.Position)) (remove func())
- func (s *Scroll) CreateRenderer() core.WidgetRenderer
- func (s *Scroll) DrawsDisabledLook() bool
- func (s *Scroll) MinSize() geo.Size
- func (s *Scroll) Refresh()
- func (s *Scroll) Resize(sz geo.Size)
- func (s *Scroll) ScrollToBottom()
- func (s *Scroll) ScrollToOffset(p geo.Position)
- func (s *Scroll) ScrollToTop()
- func (s *Scroll) Scrolled(ev *event.ScrollEvent)
- func (s *Scroll) SetMinSize(size geo.Size)
- func (s *Scroll) TryScrolled(ev *event.ScrollEvent) bool
- type ScrollDirection
- type Shadow
- type ShadowType
- type ShadowingRenderer
- type SimpleRenderer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttachPress ¶ added in v1.3.0
func AttachPress(t *PressTarget, shape func() (PressShape, bool)) *canvas.Ripple
AttachPress starts the feedback of t for a new renderer and returns the ripple it draws on, for the renderer to place above the background and below the content. shape says where the state layer shows; it returns false while the widget takes no press, such as when it is disabled.
func CancelPress ¶ added in v1.3.0
func CancelPress(t *PressTarget)
CancelPress ends the pressed state of t with no feedback left. A widget calls it from HoverOut, and wherever it stops being a target mid-press.
func Repaint ¶
func Repaint(obj core.CanvasObject)
Repaint instructs the containing canvas to redraw, even if nothing changed. Callers have moved or resized obj, and the canvas's partial repaint learns where from this alone (#599). This method is a duplicate of what is in `canvas/canvas.go` to avoid a dependency loop or public API.
func ShadowGeometry ¶ added in v1.2.0
func ShadowGeometry(level ElevationLevel) (blurRadius, offsetY float32)
ShadowGeometry is the blur radius and downward offset of the box shadow an object at level casts.
func TapPress ¶ added in v1.3.0
func TapPress(t *PressTarget, ev *event.PointEvent)
TapPress shows a press and its release for a tap that had no press before it: a key, an accessibility action, or a tap from code. A pointer tap's press showed already, and this does nothing for it. ev is nil for a tap with no position, which shows from the shape's centre.
Types ¶
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base provides a helper that handles basic widget behaviours.
func (*Base) ExtendBaseWidget ¶
ExtendBaseWidget is used by an extending widget to make use of BaseWidget functionality.
func (*Base) Move ¶
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) Refresh ¶
func (w *Base) Refresh()
Refresh causes this widget to be redrawn in it's current state
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 (pre-rebrand tracker #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 ¶
PassesInputThrough marks the ghost as input-transparent for the driver's hit-testing (internal/driver.InputPassThrough).
func (*DragGhost) SetPosition ¶
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) 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 (pre-rebrand tracker #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 PressFeedback ¶ added in v1.3.0
type PressFeedback struct {
// Ripple is what the feedback draws on. The renderer places it above the
// background and below the content, and keeps it the widget's size.
Ripple *canvas.Ripple
// contains filtered or unexported fields
}
PressFeedback draws the MD3 pressed state of a tappable widget on a canvas.Ripple the widget's renderer holds: a state layer in the widget's content colour, at the theme's pressed opacity, that spreads from the press point while the pointer is down and fades after it lifts (#1085). It used to be a ripple started at the release, fading as it grew, which a fingertip hid until it was a few percent.
The widget calls Press from TouchDown and a primary MouseDown, Release from TouchUp and MouseUp, and Cancel from TouchCancel and HoverOut (a mouse released elsewhere sends the widget no MouseUp). Tap is for an activation with no press before it, such as the keyboard's. All run on the main goroutine.
With animations off, the state layer covers the shape from the press to the release, with no ripple.
func NewPressFeedback ¶ added in v1.3.0
func NewPressFeedback() *PressFeedback
NewPressFeedback returns feedback that draws on a new, hidden ripple.
func PressFeedbackOf ¶ added in v1.3.0
func PressFeedbackOf(t *PressTarget) *PressFeedback
PressFeedbackOf returns the feedback of t, or nil before its renderer exists. Tests read the pressed state from it.
func (*PressFeedback) Cancel ¶ added in v1.3.0
func (f *PressFeedback) Cancel()
Cancel ends the press with no feedback left: the pointer left the widget, or the touch turned into a scroll or a drag, so it did not tap it.
func (*PressFeedback) Press ¶ added in v1.3.0
func (f *PressFeedback) Press(at geo.Position, size geo.Size, cornerRadius float32, content color.Color)
Press shows the pressed state from at, in the widget's coordinates, over a shape of size with corners of cornerRadius, in content, the colour of the widget's text or icon.
func (*PressFeedback) Pressed ¶ added in v1.3.0
func (f *PressFeedback) Pressed() bool
Pressed reports whether the pointer is down on the widget: between a Press and its Release or Cancel.
func (*PressFeedback) Release ¶ added in v1.3.0
func (f *PressFeedback) Release()
Release ends the press: the ripple finishes covering the shape, then fades. It does nothing without a press.
func (*PressFeedback) Resize ¶ added in v1.3.0
func (f *PressFeedback) Resize(size geo.Size)
Resize keeps the ripple the widget's size. A renderer calls it from Layout.
func (*PressFeedback) Tap ¶ added in v1.3.0
func (f *PressFeedback) Tap(at geo.Position, size geo.Size, cornerRadius float32, content color.Color)
Tap shows a press and its release at once, for an activation that had no press before it: a key, an accessibility action, or a tap whose press the widget did not see. It does nothing while a press or its release shows.
type PressShape ¶ added in v1.3.0
type PressShape struct {
// Pos and Size place the state layer in the widget's coordinates: the
// whole widget for a row, the indicator pill of a navigation item, the
// circle around a checkbox.
Pos geo.Position
Size geo.Size
// CornerRadius rounds the state layer; half the size makes a circle.
CornerRadius float32
// TopLeftCornerRadius and the three after it round one corner each in
// place of CornerRadius when not zero, for a part rounded on its outer
// side only: a segmented button's end segment, a half of a split button
// (#1156).
TopLeftCornerRadius, TopRightCornerRadius float32
BottomRightCornerRadius, BottomLeftCornerRadius float32
// Content is the colour of the widget's text or icon. The state layer is
// that colour at the theme's pressed opacity.
Content color.Color
// FromCenter spreads the ripple from the shape's centre rather than from
// the press, for a control whose target is larger than its state layer:
// a press on a checkbox's label still shows around the box.
FromCenter bool
}
PressShape is where a widget's pressed state shows, and in what colour.
type PressTarget ¶ added in v1.3.0
type PressTarget struct {
// contains filtered or unexported fields
}
PressTarget gives a widget the MD3 pressed state of PressFeedback, with the press, release and cancel events it needs (#1091). A widget embeds it, which makes it a mobile.Touchable and a desktop.Mouseable, and calls AttachPress from CreateRenderer and TapPress from Tapped. A widget that is Hoverable calls CancelPress from HoverOut: a mouse released elsewhere sends it no MouseUp.
The helpers are functions rather than methods so that a public widget that embeds it gains only the event methods.
func (*PressTarget) MouseDown ¶ added in v1.3.0
func (t *PressTarget) MouseDown(ev *desktop.MouseEvent)
MouseDown shows the pressed state from where the primary button went down.
func (*PressTarget) MouseUp ¶ added in v1.3.0
func (t *PressTarget) MouseUp(*desktop.MouseEvent)
MouseUp ends the pressed state.
func (*PressTarget) TouchCancel ¶ added in v1.3.0
func (t *PressTarget) TouchCancel(*mobile.TouchEvent)
TouchCancel ends the pressed state with no feedback left: the finger left the widget, or the touch became a scroll or a drag of something else.
func (*PressTarget) TouchDown ¶ added in v1.3.0
func (t *PressTarget) TouchDown(ev *mobile.TouchEvent)
TouchDown shows the pressed state from where the finger went down.
func (*PressTarget) TouchUp ¶ added in v1.3.0
func (t *PressTarget) TouchUp(*mobile.TouchEvent)
TouchUp ends the pressed state.
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: 1.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 pre-rebrand tracker #353 / pre-rebrand tracker #357.
HideShadows bool
// Inert, when set and returning true, makes the scroll refuse the user's
// input: a wheel or touchpad scroll, a touch drag of the content, and a
// drag or tap on its bars. A widget that owns the scroll sets it to its
// Disabled method, so that a disabled collection does not scroll (#1215).
// A refused wheel scroll is consumed (TryScrolled reports true) and a
// refused touch drag is claimed, so neither reaches the scroll around it:
// over a disabled collection nothing scrolls (#1251). Scrolls from code
// (ScrollToOffset and the others) still move it.
Inert func() bool `json:"-"`
// 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 ¶
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) DrawsDisabledLook ¶ added in v1.3.0
DrawsDisabledLook reports that the paint walk leaves a Scroll's own drawing, its bars and shadows, as it is under a disabled container, as it was before #1393; the widgets it scrolls are dimmed or not by their own looks. A disabled collection stops its scrolling itself (Inert, #1215).
Since: 1.3
func (*Scroll) Refresh ¶
func (s *Scroll) Refresh()
Refresh causes this widget to be redrawn in it's current state
func (*Scroll) Resize ¶
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. Like every programmatic scroll it reports the move through OnScrolled.
func (*Scroll) ScrollToOffset ¶
ScrollToOffset will update the location of the content of this scroll container. The offset is clamped to the content, and a resulting move is reported through OnScrolled and the scroll listeners, as a user scroll is.
Since: 1.0
func (*Scroll) ScrollToTop ¶
func (s *Scroll) ScrollToTop()
ScrollToTop will scroll content to container top. Like every programmatic scroll it reports the move through OnScrolled.
func (*Scroll) Scrolled ¶
func (s *Scroll) Scrolled(ev *event.ScrollEvent)
Scrolled is called when an input device triggers a scroll event
func (*Scroll) SetMinSize ¶
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: 1.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: 1.0
func NewSimpleRenderer ¶
func NewSimpleRenderer(object core.CanvasObject) *SimpleRenderer
NewSimpleRenderer creates a new SimpleRenderer to render a widget using a single CanvasObject.
Since: 1.0
func (*SimpleRenderer) Destroy ¶
func (r *SimpleRenderer) Destroy()
Destroy does nothing in this implementation.
Since: 1.0
func (*SimpleRenderer) Layout ¶
func (r *SimpleRenderer) Layout(s geo.Size)
Layout updates the contained object to be the requested size.
Since: 1.0
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: 1.0
func (*SimpleRenderer) Objects ¶
func (r *SimpleRenderer) Objects() []core.CanvasObject
Objects returns the objects that should be rendered.
Since: 1.0
func (*SimpleRenderer) Refresh ¶
func (r *SimpleRenderer) Refresh()
Refresh requests the underlying object to redraw.
Since: 1.0