TachyonUI 1.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_color_picker_subsystem.h
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4#include <string>
5#include <unordered_map>
6#include <vector>
7
8#include <gui_core/gui_id.h>
12
13namespace tachyon
14{
17
18 class FramePipeline;
19 struct FrameContext;
20
26 {
29 float h = 0, s = 0, v = 0, a = 1;
32 float spaceHue = 0;
34 bool allowHDR = false;
35 float hdrBrightness = 1.0f;
36 std::string hexText;
37
39
42 float comp[3] = { 0, 0, 0 };
44 float snapComp[3] = { 0, 0, 0 };
45 bool slidersInitialized = false;
46
48 bool byteRange = true;
50 bool picking = false;
51 std::optional<bool> canPick;
52 std::string context;
53
57 std::vector<tachyon::color4f> recent;
58
70
72 enum class DragTarget { None, Square, Hue, Alpha };
74 struct HSVA { float h = 0.0f, s = 0.0f, v = 0.0f, a = 1.0f; };
78
79 static constexpr int kNumGradientSliders = 4;
81
85 std::vector<PaletteSwatch> palette = {
86 {{ 0.937f, 0.408f, 0.408f, 1.0f }}, {{ 0.965f, 0.620f, 0.294f, 1.0f }}, {{ 0.910f, 0.718f, 0.322f, 1.0f }},
87 {{ 0.290f, 0.761f, 0.549f, 1.0f }}, {{ 0.165f, 0.776f, 0.729f, 0.5f }}, {{ 0.231f, 0.510f, 0.965f, 1.0f }},
88 {{ 0.420f, 0.608f, 1.000f, 1.0f }}, {{ 0.659f, 0.545f, 0.980f, 0.5f }}, {{ 0.957f, 0.447f, 0.714f, 1.0f }},
89 {{ 1.000f, 1.000f, 1.000f, 1.0f }}, {{ 0.000f, 0.000f, 0.000f, 1.0f }}, {{ 0.000f, 0.000f, 0.000f, 0.5f }},
90 };
91 };
92
98 {
99 public:
101
103 ColorPickerState& State() { return m_state; }
104
108
112
116
117 private:
118 ColorPickerState m_state{};
119 SwatchStyles<> m_swatchStyles;
120 };
121
122}
void KeepSwatchAlive(tachyon::ID swatchID)
Carries swatchID's style over without rebuilding it: a cache-hit scope doesn't re-claim its swatches,...
ColorPickerSubsystem(FramePipeline &frame)
void ForgetStyles()
Drops every held style index without destroying it; call after a theme reload (StyleManager::ClearAll...
tachyon::VisualColorStyleIndex & ClaimSwatchStyle(tachyon::ID swatchID)
The color style slot of swatch swatchID, kept alive this frame.
ColorPickerState & State()
The picker popup's state.
Definition gui_color_picker_subsystem.h:103
Stage callbacks run in registration order (no priorities): if A must run before B,...
Definition gui_frame_pipeline.h:74
Swatches' color styles, by swatch ID: each kept while it's claimed every frame, and destroyed the fra...
Definition gui_swatch_styles.h:21
@ None
Definition gui_element_flags.h:18
@ Alpha
Definition gui_image.h:33
@ Cancel
Definition gui_input_enums.h:304
ColorSpace
The space gradient stops are interpolated in.
Definition gui_style_gradient.h:81
VisualColorStyleIndex
Index into StyleManager's color style pool; Invalid (0) draws nothing (transparent).
Definition gui_style.h:33
@ HSV
Definition gui_style_gradient.h:85
@ Invalid
Definition gui_style.h:33
Definition gui_logging.h:24
The working color as HSV+A, the part a press on the square or a strip changes.
Definition gui_color_picker_subsystem.h:74
float h
Definition gui_color_picker_subsystem.h:74
float v
Definition gui_color_picker_subsystem.h:74
float s
Definition gui_color_picker_subsystem.h:74
float a
Definition gui_color_picker_subsystem.h:74
Definition gui_color_picker_subsystem.h:82
tachyon::color4f color
Definition gui_color_picker_subsystem.h:82
Persistent state of the color picker popup.
Definition gui_color_picker_subsystem.h:26
tachyon::VisualColorStyleIndex hueColor
The pure hue, shown in the hue handle.
Definition gui_color_picker_subsystem.h:63
float hdrBrightness
HDR multiplier; > 1 brightens past 1.
Definition gui_color_picker_subsystem.h:35
float spaceHue
The hue in the active space (HSL's, Lab's or Oklab's angle), 0-1.
Definition gui_color_picker_subsystem.h:32
tachyon::VisualColorStyleIndex hueStrip
Definition gui_color_picker_subsystem.h:60
std::optional< bool > canPick
whether the platform reads the screen (asked once)
Definition gui_color_picker_subsystem.h:51
static constexpr int kNumGradientSliders
Definition gui_color_picker_subsystem.h:79
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.
Definition gui_color_picker_subsystem.h:77
tachyon::VisualColorStyleIndex originalStyle
Definition gui_color_picker_subsystem.h:69
tachyon::VisualColorStyleIndex alphaStrip
Definition gui_color_picker_subsystem.h:61
DragTarget
What a press on the square or a strip changes.
Definition gui_color_picker_subsystem.h:72
std::vector< PaletteSwatch > palette
The design's palette: red, orange, amber, green, teal (half clear), blue, sky, violet (half clear),...
Definition gui_color_picker_subsystem.h:85
bool picking
The eyedropper is held: the color follows the screen under the cursor.
Definition gui_color_picker_subsystem.h:50
bool allowHDR
the opening field accepts HDR colors
Definition gui_color_picker_subsystem.h:34
CloseRequest
OK keeps the color (and adds it to the recent ones), Cancel and the close button restore the one the ...
Definition gui_color_picker_subsystem.h:56
@ None
Definition gui_color_picker_subsystem.h:56
enum tachyon::ColorPickerState::CloseRequest closeRequest
bool byteRange
Channel values shown 0-255 (and hue in degrees, S/V/L in percent), or 0-1.
Definition gui_color_picker_subsystem.h:48
tachyon::VisualColorStyleIndex gradientStyles[kNumGradientSliders]
Definition gui_color_picker_subsystem.h:80
std::string context
what's being edited (the field's label), after the title
Definition gui_color_picker_subsystem.h:52
tachyon::VisualColorStyleIndex outlineColor
Outline around the cursors and handles.
Definition gui_color_picker_subsystem.h:66
float s
Definition gui_color_picker_subsystem.h:29
tachyon::VisualColorStyleIndex newColor
The new color, with its alpha.
Definition gui_color_picker_subsystem.h:68
tachyon::color4f originalColor
color when picker was opened
Definition gui_color_picker_subsystem.h:33
tachyon::VisualColorStyleIndex svQuadColor
Definition gui_color_picker_subsystem.h:59
tachyon::VisualColorStyleIndex whiteColor
Definition gui_color_picker_subsystem.h:64
tachyon::ColorSpace activeSpace
Definition gui_color_picker_subsystem.h:38
tachyon::ID triggerID
swatch that opened the picker
Definition gui_color_picker_subsystem.h:27
float snapComp[3]
comp as last built; a difference next frame means a slider edited it.
Definition gui_color_picker_subsystem.h:44
bool slidersInitialized
Definition gui_color_picker_subsystem.h:45
float comp[3]
Components of the active space (H/S/V, R/G/B, L/a/b, ...).
Definition gui_color_picker_subsystem.h:42
tachyon::ID windowID
popup window ID
Definition gui_color_picker_subsystem.h:28
float a
working HSV+A copy
Definition gui_color_picker_subsystem.h:29
float h
Definition gui_color_picker_subsystem.h:29
std::string hexText
hex input field text
Definition gui_color_picker_subsystem.h:36
float v
Definition gui_color_picker_subsystem.h:29
std::vector< tachyon::color4f > recent
newest first
Definition gui_color_picker_subsystem.h:57
Per-frame values plus references to long-lived managers, passed to every stage callback.
Definition gui_frame_pipeline.h:32
One press that may become a drag, with what every control does around it: the focus and the capture o...
Definition gui_gesture.h:60
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
static constexpr ID Invalid()
The "no element" ID (all bits zero); also the default for optional ID parameters.
Definition gui_id.h:66
Definition gui_base_types.h:394