TachyonUI 0.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;
31 bool allowHDR = false;
32 float hdrBrightness = 1.0f;
33 std::string hexText;
34
36
39 float comp[3] = { 0, 0, 0 };
41 float snapComp[3] = { 0, 0, 0 };
42 bool slidersInitialized = false;
43
45 bool byteRange = true;
47 bool picking = false;
48 std::optional<bool> canPick;
49 std::string context;
50
54 std::vector<tachyon::color4f> recent;
55
71
73 enum class DragTarget { None, Square, Hue, Alpha };
77 float startH = 0.0f, startS = 0.0f, startV = 0.0f, startA = 1.0f;
78
79 static constexpr int kNumGradientSliders = 4;
81
83 std::vector<PaletteSwatch> palette = {
84 {{ 0.8f, 0.8f, 0.8f, 1.0f }},
85 {{ 0.0f, 0.8f, 0.8f, 1.0f }},
86 {{ 0.8f, 0.0f, 0.8f, 1.0f }},
87 {{ 0.8f, 0.8f, 0.0f, 1.0f }},
88 };
89 };
90
96 {
97 public:
99
101 ColorPickerState& State() { return m_state; }
102
106
110
114
115 private:
116 ColorPickerState m_state{};
117 std::unordered_map<tachyon::ID, tachyon::VisualColorStyleIndex> m_swatchStyles, m_prevSwatchStyles;
118 };
119
120}
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:101
Stage callbacks run in registration order (no priorities): if A must run before B,...
Definition gui_frame_pipeline.h:74
@ None
Definition gui_element_flags.h:19
@ Cancel
Definition gui_input_enums.h:304
ColorSpace
The space gradient stops are interpolated in.
Definition gui_style_gradient.h:79
VisualColorStyleIndex
Index into StyleManager's color style pool; Invalid (0) draws nothing (transparent).
Definition gui_style.h:33
@ HSV
Definition gui_style_gradient.h:83
@ Invalid
Definition gui_style.h:33
Definition gui_logging.h:24
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:60
float hdrBrightness
HDR multiplier; > 1 brightens past 1.
Definition gui_color_picker_subsystem.h:32
tachyon::VisualColorStyleIndex originalOpaque
The original color without its alpha, for the preview's top half.
Definition gui_color_picker_subsystem.h:70
tachyon::VisualColorStyleIndex hueStrip
Definition gui_color_picker_subsystem.h:57
std::optional< bool > canPick
whether the platform reads the screen (asked once)
Definition gui_color_picker_subsystem.h:48
static constexpr int kNumGradientSliders
Definition gui_color_picker_subsystem.h:79
tachyon::VisualColorStyleIndex newOpaque
The new color without its alpha, for the preview's top half.
Definition gui_color_picker_subsystem.h:68
float startV
Definition gui_color_picker_subsystem.h:77
tachyon::VisualColorStyleIndex originalStyle
Definition gui_color_picker_subsystem.h:66
tachyon::VisualColorStyleIndex alphaStrip
Definition gui_color_picker_subsystem.h:58
DragTarget
What a press on the square or a strip changes.
Definition gui_color_picker_subsystem.h:73
std::vector< PaletteSwatch > palette
Definition gui_color_picker_subsystem.h:83
float startH
The color before it; put back by Escape.
Definition gui_color_picker_subsystem.h:77
bool picking
The eyedropper is held: the color follows the screen under the cursor.
Definition gui_color_picker_subsystem.h:47
bool allowHDR
the opening field accepts HDR colors
Definition gui_color_picker_subsystem.h:31
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:53
@ None
Definition gui_color_picker_subsystem.h:53
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:45
tachyon::VisualColorStyleIndex gradientStyles[kNumGradientSliders]
Definition gui_color_picker_subsystem.h:80
float startS
Definition gui_color_picker_subsystem.h:77
std::string context
what's being edited (the field's label), after the title
Definition gui_color_picker_subsystem.h:49
tachyon::VisualColorStyleIndex outlineColor
Outline around the cursors and handles.
Definition gui_color_picker_subsystem.h:63
tachyon::PointerDrag press
The press on the square or a strip, a drag from the start.
Definition gui_color_picker_subsystem.h:75
float s
Definition gui_color_picker_subsystem.h:29
tachyon::VisualColorStyleIndex newColor
The new color, with its alpha.
Definition gui_color_picker_subsystem.h:65
tachyon::color4f originalColor
color when picker was opened
Definition gui_color_picker_subsystem.h:30
tachyon::VisualColorStyleIndex svQuadColor
Definition gui_color_picker_subsystem.h:56
tachyon::VisualColorStyleIndex whiteColor
Definition gui_color_picker_subsystem.h:61
tachyon::ColorSpace activeSpace
Definition gui_color_picker_subsystem.h:35
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:41
float startA
Definition gui_color_picker_subsystem.h:77
bool slidersInitialized
Definition gui_color_picker_subsystem.h:42
float comp[3]
Components of the active space (H/S/V, R/G/B, L/a/b, ...).
Definition gui_color_picker_subsystem.h:39
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:33
float v
Definition gui_color_picker_subsystem.h:29
std::vector< tachyon::color4f > recent
newest first
Definition gui_color_picker_subsystem.h:54
Per-frame values plus references to long-lived managers, passed to every stage callback.
Definition gui_frame_pipeline.h:32
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
One press on an element that may become a drag.
Definition gui_pointer_drag.h:41
Definition gui_base_types.h:395