|
TachyonUI 0.1.0
High-performance UI for building tools.
|
Skribidi-based implementation of ITextSystem. More...
#include <gui_core/text/skribidi/gui_text_system_skribidi.h>
Public Member Functions | |
| SkribidiTextSystem () | |
| ~SkribidiTextSystem () override | |
| bool | Initialize (GraphicsContext *graphicsContext, StyleManager *styleManager, TextAtlasManager *textAtlasManager, GUIStateManager *guiStateManager, IClipboard *clipboard) override |
| void | Shutdown () override |
| void | Update () override |
| void | BeginFrame (int2 screenMousePos, MouseButtons mouseButtons, uint32_t timeMs) override |
| Starts a frame, before the UI is built: clears the per-frame editor registrations that this frame's RegisterEditableText calls fill again. | |
| void | BeginAtlasRecord (ID scopeId) override |
| Records the glyph and icon atlas entries a cached scope's primitives use, until EndAtlasRecord. | |
| void | EndAtlasRecord () override |
| bool | ReplayAtlasTouches (ID scopeId) override |
| void | OnKeyboard (ID windowId, KeyCode key, int repeat, KeyModifier modifiers, KeyAction action) override |
| Keyboard input for the active text editor. | |
| void | OnMouseMove (ID windowId, int2 screenPos, MouseButtons button, KeyModifier modifiers) override |
| Mouse movement for text selection and drag-drop. | |
| void | OnMouseButton (ID windowId, int2 screenPos, MouseButtons button, KeyModifier modifiers, MouseAction action) override |
| Mouse buttons for text editors: caret placement, selection, drag-drop. | |
| void | OnMouseScroll (ID windowId, int2 screenPos, float2 scrollOffset, KeyModifier modifiers) override |
| Mouse wheel input for text editors. | |
| void | OnTextComposition (ID windowId, std::string_view text, int32_t cursor) override |
| IME composition (pre-edit) text, UTF-8, shown but not yet committed; empty when composing ends. | |
| void | SwitchTextEditor (ID from, ID to) override |
| The focused text field changed (GUIStateManager::TextEditorFocus): commit from (ID::Invalid if none) and move the editor to to (ID::Invalid: no editor). | |
| void | SetUndoHistory (UndoHistory *history) override |
| Where committed text edits go as undo steps (none: not recorded). | |
| ID | ActiveElementID () const |
| The field the editor holds: the text focus as of the last switch. | |
| bool | DoesTextEditorAcceptTabs (ID elementId) const override |
| True when the editor elementId inserts tabs (TextEditBehavior::AcceptTabs). | |
| bool | IsTextEditor (ID elementId) const override |
| True when elementId registered editable text this frame. | |
| void | RequestSelectAll (ID elementId) override |
| Selects all text of the editor elementId the next time it renders. | |
| TextEditUpdate | ConsumeTextEditUpdate (TextID textId, std::string &outText) override |
| Takes the pending edit of textId: the edited text goes to outText, the result says whether it changed or was committed. | |
| bool | UpdateText (TextID textId, std::string_view text) override |
| Replaces the text of textId; true when it changed. | |
| std::string | Copy () override |
| The active editor's selected text. | |
| std::string | Cut () override |
| Removes the active editor's selected text and returns it. | |
| void | Paste (std::string_view text) override |
| Inserts Text into the active editor at the caret, replacing the selection. | |
| bool | IsHoveringSelectedText (ID textEditorId, ID windowId, tachyon::int2 screenSpace) const override |
| True when the screen point screenSpace is over selected text in textEditorId. | |
| bool | TryGetTextDragCursor (ID windowId, tachyon::int2 screenSpace, MouseCursor &outCursor) const override |
| The mouse cursor to show while text is dragged; true when it overrides the hover cursor. | |
| bool | TryGetTextDragHoverTarget (ID windowId, tachyon::int2 screenSpace, ID &outTargetId) const override |
| While text is dragged, sets outTargetId to the drop target under the cursor (ID::Invalid if none) and returns true. | |
| void | ClearCache () override |
| Drops every registered text and the live editor; earlier TextIDs become invalid. | |
| size_t | RegisteredTextCount () const |
| Number of registered texts held, for diagnostics. | |
| uint64_t | LayoutsMade () const |
| Number of text layouts made so far, for diagnostics. | |
| void | EnsureCursorVisible (ID textEditorId) override |
| Asks for the caret of textEditorId to be scrolled into view; editor input calls it when the caret moves. | |
| std::optional< IntRect > | GetCursorRect (ID textEditorId) override |
| Takes a pending EnsureCursorVisible request for textEditorId and returns the caret rect, relative to the editor's inner rect. | |
| std::optional< IntRect > | GetCaretScreenRect () const override |
| The active editor's caret in absolute screen coordinates (through any zoom/pan), to place the IME candidate window. | |
| TextID | RegisterEditableText (ID elementId, std::string &text, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool &wasModified, const ITextValidator *validator=nullptr) override |
| Registers Text as editable by elementId; wasModified is set when an edit changed it. | |
| std::string * | ValueEditText (ID elementId, bool &started) override |
| The text the focused field elementId edits, kept while it has the focus (its value isn't formatted again under the typing); null when it doesn't have it. | |
| void | SetTextColor (TextID textId, VisualColorStyleIndex color) override |
| Draw a registered text in color instead of its style's text color, until it is registered again (call after each registration, e.g. | |
| void | SetCaretColor (VisualColorStyleIndex color) override |
| The text caret's color (the theme's –caret). Set again after the style manager is cleared. | |
| void | SetFontDirectory (std::string_view directory) override |
| Where the built-in fonts are (default "fonts", relative to the working directory): Inter for text and JetBrains Mono for monospace. | |
| void | SetFallbackFontDirectory (std::string_view directory) override |
| Where the optional fallback fonts are: Noto, for other scripts, emoji and symbols. | |
| void | SetLanguage (std::string_view languageTag) override |
| The default language as a BCP 47 tag ("ja", "zh-Hant", "ko"), for text whose style has no language of its own (TextStyle::language / -tachyon-language). | |
| FontID | RegisterFontFamily (std::string_view familyName, std::span< const FontFaceSource > faces) override |
| Registers a font family from its faces (regular, bold, italic, ...); each face's weight and style come from the file. | |
| TextID | RegisterText (ID elementId, IconID iconId, std::string_view text, StyleRef styleIndex, ElementState state) override |
| Registers static text, with an optional icon, for elementId. | |
| TextID | RegisterRichText (ID elementId, const std::span< ContentRun > &contentRuns, StyleRef styleIndex, ElementState state) override |
| Registers text made of runs: styled text, inline icons and links. | |
| TextID | RegisterEditableRichText (ID elementId, const std::span< ContentRun > &contentRuns, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool &wasModified) override |
| Registers rich text that renders like RegisterRichText but can also be selected and copied (the runs' text joined). | |
| TextID | GetTextID (ID elementId) const override |
| The TextID elementId registered this frame, or TextID::Invalid. | |
| std::string_view | GetText (TextID textId) const override |
| The text registered as textId. | |
| TextMeasurement | GetTextMeasurement (TextID textId) const override |
| The unwrapped measurement of textId, in pixels; cached until its text or style changes. | |
| int32_t | GetTextHeightWithoutIcon (TextID textId) const override |
| How high textId's text is unwrapped, in pixels, without the icon it was registered with (which its measurement has in it). | |
| TextMeasurement | MeasureText (TextID textId, const TextWrapContext &wrapContext) const override |
| The measurement of textId wrapped to wrapContext.maxWidth, in pixels. | |
| void | RenderText (TextID textId, IntRect rect, IntRect innerRect, IntRect clipRect, float pixelScale=1.f, const float3x2 &screenToLayout=float3x2::Identity()) override |
| Draws textId into rect (renderer space, window-local), clipped to clipRect. | |
| std::optional< MouseCursor > | LinkCursorAt (ID elementId, int32_t localX, int32_t localY) const override |
| The cursor of the link at (localX, localY), element-local (its LinkStyle::cursor); none when there's no link there. | |
| intptr_t | HitTestContent (TextID textId, int32_t localX, int32_t localY) const override |
| The contentId of the run at (localX, localY), element-local; 0 if none. | |
| void | SetHoveredContent (TextID textId, intptr_t contentId) override |
| Sets the hovered run of textId (by contentId), drawn in its hover style; 0 for none. | |
| bool | IsValidIcon (IconID iconId) const override |
| True when iconId is a registered icon. | |
| IconID | RegisterIconFromSVG (const char *name, const char *svg_data, size_t svg_size) override |
| Registers an icon from SVG data under a unique name. | |
| IconID | RegisterIconFromSVGFile (const char *path) override |
| Registers an icon from an SVG file, named by its path. | |
| IconID | RegisterIconFromPixels (const char *name, uint2 size, std::span< const uint8_t > rgba) override |
| Registers an icon from size.x x size.y RGBA pixels (straight alpha, rows from the top) under a unique name: a picture in its own colors, drawn untinted. | |
| void | UnregisterIcon (IconID iconId) override |
| Lets go of an icon from RegisterIconFromPixels: its image slot is freed, the ID draws nothing from then on and isn't given out again, and its name can be registered anew. | |
| IconMeasurement | GetIconMeasurement (IconID iconId) const override |
| The natural size of iconId, in pixels (same as MeasureIcon). | |
| IconMeasurement | MeasureIcon (IconID iconId) const override |
| The natural size of iconId, in pixels. | |
| void | RenderIcon (IconID iconId, IntRect rect, IntRect clipRect, VisualColorStyleIndex tint, std::span< const VisualShadow > shadows={}) override |
| Draws iconId fitted into rect (aspect kept, centered), clipped to clipRect. | |
| FontID | RegisterFontFamily (std::string_view familyName, std::span< const std::string_view > faceFiles) |
| Public Member Functions inherited from tachyon::ITextSystem | |
| virtual | ~ITextSystem ()=default |
| FontID | RegisterFontFamily (std::string_view familyName, std::span< const std::string_view > faceFiles) |
| TextID | RegisterText (ID elementId, std::string_view text, StyleRef styleIndex, ElementState state) |
| template<typename T, typename Converter = TextConverter<T>> | |
| 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 TextConverter). | |
| template<typename T> | |
| 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. | |
| Public Member Functions inherited from tachyon::IPlatformInputHandler | |
| virtual | ~IPlatformInputHandler ()=default |
| virtual void | OnFileDrop (tachyon::ID, tachyon::int2, FileDropAction, std::string_view) |
| A drag from another application over window id: it came, moved to screenPos (screen pixels), dropped a file or text (data), or ended (dropped, or left the window). | |
Static Public Member Functions | |
| static void | ScreenToTextEditorLocalPoint (tachyon::int2 screenSpace, const IntRect &textEditorInnerRect, tachyon::float2 &outLocal, const float3x2 &screenToLayout=float3x2::Identity()) |
Skribidi-based implementation of ITextSystem.
| tachyon::SkribidiTextSystem::SkribidiTextSystem | ( | ) |
|
override |
|
overridevirtual |
Implements tachyon::ITextSystem.
|
overridevirtual |
Implements tachyon::ITextSystem.
|
overridevirtual |
Implements tachyon::ITextSystem.
|
overridevirtual |
Starts a frame, before the UI is built: clears the per-frame editor registrations that this frame's RegisterEditableText calls fill again.
Implements tachyon::ITextSystem.
|
overridevirtual |
Records the glyph and icon atlas entries a cached scope's primitives use, until EndAtlasRecord.
ReplayAtlasTouches keeps them alive on each frame the cached pixels are reused, and returns false when one was evicted or moved: the scope must render again.
Reimplemented from tachyon::ITextSystem.
|
overridevirtual |
Reimplemented from tachyon::ITextSystem.
|
overridevirtual |
Reimplemented from tachyon::ITextSystem.
|
overridevirtual |
Keyboard input for the active text editor.
Implements tachyon::ITextSystem.
|
overridevirtual |
Mouse movement for text selection and drag-drop.
Implements tachyon::ITextSystem.
|
overridevirtual |
Mouse buttons for text editors: caret placement, selection, drag-drop.
Implements tachyon::ITextSystem.
|
overridevirtual |
Mouse wheel input for text editors.
Implements tachyon::ITextSystem.
|
overridevirtual |
IME composition (pre-edit) text, UTF-8, shown but not yet committed; empty when composing ends.
cursor is the caret's codepoint offset within it. Committed text still arrives as KeyChar.
Implements tachyon::IPlatformInputHandler.
The focused text field changed (GUIStateManager::TextEditorFocus): commit from (ID::Invalid if none) and move the editor to to (ID::Invalid: no editor).
Implements tachyon::ITextSystem.
|
inlineoverridevirtual |
Where committed text edits go as undo steps (none: not recorded).
Implements tachyon::ITextSystem.
| ID tachyon::SkribidiTextSystem::ActiveElementID | ( | ) | const |
The field the editor holds: the text focus as of the last switch.
|
overridevirtual |
True when the editor elementId inserts tabs (TextEditBehavior::AcceptTabs).
Implements tachyon::ITextSystem.
|
overridevirtual |
True when elementId registered editable text this frame.
Implements tachyon::ITextSystem.
|
overridevirtual |
Selects all text of the editor elementId the next time it renders.
Implements tachyon::ITextSystem.
|
overridevirtual |
Takes the pending edit of textId: the edited text goes to outText, the result says whether it changed or was committed.
Implements tachyon::ITextSystem.
|
overridevirtual |
Replaces the text of textId; true when it changed.
Implements tachyon::ITextSystem.
|
overridevirtual |
The active editor's selected text.
Implements tachyon::ITextSystem.
|
overridevirtual |
Removes the active editor's selected text and returns it.
Implements tachyon::ITextSystem.
|
overridevirtual |
Inserts Text into the active editor at the caret, replacing the selection.
Implements tachyon::ITextSystem.
|
overridevirtual |
True when the screen point screenSpace is over selected text in textEditorId.
Implements tachyon::ITextSystem.
|
overridevirtual |
The mouse cursor to show while text is dragged; true when it overrides the hover cursor.
Implements tachyon::ITextSystem.
|
overridevirtual |
While text is dragged, sets outTargetId to the drop target under the cursor (ID::Invalid if none) and returns true.
False when no text drag is in progress.
Implements tachyon::ITextSystem.
|
overridevirtual |
Drops every registered text and the live editor; earlier TextIDs become invalid.
The focused field keeps its focus. Call when the styles are reloaded.
Implements tachyon::ITextSystem.
| size_t tachyon::SkribidiTextSystem::RegisteredTextCount | ( | ) | const |
Number of registered texts held, for diagnostics.
| uint64_t tachyon::SkribidiTextSystem::LayoutsMade | ( | ) | const |
Number of text layouts made so far, for diagnostics.
|
overridevirtual |
Asks for the caret of textEditorId to be scrolled into view; editor input calls it when the caret moves.
Doesn't scroll: whoever scrolls takes the request with GetCursorRect.
Implements tachyon::ITextSystem.
|
overridevirtual |
Takes a pending EnsureCursorVisible request for textEditorId and returns the caret rect, relative to the editor's inner rect.
Empty when none is pending for it.
Implements tachyon::ITextSystem.
|
overridevirtual |
The active editor's caret in absolute screen coordinates (through any zoom/pan), to place the IME candidate window.
Empty when no editor is active.
Implements tachyon::ITextSystem.
|
overridevirtual |
Registers Text as editable by elementId; wasModified is set when an edit changed it.
validator limits what can be typed, pasted or dropped in; it must outlive the field.
Implements tachyon::ITextSystem.
|
overridevirtual |
The text the focused field elementId edits, kept while it has the focus (its value isn't formatted again under the typing); null when it doesn't have it.
started is set when the focus just arrived: fill it from the value then.
Implements tachyon::ITextSystem.
|
overridevirtual |
Draw a registered text in color instead of its style's text color, until it is registered again (call after each registration, e.g.
for a NaN value).
Implements tachyon::ITextSystem.
|
overridevirtual |
The text caret's color (the theme's –caret). Set again after the style manager is cleared.
Implements tachyon::ITextSystem.
|
overridevirtual |
Where the built-in fonts are (default "fonts", relative to the working directory): Inter for text and JetBrains Mono for monospace.
Empty loads none, for an app that registers its own. Initialize fails when they are set but missing. Call before Initialize.
Implements tachyon::ITextSystem.
|
overridevirtual |
Where the optional fallback fonts are: Noto, for other scripts, emoji and symbols.
Empty (the default) loads none. Only the files an app ships there are used; missing ones are skipped with a warning. Call before Initialize.
Implements tachyon::ITextSystem.
|
overridevirtual |
The default language as a BCP 47 tag ("ja", "zh-Hant", "ko"), for text whose style has no language of its own (TextStyle::language / -tachyon-language).
It picks regional letterforms, e.g. Japanese kanji vs Chinese hanzi; empty means Simplified Chinese forms. Changing it lays all text out again.
Implements tachyon::ITextSystem.
|
overridevirtual |
Registers a font family from its faces (regular, bold, italic, ...); each face's weight and style come from the file.
Returns FontIDFromName(familyName) for use in TextStyle::fontId, or FontID::Invalid if no face could be loaded. Re-registering a family name with the same faces is a no-op; other faces replace the old ones and all text is laid out again (a failed re-registration keeps the previous faces).
Implements tachyon::ITextSystem.
|
overridevirtual |
Registers static text, with an optional icon, for elementId.
Implements tachyon::ITextSystem.
|
overridevirtual |
Registers text made of runs: styled text, inline icons and links.
Implements tachyon::ITextSystem.
|
overridevirtual |
Registers rich text that renders like RegisterRichText but can also be selected and copied (the runs' text joined).
Pass TextEditBehavior::ReadOnly to block edits.
Implements tachyon::ITextSystem.
The TextID elementId registered this frame, or TextID::Invalid.
Lets an event handler find its text for hit-testing and hover.
Implements tachyon::ITextSystem.
|
overridevirtual |
The text registered as textId.
Implements tachyon::ITextSystem.
|
overridevirtual |
The unwrapped measurement of textId, in pixels; cached until its text or style changes.
Implements tachyon::ITextSystem.
|
overridevirtual |
How high textId's text is unwrapped, in pixels, without the icon it was registered with (which its measurement has in it).
Implements tachyon::ITextSystem.
|
overridevirtual |
The measurement of textId wrapped to wrapContext.maxWidth, in pixels.
Implements tachyon::ITextSystem.
|
overridevirtual |
Draws textId into rect (renderer space, window-local), clipped to clipRect.
rect can be larger than innerRect when the element scrolls its text. innerRect is the visible content area in absolute layout coordinates (the element's ElementRect::innerRect); mouse positions are hit-tested against it after mapping them with screenToLayout, the inverse of any ancestor zoom/pan.
Implements tachyon::ITextSystem.
|
overridevirtual |
The cursor of the link at (localX, localY), element-local (its LinkStyle::cursor); none when there's no link there.
Implements tachyon::ITextSystem.
|
overridevirtual |
The contentId of the run at (localX, localY), element-local; 0 if none.
Implements tachyon::ITextSystem.
|
overridevirtual |
Sets the hovered run of textId (by contentId), drawn in its hover style; 0 for none.
Implements tachyon::ITextSystem.
|
overridevirtual |
True when iconId is a registered icon.
Implements tachyon::ITextSystem.
|
overridevirtual |
Registers an icon from SVG data under a unique name.
Registering a name again returns the existing icon.
Implements tachyon::ITextSystem.
|
overridevirtual |
Registers an icon from an SVG file, named by its path.
IconID::Invalid if the file is missing, unreadable or doesn't parse.
Implements tachyon::ITextSystem.
|
overridevirtual |
Registers an icon from size.x x size.y RGBA pixels (straight alpha, rows from the top) under a unique name: a picture in its own colors, drawn untinted.
Registering a name again returns the existing icon. Each takes one of the image slots shared with fonts, gradients and images. IconID::Invalid if rgba is too short.
Implements tachyon::ITextSystem.
|
overridevirtual |
Lets go of an icon from RegisterIconFromPixels: its image slot is freed, the ID draws nothing from then on and isn't given out again, and its name can be registered anew.
Does nothing for other icons.
Implements tachyon::ITextSystem.
|
overridevirtual |
The natural size of iconId, in pixels (same as MeasureIcon).
Implements tachyon::ITextSystem.
|
overridevirtual |
The natural size of iconId, in pixels.
Implements tachyon::ITextSystem.
|
overridevirtual |
Draws iconId fitted into rect (aspect kept, centered), clipped to clipRect.
Single-color icons are drawn in tint, like text; colored icons keep their colors. shadows (a text style's textShadows, the first on top) are drawn under it.
Implements tachyon::ITextSystem.
|
static |
|
inline |