README

colorpicker

Go Reference

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

screenshot of provided widgets

Expand ▾ Collapse ▴

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

    This section is empty.

    Functions

    This section is empty.

    Types

    type C

    type C = layout.Context

    type D

    type D = layout.Dimensions

    type MuxOption

    type MuxOption struct {
    	Label string
    	Value *color.NRGBA
    }

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

      type MuxState

      type MuxState struct {
      	widget.Enum
      	Options        map[string]*color.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() *color.NRGBA

            Color returns the currently-selected color.

            type MuxStyle

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

              MuxStyle renders a MuxState as a material design themed widget.

              func Mux

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

                Mux creates a MuxStyle from a theme and a state.

                func (MuxStyle) Layout

                func (m MuxStyle) Layout(gtx layout.Context) layout.Dimensions

                  Layout renders the MuxStyle into the provided context.

                  type PickerStyle

                  type PickerStyle struct {
                  	*State
                  	*material.Theme
                  	Label string
                  }

                    PickerStyle renders a color picker using material widgets.

                    func Picker

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

                      Picker creates a pickerstyle from a theme and a state.

                      func (PickerStyle) Layout

                      func (p PickerStyle) Layout(gtx layout.Context) layout.Dimensions

                        Layout renders the PickerStyle into the provided context.

                        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) Changed

                              func (s State) Changed() bool

                                Changed returns whether the color has changed since last frame.

                                func (State) Color

                                func (s State) Color() 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) Layout

                                    func (s *State) Layout(gtx layout.Context) layout.Dimensions

                                      Layout handles all state updates from the underlying widgets.

                                      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(c color.NRGBA)

                                          SetColor changes the color represented by the colorpicker.

                                          Source Files