TachyonUI 1.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_text_system.h
Go to the documentation of this file.
1#pragma once
2
4#include <gui_core/gui_id.h>
5#include <gui_core/gui_hash.h>
6
9
11
14
15#include <bit>
16#include <cstddef>
17#include <stdint.h>
18#include <optional>
19#include <span>
20#include <string>
21#include <string_view>
22#include <vector>
23
24namespace tachyon
25{
28
32 {
33 std::string_view file;
34 std::span<const std::byte> data;
35 };
36
37 // Forward declarations
38 class GraphicsContext;
39 class GUIStateManager;
40 class IClipboard;
41 class StyleManager;
42 class ScrollManagement;
43 class TextAtlasManager;
44 enum class KeyAction : uint8_t;
45 enum class MouseAction : uint8_t;
46 enum class ElementFlags : uint32_t;
47
48 // ------------------------------------------------------------------------
49 // Icon Measurement Result
50 // ------------------------------------------------------------------------
51
53 {
54 int32_t width = 0;
55 int32_t height = 0;
56
57 constexpr int2 Size() const { return int2{ width, height }; }
58 constexpr bool IsEmpty() const { return width == 0 && height == 0; }
59 };
60
61 // ------------------------------------------------------------------------
62 // Text Measurement Result
63 // ------------------------------------------------------------------------
65 {
66 static constexpr int32_t kUnbounded = std::numeric_limits<int32_t>::max();
67
68 int32_t minWidth = 0;
69 int32_t maxWidth = 0;
70 int32_t minHeight = 0;
71 int32_t maxHeight = 0;
72
73 constexpr int2 MinSize() const { return int2{ minWidth, minHeight }; }
74 constexpr int2 MaxSize() const { return int2{ maxWidth, maxHeight }; }
75 constexpr bool IsEmpty() const { return maxWidth == 0 && maxHeight == 0; }
76 };
77
78 // ------------------------------------------------------------------------
79 // Text Wrap Context - Constraints for text measurement
80 // ------------------------------------------------------------------------
81
83 {
84 int32_t maxWidth = INT32_MAX;
85 int32_t maxHeight = INT32_MAX;
86 uint32_t maxLines = UINT32_MAX;
87
88 bool operator==(const TextWrapContext&) const = default;
89
90 inline uint64_t GetHashCode() const { return Hash::Calculate(*this); }
91 };
92
93 // ------------------------------------------------------------------------
94 // Text Editing Behavior
95 // ------------------------------------------------------------------------
96
97 enum class TextEditBehavior : uint8_t
98 {
99 None = 0,
101 Multiline = 1 << 1,
102 AcceptTabs = 1 << 2,
103 ReadOnly = 1 << 3
104 };
106
107
108 // ----------------------------------------------------------------------------------
109 // ContentRun - Represents a run of either text or an icon for rich text registration
110 // ----------------------------------------------------------------------------------
111
112
114 {
115 color4b color { 64, 148, 255, 255 };
116 color4b hoverColor { 128, 200, 255, 255 };
121
122 bool operator==(const LinkStyle&) const noexcept = default;
123 };
124
127 {
128 static constexpr float kSizeAuto = -1.0f;
129
130 enum Type { Text, Icon };
132
133 std::string_view text;
135
138
139 intptr_t contentId = 0;
140 bool isLink = false;
142
145 const TextStyle* textStyleOverride = nullptr;
151
152 uint64_t GetHashCode() const
153 {
154 uint64_t hash = Hash::Calculate(type);
155 if (type == Text)
156 {
157 hash = Hash::Combine(hash, Hash::Calculate(text));
158 } else
159 {
160 if (iconID == IconID::Invalid)
161 {
162 hash = Hash::Combine(hash, ((uint32_t)iconID), 0, 0);
163 } else
164 {
165 hash = Hash::Combine(hash, ((uint32_t)iconID), std::bit_cast<uint32_t>(iconWidth), std::bit_cast<uint32_t>(iconHeight));
166 }
167 }
168 hash = Hash::Combine(hash, static_cast<uint64_t>(contentId), isLink ? 1u : 0u);
169 if (isLink)
174 if (background.a != 0)
176 if (color.a != 0)
177 hash = Hash::Combine(hash, Hash::Calculate(color), 1u);
178 return hash;
179 }
180 };
181
182
183 // ------------------------------------------------------------------------
184 // Abstract Text System Interface
185 // ------------------------------------------------------------------------
186
189 {
190 public:
191 virtual ~ITextSystem() = default;
192
194 {
195 bool textChanged = false;
196 bool textCommitted = false;
197
198 constexpr bool HasUpdate() const
199 {
200 return textChanged || textCommitted;
201 }
202 };
203
204 // -------------------- Initialization --------------------
205
209 virtual void SetFontDirectory(std::string_view directory) = 0;
210
214 virtual void SetFallbackFontDirectory(std::string_view directory) = 0;
215
216 virtual bool Initialize(GraphicsContext* graphicsContext, StyleManager* styleManager,
217 TextAtlasManager* textAtlasManager,
218 GUIStateManager* guiStateManager, IClipboard* clipboard) = 0;
219 virtual void Shutdown() = 0;
220 virtual void Update() = 0;
221
224 virtual void BeginFrame(int2 screenMousePos, MouseButtons mouseButtons, uint32_t timeMs) = 0;
225
229 virtual void BeginAtlasRecord(ID /*scopeId*/) {}
230 virtual void EndAtlasRecord() {}
231 virtual bool ReplayAtlasTouches(ID /*scopeId*/) { return true; }
232
233 // -------------------- Font Registration --------------------
234
239 virtual void SetLanguage(std::string_view languageTag) = 0;
240
246 virtual FontID RegisterFontFamily(std::string_view familyName, std::span<const FontFaceSource> faces) = 0;
247 FontID RegisterFontFamily(std::string_view familyName, std::span<const std::string_view> faceFiles)
248 {
249 std::vector<FontFaceSource> faces;
250 faces.reserve(faceFiles.size());
251 for (std::string_view file : faceFiles)
252 faces.push_back(FontFaceSource{ .file = file });
253 return RegisterFontFamily(familyName, faces);
254 }
255
256 // -------------------- Text Registration --------------------
257
259 virtual TextID RegisterText(ID elementId, IconID iconId, std::string_view text, StyleRef styleIndex, ElementState state) = 0;
260 TextID RegisterText(ID elementId, std::string_view text, StyleRef styleIndex, ElementState state) { return RegisterText(elementId, IconID::Invalid, text, styleIndex, state); }
261
264 virtual TextID RegisterEditableText(ID elementId, std::string& text, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool& wasModified,
265 const ITextValidator* validator = nullptr) = 0;
266
270 virtual std::string* ValueEditText(ID elementId, bool& started) = 0;
271
274 template<typename T, typename Converter = TextConverter<T>>
275 TextID RegisterEditableValue(ID elementId, T& value, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool& wasModified,
276 const Converter& converter = DefaultTextConverter<T>())
277 {
278 bool started = false;
279 std::string* editText = ValueEditText(elementId, started);
280 std::string shownText;
281 if (editText == nullptr)
282 shownText = converter.Format(value, /*editing*/ false);
283 else if (started)
284 *editText = converter.Format(value, /*editing*/ true);
285 std::string& text = editText ? *editText : shownText;
286
287 bool edited = false;
288 const TextID textId = RegisterEditableText(elementId, text, behavior, styleIndex, state, edited, &converter);
289 if (edited && converter.Parse(text, value))
290 wasModified = true;
291 return textId;
292 }
293
296 template<typename T>
297 TextID RegisterEditableNumber(ID elementId, T& value, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool& wasModified, NumericFieldConfig<T> config = {})
298 {
299 bool edited = false;
300 TextID textId{};
301 if constexpr (std::is_floating_point_v<T>)
302 textId = RegisterEditableValue(elementId, value, behavior, styleIndex, state, edited, FixedDecimalsConverter<T>(config.decimals));
303 else
304 textId = RegisterEditableValue(elementId, value, behavior, styleIndex, state, edited);
305 if (edited)
306 {
307 wasModified = true;
308 value = std::clamp(value, config.minVal, config.maxVal);
309 }
310 return textId;
311 }
312
315 virtual void SetTextColor(TextID textId, VisualColorStyleIndex color) = 0;
316
318 virtual void SetCaretColor(VisualColorStyleIndex color) = 0;
320 virtual void SetUndoHistory(class UndoHistory* history) = 0;
321
323 virtual std::string_view GetText(TextID textId) const = 0;
324
325
327 virtual TextID RegisterRichText(ID elementId, const std::span<ContentRun>& contentRuns,
328 StyleRef styleIndex, ElementState state) = 0;
329
332 virtual TextID RegisterEditableRichText(ID elementId, const std::span<ContentRun>& contentRuns,
333 TextEditBehavior behavior, StyleRef styleIndex,
334 ElementState state, bool& wasModified) = 0;
335
338 virtual TextID GetTextID(ID elementId) const = 0;
339
340 // -------------------- Text Measurement (for layout) --------------------
341
343 virtual TextMeasurement GetTextMeasurement(TextID textId) const = 0;
344
346 virtual TextMeasurement MeasureText(TextID textId, const TextWrapContext& wrapContext) const = 0;
347
350 virtual int32_t GetTextHeightWithoutIcon(TextID textId) const = 0;
351
352 // -------------------- Text Rendering --------------------
353
359 virtual void RenderText(TextID textId, IntRect rect, IntRect innerRect, IntRect clipRect, float pixelScale = 1.f,
360 const float3x2& screenToLayout = float3x2::Identity()) = 0;
361
364 virtual std::optional<MouseCursor> LinkCursorAt(ID elementId, int32_t localX, int32_t localY) const = 0;
365
367 virtual intptr_t HitTestContent(TextID textId, int32_t localX, int32_t localY) const = 0;
368
370 virtual void SetHoveredContent(TextID textId, intptr_t contentId) = 0;
371
372
373
374 // -------------------- Icon Measurement --------------------
375
377 virtual IconMeasurement GetIconMeasurement(IconID iconId) const = 0;
378
380 virtual IconMeasurement MeasureIcon(IconID iconId) const = 0;
381
382 // -------------------- Icon Registration --------------------
383
385 virtual bool IsValidIcon(IconID iconId) const = 0;
386
389 virtual IconID RegisterIconFromSVG(const char* name, const char* svg_data, size_t svg_size) = 0;
390
393 virtual IconID RegisterIconFromSVGFile(const char* path) = 0;
394
400 virtual IconID RegisterIconFromPixels(const char* name, uint2 size, std::span<const uint8_t> rgba) = 0;
401
406 virtual void UnregisterIcon(IconID iconId) = 0;
407
408 // -------------------- Icon Rendering --------------------
409
413 virtual void RenderIcon(IconID iconId, IntRect rect, IntRect clipRect, VisualColorStyleIndex tint,
414 std::span<const VisualShadow> shadows = {}) = 0;
415
416
417
418 // -------------------- Editor Input Handling --------------------
420 virtual void OnKeyboard(ID windowId, KeyCode key, int repeat, KeyModifier modifiers, KeyAction action) = 0;
421
423 virtual void OnMouseMove(ID windowId, tachyon::int2 screenPos, MouseButtons button, KeyModifier modifiers) = 0;
424
426 virtual void OnMouseButton(ID windowId, tachyon::int2 screenPos, MouseButtons button, KeyModifier modifiers, MouseAction action) = 0;
427
429 virtual void OnMouseScroll(ID windowId, tachyon::int2 screenPos, tachyon::float2 scrollOffset, KeyModifier modifiers) = 0;
430
433 virtual void SwitchTextEditor(ID from, ID to) = 0;
434
436 virtual bool DoesTextEditorAcceptTabs(ID elementId) const = 0;
437
439 virtual bool IsTextEditor(ID elementId) const = 0;
440
442 virtual void RequestSelectAll(ID elementId) = 0;
443
446 virtual TextEditUpdate ConsumeTextEditUpdate(TextID textId, std::string& outText) = 0;
447
449 virtual bool UpdateText(TextID textId, std::string_view text) = 0;
450
452 virtual std::string Copy() = 0;
453
455 virtual std::string Cut() = 0;
456
458 virtual void Paste(std::string_view text) = 0;
459
461 virtual bool IsHoveringSelectedText(ID textEditorId, ID windowId, tachyon::int2 screenSpace) const = 0;
462
464 virtual bool TryGetTextDragCursor(ID windowId, tachyon::int2 screenSpace, MouseCursor& outCursor) const = 0;
465
468 virtual bool TryGetTextDragHoverTarget(ID windowId, tachyon::int2 screenSpace, ID& outTargetId) const = 0;
469
470 // -------------------- Cache Management --------------------
471
474 virtual void ClearCache() = 0;
475
476 // -------------------- Cursor Visibility --------------------
477
480 virtual void EnsureCursorVisible(ID textEditorId) = 0;
481
484 virtual std::optional<IntRect> GetCursorRect(ID textEditorId) = 0;
485
488 virtual std::optional<IntRect> GetCaretScreenRect() const = 0;
489 };
490
491} // namespace tachyon
Owns the per-frame state objects and runs their BeginFrame / EndFrame in order.
Definition gui_state_manager.h:65
A graphics backend: the device, the window contexts that render the GUI's windows,...
Definition gui_graphics_context.h:53
The clipboard text editors copy to and paste from, and images go through; GUIApplication::SetClipboar...
Definition gui_clipboard.h:29
Platform-level input interface: receives raw OS events (keyboard, mouse) and forwards them into the G...
Definition gui_platform_input_handler.h:25
Text and icon registration, measurement, rendering and editing.
Definition gui_text_system.h:189
virtual void SetLanguage(std::string_view languageTag)=0
The default language as a BCP 47 tag ("ja", "zh-Hant", "ko"), for text whose style has no language of...
virtual void OnMouseScroll(ID windowId, tachyon::int2 screenPos, tachyon::float2 scrollOffset, KeyModifier modifiers)=0
Mouse wheel input for text editors.
virtual std::optional< IntRect > GetCaretScreenRect() const =0
The active editor's caret in absolute screen coordinates (through any zoom/pan), to place the IME can...
virtual void OnMouseButton(ID windowId, tachyon::int2 screenPos, MouseButtons button, KeyModifier modifiers, MouseAction action)=0
Mouse buttons for text editors: caret placement, selection, drag-drop.
virtual TextID GetTextID(ID elementId) const =0
The TextID elementId registered this frame, or TextID::Invalid.
virtual void UnregisterIcon(IconID iconId)=0
Lets go of one registration of an icon from RegisterIconFromPixels.
virtual void SetTextColor(TextID textId, VisualColorStyleIndex color)=0
Draw a registered text in color instead of its style's text color, until it is registered again (call...
TextID RegisterText(ID elementId, std::string_view text, StyleRef styleIndex, ElementState state)
Definition gui_text_system.h:260
virtual int32_t GetTextHeightWithoutIcon(TextID textId) const =0
How high textId's text is unwrapped, in pixels, without the icon it was registered with (which its me...
virtual std::string * ValueEditText(ID elementId, bool &started)=0
The text the focused field elementId edits, kept while it has the focus (its value isn't formatted ag...
virtual IconID RegisterIconFromSVGFile(const char *path)=0
Registers an icon from an SVG file, named by its path.
virtual void SetCaretColor(VisualColorStyleIndex color)=0
The text caret's color (the theme's –caret). Set again after the style manager is cleared.
virtual TextID RegisterEditableRichText(ID elementId, const std::span< ContentRun > &contentRuns, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool &wasModified)=0
Registers rich text that renders like RegisterRichText but can also be selected and copied (the runs'...
virtual intptr_t HitTestContent(TextID textId, int32_t localX, int32_t localY) const =0
The contentId of the run at (localX, localY), element-local; 0 if none.
virtual TextMeasurement MeasureText(TextID textId, const TextWrapContext &wrapContext) const =0
The measurement of textId wrapped to wrapContext.maxWidth, in pixels.
virtual IconID RegisterIconFromSVG(const char *name, const char *svg_data, size_t svg_size)=0
Registers an icon from SVG data under a unique name.
virtual bool ReplayAtlasTouches(ID)
Definition gui_text_system.h:231
virtual void Paste(std::string_view text)=0
Inserts text into the active editor at the caret, replacing the selection.
virtual FontID RegisterFontFamily(std::string_view familyName, std::span< const FontFaceSource > faces)=0
Registers a font family from its faces (regular, bold, italic, ...); each face's weight and style com...
virtual void OnMouseMove(ID windowId, tachyon::int2 screenPos, MouseButtons button, KeyModifier modifiers)=0
Mouse movement for text selection and drag-drop.
virtual bool TryGetTextDragHoverTarget(ID windowId, tachyon::int2 screenSpace, ID &outTargetId) const =0
While text is dragged, sets outTargetId to the drop target under the cursor (ID::Invalid if none) and...
virtual void RequestSelectAll(ID elementId)=0
Selects all text of the editor elementId the next time it renders.
virtual bool TryGetTextDragCursor(ID windowId, tachyon::int2 screenSpace, MouseCursor &outCursor) const =0
The mouse cursor to show while text is dragged; true when it overrides the hover cursor.
virtual IconMeasurement MeasureIcon(IconID iconId) const =0
The natural size of iconId, in pixels.
virtual std::string Copy()=0
The active editor's selected text.
virtual TextMeasurement GetTextMeasurement(TextID textId) const =0
The unwrapped measurement of textId, in pixels; cached until its text or style changes.
virtual bool IsHoveringSelectedText(ID textEditorId, ID windowId, tachyon::int2 screenSpace) const =0
True when the screen point screenSpace is over selected text in textEditorId.
virtual void SetUndoHistory(class UndoHistory *history)=0
Where committed text edits go as undo steps (none: not recorded).
virtual IconID RegisterIconFromPixels(const char *name, uint2 size, std::span< const uint8_t > rgba)=0
Registers an icon from size.x x size.y RGBA pixels (straight alpha, rows from the top) under a unique...
TextID RegisterEditableNumber(ID elementId, T &value, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool &wasModified, NumericFieldConfig< T > config={})
Registers an editable number, clamped to config's [minVal, maxVal] after an edit, a float or double s...
Definition gui_text_system.h:297
virtual bool IsTextEditor(ID elementId) const =0
True when elementId registered editable text this frame.
virtual void Shutdown()=0
TextID RegisterEditableValue(ID elementId, T &value, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool &wasModified, const Converter &converter=DefaultTextConverter< T >())
Registers a field that edits value as text: converter formats it and parses the edits back (see TextC...
Definition gui_text_system.h:275
virtual TextID RegisterRichText(ID elementId, const std::span< ContentRun > &contentRuns, StyleRef styleIndex, ElementState state)=0
Registers text made of runs: styled text, inline icons and links.
virtual std::optional< IntRect > GetCursorRect(ID textEditorId)=0
Takes a pending EnsureCursorVisible request for textEditorId and returns the caret rect,...
virtual void OnKeyboard(ID windowId, KeyCode key, int repeat, KeyModifier modifiers, KeyAction action)=0
Keyboard input for the active text editor.
virtual ~ITextSystem()=default
virtual void SetHoveredContent(TextID textId, intptr_t contentId)=0
Sets the hovered run of textId (by contentId), drawn in its hover style; 0 for none.
virtual void BeginAtlasRecord(ID)
Records the glyph and icon atlas entries a cached scope's primitives use, until EndAtlasRecord.
Definition gui_text_system.h:229
virtual bool IsValidIcon(IconID iconId) const =0
True when iconId is a registered icon.
virtual void RenderText(TextID textId, IntRect rect, IntRect innerRect, IntRect clipRect, float pixelScale=1.f, const float3x2 &screenToLayout=float3x2::Identity())=0
Draws textId into rect (renderer space, window-local), clipped to clipRect.
virtual void BeginFrame(int2 screenMousePos, MouseButtons mouseButtons, uint32_t timeMs)=0
Starts a frame, before the UI is built: clears the per-frame editor registrations that this frame's R...
virtual std::optional< MouseCursor > LinkCursorAt(ID elementId, int32_t localX, int32_t localY) const =0
The cursor of the link at (localX, localY), element-local (its LinkStyle::cursor); none when there's ...
virtual IconMeasurement GetIconMeasurement(IconID iconId) const =0
The natural size of iconId, in pixels (same as MeasureIcon).
virtual void SwitchTextEditor(ID from, ID to)=0
The focused text field changed (GUIStateManager::TextEditorFocus): commit from (ID::Invalid if none) ...
virtual void Update()=0
virtual TextEditUpdate ConsumeTextEditUpdate(TextID textId, std::string &outText)=0
Takes the pending edit of textId: the edited text goes to outText, the result says whether it changed...
virtual TextID RegisterEditableText(ID elementId, std::string &text, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool &wasModified, const ITextValidator *validator=nullptr)=0
Registers text as editable by elementId; wasModified is set when an edit changed it.
virtual bool Initialize(GraphicsContext *graphicsContext, StyleManager *styleManager, TextAtlasManager *textAtlasManager, GUIStateManager *guiStateManager, IClipboard *clipboard)=0
virtual void ClearCache()=0
Drops every registered text and the live editor; earlier TextIDs become invalid.
virtual void SetFallbackFontDirectory(std::string_view directory)=0
Where the optional fallback fonts are: Noto, for other scripts, emoji and symbols.
virtual TextID RegisterText(ID elementId, IconID iconId, std::string_view text, StyleRef styleIndex, ElementState state)=0
Registers static text, with an optional icon, for elementId.
virtual bool DoesTextEditorAcceptTabs(ID elementId) const =0
True when the editor elementId inserts tabs (TextEditBehavior::AcceptTabs).
virtual bool UpdateText(TextID textId, std::string_view text)=0
Replaces the text of textId; true when it changed.
FontID RegisterFontFamily(std::string_view familyName, std::span< const std::string_view > faceFiles)
Definition gui_text_system.h:247
virtual void RenderIcon(IconID iconId, IntRect rect, IntRect clipRect, VisualColorStyleIndex tint, std::span< const VisualShadow > shadows={})=0
Draws iconId fitted into rect (aspect kept, centered), clipped to clipRect.
virtual std::string_view GetText(TextID textId) const =0
The text registered as textId.
virtual void EndAtlasRecord()
Definition gui_text_system.h:230
virtual void SetFontDirectory(std::string_view directory)=0
Where the built-in fonts are (default "fonts", relative to the working directory): Inter for text and...
virtual void EnsureCursorVisible(ID textEditorId)=0
Asks for the caret of textEditorId to be scrolled into view; editor input calls it when the caret mov...
virtual std::string Cut()=0
Removes the active editor's selected text and returns it.
What an editable field takes as text, asked while it is edited.
Definition gui_text_converter.h:22
Scroll containers' offsets (pixels), kept across frames by ID behind handles.
Definition gui_scroll_management.h:33
Bakes serializable Styles into deduplicated runtime layout/visual styles; a StyleRef holds indices in...
Definition gui_style_manager.h:39
Definition gui_text_atlas_manager.h:17
One text decoration line (underline, overline, ...).
Definition gui_style_text.h:232
uint64_t GetHashCode() const noexcept
What text is measured and laid out from: font, metrics and decoration lines.
Definition gui_style_text.h:260
uint64_t GetHashCode() const noexcept
The app's undo history: steps that each undo and redo one change.
Definition gui_undo_history.h:20
ElementFlags
What an element is and how it behaves, combined with |.
Definition gui_element_flags.h:17
@ None
Definition gui_element_flags.h:18
KeyCode
Keys by what the keyboard layout makes them, not by position.
Definition gui_input_enums.h:106
KeyAction
A keyboard event: a key down or up, or a typed character (KeyChar).
Definition gui_input_enums.h:50
KeyModifier
Modifier keys held, combined with |.
Definition gui_input_enums.h:26
MouseButtons
Mouse buttons, combined with |.
Definition gui_input_enums.h:38
MouseAction
Whether a mouse button went down or up.
Definition gui_input_enums.h:58
MouseCursor
Mouse cursor shown over an element (CSS: cursor).
Definition gui_style.h:481
VisualColorStyleIndex
Index into StyleManager's color style pool; Invalid (0) draws nothing (transparent).
Definition gui_style.h:33
FontID
Handle for a font family registered with ITextSystem::RegisterFontFamily().
Definition gui_style_text.h:20
TextID
Handle for text registered with the text system (ITextSystem::RegisterText and friends).
Definition gui_style_text.h:13
IconID
Handle for an icon registered with ITextSystem::RegisterIconFromSVG / RegisterIconFromSVGFile.
Definition gui_style_text.h:15
ElementState
Interaction state bits of an element; they pick the Style::states variant it draws with.
Definition gui_style.h:42
@ Pointer
Pointing hand for clickable items.
Definition gui_style.h:486
@ Invalid
Definition gui_style_text.h:15
const TextConverter< T > & DefaultTextConverter()
The converter a field uses for T when it is given none.
Definition gui_text_converter.h:90
TextEditBehavior
Definition gui_text_system.h:98
const TextConverter< T > & FixedDecimalsConverter(int decimals)
The converter that shows a float or double with decimals digits after the point (0 to 9; less shows a...
Definition gui_text_converter.h:100
@ ReadOnly
selectable and copyable, but not editable
Definition gui_text_system.h:103
@ Multiline
Enter inserts a newline instead of committing.
Definition gui_text_system.h:101
@ ContinuousUpdate
update the text on every keystroke, not only on commit
Definition gui_text_system.h:100
@ AcceptTabs
Tab inserts a tab character instead of moving focus.
Definition gui_text_system.h:102
#define TACHYON_ENUM_OPERATORS(EnumType)
Definition gui_enum_operators.h:8
uint64_t Calculate(std::string_view str)
FNV-1a hash of str; same result as CalculateConst.
Definition gui_hash.h:29
constexpr uint64_t Combine(uint64_t a, uint64_t b)
Order-dependent combine; repeated values don't cancel out.
Definition gui_hash.h:65
Definition gui_logging.h:24
One run of rich text: a piece of text or an inline icon.
Definition gui_text_system.h:127
Type
Definition gui_text_system.h:130
@ Icon
Definition gui_text_system.h:130
@ Text
Definition gui_text_system.h:130
const TextStyle * textStyleOverride
Text style of this run in place of the element's (font, size, weight, ...); null uses the element's.
Definition gui_text_system.h:145
float iconWidth
CSS px, or kSizeAuto.
Definition gui_text_system.h:136
std::string_view text
Text runs.
Definition gui_text_system.h:133
LinkStyle linkStyle
Definition gui_text_system.h:141
color4b color
This run's text color in place of the element's (bold text in a brighter one, say); alpha 0 keeps the...
Definition gui_text_system.h:150
Type type
Definition gui_text_system.h:131
uint64_t GetHashCode() const
Definition gui_text_system.h:152
static constexpr float kSizeAuto
size the icon automatically
Definition gui_text_system.h:128
IconID iconID
Icon runs.
Definition gui_text_system.h:134
float iconHeight
CSS px, or kSizeAuto.
Definition gui_text_system.h:137
intptr_t contentId
non-zero makes the run hittable (HitTestContent returns it)
Definition gui_text_system.h:139
bool isLink
drawn as a link: underlined, in linkStyle's colors
Definition gui_text_system.h:140
color4b background
A box under this run, in this color (inline code on a well, say); alpha 0 is none.
Definition gui_text_system.h:147
One face of a font family: a font file, or font data in memory that stays valid while the family is r...
Definition gui_text_system.h:32
std::span< const std::byte > data
Definition gui_text_system.h:34
std::string_view file
Definition gui_text_system.h:33
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
Definition gui_text_system.h:194
bool textChanged
Definition gui_text_system.h:195
constexpr bool HasUpdate() const
Definition gui_text_system.h:198
bool textCommitted
Definition gui_text_system.h:196
Definition gui_text_system.h:53
constexpr bool IsEmpty() const
Definition gui_text_system.h:58
int32_t width
Definition gui_text_system.h:54
int32_t height
Definition gui_text_system.h:55
constexpr int2 Size() const
Definition gui_text_system.h:57
Definition gui_base_types.h:406
Colors of a link run, normal and hovered.
Definition gui_text_system.h:114
color4b color
Definition gui_text_system.h:115
color4b hoverColor
Definition gui_text_system.h:116
bool operator==(const LinkStyle &) const noexcept=default
TextDecoration underline
Its underline at rest, in CSS px: thickness, offset under the text, solid or dotted.
Definition gui_text_system.h:120
MouseCursor cursor
over the link
Definition gui_text_system.h:117
Drag speed and range of a numeric Field, specialized per value type.
Definition gui_numeric_field_config.h:54
A registered style, as StyleManager::Register returns it: indices into the shared style pools,...
Definition gui_style_ref.h:25
Definition gui_text_system.h:65
constexpr int2 MinSize() const
Definition gui_text_system.h:73
constexpr int2 MaxSize() const
Definition gui_text_system.h:74
int32_t maxWidth
max-content width: the widest line without wrapping
Definition gui_text_system.h:69
constexpr bool IsEmpty() const
Definition gui_text_system.h:75
int32_t minWidth
min-content width: widest unbreakable run; maxWidth when it can't wrap
Definition gui_text_system.h:68
static constexpr int32_t kUnbounded
Definition gui_text_system.h:66
int32_t minHeight
height of the text laid out at maxWidth
Definition gui_text_system.h:70
int32_t maxHeight
same as minHeight
Definition gui_text_system.h:71
Definition gui_text_system.h:83
uint32_t maxLines
Definition gui_text_system.h:86
int32_t maxWidth
Definition gui_text_system.h:84
bool operator==(const TextWrapContext &) const =default
uint64_t GetHashCode() const
Definition gui_text_system.h:90
int32_t maxHeight
Definition gui_text_system.h:85
Definition gui_base_types.h:383
byte a
Definition gui_base_types.h:384
Definition gui_base_types.h:120
2D affine transform matrix (2 rows x 3 columns): x' = r0.x*x + r0.y*y + r0.z y' = r1....
Definition gui_base_types.h:218
static constexpr float3x2 Identity()
Definition gui_base_types.h:227
Integer 2D vector.
Definition gui_base_types.h:18
Definition gui_base_types.h:74