component

package
v0.0.0-...-ec244d1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package component copy form github.com/gio-x

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithAlpha

func WithAlpha(c color.NRGBA, a uint8) color.NRGBA

WithAlpha returns the input color with the new alpha value.

Types

type AlphaPalette

type AlphaPalette struct {
	Hover, Selected uint8
}

AlphaPalette is the set of alpha values to be applied for certain material design states like hover, selected, etc...

type C

type C = layout.Context

type D

type D = layout.Dimensions

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 reversable.

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 update the progress value.

func (Progress) Absolute

func (p Progress) Absolute() float32

Absolute reports the absolute progress, ignoring direction.

func (Progress) Direction

func (p Progress) Direction() ProgressDirection

Direction reports the current direction.

func (Progress) Finished

func (p Progress) Finished() bool

func (Progress) Progress

func (p Progress) Progress() float32

Progress reports the current progress as a float between [0, 1].

func (*Progress) Start

func (p *Progress) Start(began time.Time, direction ProgressDirection, duration time.Duration)

Start the progress in the given direction over the given duration.

func (Progress) Started

func (p Progress) Started() bool

Started reports true if progression has started.

func (*Progress) Stop

func (p *Progress) Stop()

Stop the progress.

func (*Progress) Update

func (p *Progress) Update(now time.Time)

type ProgressDirection

type ProgressDirection int

ProgressDirection specifies how to update 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 Rect

type Rect struct {
	Color color.NRGBA
	Size  image.Point
	Radii int
}

func (Rect) Layout

func (r Rect) Layout(gtx C) D

type TextField

type TextField struct {
	// Editor contains the edit buffer.
	widget.Editor

	// Helper text to give additional context to a field.
	Helper string
	// CharLimit specifies the maximum number of characters the text input
	// will allow. Zero means "no limit".
	CharLimit uint
	// Prefix appears before the content of the text input.
	Prefix layout.Widget
	// Suffix appears after the content of the text input.
	Suffix layout.Widget
	// contains filtered or unexported fields
}

TextField implements the Material Design Text Field described here: https://material.io/components/text-fields

func (*TextField) Clear

func (in *TextField) Clear()

Clear the input text and reset any error status.

func (*TextField) ClearError

func (in *TextField) ClearError()

ClearError clears any errored status.

func (TextField) IsActive

func (in TextField) IsActive() bool

IsActive if input is in an active state (Active, Focused or Errored).

func (*TextField) IsErrored

func (in *TextField) IsErrored() bool

IsErrored if input is in an errored state. Typically this is when the validator has returned an error message.

func (*TextField) Layout

func (in *TextField) Layout(gtx C, th *material.Theme, hint string) D

func (*TextField) SetError

func (in *TextField) SetError(err string)

SetError puts the input into an errored state with the specified error text.

func (*TextField) TextTooLong

func (in *TextField) TextTooLong() bool

TextTooLong returns whether the current editor text exceeds the set character limit.

func (*TextField) Update

func (in *TextField) Update(gtx C, th *material.Theme, hint string)

type Validator

type Validator = func(string) string

Validator validates text and returns a string describing the error. Error is displayed as helper text.

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 appearsing 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 layout.Context) 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 layout.Context to ensure that the next frame will be generated promptly.

func (*VisibilityAnimation) String

func (v *VisibilityAnimation) String(gtx layout.Context) 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
)

func (VisibilityAnimationState) String

func (v VisibilityAnimationState) String() string

Jump to

Keyboard shortcuts

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