ColorPicker

package
v0.0.0-...-357ca8a Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

A widget that provides an interface for selecting or modifying a color. It can optionally provide functionalities like a color sampler (eyedropper), color modes, and presets.

Note: This control is the color picker widget itself. You can use a ColorPickerButton instead if you need a button that brings up a ColorPicker in a popup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsColorPicker() Instance
}

type ColorModeType

type ColorModeType int //gd:ColorPicker.ColorModeType
const (
	// Allows editing the color with Red/Green/Blue sliders in sRGB color space.
	ModeRgb ColorModeType = 0
	// Allows editing the color with Hue/Saturation/Value sliders.
	ModeHsv ColorModeType = 1
	ModeRaw ColorModeType = 2
	// Allows editing the color with Red/Green/Blue sliders in linear color space.
	ModeLinear ColorModeType = 2
	// Allows editing the color with Hue/Saturation/Lightness sliders.
	//
	// OKHSL is a new color space similar to HSL but that better match perception by leveraging the Oklab color space which is designed to be simple to use, while doing a good job at predicting perceived lightness, chroma and hue.
	//
	// [Okhsv and Okhsl color spaces]
	//
	// [Okhsv and Okhsl color spaces]: https://bottosson.github.io/posts/colorpicker/
	ModeOkhsl ColorModeType = 3
)

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsBoxContainer

func (self *Extension[T]) AsBoxContainer() BoxContainer.Instance

func (*Extension[T]) AsCanvasItem

func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance

func (*Extension[T]) AsColorPicker

func (self *Extension[T]) AsColorPicker() Instance

func (*Extension[T]) AsContainer

func (self *Extension[T]) AsContainer() Container.Instance

func (*Extension[T]) AsControl

func (self *Extension[T]) AsControl() Control.Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsVBoxContainer

func (self *Extension[T]) AsVBoxContainer() VBoxContainer.Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.ColorPicker

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AddPreset

func (self Instance) AddPreset(color Color.RGBA)

Adds the given color to a list of color presets. The presets are displayed in the color picker and the user will be able to select them.

Note: The presets list is only for this color picker.

func (Instance) AddRecentPreset

func (self Instance) AddRecentPreset(color Color.RGBA)

Adds the given color to a list of color recent presets so that it can be picked later. Recent presets are the colors that were picked recently, a new preset is automatically created and added to recent presets when you pick a new color.

Note: The recent presets list is only for this color picker.

func (Instance) AsBoxContainer

func (self Instance) AsBoxContainer() BoxContainer.Instance

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsColorPicker

func (self Instance) AsColorPicker() Instance

func (Instance) AsContainer

func (self Instance) AsContainer() Container.Instance

func (Instance) AsControl

func (self Instance) AsControl() Control.Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsVBoxContainer

func (self Instance) AsVBoxContainer() VBoxContainer.Instance

func (Instance) CanAddSwatches

func (self Instance) CanAddSwatches() bool

If true, it's possible to add presets under Swatches. If false, the button to add presets is disabled.

func (Instance) Color

func (self Instance) Color() Color.RGBA

The currently selected color.

func (Instance) ColorMode

func (self Instance) ColorMode() ColorModeType

The currently selected color mode.

func (Instance) ColorModesVisible

func (self Instance) ColorModesVisible() bool

If true, the color mode buttons are visible.

func (Instance) DeferredMode

func (self Instance) DeferredMode() bool

If true, the color will apply only after the user releases the mouse button, otherwise it will apply immediately even in mouse motion event (which can cause performance issues).

func (Instance) EditAlpha

func (self Instance) EditAlpha() bool

If true, shows an alpha channel slider (opacity).

func (Instance) EditIntensity

func (self Instance) EditIntensity() bool

If true, shows an intensity slider. The intensity is applied as follows: multiply the color by 2 ** intensity in linear RGB space, and then convert it back to sRGB.

func (Instance) ErasePreset

func (self Instance) ErasePreset(color Color.RGBA)

Removes the given color from the list of color presets of this color picker.

func (Instance) EraseRecentPreset

func (self Instance) EraseRecentPreset(color Color.RGBA)

Removes the given color from the list of color recent presets of this color picker.

func (Instance) GetPresets

func (self Instance) GetPresets() []Color.RGBA

Returns the list of colors in the presets of the color picker.

func (Instance) GetRecentPresets

func (self Instance) GetRecentPresets() []Color.RGBA

Returns the list of colors in the recent presets of the color picker.

func (Instance) HexVisible

func (self Instance) HexVisible() bool

If true, the hex color code input field is visible.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) OnColorChanged

func (self Instance) OnColorChanged(cb func(color Color.RGBA), flags ...Signal.Flags)

Emitted when the color is changed.

func (Instance) OnPresetAdded

func (self Instance) OnPresetAdded(cb func(color Color.RGBA), flags ...Signal.Flags)

Emitted when a preset is added.

func (Instance) OnPresetRemoved

func (self Instance) OnPresetRemoved(cb func(color Color.RGBA), flags ...Signal.Flags)

Emitted when a preset is removed.

func (Instance) PickerShape

func (self Instance) PickerShape() PickerShapeType

The shape of the color space view.

func (Instance) PresetsVisible

func (self Instance) PresetsVisible() bool

If true, the Swatches and Recent Colors presets are visible.

func (Instance) SamplerVisible

func (self Instance) SamplerVisible() bool

If true, the color sampler and color preview are visible.

func (Instance) SetCanAddSwatches

func (self Instance) SetCanAddSwatches(value bool)

SetCanAddSwatches sets the property returned by [AreSwatchesEnabled].

func (Instance) SetColor

func (self Instance) SetColor(value Color.RGBA)

SetColor sets the property returned by [GetPickColor].

func (Instance) SetColorMode

func (self Instance) SetColorMode(value ColorModeType)

SetColorMode sets the property returned by [GetColorMode].

func (Instance) SetColorModesVisible

func (self Instance) SetColorModesVisible(value bool)

SetColorModesVisible sets the property returned by [AreModesVisible].

func (Instance) SetDeferredMode

func (self Instance) SetDeferredMode(value bool)

SetDeferredMode sets the property returned by [IsDeferredMode].

func (Instance) SetEditAlpha

func (self Instance) SetEditAlpha(value bool)

SetEditAlpha sets the property returned by [IsEditingAlpha].

func (Instance) SetEditIntensity

func (self Instance) SetEditIntensity(value bool)

SetEditIntensity sets the property returned by [IsEditingIntensity].

func (Instance) SetHexVisible

func (self Instance) SetHexVisible(value bool)

SetHexVisible sets the property returned by [IsHexVisible].

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetPickerShape

func (self Instance) SetPickerShape(value PickerShapeType)

SetPickerShape sets the property returned by [GetPickerShape].

func (Instance) SetPresetsVisible

func (self Instance) SetPresetsVisible(value bool)

SetPresetsVisible sets the property returned by [ArePresetsVisible].

func (Instance) SetSamplerVisible

func (self Instance) SetSamplerVisible(value bool)

SetSamplerVisible sets the property returned by [IsSamplerVisible].

func (Instance) SetSlidersVisible

func (self Instance) SetSlidersVisible(value bool)

SetSlidersVisible sets the property returned by [AreSlidersVisible].

func (Instance) SlidersVisible

func (self Instance) SlidersVisible() bool

If true, the color sliders are visible.

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type PickerShapeType

type PickerShapeType int //gd:ColorPicker.PickerShapeType
const (
	// HSV Color Model rectangle color space.
	ShapeHsvRectangle PickerShapeType = 0
	// HSV Color Model rectangle color space with a wheel.
	ShapeHsvWheel PickerShapeType = 1
	// HSV Color Model circle color space. Use Saturation as a radius.
	ShapeVhsCircle PickerShapeType = 2
	// HSL OK Color Model circle color space.
	ShapeOkhslCircle PickerShapeType = 3
	// The color space shape and the shape select button are hidden. Can't be selected from the shapes popup.
	ShapeNone PickerShapeType = 4
	// OKHSL Color Model rectangle with constant lightness.
	ShapeOkHsRectangle PickerShapeType = 5
	// OKHSL Color Model rectangle with constant saturation.
	ShapeOkHlRectangle PickerShapeType = 6
)

Jump to

Keyboard shortcuts

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