TachyonUI 1.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
tachyon::ColorPickerState Struct Reference

Persistent state of the color picker popup. More...

#include <gui_controls/subsystems/gui_color_picker_subsystem.h>

Classes

struct  HSVA
 The working color as HSV+A, the part a press on the square or a strip changes. More...
struct  PaletteSwatch

Public Types

enum class  CloseRequest { None , Ok , Cancel }
 OK keeps the color (and adds it to the recent ones), Cancel and the close button restore the one the picker opened with. More...
enum class  DragTarget { None , Square , Hue , Alpha }
 What a press on the square or a strip changes. More...

Public Attributes

tachyon::ID triggerID = tachyon::ID::Invalid()
 swatch that opened the picker
tachyon::ID windowID = tachyon::ID::Invalid()
 popup window ID
float h = 0
float s = 0
float v = 0
float a = 1
 working HSV+A copy
float spaceHue = 0
 The hue in the active space (HSL's, Lab's or Oklab's angle), 0-1.
tachyon::color4f originalColor {}
 color when picker was opened
bool allowHDR = false
 the opening field accepts HDR colors
float hdrBrightness = 1.0f
 HDR multiplier; > 1 brightens past 1.
std::string hexText
 hex input field text
tachyon::ColorSpace activeSpace = tachyon::ColorSpace::HSV
float comp [3] = { 0, 0, 0 }
 Components of the active space (H/S/V, R/G/B, L/a/b, ...).
float snapComp [3] = { 0, 0, 0 }
 comp as last built; a difference next frame means a slider edited it.
bool slidersInitialized = false
bool byteRange = true
 Channel values shown 0-255 (and hue in degrees, S/V/L in percent), or 0-1.
bool picking = false
 The eyedropper is held: the color follows the screen under the cursor.
std::optional< bool > canPick
 whether the platform reads the screen (asked once)
std::string context
 what's being edited (the field's label), after the title
enum tachyon::ColorPickerState::CloseRequest closeRequest = CloseRequest::None
std::vector< tachyon::color4f > recent
 newest first
tachyon::VisualColorStyleIndex svQuadColor = tachyon::VisualColorStyleIndex::Invalid
tachyon::VisualColorStyleIndex hueStrip = tachyon::VisualColorStyleIndex::Invalid
tachyon::VisualColorStyleIndex alphaStrip = tachyon::VisualColorStyleIndex::Invalid
tachyon::VisualColorStyleIndex hueColor = tachyon::VisualColorStyleIndex::Invalid
 The pure hue, shown in the hue handle.
tachyon::VisualColorStyleIndex whiteColor = tachyon::VisualColorStyleIndex::Invalid
tachyon::VisualColorStyleIndex outlineColor = tachyon::VisualColorStyleIndex::Invalid
 Outline around the cursors and handles.
tachyon::VisualColorStyleIndex newColor = tachyon::VisualColorStyleIndex::Invalid
 The new color, with its alpha.
tachyon::VisualColorStyleIndex originalStyle = tachyon::VisualColorStyleIndex::Invalid
tachyon::Gesture< HSVA > press
 The press on the square or a strip, a drag from the start; the color before it is put back by Escape.
tachyon::VisualColorStyleIndex gradientStyles [kNumGradientSliders] = {}
std::vector< PaletteSwatch > palette
 The design's palette: red, orange, amber, green, teal (half clear), blue, sky, violet (half clear), pink, white, black, black (half clear).

Static Public Attributes

static constexpr int kNumGradientSliders = 4

Detailed Description

Persistent state of the color picker popup.

The picker opens off a ColorField swatch (triggerID), edits a working copy, and writes the result back to the caller's color. It lives across frames so the popup keeps its tab, palette and drag state while the popup is rebuilt each frame.

Member Enumeration Documentation

◆ CloseRequest

OK keeps the color (and adds it to the recent ones), Cancel and the close button restore the one the picker opened with.

Handled by the ColorField on its next frame.

Enumerator
None 
Ok 
Cancel 

◆ DragTarget

What a press on the square or a strip changes.

Enumerator
None 
Square 
Hue 
Alpha 

Member Data Documentation

◆ triggerID

tachyon::ID tachyon::ColorPickerState::triggerID = tachyon::ID::Invalid()

swatch that opened the picker

◆ windowID

tachyon::ID tachyon::ColorPickerState::windowID = tachyon::ID::Invalid()

popup window ID

◆ h

float tachyon::ColorPickerState::h = 0

◆ s

float tachyon::ColorPickerState::s = 0

◆ v

float tachyon::ColorPickerState::v = 0

◆ a

float tachyon::ColorPickerState::a = 1

working HSV+A copy

◆ spaceHue

float tachyon::ColorPickerState::spaceHue = 0

The hue in the active space (HSL's, Lab's or Oklab's angle), 0-1.

Kept apart: a grey has none, and the strip and square still need one to work with.

◆ originalColor

tachyon::color4f tachyon::ColorPickerState::originalColor {}

color when picker was opened

◆ allowHDR

bool tachyon::ColorPickerState::allowHDR = false

the opening field accepts HDR colors

◆ hdrBrightness

float tachyon::ColorPickerState::hdrBrightness = 1.0f

HDR multiplier; > 1 brightens past 1.

◆ hexText

std::string tachyon::ColorPickerState::hexText

hex input field text

◆ activeSpace

tachyon::ColorSpace tachyon::ColorPickerState::activeSpace = tachyon::ColorSpace::HSV

◆ comp

float tachyon::ColorPickerState::comp[3] = { 0, 0, 0 }

Components of the active space (H/S/V, R/G/B, L/a/b, ...).

Members, since the channel tracks' handlers keep pointers to them until dispatch.

◆ snapComp

float tachyon::ColorPickerState::snapComp[3] = { 0, 0, 0 }

comp as last built; a difference next frame means a slider edited it.

◆ slidersInitialized

bool tachyon::ColorPickerState::slidersInitialized = false

◆ byteRange

bool tachyon::ColorPickerState::byteRange = true

Channel values shown 0-255 (and hue in degrees, S/V/L in percent), or 0-1.

◆ picking

bool tachyon::ColorPickerState::picking = false

The eyedropper is held: the color follows the screen under the cursor.

◆ canPick

std::optional<bool> tachyon::ColorPickerState::canPick

whether the platform reads the screen (asked once)

◆ context

std::string tachyon::ColorPickerState::context

what's being edited (the field's label), after the title

◆ closeRequest

enum tachyon::ColorPickerState::CloseRequest tachyon::ColorPickerState::closeRequest = CloseRequest::None

◆ recent

std::vector<tachyon::color4f> tachyon::ColorPickerState::recent

newest first

◆ svQuadColor

◆ hueStrip

◆ alphaStrip

◆ hueColor

The pure hue, shown in the hue handle.

◆ whiteColor

◆ outlineColor

Outline around the cursors and handles.

◆ newColor

The new color, with its alpha.

◆ originalStyle

tachyon::VisualColorStyleIndex tachyon::ColorPickerState::originalStyle = tachyon::VisualColorStyleIndex::Invalid

◆ press

tachyon::Gesture<HSVA> tachyon::ColorPickerState::press

The press on the square or a strip, a drag from the start; the color before it is put back by Escape.

◆ kNumGradientSliders

int tachyon::ColorPickerState::kNumGradientSliders = 4
staticconstexpr

◆ gradientStyles

tachyon::VisualColorStyleIndex tachyon::ColorPickerState::gradientStyles[kNumGradientSliders] = {}

◆ palette

std::vector<PaletteSwatch> tachyon::ColorPickerState::palette
Initial value:
= {
{{ 0.937f, 0.408f, 0.408f, 1.0f }}, {{ 0.965f, 0.620f, 0.294f, 1.0f }}, {{ 0.910f, 0.718f, 0.322f, 1.0f }},
{{ 0.290f, 0.761f, 0.549f, 1.0f }}, {{ 0.165f, 0.776f, 0.729f, 0.5f }}, {{ 0.231f, 0.510f, 0.965f, 1.0f }},
{{ 0.420f, 0.608f, 1.000f, 1.0f }}, {{ 0.659f, 0.545f, 0.980f, 0.5f }}, {{ 0.957f, 0.447f, 0.714f, 1.0f }},
{{ 1.000f, 1.000f, 1.000f, 1.0f }}, {{ 0.000f, 0.000f, 0.000f, 1.0f }}, {{ 0.000f, 0.000f, 0.000f, 0.5f }},
}

The design's palette: red, orange, amber, green, teal (half clear), blue, sky, violet (half clear), pink, white, black, black (half clear).


The documentation for this struct was generated from the following file: