Documentation ¶
Overview ¶
Package wid is an alternative implementation of gio's material widgets
Index ¶
- Constants
- Variables
- func ARGB(c uint32) color.NRGBA
- func Button[V StrValue](th *Theme, label V, options ...Option) layout.Widget
- func CalcMin(gtx C, width unit.Dp) image.Point
- func Checkbox(th *Theme, label string, options ...Option) func(gtx C) D
- func Clamp[T constraints.Ordered](v T, lo T, hi T) T
- func ColDisabled(c color.NRGBA, disabled bool) color.NRGBA
- func DeEmphasis(c color.NRGBA, amount uint8) color.NRGBA
- func Disabled(c color.NRGBA) (d color.NRGBA)
- func DrawShadow(gtx C, outline image.Rectangle, rr int, elevation int)
- func DropDown(th *Theme, index *int, items []string, options ...Option) layout.Widget
- func Edit(th *Theme, options ...Option) func(gtx C) D
- func FPt(p image.Point) f32.Point
- func Gray(c color.NRGBA) color.NRGBA
- func GridRow(th *Theme, pbgColor *color.NRGBA, gridLineWidth unit.Dp, weights []float32, ...) layout.Widget
- func HeaderButton(th *Theme, label string, options ...Option) layout.Widget
- func Hovered(c color.NRGBA) (d color.NRGBA)
- func Hsl2rgb(hueDegrees float64, saturation float64, light float64) color.NRGBA
- func Image(img image.Image, fit Fit) func(gtx C) D
- func ImageFromJpgFile(filename string, fit Fit) func(gtx C) D
- func Interpolate(a, b color.NRGBA, progress float32) color.NRGBA
- func Invalidate()
- func Label[V Value](th *Theme, v V, options ...Option) func(gtx C) D
- func List(th *Theme, a AnchorStrategy, widgets ...layout.Widget) layout.Widget
- func Luminance(c color.NRGBA) byte
- func Max[T constraints.Ordered](x, y T) T
- func Min[T constraints.Ordered](x, y T) T
- func MulAlpha(c color.NRGBA, alpha uint8) color.NRGBA
- func OutlineButton(th *Theme, label string, options ...Option) layout.Widget
- func ProgressBar(th *Theme, progress *float32, options ...Option) func(gtx C) D
- func RGB(c uint32) color.NRGBA
- func RadioButton(th *Theme, value *string, key string, label string, options ...Option) func(gtx C) D
- func Rgb2hsl(c color.NRGBA) (float64, float64, float64)
- func RoundButton(th *Theme, d *Icon, options ...Option) layout.Widget
- func Row(th *Theme, pbgColor *color.NRGBA, weights []float32, widgets ...layout.Widget) layout.Widget
- func RrOp(rr clip.RRect, d int, ops *op.Ops) clip.Op
- func Run(win *app.Window, form *layout.Widget, th *Theme)
- func RunWithContext(ctx context.Context, win *app.Window, form *layout.Widget, th *Theme)
- func Separator(th *Theme, thickness unit.Dp, options ...Option) layout.Widget
- func ShadowPath(rr clip.RRect, d int, ops *op.Ops) clip.PathSpec
- func Slider(th *Theme, value *float32, minV, maxV float32, options ...Option) layout.Widget
- func Space(size unit.Dp) layout.Widget
- func SplitHorizontal(th *Theme, ratio float32, w1 layout.Widget, w2 layout.Widget) func(gtx C) D
- func SplitVertical(th *Theme, ratio float32, w1 layout.Widget, w2 layout.Widget) func(gtx C) D
- func StringerValue(th *Theme, s func(dp int) string, options ...Option) func(gtx C) D
- func Switch(th *Theme, statePtr *bool, options ...Option) func(gtx C) D
- func Table(th *Theme, a AnchorStrategy, heading layout.Widget, widgets ...layout.Widget) layout.Widget
- func TextButton(th *Theme, label string, options ...Option) layout.Widget
- func Tone(c color.NRGBA, tone int) color.NRGBA
- func UpdateMousePos(gtx C, win *app.Window)
- func WithAlpha(c color.NRGBA, alpha uint8) color.NRGBA
- type AnchorStrategy
- type Base
- type BaseIf
- type BaseOption
- func Bg(c *color.NRGBA) BaseOption
- func Border(b unit.Dp) BaseOption
- func Do(f func()) BaseOption
- func En(b *bool) BaseOption
- func Fg(c *color.NRGBA) BaseOption
- func FontSize(v float32) BaseOption
- func Heading() BaseOption
- func Hint(hint string) BaseOption
- func Large() BaseOption
- func Lbl(s string) BaseOption
- func Pads(pads ...float32) BaseOption
- func Prim() BaseOption
- func PrimCont() BaseOption
- func Role(r UIRole) BaseOption
- func Sec() BaseOption
- func SecCont() BaseOption
- func Small() BaseOption
- func W(width float32) BaseOption
- type BtnOption
- type ButtonDef
- type ButtonStyle
- type C
- type CheckBoxDef
- type CheckboxOption
- type Click
- type Clickable
- func (b *Clickable) Click()
- func (b *Clickable) Clicked() bool
- func (b *Clickable) Clicks() []Click
- func (b *Clickable) Focused() bool
- func (b Clickable) GetIndex(n int) int
- func (b *Clickable) HandleEvents(gtx C)
- func (b *Clickable) History() []Press
- func (b *Clickable) Hovered() bool
- func (b *Clickable) Pressed() bool
- func (b *Clickable) SetupEventHandlers(gtx C, size image.Point)
- type Con
- type D
- type DropDownStyle
- type EditDef
- type EditOption
- type Fit
- type Icon
- type ImageDef
- type InvalidateDeadline
- type LabelDef
- type LabelOption
- type ListStyle
- type Option
- type Pallet
- type Press
- type Progress
- func (p Progress) Absolute() float32
- func (p Progress) Direction() ProgressDirection
- func (p Progress) Finished() bool
- func (p Progress) Progress() float32
- func (p *Progress) Start(began time.Time, direction ProgressDirection, duration time.Duration)
- func (p Progress) Started() bool
- func (p *Progress) Stop()
- func (p *Progress) Update(now time.Time)
- type ProgressBarStyle
- type ProgressDirection
- type Rectangle
- type Resize
- type ScrollIndicatorStyle
- type ScrollTrackStyle
- type Scrollbar
- func (s *Scrollbar) AddDrag(ops *op.Ops)
- func (s *Scrollbar) AddIndicator(ops *op.Ops)
- func (s *Scrollbar) AddTrack(ops *op.Ops)
- func (s *Scrollbar) IndicatorHovered() bool
- func (s *Scrollbar) Layout(gtx C, axis layout.Axis, viewportStart, viewportEnd float32) D
- func (s *Scrollbar) ScrollDistance() float32
- type ScrollbarStyle
- type SeparatorStyle
- type ShadowStyle
- type SliderStyle
- type StrValue
- type SwitchDef
- type Theme
- type Tooltip
- type UIRole
- type UIState
- type Value
- type VisibilityAnimation
- func (v VisibilityAnimation) Animating() bool
- func (v *VisibilityAnimation) Appear(now time.Time)
- func (v *VisibilityAnimation) Disappear(now time.Time)
- func (v *VisibilityAnimation) Revealed(gtx C) float32
- func (v *VisibilityAnimation) String(gtx C) string
- func (v *VisibilityAnimation) ToggleVisibility(now time.Time)
- func (v VisibilityAnimation) Visible() bool
- type VisibilityAnimationState
- type Wid
Constants ¶
const ( CursorSizeX = 10 CursorSizeY = 32 )
Variables ¶
var ( MouseX float32 MouseY float32 WinX int WinY int CurrentX int CurrentY int GuiLock sync.RWMutex )
var ( Red = RGB(0xFF0000) Yellow = RGB(0xFFFF00) Green = RGB(0x00FF00) Blue = RGB(0x0000FF) White = RGB(0xFFFFFF) Black = RGB(0x000000) )
Some default colors
var SpaceClose = []float32{}
SpaceClose is a shortcut for specifying that the row elements are placed close together, left to right
var SpaceDistribute []float32 = nil
SpaceDistribute should disribute the widgets on a row evenly, with equal space for each
Functions ¶
func Checkbox ¶
Checkbox returns a widget that can be checked, with label, initial state and handler function
func Clamp ¶
func Clamp[T constraints.Ordered](v T, lo T, hi T) T
func ColDisabled ¶
ColDisabled returns the disabled color of c, depending on the disabled flag.
func DeEmphasis ¶
DeEmphasis will change a color to a less prominent color In light mode, colors will be lighter, in dark mode, colors will be darker The amount of darkening is greater than the amount of lightening
func Disabled ¶
Disabled blends color towards the luminance and multiplies alpha. Blending towards luminance will desaturate the color. Multiplying alpha blends the color together more with the background.
func GridRow ¶
func GridRow(th *Theme, pbgColor *color.NRGBA, gridLineWidth unit.Dp, weights []float32, widgets ...layout.Widget) layout.Widget
GridRow returns a widget grid row with a grid separating columns and rows
func HeaderButton ¶
HeaderButton is a shortcut to a text only button with left justified text and a given size
func Hsl2rgb ¶
Internal HSV->RGB function for doing conversions using float inputs (saturation, value) and outputs (for R, G, and B). Basically a direct implementation of this: https://en.wikipedia.org/wiki/HSL_and_HSV#Converting_to_RGB
func Interpolate ¶
Interpolate returns a color in between given colors a and b, depending on progress from 0.0 to 1.0
func Invalidate ¶
func Invalidate()
func Max ¶
func Max[T constraints.Ordered](x, y T) T
func Min ¶
func Min[T constraints.Ordered](x, y T) T
func OutlineButton ¶
OutlineButton is a shortcut to an outlined button
func ProgressBar ¶
ProgressBar returns a widget for a progress bar
func RadioButton ¶
func RadioButton(th *Theme, value *string, key string, label string, options ...Option) func(gtx C) D
RadioButton returns a RadioButton with a label. The key specifies the initial value for the output
func Rgb2hsl ¶
Internal implementation converting RGB to HSL, HSV, or HSI. Basically a direct implementation of this: https://en.wikipedia.org/wiki/HSL_and_HSV#General_approach
func RoundButton ¶
RoundButton is a shortcut to a round button
func Row ¶
func Row(th *Theme, pbgColor *color.NRGBA, weights []float32, widgets ...layout.Widget) layout.Widget
Row returns a widget grid row with selectable color.
func RunWithContext ¶
func ShadowPath ¶
ShadowPath returns the PathSpec for the shadow This is a border around a rounded rectangle with width d
func SplitHorizontal ¶
SplitHorizontal is used to layout two widgets with a vertical splitter between.
func SplitVertical ¶
SplitVertical is used to layout two widgets with a vertical splitter between.
func StringerValue ¶
Value returns a widget for a value given by stringer function
func Table ¶
func Table(th *Theme, a AnchorStrategy, heading layout.Widget, widgets ...layout.Widget) layout.Widget
Table makes a scrollable vertical list with a fixed header row
func TextButton ¶
TextButton is a shortcut to a text only button
func Tone ¶
Tone is the google material tone implementation See: https://m3.material.io/styles/color/the-color-system/key-colors-tones
func UpdateMousePos ¶
UpdateMousePos must be called from the main program in order to get mouse position and window size. They are needed to avoid that the tooltip is outside the window frame
Types ¶
type AnchorStrategy ¶
type AnchorStrategy uint8
AnchorStrategy defines a means of attaching a scrollbar to content.
const ( // Occupy reserves space for the scrollbar, making the underlying // content region smaller on one axis. Occupy AnchorStrategy = iota // Overlay causes the scrollbar to float atop the content without // occupying any space. Content in the underlying area can be occluded // by the scrollbar. Overlay )
type Base ¶
Base is tha base structure for widgets. It contains variables that (almost) all widgets share
func (*Base) Apply ¶
Apply will apply all optional parameters. This can only be used when the widget has no own options.
func (Base) CheckDisable ¶
type BaseIf ¶
type BaseIf interface {
// contains filtered or unexported methods
}
BaseIf is the interface functions for widgets, used by options to set parameters
type BaseOption ¶
type BaseOption func(BaseIf)
BaseOption is a type for optional parameters when creating widgets
func Bg ¶
func Bg(c *color.NRGBA) BaseOption
Bg is an option parameter to set widget background color
func Border ¶
func Border(b unit.Dp) BaseOption
func Do ¶
func Do(f func()) BaseOption
Do is an optional parameter to set a callback when widget state changes
func En ¶
func En(b *bool) BaseOption
func Fg ¶
func Fg(c *color.NRGBA) BaseOption
Fg is an option parameter to set widget foreground color
func FontSize ¶
func FontSize(v float32) BaseOption
FontSize set the font size for text in the widget
func Hint ¶
func Hint(hint string) BaseOption
Hint is an option parameter to set the widget hint (tooltip)
func Pads ¶
func Pads(pads ...float32) BaseOption
Pads is an option parameter to set customized padding. Noe that 1,2,3 or 4 paddings can be specified. If 1 is supplied, it is used for left,right,top,bottom, all with the same padding If 2 is supplied, the first is used for top/bottom, and the second for left and right padding If 4 is supplied, it is used for top, right, bottom, left in that sequence. All values are in Dp (float32 device independent pixels)
func Role ¶
func Role(r UIRole) BaseOption
Role set the theme role for the widget (Primary, Secondary etc)
type ButtonDef ¶
type ButtonDef struct { Base Tooltip Clickable Text *string Icon *Icon Style ButtonStyle // contains filtered or unexported fields }
ButtonDef is the struct for buttons
func (*ButtonDef) HandleClick ¶
func (b *ButtonDef) HandleClick()
HandleClick will call the callback function
type ButtonStyle ¶
type ButtonStyle int
ButtonStyle indicates a Contained, Text, Outline or round button
const ( // Contained is a solid, colored button Contained ButtonStyle = iota // Text is a button without outline or color. Just text Text // Outlined is a text button with outline Outlined // Round is a round button, usually with icon only Round // Header Header )
type CheckBoxDef ¶
type CheckBoxDef struct { Base Clickable Label string StrValue *string BoolValue *bool Checked bool TextSize unit.Sp Key string // contains filtered or unexported fields }
CheckBoxDef defines a checkbox widget
func (*CheckBoxDef) Layout ¶
func (c *CheckBoxDef) Layout(gtx C) D
Layout updates the checkBox and displays it.
type CheckboxOption ¶
type CheckboxOption func(w *CheckBoxDef)
CheckboxOption is options specific to Checkboxes
func Bool ¶
func Bool(b *bool) CheckboxOption
Bool is an option parameter to set the variable updated
type Clickable ¶
type Clickable struct {
// contains filtered or unexported fields
}
Clickable represents a clickable area.
func (*Clickable) Clicked ¶
Clicked reports whether there are pending clicks as would be reported by Clicks. If so, Clicked removes the earliest click.
func (*Clickable) HandleEvents ¶
HandleEvents the button state by processing events.
func (*Clickable) History ¶
History is the past pointer presses useful for drawing markers. History is retained for a short duration (about a second).
type Con ¶
type Con = layout.Constraints
type DropDownStyle ¶
DropDownStyle is the struct for dropdown lists.
func (*DropDownStyle) Layout ¶
func (b *DropDownStyle) Layout(gtx C) D
Layout adds padding to a dropdown box drawn with b.layout().
type EditOption ¶
type EditOption func(w *EditDef)
EditOption is options specific to Edits
func Area ¶
func Area(min, max int) EditOption
Area is an option parameter to set the minimum and maximum height of the edit area and allow multi-line editing.
func ReadOnly ¶
func ReadOnly() EditOption
ReadOnly is an option parameter to set the edit to read-only
type Fit ¶
type Fit uint8
Fit scales a widget to fit and clip to the constraints.
const ( // Unscaled does not alter the scale of a widget. Unscaled Fit = iota // Contain scales widget as large as possible without cropping, // and it preserves aspect-ratio. Contain // Cover scales the widget to cover the constraint area and // preserves aspect-ratio. Cover // ScaleDown scales the widget smaller without cropping, // when it exceeds the constraint area. // It preserves aspect-ratio. ScaleDown // Fill stretches the widget to the constraints and does not // preserve aspect-ratio. Fill )
type Icon ¶
type Icon struct {
// contains filtered or unexported fields
}
Icon is the definition of an icon
type ImageDef ¶
type ImageDef struct { // Src is the image to display. Src paint.ImageOp // Fit specifies how to scale the image to the constraints. // By default, it does not do any scaling. Fit Fit // Position specifies where to position the image within // the constraints. Position layout.Direction // Scale is the ratio of image pixels to // dps. If Scale is zero Image falls back to // a scale that match a standard 72 DPI. Scale float32 }
ImageDef is a widget that displays an image.
type InvalidateDeadline ¶
type InvalidateDeadline struct { // The time at which a frame needs to be drawn. Target time.Time // Whether the deadline is active. Active bool }
InvalidateDeadline helps to ensure that a frame is generated at a specific point in time in the future. It does this by always requesting a future invalidation at its target time until it reaches its target time. This makes animating delays much cleaner.
func (*InvalidateDeadline) ClearTarget ¶
func (i *InvalidateDeadline) ClearTarget()
ClearTarget cancels a request to invalidate in the future.
func (*InvalidateDeadline) Process ¶
func (i *InvalidateDeadline) Process(gtx C) bool
Process checks the current frame time and either requests a future invalidation or does nothing. It returns whether the current frame is the frame requested by the last call to SetTarget.
func (*InvalidateDeadline) SetTarget ¶
func (i *InvalidateDeadline) SetTarget(t time.Time)
SetTarget configures a specific time in the future at which a frame should be rendered.
type LabelDef ¶
type LabelDef struct { Base // Face defines the text style. Font text.Font // Alignment specify the text alignment. Alignment text.Alignment // MaxLines limits the number of lines. Zero means no limit. MaxLines int TextSize unit.Sp Stringer func(dp int) string // contains filtered or unexported fields }
LabelDef is the setup for a label.
type LabelOption ¶
type LabelOption func(w *LabelDef)
LabelOption is options specific to Edits.
func Dp ¶
func Dp(n int) LabelOption
type ListStyle ¶
type ListStyle struct { Hpos int HorTotal int HorVisible bool VScrollBar ScrollbarStyle HScrollBar ScrollbarStyle AnchorStrategy // contains filtered or unexported fields }
ListStyle configures the presentation of a layout.List with a scrollbar.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is the interface for optional parameters
type Pallet ¶
type Pallet struct { PrimaryColor color.NRGBA SecondaryColor color.NRGBA TertiaryColor color.NRGBA ErrorColor color.NRGBA NeutralColor color.NRGBA NeutralVariantColor color.NRGBA }
Pallet is the key colors. All other colors are derived from them
type Press ¶
type Press struct { // Position of the press. Position image.Point // Start is when the press began. Start time.Time // End is when the press was ended by a release or cancel. // A zero End means it hasn't ended yet. End time.Time // Cancelled is true for cancelled presses. Cancelled bool }
Press represents a past pointer press.
type Progress ¶
type Progress struct {
// contains filtered or unexported fields
}
Progress is an animation primitive that tracks progress of time over a fixed duration as a float between [0, 1].
Progress is reversible.
Widgets map async UI events to state changes: stop, forward, reverse. Widgets then interpolate visual data based on progress value.
Update method must be called every tick to HandleEvents the progress value.
func (Progress) Direction ¶
func (p Progress) Direction() ProgressDirection
Direction reports the current direction.
type ProgressBarStyle ¶
ProgressBarStyle defines the progress bar
type ProgressDirection ¶
type ProgressDirection int
ProgressDirection specifies how to HandleEvents progress every tick.
const ( // Forward progresses from 0 to 1. Forward ProgressDirection = iota // Reverse progresses from 1 to 0. Reverse )
func (ProgressDirection) String ¶
func (d ProgressDirection) String() string
type ScrollIndicatorStyle ¶
type ScrollIndicatorStyle struct { // MajorMinLen is the smallest that the scroll indicator is allowed to // be along the major axis. MajorMinLen unit.Dp // MinorWidth is the width of the scroll indicator across the minor axis. MinorWidth unit.Dp // Color and HoverColor are the normal and hovered colors of the scroll // indicator. Color, HoverColor color.NRGBA // CornerRadius is the corner radius of the rectangular indicator. 0 // will produce square corners. 0.5*MinorWidth will produce perfectly // round corners. CornerRadius unit.Dp }
ScrollIndicatorStyle configures the presentation of a scroll indicator.
type ScrollTrackStyle ¶
type ScrollTrackStyle struct {
// MajorPadding and MinorPadding along the major and minor axis of the
// scrollbar's track. This is used to keep the scrollbar from touching
// the edges of the content area.
MajorPadding, MinorPadding unit.Dp
// Color of the track background.
Color color.NRGBA
}
ScrollTrackStyle configures the presentation of a track for a scroll area.
type Scrollbar ¶
type Scrollbar struct {
// contains filtered or unexported fields
}
Scrollbar holds the persistent state for an area that can display a scrollbar. In particular, it tracks the position of a viewport along a one-dimensional region of content. The viewport's position can be adjusted by drag operations along the display area, or by clicks within the display area.
Scrollbar additionally detects when a scroll indicator region is hovered.
func (*Scrollbar) AddDrag ¶
AddDrag configures the drag listener for the scrollbar to use the most recently added pointer.AreaOp.
func (*Scrollbar) AddIndicator ¶
AddIndicator configures the indicator click listener for the scrollbar to use the most recently added pointer.AreaOp.
func (*Scrollbar) AddTrack ¶
AddTrack configures the track click listener for the scrollbar to use the most recently added pointer.AreaOp.
func (*Scrollbar) IndicatorHovered ¶
IndicatorHovered returns whether the scroll indicator is currently being hovered by the pointer.
func (*Scrollbar) Layout ¶
Layout updates the internal state of the scrollbar based on events since the previous call to Layout. The provided axis will be used to normalize input event coordinates and constraints into an axis- independent format. viewportStart is the position of the beginning of the scrollable viewport relative to the underlying content expressed as a value in the range [0,1]. viewportEnd is the position of the end of the viewport relative to the underlying content, also expressed as a value in the range [0,1]. For example, if viewportStart is 0.25 and viewportEnd is .5, the viewport described by the scrollbar is currently showing the second quarter of the underlying content.
func (*Scrollbar) ScrollDistance ¶
ScrollDistance returns the normalized distance that the scrollbar moved during the last call to Layout as a value in the range [-1,1].
type ScrollbarStyle ¶
type ScrollbarStyle struct { Scrollbar *Scrollbar Track ScrollTrackStyle Indicator ScrollIndicatorStyle }
ScrollbarStyle configures the presentation of a scrollbar.
func MakeScrollbarStyle ¶
func MakeScrollbarStyle(th *Theme) ScrollbarStyle
MakeScrollbarStyle configures the presentation of a scrollbar using the provided theme and state.
func (ScrollbarStyle) Width ¶
func (s ScrollbarStyle) Width() unit.Dp
Width returns the minor axis width of the scrollbar in its current configuration (taking padding for the scroll track into account).
type SeparatorStyle ¶
type SeparatorStyle struct { Base // contains filtered or unexported fields }
SeparatorStyle defines material rendering parameters for separator
type ShadowStyle ¶
ShadowStyle defines a shadow cast by a rounded rectangle.
func Shadow ¶
func Shadow(radius int, elevation int) ShadowStyle
Shadow defines a shadow cast by a rounded rectangle with the given corner radius and elevation.
func (ShadowStyle) Layout ¶
func (s ShadowStyle) Layout(gtx C) D
Layout renders the shadow into the gtx. The shadow's size will assume that the rectangle casting the shadow is of size gtx.Constraints.Min.
type SliderStyle ¶
SliderStyle is the parameters for a slider
type Theme ¶
type Theme struct { Pallet DarkMode bool Shaper *text.Shaper TextSize unit.Sp DefaultFont text.Font CheckBoxChecked *Icon CheckBoxUnchecked *Icon RadioChecked *Icon RadioUnchecked *Icon FingerSize unit.Dp // FingerSize is the minimum touch target size. SelectionColor color.NRGBA BorderThickness unit.Dp BorderColor color.NRGBA BorderColorHovered color.NRGBA BorderColorActive color.NRGBA BorderCornerRadius unit.Dp TooltipInset layout.Inset TooltipCornerRadius unit.Dp TooltipWidth unit.Dp TooltipBackground color.NRGBA TooltipOnBackground color.NRGBA OutsidePadding layout.Inset InsidePadding layout.Inset IconInset layout.Inset ListInset layout.Inset ButtonPadding layout.Inset ButtonLabelPadding layout.Inset ButtonCornerRadius unit.Dp IconSize unit.Dp // Elevation is the shadow width Elevation unit.Dp // SashColor is the color of the movable divider SashColor color.NRGBA SashWidth unit.Dp TrackColor color.NRGBA DotColor color.NRGBA // Tooltip settings // HoverDelay is the delay between the cursor entering the tip area // and the tooltip appearing. HoverDelay time.Duration // LongPressDelay is the required duration of a press in the area for // it to count as a long press. LongPressDelay time.Duration // LongPressDuration is the amount of time the tooltip should be displayed // after being triggered by a long press. LongPressDuration time.Duration // FadeDuration is the amount of time it takes the tooltip to fade in // and out. FadeDuration time.Duration RowPadTop unit.Sp RowPadBtm unit.Sp // Scroll bar size ScrollMajorPadding unit.Sp ScrollMinorPadding unit.Sp ScrollMajorMinLen unit.Sp ScrollMinorWidth unit.Sp ScrollCornerRadius unit.Sp }
Theme contains color/layout settings for all widgets
type Tooltip ¶
type Tooltip struct { VisibilityAnimation // MaxWidth is the maximum width of the tool-tip box. Should be less than form width. MaxWidth unit.Dp // Text defines the content of the tooltip. Text widget.Label Hover InvalidateDeadline Press InvalidateDeadline LongPress InvalidateDeadline Fgc color.NRGBA Bgc color.NRGBA TooltipRR unit.Dp TextSize unit.Sp // contains filtered or unexported fields }
Tooltip implements a material design tool tip as defined at: https://material.io/components/tooltips#specs
func DesktopTooltip ¶
DesktopTooltip constructs a tooltip suitable for use on desktop devices.
func MobileTooltip ¶
MobileTooltip constructs a tooltip suitable for use on mobile devices.
func PlatformTooltip ¶
PlatformTooltip creates a tooltip styled to the current platform (desktop or mobile) by choosing based on the OS. This choice may not always be appropriate as it only uses the OS to decide.
type UIRole ¶
type UIRole uint8
UIRole describes the type of UI element There are two colors for each UIRole, one for text/icon and one for background Typicaly you specify a UIRole for each user elemet (button, checkbox etc). Default and Zero value is Neutral.
const ( // Canvas is white/black. Used in edits, dropdowns etc to standouw Canvas UIRole = iota // Surface is the default surface for windows. Surface // SurfaceVariant is for variation SurfaceVariant // Primary is for prominent buttons, active states etc Primary // PrimaryContainer is a light background tinted with Primary color. PrimaryContainer // Secondary is for less prominent components Secondary // SecondaryContainer is a light background tinted with Secondary color. SecondaryContainer // Tertiary is for contrasting elements Tertiary // TertiaryContainer is a light background tinted with Tertiary color. TertiaryContainer // Error is usualy red Error // ErrorContainer is usualy light red ErrorContainer // Outline is used for frames and buttons Outline // Undefined can be used to detect missing initializations Undefined )
type VisibilityAnimation ¶
type VisibilityAnimation struct { // How long does the animation last time.Duration State VisibilityAnimationState Started time.Time }
VisibilityAnimation holds the animation state for animations that transition between a "visible" and "invisible" state for a fixed duration of time.
func (VisibilityAnimation) Animating ¶
func (v VisibilityAnimation) Animating() bool
Animating returns whether the animation is either in the process of appearing or disappearing.
func (*VisibilityAnimation) Appear ¶
func (v *VisibilityAnimation) Appear(now time.Time)
Appear triggers the animation to begin becoming visible at the provided time. It is a no-op if the animation is already visible.
func (*VisibilityAnimation) Disappear ¶
func (v *VisibilityAnimation) Disappear(now time.Time)
Disappear triggers the animation to begin becoming invisible at the provided time. It is a no-op if the animation is already invisible.
func (*VisibilityAnimation) Revealed ¶
func (v *VisibilityAnimation) Revealed(gtx C) float32
Revealed returns the fraction of the animated entity that should be revealed at the current time in the animation. This fraction is computed with linear interpolation.
Revealed should be invoked during every frame that v.Animating() returns true.
If the animation reaches its end this frame, Revealed will transition it to a non-animating state automatically.
If the animation is in the process of animating, calling Revealed will automatically add an InvalidateOp to the provided Context to ensure that the next frame will be generated promptly.
func (*VisibilityAnimation) String ¶
func (v *VisibilityAnimation) String(gtx C) string
func (*VisibilityAnimation) ToggleVisibility ¶
func (v *VisibilityAnimation) ToggleVisibility(now time.Time)
ToggleVisibility will make an invisible animation begin the process of becoming visible and a visible animation begin the process of disappearing.
func (VisibilityAnimation) Visible ¶
func (v VisibilityAnimation) Visible() bool
Visible returns whether any part of the animated entity should be visible during the current animation frame.
type VisibilityAnimationState ¶
type VisibilityAnimationState int
VisibilityAnimationState represents possible states that a VisibilityAnimation can be in.
const ( Visible VisibilityAnimationState = iota Disappearing Appearing Invisible )
Visibility constants
func (VisibilityAnimationState) String ¶
func (v VisibilityAnimationState) String() string