colorpicker

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Unlicense Imports: 13 Imported by: 0

README

colorpicker

Go Reference

This is a simple Gio package that provides widgets for choosing colors.

screenshot of provided widgets

Documentation

Overview

Package colorpicker provides simple widgets for selecting an RGBA color and for choosing one of a set of colors.

The PickerStyle type can be used to render a colorpicker (the state will be stored in a State). Colorpickers allow choosing specific RGBA values with sliders or providing an RGB hex code.

The MuxStyle type can be used to render a color multiplexer (the state will be stored in a MuxState). Color multiplexers provide a choice from among a set of colors.

Index

Constants

This section is empty.

Variables

View Source
var (
	Horizontal   = _l.Horizontal
	Vertical     = _l.Vertical
	Start        = _l.Start
	End          = _l.End
	Middle       = _l.Middle
	Baseline     = _l.Baseline
	SpaceSides   = _l.SpaceSides
	SpaceStart   = _l.SpaceStart
	SpaceEvenly  = _l.SpaceEvenly
	SpaceAround  = _l.SpaceAround
	SpaceBetween = _l.SpaceBetween
	SpaceEnd     = _l.SpaceEnd
)
View Source
var (
	Exact        = _l.Exact
	Pt           = _i.Pt
	Rigid        = _l.Rigid
	Flexed       = _l.Flexed
	UniformInset = _l.UniformInset
	Body1        = _m.Body1
	Editor       = _m.Editor
	RadioButton  = _m.RadioButton
	Slider       = _m.Slider
	Expanded     = _l.Expanded
	Stacked      = _l.Stacked
	FillShape    = _p.FillShape
	Fill         = _p.Fill
)

Functions

This section is empty.

Types

type Alignment

type Alignment = _l.Alignment

type Axis

type Axis = _l.Axis

type Constraints

type Constraints = _l.Constraints

type Dim

type Dim = _l.Dimensions

type Dp

type Dp = _u.Dp

type Enum

type Enum = _w.Enum

type Flex

type Flex = _l.Flex

type FlexChild

type FlexChild = _l.FlexChild

type Gx

type Gx = _l.Context

type Inset

type Inset = _l.Inset

type List

type List = _l.List

type MuxOption

type MuxOption struct {
	Label string
	Value *NRGBA
}

MuxOption is one choice for the value of a color multiplexer.

type MuxState

type MuxState struct {
	Enum
	Options        map[string]*NRGBA
	OrderedOptions []string
}

MuxState holds the state of a color multiplexer. A color multiplexer allows choosing from among a set of colors.

func NewMuxState

func NewMuxState(options ...MuxOption) MuxState

NewMuxState creates a MuxState that will provide choices between the MuxOptions given as parameters.

func (MuxState) Color

func (m MuxState) Color() *NRGBA

Color returns the currently-selected color.

type MuxStyle

type MuxStyle struct {
	*MuxState
	Theme *Theme
	Label string
}

MuxStyle renders a MuxState as a material design themed widget.

func Mux

func Mux(theme *Theme, state *MuxState, label string) MuxStyle

Mux creates a MuxStyle from a theme and a state.

func (MuxStyle) Layout

func (m MuxStyle) Layout(g Gx) Dim

Layout renders the MuxStyle into the provided context.

type NRGBA

type NRGBA = _c.NRGBA

type PickerStyle

type PickerStyle struct {
	*State
	*Theme
	Label string
	// MonospaceFace selects the typeface to use for monospace text fields.
	// The zero value will use the generic family "monospace".
	MonospaceFace font.Typeface
}

PickerStyle renders a color picker using material widgets.

func Picker

func Picker(th *Theme, state *State, label string) PickerStyle

Picker creates a pickerstyle from a theme and a state.

func (PickerStyle) Layout

func (p PickerStyle) Layout(g Gx) Dim

Layout renders the PickerStyle into the provided context.

type Point

type Point = _i.Point

type Rectangle

type Rectangle = _i.Rectangle

type Sp

type Sp = _u.Sp

type Spacing

type Spacing = _l.Spacing

type Stack

type Stack = _l.Stack

type State

type State struct {
	R, G, B, A widget.Float
	widget.Editor
	// contains filtered or unexported fields
}

State is the state of a colorpicker.

func (State) Alpha

func (s State) Alpha() uint8

Alpha returns the alpha value of the currently selected color.

func (State) Blue

func (s State) Blue() uint8

Blue returns the blue value of the currently selected color.

func (State) Color

func (s State) Color() NRGBA

Color returns the currently selected color.

func (State) Green

func (s State) Green() uint8

Green returns the green value of the currently selected color.

func (State) Red

func (s State) Red() uint8

Red returns the red value of the currently selected color.

func (*State) SetColor

func (s *State) SetColor(col NRGBA)

SetColor changes the color represented by the colorpicker.

func (*State) Update

func (s *State) Update(g Gx) bool

Update handles all state updates from the underlying widgets.

type Theme

type Theme = _m.Theme

type Widget

type Widget = _l.Widget

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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