TachyonUI 0.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
10
12
15
16#include <bit>
17#include <cstddef>
18#include <stdint.h>
19#include <optional>
20#include <span>
21#include <string>
22#include <string_view>
23#include <vector>
24
25namespace tachyon
26{
29
33 {
34 std::string_view file;
35 std::span<const std::byte> data;
36 };
37
38 // Forward declarations
39 class GraphicsContext;
40 class GUIStateManager;
41 class IClipboard;
42 class StyleManager;
43 class ScrollManagement;
44 class TextAtlasManager;
45 enum class KeyAction : uint8_t;
46 enum class MouseAction : uint8_t;
47 enum class ElementFlags : uint32_t;
48
49 // ------------------------------------------------------------------------
50 // Icon Measurement Result
51 // ------------------------------------------------------------------------
52
54 {
55 int32_t width = 0;
56 int32_t height = 0;
57
58 constexpr int2 Size() const { return int2{ width, height }; }
59 constexpr bool IsEmpty() const { return width == 0 && height == 0; }
60 };
61
62 // ------------------------------------------------------------------------
63 // Text Measurement Result
64 // ------------------------------------------------------------------------
66 {
67 static constexpr int32_t kUnbounded = std::numeric_limits<int32_t>::max();
68
69 int32_t minWidth = 0;
70 int32_t maxWidth = 0;
71 int32_t minHeight = 0;
72 int32_t maxHeight = 0;
73
74 constexpr int2 MinSize() const { return int2{ minWidth, minHeight }; }
75 constexpr int2 MaxSize() const { return int2{ maxWidth, maxHeight }; }
76 constexpr bool IsEmpty() const { return maxWidth == 0 && maxHeight == 0; }
77 };
78
79 // ------------------------------------------------------------------------
80 // Text Wrap Context - Constraints for text measurement
81 // ------------------------------------------------------------------------
82
84 {
85 int32_t maxWidth = INT32_MAX;
86 int32_t maxHeight = INT32_MAX;
87 uint32_t maxLines = UINT32_MAX;
88
89 bool operator==(const TextWrapContext&) const = default;
90
91 inline uint64_t GetHashCode() const { return Hash::Calculate(*this); }
92 };
93
94 // ------------------------------------------------------------------------
95 // Text Editing Behavior
96 // ------------------------------------------------------------------------
97
98 enum class TextEditBehavior : uint8_t
99 {
100 None = 0,
102 Multiline = 1 << 1,
103 AcceptTabs = 1 << 2,
104 ReadOnly = 1 << 3
105 };
107
108
109 // ----------------------------------------------------------------------------------
110 // ContentRun - Represents a run of either text or an icon for rich text registration
111 // ----------------------------------------------------------------------------------
112
113
115 {
116 color4b color { 64, 148, 255, 255 };
117 color4b hoverColor { 128, 200, 255, 255 };
119
120 bool operator==(const LinkStyle&) const noexcept = default;
121 };
122
125 {
126 static constexpr float kSizeAuto = -1.0f;
127
128 enum Type { Text, Icon };
130
131 std::string_view text;
133
136
137 intptr_t contentId = 0;
138 bool isLink = false;
140
143 const TextStyle* textStyleOverride = nullptr;
144
145 uint64_t GetHashCode() const
146 {
147 uint64_t hash = Hash::Calculate(type);
148 if (type == Text)
149 {
150 hash = Hash::Combine(hash, Hash::Calculate(text));
151 } else
152 {
153 if (iconID == IconID::Invalid)
154 {
155 hash = Hash::Combine(hash, ((uint32_t)iconID), 0, 0);
156 } else
157 {
158 hash = Hash::Combine(hash, ((uint32_t)iconID), std::bit_cast<uint32_t>(iconWidth), std::bit_cast<uint32_t>(iconHeight));
159 }
160 }
161 hash = Hash::Combine(hash, static_cast<uint64_t>(contentId), isLink ? 1u : 0u);
162 if (isLink)
167 return hash;
168 }
169 };
170
171
172 // ------------------------------------------------------------------------
173 // Abstract Text System Interface
174 // ------------------------------------------------------------------------
175
178 {
179 public:
180 virtual ~ITextSystem() = default;
181
183 {
184 bool textChanged = false;
185 bool textCommitted = false;
186
187 constexpr bool HasUpdate() const
188 {
189 return textChanged || textCommitted;
190 }
191 };
192
193 // -------------------- Initialization --------------------
194
198 virtual void SetFontDirectory(std::string_view directory) = 0;
199
203 virtual void SetFallbackFontDirectory(std::string_view directory) = 0;
204
205 virtual bool Initialize(GraphicsContext* graphicsContext, StyleManager* styleManager,
206 TextAtlasManager* textAtlasManager,
207 GUIStateManager* guiStateManager, IClipboard* clipboard) = 0;
208 virtual void Shutdown() = 0;
209 virtual void Update() = 0;
210
213 virtual void BeginFrame(int2 screenMousePos, MouseButtons mouseButtons, uint32_t timeMs) = 0;
214
218 virtual void BeginAtlasRecord(ID /*scopeId*/) {}
219 virtual void EndAtlasRecord() {}
220 virtual bool ReplayAtlasTouches(ID /*scopeId*/) { return true; }
221
222 // -------------------- Font Registration --------------------
223
228 virtual void SetLanguage(std::string_view languageTag) = 0;
229
235 virtual FontID RegisterFontFamily(std::string_view familyName, std::span<const FontFaceSource> faces) = 0;
236 FontID RegisterFontFamily(std::string_view familyName, std::span<const std::string_view> faceFiles)
237 {
238 std::vector<FontFaceSource> faces;
239 faces.reserve(faceFiles.size());
240 for (std::string_view file : faceFiles)
241 faces.push_back(FontFaceSource{ .file = file });
242 return RegisterFontFamily(familyName, faces);
243 }
244
245 // -------------------- Text Registration --------------------
246
248 virtual TextID RegisterText(ID elementId, IconID iconId, std::string_view text, StyleRef styleIndex, ElementState state) = 0;
249 TextID RegisterText(ID elementId, std::string_view text, StyleRef styleIndex, ElementState state) { return RegisterText(elementId, IconID::Invalid, text, styleIndex, state); }
250
253 virtual TextID RegisterEditableText(ID elementId, std::string& text, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool& wasModified,
254 const ITextValidator* validator = nullptr) = 0;
255
259 virtual std::string* ValueEditText(ID elementId, bool& started) = 0;
260
263 template<typename T, typename Converter = TextConverter<T>>
264 TextID RegisterEditableValue(ID elementId, T& value, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool& wasModified,
265 const Converter& converter = DefaultTextConverter<T>())
266 {
267 bool started = false;
268 std::string* editText = ValueEditText(elementId, started);
269 std::string shownText;
270 if (editText == nullptr)
271 shownText = converter.Format(value, /*editing*/ false);
272 else if (started)
273 *editText = converter.Format(value, /*editing*/ true);
274 std::string& text = editText ? *editText : shownText;
275
276 bool edited = false;
277 const TextID textId = RegisterEditableText(elementId, text, behavior, styleIndex, state, edited, &converter);
278 if (edited && converter.Parse(text, value))
279 wasModified = true;
280 return textId;
281 }
282
284 template<typename T>
285 TextID RegisterEditableNumber(ID elementId, T& value, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool& wasModified, NumericFieldConfig<T> config = {})
286 {
287 bool edited = false;
288 const TextID textId = RegisterEditableValue(elementId, value, behavior, styleIndex, state, edited);
289 if (edited)
290 {
291 wasModified = true;
292 value = std::clamp(value, config.minVal, config.maxVal);
293 }
294 return textId;
295 }
296
299 virtual void SetTextColor(TextID textId, VisualColorStyleIndex color) = 0;
300
302 virtual void SetCaretColor(VisualColorStyleIndex color) = 0;
304 virtual void SetUndoHistory(class UndoHistory* history) = 0;
305
307 virtual std::string_view GetText(TextID textId) const = 0;
308
309
311 virtual TextID RegisterRichText(ID elementId, const std::span<ContentRun>& contentRuns,
312 StyleRef styleIndex, ElementState state) = 0;
313
316 virtual TextID RegisterEditableRichText(ID elementId, const std::span<ContentRun>& contentRuns,
317 TextEditBehavior behavior, StyleRef styleIndex,
318 ElementState state, bool& wasModified) = 0;
319
322 virtual TextID GetTextID(ID elementId) const = 0;
323
324 // -------------------- Text Measurement (for layout) --------------------
325
327 virtual TextMeasurement GetTextMeasurement(TextID textId) const = 0;
328
330 virtual TextMeasurement MeasureText(TextID textId, const TextWrapContext& wrapContext) const = 0;
331
334 virtual int32_t GetTextHeightWithoutIcon(TextID textId) const = 0;
335
336 // -------------------- Text Rendering --------------------
337
343 virtual void RenderText(TextID textId, IntRect rect, IntRect innerRect, IntRect clipRect, float pixelScale = 1.f,
344 const float3x2& screenToLayout = float3x2::Identity()) = 0;
345
348 virtual std::optional<MouseCursor> LinkCursorAt(ID elementId, int32_t localX, int32_t localY) const = 0;
349
351 virtual intptr_t HitTestContent(TextID textId, int32_t localX, int32_t localY) const = 0;
352
354 virtual void SetHoveredContent(TextID textId, intptr_t contentId) = 0;
355
356
357
358 // -------------------- Icon Measurement --------------------
359
361 virtual IconMeasurement GetIconMeasurement(IconID iconId) const = 0;
362
364 virtual IconMeasurement MeasureIcon(IconID iconId) const = 0;
365
366 // -------------------- Icon Registration --------------------
367
369 virtual bool IsValidIcon(IconID iconId) const = 0;
370
373 virtual IconID RegisterIconFromSVG(const char* name, const char* svg_data, size_t svg_size) = 0;
374
377 virtual IconID RegisterIconFromSVGFile(const char* path) = 0;
378
383 virtual IconID RegisterIconFromPixels(const char* name, uint2 size, std::span<const uint8_t> rgba) = 0;
384
388 virtual void UnregisterIcon(IconID iconId) = 0;
389
390 // -------------------- Icon Rendering --------------------
391
395 virtual void RenderIcon(IconID iconId, IntRect rect, IntRect clipRect, VisualColorStyleIndex tint,
396 std::span<const VisualShadow> shadows = {}) = 0;
397
398
399
400 // -------------------- Editor Input Handling --------------------
402 virtual void OnKeyboard(ID windowId, KeyCode key, int repeat, KeyModifier modifiers, KeyAction action) = 0;
403
405 virtual void OnMouseMove(ID windowId, tachyon::int2 screenPos, MouseButtons button, KeyModifier modifiers) = 0;
406
408 virtual void OnMouseButton(ID windowId, tachyon::int2 screenPos, MouseButtons button, KeyModifier modifiers, MouseAction action) = 0;
409
411 virtual void OnMouseScroll(ID windowId, tachyon::int2 screenPos, tachyon::float2 scrollOffset, KeyModifier modifiers) = 0;
412
415 virtual void SwitchTextEditor(ID from, ID to) = 0;
416
418 virtual bool DoesTextEditorAcceptTabs(ID elementId) const = 0;
419
421 virtual bool IsTextEditor(ID elementId) const = 0;
422
424 virtual void RequestSelectAll(ID elementId) = 0;
425
428 virtual TextEditUpdate ConsumeTextEditUpdate(TextID textId, std::string& outText) = 0;
429
431 virtual bool UpdateText(TextID textId, std::string_view text) = 0;
432
434 virtual std::string Copy() = 0;
435
437 virtual std::string Cut() = 0;
438
440 virtual void Paste(std::string_view text) = 0;
441
443 virtual bool IsHoveringSelectedText(ID textEditorId, ID windowId, tachyon::int2 screenSpace) const = 0;
444
446 virtual bool TryGetTextDragCursor(ID windowId, tachyon::int2 screenSpace, MouseCursor& outCursor) const = 0;
447
450 virtual bool TryGetTextDragHoverTarget(ID windowId, tachyon::int2 screenSpace, ID& outTargetId) const = 0;
451
452 // -------------------- Cache Management --------------------
453
456 virtual void ClearCache() = 0;
457
458 // -------------------- Cursor Visibility --------------------
459
462 virtual void EnsureCursorVisible(ID textEditorId) = 0;
463
466 virtual std::optional<IntRect> GetCursorRect(ID textEditorId) = 0;
467
470 virtual std::optional<IntRect> GetCaretScreenRect() const = 0;
471 };
472
473} // 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:60
The clipboard text editors copy to and paste from; GUIApplication::SetClipboard sets one (default: SD...
Definition gui_clipboard.h:14
Platform-level input interface: receives raw OS events (keyboard, mouse) and forwards them into the G...
Definition gui_platform_input_handler.h:24
Text and icon registration, measurement, rendering and editing.
Definition gui_text_system.h:178
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 an icon from RegisterIconFromPixels: its image slot is freed, the ID draws nothing from th...
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:249
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:220
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.
Definition gui_text_system.h:285
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:264
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:218
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:236
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:219
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:19
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
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:18
ElementFlags
What an element is and how it behaves, combined with |.
Definition gui_element_flags.h:18
@ None
Definition gui_element_flags.h:19
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:478
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:483
@ 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:74
TextEditBehavior
Definition gui_text_system.h:99
@ ReadOnly
selectable and copyable, but not editable
Definition gui_text_system.h:104
@ Multiline
Enter inserts a newline instead of committing.
Definition gui_text_system.h:102
@ ContinuousUpdate
update the text on every keystroke, not only on commit
Definition gui_text_system.h:101
@ AcceptTabs
Tab inserts a tab character instead of moving focus.
Definition gui_text_system.h:103
#define TACHYON_ENUM_OPERATORS(EnumType)
Definition gui_enum_operators.h:6
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:125
Type
Definition gui_text_system.h:128
@ Icon
Definition gui_text_system.h:128
@ Text
Definition gui_text_system.h:128
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:143
float iconWidth
CSS px, or kSizeAuto.
Definition gui_text_system.h:134
std::string_view text
Text runs.
Definition gui_text_system.h:131
LinkStyle linkStyle
Definition gui_text_system.h:139
Type type
Definition gui_text_system.h:129
uint64_t GetHashCode() const
Definition gui_text_system.h:145
static constexpr float kSizeAuto
size the icon automatically
Definition gui_text_system.h:126
IconID iconID
Icon runs.
Definition gui_text_system.h:132
float iconHeight
CSS px, or kSizeAuto.
Definition gui_text_system.h:135
intptr_t contentId
non-zero makes the run hittable (HitTestContent returns it)
Definition gui_text_system.h:137
bool isLink
drawn as a link: underlined, in linkStyle's colors
Definition gui_text_system.h:138
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:33
std::span< const std::byte > data
Definition gui_text_system.h:35
std::string_view file
Definition gui_text_system.h:34
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
Definition gui_text_system.h:183
bool textChanged
Definition gui_text_system.h:184
constexpr bool HasUpdate() const
Definition gui_text_system.h:187
bool textCommitted
Definition gui_text_system.h:185
Definition gui_text_system.h:54
constexpr bool IsEmpty() const
Definition gui_text_system.h:59
int32_t width
Definition gui_text_system.h:55
int32_t height
Definition gui_text_system.h:56
constexpr int2 Size() const
Definition gui_text_system.h:58
Definition gui_base_types.h:407
Colors of a link run, normal and hovered.
Definition gui_text_system.h:115
color4b color
Definition gui_text_system.h:116
color4b hoverColor
Definition gui_text_system.h:117
bool operator==(const LinkStyle &) const noexcept=default
MouseCursor cursor
over the link
Definition gui_text_system.h:118
Drag speed and range of a numeric Field, specialized per value type.
Definition gui_numeric_field_config.h:19
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:66
constexpr int2 MinSize() const
Definition gui_text_system.h:74
constexpr int2 MaxSize() const
Definition gui_text_system.h:75
int32_t maxWidth
max-content width: the widest line without wrapping
Definition gui_text_system.h:70
constexpr bool IsEmpty() const
Definition gui_text_system.h:76
int32_t minWidth
min-content width: widest unbreakable run; maxWidth when it can't wrap
Definition gui_text_system.h:69
static constexpr int32_t kUnbounded
Definition gui_text_system.h:67
int32_t minHeight
height of the text laid out at maxWidth
Definition gui_text_system.h:71
int32_t maxHeight
same as minHeight
Definition gui_text_system.h:72
Definition gui_text_system.h:84
uint32_t maxLines
Definition gui_text_system.h:87
int32_t maxWidth
Definition gui_text_system.h:85
bool operator==(const TextWrapContext &) const =default
uint64_t GetHashCode() const
Definition gui_text_system.h:91
int32_t maxHeight
Definition gui_text_system.h:86
Definition gui_base_types.h:384
Definition gui_base_types.h:121
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:219
static constexpr float3x2 Identity()
Definition gui_base_types.h:228
Integer 2D vector.
Definition gui_base_types.h:19
Definition gui_base_types.h:75